From 6aa94afa6d439058b9568637edd9c7eae2f9d0b7 Mon Sep 17 00:00:00 2001 From: ubbo Date: Tue, 25 Oct 2011 08:32:07 +0000 Subject: destroy attachmentdok if option parsemime not set, make sure only one attachmentdok gets created git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@575 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- gpgwin.cpp | 20 ++++++++++++++++++-- gpgwin.h | 6 ++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gpgwin.cpp b/gpgwin.cpp index a86f6a1..dac830d 100644 --- a/gpgwin.cpp +++ b/gpgwin.cpp @@ -39,7 +39,7 @@ GpgWin::GpgWin() mKeyList = new KeyList(mCtx, iconPath); /* List of binary Attachments */ - mAttachments = new Attachments(iconPath); + attachmentDockCreated = false; keyMgmt = new KeyMgmt(mCtx, iconPath); keyMgmt->hide(); @@ -448,14 +448,28 @@ void GpgWin::createDockWindows() } void GpgWin::createAttachmentDock() { + if (attachmentDockCreated) { + return; + } + mAttachments = new Attachments(iconPath); attachmentDock = new QDockWidget(tr("Attached files:"), this); attachmentDock->setObjectName("AttachmentDock"); attachmentDock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); addDockWidget(Qt::BottomDockWidgetArea, attachmentDock); attachmentDock->setWidget(mAttachments); // hide till attachment is decrypted - // viewMenu->addAction(attachmentDock->toggleViewAction()); + viewMenu->addAction(attachmentDock->toggleViewAction()); attachmentDock->hide(); + attachmentDockCreated = true; +} + +void GpgWin::closeAttachmentDock() { + if (!attachmentDockCreated) { + return; + } + attachmentDock->close(); + attachmentDock->deleteLater(); + attachmentDockCreated = false; } void GpgWin::closeEvent(QCloseEvent *event) @@ -754,6 +768,8 @@ void GpgWin::openSettingsDialog() if(settings.value("mime/parseMime").toBool()) { createAttachmentDock(); + } else if(attachmentDockCreated) { + closeAttachmentDock(); } } diff --git a/gpgwin.h b/gpgwin.h index 1cfc385..a46094a 100644 --- a/gpgwin.h +++ b/gpgwin.h @@ -196,6 +196,11 @@ private: */ void createAttachmentDock(); + /** + * @details close attachment-dockwindow. + */ + void closeAttachmentDock(); + /** * @details Load settings from ini-file. */ @@ -283,6 +288,7 @@ private: QString iconPath; /**< TODO */ KeyMgmt *keyMgmt; /**< TODO */ KeyServerImportDialog *importDialog; /**< TODO */ + bool attachmentDockCreated; }; #endif // __GPGWIN_H__ -- cgit v1.2.3