1
0
Fork 0

Qt 5.9: drop overlay for Shortcut support

Now we required 5.9, can use this everywhere
This commit is contained in:
James Turner 2020-06-18 13:03:35 +01:00
parent 306cc83744
commit 7313f62353
4 changed files with 24 additions and 79 deletions

View file

@ -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);

View file

@ -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();
}
}
}

View file

@ -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

View file

@ -105,7 +105,6 @@
<file>qml/Menu.qml</file>
<file>qml/BaseMenuItem.qml</file>
<file>qml/MenuItem.qml</file>
<file>qml/+qt56/MenuItem.qml</file>
<file>qml/MenuDivider.qml</file>
<file>qml/ToggleBox.qml</file>
<file>qml/LocationAltitudeRow.qml</file>