From 3d8914cb397a3859799fc4b4bee51b65ea56b596 Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 5 Nov 2020 20:45:36 -0400 Subject: [PATCH] HTextContextMenu: less entries for readOnly fields If the context menu is for a readOnly field or area, hide pointless options like undo/redo and cut/paste. --- src/gui/Base/HMenuSeparator.qml | 2 +- src/gui/Base/HTextContextMenu.qml | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/gui/Base/HMenuSeparator.qml b/src/gui/Base/HMenuSeparator.qml index ed7925b3..775646f8 100644 --- a/src/gui/Base/HMenuSeparator.qml +++ b/src/gui/Base/HMenuSeparator.qml @@ -8,6 +8,6 @@ MenuSeparator { id: separator padding: 0 contentItem: Item { - implicitHeight: theme.spacing + implicitHeight: separator.visible ? theme.spacing : 0 } } diff --git a/src/gui/Base/HTextContextMenu.qml b/src/gui/Base/HTextContextMenu.qml index b3f7ddb3..cde72905 100644 --- a/src/gui/Base/HTextContextMenu.qml +++ b/src/gui/Base/HTextContextMenu.qml @@ -34,6 +34,7 @@ HMenu { HMenuItem { icon.name: "undo" text: qsTr("Undo") + visible: ! control.readOnly enabled: control.canUndo onTriggered: control.undo() } @@ -41,15 +42,19 @@ HMenu { HMenuItem { icon.name: "redo" text: qsTr("Redo") + visible: ! control.readOnly enabled: control.canRedo onTriggered: control.redo() } - HMenuSeparator {} + HMenuSeparator { + visible: ! control.readOnly + } HMenuItem { icon.name: "cut-text" text: qsTr("Cut") + visible: ! control.readOnly enabled: control.selectedPlainText onTriggered: control.cut() } @@ -67,11 +72,14 @@ HMenu { icon.name: "paste-text" text: qsTr("Paste") + visible: ! control.readOnly enabled: control.canPaste || pasteImage onTriggered: pasteImage ? menu.customImagePaste() : control.paste() } - HMenuSeparator {} + HMenuSeparator { + visible: ! control.readOnly + } HMenuItem { icon.name: "select-all-text"