blob: fc17a06252f595aa2f5b02a180009eebc326dffc (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
 | #pragma once
#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
    {
        return ::screen_dpi(static_cast<const self*>(this));
    }
};
 |