From b98b2b70a54c084bdc94b38f91270c9b67b4d813 Mon Sep 17 00:00:00 2001 From: nils Date: Sun, 11 Apr 2010 10:58:49 +0000 Subject: key mgmt position and size is saved (if it is wished) git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@294 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- gpgwin.cpp | 20 +++++++++++++------- keymgmt.cpp | 25 +++++++++++++++++++++++++ keymgmt.h | 3 +++ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/gpgwin.cpp b/gpgwin.cpp index 6656fea..8f43d0b 100644 --- a/gpgwin.cpp +++ b/gpgwin.cpp @@ -65,6 +65,9 @@ void GpgWin::restoreSettings() QSettings settings; //restoreGeometry(settings.value("window/geometry").toByteArray()); + // state sets pos & size of dock-widgets + this->restoreState(settings.value("window/windowState").toByteArray()); + // Restore window size & location Qt::CheckState windowSave = static_cast(settings.value("window/windowSave", Qt::Unchecked).toUInt()); if (windowSave == Qt::Checked) { @@ -84,10 +87,6 @@ void GpgWin::restoreSettings() // Iconstyle Qt::ToolButtonStyle buttonStyle = static_cast(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt()); this->setToolButtonStyle(buttonStyle); - // state sets pos & size of dock-widgets - settings.sync(); - this->restoreState(settings.value("window/windowState").toByteArray()); - } void GpgWin::createActions() @@ -291,7 +290,6 @@ void GpgWin::createDockWindows() dock->setWidget(mAttachments);*/ } - void GpgWin::closeEvent(QCloseEvent *event) { if (maybeSave()) { @@ -512,7 +510,7 @@ void GpgWin::openKeyManagement() { if (!keyMgmt) { keyMgmt = new KeyMgmt(mCtx, iconPath); - keyMgmt->resize(800, 400); +// keyMgmt->resize(800, 400); } keyMgmt->show(); keyMgmt->raise(); @@ -577,6 +575,14 @@ void GpgWin::fileEncryption() } void GpgWin::openSettingsDialog() { + QSettings settings; new SettingsDialog(); - restoreSettings(); +// restoreSettings(); + // Iconsize + QSize iconSize = settings.value("toolbar/iconsize", QSize(32, 32)).toSize(); + this->setIconSize(iconSize); + + // Iconstyle + Qt::ToolButtonStyle buttonStyle = static_cast(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt()); + this->setToolButtonStyle(buttonStyle); } diff --git a/keymgmt.cpp b/keymgmt.cpp index f4a33fb..a7b7b21 100755 --- a/keymgmt.cpp +++ b/keymgmt.cpp @@ -48,6 +48,20 @@ KeyMgmt::KeyMgmt(GpgME::Context *ctx, QString iconpath) this->setIconSize(iconSize); this->setToolButtonStyle(buttonStyle); + // state sets pos & size of dock-widgets + this->restoreState(settings.value("keymgmt/windowState").toByteArray()); + + // Restore window size & location + Qt::CheckState windowSave = static_cast(settings.value("window/windowSave", Qt::Unchecked).toUInt()); + if (windowSave == Qt::Checked) { + QPoint pos = settings.value("keymgmt/pos", QPoint(100, 100)).toPoint(); + QSize size = settings.value("keymgmt/size", QSize(800, 450)).toSize(); + this->resize(size); + this->move(pos); + } else { + this->resize(QSize(800,400)); + } + setWindowTitle(tr("Keymanagement")); mKeyList->addMenuAction(deleteSelectedKeysAct); mKeyList->addMenuAction(showKeyDetailsAct); @@ -426,3 +440,14 @@ int KeyMgmt::checkPassWordStrength() return strength; } + +void KeyMgmt::closeEvent(QCloseEvent *event) +{ + QSettings settings; + //settings.setValue("geometry", saveGeometry()); + settings.setValue("keymgmt/windowState", saveState()); + settings.setValue("keymgmt/pos", pos()); + settings.setValue("keymgmt/size", size()); + + QMainWindow::closeEvent(event); +} diff --git a/keymgmt.h b/keymgmt.h index e0ad8fa..a99562c 100755 --- a/keymgmt.h +++ b/keymgmt.h @@ -111,6 +111,9 @@ private: QDateTimeEdit *dateEdit; QCheckBox *expireCheckBox; QSlider *pwStrengthSlider; + +protected: + void closeEvent(QCloseEvent *event); }; #endif // __KEYMGMT_H__ -- cgit v1.2.3