From 7313f623538add68e158ba1432acc88ffebfd771 Mon Sep 17 00:00:00 2001 From: James Turner Date: Thu, 18 Jun 2020 13:03:35 +0100 Subject: [PATCH] Qt 5.9: drop overlay for Shortcut support Now we required 5.9, can use this everywhere --- src/GUI/LauncherMainWindow.cxx | 7 ---- src/GUI/qml/+qt56/MenuItem.qml | 68 ---------------------------------- src/GUI/qml/MenuItem.qml | 27 ++++++++++++-- src/GUI/resources.qrc | 1 - 4 files changed, 24 insertions(+), 79 deletions(-) delete mode 100644 src/GUI/qml/+qt56/MenuItem.qml diff --git a/src/GUI/LauncherMainWindow.cxx b/src/GUI/LauncherMainWindow.cxx index ec96ad694..ffdb7bc6b 100755 --- a/src/GUI/LauncherMainWindow.cxx +++ b/src/GUI/LauncherMainWindow.cxx @@ -85,13 +85,6 @@ LauncherMainWindow::LauncherMainWindow() : setResizeMode(QQuickView::SizeRootObjectToView); engine()->addImportPath("qrc:///"); - // allow selecting different QML files based on the Qt version we are - // compiled against - auto selector = new QQmlFileSelector(engine(), this); -#if QT_VERSION >= 0x050600 - selector->setExtraSelectors({"qt56"}); -#endif - QQmlContext* ctx = rootContext(); ctx->setContextProperty("_launcher", m_controller); ctx->setContextProperty("_addOns", addOnsCtl); diff --git a/src/GUI/qml/+qt56/MenuItem.qml b/src/GUI/qml/+qt56/MenuItem.qml deleted file mode 100644 index 7f5430f12..000000000 --- a/src/GUI/qml/+qt56/MenuItem.qml +++ /dev/null @@ -1,68 +0,0 @@ -import QtQuick 2.6 // so we can use Shortcut -import "." -import ".." - -BaseMenuItem { - id: root - - property alias text: itemText.text - property alias shortcut: keyShortcut.sequence - - signal triggered(); - - function minWidth() { - return itemText.width + shortcutText.width + (Style.inset * 2) - } - - Shortcut { - id: keyShortcut - onActivated: root.triggered(); - enabled: root.enabled - } - - Rectangle { - height: parent.height - width: parent.width - visible: mouse.containsMouse - color: "#cfcfcf" - } - - Text { - id: itemText - font.pixelSize: Style.baseFontPixelSize - color: mouse.containsMouse ? Style.themeColor : - (root.enabled ? Style.baseTextColor : Style.disabledTextColor); - - anchors { - left: parent.left - leftMargin: Style.inset - verticalCenter: parent.verticalCenter - } - } - - Text { - id: shortcutText - color: Style.disabledTextColor - font.pixelSize: Style.baseFontPixelSize - width: implicitWidth + Style.inset - horizontalAlignment: Text.AlignRight - text: keyShortcut.nativeText - - anchors { - right: parent.right - rightMargin: Style.inset - verticalCenter: parent.verticalCenter - } - } - - MouseArea { - id: mouse - enabled: root.enabled - anchors.fill: parent - hoverEnabled: root.enabled - onClicked: { - root.closeMenu(); - root.triggered(); - } - } -} diff --git a/src/GUI/qml/MenuItem.qml b/src/GUI/qml/MenuItem.qml index 31af765f8..ed91379d3 100644 --- a/src/GUI/qml/MenuItem.qml +++ b/src/GUI/qml/MenuItem.qml @@ -1,16 +1,22 @@ -import QtQuick 2.4 +import QtQuick 2.6 // so we can use Shortcut import "." BaseMenuItem { id: root property alias text: itemText.text - property string shortcut: "" // for compatability with Qt 5.6 and up + property alias shortcut: keyShortcut.sequence signal triggered(); function minWidth() { - return itemText.width + (Style.inset * 2) + return itemText.width + shortcutText.width + (Style.inset * 2) + } + + Shortcut { + id: keyShortcut + onActivated: root.triggered(); + enabled: root.enabled } Rectangle { @@ -33,6 +39,21 @@ BaseMenuItem { } } + Text { + id: shortcutText + color: Style.disabledTextColor + font.pixelSize: Style.baseFontPixelSize + width: implicitWidth + Style.inset + horizontalAlignment: Text.AlignRight + text: keyShortcut.nativeText + + anchors { + right: parent.right + rightMargin: Style.inset + verticalCenter: parent.verticalCenter + } + } + MouseArea { id: mouse enabled: root.enabled diff --git a/src/GUI/resources.qrc b/src/GUI/resources.qrc index 00ec2557c..4c516f813 100644 --- a/src/GUI/resources.qrc +++ b/src/GUI/resources.qrc @@ -105,7 +105,6 @@ qml/Menu.qml qml/BaseMenuItem.qml qml/MenuItem.qml - qml/+qt56/MenuItem.qml qml/MenuDivider.qml qml/ToggleBox.qml qml/LocationAltitudeRow.qml