diff --git a/bin/app/data/ApplicationSettings_template.xml b/bin/app/data/ApplicationSettings_template.xml
index 7defdc5b..e864023f 100644
--- a/bin/app/data/ApplicationSettings_template.xml
+++ b/bin/app/data/ApplicationSettings_template.xml
@@ -49,4 +49,9 @@
+
+
+
+
+
diff --git a/src/lib/settings/ApplicationSettings.cpp b/src/lib/settings/ApplicationSettings.cpp
index 752532ae..cd2369ca 100644
--- a/src/lib/settings/ApplicationSettings.cpp
+++ b/src/lib/settings/ApplicationSettings.cpp
@@ -149,4 +149,14 @@ int ApplicationSettings::getCoatiPort() const
void ApplicationSettings::setCoatiPort(const int coatiPort)
{
setValue("network/coati_port", coatiPort);
-}
\ No newline at end of file
+}
+
+int ApplicationSettings::getControlsMouseBackButton() const
+{
+ return getValue("controls/mouse_back_button", 0x8);
+}
+
+int ApplicationSettings::getControlsMouseForwardButton() const
+{
+ return getValue("controls/mouse_forward_button", 0x16);
+}
diff --git a/src/lib/settings/ApplicationSettings.h b/src/lib/settings/ApplicationSettings.h
index a0b24158..d1264188 100644
--- a/src/lib/settings/ApplicationSettings.h
+++ b/src/lib/settings/ApplicationSettings.h
@@ -59,6 +59,10 @@ public:
int getCoatiPort() const;
void setCoatiPort(const int coatiPort);
+ // controls
+ int getControlsMouseBackButton() const;
+ int getControlsMouseForwardButton() const;
+
private:
ApplicationSettings();
ApplicationSettings(const ApplicationSettings&);
diff --git a/src/lib_gui/qt/element/QtUndoRedo.cpp b/src/lib_gui/qt/element/QtUndoRedo.cpp
index 5ca86d85..c6c3eefe 100644
--- a/src/lib_gui/qt/element/QtUndoRedo.cpp
+++ b/src/lib_gui/qt/element/QtUndoRedo.cpp
@@ -16,13 +16,13 @@ QtUndoRedo::QtUndoRedo()
m_undoButton = new QPushButton(this);
m_undoButton->setObjectName("undo_button");
- m_undoButton->setToolTip("undo");
+ m_undoButton->setToolTip("back");
m_undoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_undoButton->setEnabled(false);
m_redoButton = new QPushButton(this);
m_redoButton->setObjectName("redo_button");
- m_redoButton->setToolTip("redo");
+ m_redoButton->setToolTip("forward");
m_redoButton->setAttribute(Qt::WA_LayoutUsesWidgetRect); // fixes layouting on Mac
m_redoButton->setEnabled(false);
diff --git a/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp b/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp
index 9e2d4bef..eef967c0 100644
--- a/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp
+++ b/src/lib_gui/qt/view/graphElements/QtGraphNode.cpp
@@ -265,6 +265,11 @@ void QtGraphNode::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
event->ignore();
+ if (event->button() != Qt::LeftButton)
+ {
+ return;
+ }
+
for (std::shared_ptr component : m_components)
{
component->nodeMousePressEvent(event);
@@ -303,6 +308,11 @@ void QtGraphNode::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
event->ignore();
+ if (event->button() != Qt::LeftButton)
+ {
+ return;
+ }
+
for (std::shared_ptr component : m_components)
{
component->nodeMouseReleaseEvent(event);
diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp
index 9437397a..586958d5 100644
--- a/src/lib_gui/qt/window/QtMainWindow.cpp
+++ b/src/lib_gui/qt/window/QtMainWindow.cpp
@@ -45,6 +45,39 @@ void QtViewToggle::toggledByUI()
dynamic_cast(parent())->toggleView(m_view, false);
}
+
+MouseReleaseFilter::MouseReleaseFilter(QObject* parent)
+ : QObject(parent)
+{
+ m_backButton = ApplicationSettings::getInstance()->getControlsMouseBackButton();
+ m_forwardButton = ApplicationSettings::getInstance()->getControlsMouseForwardButton();
+
+ std::cout << m_backButton << std::endl;
+ std::cout << m_forwardButton << std::endl;
+}
+
+bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event)
+{
+ if (event->type() == QEvent::MouseButtonRelease)
+ {
+ QMouseEvent* mouseEvent = dynamic_cast(event);
+
+ if (mouseEvent->button() == m_backButton)
+ {
+ MessageUndo().dispatch();
+ return true;
+ }
+ else if (mouseEvent->button() == m_forwardButton)
+ {
+ MessageRedo().dispatch();
+ return true;
+ }
+ }
+
+ return QObject::eventFilter(obj, event);
+}
+
+
QtMainWindow::QtMainWindow()
{
setObjectName("QtMainWindow");
@@ -56,6 +89,9 @@ QtMainWindow::QtMainWindow()
QApplication::setOverrideCursor(Qt::ArrowCursor);
+ QApplication* app = dynamic_cast(QCoreApplication::instance());
+ app->installEventFilter(new MouseReleaseFilter(this));
+
m_recentProjectAction = new QAction*[ApplicationSettings::MaximalAmountOfRecentProjects];
setupProjectMenu();
@@ -179,6 +215,14 @@ bool QtMainWindow::event(QEvent* event)
return QMainWindow::event(event);
}
+void QtMainWindow::keyPressEvent(QKeyEvent* event)
+{
+ if (event->key() == Qt::Key_Backspace)
+ {
+ MessageUndo().dispatch();
+ }
+}
+
void QtMainWindow::pushWindow(QWidget* window)
{
if (m_windowStack.size())
@@ -480,8 +524,8 @@ void QtMainWindow::setupEditMenu()
QMenu *menu = new QMenu(tr("&Edit"), this);
menuBar()->addMenu(menu);
- menu->addAction(tr("Undo"), this, SLOT(undo()), QKeySequence::Undo);
- menu->addAction(tr("Redo"), this, SLOT(redo()), QKeySequence::Redo);
+ menu->addAction(tr("Back"), this, SLOT(undo()), QKeySequence::Undo);
+ menu->addAction(tr("Forward"), this, SLOT(redo()), QKeySequence::Redo);
menu->addSeparator();
if(!isTrial())
diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h
index a5b7de5e..5465bb69 100644
--- a/src/lib_gui/qt/window/QtMainWindow.h
+++ b/src/lib_gui/qt/window/QtMainWindow.h
@@ -33,7 +33,26 @@ private:
View* m_view;
};
-class QtMainWindow: public QMainWindow
+
+class MouseReleaseFilter
+ : public QObject
+{
+ Q_OBJECT
+
+public:
+ MouseReleaseFilter(QObject* parent);
+
+protected:
+ bool eventFilter(QObject* obj, QEvent* event);
+
+private:
+ size_t m_backButton;
+ size_t m_forwardButton;
+};
+
+
+class QtMainWindow
+ : public QMainWindow
{
Q_OBJECT
@@ -54,6 +73,7 @@ public:
protected:
bool event(QEvent* event);
+ void keyPressEvent(QKeyEvent* event);
public slots:
void pushWindow(QWidget* window);
@@ -88,6 +108,7 @@ public slots:
void toggleView(View* view, bool fromMenu);
void handleEscapeShortcut();
+
void updateRecentProjectMenu();
static void setWindowSettingsPath(const std::string& windowSettingsPath);