ui: Added delay when changing fontsize via mouse wheel
bug id = 44
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -61,6 +61,12 @@ public:
|
||||
|
||||
protected:
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
private slots:
|
||||
void stopWaiting();
|
||||
|
||||
private:
|
||||
bool m_isWaiting;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user