aboutsummaryrefslogtreecommitdiff
path: root/qml/main.qml
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2021-10-02 23:30:45 +0000
committerlink2xt <link2xt@testrun.org>2021-10-02 23:30:45 +0000
commit2936a854df9f1a1202fda08cd71773a95c727603 (patch)
tree063e23801381e88d4b421884168c9e199166896c /qml/main.qml
parent40092aa096bac7e279eb5a4cc97758bac484236c (diff)
downloadkdeltachat-2936a854df9f1a1202fda08cd71773a95c727603.tar.gz
kdeltachat-2936a854df9f1a1202fda08cd71773a95c727603.zip
Fix QML code style
Mostly qmlformat, also rename root "id"s.
Diffstat (limited to 'qml/main.qml')
-rw-r--r--qml/main.qml109
1 files changed, 57 insertions, 52 deletions
diff --git a/qml/main.qml b/qml/main.qml
index 4969a45..1b7e1a4 100644
--- a/qml/main.qml
+++ b/qml/main.qml
@@ -1,33 +1,60 @@
+import DeltaChat 1.0
import QtQuick 2.12
import QtQuick.Controls 2.12 as Controls
import org.kde.kirigami 2.12 as Kirigami
-import DeltaChat 1.0
-
-
Kirigami.ApplicationWindow {
id: root
property DcAccountsEventEmitter eventEmitter
title: qsTr("Delta Chat")
+ Component.onCompleted: {
+ console.log('starting');
+ // Create an account if there is none.
+ if (dcAccounts.getSelectedAccount() == null) {
+ console.log("Adding first account");
+ dcAccounts.addAccount();
+ }
+ eventEmitter = dcAccounts.getEventEmitter();
+ eventEmitter.start();
+ // Open selected account if there is one.
+ let selectedAccount = dcAccounts.getSelectedAccount();
+ if (selectedAccount) {
+ if (selectedAccount.isConfigured())
+ pageStack.replace("qrc:/qml/ChatlistPage.qml", {
+ "context": selectedAccount,
+ "eventEmitter": eventEmitter
+ });
+ else
+ pageStack.replace("qrc:/qml/ConfigurePage.qml", {
+ "context": selectedAccount,
+ "eventEmitter": eventEmitter
+ });
+ }
+ dcAccounts.startIo();
+ }
+ onClosing: {
+ // Cancel all tasks that may block the termination of event loop.
+ dcAccounts.stopIo();
+ }
- Component {id: accountsPage; AccountsPage {}}
-
- pageStack.initialPage: Kirigami.Page {}
+ Component {
+ id: accountsPage
- globalDrawer: Kirigami.GlobalDrawer {
- header: Controls.Switch {
- text: "Work offline"
- onCheckedChanged: {
- if (checked) {
- dcAccounts.stopIo()
- } else {
- dcAccounts.startIo()
- }
- }
+ AccountsPage {
}
+ }
+
+ DcAccounts {
+ id: dcAccounts
+ }
+
+ pageStack.initialPage: Kirigami.Page {
+ }
+
+ globalDrawer: Kirigami.GlobalDrawer {
actions: [
Kirigami.Action {
text: "Maybe network"
@@ -38,50 +65,28 @@ Kirigami.ApplicationWindow {
text: "Switch account"
iconName: "system-switch-user"
onTriggered: {
- while (pageStack.layers.depth > 1) {
- pageStack.layers.pop()
- }
- pageStack.layers.push(accountsPage)
+ while (pageStack.layers.depth > 1)
+ pageStack.layers.pop();
+
+ pageStack.layers.push(accountsPage);
}
}
]
- }
- contextDrawer: Kirigami.ContextDrawer {
- id: contextDrawer
- }
-
- DcAccounts {
- id: dcAccounts
- }
-
- Component.onCompleted: {
- console.log('starting')
-
- // Create an account if there is none.
- if (dcAccounts.getSelectedAccount() == null) {
- console.log("Adding first account");
- dcAccounts.addAccount();
- }
-
- eventEmitter = dcAccounts.getEventEmitter()
- eventEmitter.start();
-
- // Open selected account if there is one.
- let selectedAccount = dcAccounts.getSelectedAccount();
- if (selectedAccount) {
- if (selectedAccount.isConfigured()) {
- pageStack.replace("qrc:/qml/ChatlistPage.qml", {context: selectedAccount, eventEmitter: eventEmitter})
- } else {
- pageStack.replace("qrc:/qml/ConfigurePage.qml", {context: selectedAccount, eventEmitter: eventEmitter})
+ header: Controls.Switch {
+ text: "Work offline"
+ onCheckedChanged: {
+ if (checked)
+ dcAccounts.stopIo();
+ else
+ dcAccounts.startIo();
}
}
- dcAccounts.startIo()
}
- onClosing: {
- // Cancel all tasks that may block the termination of event loop.
- dcAccounts.stopIo()
+ contextDrawer: Kirigami.ContextDrawer {
+ id: contextDrawer
}
+
}