diff options
author | link2xt <link2xt@testrun.org> | 2021-10-02 23:30:45 +0000 |
---|---|---|
committer | link2xt <link2xt@testrun.org> | 2021-10-02 23:30:45 +0000 |
commit | 2936a854df9f1a1202fda08cd71773a95c727603 (patch) | |
tree | 063e23801381e88d4b421884168c9e199166896c /qml/AccountsPage.qml | |
parent | 40092aa096bac7e279eb5a4cc97758bac484236c (diff) | |
download | kdeltachat-2936a854df9f1a1202fda08cd71773a95c727603.tar.gz kdeltachat-2936a854df9f1a1202fda08cd71773a95c727603.zip |
Fix QML code style
Mostly qmlformat, also rename root "id"s.
Diffstat (limited to 'qml/AccountsPage.qml')
-rw-r--r-- | qml/AccountsPage.qml | 116 |
1 files changed, 61 insertions, 55 deletions
diff --git a/qml/AccountsPage.qml b/qml/AccountsPage.qml index 204e4f8..1d91a5b 100644 --- a/qml/AccountsPage.qml +++ b/qml/AccountsPage.qml @@ -4,81 +4,61 @@ import QtQuick.Layouts 1.12 import org.kde.kirigami 2.12 as Kirigami Kirigami.Page { - id: accountsPage - - title: qsTr("Accounts") - - mainAction: Kirigami.Action { - iconName: "list-add-user" - text: "Add account" - onTriggered: { - let accountId = dcAccounts.addAccount() - let context = dcAccounts.getAccount(accountId); - - let title; - if (context.isConfigured()) { - title = context.getConfig("addr"); - } else { - title = `Unconfigured ${accountId}` - } - - accountsModel.insert(accountsModel.count, { - number: accountId, - title: title - }) - } - } - - ListModel { - id: accountsModel - } + id: root function updateAccounts() { - let accountsList = dcAccounts.getAll() - - accountsModel.clear() + let accountsList = dcAccounts.getAll(); + accountsModel.clear(); for (let i = 0; i < accountsList.length; i++) { let accountId = accountsList[i]; let title; let context = dcAccounts.getAccount(accountId); - if (context.isConfigured()) { + if (context.isConfigured()) title = context.getConfig("addr"); - } else { - title = `Unconfigured ${accountId}` - } - + else + title = `Unconfigured ${accountId}`; accountsModel.insert(i, { - number: accountId, - title: title - }) + "number": accountId, + "title": title + }); } } + title: qsTr("Accounts") Component.onCompleted: { - updateAccounts() + updateAccounts(); + } + + ListModel { + id: accountsModel } ListView { id: accountsListView + anchors.fill: parent model: accountsModel currentIndex: -1 delegate: Kirigami.AbstractListItem { width: accountsListView.width - onClicked: { - while (pageStack.depth > 1) { - pageStack.pop() - } - dcAccounts.selectAccount(model.number) - let context = dcAccounts.getSelectedAccount() - if (context.isConfigured()) { - pageStack.replace("qrc:/qml/ChatlistPage.qml", {context: context, eventEmitter: eventEmitter}) - } else { - pageStack.replace("qrc:/qml/ConfigurePage.qml", {context: context, eventEmitter: eventEmitter}) - } - pageStack.layers.pop() + while (pageStack.depth > 1) + pageStack.pop(); + + dcAccounts.selectAccount(model.number); + let context = dcAccounts.getSelectedAccount(); + if (context.isConfigured()) + pageStack.replace("qrc:/qml/ChatlistPage.qml", { + "context": context, + "eventEmitter": eventEmitter + }); + else + pageStack.replace("qrc:/qml/ConfigurePage.qml", { + "context": context, + "eventEmitter": eventEmitter + }); + pageStack.layers.pop(); } RowLayout { @@ -93,16 +73,42 @@ Kirigami.Page { icon.name: "delete" text: "Delete" onClicked: { - dcAccounts.removeAccount(model.number) - accountsModel.remove(model.index) + dcAccounts.removeAccount(model.number); + accountsModel.remove(model.index); } } + } + } + } Menu { id: contextMenu - MenuItem { text: "Import account" } + + MenuItem { + text: "Import account" + } + } + + mainAction: Kirigami.Action { + iconName: "list-add-user" + text: "Add account" + onTriggered: { + let accountId = dcAccounts.addAccount(); + let context = dcAccounts.getAccount(accountId); + let title; + if (context.isConfigured()) + title = context.getConfig("addr"); + else + title = `Unconfigured ${accountId}`; + accountsModel.insert(accountsModel.count, { + "number": accountId, + "title": title + }); + } + } + } |