ui: Added delay when changing fontsize via mouse wheel

bug id = 44
This commit is contained in:
Eberhard Graether
2016-03-07 15:23:34 +01:00
parent 6d7a1faaa4
commit 1603df1a43
2 changed files with 25 additions and 3 deletions
+19 -3
View File
@@ -8,6 +8,7 @@
#include <QMessageBox>
#include <QSettings>
#include <QSysInfo>
#include <QTimer>
#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<QWheelEvent*>(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)
+6
View File
@@ -61,6 +61,12 @@ public:
protected:
bool eventFilter(QObject* obj, QEvent* event);
private slots:
void stopWaiting();
private:
bool m_isWaiting;
};