From 6315d1e9371864f0ed6b3854a4b50561b062befe Mon Sep 17 00:00:00 2001 From: Anne Jan Brouwer Date: Thu, 11 Oct 2018 13:57:19 +0200 Subject: Some cleanup with help of Clang-Tidy and Clazy (part 1 of x) --- main/main.cpp | 12 ++++++------ src/configdialog.cpp | 14 +++++++------- src/executor.cpp | 5 ++--- src/qtpass.cpp | 5 +++-- src/qtpasssettings.cpp | 12 ++++++++++-- src/realpass.cpp | 4 ++-- src/util.cpp | 4 ++-- src/util.h | 2 +- tests/auto/ui/tst_ui.cpp | 14 +++++++------- tests/auto/util/tst_util.cpp | 6 +++--- 10 files changed, 43 insertions(+), 35 deletions(-) diff --git a/main/main.cpp b/main/main.cpp index 2632769d..fefe570f 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -79,13 +79,13 @@ int main(int argc, char *argv[]) { // locale = "he_IL"; // locale = "ar_MA"; translator.load(QString(":localization/localization_%1.qm").arg(locale)); - app.installTranslator(&translator); - app.setLayoutDirection(QObject::tr("LTR") == "RTL" ? Qt::RightToLeft - : Qt::LeftToRight); + SingleApplication::installTranslator(&translator); + SingleApplication::setLayoutDirection( + QObject::tr("LTR") == "RTL" ? Qt::RightToLeft : Qt::LeftToRight); MainWindow w(text); - app.setActiveWindow(&w); - app.setWindowIcon(QIcon(":artwork/icon.png")); + SingleApplication::setActiveWindow(&w); + SingleApplication::setWindowIcon(QIcon(":artwork/icon.png")); #if SINGLE_APP QObject::connect(&app, &SingleApplication::messageAvailable, &w, @@ -94,5 +94,5 @@ int main(int argc, char *argv[]) { w.show(); - return app.exec(); + return SingleApplication::exec(); } diff --git a/src/configdialog.cpp b/src/configdialog.cpp index ae07ad2c..4d126ed2 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -39,7 +39,7 @@ ConfigDialog::ConfigDialog(MainWindow *parent) ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent()); ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true)); - if (QSystemTrayIcon::isSystemTrayAvailable() == true) { + if (QSystemTrayIcon::isSystemTrayAvailable()) { ui->checkBoxHideOnClose->setChecked(QtPassSettings::isHideOnClose()); ui->checkBoxStartMinimized->setChecked(QtPassSettings::isStartMinimized()); } else { @@ -238,7 +238,7 @@ QStringList ConfigDialog::getSecretKeys() { QList keys = QtPassSettings::getPass()->listKeys("", true); QStringList names; - if (keys.size() == 0) + if (keys.empty()) return names; foreach (const UserInfo &sec, keys) @@ -266,8 +266,8 @@ QString ConfigDialog::selectExecutable() { dialog.setOption(QFileDialog::ReadOnly); if (dialog.exec()) return dialog.selectedFiles().first(); - else - return QString(); + + return QString(); } /** @@ -281,8 +281,8 @@ QString ConfigDialog::selectFolder() { dialog.setOption(QFileDialog::ShowDirsOnly); if (dialog.exec()) return dialog.selectedFiles().first(); - else - return QString(); + + return QString(); } /** @@ -615,7 +615,7 @@ void ConfigDialog::wizard() { * @param useSystray */ void ConfigDialog::useTrayIcon(bool useSystray) { - if (QSystemTrayIcon::isSystemTrayAvailable() == true) { + if (QSystemTrayIcon::isSystemTrayAvailable()) { ui->checkBoxUseTrayIcon->setChecked(useSystray); ui->checkBoxHideOnClose->setEnabled(useSystray); ui->checkBoxStartMinimized->setEnabled(useSystray); diff --git a/src/executor.cpp b/src/executor.cpp index cd20f11c..d536068c 100644 --- a/src/executor.cpp +++ b/src/executor.cpp @@ -155,10 +155,9 @@ int Executor::executeBlocking(QString app, const QStringList &args, if (process_err != Q_NULLPTR) *process_err = perr; return internal.exitCode(); - } else { - // TODO(bezet): emit error() ? - return -1; // QProcess error code + qDebug error? } + // TODO(bezet): emit error() ? + return -1; // QProcess error code + qDebug error? } /** diff --git a/src/qtpass.cpp b/src/qtpass.cpp index 2239e86d..fda99cad 100644 --- a/src/qtpass.cpp +++ b/src/qtpass.cpp @@ -23,6 +23,7 @@ QtPass::QtPass() : clippedText(QString()), freshStart(true) { if (!setup()) { // no working config so this should quit without config anything QApplication::quit(); + {} } setClipboardTimer(); @@ -273,7 +274,7 @@ void QtPass::processErrorExit(int exitCode, const QString &p_error) { output.replace( QRegExp("((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://\\S+)"), - "\\1"); + R"(\1)"); output.replace(QRegExp("\n"), "
"); m_mainWindow->flashText(output, false, true); @@ -335,7 +336,7 @@ void QtPass::showInTextBrowser(QString output, QString prefix, output.replace( QRegExp("((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://\\S+)"), - "\\1"); + R"(\1)"); output.replace(QRegExp("\n"), "
"); output = prefix + output + postfix; diff --git a/src/qtpasssettings.cpp b/src/qtpasssettings.cpp index fadb37fc..77be99ad 100644 --- a/src/qtpasssettings.cpp +++ b/src/qtpasssettings.cpp @@ -531,5 +531,13 @@ void QtPassSettings::setTemplateAllFields(const bool &templateAllFields) { templateAllFields); } -RealPass *QtPassSettings::getRealPass() { if (realPass.isNull()) realPass.reset(new RealPass()); return realPass.data(); } -ImitatePass *QtPassSettings::getImitatePass() { if (imitatePass.isNull()) imitatePass.reset(new ImitatePass()); return imitatePass.data(); } +RealPass *QtPassSettings::getRealPass() { + if (realPass.isNull()) + realPass.reset(new RealPass()); + return realPass.data(); +} +ImitatePass *QtPassSettings::getImitatePass() { + if (imitatePass.isNull()) + imitatePass.reset(new ImitatePass()); + return imitatePass.data(); +} diff --git a/src/realpass.cpp b/src/realpass.cpp index 476757ee..071f618b 100644 --- a/src/realpass.cpp +++ b/src/realpass.cpp @@ -104,7 +104,7 @@ void RealPass::Move(const QString src, const QString dest, const bool force) { // pass uses always the force mode, when call from eg. QT. so we have to check // if this are to files // and the user didnt want to move force - if (force == false && srcFileInfo.isFile() && destFileInfo.isFile()) { + if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) { return; } @@ -144,7 +144,7 @@ void RealPass::Copy(const QString src, const QString dest, const bool force) { // pass uses always the force mode, when call from eg. QT. so we have to check // if this are to files // and the user didnt want to move force - if (force == false && srcFileInfo.isFile() && destFileInfo.isFile()) { + if (!force && srcFileInfo.isFile() && destFileInfo.isFile()) { return; } diff --git a/src/util.cpp b/src/util.cpp index ac69bae7..db8478e4 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -149,9 +149,9 @@ QString Util::getDir(const QModelIndex &index, bool forPass, return filePath; } -void Util::copyDir(const QString src, const QString dest) { +void Util::copyDir(const QString &src, const QString &dest) { QDir srcDir(src); - if (srcDir.exists() == false) { + if (!srcDir.exists()) { return; } srcDir.mkpath(dest); diff --git a/src/util.h b/src/util.h index b65d7099..f0dca51f 100644 --- a/src/util.h +++ b/src/util.h @@ -21,7 +21,7 @@ public: static QString getDir(const QModelIndex &index, bool forPass, const QFileSystemModel &model, const StoreModel &storeModel); - static void copyDir(const QString src, const QString dest); + static void copyDir(const QString &src, const QString &dest); private: static void initialiseEnvironment(); diff --git a/tests/auto/ui/tst_ui.cpp b/tests/auto/ui/tst_ui.cpp index 065a2143..ae05fac7 100644 --- a/tests/auto/ui/tst_ui.cpp +++ b/tests/auto/ui/tst_ui.cpp @@ -20,40 +20,40 @@ private Q_SLOTS: */ void tst_ui::contentRemainsSame() { QScopedPointer d( - new PasswordDialog(PasswordConfiguration{}, NULL)); + new PasswordDialog(PasswordConfiguration{}, nullptr)); d->setTemplate("", false); QString input = "pw\n"; d->setPass(input); QCOMPARE(d->getPassword(), input); - d.reset(new PasswordDialog(PasswordConfiguration{}, NULL)); + d.reset(new PasswordDialog(PasswordConfiguration{}, nullptr)); input = "pw\nname: value\n"; d->setPass(input); QCOMPARE(d->getPassword(), input); - d.reset(new PasswordDialog(PasswordConfiguration{}, NULL)); + d.reset(new PasswordDialog(PasswordConfiguration{}, nullptr)); d->setTemplate("name", false); d->setPass(input); QCOMPARE(d->getPassword(), input); - d.reset(new PasswordDialog(PasswordConfiguration{}, NULL)); + d.reset(new PasswordDialog(PasswordConfiguration{}, nullptr)); d->setTemplate("name", true); d->setPass(input); QCOMPARE(d->getPassword(), input); - d.reset(new PasswordDialog(PasswordConfiguration{}, NULL)); + d.reset(new PasswordDialog(PasswordConfiguration{}, nullptr)); d->setTemplate("", false); d->templateAll(true); d->setPass(input); QCOMPARE(d->getPassword(), input); - d.reset(new PasswordDialog(PasswordConfiguration{}, NULL)); + d.reset(new PasswordDialog(PasswordConfiguration{}, nullptr)); d->setTemplate("", true); d->templateAll(true); d->setPass(input); QCOMPARE(d->getPassword(), input); - d.reset(new PasswordDialog(PasswordConfiguration{}, NULL)); + d.reset(new PasswordDialog(PasswordConfiguration{}, nullptr)); d->setTemplate("name", true); d->templateAll(true); d->setPass(input); diff --git a/tests/auto/util/tst_util.cpp b/tests/auto/util/tst_util.cpp index cce06664..ae2bd9e1 100644 --- a/tests/auto/util/tst_util.cpp +++ b/tests/auto/util/tst_util.cpp @@ -12,7 +12,7 @@ class tst_util : public QObject { public: tst_util(); - ~tst_util(); + ~tst_util() override; public Q_SLOTS: void init(); @@ -32,12 +32,12 @@ bool operator==(const NamedValue &a, const NamedValue &b) { /** * @brief tst_util::tst_util basic constructor */ -tst_util::tst_util() {} +tst_util::tst_util() = default; /** * @brief tst_util::~tst_util basic destructor */ -tst_util::~tst_util() {} +tst_util::~tst_util() = default; /** * @brief tst_util::init unit test init method -- cgit v1.2.3 From 69512ff6f286371d2846b84a809bbfbc9a7e7289 Mon Sep 17 00:00:00 2001 From: Anne Jan Brouwer Date: Fri, 12 Oct 2018 16:03:22 +0200 Subject: Some cleanup with help of Clang-Tidy and Clazy (part 2 of x) --- localization/localization_ar_MA.ts | 6 +++--- localization/localization_ca.ts | 6 +++--- localization/localization_cs_CZ.ts | 6 +++--- localization/localization_de_DE.ts | 6 +++--- localization/localization_de_LU.ts | 6 +++--- localization/localization_el_GR.ts | 6 +++--- localization/localization_en_GB.ts | 6 +++--- localization/localization_en_US.ts | 6 +++--- localization/localization_es_ES.ts | 6 +++--- localization/localization_fr_BE.ts | 6 +++--- localization/localization_fr_FR.ts | 6 +++--- localization/localization_fr_LU.ts | 6 +++--- localization/localization_gl_ES.ts | 6 +++--- localization/localization_he_IL.ts | 6 +++--- localization/localization_hu_HU.ts | 6 +++--- localization/localization_it_IT.ts | 6 +++--- localization/localization_lb_LU.ts | 6 +++--- localization/localization_nl.ts | 6 +++--- localization/localization_pl_PL.ts | 6 +++--- localization/localization_pt_PT.ts | 6 +++--- localization/localization_ru_RU.ts | 6 +++--- localization/localization_sv_SE.ts | 6 +++--- localization/localization_zh_CN.ts | 6 +++--- src/filecontent.cpp | 2 +- src/imitatepass.cpp | 2 +- src/keygendialog.cpp | 4 ++-- src/mainwindow.cpp | 10 +++++----- src/pass.cpp | 2 +- src/passworddialog.cpp | 6 +++--- src/qprogressindicator.cpp | 6 +++--- src/realpass.cpp | 2 +- src/settingsconstants.cpp | 2 +- src/storemodel.cpp | 12 ++++++------ src/trayicon.cpp | 6 +++--- src/usersdialog.cpp | 22 ++++++++++------------ 35 files changed, 106 insertions(+), 108 deletions(-) diff --git a/localization/localization_ar_MA.ts b/localization/localization_ar_MA.ts index b060c825..9129cf16 100644 --- a/localization/localization_ar_MA.ts +++ b/localization/localization_ar_MA.ts @@ -789,7 +789,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR Flips interface RTL @@ -798,7 +798,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -963,7 +963,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_ca.ts b/localization/localization_ca.ts index 448ca392..c9766d36 100644 --- a/localization/localization_ca.ts +++ b/localization/localization_ca.ts @@ -948,7 +948,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -956,7 +956,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Generació del parell de claus GPG @@ -1127,7 +1127,7 @@ Les entrades vermelles no són vàlides, no podreu xifrar. No s'ha trobat la clau a l'anell de claus - + created creada diff --git a/localization/localization_cs_CZ.ts b/localization/localization_cs_CZ.ts index 7de264e7..7a8cb012 100644 --- a/localization/localization_cs_CZ.ts +++ b/localization/localization_cs_CZ.ts @@ -926,7 +926,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -934,7 +934,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Generování páru GPG klíčů @@ -1105,7 +1105,7 @@ Modře označené záznamy poskytují tajný klíč, vyberte jeden z nich, kter Klíč nebyl v klíčence nalezen - + created vytvořen diff --git a/localization/localization_de_DE.ts b/localization/localization_de_DE.ts index 929efa1d..4b4057dd 100755 --- a/localization/localization_de_DE.ts +++ b/localization/localization_de_DE.ts @@ -916,7 +916,7 @@ Neues Passwort-Datei: QObject - + LTR LTR @@ -924,7 +924,7 @@ Neues Passwort-Datei: QtPass - + Generating GPG key pair GPG Schlüssel-Paar wird generiert @@ -1092,7 +1092,7 @@ Die roten Einträge sind ungültig / abgelaufen und für Entschlüsselung nicht Schlüssel nicht in Keyring gefunden - + created erstellt diff --git a/localization/localization_de_LU.ts b/localization/localization_de_LU.ts index db746bf8..b3943ba0 100755 --- a/localization/localization_de_LU.ts +++ b/localization/localization_de_LU.ts @@ -911,7 +911,7 @@ Neues Passwort-Datei: QObject - + LTR LTR @@ -919,7 +919,7 @@ Neues Passwort-Datei: QtPass - + Generating GPG key pair GPG Schlüssel-Paar wird generiert @@ -1087,7 +1087,7 @@ Die roten Einträge sind ungültig / abgelaufen und für Entschlüsselung nicht Schlüssel nicht in Keyring gefunden - + created erstellt diff --git a/localization/localization_el_GR.ts b/localization/localization_el_GR.ts index ac48f971..4a1b6681 100644 --- a/localization/localization_el_GR.ts +++ b/localization/localization_el_GR.ts @@ -793,7 +793,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -801,7 +801,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -966,7 +966,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_en_GB.ts b/localization/localization_en_GB.ts index febd914f..bbaaa4ed 100644 --- a/localization/localization_en_GB.ts +++ b/localization/localization_en_GB.ts @@ -959,7 +959,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -967,7 +967,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Generating GPG key pair @@ -1138,7 +1138,7 @@ Red entries are not valid, you will not be able to encrypt to these.Key not found in keyring - + created created diff --git a/localization/localization_en_US.ts b/localization/localization_en_US.ts index b0dd6dd4..45c3973a 100644 --- a/localization/localization_en_US.ts +++ b/localization/localization_en_US.ts @@ -959,7 +959,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -967,7 +967,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Generating GPG key pair @@ -1138,7 +1138,7 @@ Red entries are not valid, you will not be able to encrypt to these.Key not found in keyring - + created created diff --git a/localization/localization_es_ES.ts b/localization/localization_es_ES.ts index e88dee02..85545907 100644 --- a/localization/localization_es_ES.ts +++ b/localization/localization_es_ES.ts @@ -893,7 +893,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -901,7 +901,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Generar par de claves GPG @@ -1069,7 +1069,7 @@ Entradas rojas no son válidos, usted no será capaz de cifrar a estos.La llave no se encuentra en el llavero - + created creado diff --git a/localization/localization_fr_BE.ts b/localization/localization_fr_BE.ts index 95233ebe..e10608ec 100644 --- a/localization/localization_fr_BE.ts +++ b/localization/localization_fr_BE.ts @@ -926,7 +926,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR GAD @@ -934,7 +934,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Génération d'une paire de clés GPG @@ -1105,7 +1105,7 @@ Les entrées en rouge ne sont pas marquées comme étant de confiance dans GnuPG Clé introuvable dans le trousseau de clés - + created créé diff --git a/localization/localization_fr_FR.ts b/localization/localization_fr_FR.ts index 209dbf5e..34d3436b 100644 --- a/localization/localization_fr_FR.ts +++ b/localization/localization_fr_FR.ts @@ -958,7 +958,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR GAD @@ -966,7 +966,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Génération d'une paire de clés GPG @@ -1137,7 +1137,7 @@ Les entrées rouges ne sont pas valides, vous ne pourrez pas vous en servir pour Clé introuvable dans le trousseau de clés - + created créé diff --git a/localization/localization_fr_LU.ts b/localization/localization_fr_LU.ts index 04362213..b5b0a5d1 100644 --- a/localization/localization_fr_LU.ts +++ b/localization/localization_fr_LU.ts @@ -926,7 +926,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR GAD @@ -934,7 +934,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Génération d'une paire de clés GPG @@ -1105,7 +1105,7 @@ Les entrées en rouge ne sont pas marquées comme étant de confiance dans GnuPG Clé introuvable dans le trousseau de clés - + created créé diff --git a/localization/localization_gl_ES.ts b/localization/localization_gl_ES.ts index d5c295c4..dc545b5f 100644 --- a/localization/localization_gl_ES.ts +++ b/localization/localization_gl_ES.ts @@ -932,7 +932,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -940,7 +940,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -1105,7 +1105,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_he_IL.ts b/localization/localization_he_IL.ts index 3d12112a..5c0060e6 100644 --- a/localization/localization_he_IL.ts +++ b/localization/localization_he_IL.ts @@ -789,7 +789,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR Flips interface RTL @@ -798,7 +798,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -963,7 +963,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_hu_HU.ts b/localization/localization_hu_HU.ts index 656f8960..97e58d0b 100644 --- a/localization/localization_hu_HU.ts +++ b/localization/localization_hu_HU.ts @@ -825,7 +825,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -833,7 +833,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -998,7 +998,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_it_IT.ts b/localization/localization_it_IT.ts index 6335f2a5..ad78b5a8 100644 --- a/localization/localization_it_IT.ts +++ b/localization/localization_it_IT.ts @@ -970,7 +970,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -978,7 +978,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Generando una coppia di chiavi GPG @@ -1149,7 +1149,7 @@ Le righe rosse non sono valide, non saranno utilizzabili per cifrare.Chiave non trovata nel portachiavi - + created creato diff --git a/localization/localization_lb_LU.ts b/localization/localization_lb_LU.ts index ad0a5317..af3eed91 100644 --- a/localization/localization_lb_LU.ts +++ b/localization/localization_lb_LU.ts @@ -789,7 +789,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -797,7 +797,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -962,7 +962,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_nl.ts b/localization/localization_nl.ts index 647e7ce7..7035e8bb 100644 --- a/localization/localization_nl.ts +++ b/localization/localization_nl.ts @@ -952,7 +952,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -960,7 +960,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Nieuw GPG sleutelpaar genereren @@ -1130,7 +1130,7 @@ Rode entries zijn ongeldig, je zult niet in staat zijn om te versleutelen voor d Sleutel niet gevonden in keyring - + created aangemaakt diff --git a/localization/localization_pl_PL.ts b/localization/localization_pl_PL.ts index 74dac054..854dda00 100644 --- a/localization/localization_pl_PL.ts +++ b/localization/localization_pl_PL.ts @@ -793,7 +793,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -801,7 +801,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair @@ -966,7 +966,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + created diff --git a/localization/localization_pt_PT.ts b/localization/localization_pt_PT.ts index aed7687b..6549ad40 100644 --- a/localization/localization_pt_PT.ts +++ b/localization/localization_pt_PT.ts @@ -912,7 +912,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -920,7 +920,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Gerar par de chaves GPG @@ -1088,7 +1088,7 @@ Os elementos a vermelho não são válidos. Não será possível desencriptar ut Chave não disponível no keyring - + created criado diff --git a/localization/localization_ru_RU.ts b/localization/localization_ru_RU.ts index ffce4607..0ff4caa8 100644 --- a/localization/localization_ru_RU.ts +++ b/localization/localization_ru_RU.ts @@ -925,7 +925,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR LTR @@ -933,7 +933,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Генерирую ключевую пару GPG @@ -1102,7 +1102,7 @@ Red entries are not valid, you will not be able to encrypt to these. Ключ не найден в хранилище ключей GPG - + created создан diff --git a/localization/localization_sv_SE.ts b/localization/localization_sv_SE.ts index a0b66bf0..8f7e1af4 100644 --- a/localization/localization_sv_SE.ts +++ b/localization/localization_sv_SE.ts @@ -870,7 +870,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR @@ -878,7 +878,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair Skapar GPG nyckelpar @@ -1047,7 +1047,7 @@ Röd färg betyder att nyckeln är ogiltig. Du kan inte använda någon av dessa Kunde inte hitta nyckel i nyckelring - + created skapad diff --git a/localization/localization_zh_CN.ts b/localization/localization_zh_CN.ts index 603ce693..dd53a3ae 100644 --- a/localization/localization_zh_CN.ts +++ b/localization/localization_zh_CN.ts @@ -925,7 +925,7 @@ p, li { white-space: pre-wrap; } QObject - + LTR 从左到右 @@ -933,7 +933,7 @@ p, li { white-space: pre-wrap; } QtPass - + Generating GPG key pair 正在生成 GPG 密钥对 @@ -1104,7 +1104,7 @@ Red entries are not valid, you will not be able to encrypt to these. 所选密钥未找到 - + created 创建于 diff --git a/src/filecontent.cpp b/src/filecontent.cpp index 0e22a377..d77983c2 100644 --- a/src/filecontent.cpp +++ b/src/filecontent.cpp @@ -7,7 +7,7 @@ FileContent FileContent::parse(const QString &fileContent, QString password = lines.takeFirst(); QStringList remainingData; NamedValues namedValues; - for (QString line : lines) { + for (const QString &line : lines) { if (line.contains(":")) { int colon = line.indexOf(':'); QString name = line.left(colon); diff --git a/src/imitatepass.cpp b/src/imitatepass.cpp index f1c84e40..7998bf0f 100644 --- a/src/imitatepass.cpp +++ b/src/imitatepass.cpp @@ -12,7 +12,7 @@ using namespace Enums; * @brief ImitatePass::ImitatePass for situaions when pass is not available * we imitate the behavior of pass https://www.passwordstore.org/ */ -ImitatePass::ImitatePass() {} +ImitatePass::ImitatePass() = default; /** * @brief ImitatePass::GitInit git init wrapper diff --git a/src/keygendialog.cpp b/src/keygendialog.cpp index 62fcffda..c626c58f 100644 --- a/src/keygendialog.cpp +++ b/src/keygendialog.cpp @@ -132,7 +132,7 @@ void KeygenDialog::done(int r) { } // check email - QRegExp mailre("\\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\\b"); + QRegExp mailre(R"(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)"); mailre.setCaseSensitivity(Qt::CaseInsensitive); mailre.setPatternSyntax(QRegExp::RegExp); if (!mailre.exactMatch(ui->email->text())) { @@ -147,7 +147,7 @@ void KeygenDialog::done(int r) { ui->checkBox->setEnabled(false); ui->plainTextEdit->setEnabled(false); - QProgressIndicator *pi = new QProgressIndicator(); + auto *pi = new QProgressIndicator(); pi->startAnimation(); pi->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index c92f74dc..f5d3c915 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -830,7 +830,7 @@ void MainWindow::closeEvent(QCloseEvent *event) { */ bool MainWindow::eventFilter(QObject *obj, QEvent *event) { if (obj == ui->lineEdit && event->type() == QEvent::KeyPress) { - QKeyEvent *key = static_cast(event); + auto *key = dynamic_cast(event); if (key->key() == Qt::Key_Down) { ui->treeView->setFocus(); } @@ -1016,7 +1016,7 @@ void MainWindow::addToGridLayout(int position, const QString &field, ly->setContentsMargins(5, 2, 2, 2); frame->setLayout(ly); if (QtPassSettings::getClipBoardType() != Enums::CLIPBOARD_NEVER) { - QPushButtonWithClipboard *fieldLabel = + auto *fieldLabel = new QPushButtonWithClipboard(trimmedValue, this); connect(fieldLabel, &QPushButtonWithClipboard::clicked, m_qtPass, &QtPass::copyTextToClipboard); @@ -1028,7 +1028,7 @@ void MainWindow::addToGridLayout(int position, const QString &field, // set the echo mode to password, if the field is "password" if (QtPassSettings::isHidePassword() && trimmedField == tr("Password")) { - QLineEdit *line = new QLineEdit(); + auto *line = new QLineEdit(); line->setObjectName(trimmedField); line->setText(trimmedValue); line->setReadOnly(true); @@ -1037,7 +1037,7 @@ void MainWindow::addToGridLayout(int position, const QString &field, line->setEchoMode(QLineEdit::Password); frame->layout()->addWidget(line); } else { - QTextBrowser *line = new QTextBrowser(); + auto *line = new QTextBrowser(); line->setOpenExternalLinks(true); line->setOpenLinks(true); line->setMaximumHeight(26); @@ -1047,7 +1047,7 @@ void MainWindow::addToGridLayout(int position, const QString &field, line->setObjectName(trimmedField); trimmedValue.replace( QRegExp("((?:https?|ftp|ssh|sftp|ftps|webdav|webdavs)://\\S+)"), - "\\1"); + R"(\1)"); line->setText(trimmedValue); line->setReadOnly(true); line->setStyleSheet("border-style: none ; background: transparent;"); diff --git a/src/pass.cpp b/src/pass.cpp index 788b868b..70fee7a6 100644 --- a/src/pass.cpp +++ b/src/pass.cpp @@ -184,7 +184,7 @@ QList Pass::listKeys(QString keystring, bool secret) { */ void Pass::finished(int id, int exitCode, const QString &out, const QString &err) { - PROCESS pid = static_cast(id); + auto pid = static_cast(id); if (exitCode != 0) { emit processErrorExit(exitCode, err); return; diff --git a/src/passworddialog.cpp b/src/passworddialog.cpp index 9691e3ef..ca3b5244 100644 --- a/src/passworddialog.cpp +++ b/src/passworddialog.cpp @@ -65,7 +65,7 @@ PasswordDialog::PasswordDialog(const QString &file, const bool &isNew, } /** - * @brief PasswordDialog::~PasswordDialog basic destructor. + * @brief Pass{}{}wordDialog::~PasswordDialog basic destructor. */ PasswordDialog::~PasswordDialog() { delete ui; } @@ -134,7 +134,7 @@ void PasswordDialog::setPassword(QString password) { // show remaining values (if there are) otherLines.clear(); for (const NamedValue &nv : namedValues) { - QLineEdit *line = new QLineEdit(); + auto *line = new QLineEdit(); line->setObjectName(nv.name); line->setText(nv.value); ui->formLayout->addRow(new QLabel(nv.name), line); @@ -179,7 +179,7 @@ void PasswordDialog::setTemplate(QString rawFields, bool useTemplate) { foreach (QString field, m_fields) { if (field.isEmpty()) continue; - QLineEdit *line = new QLineEdit(); + auto *line = new QLineEdit(); line->setObjectName(field); ui->formLayout->addRow(new QLabel(field), line); setTabOrder(previous, line); diff --git a/src/qprogressindicator.cpp b/src/qprogressindicator.cpp index 009981f3..ae90f939 100644 --- a/src/qprogressindicator.cpp +++ b/src/qprogressindicator.cpp @@ -60,7 +60,7 @@ void QProgressIndicator::setColor(const QColor &color) { * @brief QProgressIndicator::sizeHint default minimum size. * @return QSize(20, 20) */ -QSize QProgressIndicator::sizeHint() const { return QSize(20, 20); } +QSize QProgressIndicator::sizeHint() const { return {20, 20}; } /** * @brief QProgressIndicator::heightForWidth square ratio. @@ -90,8 +90,8 @@ void QProgressIndicator::paintEvent(QPaintEvent * /*event*/) { QPainter p(this); p.setRenderHint(QPainter::Antialiasing); - int outerRadius = int((width - 1) * 0.5); - int innerRadius = int((width - 1) * 0.5 * 0.38); + auto outerRadius = int((width - 1) * 0.5); + auto innerRadius = int((width - 1) * 0.5 * 0.38); int capsuleHeight = outerRadius - innerRadius; int capsuleWidth = diff --git a/src/realpass.cpp b/src/realpass.cpp index 071f618b..bf420340 100644 --- a/src/realpass.cpp +++ b/src/realpass.cpp @@ -6,7 +6,7 @@ using namespace Enums; -RealPass::RealPass() {} +RealPass::RealPass() = default; /** * @brief RealPass::GitInit pass git init wrapper diff --git a/src/settingsconstants.cpp b/src/settingsconstants.cpp index 066931f3..5a38b814 100644 --- a/src/settingsconstants.cpp +++ b/src/settingsconstants.cpp @@ -1,6 +1,6 @@ #include "settingsconstants.h" -SettingsConstants::SettingsConstants() {} +SettingsConstants::SettingsConstants() = default; const QString SettingsConstants::version = "version"; diff --git a/src/storemodel.cpp b/src/storemodel.cpp index 2b7d3ac7..0f6dca0a 100644 --- a/src/storemodel.cpp +++ b/src/storemodel.cpp @@ -125,9 +125,9 @@ Qt::ItemFlags StoreModel::flags(const QModelIndex &index) const { if (index.isValid()) { return Qt::ItemIsDragEnabled | Qt::ItemIsDropEnabled | defaultFlags; - } else { + } return Qt::ItemIsDropEnabled | defaultFlags; - } + } QStringList StoreModel::mimeTypes() const { @@ -152,7 +152,7 @@ QMimeData *StoreModel::mimeData(const QModelIndexList &indexes) const { stream << info; } - QMimeData *mimeData = new QMimeData(); + auto *mimeData = new QMimeData(); mimeData->setData("application/vnd+qtpass.dragAndDropInfoPasswordStore", encodedData); return mimeData; @@ -218,14 +218,14 @@ bool StoreModel::dropMimeData(const QMimeData *data, Qt::DropAction action, QFileInfo destFileinfo = fs->fileInfo(mapToSource(destIndex)); QFileInfo srcFileInfo = QFileInfo(info.path); QDir qdir; - QString cleanedSrc = qdir.cleanPath(srcFileInfo.absoluteFilePath()); - QString cleanedDest = qdir.cleanPath(destFileinfo.absoluteFilePath()); + QString cleanedSrc = QDir::cleanPath(srcFileInfo.absoluteFilePath()); + QString cleanedDest = QDir::cleanPath(destFileinfo.absoluteFilePath()); if (info.isDir) { QDir srcDir = QDir(info.path); // dropped dir onto dir if (destFileinfo.isDir()) { QDir destDir = QDir(cleanedDest).filePath(srcFileInfo.fileName()); - QString cleanedDestDir = qdir.cleanPath(destDir.absolutePath()); + QString cleanedDestDir = QDir::cleanPath(destDir.absolutePath()); if (action == Qt::MoveAction) { QtPassSettings::getPass()->Move(cleanedSrc, cleanedDestDir); } else if (action == Qt::CopyAction) { diff --git a/src/trayicon.cpp b/src/trayicon.cpp index a9fe5784..99f80def 100644 --- a/src/trayicon.cpp +++ b/src/trayicon.cpp @@ -19,7 +19,7 @@ TrayIcon::TrayIcon(QMainWindow *parent) sysTrayIcon(nullptr), trayIconMenu(nullptr), isAllocated(false) { parentwin = parent; - if (QSystemTrayIcon::isSystemTrayAvailable() == true) { + if (QSystemTrayIcon::isSystemTrayAvailable()) { createActions(); createTrayIcon(); @@ -45,7 +45,7 @@ TrayIcon::TrayIcon(QMainWindow *parent) * @param visible */ void TrayIcon::setVisible(bool visible) { - if (visible == true) + if (visible) parentwin->show(); else parentwin->hide(); @@ -99,7 +99,7 @@ void TrayIcon::createTrayIcon() { * @brief TrayIcon::showHideParent toggle app visibility. */ void TrayIcon::showHideParent() { - if (parentwin->isVisible() == true) + if (parentwin->isVisible()) parentwin->hide(); else parentwin->show(); diff --git a/src/usersdialog.cpp b/src/usersdialog.cpp index ddbafaeb..34b28fb9 100644 --- a/src/usersdialog.cpp +++ b/src/usersdialog.cpp @@ -28,9 +28,9 @@ UsersDialog::UsersDialog(QString dir, QWidget *parent) QList secret_keys = QtPassSettings::getPass()->listKeys("", true); foreach (const UserInfo &sec, secret_keys) { - for (QList::iterator it = users.begin(); it != users.end(); ++it) - if (sec.key_id == it->key_id) - it->have_secret = true; + for (auto & user : users) + if (sec.key_id == user.key_id) + user.have_secret = true; } QList selected_users; @@ -41,9 +41,9 @@ UsersDialog::UsersDialog(QString dir, QWidget *parent) if (!recipients.isEmpty()) selected_users = QtPassSettings::getPass()->listKeys(recipients); foreach (const UserInfo &sel, selected_users) { - for (QList::iterator it = users.begin(); it != users.end(); ++it) - if (sel.key_id == it->key_id) - it->enabled = true; + for (auto & user : users) + if (sel.key_id == user.key_id) + user.enabled = true; } if (count > selected_users.size()) { @@ -51,7 +51,7 @@ UsersDialog::UsersDialog(QString dir, QWidget *parent) QStringList recipients = QtPassSettings::getPass()->getRecipientList( m_dir.isEmpty() ? "" : m_dir); foreach (const QString recipient, recipients) { - if (QtPassSettings::getPass()->listKeys(recipient).size() < 1) { + if (QtPassSettings::getPass()->listKeys(recipient).empty()) { UserInfo i; i.enabled = true; i.key_id = recipient; @@ -120,7 +120,7 @@ void UsersDialog::keyPressEvent(QKeyEvent *event) { void UsersDialog::itemChange(QListWidgetItem *item) { if (!item) return; - UserInfo *info = item->data(Qt::UserRole).value(); + auto *info = item->data(Qt::UserRole).value(); if (!info) return; info->enabled = item->checkState() == Qt::Checked; @@ -137,9 +137,7 @@ void UsersDialog::populateList(const QString &filter) { nameFilter.setCaseSensitivity(Qt::CaseInsensitive); ui->listWidget->clear(); if (!m_userList.isEmpty()) { - for (QList::iterator it = m_userList.begin(); - it != m_userList.end(); ++it) { - UserInfo &user(*it); + for (auto & user : m_userList) { if (filter.isEmpty() || nameFilter.exactMatch(user.name)) { if (!user.isValid() && !ui->checkBox->isChecked()) continue; @@ -155,7 +153,7 @@ void UsersDialog::populateList(const QString &filter) { if (user.expiry.toTime_t() > 0) userText += " " + tr("expires") + " " + user.expiry.toString(Qt::SystemLocaleShortDate); - QListWidgetItem *item = new QListWidgetItem(userText, ui->listWidget); + auto *item = new QListWidgetItem(userText, ui->listWidget); item->setCheckState(user.enabled ? Qt::Checked : Qt::Unchecked); item->setData(Qt::UserRole, QVariant::fromValue(&user)); if (user.have_secret) { -- cgit v1.2.3 From 777e20f67cca7ed7776863f3662547116597d1e4 Mon Sep 17 00:00:00 2001 From: Anne Jan Brouwer Date: Fri, 12 Oct 2018 17:25:04 +0200 Subject: Some cleanup with help of Clang-Tidy and Clazy (part 3 of x) --- localization/localization_ar_MA.ts | 4 ++-- localization/localization_ca.ts | 4 ++-- localization/localization_cs_CZ.ts | 4 ++-- localization/localization_de_DE.ts | 4 ++-- localization/localization_de_LU.ts | 4 ++-- localization/localization_el_GR.ts | 4 ++-- localization/localization_en_GB.ts | 4 ++-- localization/localization_en_US.ts | 4 ++-- localization/localization_es_ES.ts | 4 ++-- localization/localization_fr_BE.ts | 4 ++-- localization/localization_fr_FR.ts | 4 ++-- localization/localization_fr_LU.ts | 4 ++-- localization/localization_gl_ES.ts | 4 ++-- localization/localization_he_IL.ts | 4 ++-- localization/localization_hu_HU.ts | 4 ++-- localization/localization_it_IT.ts | 4 ++-- localization/localization_lb_LU.ts | 4 ++-- localization/localization_nl.ts | 4 ++-- localization/localization_pl_PL.ts | 4 ++-- localization/localization_pt_PT.ts | 4 ++-- localization/localization_ru_RU.ts | 4 ++-- localization/localization_sv_SE.ts | 4 ++-- localization/localization_zh_CN.ts | 4 ++-- src/imitatepass.cpp | 7 ++++--- src/imitatepass.h | 2 +- src/keygendialog.cpp | 2 +- src/keygendialog.h | 2 +- src/qtpass.cpp | 3 ++- src/realpass.cpp | 3 ++- src/singleapplication.cpp | 6 +++--- src/singleapplication.h | 2 +- src/storemodel.cpp | 6 +++--- src/trayicon.cpp | 2 +- src/trayicon.h | 2 +- src/usersdialog.cpp | 9 +++++---- 35 files changed, 71 insertions(+), 67 deletions(-) diff --git a/localization/localization_ar_MA.ts b/localization/localization_ar_MA.ts index 9129cf16..dc52240f 100644 --- a/localization/localization_ar_MA.ts +++ b/localization/localization_ar_MA.ts @@ -384,7 +384,7 @@ email ImitatePass - + Can not edit @@ -948,7 +948,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + Can not get key list diff --git a/localization/localization_ca.ts b/localization/localization_ca.ts index c9766d36..52ebc5a3 100644 --- a/localization/localization_ca.ts +++ b/localization/localization_ca.ts @@ -390,7 +390,7 @@ email ImitatePass - + Can not edit No es pot editar @@ -1112,7 +1112,7 @@ Les entrades vermelles no són vàlides, no podreu xifrar. Mostra les claus inutilitzables - + Can not get key list No es pot obtenir la llista de claus diff --git a/localization/localization_cs_CZ.ts b/localization/localization_cs_CZ.ts index 7a8cb012..334b1289 100644 --- a/localization/localization_cs_CZ.ts +++ b/localization/localization_cs_CZ.ts @@ -390,7 +390,7 @@ email ImitatePass - + Can not edit Nelze upravovat @@ -1090,7 +1090,7 @@ Modře označené záznamy poskytují tajný klíč, vyberte jeden z nich, kter Zobrazit nepoužitelné klíče - + Can not get key list Nelze získat seznam klíčů diff --git a/localization/localization_de_DE.ts b/localization/localization_de_DE.ts index 4b4057dd..f3a9f438 100755 --- a/localization/localization_de_DE.ts +++ b/localization/localization_de_DE.ts @@ -391,7 +391,7 @@ email ImitatePass - + Can not edit Ändern nicht möglich @@ -1077,7 +1077,7 @@ Die roten Einträge sind ungültig / abgelaufen und für Entschlüsselung nicht unbrauchbare Schlüssel anzeigen - + Can not get key list Schlüssel-Liste nicht gefunden diff --git a/localization/localization_de_LU.ts b/localization/localization_de_LU.ts index b3943ba0..5c1fa3c1 100755 --- a/localization/localization_de_LU.ts +++ b/localization/localization_de_LU.ts @@ -391,7 +391,7 @@ email ImitatePass - + Can not edit Ändern nicht möglich @@ -1072,7 +1072,7 @@ Die roten Einträge sind ungültig / abgelaufen und für Entschlüsselung nicht unbrauchbare Schlüssel anzeigen - + Can not get key list Schlüssel-Liste nicht gefunden diff --git a/localization/localization_el_GR.ts b/localization/localization_el_GR.ts index 4a1b6681..e9fdd230 100644 --- a/localization/localization_el_GR.ts +++ b/localization/localization_el_GR.ts @@ -384,7 +384,7 @@ email ImitatePass - + Can not edit @@ -951,7 +951,7 @@ Red entries are not valid, you will not be able to encrypt to these. - + Can not get key list diff --git a/localization/localization_en_GB.ts b/localization/localization_en_GB.ts index bbaaa4ed..24dede5c 100644 --- a/localization/localization_en_GB.ts +++ b/localization/localization_en_GB.ts @@ -390,7 +390,7 @@ email ImitatePass - + Can not edit Can not edit @@ -1123,7 +1123,7 @@ Red entries are not valid, you will not be able to encrypt to these.Show unusable keys - + Can not get key list Can not get key list diff --git a/localization/localization_en_US.ts b/localization/localization_en_US.ts index 45c3973a..23af34c0 100644 --- a/localization/localization_en_US.ts +++ b/localization/localization_en_US.ts @@ -390,7 +390,7 @@ email ImitatePass - + Can not edit Can not edit @@ -1123,7 +1123,7 @@ Red entries are not valid, you will not be able to encrypt to these.Show unusable keys - + Can not get key list Can not get key list diff --git a/localization/localization_es_ES.ts b/localization/localization_es_ES.ts index 85545907..7b2a2cc6 100644 --- a/localization/localization_es_ES.ts +++ b/localization/localization_es_ES.ts @@ -384,7 +384,7 @@ email ImitatePass - + Can not edit No se puede editar @@ -1054,7 +1054,7 @@ Entradas rojas no son válidos, usted no será capaz de cifrar a estos.Mostrar claves no usables