summaryrefslogtreecommitdiffhomepage
path: root/compat/qt-dpi.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'compat/qt-dpi.hpp')
-rw-r--r--compat/qt-dpi.hpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/compat/qt-dpi.hpp b/compat/qt-dpi.hpp
new file mode 100644
index 00000000..01659c8a
--- /dev/null
+++ b/compat/qt-dpi.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <algorithm>
+#include <QWidget>
+
+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
+ }
+};