diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2019-05-15 10:56:15 +0200 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2019-05-15 10:56:15 +0200 |
commit | e925c482e8b7b9fe8b93b54488a5e6c1dd60f554 (patch) | |
tree | 34ab61c2e99f9c21750be8bb8127cf8d489146c2 /src/util | |
parent | 341ec911cd4d9a84652b699dc6c52984d6810b54 (diff) |
replace WaveformWidgetFactory::getDevicePixelRatio() with acompatibility solution that consideres the parent widget device pixel ratio with < qt5.6 and above.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/compatibility.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util/compatibility.h b/src/util/compatibility.h index 9cf12004c8..5216df9a27 100644 --- a/src/util/compatibility.h +++ b/src/util/compatibility.h @@ -5,6 +5,8 @@ #include <QAtomicPointer> #include <QStringList> #include <QApplication> +#include <QWindow> +#include <QWidget> #include <QLocale> #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) @@ -55,4 +57,22 @@ void qAsConst(const T &&) = delete; #endif + +inline qreal getDevicePixelRatioF(const QWidget* widget) { +#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) + return widget->devicePixelRatioF(); +#endif + + // Crawl up to the window and return qreal value + QWindow* window = widget->window()->windowHandle(); + if (window) { + return window->devicePixelRatio(); + } + + // return integer value as last resort + return widget->devicePixelRatio(); +} + + + #endif /* COMPATABILITY_H */ |