diff options
author | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2010-02-07 17:16:29 +0000 |
---|---|---|
committer | ubbo <ubbo@34ebc366-c3a9-4b3c-9f84-69acf7962910> | 2010-02-07 17:16:29 +0000 |
commit | 9f7682c3cd103379af2916ef83e4a24010ae67c4 (patch) | |
tree | 455d607b5361bd632d8df957c97d886dfa2b17a3 | |
parent | updated TODO (diff) | |
download | gpg4usb-9f7682c3cd103379af2916ef83e4a24010ae67c4.tar.gz gpg4usb-9f7682c3cd103379af2916ef83e4a24010ae67c4.zip |
experiment with QSettings, store & restore size and location of mainwindow, save settings to appplication path
git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@272 34ebc366-c3a9-4b3c-9f84-69acf7962910
-rw-r--r-- | gpgwin.cpp | 12 | ||||
-rw-r--r-- | main.cpp | 9 |
2 files changed, 19 insertions, 2 deletions
@@ -54,6 +54,14 @@ GpgWin::GpgWin() setToolButtonStyle(Qt::ToolButtonTextUnderIcon); setIconSize(QSize(32, 32)); setCurrentFile(""); + + // Restore window size & location + // TODO: is this a good idea for a portable app? screen size & resolution may vary + QSettings settings; + QPoint pos = settings.value("pos", QPoint(100, 100)).toPoint(); + QSize size = settings.value("size", QSize(800, 450)).toSize(); + resize(size); + move(pos); //mKeyList->addMenuAction(deleteSelectedKeysAct); mKeyList->addMenuAction(appendSelectedKeysAct); @@ -261,6 +269,10 @@ void GpgWin::closeEvent(QCloseEvent *event) } else { event->ignore(); } + + QSettings settings; + settings.setValue("pos", pos()); + settings.setValue("size", size()); } void GpgWin::open() @@ -35,6 +35,13 @@ int main(int argc, char *argv[]) app.setApplicationVersion("0.2.2"); app.setApplicationName("gpg4usb"); + + // QSettings uses org-name for automatically setting path... + app.setOrganizationName("conf"); + //app.setOrganizationDomain("gpg4usb.cpunk.de"); // mac uses this? + // specify default path & format for QSettings + QSettings::setPath(QSettings::IniFormat, QSettings::UserScope, qApp->applicationDirPath()); + QSettings::setDefaultFormat(QSettings::IniFormat); //internationalize QTranslator translator; @@ -43,8 +50,6 @@ int main(int argc, char *argv[]) app.installTranslator(&translator); GpgWin *window = new GpgWin(); - window->resize(800, 450); - window->show(); return app.exec(); |