summaryrefslogtreecommitdiff
path: root/src/controls/Private/EditMenu_base.qml
diff options
context:
space:
mode:
authorKai Uwe Broulik <kde@privat.broulik.de>2015-01-19 17:38:47 +0100
committerKai Uwe Broulik <kde@privat.broulik.de>2015-01-24 19:43:58 +0100
commit02d7f36ddfd444d715f82c1a780e99f6e0a7c14a (patch)
treef2005c1f05512016e16761e39592d6f75de2b1b3 /src/controls/Private/EditMenu_base.qml
parente6855d875c71bc2cb7f7758706830f329d6badcb (diff)
downloadqtquickcontrols-02d7f36ddfd444d715f82c1a780e99f6e0a7c14a.tar.gz
Add Undo, Redo, Delete, Clear and Select All actions to EditMenu
These items are present in their QtWidgets counterparts. Upstreamed from KDE's KQuickControls Change-Id: If9c6a8db676ee2c94927cbe9a41691d8b2072e07 Reviewed-by: Albert Astals Cid <albert.astals@canonical.com> Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls/Private/EditMenu_base.qml')
-rw-r--r--src/controls/Private/EditMenu_base.qml61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/controls/Private/EditMenu_base.qml b/src/controls/Private/EditMenu_base.qml
index 3745d9f4..354b9c66 100644
--- a/src/controls/Private/EditMenu_base.qml
+++ b/src/controls/Private/EditMenu_base.qml
@@ -46,6 +46,28 @@ Item {
anchors.fill: parent
Component {
+ id: undoAction
+ Action {
+ text: qsTr("&Undo")
+ shortcut: StandardKey.Undo
+ iconName: "edit-undo"
+ enabled: input.canUndo
+ onTriggered: input.undo()
+ }
+ }
+
+ Component {
+ id: redoAction
+ Action {
+ text: qsTr("&Redo")
+ shortcut: StandardKey.Redo
+ iconName: "edit-redo"
+ enabled: input.canRedo
+ onTriggered: input.redo()
+ }
+ }
+
+ Component {
id: cutAction
Action {
text: "Cu&t"
@@ -84,10 +106,49 @@ Item {
}
}
+ Component {
+ id: deleteAction
+ Action {
+ text: qsTr("Delete")
+ shortcut: StandardKey.Delete
+ iconName: "edit-delete"
+ enabled: !input.readOnly && input.selectionStart !== input.selectionEnd
+ onTriggered: input.remove(input.selectionStart, input.selectionEnd)
+ }
+ }
+
+ Component {
+ id: clearAction
+ Action {
+ text: qsTr("Clear")
+ shortcut: StandardKey.DeleteCompleteLine
+ iconName: "edit-clear"
+ enabled: !input.readOnly && input.length > 0
+ onTriggered: input.remove(0, input.length)
+ }
+ }
+
+ Component {
+ id: selectAllAction
+ Action {
+ text: qsTr("Select All")
+ shortcut: StandardKey.SelectAll
+ enabled: !(input.selectionStart === 0 && input.selectionEnd === input.length)
+ onTriggered: input.selectAll()
+ }
+ }
+
property Component defaultMenu: Menu {
+ MenuItem { action: undoAction.createObject(editMenuBase) }
+ MenuItem { action: redoAction.createObject(editMenuBase) }
+ MenuSeparator {}
MenuItem { action: cutAction.createObject(editMenuBase) }
MenuItem { action: copyAction.createObject(editMenuBase) }
MenuItem { action: pasteAction.createObject(editMenuBase) }
+ MenuItem { action: deleteAction.createObject(editMenuBase) }
+ MenuItem { action: clearAction.createObject(editMenuBase) }
+ MenuSeparator {}
+ MenuItem { action: selectAllAction.createObject(editMenuBase) }
}
Connections {