From b8762ddb38dd975b0acb217b793594dfed83a824 Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 12 Sep 2020 14:10:13 +0300 Subject: Initial commit --- qml/AccountsPage.qml | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 qml/AccountsPage.qml (limited to 'qml/AccountsPage.qml') diff --git a/qml/AccountsPage.qml b/qml/AccountsPage.qml new file mode 100644 index 0000000..8bda7a7 --- /dev/null +++ b/qml/AccountsPage.qml @@ -0,0 +1,90 @@ +import QtQuick 2.14 +import QtQuick.Controls 2.14 +import QtQuick.Layouts 1.14 +import QtQuick.Dialogs 1.0 +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: accountsModel.addAccount() + } + + contextualActions: [ + Kirigami.Action { + text: "Import account" + iconName: "document-import" + onTriggered: importAccountDialog.open() + } + ] + + FileDialog { + id: importAccountDialog + title: "Import account" + onAccepted: { + var url = importAccountDialog.fileUrl.toString() + if (url.startsWith("file://")) { + var filename = url.substring(7); + console.log("Importing " + filename) + var accountId = accountsModel.importAccount (filename) + if (accountId == 0) { + console.log("Import failed") + } else { + console.log("Import succeeded") + } + } + } + } + + ListView { + id: accountsListView + anchors.fill: parent + model: accountsModel + + delegate: RowLayout { + width: accountsListView.width + + Label { + Layout.fillWidth: true + text: model.number + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + } + + Button { + width: 100 + palette.button: "light green" + text: "Select" + onClicked: { + while (pageStack.depth > 1) { + pageStack.pop() + } + accountsModel.selectedAccount = model.number + let context = accountsModel.getSelectedAccount() + if (context.isConfigured()) { + pageStack.push("qrc:/qml/ChatlistPage.qml", {context: context}) + } else { + pageStack.push("qrc:/qml/ConfigurePage.qml", {}) + } + } + } + + Button { + width: 100 + palette.button: "red" + text: "Delete" + onClicked: accountsModel.removeAccount(model.number) + } + } + } + + Menu { + id: contextMenu + MenuItem { text: "Import account" } + } +} -- cgit v1.2.3-54-g00ecf