mirror of
https://github.com/rizinorg/cutter
synced 2026-08-11 16:23:06 -04:00
* Refactor code to match coding style * NULL to nullptr * clang format 16 * Remove unused header * Fix ordering of headers * QtResImporter: Don't ignore return value of file.open() * Add missing memory header * GraphGridLayout: Remove <ranges> * GraphGridLayout: no views::reverse * Fix typos * Console widget cmd fix
23 lines
651 B
C++
23 lines
651 B
C++
#include "common/HighDpiPixmap.h"
|
|
|
|
#include <QGuiApplication>
|
|
#include <QScreen>
|
|
|
|
static qreal getDevicePixelRatio(qreal devicePixelRatio)
|
|
{
|
|
if (devicePixelRatio > 0) {
|
|
return devicePixelRatio;
|
|
}
|
|
qreal ratio = 1;
|
|
for (auto screen : QGuiApplication::screens()) {
|
|
ratio = std::max(ratio, screen->devicePixelRatio());
|
|
}
|
|
return ratio;
|
|
}
|
|
|
|
HighDpiPixmap::HighDpiPixmap(int width, int height, qreal devicePixelRatio)
|
|
: QPixmap(int(width * getDevicePixelRatio(devicePixelRatio)),
|
|
int(height * getDevicePixelRatio(devicePixelRatio)))
|
|
{
|
|
setDevicePixelRatio(getDevicePixelRatio(devicePixelRatio));
|
|
}
|