From 1603df1a436fc59d9b800a6db77ccbe28d4c614d Mon Sep 17 00:00:00 2001 From: Eberhard Graether Date: Mon, 7 Mar 2016 15:23:34 +0100 Subject: [PATCH] ui: Added delay when changing fontsize via mouse wheel bug id = 44 --- src/lib_gui/qt/window/QtMainWindow.cpp | 22 +++++++++++++++++++--- src/lib_gui/qt/window/QtMainWindow.h | 6 ++++++ 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/src/lib_gui/qt/window/QtMainWindow.cpp b/src/lib_gui/qt/window/QtMainWindow.cpp index 0048106c..13b90c62 100644 --- a/src/lib_gui/qt/window/QtMainWindow.cpp +++ b/src/lib_gui/qt/window/QtMainWindow.cpp @@ -8,6 +8,7 @@ #include #include #include +#include #include "component/view/View.h" #include "component/view/CompositeView.h" @@ -85,30 +86,45 @@ bool MouseReleaseFilter::eventFilter(QObject* obj, QEvent* event) MouseWheelFilter::MouseWheelFilter(QObject* parent) : QObject(parent) + , m_isWaiting(false) { } bool MouseWheelFilter::eventFilter(QObject* obj, QEvent* event) { - if (event->type() == QEvent::Wheel && QApplication::keyboardModifiers() == Qt::ControlModifier) + bool dispatched = false; + + if (!m_isWaiting && event->type() == QEvent::Wheel && QApplication::keyboardModifiers() == Qt::ControlModifier) { QWheelEvent* wheelEvent = dynamic_cast(event); if (wheelEvent->delta() > 0.0f) { MessageZoom(true).dispatch(); - return true; + dispatched = true; } else if (wheelEvent->delta() < 0.0f) { MessageZoom(false).dispatch(); - return true; + dispatched = true; } } + if (dispatched) + { + QTimer::singleShot(250, this, SLOT(stopWaiting())); + m_isWaiting = true; + return true; + } + return QObject::eventFilter(obj, event); } +void MouseWheelFilter::stopWaiting() +{ + m_isWaiting = false; +} + QtMainWindow::QtMainWindow() : m_showDockWidgetTitleBars(true) diff --git a/src/lib_gui/qt/window/QtMainWindow.h b/src/lib_gui/qt/window/QtMainWindow.h index 40ea00e8..ff1382f3 100644 --- a/src/lib_gui/qt/window/QtMainWindow.h +++ b/src/lib_gui/qt/window/QtMainWindow.h @@ -61,6 +61,12 @@ public: protected: bool eventFilter(QObject* obj, QEvent* event); + +private slots: + void stopWaiting(); + +private: + bool m_isWaiting; };