mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-27 16:29:44 -05:00
Add password repeat check for entry passwords.
This commit is contained in:
parent
fc8f1231c6
commit
7c70eccaf7
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <QtGui/QListWidget>
|
#include <QtGui/QListWidget>
|
||||||
#include <QtGui/QStackedLayout>
|
#include <QtGui/QStackedLayout>
|
||||||
|
#include <QtGui/QMessageBox>
|
||||||
|
|
||||||
#include "core/Entry.h"
|
#include "core/Entry.h"
|
||||||
#include "core/Group.h"
|
#include "core/Group.h"
|
||||||
@ -74,6 +75,8 @@ EditEntryWidget::EditEntryWidget(QWidget* parent)
|
|||||||
|
|
||||||
connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePassword(bool)));
|
connect(m_mainUi->togglePasswordButton, SIGNAL(toggled(bool)), SLOT(togglePassword(bool)));
|
||||||
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
|
connect(m_mainUi->expireCheck, SIGNAL(toggled(bool)), m_mainUi->expireDatePicker, SLOT(setEnabled(bool)));
|
||||||
|
connect(m_mainUi->passwordEdit, SIGNAL(textEdited(QString)), SLOT(setPasswordCheckColors()));
|
||||||
|
connect(m_mainUi->passwordRepeatEdit, SIGNAL(textEdited(QString)), SLOT(setPasswordCheckColors()));
|
||||||
|
|
||||||
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(saveEntry()));
|
connect(m_ui->buttonBox, SIGNAL(accepted()), SLOT(saveEntry()));
|
||||||
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel()));
|
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(cancel()));
|
||||||
@ -83,6 +86,10 @@ EditEntryWidget::~EditEntryWidget()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QColor EditEntryWidget::normalColor = Qt::white;
|
||||||
|
const QColor EditEntryWidget::correctSoFarColor = QColor(255, 205, 15);
|
||||||
|
const QColor EditEntryWidget::errorColor = QColor(255, 125, 125);
|
||||||
|
|
||||||
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName)
|
void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupName)
|
||||||
{
|
{
|
||||||
m_entry = entry;
|
m_entry = entry;
|
||||||
@ -99,6 +106,7 @@ void EditEntryWidget::loadEntry(Entry* entry, bool create, const QString& groupN
|
|||||||
m_mainUi->urlEdit->setText(entry->url());
|
m_mainUi->urlEdit->setText(entry->url());
|
||||||
m_mainUi->passwordEdit->setText(entry->password());
|
m_mainUi->passwordEdit->setText(entry->password());
|
||||||
m_mainUi->passwordRepeatEdit->setText(entry->password());
|
m_mainUi->passwordRepeatEdit->setText(entry->password());
|
||||||
|
setPasswordCheckColors();
|
||||||
m_mainUi->expireCheck->setChecked(entry->timeInfo().expires());
|
m_mainUi->expireCheck->setChecked(entry->timeInfo().expires());
|
||||||
m_mainUi->expireDatePicker->setDateTime(entry->timeInfo().expiryTime());
|
m_mainUi->expireDatePicker->setDateTime(entry->timeInfo().expiryTime());
|
||||||
m_mainUi->togglePasswordButton->setChecked(true);
|
m_mainUi->togglePasswordButton->setChecked(true);
|
||||||
@ -118,7 +126,10 @@ void EditEntryWidget::saveEntry()
|
|||||||
m_entry->setTitle(m_mainUi->titleEdit->text());
|
m_entry->setTitle(m_mainUi->titleEdit->text());
|
||||||
m_entry->setUsername(m_mainUi->usernameEdit->text());
|
m_entry->setUsername(m_mainUi->usernameEdit->text());
|
||||||
m_entry->setUrl(m_mainUi->urlEdit->text());
|
m_entry->setUrl(m_mainUi->urlEdit->text());
|
||||||
// TODO check password repeat field
|
if (!passwordsEqual()) {
|
||||||
|
QMessageBox::warning(this, tr("Error"), tr("Different passwords supplied."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
m_entry->setPassword(m_mainUi->passwordEdit->text());
|
m_entry->setPassword(m_mainUi->passwordEdit->text());
|
||||||
m_entry->setExpires(m_mainUi->expireCheck->isChecked());
|
m_entry->setExpires(m_mainUi->expireCheck->isChecked());
|
||||||
QDateTime dateTime(m_mainUi->expireDatePicker->dateTime());
|
QDateTime dateTime(m_mainUi->expireDatePicker->dateTime());
|
||||||
@ -147,3 +158,25 @@ void EditEntryWidget::togglePassword(bool checked)
|
|||||||
m_mainUi->passwordEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal);
|
m_mainUi->passwordEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal);
|
||||||
m_mainUi->passwordRepeatEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal);
|
m_mainUi->passwordRepeatEdit->setEchoMode(checked ? QLineEdit::Password : QLineEdit::Normal);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool EditEntryWidget::passwordsEqual()
|
||||||
|
{
|
||||||
|
return m_mainUi->passwordEdit->text() == m_mainUi->passwordRepeatEdit->text();
|
||||||
|
}
|
||||||
|
|
||||||
|
void EditEntryWidget::setPasswordCheckColors()
|
||||||
|
{
|
||||||
|
QPalette pal;
|
||||||
|
if (passwordsEqual()) {
|
||||||
|
pal.setColor(QPalette::Base, normalColor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (m_mainUi->passwordEdit->text().startsWith(m_mainUi->passwordRepeatEdit->text())) {
|
||||||
|
pal.setColor(QPalette::Base, correctSoFarColor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
pal.setColor(QPalette::Base, errorColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_mainUi->passwordRepeatEdit->setPalette(pal);
|
||||||
|
}
|
||||||
|
@ -46,6 +46,10 @@ public:
|
|||||||
|
|
||||||
void loadEntry(Entry* entry, bool create, const QString& groupName);
|
void loadEntry(Entry* entry, bool create, const QString& groupName);
|
||||||
|
|
||||||
|
static const QColor normalColor;
|
||||||
|
static const QColor correctSoFarColor;
|
||||||
|
static const QColor errorColor;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void editFinished(bool accepted);
|
void editFinished(bool accepted);
|
||||||
|
|
||||||
@ -53,6 +57,7 @@ private Q_SLOTS:
|
|||||||
void saveEntry();
|
void saveEntry();
|
||||||
void cancel();
|
void cancel();
|
||||||
void togglePassword(bool checked);
|
void togglePassword(bool checked);
|
||||||
|
void setPasswordCheckColors();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Entry* m_entry;
|
Entry* m_entry;
|
||||||
@ -69,6 +74,8 @@ private:
|
|||||||
EntryAttachments* m_entryAttachments;
|
EntryAttachments* m_entryAttachments;
|
||||||
EntryAttributes* m_entryAttributes;
|
EntryAttributes* m_entryAttributes;
|
||||||
|
|
||||||
|
bool passwordsEqual();
|
||||||
|
|
||||||
Q_DISABLE_COPY(EditEntryWidget)
|
Q_DISABLE_COPY(EditEntryWidget)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user