mirror of
https://github.com/tnodir/fort
synced 2024-11-15 09:45:44 +00:00
UI: ProgramEditDialog: Handle default button
This commit is contained in:
parent
3733819936
commit
f08af8834b
@ -589,6 +589,7 @@ QLayout *ProgramEditDialog::setupButtonsLayout()
|
||||
{
|
||||
setupAdvancedMode();
|
||||
|
||||
// OK
|
||||
m_btOk = ControlUtil::createButton(QString(), [&] {
|
||||
if (save()) {
|
||||
closeOnSave();
|
||||
@ -596,6 +597,9 @@ QLayout *ProgramEditDialog::setupButtonsLayout()
|
||||
});
|
||||
m_btOk->setDefault(true);
|
||||
|
||||
connect(this, &WidgetWindow::defaultButtonPressed, m_btOk, &QAbstractButton::click);
|
||||
|
||||
// Cancel
|
||||
m_btCancel = new QPushButton();
|
||||
connect(m_btCancel, &QAbstractButton::clicked, this, &QWidget::close);
|
||||
|
||||
|
@ -91,12 +91,17 @@ void WidgetWindow::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
QWidget::keyPressEvent(event);
|
||||
|
||||
if (event->modifiers() != Qt::NoModifier)
|
||||
return;
|
||||
|
||||
switch (event->key()) {
|
||||
case Qt::Key_Escape:
|
||||
if (event->modifiers() == Qt::NoModifier) {
|
||||
case Qt::Key_Return:
|
||||
case Qt::Key_Enter: {
|
||||
emit defaultButtonPressed();
|
||||
} break;
|
||||
case Qt::Key_Escape: {
|
||||
close();
|
||||
}
|
||||
break;
|
||||
} break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -35,6 +35,8 @@ signals:
|
||||
void aboutToShow();
|
||||
void aboutToClose(QEvent *event);
|
||||
|
||||
void defaultButtonPressed();
|
||||
|
||||
protected:
|
||||
void moveEvent(QMoveEvent *event) override;
|
||||
void resizeEvent(QResizeEvent *event) override;
|
||||
|
Loading…
Reference in New Issue
Block a user