Add MnemonicLabel and MnemonicAction components
Looks like i am going to do many Labels and Actions that require mnemonics, and i do not want to setup the properties everytime.
This commit is contained in:
parent
268f4329c0
commit
392d993c8a
|
@ -15,6 +15,8 @@ qt_add_qml_module(${PROJECT_NAME}
|
|||
ErrorNotification.qml
|
||||
LoginPage.qml
|
||||
Main.qml
|
||||
MnemonicAction.qml
|
||||
MnemonicLabel.qml
|
||||
ReservationsPage.qml
|
||||
SelectableLabel.qml
|
||||
)
|
||||
|
|
|
@ -9,19 +9,9 @@ Page {
|
|||
title: qsTr("Login")
|
||||
|
||||
ColumnLayout {
|
||||
Label {
|
||||
id: userLabel
|
||||
|
||||
Mnemonic.label: qsTr("&User:")
|
||||
text: Mnemonic.richTextLabel
|
||||
|
||||
Shortcut {
|
||||
sequence: userLabel.Mnemonic.sequence
|
||||
|
||||
onActivated: function () {
|
||||
user.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
MnemonicLabel {
|
||||
buddy: user
|
||||
mnemonic: qsTr("&User:")
|
||||
}
|
||||
|
||||
TextField {
|
||||
|
@ -30,19 +20,9 @@ Page {
|
|||
focus: true
|
||||
}
|
||||
|
||||
Label {
|
||||
id: passwordLabel
|
||||
|
||||
Mnemonic.label: qsTr("&Password:")
|
||||
text: Mnemonic.richTextLabel
|
||||
|
||||
Shortcut {
|
||||
sequence: passwordLabel.Mnemonic.sequence
|
||||
|
||||
onActivated: function () {
|
||||
password.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
MnemonicLabel {
|
||||
buddy: password
|
||||
mnemonic: qsTr("&Password:")
|
||||
}
|
||||
|
||||
TextField {
|
||||
|
@ -56,12 +36,10 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
Action {
|
||||
MnemonicAction {
|
||||
id: loginAction
|
||||
|
||||
Mnemonic.label: qsTr("Log &in")
|
||||
shortcut: Mnemonic.sequence
|
||||
text: Mnemonic.richTextLabel
|
||||
mnemonic: qsTr("Log &in")
|
||||
|
||||
onTriggered: function () {
|
||||
Database.open(user.text, password.text);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Action {
|
||||
id: control
|
||||
|
||||
required property string mnemonic
|
||||
|
||||
Mnemonic.label: mnemonic
|
||||
shortcut: Mnemonic.sequence
|
||||
text: Mnemonic.richTextLabel
|
||||
}
|
|
@ -0,0 +1,21 @@
|
|||
pragma ComponentBehavior: Bound
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
Label {
|
||||
id: control
|
||||
|
||||
required property Item buddy
|
||||
required property string mnemonic
|
||||
|
||||
Mnemonic.label: control.mnemonic
|
||||
text: Mnemonic.richTextLabel
|
||||
|
||||
Shortcut {
|
||||
sequence: control.Mnemonic.sequence
|
||||
|
||||
onActivated: function () {
|
||||
control.buddy.forceActiveFocus();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -15,13 +15,11 @@ Page {
|
|||
}
|
||||
}
|
||||
|
||||
Action {
|
||||
MnemonicAction {
|
||||
id: logoutAction
|
||||
|
||||
Mnemonic.label: qsTr("Log &out")
|
||||
icon.name: "system-log-out"
|
||||
shortcut: Mnemonic.sequence
|
||||
text: Mnemonic.richTextLabel
|
||||
mnemonic: qsTr("Log &out")
|
||||
|
||||
onTriggered: function () {
|
||||
Database.close();
|
||||
|
|
Loading…
Reference in New Issue