-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathActions10.qml
33 lines (28 loc) · 986 Bytes
/
Actions10.qml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
pragma Singleton
import QtQuick 2.4
import QtQuick.Controls 1.3
import "." 1.0 as App
QtObject {
id: actionsSingleton
property Action appQuitAction: Action {
text: qsTr("E&xit")
tooltip: qsTr("Exit the application")
onTriggered: Qt.quit();
}
function keyPressed(event, source) {
if (event.matches(StandardKey.Quit) ||
(event.key === Qt.Key_Q && event.modifiers === Qt.ControlModifier)) {
appQuitAction.trigger(source);
} else {
event.accepted = false;
return;
}
event.accepted = true;
}
Component.onCompleted: {
// Keep all the shortcut assignments here simply to group them together for clarity.
appQuitAction.shortcut = "Ctrl+Q";
// There is currently a bug in QML when this file is a singleton whereby the shortcuts
// no longer work. Therefore the key handling is also handled in the keyPressed function.
}
}