From b40e5686dccfb9f60abc186120e9db17edfa81c0 Mon Sep 17 00:00:00 2001 From: Darwin Shameran Date: Sat, 29 Sep 2018 13:44:23 +0200 Subject: [PATCH] Add option to not show password placeholder when field is empty (#2333) * Add option to not show password placeholder when field is empty * Set the option to show an empty passwd field instead of dots to true by default --- share/keepassxc.ini | 1 + src/core/Config.cpp | 1 + src/gui/ApplicationSettingsWidget.cpp | 8 +++---- src/gui/ApplicationSettingsWidgetSecurity.ui | 7 +++++++ src/gui/entry/EntryModel.cpp | 22 ++++++++++++-------- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/share/keepassxc.ini b/share/keepassxc.ini index 54920224..b91fefb4 100644 --- a/share/keepassxc.ini +++ b/share/keepassxc.ini @@ -34,6 +34,7 @@ lockdatabaseidlesec=240 lockdatabaseminimize=false lockdatabasescreenlock=true passwordscleartext=false +passwordemptynodots=true passwordsrepeat=false [Http] diff --git a/src/core/Config.cpp b/src/core/Config.cpp index 1a0f7b43..8f1dc55f 100644 --- a/src/core/Config.cpp +++ b/src/core/Config.cpp @@ -146,6 +146,7 @@ void Config::init(const QString& fileName) m_defaults.insert("security/lockdatabasescreenlock", true); m_defaults.insert("security/passwordsrepeat", false); m_defaults.insert("security/passwordscleartext", false); + m_defaults.insert("security/passwordemptynodots", true); m_defaults.insert("security/hidepassworddetails", true); m_defaults.insert("security/autotypeask", true); m_defaults.insert("security/IconDownloadFallback", false); diff --git a/src/gui/ApplicationSettingsWidget.cpp b/src/gui/ApplicationSettingsWidget.cpp index c4680457..28546204 100644 --- a/src/gui/ApplicationSettingsWidget.cpp +++ b/src/gui/ApplicationSettingsWidget.cpp @@ -88,10 +88,7 @@ ApplicationSettingsWidget::ApplicationSettingsWidget(QWidget* parent) m_secUi->lockDatabaseIdleSpinBox, SLOT(setEnabled(bool))); - connect(m_secUi->touchIDResetCheckBox, - SIGNAL(toggled(bool)), - m_secUi->touchIDResetSpinBox, - SLOT(setEnabled(bool))); + connect(m_secUi->touchIDResetCheckBox, SIGNAL(toggled(bool)), m_secUi->touchIDResetSpinBox, SLOT(setEnabled(bool))); #ifndef WITH_XC_NETWORKING m_secUi->privacy->setVisible(false); @@ -189,6 +186,7 @@ void ApplicationSettingsWidget::loadSettings() m_secUi->fallbackToSearch->setChecked(config()->get("security/IconDownloadFallback").toBool()); m_secUi->passwordCleartextCheckBox->setChecked(config()->get("security/passwordscleartext").toBool()); + m_secUi->passwordShowDotsCheckBox->setChecked(config()->get("security/passwordemptynodots").toBool()); m_secUi->passwordDetailsCleartextCheckBox->setChecked(config()->get("security/hidepassworddetails").toBool()); m_secUi->passwordRepeatCheckBox->setChecked(config()->get("security/passwordsrepeat").toBool()); m_secUi->hideNotesCheckBox->setChecked(config()->get("security/hidenotes").toBool()); @@ -259,6 +257,8 @@ void ApplicationSettingsWidget::saveSettings() config()->set("security/IconDownloadFallback", m_secUi->fallbackToSearch->isChecked()); config()->set("security/passwordscleartext", m_secUi->passwordCleartextCheckBox->isChecked()); + config()->set("security/passwordemptynodots", m_secUi->passwordShowDotsCheckBox->isChecked()); + config()->set("security/hidepassworddetails", m_secUi->passwordDetailsCleartextCheckBox->isChecked()); config()->set("security/passwordsrepeat", m_secUi->passwordRepeatCheckBox->isChecked()); config()->set("security/hidenotes", m_secUi->hideNotesCheckBox->isChecked()); diff --git a/src/gui/ApplicationSettingsWidgetSecurity.ui b/src/gui/ApplicationSettingsWidgetSecurity.ui index bef64dc7..45d2f954 100644 --- a/src/gui/ApplicationSettingsWidgetSecurity.ui +++ b/src/gui/ApplicationSettingsWidgetSecurity.ui @@ -179,6 +179,13 @@ + + + + Don't use placeholder for empty password fields + + + diff --git a/src/gui/entry/EntryModel.cpp b/src/gui/entry/EntryModel.cpp index fe1f7047..0616374a 100644 --- a/src/gui/entry/EntryModel.cpp +++ b/src/gui/entry/EntryModel.cpp @@ -24,6 +24,7 @@ #include #include +#include "core/Config.h" #include "core/DatabaseIcons.h" #include "core/Entry.h" #include "core/Global.h" @@ -172,6 +173,9 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const if (attr->isReference(EntryAttributes::PasswordKey)) { result.prepend(tr("Ref: ", "Reference abbreviation")); } + if (entry->password().isEmpty() && config()->get("security/passwordemptynodots").toBool()) { + result = ""; + } return result; case Url: result = entry->resolveMultiplePlaceholders(entry->displayUrl()); @@ -202,17 +206,17 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const result = entry->timeInfo().lastAccessTime().toLocalTime().toString(EntryModel::DateFormat); return result; case Attachments: { - // Display comma-separated list of attachments - QList attachments = entry->attachments()->keys(); - for (int i = 0; i < attachments.size(); ++i) { - if (result.isEmpty()) { - result.append(attachments.at(i)); - continue; - } - result.append(QString(", ") + attachments.at(i)); + // Display comma-separated list of attachments + QList attachments = entry->attachments()->keys(); + for (int i = 0; i < attachments.size(); ++i) { + if (result.isEmpty()) { + result.append(attachments.at(i)); + continue; } - return result; + result.append(QString(", ") + attachments.at(i)); } + return result; + } case Totp: result = entry->hasTotp() ? tr("Yes") : ""; return result;