diff options
| author | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-30 13:29:38 +1000 |
|---|---|---|
| committer | 2 * r + 2 * t <61896496+soramanew@users.noreply.github.com> | 2025-08-30 13:29:38 +1000 |
| commit | 31b924495752979442b374e8d390f19f5377408d (patch) | |
| tree | f3481c2ac4f00ac7e0bebd20eec4639ada989d1c /plugin | |
| parent | launcher: allow show on hover (#498) (diff) | |
| download | caelestia-shell-31b924495752979442b374e8d390f19f5377408d.tar.gz caelestia-shell-31b924495752979442b374e8d390f19f5377408d.tar.bz2 caelestia-shell-31b924495752979442b374e8d390f19f5377408d.zip | |
plugin/cutils: fix saveItem scaling
Fixes #521
Closes #524
Diffstat (limited to 'plugin')
| -rw-r--r-- | plugin/src/Caelestia/cutils.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/plugin/src/Caelestia/cutils.cpp b/plugin/src/Caelestia/cutils.cpp index 3e7742b..f6ca0bf 100644 --- a/plugin/src/Caelestia/cutils.cpp +++ b/plugin/src/Caelestia/cutils.cpp @@ -1,6 +1,7 @@ #include "cutils.hpp" #include <qobject.h> +#include <QtQuick/QQuickWindow> #include <QtQuick/QQuickItem> #include <QtQuick/QQuickItemGrabResult> #include <QThreadPool> @@ -38,15 +39,21 @@ void CUtils::saveItem(QQuickItem* target, const QUrl& path, const QRect& rect, Q return; } + auto scaledRect = rect; + if (rect.isValid()) { + qreal scale = target->window()->devicePixelRatio(); + scaledRect = QRect(rect.left() * scale, rect.top() * scale, rect.width() * scale, rect.height() * scale); + } + QSharedPointer<QQuickItemGrabResult> grabResult = target->grabToImage(); QObject::connect(grabResult.data(), &QQuickItemGrabResult::ready, this, - [grabResult, rect, path, onSaved, onFailed, this]() { - QThreadPool::globalInstance()->start([grabResult, rect, path, onSaved, onFailed, this] { + [grabResult, scaledRect, path, onSaved, onFailed, this]() { + QThreadPool::globalInstance()->start([grabResult, scaledRect, path, onSaved, onFailed, this] { QImage image = grabResult->image(); - if (!rect.isEmpty()) { - image = image.copy(rect); + if (scaledRect.isValid()) { + image = image.copy(scaledRect); } const QString file = path.toLocalFile(); |