diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/configdialog.cpp | 44 | ||||
-rw-r--r-- | src/configdialog.h | 4 | ||||
-rw-r--r-- | src/configdialog.ui | 53 | ||||
-rw-r--r-- | src/executor.cpp | 3 | ||||
-rw-r--r-- | src/filecontent.cpp | 2 | ||||
-rw-r--r-- | src/imitatepass.cpp | 135 | ||||
-rw-r--r-- | src/imitatepass.h | 1 | ||||
-rw-r--r-- | src/keygendialog.cpp | 19 | ||||
-rw-r--r-- | src/keygendialog.ui | 43 | ||||
-rw-r--r-- | src/mainwindow.cpp | 68 | ||||
-rw-r--r-- | src/mainwindow.h | 2 | ||||
-rw-r--r-- | src/mainwindow.ui | 8 | ||||
-rw-r--r-- | src/pass.cpp | 101 | ||||
-rw-r--r-- | src/pass.h | 8 | ||||
-rw-r--r-- | src/passworddialog.cpp | 4 | ||||
-rw-r--r-- | src/passworddialog.ui | 8 | ||||
-rw-r--r-- | src/qprogressindicator.cpp | 26 | ||||
-rw-r--r-- | src/qprogressindicator.h | 41 | ||||
-rw-r--r-- | src/qtpass.cpp | 38 | ||||
-rw-r--r-- | src/qtpasssettings.cpp | 74 | ||||
-rw-r--r-- | src/qtpasssettings.h | 18 | ||||
-rw-r--r-- | src/realpass.cpp | 9 | ||||
-rw-r--r-- | src/settingsconstants.cpp | 4 | ||||
-rw-r--r-- | src/settingsconstants.h | 4 | ||||
-rw-r--r-- | src/src.pro | 4 | ||||
-rw-r--r-- | src/storemodel.cpp | 12 | ||||
-rw-r--r-- | src/storemodel.h | 1 | ||||
-rw-r--r-- | src/usersdialog.cpp | 16 | ||||
-rw-r--r-- | src/usersdialog.ui | 8 | ||||
-rw-r--r-- | src/util.cpp | 11 | ||||
-rw-r--r-- | src/util.h | 3 |
31 files changed, 581 insertions, 191 deletions
diff --git a/src/configdialog.cpp b/src/configdialog.cpp index ecdeeb83..4c9f227d 100644 --- a/src/configdialog.cpp +++ b/src/configdialog.cpp @@ -3,6 +3,7 @@ #include "mainwindow.h" #include "qtpasssettings.h" #include "ui_configdialog.h" +#include "util.h" #include <QClipboard> #include <QDir> #include <QFileDialog> @@ -37,6 +38,9 @@ ConfigDialog::ConfigDialog(MainWindow *parent) QtPassSettings::getAutoclearPanelSeconds()); ui->checkBoxHidePassword->setChecked(QtPassSettings::isHidePassword()); ui->checkBoxHideContent->setChecked(QtPassSettings::isHideContent()); + ui->checkBoxUseMonospace->setChecked(QtPassSettings::isUseMonospace()); + ui->checkBoxDisplayAsIs->setChecked(QtPassSettings::isDisplayAsIs()); + ui->checkBoxNoLineWrapping->setChecked(QtPassSettings::isNoLineWrapping()); ui->checkBoxAddGPGId->setChecked(QtPassSettings::isAddGPGId(true)); if (QSystemTrayIcon::isSystemTrayAvailable()) { @@ -94,7 +98,8 @@ ConfigDialog::ConfigDialog(MainWindow *parent) useTemplate(QtPassSettings::isUseTemplate()); ui->profileTable->verticalHeader()->hide(); - ui->profileTable->horizontalHeader()->setStretchLastSection(true); + ui->profileTable->horizontalHeader()->setSectionResizeMode( + 1, QHeaderView::Stretch); ui->label->setText(ui->label->text() + VERSION); ui->comboBoxClipboard->clear(); @@ -167,7 +172,7 @@ void ConfigDialog::validate(QTableWidgetItem *item) { for (int j = 0; j < ui->profileTable->columnCount(); j++) { QTableWidgetItem *_item = ui->profileTable->item(i, j); - if (_item->text().isEmpty()) { + if (_item->text().isEmpty() && j != 2) { _item->setBackground(Qt::red); status = false; break; @@ -178,7 +183,7 @@ void ConfigDialog::validate(QTableWidgetItem *item) { break; } } else { - if (item->text().isEmpty()) { + if (item->text().isEmpty() && item->column() != 2) { item->setBackground(Qt::red); status = false; } @@ -203,6 +208,9 @@ void ConfigDialog::on_accepted() { ui->spinBoxAutoclearPanelSeconds->value()); QtPassSettings::setHidePassword(ui->checkBoxHidePassword->isChecked()); QtPassSettings::setHideContent(ui->checkBoxHideContent->isChecked()); + QtPassSettings::setUseMonospace(ui->checkBoxUseMonospace->isChecked()); + QtPassSettings::setDisplayAsIs(ui->checkBoxDisplayAsIs->isChecked()); + QtPassSettings::setNoLineWrapping(ui->checkBoxNoLineWrapping->isChecked()); QtPassSettings::setAddGPGId(ui->checkBoxAddGPGId->isChecked()); QtPassSettings::setUseTrayIcon(ui->checkBoxUseTrayIcon->isEnabled() && ui->checkBoxUseTrayIcon->isChecked()); @@ -297,7 +305,7 @@ QString ConfigDialog::selectExecutable() { dialog.setFileMode(QFileDialog::ExistingFile); dialog.setOption(QFileDialog::ReadOnly); if (dialog.exec()) - return dialog.selectedFiles().first(); + return dialog.selectedFiles().constFirst(); return QString(); } @@ -312,7 +320,7 @@ QString ConfigDialog::selectFolder() { dialog.setFilter(QDir::NoFilter); dialog.setOption(QFileDialog::ShowDirsOnly); if (dialog.exec()) - return dialog.selectedFiles().first(); + return dialog.selectedFiles().constFirst(); return QString(); } @@ -454,8 +462,8 @@ void ConfigDialog::genKey(QString batch, QDialog *dialog) { * @param profiles * @param profile */ -void ConfigDialog::setProfiles(QHash<QString, QString> profiles, - QString profile) { +void ConfigDialog::setProfiles(QHash<QString, QHash<QString, QString>> profiles, + QString currentProfile) { // dbg()<< profiles; if (profiles.contains("")) { profiles.remove(""); @@ -463,15 +471,18 @@ void ConfigDialog::setProfiles(QHash<QString, QString> profiles, } ui->profileTable->setRowCount(profiles.count()); - QHashIterator<QString, QString> i(profiles); + QHashIterator<QString, QHash<QString, QString>> i(profiles); int n = 0; while (i.hasNext()) { i.next(); if (!i.value().isEmpty() && !i.key().isEmpty()) { ui->profileTable->setItem(n, 0, new QTableWidgetItem(i.key())); - ui->profileTable->setItem(n, 1, new QTableWidgetItem(i.value())); + ui->profileTable->setItem(n, 1, + new QTableWidgetItem(i.value().value("path"))); + ui->profileTable->setItem( + n, 2, new QTableWidgetItem(i.value().value("signingKey"))); // dbg()<< "naam:" + i.key(); - if (i.key() == profile) + if (i.key() == currentProfile) ui->profileTable->selectRow(n); } ++n; @@ -482,17 +493,23 @@ void ConfigDialog::setProfiles(QHash<QString, QString> profiles, * @brief ConfigDialog::getProfiles return profile list. * @return */ -QHash<QString, QString> ConfigDialog::getProfiles() { - QHash<QString, QString> profiles; +QHash<QString, QHash<QString, QString>> ConfigDialog::getProfiles() { + QHash<QString, QHash<QString, QString>> profiles; // Check? for (int i = 0; i < ui->profileTable->rowCount(); ++i) { + QHash<QString, QString> profile; QTableWidgetItem *pathItem = ui->profileTable->item(i, 1); if (nullptr != pathItem) { QTableWidgetItem *item = ui->profileTable->item(i, 0); if (item == nullptr) { continue; } - profiles.insert(item->text(), pathItem->text()); + profile["path"] = pathItem->text(); + QTableWidgetItem *signingKeyItem = ui->profileTable->item(i, 2); + if (nullptr != signingKeyItem) { + profile["signingKey"] = signingKeyItem->text(); + } + profiles.insert(item->text(), profile); } } return profiles; @@ -506,6 +523,7 @@ void ConfigDialog::on_addButton_clicked() { ui->profileTable->insertRow(n); ui->profileTable->setItem(n, 0, new QTableWidgetItem()); ui->profileTable->setItem(n, 1, new QTableWidgetItem(ui->storePath->text())); + ui->profileTable->setItem(n, 2, new QTableWidgetItem()); ui->profileTable->selectRow(n); ui->deleteButton->setEnabled(true); diff --git a/src/configdialog.h b/src/configdialog.h index a0f162b0..4460d4bf 100644 --- a/src/configdialog.h +++ b/src/configdialog.h @@ -31,7 +31,7 @@ public: void useSelection(bool useSelection); void useAutoclear(bool useAutoclear); void useAutoclearPanel(bool useAutoclearPanel); - QHash<QString, QString> getProfiles(); + QHash<QString, QHash<QString, QString>> getProfiles(); void wizard(); void genKey(QString, QDialog *); void useTrayIcon(bool useSystray); @@ -76,7 +76,7 @@ private: QStringList getSecretKeys(); void setGitPath(QString); - void setProfiles(QHash<QString, QString>, QString); + void setProfiles(QHash<QString, QHash<QString, QString>>, QString); void usePass(bool usePass); void setGroupBoxState(); diff --git a/src/configdialog.ui b/src/configdialog.ui index 939fd54d..af9c97e6 100644 --- a/src/configdialog.ui +++ b/src/configdialog.ui @@ -7,7 +7,7 @@ <x>0</x> <y>0</y> <width>659</width> - <height>650</height> + <height>728</height> </rect> </property> <property name="sizePolicy"> @@ -19,6 +19,10 @@ <property name="windowTitle"> <string>Configuration</string> </property> + <property name="windowIcon"> + <iconset resource="../resources.qrc"> + <normaloff>:/artwork/icon.png</normaloff>:/artwork/icon.png</iconset> + </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <property name="leftMargin"> <number>6</number> @@ -212,6 +216,44 @@ </item> </layout> </item> + <item> + <layout class="QHBoxLayout" name="horizontalLayout_19"> + <item> + <widget class="QCheckBox" name="checkBoxUseMonospace"> + <property name="text"> + <string>Use a monospace font</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxDisplayAsIs"> + <property name="text"> + <string>Display the files content as-is</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBoxNoLineWrapping"> + <property name="text"> + <string>No line wrapping</string> + </property> + </widget> + </item> + <item> + <spacer name="horizontalSpacer_9"> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>40</width> + <height>20</height> + </size> + </property> + </spacer> + </item> + </layout> + </item> </layout> </item> <item> @@ -875,6 +917,11 @@ <string>Path</string> </property> </column> + <column> + <property name="text"> + <string>Signing Key</string> + </property> + </column> </widget> </item> <item> @@ -1051,7 +1098,9 @@ e-mail</string> <tabstop>storePath</tabstop> <tabstop>toolButtonStore</tabstop> </tabstops> - <resources/> + <resources> + <include location="../resources.qrc"/> + </resources> <connections> <connection> <sender>buttonBox</sender> diff --git a/src/executor.cpp b/src/executor.cpp index a4e91bb4..1da58e81 100644 --- a/src/executor.cpp +++ b/src/executor.cpp @@ -4,6 +4,9 @@ #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) #include <QTextCodec> #endif +#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0) +#include <QStringDecoder> +#endif #ifdef QT_DEBUG #include "debughelper.h" diff --git a/src/filecontent.cpp b/src/filecontent.cpp index 65984850..1c29ae5c 100644 --- a/src/filecontent.cpp +++ b/src/filecontent.cpp @@ -11,7 +11,7 @@ FileContent FileContent::parse(const QString &fileContent, QString password = lines.takeFirst(); QStringList remainingData, remainingDataDisplay; NamedValues namedValues; - for (const QString &line : lines) { + for (const QString &line : qAsConst(lines)) { if (line.contains(":")) { int colon = line.indexOf(':'); QString name = line.left(colon); diff --git a/src/imitatepass.cpp b/src/imitatepass.cpp index 2140505b..8300cb36 100644 --- a/src/imitatepass.cpp +++ b/src/imitatepass.cpp @@ -1,5 +1,6 @@ #include "imitatepass.h" #include "qtpasssettings.h" +#include "util.h" #include <QDirIterator> #include <QRegularExpression> #include <utility> @@ -89,6 +90,12 @@ void ImitatePass::OtpGenerate(QString file) { */ void ImitatePass::Insert(QString file, QString newValue, bool overwrite) { file = file + ".gpg"; + QString gpgIdPath = Pass::getGpgIdPath(file); + if (!verifyGpgIdFile(gpgIdPath)) { + emit critical(tr("Check .gpgid file signature!"), + tr("Signature for %1 is invalid.").arg(gpgIdPath)); + return; + } transactionHelper trans(this, PASS_INSERT); QStringList recipients = Pass::getRecipientList(file); if (recipients.isEmpty()) { @@ -112,7 +119,7 @@ void ImitatePass::Insert(QString file, QString newValue, bool overwrite) { if (!overwrite) executeGit(GIT_ADD, {"add", pgit(file)}); QString path = QDir(QtPassSettings::getPassStore()).relativeFilePath(file); - path.replace(QRegularExpression("\\.gpg$"), ""); + path.replace(Util::endsWithGpg(), ""); QString msg = QString(overwrite ? "Edit" : "Add") + " for " + path + " using QtPass."; GitCommit(file, msg); @@ -127,9 +134,9 @@ void ImitatePass::Insert(QString file, QString newValue, bool overwrite) { */ void ImitatePass::GitCommit(const QString &file, const QString &msg) { if (file.isEmpty()) - executeGit(GIT_COMMIT, {"commit", "-m", msg}); + executeGit(GIT_COMMIT, {"commit", "-m", msg}); else - executeGit(GIT_COMMIT, {"commit", "-m", msg, "--", pgit(file)}); + executeGit(GIT_COMMIT, {"commit", "-m", msg, "--", pgit(file)}); } /** @@ -147,12 +154,8 @@ void ImitatePass::Remove(QString file, bool isDir) { GitCommit(file, "Remove for " + file + " using QtPass."); } else { if (isDir) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QDir dir(file); dir.removeRecursively(); -#else - removeDir(QtPassSettings::getPassStore() + file); -#endif } else QFile(file).remove(); } @@ -166,6 +169,38 @@ void ImitatePass::Remove(QString file, bool isDir) { * path */ void ImitatePass::Init(QString path, const QList<UserInfo> &users) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + QStringList signingKeys = + QtPassSettings::getPassSigningKey().split(" ", Qt::SkipEmptyParts); +#else + QStringList signingKeys = + QtPassSettings::getPassSigningKey().split(" ", QString::SkipEmptyParts); +#endif + QString gpgIdSigFile = path + ".gpg-id.sig"; + bool addSigFile = false; + if (!signingKeys.isEmpty()) { + QString out; + QStringList args = + QStringList{"--status-fd=1", "--list-secret-keys"} + signingKeys; + exec.executeBlocking(QtPassSettings::getGpgExecutable(), args, &out); + bool found = false; + for (auto &key : signingKeys) { + if (out.contains("[GNUPG:] KEY_CONSIDERED " + key)) { + found = true; + break; + } + } + if (!found) { + emit critical(tr("No signing key!"), + tr("None of the secret signing keys is available.\n" + "You will not be able to change the user list!")); + return; + } + QFileInfo checkFile(gpgIdSigFile); + if (!checkFile.exists() || !checkFile.isFile()) + addSigFile = true; + } + QString gpgIdFile = path + ".gpg-id"; QFile gpgId(gpgIdFile); bool addFile = false; @@ -196,18 +231,73 @@ void ImitatePass::Init(QString path, const QList<UserInfo> &users) { return; } + if (!signingKeys.isEmpty()) { + QStringList args; + for (auto &key : signingKeys) { + args.append(QStringList{"--default-key", key}); + } + args.append(QStringList{"--yes", "--detach-sign", gpgIdFile}); + exec.executeBlocking(QtPassSettings::getGpgExecutable(), args); + if (!verifyGpgIdFile(gpgIdFile)) { + emit critical(tr("Check .gpgid file signature!"), + tr("Signature for %1 is invalid.").arg(gpgIdFile)); + return; + } + } + if (!QtPassSettings::isUseWebDav() && QtPassSettings::isUseGit() && !QtPassSettings::getGitExecutable().isEmpty()) { if (addFile) executeGit(GIT_ADD, {"add", pgit(gpgIdFile)}); QString commitPath = gpgIdFile; - commitPath.replace(QRegularExpression("\\.gpg$"), ""); + commitPath.replace(Util::endsWithGpg(), ""); GitCommit(gpgIdFile, "Added " + commitPath + " using QtPass."); + if (!signingKeys.isEmpty()) { + if (addSigFile) + executeGit(GIT_ADD, {"add", pgit(gpgIdSigFile)}); + commitPath = gpgIdSigFile; + commitPath.replace(QRegularExpression("\\.gpg$"), ""); + GitCommit(gpgIdSigFile, "Added " + commitPath + " using QtPass."); + } } reencryptPath(path); } /** + * @brief ImitatePass::verifyGpgIdFile verify detached gpgid file signature. + * @param file which gpgid file. + * @return was verification succesful? + */ +bool ImitatePass::verifyGpgIdFile(const QString &file) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) + QStringList signingKeys = + QtPassSettings::getPassSigningKey().split(" ", Qt::SkipEmptyParts); +#else + QStringList signingKeys = + QtPassSettings::getPassSigningKey().split(" ", QString::SkipEmptyParts); +#endif + if (signingKeys.isEmpty()) + return true; + QString out; + QStringList args = + QStringList{"--verify", "--status-fd=1", pgpg(file) + ".sig", pgpg(file)}; + exec.executeBlocking(QtPassSettings::getGpgExecutable(), args, &out); + QRegularExpression re( + "^\\[GNUPG:\\] VALIDSIG ([A-F0-9]{40}) .* ([A-F0-9]{40})\\r?$", + QRegularExpression::MultilineOption); + QRegularExpressionMatch m = re.match(out); + if (!m.hasMatch()) + return false; + QStringList fingerprints = m.capturedTexts(); + fingerprints.removeFirst(); + for (auto &key : signingKeys) { + if (fingerprints.contains(key)) + return true; + } + return false; +} + +/** * @brief ImitatePass::removeDir delete folder recursive. * @param dirName which folder. * @return was removal succesful? @@ -252,10 +342,21 @@ void ImitatePass::reencryptPath(const QString &dir) { QDir currentDir; QDirIterator gpgFiles(dir, QStringList() << "*.gpg", QDir::Files, QDirIterator::Subdirectories); + QStringList gpgIdFilesVerified; QStringList gpgId; while (gpgFiles.hasNext()) { QString fileName = gpgFiles.next(); if (gpgFiles.fileInfo().path() != currentDir.path()) { + QString gpgIdPath = Pass::getGpgIdPath(fileName); + if (!gpgIdFilesVerified.contains(gpgIdPath)) { + if (!verifyGpgIdFile(gpgIdPath)) { + emit critical(tr("Check .gpgid file signature!"), + tr("Signature for %1 is invalid.").arg(gpgIdPath)); + emit endReencryptPath(); + return; + } + gpgIdFilesVerified.append(gpgIdPath); + } gpgId = getRecipientList(fileName); gpgId.sort(); } @@ -267,10 +368,11 @@ void ImitatePass::reencryptPath(const QString &dir) { exec.executeBlocking(QtPassSettings::getGpgExecutable(), args, &keys, &err); QStringList actualKeys; keys += err; + static const QRegularExpression newLines{"[\r\n]"}; #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - QStringList key = keys.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); + QStringList key = keys.split(newLines, Qt::SkipEmptyParts); #else - QStringList key = keys.split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts); + QStringList key = keys.split(newLines, QString::SkipEmptyParts); #endif QListIterator<QString> itr(key); while (itr.hasNext()) { @@ -323,7 +425,7 @@ void ImitatePass::reencryptPath(const QString &dir) { {"add", pgit(fileName)}); QString path = QDir(QtPassSettings::getPassStore()).relativeFilePath(fileName); - path.replace(QRegularExpression("\\.gpg$"), ""); + path.replace(Util::endsWithGpg(), ""); exec.executeBlocking(QtPassSettings::getGitExecutable(), {"commit", pgit(fileName), "-m", "Edit for " + path + " using QtPass."}); @@ -403,11 +505,12 @@ void ImitatePass::Move(const QString src, const QString dest, executeGit(GIT_MOVE, args); QString relSrc = QDir(QtPassSettings::getPassStore()).relativeFilePath(src); - relSrc.replace(QRegularExpression("\\.gpg$"), ""); - QString relDest = QDir(QtPassSettings::getPassStore()).relativeFilePath(destFile); - relDest.replace(QRegularExpression("\\.gpg$"), ""); + relSrc.replace(Util::endsWithGpg(), ""); + QString relDest = + QDir(QtPassSettings::getPassStore()).relativeFilePath(destFile); + relDest.replace(Util::endsWithGpg(), ""); QString message = QString("Moved for %1 to %2 using QtPass."); - message = message.arg(relSrc).arg(relDest); + message = message.arg(relSrc, relDest); GitCommit("", message); } else { QDir qDir; @@ -433,7 +536,7 @@ void ImitatePass::Copy(const QString src, const QString dest, executeGit(GIT_COPY, args); QString message = QString("copied from %1 to %2 using QTPass."); - message = message.arg(src).arg(dest); + message = message.arg(src, dest); GitCommit("", message); } else { QDir qDir; diff --git a/src/imitatepass.h b/src/imitatepass.h index 4bfd3a94..d29a25d4 100644 --- a/src/imitatepass.h +++ b/src/imitatepass.h @@ -11,6 +11,7 @@ class ImitatePass : public Pass, private simpleTransaction { Q_OBJECT + bool verifyGpgIdFile(const QString &file); bool removeDir(const QString &dirName); void GitCommit(const QString &file, const QString &msg); diff --git a/src/keygendialog.cpp b/src/keygendialog.cpp index a7661865..ba1efdb0 100644 --- a/src/keygendialog.cpp +++ b/src/keygendialog.cpp @@ -84,12 +84,13 @@ void KeygenDialog::on_name_textChanged(const QString &arg1) { void KeygenDialog::replace(const QString &key, const QString &value) { QStringList clear; QString expert = ui->plainTextEdit->toPlainText(); + static const QRegularExpression newLines{"[\r\n]"}; #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - QStringList lines = expert.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); + const QStringList lines = expert.split(newLines, Qt::SkipEmptyParts); #else - QStringList lines = expert.split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts); + const QStringList lines = expert.split(newLines, QString::SkipEmptyParts); #endif - foreach (QString line, lines) { + for (QString line : lines) { line.replace(QRegularExpression(key + ":.*"), key + ": " + value); if (key == "Passphrase") line.replace("%no-protection", "Passphrase: " + value); @@ -106,12 +107,13 @@ void KeygenDialog::replace(const QString &key, const QString &value) { void KeygenDialog::no_protection(bool enable) { QStringList clear; QString expert = ui->plainTextEdit->toPlainText(); + static const QRegularExpression newLines{"[\r\n]"}; #if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) - QStringList lines = expert.split(QRegularExpression("[\r\n]"), Qt::SkipEmptyParts); + const QStringList lines = expert.split(newLines, Qt::SkipEmptyParts); #else - QStringList lines = expert.split(QRegularExpression("[\r\n]"), QString::SkipEmptyParts); + const QStringList lines = expert.split(newLines, QString::SkipEmptyParts); #endif - foreach (QString line, lines) { + for (QString line : lines) { bool remove = false; if (!enable) { if (line.indexOf("%no-protection") == 0) @@ -141,7 +143,10 @@ void KeygenDialog::done(int r) { } // check email - QRegularExpression mailre(QRegularExpression::anchoredPattern(R"(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)"), QRegularExpression::CaseInsensitiveOption); + static const QRegularExpression mailre( + QRegularExpression::anchoredPattern( + R"(\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)"), + QRegularExpression::CaseInsensitiveOption); if (!mailre.match(ui->email->text()).hasMatch()) { QMessageBox::critical( this, tr("Invalid email"), diff --git a/src/keygendialog.ui b/src/keygendialog.ui index 61643bc8..81a6140c 100644 --- a/src/keygendialog.ui +++ b/src/keygendialog.ui @@ -7,12 +7,16 @@ <x>0</x> <y>0</y> <width>606</width> - <height>480</height> + <height>497</height> </rect> </property> <property name="windowTitle"> <string>Generate GnuPG keypair</string> </property> + <property name="windowIcon"> + <iconset resource="../resources.qrc"> + <normaloff>:/artwork/icon.png</normaloff>:/artwork/icon.png</iconset> + </property> <layout class="QVBoxLayout" name="verticalLayout_2"> <property name="leftMargin"> <number>6</number> @@ -72,18 +76,6 @@ </sizepolicy> </property> <layout class="QFormLayout" name="formLayout"> - <property name="leftMargin"> - <number>0</number> - </property> - <property name="topMargin"> - <number>0</number> - </property> - <property name="rightMargin"> - <number>0</number> - </property> - <property name="bottomMargin"> - <number>0</number> - </property> <item row="0" column="0"> <widget class="QLabel" name="labelEmail"> <property name="sizePolicy"> @@ -101,6 +93,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>email</cstring> + </property> </widget> </item> <item row="0" column="1"> @@ -130,6 +125,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>name</cstring> + </property> </widget> </item> <item row="1" column="1"> @@ -159,6 +157,9 @@ <property name="alignment"> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set> </property> + <property name="buddy"> + <cstring>passphrase1</cstring> + </property> </widget> </item> <item row="2" column="1"> @@ -203,6 +204,13 @@ </property> </widget> </item> + <item row="3" column="0"> + <widget class="QLabel" name="label_2"> + <property name="text"> + <string>Repeat pass</string> + </property> + </widget> + </item> </layout> </widget> </item> @@ -240,8 +248,8 @@ # first test version please comment # %echo Generating a default key -Key-Type: default -Subkey-Type: default +Key-Type: RSA +Subkey-Type: RSA Name-Real: Name-Comment: QtPass Name-Email: @@ -289,12 +297,15 @@ Expire-Date: 0 </widget> <tabstops> <tabstop>email</tabstop> + <tabstop>name</tabstop> <tabstop>passphrase1</tabstop> <tabstop>passphrase2</tabstop> <tabstop>checkBox</tabstop> <tabstop>plainTextEdit</tabstop> </tabstops> - <resources/> + <resources> + <include location="../resources.qrc"/> + </resources> <connections> <connection> <sender>buttonBox</sender> diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d792c6ed..b39d3147 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -6,14 +6,12 @@ #include "configdialog.h" #include "filecontent.h" -#include "keygendialog.h" #include "passworddialog.h" #include "qpushbuttonasqrcode.h" #include "qpushbuttonshowpassword.h" #include "qpushbuttonwithclipboard.h" #include "qtpass.h" #include "qtpasssettings.h" -#include "settingsconstants.h" #include "trayicon.h" #include "ui_mainwindow.h" #include "usersdialog.h" @@ -87,6 +85,12 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent) connect(ui->treeView, &DeselectableTreeView::emptyClicked, this, &MainWindow::deselect); + if (QtPassSettings::isUseMonospace()) { + ui->textBrowser->setFont(QFont(QStringLiteral("Monospace"))); + } + if (QtPassSettings::isNoLineWrapping()) { + ui->textBrowser->setLineWrapMode(QTextBrowser::NoWrap); + } ui->textBrowser->setOpenExternalLinks(true); ui->textBrowser->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->textBrowser, &QWidget::customContextMenuRequested, this, @@ -108,13 +112,10 @@ MainWindow::MainWindow(const QString &searchText, QWidget *parent) initToolBarButtons(); initStatusBar(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) ui->lineEdit->setClearButtonEnabled(true); -#endif setUiElementsEnabled(tr |