diff --git a/src/Gui/KSWidget.h b/src/Gui/KSWidget.h --- a/src/Gui/KSWidget.h +++ b/src/Gui/KSWidget.h @@ -79,6 +79,7 @@ QCheckBox *mWindowDecorations; QCheckBox *mCaptureTransientOnly; QCheckBox *mQuitAfterSaveOrCopy; + QCheckBox *mShowMagnifier; QLabel *mCaptureModeLabel; QLabel *mContentOptionsLabel; }; diff --git a/src/Gui/KSWidget.cpp b/src/Gui/KSWidget.cpp --- a/src/Gui/KSWidget.cpp +++ b/src/Gui/KSWidget.cpp @@ -109,11 +109,17 @@ mQuitAfterSaveOrCopy->setToolTip(i18n("Quit Spectacle after saving or copying the image")); connect(mQuitAfterSaveOrCopy, &QCheckBox::clicked, configManager, &SpectacleConfig::setQuitAfterSaveOrCopyChecked); + mShowMagnifier = new QCheckBox(i18n("Show magnifier"), this); + mShowMagnifier->setToolTip(i18n("Show magnifier")); + mShowMagnifier->setEnabled(false); + connect(mShowMagnifier, &QCheckBox::clicked, configManager, &SpectacleConfig::setShowMagnifierChecked); + mContentOptionsForm = new QVBoxLayout; mContentOptionsForm->addWidget(mMousePointer); mContentOptionsForm->addWidget(mWindowDecorations); mContentOptionsForm->addWidget(mCaptureTransientOnly); mContentOptionsForm->addWidget(mQuitAfterSaveOrCopy); + mContentOptionsForm->addWidget(mShowMagnifier); mContentOptionsForm->setContentsMargins(24, 0, 0, 0); // the take a new screenshot button @@ -155,6 +161,7 @@ mCaptureOnClick->setChecked (configManager->onClickChecked()); mCaptureTransientOnly->setChecked (configManager->captureTransientWindowOnlyChecked()); mQuitAfterSaveOrCopy->setChecked (configManager->quitAfterSaveOrCopyChecked()); + mShowMagnifier->setChecked (configManager->showMagnifierChecked()); mCaptureArea->setCurrentIndex (configManager->captureMode()); mDelayMsec->setValue (configManager->captureDelay()); @@ -221,13 +228,21 @@ case ImageGrabber::WindowUnderCursor: mWindowDecorations->setEnabled(true); mCaptureTransientOnly->setEnabled(true); + mShowMagnifier->setEnabled(false); break; case ImageGrabber::ActiveWindow: mWindowDecorations->setEnabled(true); mCaptureTransientOnly->setEnabled(false); + mShowMagnifier->setEnabled(false); + break; + case ImageGrabber::RectangularRegion: + mWindowDecorations->setEnabled(false); + mCaptureTransientOnly->setEnabled(false); + mShowMagnifier->setEnabled(true); break; default: mWindowDecorations->setEnabled(false); mCaptureTransientOnly->setEnabled(false); + mShowMagnifier->setEnabled(false); } } diff --git a/src/QuickEditor/EditorRoot.qml b/src/QuickEditor/EditorRoot.qml --- a/src/QuickEditor/EditorRoot.qml +++ b/src/QuickEditor/EditorRoot.qml @@ -29,6 +29,12 @@ property var selection: undefined; property color maskColour: Qt.rgba(0, 0, 0, 0.15); property color strokeColour: Qt.rgba(0.114, 0.6, 0.953, 1); + property color crossColour: Qt.rgba(0.114, 0.6, 0.953, 0.5); + property bool showMagnifier: false; + property var magZoom: 5; + property var magPixels: 16; + property var magOffset: 32; + SystemPalette { id: systemPalette; } @@ -48,6 +54,10 @@ cropDisplayCanvas.requestPaint(); } + function setShowMagnifier() { + showMagnifier = true; + } + function accept() { if (selection) { acceptImage(selection.x, selection.y, selection.width, selection.height); @@ -188,9 +198,37 @@ ctx.strokeRect(selectionBoxX - 4, selectionBoxY - selectionTextRect.height - 2, selectionTextRect.width + 10, selectionTextRect.height + 8); ctx.fillStyle = systemPalette.windowText; ctx.fillText(selectionText, selectionBoxX, selectionBoxY); + if (selection.zx >= 0 && selection.zy >= 0 && showMagnifier) { + var offsetX = magOffset; + var offsetY = magOffset; + var magX = selection.zx; + var magY = selection.zy; + var magWidth = (magPixels * 2 + 1) * magZoom; + var magHeight = (magPixels * 2 + 1) * magZoom; + + if (magX + offsetX + magWidth >= Window.width / Screen.devicePixelRatio) { + offsetX -= offsetX * 2 + magWidth; + } + + if (magY + offsetY + magHeight >= Window.height / Screen.devicePixelRatio) { + offsetY -= offsetY * 2 + magHeight; + } + + magX += offsetX; + magY += offsetY; + crossMagnifier.visible = true; + crossMagnifier.x = magX; + crossMagnifier.y = magY; + crossBackground.x = -selection.zx * Screen.devicePixelRatio * magZoom + magPixels * magZoom; + crossBackground.y = -selection.zy * Screen.devicePixelRatio * magZoom + magPixels * magZoom; + ctx.strokeRect(magX, magY, magWidth, magHeight); + } else { + crossMagnifier.visible = false; + } } else { midHelpText.visible = true; bottomHelpText.visible = false; + crossMagnifier.visible = false; } } @@ -229,6 +267,7 @@ border.width: 1; border.color: Qt.rgba(0, 0, 0, 1); color: Qt.rgba(1, 1, 1, 0.85); + visible: false; anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; @@ -241,6 +280,61 @@ anchors.centerIn: parent; } } + + Rectangle { + id: crossMagnifier; + objectName: "crossMagnifier"; + + height: ( magPixels * 2 + 1) * magZoom; + width: ( magPixels * 2 + 1) * magZoom; + border.width: 0; + visible: false; + clip: true + + Image { + id: crossBackground; + objectName: "crossBackground"; + source: "image://snapshot/rawimage"; + cache: false; + smooth: false; + height: Window.height * magZoom; + width: Window.width * magZoom; + fillMode: Image.PreserveAspectCrop; + } + + Rectangle { + x: magPixels * magZoom; + y: 0; + width: magZoom; + height: magPixels * magZoom; + color: crossColour; + } + + Rectangle { + x: magPixels * magZoom; + y: (magPixels + 1) * magZoom; + width: magZoom; + height: magPixels * magZoom; + color: crossColour; + } + + Rectangle { + x: 0; + y: magPixels * magZoom; + width: magPixels * magZoom; + height: magZoom; + color: crossColour; + } + + Rectangle { + x: (magPixels + 1) * magZoom; + y: magPixels * magZoom; + width: magPixels * magZoom; + height: magZoom; + color: crossColour; + } + } + } MouseArea { @@ -273,7 +367,8 @@ selection.y = Math.min(starty, mouse.y); selection.width = Math.abs(startx - mouse.x) + 1; selection.height = Math.abs(starty - mouse.y) + 1; - + selection.zx = mouse.x; + selection.zy = mouse.y; cropDisplayCanvas.requestPaint(); } @@ -283,6 +378,12 @@ cropDisplayCanvas.requestPaint(); } } + + onReleased: { + selection.zx = -1; + selection.zy = -1; + cropDisplayCanvas.requestPaint(); + } } Component { diff --git a/src/QuickEditor/QuickEditor.cpp b/src/QuickEditor/QuickEditor.cpp --- a/src/QuickEditor/QuickEditor.cpp +++ b/src/QuickEditor/QuickEditor.cpp @@ -114,6 +114,12 @@ } } + if (config->showMagnifierChecked()) { + QMetaObject::invokeMethod( + rootItem, "setShowMagnifier" + ); + } + if (config->useLightRegionMaskColour()) { rootItem->setProperty("maskColour", QColor(255, 255, 255, 100)); rootItem->setProperty("strokeColour", QColor(96, 96, 96, 255)); diff --git a/src/QuickEditor/SelectionRectangle.qml b/src/QuickEditor/SelectionRectangle.qml --- a/src/QuickEditor/SelectionRectangle.qml +++ b/src/QuickEditor/SelectionRectangle.qml @@ -27,6 +27,14 @@ property var imageElement: null; property int minRectSize: 20; property int mouseAreaSize: 20; + property var zx: -1; + property var zy: -1; + + function resetZxZy() { + zx = -1; + zy = -1; + drawCanvas.requestPaint(); + } signal doubleClicked(); @@ -77,21 +85,29 @@ onPressed: { brxLimit = (parent.x + parent.width) - minRectSize; bryLimit = (parent.y + parent.height) - minRectSize; + parent.zx = parent.x; + parent.zy = parent.y; } onPositionChanged: { if ((parent.x + mouse.x) < brxLimit) { parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.zx = parent.zx + mouse.x; } if ((parent.y + mouse.y) < bryLimit) { parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.zy = parent.zy + mouse.y; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -110,20 +126,28 @@ onPressed: { brxLimit = parent.x + mouseAreaSize + minRectSize; bryLimit = (parent.y + parent.height) - minRectSize; + parent.zx = parent.x + parent.width - 1; + parent.zy = parent.y; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > brxLimit) { parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.zx = parent.zx + mouse.x - mouseAreaSize + 1; } if ((parent.y + mouse.y) < bryLimit) { parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.zy = parent.zy + mouse.y; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -142,20 +166,28 @@ onPressed: { brxLimit = (parent.x + parent.width) - minRectSize; bryLimit = parent.y + mouseAreaSize + minRectSize; + parent.zx = parent.x; + parent.zy = parent.y + parent.height - 1; } onPositionChanged: { if ((parent.x + mouse.x) < brxLimit) { parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.zx = parent.zx + mouse.x; } if ((parent.y + parent.height + mouse.y) > bryLimit) { parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.zy = parent.zy + mouse.y - mouseAreaSize + 1; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -174,18 +206,26 @@ onPressed: { brxLimit = parent.x + mouseAreaSize + minRectSize; bryLimit = parent.y + mouseAreaSize + minRectSize; + parent.zx = parent.x + parent.width - 1; + parent.zy = parent.y + parent.height - 1; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > brxLimit) { parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.zx = parent.zx + mouse.x - mouseAreaSize + 1; } if ((parent.y + parent.height + mouse.y) > bryLimit) { parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.zy = parent.zy + mouse.y - mouseAreaSize + 1; } drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -202,16 +242,23 @@ onPressed: { limit = (parent.y + parent.height) - minRectSize; + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2; + parent.zy = parent.y; } onPositionChanged: { if ((parent.y + mouse.y) < limit) { parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.zy = parent.zy + mouse.y; } - + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2 + mouse.x + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -228,15 +275,22 @@ onPressed: { limit = parent.y + mouseAreaSize + minRectSize; + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2; + parent.zy = parent.y + parent.height - 1; } onPositionChanged: { if ((parent.y + parent.height + mouse.y) > limit) { parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.zy = parent.zy + mouse.y - mouseAreaSize + 1; } - + parent.zx = parent.x + (parent.width >> 1) - mouseAreaSize / 2 + mouse.x + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -253,16 +307,23 @@ onPressed: { limit = (parent.x + parent.width) - minRectSize; + parent.zx = parent.x; + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2; } onPositionChanged: { if ((parent.x + mouse.x) < limit) { parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.zx = parent.zx + mouse.x; } - + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2 + mouse.y + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } MouseArea { @@ -279,14 +340,21 @@ onPressed: { limit = parent.x + mouseAreaSize + minRectSize; + parent.zx = parent.x + parent.width - 1; + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > limit) { parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.zx = parent.zx + mouse.x - mouseAreaSize + 1; } - + parent.zy = parent.y + (parent.height >> 1) - mouseAreaSize / 2 + mouse.y + 1; drawCanvas.requestPaint(); } + + onReleased: { + resetZxZy(); + } } } diff --git a/src/QuickEditor/EditorRoot.qml b/src/QuickEditor/final/EditorRoot.qml copy from src/QuickEditor/EditorRoot.qml copy to src/QuickEditor/final/EditorRoot.qml --- a/src/QuickEditor/EditorRoot.qml +++ b/src/QuickEditor/final/EditorRoot.qml @@ -188,9 +188,28 @@ ctx.strokeRect(selectionBoxX - 4, selectionBoxY - selectionTextRect.height - 2, selectionTextRect.width + 10, selectionTextRect.height + 8); ctx.fillStyle = systemPalette.windowText; ctx.fillText(selectionText, selectionBoxX, selectionBoxY); + if (selection.zx >= 0 && selection.zy >= 0) { + var zx = selection.zx + 15; + var zy = selection.zy + 15; + if (zx + 72 >= Window.width) { + zx -= 102; + } + if (zy + 72 >= Window.height) { + zy -= 102; + } + crossMagnifier.visible = true; + crossMagnifier.x = zx; + crossMagnifier.y = zy; + crossBackground.x = -selection.zx * 8 + 32; + crossBackground.y = -selection.zy * 8 + 32; + ctx.strokeRect(zx, zy, 72, 72); + } else { + crossMagnifier.visible = false; + } } else { midHelpText.visible = true; bottomHelpText.visible = false; + crossMagnifier.visible = false; } } @@ -229,6 +248,7 @@ border.width: 1; border.color: Qt.rgba(0, 0, 0, 1); color: Qt.rgba(1, 1, 1, 0.85); + visible: false; anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; @@ -241,6 +261,46 @@ anchors.centerIn: parent; } } + + Rectangle { + id: crossMagnifier; + objectName: "crossMagnifier"; + + height: 72; + width: 72; + border.width: 1; + border.color: Qt.rgba(0, 0, 0, 1); + visible: false; + clip: true + + Image { + id: crossBackground; + objectName: "crossBackground"; + source: "image://snapshot/rawimage"; + cache: false; + smooth: false; + height: Window.height / Screen.devicePixelRatio * 8; + width: Window.width / Screen.devicePixelRatio * 8; + fillMode: Image.PreserveAspectCrop; + } + + Rectangle { + x: 32; + y: 0; + width: 8; + height: 72; + color: Qt.rgba(0.114, 0.6, 0.953, 0.5); + } + + Rectangle { + x: 0; + y: 32; + width: 72; + height: 8; + color: Qt.rgba(0.114, 0.6, 0.953, 0.5); + } + } + } MouseArea { @@ -269,10 +329,12 @@ } onPositionChanged: { + selection.zx = mouse.x; + selection.zy = mouse.y; selection.x = Math.min(startx, mouse.x); selection.y = Math.min(starty, mouse.y); - selection.width = Math.abs(startx - mouse.x) + 1; - selection.height = Math.abs(starty - mouse.y) + 1; + selection.width = Math.abs(startx - mouse.x); + selection.height = Math.abs(starty - mouse.y); cropDisplayCanvas.requestPaint(); } @@ -283,6 +345,12 @@ cropDisplayCanvas.requestPaint(); } } + + onReleased: { + selection.zx = -1; + selection.zy = -1; + cropDisplayCanvas.requestPaint(); + } } Component { diff --git a/src/QuickEditor/SelectionRectangle.qml b/src/QuickEditor/final/SelectionRectangle.qml copy from src/QuickEditor/SelectionRectangle.qml copy to src/QuickEditor/final/SelectionRectangle.qml --- a/src/QuickEditor/SelectionRectangle.qml +++ b/src/QuickEditor/final/SelectionRectangle.qml @@ -25,8 +25,8 @@ property var drawCanvas: null; property var imageElement: null; - property int minRectSize: 20; - property int mouseAreaSize: 20; + property int zx: -1; + property int zy: -1; signal doubleClicked(); @@ -70,26 +70,35 @@ anchors.top: parent.top; anchors.left: parent.left; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeFDiagCursor; onPressed: { - brxLimit = (parent.x + parent.width) - minRectSize; - bryLimit = (parent.y + parent.height) - minRectSize; + brxLimit = (parent.x + parent.width) - 20; + bryLimit = (parent.y + parent.height) - 20; + parent.zx = parent.x; + parent.zy = parent.y; } onPositionChanged: { if ((parent.x + mouse.x) < brxLimit) { - parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.x = parent.x + mouse.x; + parent.zx = parent.zx + mouse.x; } if ((parent.y + mouse.y) < bryLimit) { - parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.y = parent.y + mouse.y; + parent.zy = parent.zy + mouse.y; } + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } @@ -103,25 +112,34 @@ anchors.top: parent.top; anchors.right: parent.right; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeBDiagCursor; onPressed: { - brxLimit = parent.x + mouseAreaSize + minRectSize; - bryLimit = (parent.y + parent.height) - minRectSize; + brxLimit = parent.x + 40; + bryLimit = (parent.y + parent.height) - 20; + parent.zx = parent.x + parent.width; + parent.zy = parent.y; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > brxLimit) { - parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.width = parent.width + mouse.x - 20; + parent.zx = parent.zx + mouse.x - 20; } if ((parent.y + mouse.y) < bryLimit) { - parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.y = parent.y + mouse.y; + parent.zy = parent.zy + mouse.y; } + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } @@ -135,25 +153,34 @@ anchors.bottom: parent.bottom; anchors.left: parent.left; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeBDiagCursor; onPressed: { - brxLimit = (parent.x + parent.width) - minRectSize; - bryLimit = parent.y + mouseAreaSize + minRectSize; + brxLimit = (parent.x + parent.width) - 20; + bryLimit = parent.y + 40; + parent.zx = parent.x; + parent.zy = parent.y + parent.height; } onPositionChanged: { if ((parent.x + mouse.x) < brxLimit) { - parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.x = parent.x + mouse.x; + parent.zx = parent.zx + mouse.x; } if ((parent.y + parent.height + mouse.y) > bryLimit) { - parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.height = parent.height + mouse.y - 20; + parent.zy = parent.zy + mouse.y - 20; } + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } @@ -167,25 +194,35 @@ anchors.bottom: parent.bottom; anchors.right: parent.right; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeFDiagCursor; onPressed: { - brxLimit = parent.x + mouseAreaSize + minRectSize; - bryLimit = parent.y + mouseAreaSize + minRectSize; + brxLimit = parent.x + 40; + bryLimit = parent.y + 40; + parent.zx = parent.x + parent.width; + parent.zy = parent.y + parent.height; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > brxLimit) { - parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.width = parent.width + mouse.x - 20; + parent.zx = parent.zx + mouse.x - 20; } if ((parent.y + parent.height + mouse.y) > bryLimit) { - parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.height = parent.height + mouse.y - 20; + parent.zy = parent.zy + mouse.y - 20; } drawCanvas.requestPaint(); } + + onReleased: { + parent.zx = -1; + parent.zy = -1; + drawCanvas.requestPaint(); + } } MouseArea { @@ -196,20 +233,29 @@ anchors.horizontalCenter: parent.horizontalCenter; anchors.top: parent.top; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeVerCursor; onPressed: { - limit = (parent.y + parent.height) - minRectSize; + limit = (parent.y + parent.height) - 20; + parent.zx = parent.x + parent.width / 2 - 10; + parent.zy = parent.y; } onPositionChanged: { if ((parent.y + mouse.y) < limit) { - parent.y = parent.y + mouse.y; parent.height = parent.height - mouse.y; + parent.y = parent.y + mouse.y; + parent.zy = parent.zy + mouse.y; } + parent.zx = parent.x + parent.width / 2 - 10 + mouse.x; + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } @@ -222,19 +268,28 @@ anchors.horizontalCenter: parent.horizontalCenter; anchors.bottom: parent.bottom; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeVerCursor; onPressed: { - limit = parent.y + mouseAreaSize + minRectSize; + limit = parent.y + 40; + parent.zx = parent.x + parent.width / 2 - 10; + parent.zy = parent.y + parent.height; } onPositionChanged: { if ((parent.y + parent.height + mouse.y) > limit) { - parent.height = parent.height + mouse.y - mouseAreaSize + 1; + parent.height = parent.height + mouse.y - 20; + parent.zy = parent.zy + mouse.y - 20; } + parent.zx = parent.x + parent.width / 2 - 10 + mouse.x; + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } @@ -247,20 +302,29 @@ anchors.verticalCenter: parent.verticalCenter; anchors.left: parent.left; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeHorCursor; onPressed: { - limit = (parent.x + parent.width) - minRectSize; + limit = (parent.x + parent.width) - 20; + parent.zx = parent.x; + parent.zy = parent.y + parent.height / 2 - 10; } onPositionChanged: { if ((parent.x + mouse.x) < limit) { - parent.x = parent.x + mouse.x; parent.width = parent.width - mouse.x; + parent.x = parent.x + mouse.x; + parent.zx = parent.zx + mouse.x; } + parent.zy = parent.y + parent.height / 2 - 10 + mouse.y; + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } @@ -273,19 +337,28 @@ anchors.verticalCenter: parent.verticalCenter; anchors.right: parent.right; - width: mouseAreaSize; - height: mouseAreaSize; + width: 20; + height: 20; cursorShape: Qt.SizeHorCursor; onPressed: { - limit = parent.x + mouseAreaSize + minRectSize; + limit = parent.x + 40; + parent.zx = parent.x + parent.width; + parent.zy = parent.y + parent.height / 2 - 10; } onPositionChanged: { if ((parent.x + parent.width + mouse.x) > limit) { - parent.width = parent.width + mouse.x - mouseAreaSize + 1; + parent.width = parent.width + mouse.x - 20; + parent.zx = parent.zx + mouse.x - 20; } + parent.zy = parent.y + parent.height / 2 - 10 + mouse.y; + drawCanvas.requestPaint(); + } + onReleased: { + parent.zx = -1; + parent.zy = -1; drawCanvas.requestPaint(); } } diff --git a/src/SpectacleConfig.h b/src/SpectacleConfig.h --- a/src/SpectacleConfig.h +++ b/src/SpectacleConfig.h @@ -75,6 +75,9 @@ bool quitAfterSaveOrCopyChecked() const; void setQuitAfterSaveOrCopyChecked(bool enabled); + bool showMagnifierChecked() const; + void setShowMagnifierChecked(bool enabled); + qreal captureDelay() const; void setCaptureDelay(qreal delay); diff --git a/src/SpectacleConfig.cpp b/src/SpectacleConfig.cpp --- a/src/SpectacleConfig.cpp +++ b/src/SpectacleConfig.cpp @@ -128,6 +128,19 @@ mGuiConfig.sync(); } +// show magnifier + +bool SpectacleConfig::showMagnifierChecked() const +{ + return mGuiConfig.readEntry(QStringLiteral("showMagnifier"), false); +} + +void SpectacleConfig::setShowMagnifierChecked(bool enabled) +{ + mGuiConfig.writeEntry(QStringLiteral("showMagnifier"), enabled); + mGuiConfig.sync(); +} + // capture delay qreal SpectacleConfig::captureDelay() const