mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-25 23:39:45 -05:00
Set password input field font correctly. (#8732)
Also update member variable names to describe their contents better. Fixes #8709
This commit is contained in:
parent
033dd79c58
commit
3cbe4df8c7
@ -54,7 +54,7 @@ PasswordWidget::PasswordWidget(QWidget* parent)
|
|||||||
// use a monospace font for the password field
|
// use a monospace font for the password field
|
||||||
QFont passwordFont = Font::fixedFont();
|
QFont passwordFont = Font::fixedFont();
|
||||||
passwordFont.setLetterSpacing(QFont::PercentageSpacing, 110);
|
passwordFont.setLetterSpacing(QFont::PercentageSpacing, 110);
|
||||||
setFont(passwordFont);
|
m_ui->passwordEdit->setFont(passwordFont);
|
||||||
|
|
||||||
// Prevent conflicts with global Mac shortcuts (force Control on all platforms)
|
// Prevent conflicts with global Mac shortcuts (force Control on all platforms)
|
||||||
#ifdef Q_OS_MAC
|
#ifdef Q_OS_MAC
|
||||||
@ -143,19 +143,19 @@ void PasswordWidget::setReadOnly(bool state)
|
|||||||
m_ui->passwordEdit->setReadOnly(state);
|
m_ui->passwordEdit->setReadOnly(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordWidget::setRepeatPartner(PasswordWidget* repeatEdit)
|
void PasswordWidget::setRepeatPartner(PasswordWidget* repeatPartner)
|
||||||
{
|
{
|
||||||
m_repeatPasswordEdit = repeatEdit;
|
m_repeatPasswordWidget = repeatPartner;
|
||||||
m_repeatPasswordEdit->setParentPasswordEdit(this);
|
m_repeatPasswordWidget->setParentPasswordEdit(this);
|
||||||
|
|
||||||
connect(
|
connect(
|
||||||
m_ui->passwordEdit, SIGNAL(textChanged(QString)), m_repeatPasswordEdit, SLOT(autocompletePassword(QString)));
|
m_ui->passwordEdit, SIGNAL(textChanged(QString)), m_repeatPasswordWidget, SLOT(autocompletePassword(QString)));
|
||||||
connect(m_ui->passwordEdit, SIGNAL(textChanged(QString)), m_repeatPasswordEdit, SLOT(updateRepeatStatus()));
|
connect(m_ui->passwordEdit, SIGNAL(textChanged(QString)), m_repeatPasswordWidget, SLOT(updateRepeatStatus()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordWidget::setParentPasswordEdit(PasswordWidget* parent)
|
void PasswordWidget::setParentPasswordEdit(PasswordWidget* parent)
|
||||||
{
|
{
|
||||||
m_parentPasswordEdit = parent;
|
m_parentPasswordWidget = parent;
|
||||||
// Hide actions
|
// Hide actions
|
||||||
m_toggleVisibleAction->setVisible(false);
|
m_toggleVisibleAction->setVisible(false);
|
||||||
m_passwordGeneratorAction->setVisible(false);
|
m_passwordGeneratorAction->setVisible(false);
|
||||||
@ -176,13 +176,13 @@ void PasswordWidget::setShowPassword(bool show)
|
|||||||
m_toggleVisibleAction->setIcon(icons()->onOffIcon("password-show", show));
|
m_toggleVisibleAction->setIcon(icons()->onOffIcon("password-show", show));
|
||||||
m_toggleVisibleAction->setChecked(show);
|
m_toggleVisibleAction->setChecked(show);
|
||||||
|
|
||||||
if (m_repeatPasswordEdit) {
|
if (m_repeatPasswordWidget) {
|
||||||
m_repeatPasswordEdit->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password);
|
m_repeatPasswordWidget->setEchoMode(show ? QLineEdit::Normal : QLineEdit::Password);
|
||||||
if (!config()->get(Config::Security_PasswordsRepeatVisible).toBool()) {
|
if (!config()->get(Config::Security_PasswordsRepeatVisible).toBool()) {
|
||||||
m_repeatPasswordEdit->setEnabled(!show);
|
m_repeatPasswordWidget->setEnabled(!show);
|
||||||
m_repeatPasswordEdit->setText(text());
|
m_repeatPasswordWidget->setText(text());
|
||||||
} else {
|
} else {
|
||||||
m_repeatPasswordEdit->setEnabled(true);
|
m_repeatPasswordWidget->setEnabled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -199,19 +199,19 @@ void PasswordWidget::popupPasswordGenerator()
|
|||||||
generator->setPasswordLength(text().length());
|
generator->setPasswordLength(text().length());
|
||||||
|
|
||||||
connect(generator, SIGNAL(appliedPassword(QString)), SLOT(setText(QString)));
|
connect(generator, SIGNAL(appliedPassword(QString)), SLOT(setText(QString)));
|
||||||
if (m_repeatPasswordEdit) {
|
if (m_repeatPasswordWidget) {
|
||||||
connect(generator, SIGNAL(appliedPassword(QString)), m_repeatPasswordEdit, SLOT(setText(QString)));
|
connect(generator, SIGNAL(appliedPassword(QString)), m_repeatPasswordWidget, SLOT(setText(QString)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PasswordWidget::updateRepeatStatus()
|
void PasswordWidget::updateRepeatStatus()
|
||||||
{
|
{
|
||||||
static const auto stylesheetTemplate = QStringLiteral("QLineEdit { background: %1; }");
|
static const auto stylesheetTemplate = QStringLiteral("QLineEdit { background: %1; }");
|
||||||
if (!m_parentPasswordEdit) {
|
if (!m_parentPasswordWidget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto otherPassword = m_parentPasswordEdit->text();
|
const auto otherPassword = m_parentPasswordWidget->text();
|
||||||
const auto password = text();
|
const auto password = text();
|
||||||
if (otherPassword != password) {
|
if (otherPassword != password) {
|
||||||
bool isCorrect = false;
|
bool isCorrect = false;
|
||||||
@ -251,7 +251,7 @@ bool PasswordWidget::event(QEvent* event)
|
|||||||
|
|
||||||
void PasswordWidget::checkCapslockState()
|
void PasswordWidget::checkCapslockState()
|
||||||
{
|
{
|
||||||
if (m_parentPasswordEdit) {
|
if (m_parentPasswordWidget) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public:
|
|||||||
explicit PasswordWidget(QWidget* parent = nullptr);
|
explicit PasswordWidget(QWidget* parent = nullptr);
|
||||||
~PasswordWidget() override;
|
~PasswordWidget() override;
|
||||||
void enablePasswordGenerator();
|
void enablePasswordGenerator();
|
||||||
void setRepeatPartner(PasswordWidget* repeatEdit);
|
void setRepeatPartner(PasswordWidget* repeatPartner);
|
||||||
void setQualityVisible(bool state);
|
void setQualityVisible(bool state);
|
||||||
|
|
||||||
bool isPasswordVisible() const;
|
bool isPasswordVisible() const;
|
||||||
@ -76,8 +76,8 @@ private:
|
|||||||
QPointer<QAction> m_toggleVisibleAction;
|
QPointer<QAction> m_toggleVisibleAction;
|
||||||
QPointer<QAction> m_passwordGeneratorAction;
|
QPointer<QAction> m_passwordGeneratorAction;
|
||||||
QPointer<QAction> m_capslockAction;
|
QPointer<QAction> m_capslockAction;
|
||||||
QPointer<PasswordWidget> m_repeatPasswordEdit;
|
QPointer<PasswordWidget> m_repeatPasswordWidget;
|
||||||
QPointer<PasswordWidget> m_parentPasswordEdit;
|
QPointer<PasswordWidget> m_parentPasswordWidget;
|
||||||
|
|
||||||
bool m_capslockState = false;
|
bool m_capslockState = false;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user