Fixing bug with shortcuts no longer working when using MixedMenu.
This commit is contained in:
parent
092a101d2d
commit
f2de022f2a
3 changed files with 38 additions and 0 deletions
14
Action.qml
14
Action.qml
|
@ -62,6 +62,14 @@ Item {
|
||||||
onToggled: root.toggled()
|
onToggled: root.toggled()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// Forwarding to MenuBar. Little hack to make Action shortcuts work properly, because otherwise, they would not trigger
|
||||||
|
if(shortcut != 0) {
|
||||||
|
console.log("Adding shortcut for", text, "with shortcut", shortcut)
|
||||||
|
parent.parent.addShortcut(shortcut, root.triggered)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\qmlmethod void Action::toggle()
|
\qmlmethod void Action::toggle()
|
||||||
Toggles the \c checked state to its opposite state.
|
Toggles the \c checked state to its opposite state.
|
||||||
|
@ -70,4 +78,10 @@ Item {
|
||||||
root.trueItem.toggle()
|
root.trueItem.toggle()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlmethod void Action::addShortcut(keysequence sequence, var trigger)
|
||||||
|
|
||||||
|
*/
|
||||||
|
function addShortcut(sequence, trigger) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
9
Menu.qml
9
Menu.qml
|
@ -192,4 +192,13 @@ Item {
|
||||||
controlsMenu.popup()
|
controlsMenu.popup()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlmethod void Menu::addShortcut(keysequence sequence, var trigger)
|
||||||
|
Forwarding to MenuBar. Little hack to make Action shortcuts work properly, because otherwise, they would not trigger
|
||||||
|
\sa MenuBar::addShortcut
|
||||||
|
*/
|
||||||
|
function addShortcut(sequence, trigger) {
|
||||||
|
parent.parent.addShortcut(sequence, trigger)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
15
MenuBar.qml
15
MenuBar.qml
|
@ -82,4 +82,19 @@ Item {
|
||||||
function clear(){
|
function clear(){
|
||||||
root.trueItem.clear()
|
root.trueItem.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\qmlmethod void MenuBar::addShortcut(keysequence sequence, var trigger)
|
||||||
|
Little hack to make Action shortcuts work properly.
|
||||||
|
*/
|
||||||
|
function addShortcut(sequence, trigger) {
|
||||||
|
var newShortcut = Qt.createQmlObject(`
|
||||||
|
import QtQuick 2.12;
|
||||||
|
Shortcut {
|
||||||
|
context: Qt.ApplicationShortcut
|
||||||
|
}`, root, "shortcut" + sequence);
|
||||||
|
newShortcut.sequence = sequence
|
||||||
|
newShortcut.activated.connect(trigger)
|
||||||
|
console.log("Added shortcut " + sequence)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue