From c9c3e5241b3b65c13b9654909df730e748b07436 Mon Sep 17 00:00:00 2001 From: nils Date: Sun, 14 Nov 2010 01:45:16 +0000 Subject: cleaned up settings dialog and bump version to 0.2.5 git-svn-id: http://cpunk.de/svn/src/gpg4usb/trunk@392 34ebc366-c3a9-4b3c-9f84-69acf7962910 --- attachments.cpp | 1 - gpg4usb.pro | 4 +- gpgwin.cpp | 3 +- main.cpp | 2 +- settingsdialog.cpp | 207 ++++++++++++++++++++++++----------------------------- settingsdialog.h | 42 +++-------- 6 files changed, 106 insertions(+), 153 deletions(-) diff --git a/attachments.cpp b/attachments.cpp index 83238d4..31a66eb 100644 --- a/attachments.cpp +++ b/attachments.cpp @@ -139,7 +139,6 @@ void Attachments::openFile() { QString attachmentDir = qApp->applicationDirPath() + "/attachments/"; //QDir p = QDir(qApp->applicationDirPath() + "/attachments/"); if(!QDir(attachmentDir).exists()) { - qDebug() << "creating " << attachmentDir; QDir().mkpath(attachmentDir); } diff --git a/gpg4usb.pro b/gpg4usb.pro index d7ad867..301f34b 100644 --- a/gpg4usb.pro +++ b/gpg4usb.pro @@ -11,8 +11,8 @@ DEPENDPATH += . INCLUDEPATH += . \ ./include -CONFIG += release static -# CONFIG += debug +# CONFIG += release static +CONFIG += debug # Input HEADERS += attachments.h \ diff --git a/gpgwin.cpp b/gpgwin.cpp index 0af48e5..da6af8a 100644 --- a/gpgwin.cpp +++ b/gpgwin.cpp @@ -69,7 +69,6 @@ GpgWin::GpgWin() loadFile(args[1]); } } -qDebug() << QLibraryInfo::location(QLibraryInfo::TranslationsPath); } void GpgWin::restoreSettings() @@ -515,7 +514,7 @@ void GpgWin::about() "Developer:
" "Bene, Heimer, Juergen, Nils, Ubbo

" "Translation:
" - "Alessandro (pt_br), Alex (fr), Kirill (ru), Viriato (es)

" + "Alessandro (pt_br), Alex (fr), Kirill (ru), Viriato (es), Serse (it)

" "If you have any questions and/or
" "suggestions, contact us at
" "gpg4usb at cpunk.de

