changeset 1300:1589bc7528b7

Ctrl-click on level-pan tool button now also resets to default
author Chris Cannam
date Thu, 21 Jun 2018 10:43:14 +0100
parents 91670e4e76a6
children e8368466fa34
files widgets/LevelPanToolButton.cpp widgets/LevelPanToolButton.h
diffstat 2 files changed, 17 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/LevelPanToolButton.cpp	Mon Jun 11 14:40:36 2018 +0100
+++ b/widgets/LevelPanToolButton.cpp	Thu Jun 21 10:43:14 2018 +0100
@@ -18,9 +18,12 @@
 #include <QMenu>
 #include <QWidgetAction>
 #include <QImage>
+#include <QMouseEvent>
 #include <QStylePainter>
 #include <QStyleOptionToolButton>
 
+#include "base/Debug.h"
+
 #include <iostream>
 using std::cerr;
 using std::endl;
@@ -60,6 +63,19 @@
 }
 
 void
+LevelPanToolButton::mousePressEvent(QMouseEvent *e)
+{
+    if (e->button() == Qt::MidButton ||
+        ((e->button() == Qt::LeftButton) &&
+         (e->modifiers() & Qt::ControlModifier))) {
+        m_lpw->setToDefault();
+        e->accept();
+    } else {
+        QToolButton::mousePressEvent(e);
+    }
+}
+
+void
 LevelPanToolButton::wheelEvent(QWheelEvent *e)
 {
     m_lpw->wheelEvent(e);
--- a/widgets/LevelPanToolButton.h	Mon Jun 11 14:40:36 2018 +0100
+++ b/widgets/LevelPanToolButton.h	Thu Jun 21 10:43:14 2018 +0100
@@ -70,6 +70,7 @@
     virtual void paintEvent(QPaintEvent *);
     virtual void enterEvent(QEvent *);
     virtual void leaveEvent(QEvent *);
+    virtual void mousePressEvent(QMouseEvent *);
     virtual void wheelEvent(QWheelEvent *e);
     
     LevelPanWidget *m_lpw;