forked from qt-creator/qt-creator
QmlDesigner: Fix context menu looks
Change-Id: I6d8a87354456ced6420b62f6a8bfa73a81ce6228 Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
This commit is contained in:
committed by
Henning Gründl
parent
ef95a19a5f
commit
0e159760e5
@@ -24,20 +24,19 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
import QtQuick 2.12
|
import QtQuick 2.12
|
||||||
import QtQuick.Controls 2.12 as Controls2
|
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
id: contextMenu
|
id: contextMenu
|
||||||
|
|
||||||
property Item myTextEdit
|
property Item myTextEdit
|
||||||
|
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Undo"
|
text: "Undo"
|
||||||
enabled: myTextEdit.canUndo
|
enabled: myTextEdit.canUndo
|
||||||
onTriggered: myTextEdit.undo()
|
onTriggered: myTextEdit.undo()
|
||||||
/* shortcut: StandardKey.Undo Shortcuts in QQC2 seem to override global shortcuts */
|
/* shortcut: StandardKey.Undo Shortcuts in QQC2 seem to override global shortcuts */
|
||||||
}
|
}
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Redo"
|
text: "Redo"
|
||||||
enabled: myTextEdit.canRedo
|
enabled: myTextEdit.canRedo
|
||||||
onTriggered: myTextEdit.redo()
|
onTriggered: myTextEdit.redo()
|
||||||
@@ -47,32 +46,32 @@ Menu {
|
|||||||
MenuSeparator {
|
MenuSeparator {
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Copy"
|
text: "Copy"
|
||||||
enabled: myTextEdit.selectedText !== ""
|
enabled: myTextEdit.selectedText !== ""
|
||||||
onTriggered: myTextEdit.copy()
|
onTriggered: myTextEdit.copy()
|
||||||
/* shortcut: StandardKey.Copy Shortcuts in QQC2 seem to override global shortcuts */
|
/* shortcut: StandardKey.Copy Shortcuts in QQC2 seem to override global shortcuts */
|
||||||
}
|
}
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Cut"
|
text: "Cut"
|
||||||
enabled: myTextEdit.selectedText !== "" && !myTextEdit.readOnly
|
enabled: myTextEdit.selectedText !== "" && !myTextEdit.readOnly
|
||||||
onTriggered: myTextEdit.cut()
|
onTriggered: myTextEdit.cut()
|
||||||
/* shortcut: StandardKey.Cut Shortcuts in QQC2 seem to override global shortcuts */
|
/* shortcut: StandardKey.Cut Shortcuts in QQC2 seem to override global shortcuts */
|
||||||
}
|
}
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Paste"
|
text: "Paste"
|
||||||
enabled: myTextEdit.canPaste
|
enabled: myTextEdit.canPaste
|
||||||
onTriggered: myTextEdit.paste()
|
onTriggered: myTextEdit.paste()
|
||||||
/* shortcut: StandardKey.Paste Shortcuts in QQC2 seem to override global shortcuts */
|
/* shortcut: StandardKey.Paste Shortcuts in QQC2 seem to override global shortcuts */
|
||||||
}
|
}
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Delete"
|
text: "Delete"
|
||||||
enabled: myTextEdit.selectedText !== ""
|
enabled: myTextEdit.selectedText !== ""
|
||||||
onTriggered: myTextEdit.remove(myTextEdit.selectionStart,
|
onTriggered: myTextEdit.remove(myTextEdit.selectionStart,
|
||||||
myTextEdit.selectionEnd)
|
myTextEdit.selectionEnd)
|
||||||
/* shortcut: StandardKey.Delete Shortcuts in QQC2 seem to override global shortcuts */
|
/* shortcut: StandardKey.Delete Shortcuts in QQC2 seem to override global shortcuts */
|
||||||
}
|
}
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Clear"
|
text: "Clear"
|
||||||
enabled: myTextEdit.text !== ""
|
enabled: myTextEdit.text !== ""
|
||||||
onTriggered: myTextEdit.clear()
|
onTriggered: myTextEdit.clear()
|
||||||
@@ -82,7 +81,7 @@ Menu {
|
|||||||
MenuSeparator {
|
MenuSeparator {
|
||||||
}
|
}
|
||||||
|
|
||||||
Controls2.MenuItem {
|
MenuItem {
|
||||||
text: "Select All"
|
text: "Select All"
|
||||||
enabled: myTextEdit.text !== ""
|
enabled: myTextEdit.text !== ""
|
||||||
&& myTextEdit.selectedText !== myTextEdit.text
|
&& myTextEdit.selectedText !== myTextEdit.text
|
||||||
|
@@ -46,11 +46,6 @@ T.MenuItem {
|
|||||||
action: Action {}
|
action: Action {}
|
||||||
|
|
||||||
contentItem: Item {
|
contentItem: Item {
|
||||||
id: menuItem
|
|
||||||
|
|
||||||
width: control.menu.width
|
|
||||||
height: StudioTheme.Values.height
|
|
||||||
|
|
||||||
Text {
|
Text {
|
||||||
id: textLabel
|
id: textLabel
|
||||||
text: control.text
|
text: control.text
|
||||||
@@ -77,11 +72,11 @@ T.MenuItem {
|
|||||||
|
|
||||||
background: Rectangle {
|
background: Rectangle {
|
||||||
implicitWidth: textLabel.implicitWidth + control.labelSpacing + shortcutLabel.implicitWidth
|
implicitWidth: textLabel.implicitWidth + control.labelSpacing + shortcutLabel.implicitWidth
|
||||||
+ control.leftPadding + control.rightPadding // TODO
|
+ control.leftPadding + control.rightPadding
|
||||||
implicitHeight: StudioTheme.Values.height
|
implicitHeight: StudioTheme.Values.height
|
||||||
x: StudioTheme.Values.border
|
x: StudioTheme.Values.border
|
||||||
y: StudioTheme.Values.border
|
y: StudioTheme.Values.border
|
||||||
width: control.width - (StudioTheme.Values.border * 2)
|
width: control.menu.width - (StudioTheme.Values.border * 2)
|
||||||
height: control.height - (StudioTheme.Values.border * 2)
|
height: control.height - (StudioTheme.Values.border * 2)
|
||||||
color: control.down ? control.palette.midlight : control.highlighted ? StudioTheme.Values.themeInteraction : "transparent"
|
color: control.down ? control.palette.midlight : control.highlighted ? StudioTheme.Values.themeInteraction : "transparent"
|
||||||
}
|
}
|
||||||
|
@@ -36,11 +36,10 @@ T.MenuSeparator {
|
|||||||
implicitContentHeight + topPadding + bottomPadding)
|
implicitContentHeight + topPadding + bottomPadding)
|
||||||
|
|
||||||
padding: 0
|
padding: 0
|
||||||
verticalPadding: padding
|
|
||||||
|
|
||||||
contentItem: Rectangle {
|
contentItem: Rectangle {
|
||||||
implicitWidth: 10
|
width: control.parent.width
|
||||||
implicitHeight: StudioTheme.Values.border
|
height: StudioTheme.Values.border
|
||||||
color: StudioTheme.Values.themeControlOutline
|
color: StudioTheme.Values.themeControlOutline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user