mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
09403f3724
commit
fafaf0eef0
2 changed files with 13 additions and 0 deletions
|
@ -26,6 +26,7 @@
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QPalette>
|
#include <QPalette>
|
||||||
#include <QScrollBar>
|
#include <QScrollBar>
|
||||||
|
#include <QShortcut>
|
||||||
|
|
||||||
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
weightModel(new WeightModel(this)),
|
weightModel(new WeightModel(this)),
|
||||||
|
@ -48,6 +49,10 @@ MainTab::MainTab(QWidget *parent) : QTabWidget(parent),
|
||||||
|
|
||||||
action = new QAction(tr("Cancel"), this);
|
action = new QAction(tr("Cancel"), this);
|
||||||
connect(action, SIGNAL(triggered(bool)), this, SLOT(rejectChanges()));
|
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);
|
addMessageAction(action);
|
||||||
|
|
||||||
if (qApp->style()->objectName() == "oxygen")
|
if (qApp->style()->objectName() == "oxygen")
|
||||||
|
@ -280,6 +285,7 @@ bool MainTab::eventFilter(QObject *object, QEvent *event)
|
||||||
|
|
||||||
if (editMode != NONE)
|
if (editMode != NONE)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
|
// for the dateTimeEdit widget we need to ignore Wheel events as well (as long as we aren't editing)
|
||||||
if (object->objectName() == "dateTimeEdit" &&
|
if (object->objectName() == "dateTimeEdit" &&
|
||||||
(event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel))
|
(event->type() == QEvent::FocusIn || event->type() == QEvent::Wheel))
|
||||||
|
@ -1052,3 +1058,9 @@ QString MainTab::trHemisphere(const char *orig)
|
||||||
{
|
{
|
||||||
return tr(orig);
|
return tr(orig);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainTab::escDetected()
|
||||||
|
{
|
||||||
|
if (editMode != NONE)
|
||||||
|
rejectChanges();
|
||||||
|
}
|
||||||
|
|
|
@ -82,6 +82,7 @@ slots:
|
||||||
void toggleTriggeredColumn();
|
void toggleTriggeredColumn();
|
||||||
void updateTextLabels(bool showUnits = true);
|
void updateTextLabels(bool showUnits = true);
|
||||||
QString trHemisphere(const char *orig);
|
QString trHemisphere(const char *orig);
|
||||||
|
void escDetected(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui::MainTab ui;
|
Ui::MainTab ui;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue