2
* Copyright (C) 2012 Felix Geyer <debfx@fobos.de>
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation, either version 2 or (at your option)
7
* version 3 of the License.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
#include "DialogyWidget.h"
23
DialogyWidget::DialogyWidget(QWidget* parent)
26
setAutoFillBackground(true);
29
void DialogyWidget::keyPressEvent(QKeyEvent* e)
32
if (e->modifiers() == Qt::ControlModifier && e->key() == Qt::Key_Period) {
33
if (!clickButton(QDialogButtonBox::Cancel)) {
38
if (!e->modifiers() || e->modifiers() == Qt::ControlModifier
39
|| (e->modifiers() & Qt::KeypadModifier && e->key() == Qt::Key_Enter)) {
43
if (!clickButton(QDialogButtonBox::Ok)) {
48
if (!clickButton(QDialogButtonBox::Cancel)) {
49
if (!clickButton(QDialogButtonBox::Close)) {
62
bool DialogyWidget::clickButton(QDialogButtonBox::StandardButton standardButton)
66
if (standardButton == QDialogButtonBox::Ok) {
67
pb = qobject_cast<QPushButton*>(focusWidget());
68
if (pb && pb->isVisible() && pb->isEnabled() && pb->hasFocus()) {
74
QList<QDialogButtonBox*> buttonBoxes = findChildren<QDialogButtonBox*>();
75
for (auto buttonBox : buttonBoxes) {
76
pb = buttonBox->button(standardButton);
77
if (pb && pb->isVisible() && pb->isEnabled()) {