| 1 |
import QtQuick 2.6 // so we can use Shortcut |
| 2 |
import FlightGear 1.0 |
| 3 |
|
| 4 |
BaseMenuItem { |
| 5 |
id: root |
| 6 |
|
| 7 |
property alias text: itemText.text |
| 8 |
property alias shortcut: keyShortcut.sequence |
| 9 |
|
| 10 |
signal triggered(); |
| 11 |
|
| 12 |
function minWidth() { |
| 13 |
return itemText.width + shortcutText.width + (Style.inset * 2) |
| 14 |
} |
| 15 |
|
| 16 |
Shortcut { |
| 17 |
id: keyShortcut |
| 18 |
onActivated: root.triggered(); |
| 19 |
enabled: root.enabled |
| 20 |
} |
| 21 |
|
| 22 |
Rectangle { |
| 23 |
height: parent.height |
| 24 |
width: parent.width |
| 25 |
visible: mouse.containsMouse |
| 26 |
color: "#cfcfcf" |
| 27 |
} |
| 28 |
|
| 29 |
Text { |
| 30 |
id: itemText |
| 31 |
font.pixelSize: Style.baseFontPixelSize |
| 32 |
color: mouse.containsMouse ? Style.themeColor : |
| 33 |
(root.enabled ? Style.baseTextColor : Style.disabledTextColor); |
| 34 |
|
| 35 |
anchors { |
| 36 |
left: parent.left |
| 37 |
leftMargin: Style.inset |
| 38 |
verticalCenter: parent.verticalCenter |
| 39 |
} |
| 40 |
} |
| 41 |
|
| 42 |
Text { |
| 43 |
id: shortcutText |
| 44 |
color: Style.disabledTextColor |
| 45 |
font.pixelSize: Style.baseFontPixelSize |
| 46 |
width: implicitWidth + Style.inset |
| 47 |
horizontalAlignment: Text.AlignRight |
| 48 |
text: keyShortcut.nativeText |
| 49 |
|
| 50 |
anchors { |
| 51 |
right: parent.right |
| 52 |
rightMargin: Style.inset |
| 53 |
verticalCenter: parent.verticalCenter |
| 54 |
} |
| 55 |
} |
| 56 |
|
| 57 |
MouseArea { |
| 58 |
id: mouse |
| 59 |
enabled: root.enabled |
| 60 |
anchors.fill: parent |
| 61 |
hoverEnabled: root.enabled |
| 62 |
onClicked: { |
| 63 |
root.closeMenu(); |
| 64 |
root.triggered(); |
| 65 |
} |
| 66 |
} |
| 67 |
} |