Cancel dive edit when escape key is pressed

Also seems intuitive. What's odd is that in the Planner you get a
confirmation dialog while here you don't. We should be consistent.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2014-06-03 15:29:28 -07:00
parent 09403f3724
commit fafaf0eef0
2 changed files with 13 additions and 0 deletions

View file

@ -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();
}

View file

@ -82,6 +82,7 @@ slots:
void toggleTriggeredColumn();
void updateTextLabels(bool showUnits = true);
QString trHemisphere(const char *orig);
void escDetected(void);
private:
Ui::MainTab ui;