Remove inline password generator when editing entries
* Always use a pop-up generator to avoid cluttering the user interface and making it clear that a password is being created
This commit is contained in:
@@ -94,14 +94,10 @@ void PasswordEdit::setParentPasswordEdit(PasswordEdit* parent)
|
||||
m_passwordGeneratorAction->setVisible(false);
|
||||
}
|
||||
|
||||
void PasswordEdit::enablePasswordGenerator(bool signalOnly)
|
||||
void PasswordEdit::enablePasswordGenerator()
|
||||
{
|
||||
disconnect(m_passwordGeneratorAction);
|
||||
m_passwordGeneratorAction->setVisible(true);
|
||||
|
||||
if (signalOnly) {
|
||||
connect(m_passwordGeneratorAction, &QAction::triggered, this, &PasswordEdit::togglePasswordGenerator);
|
||||
} else {
|
||||
if (!m_passwordGeneratorAction->isVisible()) {
|
||||
m_passwordGeneratorAction->setVisible(true);
|
||||
connect(m_passwordGeneratorAction, &QAction::triggered, this, &PasswordEdit::popupPasswordGenerator);
|
||||
}
|
||||
}
|
||||
@@ -139,6 +135,7 @@ void PasswordEdit::popupPasswordGenerator()
|
||||
|
||||
pwGenerator->setStandaloneMode(false);
|
||||
pwGenerator->setPasswordVisible(isPasswordVisible());
|
||||
pwGenerator->setPasswordLength(text().length());
|
||||
|
||||
connect(pwGenerator, SIGNAL(closePasswordGenerator()), &pwDialog, SLOT(close()));
|
||||
connect(pwGenerator, SIGNAL(appliedPassword(QString)), SLOT(setText(QString)));
|
||||
|
||||
@@ -23,13 +23,15 @@
|
||||
#include <QLineEdit>
|
||||
#include <QPointer>
|
||||
|
||||
class QDialog;
|
||||
|
||||
class PasswordEdit : public QLineEdit
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit PasswordEdit(QWidget* parent = nullptr);
|
||||
void enablePasswordGenerator(bool signalOnly = false);
|
||||
void enablePasswordGenerator();
|
||||
void setRepeatPartner(PasswordEdit* repeatEdit);
|
||||
bool isPasswordVisible() const;
|
||||
|
||||
@@ -37,9 +39,6 @@ public slots:
|
||||
void setShowPassword(bool show);
|
||||
void updateRepeatStatus();
|
||||
|
||||
signals:
|
||||
void togglePasswordGenerator();
|
||||
|
||||
private slots:
|
||||
void autocompletePassword(const QString& password);
|
||||
void popupPasswordGenerator();
|
||||
|
||||
@@ -187,18 +187,13 @@ void PasswordGeneratorWidget::saveSettings()
|
||||
config()->set("generator/Type", m_ui->tabWidget->currentIndex());
|
||||
}
|
||||
|
||||
void PasswordGeneratorWidget::reset(int length)
|
||||
void PasswordGeneratorWidget::setPasswordLength(int length)
|
||||
{
|
||||
m_ui->editNewPassword->setText("");
|
||||
if (length > 0) {
|
||||
m_ui->spinBoxLength->setValue(length);
|
||||
} else {
|
||||
m_ui->spinBoxLength->setValue(config()->get("generator/Length", PasswordGenerator::DefaultLength).toInt());
|
||||
}
|
||||
|
||||
setStandaloneMode(false);
|
||||
setPasswordVisible(config()->get("security/passwordscleartext").toBool());
|
||||
updateGenerator();
|
||||
}
|
||||
|
||||
void PasswordGeneratorWidget::setStandaloneMode(bool standalone)
|
||||
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
~PasswordGeneratorWidget();
|
||||
void loadSettings();
|
||||
void saveSettings();
|
||||
void reset(int length = 0);
|
||||
void setPasswordLength(int length);
|
||||
void setStandaloneMode(bool standalone);
|
||||
QString getGeneratedPassword();
|
||||
bool isPasswordVisible() const;
|
||||
|
||||
@@ -128,8 +128,6 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
||||
|
||||
connect(m_iconsWidget, SIGNAL(messageEditEntryDismiss()), SLOT(hideMessage()));
|
||||
|
||||
m_mainUi->passwordGenerator->layout()->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
m_editWidgetProperties->setCustomData(m_customData.data());
|
||||
}
|
||||
|
||||
@@ -163,14 +161,8 @@ void EditEntryWidget::setupMain()
|
||||
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
|
||||
connect(m_mainUi->notesEnabled, SIGNAL(toggled(bool)), this, SLOT(toggleHideNotes(bool)));
|
||||
|
||||
connect(m_mainUi->passwordGenerator, SIGNAL(appliedPassword(QString)), SLOT(setGeneratedPassword(QString)));
|
||||
connect(m_mainUi->passwordGenerator, SIGNAL(closePasswordGenerator()), SLOT(togglePasswordGenerator()));
|
||||
|
||||
m_mainUi->expirePresets->setMenu(createPresetsMenu());
|
||||
connect(m_mainUi->expirePresets->menu(), SIGNAL(triggered(QAction*)), this, SLOT(useExpiryPreset(QAction*)));
|
||||
|
||||
m_mainUi->passwordGenerator->hide();
|
||||
m_mainUi->passwordGenerator->reset();
|
||||
}
|
||||
|
||||
void EditEntryWidget::setupAdvanced()
|
||||
@@ -816,8 +808,6 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
|
||||
} else {
|
||||
m_mainUi->notesEdit->setFont(Font::defaultFont());
|
||||
}
|
||||
m_mainUi->passwordGenerator->setVisible(false);
|
||||
m_mainUi->passwordGenerator->reset(entry->password().length());
|
||||
|
||||
m_advancedUi->attachmentsWidget->setReadOnly(m_history);
|
||||
m_advancedUi->addAttributeButton->setEnabled(!m_history);
|
||||
@@ -845,13 +835,12 @@ void EditEntryWidget::setForms(Entry* entry, bool restore)
|
||||
m_mainUi->passwordEdit->setText(entry->password());
|
||||
m_mainUi->passwordEdit->setShowPassword(config()->get("security/passwordscleartext").toBool());
|
||||
if (!m_history) {
|
||||
m_mainUi->passwordEdit->enablePasswordGenerator(true);
|
||||
m_mainUi->passwordEdit->enablePasswordGenerator();
|
||||
}
|
||||
m_mainUi->expireCheck->setChecked(entry->timeInfo().expires());
|
||||
m_mainUi->expireDatePicker->setDateTime(entry->timeInfo().expiryTime().toLocalTime());
|
||||
m_mainUi->expirePresets->setEnabled(!m_history);
|
||||
|
||||
|
||||
QList<QString> commonUsernames = m_db->commonUsernames();
|
||||
m_usernameCompleterModel->setStringList(commonUsernames);
|
||||
QString usernameToRestore = m_mainUi->usernameComboBox->lineEdit()->text();
|
||||
@@ -970,22 +959,6 @@ bool EditEntryWidget::commitEntry()
|
||||
return true;
|
||||
}
|
||||
|
||||
// Ask the user to apply the generator password, if open
|
||||
if (m_mainUi->passwordGenerator->isVisible()
|
||||
&& m_mainUi->passwordGenerator->getGeneratedPassword() != m_mainUi->passwordEdit->text()) {
|
||||
auto answer = MessageBox::question(this,
|
||||
tr("Apply generated password?"),
|
||||
tr("Do you want to apply the generated password to this entry?"),
|
||||
MessageBox::Yes | MessageBox::No,
|
||||
MessageBox::Yes);
|
||||
if (answer == MessageBox::Yes) {
|
||||
m_mainUi->passwordGenerator->applyPassword();
|
||||
}
|
||||
}
|
||||
|
||||
// Hide the password generator
|
||||
m_mainUi->passwordGenerator->setVisible(false);
|
||||
|
||||
if (m_advancedUi->attributesView->currentIndex().isValid() && m_advancedUi->attributesEdit->isEnabled()) {
|
||||
QString key = m_attributesModel->keyByIndex(m_advancedUi->attributesView->currentIndex());
|
||||
m_entryAttributes->set(key, m_advancedUi->attributesEdit->toPlainText(), m_entryAttributes->isProtected(key));
|
||||
@@ -1142,22 +1115,6 @@ void EditEntryWidget::clear()
|
||||
hideMessage();
|
||||
}
|
||||
|
||||
void EditEntryWidget::togglePasswordGenerator()
|
||||
{
|
||||
bool visible = m_mainUi->passwordGenerator->isVisible();
|
||||
if (!visible) {
|
||||
m_mainUi->passwordGenerator->regeneratePassword();
|
||||
m_mainUi->passwordGenerator->setPasswordVisible(m_mainUi->passwordEdit->isPasswordVisible());
|
||||
}
|
||||
m_mainUi->passwordGenerator->setVisible(!visible);
|
||||
}
|
||||
|
||||
void EditEntryWidget::setGeneratedPassword(const QString& password)
|
||||
{
|
||||
m_mainUi->passwordEdit->setText(password);
|
||||
m_mainUi->passwordGenerator->setVisible(false);
|
||||
}
|
||||
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
void EditEntryWidget::updateFaviconButtonEnable(const QString& url)
|
||||
{
|
||||
|
||||
@@ -83,8 +83,6 @@ private slots:
|
||||
void acceptEntry();
|
||||
bool commitEntry();
|
||||
void cancel();
|
||||
void togglePasswordGenerator();
|
||||
void setGeneratedPassword(const QString& password);
|
||||
#ifdef WITH_XC_NETWORKING
|
||||
void updateFaviconButtonEnable(const QString& url);
|
||||
#endif
|
||||
|
||||
@@ -20,7 +20,65 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="7" column="0" alignment="Qt::AlignRight">
|
||||
<item row="8" column="1">
|
||||
<widget class="QLabel" name="notesHint">
|
||||
<property name="visible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Toggle the checkbox to reveal the notes section.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="usernameComboBox">
|
||||
<property name="accessibleName">
|
||||
<string>Username field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="URLEdit" name="urlEdit">
|
||||
<property name="accessibleName">
|
||||
<string>Url field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="fetchFaviconButton">
|
||||
<property name="toolTip">
|
||||
<string>Download favicon for URL</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Download favicon for URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="4" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="urlLabel">
|
||||
<property name="text">
|
||||
<string>URL:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="PasswordEdit" name="passwordEdit">
|
||||
<property name="accessibleName">
|
||||
<string>Password field</string>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QCheckBox" name="expireCheck">
|
||||
<property name="toolTip">
|
||||
<string>Toggle expiration</string>
|
||||
@@ -33,7 +91,53 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QPlainTextEdit" name="notesEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Notes field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
|
||||
<widget class="QCheckBox" name="notesEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Toggle notes visible</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Toggle notes visible</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Notes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="titleEdit">
|
||||
<property name="accessibleName">
|
||||
<string>Title field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QDateTimeEdit" name="expireDatePicker">
|
||||
@@ -69,83 +173,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QPlainTextEdit" name="notesEdit">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>1</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Notes field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QComboBox" name="usernameComboBox">
|
||||
<property name="accessibleName">
|
||||
<string>Username field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="PasswordGeneratorWidget" name="passwordGenerator" native="true"/>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="titleEdit">
|
||||
<property name="accessibleName">
|
||||
<string>Title field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_6">
|
||||
<item>
|
||||
<widget class="URLEdit" name="urlEdit">
|
||||
<property name="accessibleName">
|
||||
<string>Url field</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="fetchFaviconButton">
|
||||
<property name="toolTip">
|
||||
<string>Download favicon for URL</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Download favicon for URL</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLabel" name="notesHint">
|
||||
<property name="visible">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Toggle the checkbox to reveal the notes section.</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignTop</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="urlLabel">
|
||||
<property name="text">
|
||||
<string>URL:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="usernameLabel">
|
||||
<property name="text">
|
||||
@@ -153,36 +180,6 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0" alignment="Qt::AlignLeft|Qt::AlignTop">
|
||||
<widget class="QCheckBox" name="notesEnabled">
|
||||
<property name="toolTip">
|
||||
<string>Toggle notes visible</string>
|
||||
</property>
|
||||
<property name="accessibleName">
|
||||
<string>Toggle notes visible</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Notes</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" alignment="Qt::AlignRight">
|
||||
<widget class="QLabel" name="passwordLabel">
|
||||
<property name="text">
|
||||
<string>Password:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="PasswordEdit" name="passwordEdit">
|
||||
<property name="accessibleName">
|
||||
<string>Password field</string>
|
||||
</property>
|
||||
<property name="echoMode">
|
||||
<enum>QLineEdit::Password</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<widget class="QLabel" name="titleLabel">
|
||||
<property name="geometry">
|
||||
@@ -199,12 +196,6 @@
|
||||
</widget>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>PasswordGeneratorWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>gui/PasswordGeneratorWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>PasswordEdit</class>
|
||||
<extends>QLineEdit</extends>
|
||||
|
||||
Reference in New Issue
Block a user