From 11196c0e3553350cdf13032ce361436eb1791f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20T=C5=AFma?= Date: Tue, 26 Sep 2017 07:46:46 +0200 Subject: [PATCH] Improved graph type/time type switching --- src/gui.cpp | 22 +++++++++++++++++++--- src/keys.h | 5 +++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/gui.cpp b/src/gui.cpp index 73d06cf1..9b7094bf 100644 --- a/src/gui.cpp +++ b/src/gui.cpp @@ -412,14 +412,12 @@ void GUI::createActions() _distanceGraphAction = new QAction(tr("Distance"), this); _distanceGraphAction->setCheckable(true); _distanceGraphAction->setActionGroup(ag); - _distanceGraphAction->setShortcut(DISTANCE_GRAPH_SHORTCUT); connect(_distanceGraphAction, SIGNAL(triggered()), this, SLOT(setDistanceGraph())); addAction(_distanceGraphAction); _timeGraphAction = new QAction(tr("Time"), this); _timeGraphAction->setCheckable(true); _timeGraphAction->setActionGroup(ag); - _timeGraphAction->setShortcut(TIME_GRAPH_SHORTCUT); connect(_timeGraphAction, SIGNAL(triggered()), this, SLOT(setTimeGraph())); addAction(_timeGraphAction); @@ -671,7 +669,12 @@ void GUI::keys() + tr("Last file") + "" + QKeySequence(LAST_KEY).toString() + "" + tr("Append file") + "" + QKeySequence(MODIFIER).toString() + tr("Next/Previous") - + "" + tr("Next map") + + "" + + tr("Toggle graph type") + "" + + QKeySequence(TOGGLE_GRAPH_TYPE_KEY).toString() + "" + + tr("Toggle time type") + "" + + QKeySequence(TOGGLE_TIME_TYPE_KEY).toString() + + "" + tr("Next map") + "" + NEXT_MAP_SHORTCUT.toString() + "" + tr("Previous map") + "" + PREV_MAP_SHORTCUT.toString() + "" + tr("Zoom in") @@ -1433,6 +1436,19 @@ void GUI::keyPressEvent(QKeyEvent *event) file = _browser->last(); break; + case TOGGLE_GRAPH_TYPE_KEY: + if (_timeGraphAction->isChecked()) + _distanceGraphAction->activate(QAction::Trigger); + else + _timeGraphAction->activate(QAction::Trigger); + break; + case TOGGLE_TIME_TYPE_KEY: + if (_movingTimeAction->isChecked()) + _totalTimeAction->activate(QAction::Trigger); + else + _movingTimeAction->activate(QAction::Trigger); + break; + case Qt::Key_Escape: if (_fullscreenAction->isChecked()) { _fullscreenAction->setChecked(false); diff --git a/src/keys.h b/src/keys.h index 29013a4d..07a824d5 100644 --- a/src/keys.h +++ b/src/keys.h @@ -13,6 +13,9 @@ #define ZOOM_IN QKeySequence::ZoomIn #define ZOOM_OUT QKeySequence::ZoomOut +#define TOGGLE_GRAPH_TYPE_KEY Qt::Key_X +#define TOGGLE_TIME_TYPE_KEY Qt::Key_T + #define QUIT_SHORTCUT QKeySequence(QKeySequence::Quit) #define OPEN_SHORTCUT QKeySequence(QKeySequence::Open) #define CLOSE_SHORTCUT QKeySequence(QKeySequence::Close) @@ -23,8 +26,6 @@ #define NEXT_MAP_SHORTCUT QKeySequence(QKeySequence::Forward) #define PREV_MAP_SHORTCUT QKeySequence(QKeySequence::Back) #define SHOW_GRAPHS_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_G) -#define DISTANCE_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_D) -#define TIME_GRAPH_SHORTCUT QKeySequence(Qt::CTRL + Qt::Key_T) #ifdef Q_OS_MAC #define FULLSCREEN_SHORTCUT QKeySequence(Qt::META + Qt::CTRL + Qt::Key_F)