diff options
Diffstat (limited to 'qml/main.qml')
-rw-r--r-- | qml/main.qml | 144 |
1 files changed, 135 insertions, 9 deletions
diff --git a/qml/main.qml b/qml/main.qml index 1b7e1a4..f1a04f0 100644 --- a/qml/main.qml +++ b/qml/main.qml @@ -9,6 +9,10 @@ Kirigami.ApplicationWindow { property DcAccountsEventEmitter eventEmitter title: qsTr("Delta Chat") + onClosing: { + // Cancel all tasks that may block the termination of event loop. + dcAccounts.stopIo(); + } Component.onCompleted: { console.log('starting'); // Create an account if there is none. @@ -32,11 +36,6 @@ Kirigami.ApplicationWindow { "eventEmitter": eventEmitter }); } - dcAccounts.startIo(); - } - onClosing: { - // Cancel all tasks that may block the termination of event loop. - dcAccounts.stopIo(); } Component { @@ -51,29 +50,133 @@ Kirigami.ApplicationWindow { id: dcAccounts } + Shortcut { + sequence: 'Esc' + onActivated: { + while (pageStack.layers.depth > 1) + pageStack.layers.pop(); + + } + } + + // Make Ctrl+Q works even when popup + // windows are opened + // Quit application + Shortcut { + sequence: 'Ctrl+Q' + onActivated: root.close() + context: Qt.ApplicationShortcut + } + + // Show sidebar with 'Work offline', 'Switch + // accounts' options + Shortcut { + sequence: 'Ctrl+Tab' + onActivated: sideBar.drawerOpen = true + } + + // Refresh network connectivity. Can be used + // to retry fetching messages + Shortcut { + sequence: 'F5' + onActivated: dcAccounts.maybeNetwork() + } + + // Show a popup listing keyboards shortcuts + // for KDeltaChat + Shortcut { + //context: Qt.ApplicationShortcut + + sequence: "F1" + onActivated: helpPopup.open() + } + + Controls.Popup { + id: workNetwNotif + + modal: false + focus: activeFocus ? false : false + dim: false + width: 150 + height: 50 + x: Math.round((parent.width - width) / 2) + padding: 10 + contentChildren: [ + Text { + text: "Network status :" + bottomPadding: 10 + font.bold: true + font.pixelSize: 14 + }, + Text { + text: offlineSwitch.checked ? "We can work offline now." : "We can work online now." + font.pixelSize: 9 + topPadding: 20 + leftPadding: 10 + bottomPadding: 20 + } + ] + } + + Controls.Popup { + id: helpPopup + + modal: true + focus: true + anchors.centerIn: parent + width: 200 + height: 200 + padding: 10 + contentChildren: [ + Text { + text: "Shortcuts :" + bottomPadding: 10 + font.bold: true + font.pixelSize: 14 + }, + Text { + text: "<b>F1</b>: Displays this" + "<br><b>F2</b>: Work on/offline" + "<br><b>F5</b>: Network check" + "<br><b>Shift+S</b>: Account settings" + "<br><b>Alt+C</b>: Clear search" + "<br><b>Alt+Tab</b>: Switch accounts" + "<br><b>Ctrl+F</b>: Search contacts" + "<br><b>Ctrl+N</b>: New chat" + "<br><b>Ctrl+S</b>: Send message" + "<br><b>Ctrl+Tab</b>: Show sidebar" + "<br><b>Ctrl+Q</b>: Quit" + topPadding: 20 + leftPadding: 10 + bottomPadding: 20 + } + ] + } + pageStack.initialPage: Kirigami.Page { } globalDrawer: Kirigami.GlobalDrawer { + id: sideBar + actions: [ Kirigami.Action { text: "Maybe network" + tooltip: "F5" iconName: "view-refresh" onTriggered: dcAccounts.maybeNetwork() }, Kirigami.Action { + shortcut: "Alt+Tab" text: "Switch account" - iconName: "system-switch-user" + tooltip: "Alt+Tab" + iconName: "system-users" onTriggered: { - while (pageStack.layers.depth > 1) - pageStack.layers.pop(); - + while (pageStack.layers.depth > 1)pageStack.layers.pop() pageStack.layers.push(accountsPage); } + }, + Kirigami.Action { + text: "Shortcuts" + tooltip: "F1" + iconName: "preferences-desktop-keyboard" + onTriggered: helpPopup.open() } ] header: Controls.Switch { + id: offlineSwitch + text: "Work offline" onCheckedChanged: { if (checked) @@ -81,6 +184,29 @@ Kirigami.ApplicationWindow { else dcAccounts.startIo(); } + + action: Kirigami.Action { + id: workOff + + shortcut: "F2" + tooltip: "F2" + onTriggered: { + if (offlineSwitch.state == "on") { + offlineSwitch.checked = false; + offlineSwitch.state = "off"; + workNetwNotif.close(); + workNetwNotif.open(); + console.log("Work online"); + } else { + offlineSwitch.checked = true; + offlineSwitch.state = "on"; + workNetwNotif.close(); + workNetwNotif.open(); + console.log("Work offline"); + } + } + } + } } |