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,7 @@ property int magZoom: 5; property int magPixels: 16; property int magOffset: 32; + property int largeChange: 20; SystemPalette { id: systemPalette; @@ -78,11 +79,90 @@ } Keys.onPressed: { + + // 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: + selection.x--; + break; + case Qt.Key_Right: + selection.x++; + break; + case Qt.Key_Up: + selection.y--; + break; + case Qt.Key_Down: + selection.y++; + break; + } + break; // end no modifier (just arrows) + + case Qt.ControlModifier: + switch(event.key) { + case Qt.Key_Left: + selection.x = selection.x - largeChange; + break; + case Qt.Key_Right: + selection.x = selection.x + largeChange; + break; + case Qt.Key_Up: + selection.y = selection.y - largeChange; + break; + case Qt.Key_Down: + selection.y = selection.y + largeChange; + break; + } + break; // end CTRL + arrows (large move) + + case Qt.AltModifier: + switch(event.key) { + case Qt.Key_Left: + selection.width--; + break; + case Qt.Key_Right: + selection.width++; + break; + case Qt.Key_Up: + selection.height--; + break; + case Qt.Key_Down: + selection.height++; + break; + } + break; // end ALT + arrows (resize rectangle) + + case(Qt.ControlModifier + Qt.AltModifier): + switch(event.key) { + case Qt.Key_Left: + selection.width = selection.width - largeChange; + break; + case Qt.Key_Right: + selection.width = selection.width + largeChange; + break; + case Qt.Key_Up: + selection.height = selection.height - largeChange; + break; + case Qt.Key_Down: + selection.height = selection.height + largeChange; + break; + } + break; // end CTRL + ALT + arrows (large resize rectangle) + + } + + // all switches done; repaint on any keypress + cropDisplayCanvas.requestPaint(); + + } // end Keys.onPressed + Keys.onReleased: { if (toggleMagnifier && !(event.modifiers & Qt.ShiftModifier)) { @@ -254,8 +334,8 @@ id: midHelpText; objectName: "midHelpText"; - height: midHelpTextElement.height + 40; - width: midHelpTextElement.width + 40; + height: midHelpTextElement.height + 20; + width: midHelpTextElement.width + 20; radius: 4; border.color: systemPalette.windowText; color: labelBackgroundColour; @@ -277,46 +357,100 @@ id: bottomHelpText; objectName: "bottomHelpText"; - height: bottomHelpTextElement.height + 20; - width: bottomHelpTextElement.width + 20; + height: bottomHelpTextElement.height + width: bottomHelpTextElement.width radius: 4; border.color: systemPalette.windowText; color: labelBackgroundColour; visible: false; anchors.bottom: parent.bottom; anchors.horizontalCenter: parent.horizontalCenter; + RowLayout { + id: bottomHelpTextElement + GridLayout { - id: bottomHelpTextElement; + id: leftHelpGrid columns: 2 - anchors.centerIn: parent; + Layout.alignment: Qt.AlignLeft && Qt.AlignHCenter + Layout.leftMargin: 10 + Layout.topMargin: 5 + Layout.bottomMargin: 5 Label { text: i18n("Enter, double-click:"); - Layout.alignment: Qt.AlignRight; + Layout.alignment: Qt.AlignLeft; } Label { text: i18n("Take screenshot"); } Label { text: i18n("Shift:"); - Layout.alignment: Qt.AlignRight; + Layout.alignment: Qt.AlignLeft; } Label { text: i18n("Hold to toggle magnifier"); } Label { text: i18n("Right-click:"); - Layout.alignment: Qt.AlignRight; + Layout.alignment: Qt.AlignLeft; } Label { text: i18n("Reset selection"); } Label { text: i18n("Esc:"); - Layout.alignment: Qt.AlignRight; + Layout.alignment: Qt.AlignLeft; } Label { text: i18n("Cancel"); } + + } + + // 1px wide Rectangle to draw divider line + Rectangle { + color: labelBackgroundColour; + border.color: systemPalette.windowText + border.width: 1 + height: leftHelpGrid.height + 10 + Layout.alignment: Qt.AlignTop + width: 1 + } + + GridLayout { + id: rightHelpGrid + columns: 2 + Layout.alignment: Qt.AlignLeft && Qt.AlignHCenter + Layout.rightMargin: 10 + Layout.leftMargin: 4 + Layout.topMargin: 5 + Layout.bottomMargin: 5 + + Label { + text: i18n("Arrow Keys:"); + Layout.alignment: Qt.AlignLeft; + } + Label { text: i18n("Move selection rectangle"); } + + Label { + text: i18n("CTRL + Arrow Keys:"); + Layout.alignment: Qt.AlignLeft; + } + Label { text: i18n("Move selection rectangle %1 pixels", largeChange); } + + Label { + text: i18n("ALT + Arrow Keys:"); + Layout.alignment: Qt.AlignLeft; + } + Label { text: i18n("Resize selection rectangle"); } + + Label { + text: i18n("ALT + CTRL + Arrow Keys:"); + Layout.alignment: Qt.AlignLeft; + } + Label { text: i18n("Resize selection rectangle by %1 pixels", largeChange); } + } } + } + // Use Rectangle so that the background is white when cursor nearby edge Rectangle { @@ -368,7 +502,6 @@ color: crossColour; } } - } MouseArea {