diff options
-rw-r--r-- | attachments.cpp | 1 | ||||
-rw-r--r-- | gpg4usb.pro | 4 | ||||
-rw-r--r-- | gpgwin.cpp | 3 | ||||
-rw-r--r-- | main.cpp | 2 | ||||
-rwxr-xr-x | settingsdialog.cpp | 207 | ||||
-rwxr-xr-x | 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 \ @@ -69,7 +69,6 @@ GpgWin::GpgWin() loadFile(args[1]); } } -qDebug() << QLibraryInfo::location(QLibraryInfo::TranslationsPath); } void GpgWin::restoreSettings() @@ -515,7 +514,7 @@ void GpgWin::about() "<b>Developer:</b><br>" "Bene, Heimer, Juergen, Nils, Ubbo<br><br>" "<b>Translation:</b><br>" - "Alessandro (pt_br), Alex (fr), Kirill (ru), Viriato (es)<br><br>" + "Alessandro (pt_br), Alex (fr), Kirill (ru), Viriato (es), Serse (it) <br><br>" "If you have any questions and/or<br>" "suggestions, contact us at<br>" "gpg4usb at cpunk.de</a><br><br>" @@ -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<QString, QString> GeneralTab::listLanguages() @@ -184,6 +227,39 @@ QHash<QString, QString> 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<QString, QString> 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<QString, QString> 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<QString, QString> 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<QString, QString> SettingsDialog::listLanguages() -{ - QHash<QString, QString> 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<QString, QString> lang; + private slots: QHash<QString, QString> 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<QString, QString> lang; - - QHBoxLayout *iconSizeBoxLayout; - QHBoxLayout *iconStyleBoxLayout; - QHBoxLayout *windowSizeBoxLayout; - QHBoxLayout *saveCheckedKeysBoxLayout; - QHBoxLayout *rememberPasswordBoxLayout; - QVBoxLayout *mimeParseBoxLayout; QVBoxLayout *vbox; - void setSettings(); - - -private slots: - void applySettings(); - - QHash<QString, QString> listLanguages(); }; #endif // __SETTINGSDIALOG_H__ |