aboutsummaryrefslogtreecommitdiff
path: root/qml/AccountsPage.qml
diff options
context:
space:
mode:
Diffstat (limited to 'qml/AccountsPage.qml')
-rw-r--r--qml/AccountsPage.qml116
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
+ });
+ }
+ }
+
}