diff options
Diffstat (limited to '')
-rwxr-xr-x | src/settingsdialog.cpp | 366 |
1 files changed, 177 insertions, 189 deletions
diff --git a/src/settingsdialog.cpp b/src/settingsdialog.cpp index a99b832b..212287d9 100755 --- a/src/settingsdialog.cpp +++ b/src/settingsdialog.cpp @@ -22,9 +22,8 @@ #include "settingsdialog.h" SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent) - : QDialog(parent) -{ - mCtx=ctx; + : QDialog(parent) { + mCtx = ctx; tabWidget = new QTabWidget; generalTab = new GeneralTab(mCtx); appearanceTab = new AppearanceTab; @@ -46,7 +45,7 @@ SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent) connect(buttonBox, SIGNAL(accepted()), this, SLOT(slotAccept())); connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject())); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(tabWidget); mainLayout->addWidget(buttonBox); setLayout(mainLayout); @@ -63,21 +62,18 @@ SettingsDialog::SettingsDialog(GpgME::GpgContext *ctx, QWidget *parent) connect(this, SIGNAL(signalRestartNeeded(bool)), parent, SLOT(slotSetRestartNeeded(bool))); - exec(); + exec(); } -bool SettingsDialog::getRestartNeeded() -{ +bool SettingsDialog::getRestartNeeded() const { return this->restartNeeded; } -void SettingsDialog::slotSetRestartNeeded(bool needed) -{ +void SettingsDialog::slotSetRestartNeeded(bool needed) { this->restartNeeded = needed; } -void SettingsDialog::slotAccept() -{ +void SettingsDialog::slotAccept() { generalTab->applySettings(); mimeTab->applySettings(); appearanceTab->applySettings(); @@ -92,8 +88,7 @@ void SettingsDialog::slotAccept() // http://www.informit.com/articles/article.aspx?p=1405555&seqNum=3 // http://developer.qt.nokia.com/wiki/How_to_create_a_multi_language_application -QHash<QString, QString> SettingsDialog::listLanguages() -{ +QHash<QString, QString> SettingsDialog::listLanguages() { QHash<QString, QString> languages; languages.insert("", tr("System Default")); @@ -110,28 +105,27 @@ QHash<QString, QString> SettingsDialog::listLanguages() // this works in qt 4.8 QLocale qloc(locale); - #if QT_VERSION < 0x040800 - QString language = QLocale::languageToString(qloc.language()) +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; - #else - QString language = qloc.nativeLanguageName() +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; - #endif +#if QT_VERSION < 0x040800 + QString language = QLocale::languageToString(qloc.language()) +" (" + locale + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; +#else + QString language = qloc.nativeLanguageName() + " (" + locale + + ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")"; +#endif languages.insert(locale, language); } return languages; } - -GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent) - : QWidget(parent) -{ - mCtx=ctx; +GeneralTab::GeneralTab(GpgME::GpgContext *ctx, QWidget *parent) + : QWidget(parent) { + mCtx = ctx; /***************************************** * remember Password-Box *****************************************/ - QGroupBox *rememberPasswordBox = new QGroupBox(tr("Remember Password")); - QHBoxLayout *rememberPasswordBoxLayout = new QHBoxLayout(); + auto *rememberPasswordBox = new QGroupBox(tr("Remember Password")); + auto *rememberPasswordBoxLayout = new QHBoxLayout(); rememberPasswordCheckBox = new QCheckBox(tr("Remember password until closing gpg4usb"), this); rememberPasswordBoxLayout->addWidget(rememberPasswordCheckBox); rememberPasswordBox->setLayout(rememberPasswordBoxLayout); @@ -139,43 +133,45 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent) /***************************************** * Save-Checked-Keys-Box *****************************************/ - QGroupBox *saveCheckedKeysBox = new QGroupBox(tr("Save Checked Keys")); - QHBoxLayout *saveCheckedKeysBoxLayout = new QHBoxLayout(); - saveCheckedKeysCheckBox = new QCheckBox(tr("Save checked private keys on exit and restore them on next start."), this); + auto *saveCheckedKeysBox = new QGroupBox(tr("Save Checked Keys")); + auto *saveCheckedKeysBoxLayout = new QHBoxLayout(); + saveCheckedKeysCheckBox = new QCheckBox(tr("Save checked private keys on exit and restore them on next start."), + this); saveCheckedKeysBoxLayout->addWidget(saveCheckedKeysCheckBox); saveCheckedKeysBox->setLayout(saveCheckedKeysBoxLayout); /***************************************** * Key-Impport-Confirmation Box *****************************************/ - QGroupBox *importConfirmationBox = new QGroupBox(tr("Confirm drag'n'drop key import")); - QHBoxLayout *importConfirmationBoxLayout = new QHBoxLayout(); - importConfirmationCheckBox= new QCheckBox(tr("Import files dropped on the keylist without confirmation."), this); + auto *importConfirmationBox = new QGroupBox(tr("Confirm drag'n'drop key import")); + auto *importConfirmationBoxLayout = new QHBoxLayout(); + importConfirmationCheckBox = new QCheckBox(tr("Import files dropped on the keylist without confirmation."), this); importConfirmationBoxLayout->addWidget(importConfirmationCheckBox); importConfirmationBox->setLayout(importConfirmationBoxLayout); /***************************************** * Language Select Box *****************************************/ - QGroupBox *langBox = new QGroupBox(tr("Language")); - QVBoxLayout *langBoxLayout = new QVBoxLayout(); + auto *langBox = new QGroupBox(tr("Language")); + auto *langBoxLayout = new QVBoxLayout(); langSelectBox = new QComboBox; lang = SettingsDialog::listLanguages(); - foreach(QString l , lang) { - langSelectBox->addItem(l); - } + foreach(QString l, lang) { + langSelectBox->addItem(l); + } langBoxLayout->addWidget(langSelectBox); - langBoxLayout->addWidget(new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the language!"))); + langBoxLayout->addWidget( + new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the language!"))); langBox->setLayout(langBoxLayout); - connect(langSelectBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotLanguageChanged())); + connect(langSelectBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotLanguageChanged())); /***************************************** * Own Key Select Box *****************************************/ - QGroupBox *ownKeyBox = new QGroupBox(tr("Own key")); - QVBoxLayout *ownKeyBoxLayout = new QVBoxLayout(); + auto *ownKeyBox = new QGroupBox(tr("Own key")); + auto *ownKeyBoxLayout = new QVBoxLayout(); ownKeySelectBox = new QComboBox; ownKeyBox->setLayout(ownKeyBoxLayout); @@ -184,21 +180,21 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent) // Fill the keyid hashmap keyIds.insert("", tr("<none>")); - foreach (QString keyid, *mKeyList->getAllPrivateKeys()) { - gpgme_key_t key = mCtx->getKeyDetails(keyid); - QString newKey = " (" + keyid + ")"; - if (! QString(key->uids->email).isEmpty()) { - newKey.prepend( " <"+ QString::fromUtf8(key->uids->email) +">"); + foreach (QString keyid, *mKeyList->getAllPrivateKeys()) { + gpgme_key_t key = mCtx->getKeyDetails(keyid); + QString newKey = " (" + keyid + ")"; + if (!QString(key->uids->email).isEmpty()) { + newKey.prepend(" <" + QString::fromUtf8(key->uids->email) + ">"); + } + if (!QString(key->uids->name).isEmpty()) { + newKey.prepend(" " + QString::fromUtf8(key->uids->name)); + } + keyIds.insert(key->uids->uid, newKey); } - if (! QString(key->uids->name).isEmpty()) { - newKey.prepend( " "+ QString::fromUtf8(key->uids->name)); + foreach(QString k, keyIds) { + ownKeySelectBox->addItem(k); } - keyIds.insert(key->uids->uid, newKey); - } - foreach(QString k , keyIds) { - ownKeySelectBox->addItem(k); - } - connect(ownKeySelectBox,SIGNAL(currentIndexChanged(int)),this,SLOT(slotOwnKeyIdChanged())); + connect(ownKeySelectBox, SIGNAL(currentIndexChanged(int)), this, SLOT(slotOwnKeyIdChanged())); ownKeyBoxLayout->addWidget(new QLabel(tr("Encrypt all messages additionally to the chosen key:"))); ownKeyBoxLayout->addWidget(ownKeySelectBox); @@ -206,7 +202,7 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent) /***************************************** * Mainlayout *****************************************/ - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(rememberPasswordBox); mainLayout->addWidget(saveCheckedKeysBox); mainLayout->addWidget(importConfirmationBox); @@ -223,8 +219,7 @@ GeneralTab::GeneralTab(GpgME::GpgContext *ctx,QWidget *parent) * and set the buttons and checkboxes * appropriately **********************************/ -void GeneralTab::setSettings() -{ +void GeneralTab::setSettings() { QSettings settings; // Keysaving if (settings.value("keys/keySave").toBool()) { @@ -246,14 +241,13 @@ void GeneralTab::setSettings() // Get own key information from keydb/gpg.conf (if contained) QFile gpgConfFile(qApp->applicationDirPath() + "/keydb/gpg.conf"); gpgConfFile.open(QFile::ReadOnly); - while (!gpgConfFile.atEnd()) - { + while (!gpgConfFile.atEnd()) { QString line = gpgConfFile.readLine(); - if (line.startsWith("recipient")){ + if (line.startsWith("recipient")) { QStringList args; // get key id from gpg.conf - args=line.split(" "); + args = line.split(" "); ownKeyId = args.at(1); // remove linebreak at end of id ownKeyId.remove("\n"); @@ -267,7 +261,7 @@ void GeneralTab::setSettings() ownKeySelectBox->setCurrentIndex(ownKeySelectBox->findText(ownKeyId, Qt::MatchContains)); } - if (settings.value("general/confirmImportKeys",Qt::Checked).toBool()){ + if (settings.value("general/confirmImportKeys", Qt::Checked).toBool()) { importConfirmationCheckBox->setCheckState(Qt::Checked); } } @@ -276,8 +270,7 @@ void GeneralTab::setSettings() * get the values of the buttons and * write them to settings-file *************************************/ -void GeneralTab::applySettings() -{ +void GeneralTab::applySettings() { QSettings settings; settings.setValue("keys/keySave", saveCheckedKeysCheckBox->isChecked()); // TODO: clear passwordCache instantly on unset rememberPassword @@ -286,13 +279,11 @@ void GeneralTab::applySettings() settings.setValue("general/confirmImportKeys", importConfirmationCheckBox->isChecked()); } -void GeneralTab::slotLanguageChanged() -{ +void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); } -void GeneralTab::slotOwnKeyIdChanged() -{ +void GeneralTab::slotOwnKeyIdChanged() { // Set ownKeyId to currently selected QHashIterator<QString, QString> i(keyIds); @@ -312,8 +303,7 @@ void GeneralTab::slotOwnKeyIdChanged() gpgConfTempFile.open(QFile::WriteOnly); // remove line with the hidden-encrypt-to - while (!gpgConfFile.atEnd()) - { + while (!gpgConfFile.atEnd()) { QByteArray line = gpgConfFile.readLine(); if (!line.startsWith("recipient")) { gpgConfTempFile.write(line); @@ -333,35 +323,34 @@ void GeneralTab::slotOwnKeyIdChanged() // move the temporary gpg.conffile to the actual one gpgConfFile.remove(); - gpgConfTempFile.copy(gpgConfTempFile.fileName(),gpgConfFile.fileName()); + QFile::copy(gpgConfTempFile.fileName(), gpgConfFile.fileName()); gpgConfTempFile.remove(); } MimeTab::MimeTab(QWidget *parent) - : QWidget(parent) -{ + : QWidget(parent) { /***************************************** * MIME-Parsing-Box *****************************************/ - QGroupBox *mimeQPBox = new QGroupBox(tr("Decode quoted printable")); - QVBoxLayout *mimeQPBoxLayout = new QVBoxLayout(); + auto *mimeQPBox = new QGroupBox(tr("Decode quoted printable")); + auto *mimeQPBoxLayout = new QVBoxLayout(); mimeQPCheckBox = new QCheckBox(tr("Try to recognize quoted printable."), this); mimeQPBoxLayout->addWidget(mimeQPCheckBox); mimeQPBox->setLayout(mimeQPBoxLayout); - QGroupBox *mimeParseBox = new QGroupBox(tr("Parse PGP/MIME (Experimental)")); - QVBoxLayout *mimeParseBoxLayout = new QVBoxLayout(); + auto *mimeParseBox = new QGroupBox(tr("Parse PGP/MIME (Experimental)")); + auto *mimeParseBoxLayout = new QVBoxLayout(); mimeParseCheckBox = new QCheckBox(tr("Try to split attachments from PGP-MIME ecrypted messages."), this); mimeParseBoxLayout->addWidget(mimeParseCheckBox); mimeParseBox->setLayout(mimeParseBoxLayout); - QGroupBox *mimeOpenAttachmentBox = new QGroupBox(tr("Open with external application (Experimental)")); - QVBoxLayout *mimeOpenAttachmentBoxLayout = new QVBoxLayout(); - QLabel *mimeOpenAttachmentText = new QLabel(tr("Open attachments with default application for the filetype.<br> " - "There are at least two possible problems with this behaviour:" - "<ol><li>File needs to be saved unencrypted to attachments folder.<br> " - "Its your job to clean this folder.</li>" - "<li>The external application may have its own temp files.</li></ol>")); + auto *mimeOpenAttachmentBox = new QGroupBox(tr("Open with external application (Experimental)")); + auto *mimeOpenAttachmentBoxLayout = new QVBoxLayout(); + auto *mimeOpenAttachmentText = new QLabel(tr("Open attachments with default application for the filetype.<br> " + "There are at least two possible problems with this behaviour:" + "<ol><li>File needs to be saved unencrypted to attachments folder.<br> " + "Its your job to clean this folder.</li>" + "<li>The external application may have its own temp files.</li></ol>")); //mimeOpenAttachmentBox->setDisabled(true); mimeOpenAttachmentCheckBox = new QCheckBox(tr("Enable opening with external applications."), this); @@ -370,7 +359,7 @@ MimeTab::MimeTab(QWidget *parent) mimeOpenAttachmentBoxLayout->addWidget(mimeOpenAttachmentCheckBox); mimeOpenAttachmentBox->setLayout(mimeOpenAttachmentBoxLayout); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(mimeParseBox); mainLayout->addWidget(mimeOpenAttachmentBox); mainLayout->addWidget(mimeQPBox); @@ -384,15 +373,14 @@ MimeTab::MimeTab(QWidget *parent) * and set the buttons and checkboxes * appropriately **********************************/ -void MimeTab::setSettings() -{ +void MimeTab::setSettings() { QSettings settings; // MIME-Parsing if (settings.value("mime/parsemime").toBool()) mimeParseCheckBox->setCheckState(Qt::Checked); // Qouted Printable - if (settings.value("mime/parseQP",true).toBool()) mimeQPCheckBox->setCheckState(Qt::Checked); + if (settings.value("mime/parseQP", true).toBool()) mimeQPCheckBox->setCheckState(Qt::Checked); // Open Attachments with external app if (settings.value("mime/openAttachment").toBool()) mimeOpenAttachmentCheckBox->setCheckState(Qt::Checked); @@ -403,22 +391,20 @@ void MimeTab::setSettings() * get the values of the buttons and * write them to settings-file *************************************/ -void MimeTab::applySettings() -{ +void MimeTab::applySettings() { QSettings settings; - settings.setValue("mime/parsemime" , mimeParseCheckBox->isChecked()); - settings.setValue("mime/parseQP" , mimeQPCheckBox->isChecked()); - settings.setValue("mime/openAttachment" , mimeOpenAttachmentCheckBox->isChecked()); + settings.setValue("mime/parsemime", mimeParseCheckBox->isChecked()); + settings.setValue("mime/parseQP", mimeQPCheckBox->isChecked()); + settings.setValue("mime/openAttachment", mimeOpenAttachmentCheckBox->isChecked()); } AppearanceTab::AppearanceTab(QWidget *parent) - : QWidget(parent) -{ + : QWidget(parent) { /***************************************** * Icon-Size-Box *****************************************/ - QGroupBox *iconSizeBox = new QGroupBox(tr("Iconsize")); + auto *iconSizeBox = new QGroupBox(tr("Iconsize")); iconSizeGroup = new QButtonGroup(); iconSizeSmall = new QRadioButton(tr("small")); iconSizeMedium = new QRadioButton(tr("medium")); @@ -428,7 +414,7 @@ AppearanceTab::AppearanceTab(QWidget *parent) iconSizeGroup->addButton(iconSizeMedium, 2); iconSizeGroup->addButton(iconSizeLarge, 3); - QHBoxLayout *iconSizeBoxLayout = new QHBoxLayout(); + auto *iconSizeBoxLayout = new QHBoxLayout(); iconSizeBoxLayout->addWidget(iconSizeSmall); iconSizeBoxLayout->addWidget(iconSizeMedium); iconSizeBoxLayout->addWidget(iconSizeLarge); @@ -438,7 +424,7 @@ AppearanceTab::AppearanceTab(QWidget *parent) /***************************************** * Icon-Style-Box *****************************************/ - QGroupBox *iconStyleBox = new QGroupBox(tr("Iconstyle")); + auto *iconStyleBox = new QGroupBox(tr("Iconstyle")); iconStyleGroup = new QButtonGroup(); iconTextButton = new QRadioButton(tr("just text")); iconIconsButton = new QRadioButton(tr("just icons")); @@ -448,7 +434,7 @@ AppearanceTab::AppearanceTab(QWidget *parent) iconStyleGroup->addButton(iconIconsButton, 2); iconStyleGroup->addButton(iconAllButton, 3); - QHBoxLayout *iconStyleBoxLayout = new QHBoxLayout(); + auto *iconStyleBoxLayout = new QHBoxLayout(); iconStyleBoxLayout->addWidget(iconTextButton); iconStyleBoxLayout->addWidget(iconIconsButton); iconStyleBoxLayout->addWidget(iconAllButton); @@ -458,13 +444,13 @@ AppearanceTab::AppearanceTab(QWidget *parent) /***************************************** * Window-Size-Box *****************************************/ - QGroupBox *windowSizeBox = new QGroupBox(tr("Windowstate")); - QHBoxLayout *windowSizeBoxLayout = new QHBoxLayout(); + auto *windowSizeBox = new QGroupBox(tr("Windowstate")); + auto *windowSizeBoxLayout = new QHBoxLayout(); windowSizeCheckBox = new QCheckBox(tr("Save window size and position on exit."), this); windowSizeBoxLayout->addWidget(windowSizeCheckBox); windowSizeBox->setLayout(windowSizeBoxLayout); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(iconSizeBox); mainLayout->addWidget(iconStyleBox); mainLayout->addWidget(windowSizeBox); @@ -478,31 +464,37 @@ AppearanceTab::AppearanceTab(QWidget *parent) * and set the buttons and checkboxes * appropriately **********************************/ -void AppearanceTab::setSettings() -{ +void AppearanceTab::setSettings() { QSettings settings; //Iconsize QSize iconSize = settings.value("toolbar/iconsize", QSize(24, 24)).toSize(); switch (iconSize.height()) { - case 12: iconSizeSmall->setChecked(true); - break; - case 24:iconSizeMedium->setChecked(true); - break; - case 32:iconSizeLarge->setChecked(true); - break; + case 12: + iconSizeSmall->setChecked(true); + break; + case 24: + iconSizeMedium->setChecked(true); + break; + case 32: + iconSizeLarge->setChecked(true); + break; } // Iconstyle - Qt::ToolButtonStyle iconStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon).toUInt()); + Qt::ToolButtonStyle iconStyle = static_cast<Qt::ToolButtonStyle>(settings.value("toolbar/iconstyle", + Qt::ToolButtonTextUnderIcon).toUInt()); switch (iconStyle) { - case Qt::ToolButtonTextOnly: iconTextButton->setChecked(true); - break; - case Qt::ToolButtonIconOnly:iconIconsButton->setChecked(true); - break; - case Qt::ToolButtonTextUnderIcon:iconAllButton->setChecked(true); - break; - default: - break; + case Qt::ToolButtonTextOnly: + iconTextButton->setChecked(true); + break; + case Qt::ToolButtonIconOnly: + iconIconsButton->setChecked(true); + break; + case Qt::ToolButtonTextUnderIcon: + iconAllButton->setChecked(true); + break; + default: + break; } // Window Save and Position @@ -514,46 +506,50 @@ void AppearanceTab::setSettings() * get the values of the buttons and * write them to settings-file *************************************/ -void AppearanceTab::applySettings() -{ +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; + 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; - case 2:settings.setValue("toolbar/iconstyle", Qt::ToolButtonIconOnly); - break; - case 3:settings.setValue("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon); - break; + case 1: + settings.setValue("toolbar/iconstyle", Qt::ToolButtonTextOnly); + break; + case 2: + settings.setValue("toolbar/iconstyle", Qt::ToolButtonIconOnly); + break; + case 3: + settings.setValue("toolbar/iconstyle", Qt::ToolButtonTextUnderIcon); + break; } settings.setValue("window/windowSave", windowSizeCheckBox->isChecked()); } KeyserverTab::KeyserverTab(QWidget *parent) - : QWidget(parent) -{ - QVBoxLayout *mainLayout = new QVBoxLayout(this); + : QWidget(parent) { + auto *mainLayout = new QVBoxLayout(this); - QLabel *label = new QLabel(tr("Default Keyserver for import:")); + auto *label = new QLabel(tr("Default Keyserver for import:")); comboBox = new QComboBox; comboBox->setEditable(false); comboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); - QWidget *addKeyServerBox = new QWidget(this); - QHBoxLayout *addKeyServerLayout = new QHBoxLayout(addKeyServerBox); - QLabel *http = new QLabel("http://"); + auto *addKeyServerBox = new QWidget(this); + auto *addKeyServerLayout = new QHBoxLayout(addKeyServerBox); + auto *http = new QLabel("http://"); newKeyServerEdit = new QLineEdit(this); - QPushButton *newKeyServerButton = new QPushButton(tr("Add to keyserverlist"), this); - connect(newKeyServerButton,SIGNAL(clicked()), this, SLOT(addKeyServer())); + auto *newKeyServerButton = new QPushButton(tr("Add to keyserverlist"), this); + connect(newKeyServerButton, SIGNAL(clicked()), this, SLOT(addKeyServer())); addKeyServerLayout->addWidget(http); addKeyServerLayout->addWidget(newKeyServerEdit); addKeyServerLayout->addWidget(newKeyServerButton); @@ -573,50 +569,47 @@ KeyserverTab::KeyserverTab(QWidget *parent) * and set the buttons and checkboxes * appropriately **********************************/ -void KeyserverTab::setSettings() -{ +void KeyserverTab::setSettings() { QSettings settings; QString defKeyserver = settings.value("keyserver/defaultKeyServer").toString(); - QStringList *keyServerList = new QStringList(); - for(int i=0; i < comboBox->count(); i++) { + auto *keyServerList = new QStringList(); + for (int i = 0; i < comboBox->count(); i++) { keyServerList->append(comboBox->itemText(i)); } settings.setValue("keyserver/keyServerList", *keyServerList); } -void KeyserverTab::addKeyServer() -{ +void KeyserverTab::addKeyServer() { if (newKeyServerEdit->text().startsWith("http://")) { comboBox->addItem(newKeyServerEdit->text()); } else { - comboBox->addItem("http://" +newKeyServerEdit->text()); + comboBox->addItem("http://" + newKeyServerEdit->text()); } - comboBox->setCurrentIndex(comboBox->count()-1); + comboBox->setCurrentIndex(comboBox->count() - 1); } + /*********************************** * get the values of the buttons and * write them to settings-file *************************************/ -void KeyserverTab::applySettings() -{ +void KeyserverTab::applySettings() { QSettings settings; - settings.setValue("keyserver/defaultKeyServer",comboBox->currentText()); + settings.setValue("keyserver/defaultKeyServer", comboBox->currentText()); } AdvancedTab::AdvancedTab(QWidget *parent) - : QWidget(parent) -{ + : QWidget(parent) { /***************************************** * Steganography Box *****************************************/ - QGroupBox *steganoBox = new QGroupBox(tr("Show Steganography Options [Advanced]")); - QHBoxLayout *steganoBoxLayout = new QHBoxLayout(); - steganoCheckBox= new QCheckBox(tr("Show Steganographic Options."), this); + auto *steganoBox = new QGroupBox(tr("Show Steganography Options [Advanced]")); + auto *steganoBoxLayout = new QHBoxLayout(); + steganoCheckBox = new QCheckBox(tr("Show Steganographic Options."), this); steganoBoxLayout->addWidget(steganoCheckBox); steganoBox->setLayout(steganoBoxLayout); - QVBoxLayout *mainLayout = new QVBoxLayout; + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(steganoBox); setSettings(); mainLayout->addStretch(1); @@ -624,54 +617,52 @@ AdvancedTab::AdvancedTab(QWidget *parent) } -void AdvancedTab::setSettings() -{ +void AdvancedTab::setSettings() { QSettings settings; - if (settings.value("advanced/steganography").toBool()){ + if (settings.value("advanced/steganography").toBool()) { steganoCheckBox->setCheckState(Qt::Checked); } } -void AdvancedTab::applySettings() -{ +void AdvancedTab::applySettings() { QSettings settings; settings.setValue("advanced/steganography", steganoCheckBox->isChecked()); } GpgPathsTab::GpgPathsTab(QWidget *parent) - : QWidget(parent) -{ + : QWidget(parent) { setSettings(); /***************************************** * Keydb Box *****************************************/ - QGroupBox *keydbBox = new QGroupBox(tr("Relative path to keydb")); - QGridLayout *keydbBoxLayout = new QGridLayout(); + auto *keydbBox = new QGroupBox(tr("Relative path to keydb")); + auto *keydbBoxLayout = new QGridLayout(); // Label containing the current keydbpath relative to default keydb path - keydbLabel = new QLabel(accKeydbPath,this); + keydbLabel = new QLabel(accKeydbPath, this); - QPushButton *keydbButton = new QPushButton("Change keydb path",this); + auto *keydbButton = new QPushButton("Change keydb path", this); connect(keydbButton, SIGNAL(clicked()), this, SLOT(chooseKeydbDir())); - QPushButton *keydbDefaultButton = new QPushButton("Set keydb to default path",this); + auto *keydbDefaultButton = new QPushButton("Set keydb to default path", this); connect(keydbDefaultButton, SIGNAL(clicked()), this, SLOT(setKeydbPathToDefault())); keydbBox->setLayout(keydbBoxLayout); - keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")),1,1); - keydbBoxLayout->addWidget(keydbLabel,1,2); - keydbBoxLayout->addWidget(keydbButton,1,3); - keydbBoxLayout->addWidget(keydbDefaultButton,2,3); - keydbBoxLayout->addWidget(new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the keydb path!")),3,1,1,3); - - QVBoxLayout *mainLayout = new QVBoxLayout; + keydbBoxLayout->addWidget(new QLabel(tr("Current keydb path: ")), 1, 1); + keydbBoxLayout->addWidget(keydbLabel, 1, 2); + keydbBoxLayout->addWidget(keydbButton, 1, 3); + keydbBoxLayout->addWidget(keydbDefaultButton, 2, 3); + keydbBoxLayout->addWidget( + new QLabel(tr("<b>NOTE: </b> Gpg4usb will restart automatically if you change the keydb path!")), 3, 1, 1, + 3); + + auto *mainLayout = new QVBoxLayout; mainLayout->addWidget(keydbBox); mainLayout->addStretch(1); setLayout(mainLayout); } -QString GpgPathsTab::getRelativePath(const QString dir1,const QString dir2) -{ +QString GpgPathsTab::getRelativePath(const QString &dir1, const QString &dir2) { QDir dir(dir1); QString s; @@ -683,23 +674,21 @@ QString GpgPathsTab::getRelativePath(const QString dir1,const QString dir2) return s; } -void GpgPathsTab::setKeydbPathToDefault() -{ +void GpgPathsTab::setKeydbPathToDefault() { accKeydbPath = "."; keydbLabel->setText("."); } -QString GpgPathsTab::chooseKeydbDir() -{ - QString dir = QFileDialog::getExistingDirectory(this,tr ("Choose keydb directory"),accKeydbPath,QFileDialog::ShowDirsOnly); +QString GpgPathsTab::chooseKeydbDir() { + QString dir = QFileDialog::getExistingDirectory(this, tr("Choose keydb directory"), accKeydbPath, + QFileDialog::ShowDirsOnly); accKeydbPath = getRelativePath(defKeydbPath, dir); keydbLabel->setText(accKeydbPath); return ""; } -void GpgPathsTab::setSettings() -{ +void GpgPathsTab::setSettings() { defKeydbPath = qApp->applicationDirPath() + "/keydb"; QSettings settings; @@ -709,8 +698,7 @@ void GpgPathsTab::setSettings() } } -void GpgPathsTab::applySettings() -{ +void GpgPathsTab::applySettings() { QSettings settings; - settings.setValue("gpgpaths/keydbpath",accKeydbPath); + settings.setValue("gpgpaths/keydbpath", accKeydbPath); } |