Commit 12449808 authored by Peter Wu's avatar Peter Wu
Browse files

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
parent a41e83ed
......@@ -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;
......
......@@ -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)
);
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment