Fix button highlighting in multiple dialogs

* Changed style so that only default buttons have full background highlight. This prevents confusion as to which button in various dialogs is the default/desired choice.

* Move password generator popup into static function outside of PasswordEdit so other parts of the program can easily access it.

* QDialog forces 'autoDefault' property on all buttons causing them to obtain background highlight when they are focused. Moved Password Generator outside of a QDialog and forced 'autoDefault' to false on Browser Access Dialog.

* Fixed button ordering in Totp Setup Dialog

* About dialog close button is now the default button
This commit is contained in:
Jonathan White 2020-03-22 19:40:19 -04:00 committed by Janek Bevendorff
parent fbd78037ff
commit 243f68e0e8
9 changed files with 52 additions and 29 deletions

View File

@ -57,6 +57,7 @@ void BrowserAccessControlDialog::setItems(const QList<Entry*>& items, const QStr
m_ui->itemsTable->setItem(row, 0, item); m_ui->itemsTable->setItem(row, 0, item);
auto disableButton = new QPushButton(tr("Disable for this site")); auto disableButton = new QPushButton(tr("Disable for this site"));
disableButton->setAutoDefault(false);
connect(disableButton, &QAbstractButton::pressed, [&, item] { connect(disableButton, &QAbstractButton::pressed, [&, item] {
emit disableAccess(item); emit disableAccess(item);
m_ui->itemsTable->removeRow(item->row()); m_ui->itemsTable->removeRow(item->row());

View File

@ -88,6 +88,12 @@
<property name="text"> <property name="text">
<string>Allow Selected</string> <string>Allow Selected</string>
</property> </property>
<property name="autoDefault">
<bool>true</bool>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item> <item>
@ -96,7 +102,7 @@
<string>Deny All</string> <string>Deny All</string>
</property> </property>
<property name="autoDefault"> <property name="autoDefault">
<bool>false</bool> <bool>true</bool>
</property> </property>
</widget> </widget>
</item> </item>

View File

@ -823,11 +823,6 @@ QList<Entry*> BrowserService::confirmEntries(QList<Entry*>& pwEntriesToConfirm,
accessControlDialog.setItems(pwEntriesToConfirm, !submitHost.isEmpty() ? submitHost : url, httpAuth); accessControlDialog.setItems(pwEntriesToConfirm, !submitHost.isEmpty() ? submitHost : url, httpAuth);
raiseWindow();
accessControlDialog.show();
accessControlDialog.activateWindow();
accessControlDialog.raise();
QList<Entry*> allowedEntries; QList<Entry*> allowedEntries;
if (accessControlDialog.exec() == QDialog::Accepted) { if (accessControlDialog.exec() == QDialog::Accepted) {
const auto selectedEntries = accessControlDialog.getSelectedEntries(); const auto selectedEntries = accessControlDialog.getSelectedEntries();

View File

@ -218,6 +218,8 @@ AboutDialog::AboutDialog(QWidget* parent)
setAttribute(Qt::WA_DeleteOnClose); setAttribute(Qt::WA_DeleteOnClose);
connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close())); connect(m_ui->buttonBox, SIGNAL(rejected()), SLOT(close()));
connect(m_ui->copyToClipboard, SIGNAL(clicked()), SLOT(copyToClipboard())); connect(m_ui->copyToClipboard, SIGNAL(clicked()), SLOT(copyToClipboard()));
m_ui->buttonBox->button(QDialogButtonBox::Close)->setDefault(true);
} }
AboutDialog::~AboutDialog() AboutDialog::~AboutDialog()

View File

@ -126,24 +126,14 @@ bool PasswordEdit::isPasswordVisible() const
void PasswordEdit::popupPasswordGenerator() void PasswordEdit::popupPasswordGenerator()
{ {
auto pwGenerator = new PasswordGeneratorWidget(); auto generator = PasswordGeneratorWidget::popupGenerator(this);
QDialog pwDialog(this); generator->setPasswordVisible(isPasswordVisible());
pwDialog.setWindowTitle(tr("Generate Password")); generator->setPasswordLength(text().length());
auto layout = new QVBoxLayout();
pwDialog.setLayout(layout);
layout->addWidget(pwGenerator);
pwGenerator->setStandaloneMode(false); connect(generator, SIGNAL(appliedPassword(QString)), SLOT(setText(QString)));
pwGenerator->setPasswordVisible(isPasswordVisible());
pwGenerator->setPasswordLength(text().length());
connect(pwGenerator, SIGNAL(closePasswordGenerator()), &pwDialog, SLOT(close()));
connect(pwGenerator, SIGNAL(appliedPassword(QString)), SLOT(setText(QString)));
if (m_repeatPasswordEdit) { if (m_repeatPasswordEdit) {
connect(pwGenerator, SIGNAL(appliedPassword(QString)), m_repeatPasswordEdit, SLOT(setText(QString))); connect(generator, SIGNAL(appliedPassword(QString)), m_repeatPasswordEdit, SLOT(setText(QString)));
} }
pwDialog.exec();
} }
void PasswordEdit::updateRepeatStatus() void PasswordEdit::updateRepeatStatus()

View File

@ -103,6 +103,22 @@ PasswordGeneratorWidget::~PasswordGeneratorWidget()
{ {
} }
PasswordGeneratorWidget* PasswordGeneratorWidget::popupGenerator(QWidget* parent) {
auto pwGenerator = new PasswordGeneratorWidget(parent);
pwGenerator->setWindowModality(Qt::ApplicationModal);
pwGenerator->setWindowFlags(Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
pwGenerator->setStandaloneMode(false);
connect(pwGenerator, SIGNAL(closePasswordGenerator()), pwGenerator, SLOT(deleteLater()));
pwGenerator->show();
pwGenerator->raise();
pwGenerator->activateWindow();
pwGenerator->adjustSize();
return pwGenerator;
}
void PasswordGeneratorWidget::loadSettings() void PasswordGeneratorWidget::loadSettings()
{ {
// Password config // Password config
@ -341,6 +357,9 @@ void PasswordGeneratorWidget::setAdvancedMode(bool state)
| m_ui->checkBoxLogograms->isChecked()); | m_ui->checkBoxLogograms->isChecked());
m_ui->checkBoxExtASCII->setChecked(m_ui->checkBoxExtASCIIAdv->isChecked()); m_ui->checkBoxExtASCII->setChecked(m_ui->checkBoxExtASCIIAdv->isChecked());
} }
QApplication::processEvents();
adjustSize();
} }
void PasswordGeneratorWidget::excludeHexChars() void PasswordGeneratorWidget::excludeHexChars()

View File

@ -54,6 +54,8 @@ public:
QString getGeneratedPassword(); QString getGeneratedPassword();
bool isPasswordVisible() const; bool isPasswordVisible() const;
static PasswordGeneratorWidget* popupGenerator(QWidget* parent = nullptr);
public slots: public slots:
void regeneratePassword(); void regeneratePassword();
void applyPassword(); void applyPassword();

View File

@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>622</width> <width>622</width>
<height>404</height> <height>433</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@ -96,7 +96,7 @@
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
<size> <size>
<width>350</width> <width>450</width>
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
@ -157,6 +157,9 @@ QProgressBar::chunk {
</item> </item>
<item row="0" column="2"> <item row="0" column="2">
<widget class="QPushButton" name="buttonCopy"> <widget class="QPushButton" name="buttonCopy">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Copy password</string> <string>Copy password</string>
</property> </property>
@ -170,6 +173,9 @@ QProgressBar::chunk {
</item> </item>
<item row="0" column="1"> <item row="0" column="1">
<widget class="QPushButton" name="buttonGenerate"> <widget class="QPushButton" name="buttonGenerate">
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="accessibleDescription"> <property name="accessibleDescription">
<string>Regenerate password</string> <string>Regenerate password</string>
</property> </property>
@ -290,9 +296,6 @@ QProgressBar::chunk {
<height>0</height> <height>0</height>
</size> </size>
</property> </property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="title"> <property name="title">
<string>Character Types</string> <string>Character Types</string>
</property> </property>
@ -323,9 +326,6 @@ QProgressBar::chunk {
<height>25</height> <height>25</height>
</size> </size>
</property> </property>
<property name="focusPolicy">
<enum>Qt::TabFocus</enum>
</property>
<property name="toolTip"> <property name="toolTip">
<string>Upper-case letters</string> <string>Upper-case letters</string>
</property> </property>
@ -1200,6 +1200,7 @@ QProgressBar::chunk {
<tabstop>sliderLength</tabstop> <tabstop>sliderLength</tabstop>
<tabstop>spinBoxLength</tabstop> <tabstop>spinBoxLength</tabstop>
<tabstop>buttonAdvancedMode</tabstop> <tabstop>buttonAdvancedMode</tabstop>
<tabstop>groupBox</tabstop>
<tabstop>checkBoxUpper</tabstop> <tabstop>checkBoxUpper</tabstop>
<tabstop>checkBoxLower</tabstop> <tabstop>checkBoxLower</tabstop>
<tabstop>checkBoxNumbers</tabstop> <tabstop>checkBoxNumbers</tabstop>
@ -1215,6 +1216,11 @@ QProgressBar::chunk {
<tabstop>checkBoxQuotes</tabstop> <tabstop>checkBoxQuotes</tabstop>
<tabstop>checkBoxDashes</tabstop> <tabstop>checkBoxDashes</tabstop>
<tabstop>checkBoxExtASCIIAdv</tabstop> <tabstop>checkBoxExtASCIIAdv</tabstop>
<tabstop>editAdditionalChars</tabstop>
<tabstop>editExcludedChars</tabstop>
<tabstop>buttonAddHex</tabstop>
<tabstop>checkBoxExcludeAlike</tabstop>
<tabstop>checkBoxEnsureEvery</tabstop>
<tabstop>comboBoxWordList</tabstop> <tabstop>comboBoxWordList</tabstop>
<tabstop>sliderWordCount</tabstop> <tabstop>sliderWordCount</tabstop>
<tabstop>spinBoxWordCount</tabstop> <tabstop>spinBoxWordCount</tabstop>

View File

@ -216,7 +216,9 @@
<tabstop>radioDefault</tabstop> <tabstop>radioDefault</tabstop>
<tabstop>radioSteam</tabstop> <tabstop>radioSteam</tabstop>
<tabstop>radioCustom</tabstop> <tabstop>radioCustom</tabstop>
<tabstop>algorithmComboBox</tabstop>
<tabstop>stepSpinBox</tabstop> <tabstop>stepSpinBox</tabstop>
<tabstop>digitsSpinBox</tabstop>
</tabstops> </tabstops>
<resources/> <resources/>
<connections/> <connections/>