summaryrefslogtreecommitdiffhomepage
path: root/compat/qt-dpi.hpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2021-09-25 05:59:01 +0200
committerStanislaw Halik <sthalik@misaki.pl>2021-09-26 11:22:50 +0200
commit56766097bd5c90b564d833edc5c3c0e67be43dde (patch)
tree5d335d0a07508b96bff2248757a0f3ef490482f4 /compat/qt-dpi.hpp
parent66709cb944c8299a4324fcea5f6851862cc7d258 (diff)
compat/qt-dpi: get rid of mixin crap
Diffstat (limited to 'compat/qt-dpi.hpp')
-rw-r--r--compat/qt-dpi.hpp17
1 files changed, 11 insertions, 6 deletions
diff --git a/compat/qt-dpi.hpp b/compat/qt-dpi.hpp
index 01659c8a..fc17a062 100644
--- a/compat/qt-dpi.hpp
+++ b/compat/qt-dpi.hpp
@@ -3,17 +3,22 @@
#include <algorithm>
#include <QWidget>
+static inline double screen_dpi(const QPaintDevice* widget)
+{
+ const auto& x = *widget;
+#ifdef _WIN32
+ return std::max(x.devicePixelRatioF(), 1.);
+#else
+ return std::max(std::max(x.logicalDpiX()/(double)x.physicalDpiX(), x.devicePixelRatioF()), 1.);
+#endif
+}
+
template<typename self>
struct screen_dpi_mixin
{
protected:
double screen_dpi() const
{
- const auto& x = *static_cast<const self*>(this);
-#ifdef _WIN32
- return std::max(x.devicePixelRatioF(), 1.);
-#else
- return std::max(std::max(x.logicalDpiX()/(double)x.physicalDpiX(), x.devicePixelRatioF()), 1.);
-#endif
+ return ::screen_dpi(static_cast<const self*>(this));
}
};