" diff --git a/main.cpp b/main.cpp index 1453945..d0e3479 100644 --- a/main.cpp +++ b/main.cpp @@ -33,7 +33,7 @@ int main(int argc, char *argv[]) QApplication app(argc, argv); - app.setApplicationVersion("0.2.4"); + app.setApplicationVersion("0.2.5"); app.setApplicationName("gpg4usb"); // QSettings uses org-name for automatically setting path... diff --git a/settingsdialog.cpp b/settingsdialog.cpp index 209569b..522f734 100755 --- a/settingsdialog.cpp +++ b/settingsdialog.cpp @@ -65,6 +65,15 @@ class QGroupBox; exec(); } + void SettingsDialog::accept() + { + generalTab->applySettings(); + mimeTab->applySettings(); + appearanceTab->applySettings(); + close(); + } + + GeneralTab::GeneralTab(QWidget *parent) : QWidget(parent) { @@ -113,6 +122,40 @@ class QGroupBox; setLayout(mainLayout); } + /********************************** + * Read the settings from config + * and set the buttons and checkboxes + * appropriately + **********************************/ + void GeneralTab::setSettings() + { + QSettings settings; + // Keysaving + if (settings.value("keys/keySave").toBool()) saveCheckedKeysCheckBox->setCheckState(Qt::Checked); + + // Remember Password + if (settings.value("general/rememberPassword").toBool()) rememberPasswordCheckBox->setCheckState(Qt::Checked); + + //Language setting + QString langKey = settings.value("int/lang").toString(); + QString langValue = lang.value(langKey); + if (langKey != "") { + langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); + } + } + + /*********************************** + * get the values of the buttons and + * write them to settings-file + *************************************/ + void GeneralTab::applySettings() + { + QSettings settings; + settings.setValue("keys/keySave", saveCheckedKeysCheckBox->isChecked()); + // TODO: clear passwordCache instantly on unset rememberPassword + settings.setValue("general/rememberPassword", rememberPasswordCheckBox->isChecked()); + settings.setValue("int/lang", lang.key(langSelectBox->currentText())); + } // http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3 QHash GeneralTab::listLanguages() @@ -184,6 +227,39 @@ QHash GeneralTab::listLanguages() setSettings(); } + /********************************** + * Read the settings from config + * and set the buttons and checkboxes + * appropriately + **********************************/ + void MimeTab::setSettings() + { + QSettings settings; + + // MIME-Parsing + if (settings.value("mime/parsemime").toBool()) mimeParseCheckBox->setCheckState(Qt::Checked); + + // Qouted Printable + if (settings.value("mime/parseQP").toBool()) mimeQPCheckBox->setCheckState(Qt::Checked); + + // Open Attachments with external app + if (settings.value("mime/openAttachment").toBool()) mimeOpenAttachmentCheckBox->setCheckState(Qt::Checked); + } + + + /*********************************** + * get the values of the buttons and + * write them to settings-file + *************************************/ + void MimeTab::applySettings() + { + QSettings settings; + settings.setValue("mime/parsemime" , mimeParseCheckBox->isChecked()); + settings.setValue("mime/parseQP" , mimeQPCheckBox->isChecked()); + settings.setValue("mime/openAttachment" , mimeOpenAttachmentCheckBox->isChecked()); + + } + AppearanceTab::AppearanceTab(QWidget *parent) : QWidget(parent) { @@ -237,9 +313,6 @@ QHash GeneralTab::listLanguages() windowSizeBox->setLayout(windowSizeBoxLayout); QVBoxLayout *mainLayout = new QVBoxLayout; -// layout->addWidget(topLabel); -// layout->addWidget(applicationsListBox); -// layout->addWidget(alwaysCheckBox); mainLayout->addWidget(iconSizeBox); mainLayout->addWidget(iconStyleBox); mainLayout->addWidget(windowSizeBox); @@ -247,24 +320,11 @@ QHash GeneralTab::listLanguages() setLayout(mainLayout); } - void GeneralTab::setSettings() - { - QSettings settings; - // Keysaving - if (settings.value("keys/keySave").toBool()) saveCheckedKeysCheckBox->setCheckState(Qt::Checked); - - // Remember Password - if (settings.value("general/rememberPassword").toBool()) rememberPasswordCheckBox->setCheckState(Qt::Checked); - - //Language setting - QString langKey = settings.value("int/lang").toString(); - QString langValue = lang.value(langKey); - qDebug() << langKey << langValue ; - if (langKey != "") { - langSelectBox->setCurrentIndex(langSelectBox->findText(langValue)); - } - } - + /********************************** + * Read the settings from config + * and set the buttons and checkboxes + * appropriately + **********************************/ void AppearanceTab::setSettings() { QSettings settings; @@ -297,34 +357,22 @@ QHash GeneralTab::listLanguages() } - void MimeTab::setSettings() - { - QSettings settings; - - // MIME-Parsing - if (settings.value("mime/parsemime").toBool()) mimeParseCheckBox->setCheckState(Qt::Checked); - - // Qouted Printable - if (settings.value("mime/parseQP").toBool()) mimeQPCheckBox->setCheckState(Qt::Checked); - - // Open Attachments with external app - if (settings.value("mime/openAttachment").toBool()) mimeOpenAttachmentCheckBox->setCheckState(Qt::Checked); - } - - void GeneralTab::applySettings() - { - QSettings settings; - settings.setValue("keys/keySave", saveCheckedKeysCheckBox->isChecked()); - // TODO: clear passwordCache instantly on unset rememberPassword - settings.setValue("general/rememberPassword", rememberPasswordCheckBox->isChecked()); - settings.setValue("int/lang", lang.key(langSelectBox->currentText())); -qDebug() << lang.key(langSelectBox->currentText()); -foreach (QString l,lang){qDebug() << l;} - } - + /*********************************** + * get the values of the buttons and + * write them to settings-file + *************************************/ void AppearanceTab::applySettings() { QSettings settings; + switch (iconSizeGroup->checkedId()) { + case 1: settings.setValue("toolbar/iconsize", QSize(12, 12)); + break; + case 2:settings.setValue("toolbar/iconsize", QSize(24, 24)); + break; + case 3:settings.setValue("toolbar/iconsize", QSize(32, 32)); + break; + } + switch (iconStyleGroup->checkedId()) { case 1: settings.setValue("toolbar/iconstyle", Qt::ToolButtonTextOnly); break; @@ -335,76 +383,9 @@ foreach (QString l,lang){qDebug() << l;} } settings.setValue("window/windowSave", windowSizeCheckBox->isChecked()); - } - void MimeTab::applySettings() - { - QSettings settings; - settings.setValue("mime/parsemime" , mimeParseCheckBox->isChecked()); - settings.setValue("mime/parseQP" , mimeQPCheckBox->isChecked()); - settings.setValue("mime/openAttachment" , mimeOpenAttachmentCheckBox->isChecked()); - - } - - /********************************** - * Read the settings from config - * and set the buttons and checkboxes - * appropriately - **********************************/ -void SettingsDialog::setSettings() -{ - QSettings settings; - -} - -void SettingsDialog::accept() -{ - generalTab->applySettings(); - mimeTab->applySettings(); - appearanceTab->applySettings(); - close(); -} - -/*********************************** - * get the values of the buttons and - * write them to settings-file - *************************************/ -void SettingsDialog::applySettings() -{ - QSettings settings; - - - - accept(); -} - -// http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3 -QHash SettingsDialog::listLanguages() -{ - QHash languages; - - languages.insert("", tr("System Default")); - - QString appPath = qApp->applicationDirPath(); - QDir qmDir = QDir(appPath + "/ts/"); - QStringList fileNames = - qmDir.entryList(QStringList("gpg4usb_*.qm")); - - for (int i = 0; i < fileNames.size(); ++i) { - QString locale = fileNames[i]; - locale.remove(0, locale.indexOf('_') + 1); - locale.chop(3); - - QTranslator translator; - translator.load(fileNames[i], qmDir.absolutePath()); - QString language = translator.translate("SettingsDialog", - "English"); - languages.insert(locale, language); - } - return languages; -} diff --git a/settingsdialog.h b/settingsdialog.h index a43f587..5c96788 100755 --- a/settingsdialog.h +++ b/settingsdialog.h @@ -44,11 +44,13 @@ GeneralTab(QWidget *parent = 0); void setSettings(); void applySettings(); + private: QCheckBox *rememberPasswordCheckBox; QCheckBox *saveCheckedKeysCheckBox; QComboBox *langSelectBox; QHash lang; + private slots: QHash listLanguages(); @@ -62,10 +64,11 @@ private slots: MimeTab(QWidget *parent = 0); void setSettings(); void applySettings(); + + private: QCheckBox *mimeParseCheckBox; QCheckBox *mimeQPCheckBox; QCheckBox *mimeOpenAttachmentCheckBox; - }; class AppearanceTab : public QWidget @@ -77,6 +80,7 @@ private slots: AppearanceTab(QWidget *parent = 0); void setSettings(); void applySettings(); + private: QButtonGroup *iconStyleGroup; QRadioButton *iconSizeSmall; @@ -87,7 +91,6 @@ private slots: QRadioButton *iconIconsButton; QRadioButton *iconAllButton; QCheckBox *windowSizeCheckBox; - }; @@ -100,42 +103,13 @@ public: GeneralTab *generalTab; MimeTab *mimeTab; AppearanceTab *appearanceTab; + public slots: void accept(); -private: - QTabWidget *tabWidget; // new +private: + QTabWidget *tabWidget; QDialogButtonBox *buttonBox; - - - QRadioButton *iconSizeSmall; - QRadioButton *iconSizeMedium; - QRadioButton *iconSizeLarge; - QRadioButton *iconTextButton; - QRadioButton *iconIconsButton; - QRadioButton *iconAllButton; - QCheckBox *windowSizeCheckBox; - QCheckBox *saveCheckedKeysCheckBox; - QCheckBox *rememberPasswordCheckBox; - QCheckBox *mimeParseCheckBox; - QCheckBox *mimeQPCheckBox; - QCheckBox *mimeOpenAttachmentCheckBox; - QComboBox *langSelectBox; - QHash lang; - - QHBoxLayout *iconSizeBoxLayout; - QHBoxLayout *iconStyleBoxLayout; - QHBoxLayout *windowSizeBoxLayout; - QHBoxLayout *saveCheckedKeysBoxLayout; - QHBoxLayout *rememberPasswordBoxLayout; - QVBoxLayout *mimeParseBoxLayout; QVBoxLayout *vbox; - void setSettings(); - - -private slots: - void applySettings(); - - QHash listLanguages(); }; #endif // __SETTINGSDIALOG_H__ -- cgit v1.2.3