aboutsummaryrefslogtreecommitdiff
path: root/qml/AccountsPage.qml
diff options
context:
space:
mode:
authorlink2xt <link2xt@testrun.org>2020-09-12 14:10:13 +0300
committerlink2xt <link2xt@testrun.org>2020-10-03 00:20:03 +0300
commitb8762ddb38dd975b0acb217b793594dfed83a824 (patch)
tree23ccefbba703fed6c07acce82ff72e32ba77c9ba /qml/AccountsPage.qml
downloadkdeltachat-b8762ddb38dd975b0acb217b793594dfed83a824.tar.gz
kdeltachat-b8762ddb38dd975b0acb217b793594dfed83a824.zip
Initial commit
Diffstat (limited to 'qml/AccountsPage.qml')
-rw-r--r--qml/AccountsPage.qml90
1 files changed, 90 insertions, 0 deletions
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" }
+ }
+}