diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2019-08-01 11:22:41 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2019-08-01 11:22:41 +0200 |
commit | b930dd608bf95ecc3f89007313ba8ab8b1935ee5 (patch) | |
tree | 649ddba90caa1de65ad1c53be23afeb635121e73 /compat/qt-dpi.hpp | |
parent | e71f7af1d619d02667c2bfb9f5fd0d925e534230 (diff) |
video: reuse working dpi check
Diffstat (limited to 'compat/qt-dpi.hpp')
-rw-r--r-- | compat/qt-dpi.hpp | 19 |
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 + } +}; |