mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-12-28 00:39:43 -05:00
Make dialogy widget work with arbitrary buttons in button boxes.
This commit is contained in:
parent
5ce9b5da78
commit
7a3a783eeb
@ -59,32 +59,23 @@ void DialogyWidget::keyPressEvent(QKeyEvent *e)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton button)
|
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton)
|
||||||
{
|
{
|
||||||
Q_ASSERT(button == QDialogButtonBox::Ok || button == QDialogButtonBox::Cancel);
|
QPushButton* pb = qobject_cast<QPushButton*>(focusWidget());
|
||||||
|
if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) {
|
||||||
|
pb->click();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();
|
QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();
|
||||||
for (int i = 0; i < buttonBoxes.size(); ++i) {
|
for (int i = 0; i < buttonBoxes.size(); ++i) {
|
||||||
QDialogButtonBox* buttonBox = buttonBoxes.at(i);
|
QDialogButtonBox* buttonBox = buttonBoxes.at(i);
|
||||||
QPushButton* pb;
|
pb = buttonBox->button(standardButton);
|
||||||
QPushButton* pbCancel = buttonBox->button(QDialogButtonBox::Cancel);
|
if (pb && pb->isVisible() && pb->isEnabled()) {
|
||||||
if (button == QDialogButtonBox::Ok) {
|
pb->click();
|
||||||
if (pbCancel && pbCancel->isVisible() && pbCancel->isEnabled() && pbCancel->hasFocus()) {
|
return true;
|
||||||
pbCancel->click();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
pb = buttonBox->button(button);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
pb = pbCancel;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pb) {
|
|
||||||
if (pb->isVisible() && pb->isEnabled()) {
|
|
||||||
pb->click();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ protected:
|
|||||||
virtual void keyPressEvent(QKeyEvent *e);
|
virtual void keyPressEvent(QKeyEvent *e);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool clickButton(QDialogButtonBox::StandardButton button);
|
bool clickButton(QDialogButtonBox::StandardButton standardButton);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user