diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -29,8 +29,8 @@ &FDLNotice; - 2018-03-06 - Applications 18.04 + 2018-07-17 + Applications 18.08 &spectacle; is a simple application for capturing desktop screenshots. It can capture images of the entire desktop, a single monitor, the currently active window, the window currently under the mouse, or a rectangular region of the screen. The images can then be printed, sent to other applications for manipulation, or quickly be saved as-is. @@ -150,6 +150,9 @@ The Rectangular Region option allows you to select a rectangular region of your desktop with your mouse. This region may be spread across different outputs. This mode does not immediately take a screenshot but allows you to draw a rectangle on your screen, which can be moved and resized as needed. Once the desired selection rectangle has been drawn, double-clicking anywhere on the screen, or pressing the &Enter; button on the keyboard will capture the screenshot. + + You can use the arrow keys to move and adjust the rectangle. Pressing the arrow keys will move the rectangle. Holding the Shift key while pressing the arrow keys will move the rectangle slowly, for fine-tuning your selection. Holding the Alt key while pressing the arrow keys will adjust the size of the rectangle. + diff --git a/src/QuickEditor/EditorRoot.qml b/src/QuickEditor/EditorRoot.qml --- a/src/QuickEditor/EditorRoot.qml +++ b/src/QuickEditor/EditorRoot.qml @@ -38,6 +38,8 @@ property int magZoom: 5; property int magPixels: 16; property int magOffset: 32; + property double largeChange: 15; + property double smallChange: 1 / Screen.devicePixelRatio; SystemPalette { id: systemPalette; @@ -78,11 +80,202 @@ } Keys.onPressed: { + + var change; + + // shift key alone = magnifier toggle if (event.modifiers & Qt.ShiftModifier) { toggleMagnifier = true; - cropDisplayCanvas.requestPaint(); } - } + + // nested switches for arrow keys based on modifier keys + switch(event.modifiers) { + + case Qt.NoModifier: + switch (event.key) { + + case Qt.Key_Left: + change = checkBounds(-largeChange, 0.0, "left"); + selection.x += change; + break; + case Qt.Key_Right: + change = checkBounds(largeChange, 0.0, "right"); + selection.x += change; + break; + case Qt.Key_Up: + change = checkBounds(0.0, -largeChange, "up"); + selection.y += change; + break; + case Qt.Key_Down: + change = checkBounds(0.0, largeChange, "down"); + selection.y += change; + break; + } + + break; // end no modifier (just arrows) + + case Qt.ShiftModifier: + switch (event.key) { + + case Qt.Key_Left: + change = checkBounds(-smallChange, 0.0, "left"); + selection.x += change; + break; + + case Qt.Key_Right: + change = checkBounds(smallChange, 0.0, "right"); + selection.x += change; + break; + + case Qt.Key_Up: + change = checkBounds(0.0, -smallChange, "up"); + selection.y += change; + break; + + case Qt.Key_Down: + change = checkBounds(0.0, smallChange, "down"); + selection.y += change; + break; + } + + break; // end Shift + arrows (large move) + + case Qt.AltModifier: + switch (event.key) { + + case Qt.Key_Left: + change = checkBounds(-largeChange, 0.0, "left"); + if (selection.width + change <= 0.0) { + selection.width = 0.0; + } else { + selection.width += change; + } + break; + + case Qt.Key_Right: + change = checkBounds(largeChange, 0.0, "right"); + selection.width += change; + break; + + case Qt.Key_Up: + change = checkBounds(0.0, -largeChange, "up"); + if (selection.height + change <= 0.0) { + selection.height = 0.0; + } else { + selection.height += change; + } + break; + + case Qt.Key_Down: + change = checkBounds(0.0, largeChange, "down"); + selection.height = selection.height + change; + break; + } + + break; // end ALT + arrows (resize rectangle) + + case (Qt.ShiftModifier + Qt.AltModifier): + switch (event.key) { + + case Qt.Key_Left: + change = checkBounds(-smallChange, 0.0, "left"); + if (selection.width + change <= 0.0) { + selection.width = 0.0; + } else { + selection.width += change; + } + break; + + case Qt.Key_Right: + change = checkBounds(smallChange, 0.0, "right"); + selection.width += change; + break; + + case Qt.Key_Up: + change = checkBounds(0.0, -smallChange, "up"); + if (selection.height + change <= 0.0) { + selection.height = 0.0; + } else { + selection.height += change + } + break; + + case Qt.Key_Down: + change = checkBounds(0.0, smallChange, "down"); + selection.height += change; + break; + } + + break; // end Shift + ALT + arrows (large resize rectangle) + + } + + // all switches done; repaint on any keypress + cropDisplayCanvas.requestPaint(); + + function checkBounds(changeX, changeY, direction) { + + var leftEdge = selection.x; + var rightEdge = selection.x + selection.width; + var topEdge = selection.y; + var bottomEdge = selection.y + selection.height; + + const screenMaxX = cropDisplayCanvas.width; + const screenMaxY = cropDisplayCanvas.height; + + var newX; + var newY; + + var overlap; + + newX = selection.x + changeX; + newY = selection.y + changeY; + + switch (direction) { + + case "left": + if (leftEdge + changeX > 0.0) { + return changeX; + } + + if (leftEdge + changeX < 0.0) { + return -leftEdge; + } + break; + + case "right": + newX = newX + selection.width; + if (newX < screenMaxX) { + return changeX; + } + if (newX > screenMaxX) { + overlap = newX - screenMaxX; + return changeX - overlap; + } + break; + + case "up": + if (topEdge + changeY > 0.0) { + return changeY; + } else { + return -topEdge; + } + + case "down": + newY = newY + selection.height; + if (newY < screenMaxY) { + return changeY; + } + if (newY > screenMaxY) { + overlap = newY - screenMaxY; + return changeY - overlap; + } + break; + + } + } + } // end Keys.onPressed + Keys.onReleased: { if (toggleMagnifier && !(event.modifiers & Qt.ShiftModifier)) { @@ -304,6 +497,13 @@ } Label { text: i18n("Hold to toggle magnifier"); } + Label { + text: i18n("Arrow keys:"); + Layout.alignment: Qt.AlignRight | Qt.AlignTop; + } + Label { text: i18n("Move selection rectangle \n" + + "Hold Alt to resize, Shift to fine-tune"); } + Label { text: i18n("Right-click:"); Layout.alignment: Qt.AlignRight; @@ -368,7 +568,6 @@ color: crossColour; } } - } MouseArea {