--- a/src/RelpipeChartMainWindow.cpp Fri Jan 31 23:34:52 2020 +0100
+++ b/src/RelpipeChartMainWindow.cpp Mon Jun 01 23:56:20 2020 +0200
@@ -18,6 +18,7 @@
#include <QPushButton>
#include <QTableView>
+#include <QAction>
#include "RelpipeChartMainWindow.h"
@@ -31,11 +32,39 @@
tabs->setTabIcon(optionsIndex, QIcon::fromTheme("configure"));
statusBar()->addWidget(status);
setCentralWidget(tabs);
+ setupKeyboardShortcuts();
}
+void RelpipeChartMainWindow::setupKeyboardShortcuts() {
+ // TODO: less boilerplate code
+ QAction* nextTabAction = new QAction(this);
+ nextTabAction->setShortcut(Qt::Key_PageDown | Qt::CTRL);
+ connect(nextTabAction, &QAction::triggered, this, &RelpipeChartMainWindow::selectNextTab);
+ this->addAction(nextTabAction);
+
+ QAction* previousTabAction = new QAction(this);
+ previousTabAction->setShortcut(Qt::Key_PageUp | Qt::CTRL);
+ connect(previousTabAction, &QAction::triggered, this, &RelpipeChartMainWindow::selectPreviousTab);
+ this->addAction(previousTabAction);
+
+ QAction* quitAction = new QAction(this);
+ quitAction->setShortcut(Qt::Key_Q | Qt::CTRL);
+ connect(quitAction, &QAction::triggered, this, &RelpipeChartMainWindow::close);
+ this->addAction(quitAction);
+}
+
+
RelpipeChartMainWindow::~RelpipeChartMainWindow() {
}
+void RelpipeChartMainWindow::selectNextTab() {
+ tabs->setCurrentIndex((tabs->currentIndex() + 1) % tabs->count());
+}
+
+void RelpipeChartMainWindow::selectPreviousTab() {
+ tabs->setCurrentIndex((tabs->count() + tabs->currentIndex() - 1) % tabs->count());
+}
+
void RelpipeChartMainWindow::startRelation(const string_t name, std::vector<AttributeMetadata> attributes) {
setStatusMessage(L"Reading relation: " + name);
--- a/src/RelpipeChartMainWindow.h Fri Jan 31 23:34:52 2020 +0100
+++ b/src/RelpipeChartMainWindow.h Mon Jun 01 23:56:20 2020 +0200
@@ -43,6 +43,8 @@
void attribute(const string_t value);
void endOfPipe();
void setStatusMessage(string_t message);
+ void selectNextTab();
+ void selectPreviousTab();
private:
Ui::RelpipeChartMainWindow widget;
QTabWidget* tabs = new QTabWidget(this);
@@ -50,4 +52,5 @@
RelpipeTableModel* currentModel;
RelpipeChartWidget* currentChartWidget;
QLabel* status = new QLabel();
+ void setupKeyboardShortcuts();
};