summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2016-10-15 13:18:13 (GMT)
committerPeter Wu <peter@lekensteyn.nl>2016-10-20 20:40:21 (GMT)
commit1244980882382639f35925cef1d4cf3eeb3c240c (patch)
treeb31652cd6abca9faea693153b179f534851cc9c1
parenta41e83edbaadd27cd8ea85d4dfa375033e8ade84 (diff)
Fix initial region location for High DPI screens
QML dimensions are measured in device-independent pixels, be sure to make appropriate conversions. Also make sure that the new selection size feature displays the correct dimensions. Tested with: QT_SCALE_FACTOR=2 src/spectacle and dragging the region. REVIEW: 129190 CCBUG: 357022
-rw-r--r--src/QuickEditor/EditorRoot.qml2
-rw-r--r--src/QuickEditor/QuickEditor.cpp9
2 files changed, 6 insertions, 5 deletions
diff --git a/src/QuickEditor/EditorRoot.qml b/src/QuickEditor/EditorRoot.qml
index 1719816..8a5fc49 100644
--- a/src/QuickEditor/EditorRoot.qml
+++ b/src/QuickEditor/EditorRoot.qml
@@ -165,7 +165,7 @@ Item {
// - on top of the selection if the selection x position fits the box height plus some margin
// - at the bottom otherwise
// Note that text is drawn starting from the left bottom!
- var selectionText = selection.width + "x" + selection.height;
+ var selectionText = (selection.width * Screen.devicePixelRatio) + "x" + (selection.height * Screen.devicePixelRatio);
selectionTextMetrics.font = ctx.font;
selectionTextMetrics.text = selectionText;
var selectionTextRect = selectionTextMetrics.boundingRect;
diff --git a/src/QuickEditor/QuickEditor.cpp b/src/QuickEditor/QuickEditor.cpp
index 035703a..74700fd 100644
--- a/src/QuickEditor/QuickEditor.cpp
+++ b/src/QuickEditor/QuickEditor.cpp
@@ -97,14 +97,15 @@ QuickEditor::QuickEditor(const QPixmap &pixmap, QObject *parent) :
// set up initial config
SpectacleConfig *config = SpectacleConfig::instance();
if (config->rememberLastRectangularRegion()) {
+ auto pixelRatio = d->mQuickView->devicePixelRatio();
QRect cropRegion = config->cropRegion();
if (!cropRegion.isEmpty()) {
QMetaObject::invokeMethod(
rootItem, "setInitialSelection",
- Q_ARG(QVariant, cropRegion.x()),
- Q_ARG(QVariant, cropRegion.y()),
- Q_ARG(QVariant, cropRegion.width()),
- Q_ARG(QVariant, cropRegion.height())
+ Q_ARG(QVariant, cropRegion.x() / pixelRatio),
+ Q_ARG(QVariant, cropRegion.y() / pixelRatio),
+ Q_ARG(QVariant, cropRegion.width() / pixelRatio),
+ Q_ARG(QVariant, cropRegion.height() / pixelRatio)
);
}
}