build: Add compatibility layer for Qt versions (#1118)
This commit is contained in:
@@ -186,6 +186,8 @@ add_files(
|
||||
qt/project_wizard/QtProjectWizardWindow.cpp
|
||||
qt/project_wizard/QtProjectWizardWindow.h
|
||||
|
||||
qt/utility/compatibilityQt.cpp
|
||||
qt/utility/compatibilityQt.h
|
||||
qt/utility/QtContextMenu.cpp
|
||||
qt/utility/QtContextMenu.h
|
||||
qt/utility/QtDeviceScaledPixmap.cpp
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "utility.h"
|
||||
#include "utilityApp.h"
|
||||
#include "utilityString.h"
|
||||
#include "compatibilityQt.h"
|
||||
|
||||
MouseWheelOverScrollbarFilter::MouseWheelOverScrollbarFilter() {}
|
||||
|
||||
@@ -40,7 +41,7 @@ bool MouseWheelOverScrollbarFilter::eventFilter(QObject* obj, QEvent* event)
|
||||
if (event->type() == QEvent::Wheel && scrollbar)
|
||||
{
|
||||
QRect scrollbarArea(scrollbar->pos(), scrollbar->size());
|
||||
QPoint globalMousePos = dynamic_cast<QWheelEvent*>(event)->globalPos();
|
||||
QPoint globalMousePos = utility::compatibility::QWheelEvent_globalPos(*dynamic_cast<QWheelEvent*>(event));
|
||||
QPoint localMousePos = scrollbar->mapFromGlobal(globalMousePos);
|
||||
|
||||
// instead of "scrollbar->underMouse()" we need this check implemented here because
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#include "compatibilityQt.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
|
||||
namespace utility
|
||||
{
|
||||
namespace compatibility
|
||||
{
|
||||
QPoint QWheelEvent_globalPos(const QWheelEvent& event)
|
||||
{
|
||||
#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0))
|
||||
return event.globalPosition().toPoint();
|
||||
#else
|
||||
return event.globalPos();
|
||||
#endif
|
||||
}
|
||||
} // namespace compatibility
|
||||
} // namespace utility
|
||||
@@ -0,0 +1,17 @@
|
||||
#ifndef COMPATIBILITY_QT_H
|
||||
#define COMPATIBILITY_QT_H
|
||||
|
||||
#include <QWheelEvent>
|
||||
|
||||
namespace utility
|
||||
{
|
||||
namespace compatibility
|
||||
{
|
||||
// Extracts the global position from a QWheelEvent.
|
||||
// This compatibility wrapper bridges Qt 5.12 and Qt 5.14
|
||||
QPoint QWheelEvent_globalPos(const QWheelEvent& event);
|
||||
|
||||
} // namespace compatibility
|
||||
} // namespace utility
|
||||
|
||||
#endif // COMPATIBILITY_QT_H
|
||||
Reference in New Issue
Block a user