diff options
-rw-r--r-- | qt-ui/maintab.cpp | 12 | ||||
-rw-r--r-- | qt-ui/maintab.h | 1 |
2 files changed, 13 insertions, 0 deletions
diff --git a/qt-ui/maintab.cpp b/qt-ui/maintab.cpp index 7c28a4972..e274b7485 100644 --- a/qt-ui/maintab.cpp +++ b/qt-ui/maintab.cpp @@ -26,6 +26,7 @@ #include <QTableView> #include <QPalette> #include <QScrollBar> +#include <QShortcut> MainTab::MainTab(QWidget *parent) : QTabWidget(parent), weightModel(new WeightModel(this)), @@ -48,6 +49,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent), action = new QAction(tr("Cancel"), this); connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges())); + + QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); + connect(closeKey, SIGNAL(activated()), this, SLOT(escDetected())); + addMessageAction(action); if (qApp->style()->objectName() == "oxygen") @@ -280,6 +285,7 @@ bool MainTab::eventFilter(QObject *object, QEvent *event) if (editMode != NONE) return false; + // for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing) if (object->objectName() == "dateTimeEdit" && (event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel)) @@ -1052,3 +1058,9 @@ QString MainTab::trHemisphere(const char *orig) { return tr(orig); } + +void MainTab::escDetected() +{ + if (editMode != NONE) + rejectChanges(); +} diff --git a/qt-ui/maintab.h b/qt-ui/maintab.h index 4d6a0e139..fefe0f6c0 100644 --- a/qt-ui/maintab.h +++ b/qt-ui/maintab.h @@ -82,6 +82,7 @@ slots: void toggleTriggeredColumn(); void updateTextLabels(bool showUnits = true); QString trHemisphere(const char *orig); + void escDetected(void); private: Ui::MainTab ui; |