summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-22 14:19:43 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-02-22 15:57:44 +0100
commitcb2b1a35e14031f15155243aee12fc862cb65ebf (patch)
treecc6a28ef675953d41b9eeb98b21325d9a7b030b4
parentb08e78c52a0b6a3c725ce58e0c3fb0bfcdf2bc55 (diff)
downloadkube-cb2b1a35e14031f15155243aee12fc862cb65ebf.tar.gz
kube-cb2b1a35e14031f15155243aee12fc862cb65ebf.zip
Fixed kolabnow account setup page.
The account plugin supplies the configuration UI, the application supplies the scaffolding. That way we ensure the application doens't contain any account specific code and account configurations are free to offer specialized UI's that work best for them. We're not currently using a standardized controller, but if we did those controllers would have to live with the plugin, not the framework or the components.
-rw-r--r--accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml122
-rw-r--r--components/accounts/contents/ui/AccountWizard.qml76
-rw-r--r--components/accounts/contents/ui/AccountWizardPage.qml144
-rw-r--r--components/package/contents/ui/AccountSwitcher.qml20
-rw-r--r--components/package/contents/ui/EditAccount.qml138
-rw-r--r--components/package/contents/ui/EditAccountDialog.qml20
-rw-r--r--framework/accounts/accountfactory.cpp6
-rw-r--r--framework/accounts/accountfactory.h4
-rw-r--r--framework/domain/settings/accountsettings.cpp48
-rw-r--r--framework/domain/settings/accountsettings.h5
10 files changed, 401 insertions, 182 deletions
diff --git a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml
index 753762b7..46d197fa 100644
--- a/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml
+++ b/accounts/kolabnow/package/contents/ui/KolabnowAccountSettings.qml
@@ -1,5 +1,6 @@
1/* 1/*
2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net> 2 Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
3 4
4 This program is free software; you can redistribute it and/or modify 5 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by 6 it under the terms of the GNU General Public License as published by
@@ -17,7 +18,7 @@
17*/ 18*/
18 19
19import QtQuick 2.4 20import QtQuick 2.4
20import QtQuick.Controls 1.4 21import QtQuick.Controls 1.4 as Controls
21import QtQuick.Layouts 1.1 22import QtQuick.Layouts 1.1
22 23
23import org.kde.kirigami 1.0 as Kirigami 24import org.kde.kirigami 1.0 as Kirigami
@@ -25,127 +26,108 @@ import org.kde.kirigami 1.0 as Kirigami
25import org.kube.framework.settings 1.0 as KubeSettings 26import org.kube.framework.settings 1.0 as KubeSettings
26import org.kube.accounts.kolabnow 1.0 as KolabnowAccount 27import org.kube.accounts.kolabnow 1.0 as KolabnowAccount
27 28
28
29Item { 29Item {
30 30
31 property string accountId 31 property string accountId
32 property string heading: "Connect your KolabNOW account"
33 property string subheadline: "To let Kube access your account, fill in email address, username, password and give the account a title that will be displayed inside Kube."
32 34
33 KolabnowAccount.KolabnowSettings { 35 KolabnowAccount.KolabnowSettings {
34 id: kolabnowSettings 36 id: kolabnowSettings
35 accountIdentifier: accountId 37 accountIdentifier: accountId
38 accountType: "kolabnow"
39 }
40
41 function save(){
42 kolabnowSettings.save()
36 } 43 }
37 44
38 anchors.fill: parent 45 function remove(){
46 kolabnowSettings.remove()
47 }
39 48
40 Item { 49 Item {
41 anchors { 50 anchors {
42 fill: parent 51 fill: parent
43 margins: Kirigami.Units.largeSpacing * 2
44 }
45
46 Kirigami.Heading {
47 id: heading
48 text: "Connect your KOLABNOW account"
49
50 color: Kirigami.Theme.highlightColor
51 }
52
53 Label {
54 id: subHeadline
55
56 anchors {
57 left: heading.left
58 top: heading.bottom
59 }
60
61 width: parent.width
62
63 text: "To let Kube access your KOLABNOW account, fill in email address and password and give the account a title that will be displayed inside Kube."
64 //TODO wait for kirgami theme disabled text color
65 opacity: 0.5
66 wrapMode: Text.Wrap
67 } 52 }
68 53
69
70 GridLayout { 54 GridLayout {
71 anchors { 55 anchors {
72 top:subHeadline.bottom 56 fill: parent
73 bottom: parent.bottom
74 left: parent.left
75 right: parent.right
76 topMargin: Kirigami.Units.largeSpacing
77 bottomMargin: Kirigami.Units.largeSpacing * 2
78 } 57 }
79
80 columns: 2 58 columns: 2
81 columnSpacing: Kirigami.Units.largeSpacing 59 columnSpacing: Kirigami.Units.largeSpacing
82 rowSpacing: Kirigami.Units.largeSpacing 60 rowSpacing: Kirigami.Units.largeSpacing
83 61
84 Kirigami.Label { 62 Controls.Label {
85 text: "Title of Account" 63 text: "Title of Account"
86 Layout.alignment: Qt.AlignRight 64 Layout.alignment: Qt.AlignRight
87 } 65 }
88 TextField { 66 Controls.TextField {
89 Layout.fillWidth: true 67 Layout.fillWidth: true
90 68 placeholderText: "E.g. \"Work\", \"Home\" that will be displayed in Kube as name"
91 text: kolabnowSettings.accountName 69 text: kolabnowSettings.accountName
92 placeholderText: "KOLABNOW"
93 onTextChanged: { 70 onTextChanged: {
94 kolabnowSettings.accountName = text 71 kolabnowSettings.accountName = text
95 } 72 }
96 } 73 }
97 74
98 Kirigami.Label { 75 Controls.Label {
99 text: "Email address" 76 text: "Name"
100 Layout.alignment: Qt.AlignRight 77 Layout.alignment: Qt.AlignRight
101 } 78 }
102 TextField { 79 Controls.TextField {
103 Layout.fillWidth: true 80 Layout.fillWidth: true
104 81 placeholderText: "Your name"
105 text: kolabnowSettings.emailAddress 82 text: kolabnowSettings.userName
106 onTextChanged: { 83 onTextChanged: {
107 kolabnowSettings.emailAddress = text 84 kolabnowSettings.userName = text
108 } 85 }
109 } 86 }
110 87
111 Kirigami.Label { 88 Controls.Label {
112 text: "Password" 89 text: "Email address"
113 Layout.alignment: Qt.AlignRight 90 Layout.alignment: Qt.AlignRight
114 } 91 }
115 TextField { 92 Controls.TextField {
116 Layout.fillWidth: true 93 Layout.fillWidth: true
117 94
118 text: kolabnowSettings.imapPassword 95 text: kolabnowSettings.emailAddress
119 onTextChanged: { 96 onTextChanged: {
120 kolabnowSettings.imapPassword = text 97 kolabnowSettings.emailAddress = text
121 kolabnowSettings.smtpPassword = text
122 } 98 }
99 placeholderText: "Your email address"
123 } 100 }
124 101
125 Label { 102 Controls.Label {
126 text: "" 103 text: "Password"
104 Layout.alignment: Qt.AlignRight
127 } 105 }
128 Item { 106 RowLayout {
129 Layout.fillWidth: true 107 Layout.fillWidth: true
130 108
131 Button { 109 Controls.TextField {
132 text: "Delete" 110 id: pwField
111 Layout.fillWidth: true
133 112
134 onClicked: { 113 placeholderText: "Password of your email account"
135 kolabnowSettings.remove() 114 text: kolabnowSettings.imapPassword
136 root.closeDialog() 115 onTextChanged: {
116 kolabnowSettings.imapPassword = text
117 kolabnowSettings.smtpPassword = text
137 } 118 }
138 }
139 119
140 Button { 120 echoMode: TextInput.Password
141 anchors.right: parent.right 121 }
142
143 text: "Save"
144 122
123 Controls.CheckBox {
124 text: "Show Password"
145 onClicked: { 125 onClicked: {
146 focus: true 126 if(pwField.echoMode == TextInput.Password) {
147 kolabnowSettings.save() 127 pwField.echoMode = TextInput.Normal;
148 root.closeDialog() 128 } else {
129 pwField.echoMode = TextInput.Password;
130 }
149 } 131 }
150 } 132 }
151 } 133 }
diff --git a/components/accounts/contents/ui/AccountWizard.qml b/components/accounts/contents/ui/AccountWizard.qml
index 8cc90acb..ffc3f5da 100644
--- a/components/accounts/contents/ui/AccountWizard.qml
+++ b/components/accounts/contents/ui/AccountWizard.qml
@@ -51,47 +51,15 @@ Controls2.Popup {
51 51
52 spacing: Kirigami.Units.largeSpacing 52 spacing: Kirigami.Units.largeSpacing
53 53
54 Controls2.Button { 54 Repeater {
55 55 //TODO replace by model of available accounts
56 Layout.fillWidth: true 56 model: ["kolabnow", "imap", "maildir"]
57 57 delegate: Controls2.Button {
58 text: "kolabnow account" 58 Layout.fillWidth: true
59 59 text: modelData +" account"
60 onClicked: { 60 onClicked: {
61 stack.push(kolabnow) 61 stack.push(wizardPage.createObject(app, {accountType:modelData}))
62 } 62 }
63 }
64
65 Controls2.Button {
66
67 Layout.fillWidth: true
68
69 text: "gmail account"
70
71 onClicked: {
72 stack.push(gmail)
73 }
74 }
75
76 Controls2.Button {
77
78 Layout.fillWidth: true
79
80 text: "imap account"
81
82 onClicked: {
83 stack.push(imap)
84 }
85 }
86
87 Controls2.Button {
88
89 Layout.fillWidth: true
90
91 text: "maildir archive"
92
93 onClicked: {
94 stack.push(maildir)
95 } 63 }
96 } 64 }
97 } 65 }
@@ -99,30 +67,8 @@ Controls2.Popup {
99 } 67 }
100 68
101 Component { 69 Component {
102 id: kolabnow 70 id: wizardPage
103 71 AccountWizardPage {
104 CreateKolabNow {
105 }
106 }
107
108 Component {
109 id: gmail
110
111 CreateGmail {
112 }
113 }
114
115 Component {
116 id: imap
117
118 CreateImap {
119 }
120 }
121
122 Component {
123 id: maildir
124
125 CreateMaildir {
126 } 72 }
127 } 73 }
128} 74}
diff --git a/components/accounts/contents/ui/AccountWizardPage.qml b/components/accounts/contents/ui/AccountWizardPage.qml
new file mode 100644
index 00000000..967bd4ab
--- /dev/null
+++ b/components/accounts/contents/ui/AccountWizardPage.qml
@@ -0,0 +1,144 @@
1/*
2 * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick 2.7
21import QtQuick.Layouts 1.1
22import QtQuick.Controls 1.4 as Controls
23import QtQuick.Controls 2.0 as Controls2
24import org.kde.kirigami 1.0 as Kirigami
25
26import org.kube.framework.accounts 1.0 as KubeAccounts
27
28Item {
29 id: root
30 property string accountType
31
32 KubeAccounts.AccountFactory {
33 id: accountFactory
34 accountType: root.accountType
35 }
36
37 Controls.ToolButton {
38 iconName: "go-previous"
39 tooltip: "go back"
40 onClicked: {
41 stack.pop()
42 }
43 }
44
45 //Item to avoid anchors conflict with stack
46 Item {
47
48 anchors {
49 fill: parent
50 margins: Kirigami.Units.largeSpacing * 2
51 }
52
53 Kirigami.Heading {
54 id: heading
55 text: loader.item.heading
56 color: Kirigami.Theme.highlightColor
57 }
58
59 Kirigami.Label {
60 id: subHeadline
61
62 anchors {
63 left: heading.left
64 top: heading.bottom
65 }
66
67 width: parent.width
68 text: loader.item.subheadline
69 color: Kirigami.Theme.disabledTextColor
70 wrapMode: Text.Wrap
71 }
72
73 Item {
74 id: accountEdit
75 anchors {
76 top:subHeadline.bottom
77 left: parent.left
78 right: parent.right
79 topMargin: Kirigami.Units.largeSpacing * 2
80 }
81
82 Loader {
83 id: loader
84 anchors.fill: parent
85 source: accountFactory.uiPath
86 }
87 }
88
89 Item {
90 id: spacer
91 Layout.fillHeight: true
92 anchors {
93 top:accountEdit.bottom
94 bottom: footer.top
95 left: parent.left
96 right: parent.right
97 }
98 }
99
100 //This is where we should place the account wizard ui
101 GridLayout {
102 id: footer
103 anchors {
104 bottom: parent.bottom
105 left: parent.left
106 right: parent.right
107 topMargin: Kirigami.Units.largeSpacing * 2
108 }
109
110 columns: 2
111 columnSpacing: Kirigami.Units.largeSpacing
112 rowSpacing: Kirigami.Units.largeSpacing
113
114 Item {
115 Layout.fillHeight: true
116 }
117
118 Kirigami.Label {
119 text: ""
120 }
121
122 Item {
123 Layout.fillWidth: true
124
125 Controls.Button {
126 text: "Discard"
127
128 onClicked: {
129 popup.close()
130 }
131 }
132
133 Controls.Button {
134 anchors.right: parent.right
135 text: "Save"
136 onClicked: {
137 loader.item.save()
138 popup.close()
139 }
140 }
141 }
142 }
143 }
144}
diff --git a/components/package/contents/ui/AccountSwitcher.qml b/components/package/contents/ui/AccountSwitcher.qml
index eb5702e0..48bb2c1b 100644
--- a/components/package/contents/ui/AccountSwitcher.qml
+++ b/components/package/contents/ui/AccountSwitcher.qml
@@ -72,14 +72,11 @@ Controls.ToolButton {
72 width: parent.width 72 width: parent.width
73 73
74 Controls2.Button { 74 Controls2.Button {
75
76
77 anchors { 75 anchors {
78 left: parent.left 76 left: parent.left
79 bottom: parent.bottom 77 bottom: parent.bottom
80 } 78 }
81 79
82
83 //iconName: "view-refresh" 80 //iconName: "view-refresh"
84 text: "Sync" 81 text: "Sync"
85 enabled: folderController.synchronizeAction.enabled 82 enabled: folderController.synchronizeAction.enabled
@@ -160,15 +157,6 @@ Controls.ToolButton {
160 157
161 Layout.fillHeight: true 158 Layout.fillHeight: true
162 159
163 KubeAccounts.AccountFactory {
164 id: accountFactory
165 accountId: model.accountId
166 }
167
168 // Kirigami.Icon {
169 // source: model.icon
170 // }
171
172 Controls2.Label { 160 Controls2.Label {
173 text: model.name 161 text: model.name
174 } 162 }
@@ -191,20 +179,14 @@ Controls.ToolButton {
191 text: "edit" 179 text: "edit"
192 180
193 onClicked: { 181 onClicked: {
194 editAccountComponent.createObject(app) 182 editAccountComponent.createObject(app, {accountId:model.accountId})
195 popup.close() 183 popup.close()
196 } 184 }
197 185
198 Component { 186 Component {
199 id: editAccountComponent 187 id: editAccountComponent
200
201 KubeComponents.EditAccountDialog { 188 KubeComponents.EditAccountDialog {
202 id: editAccount
203
204 anchors.fill: parent 189 anchors.fill: parent
205
206 accountId: accountFactory.accountId
207 uiSource: accountFactory.uiPath
208 } 190 }
209 } 191 }
210 } 192 }
diff --git a/components/package/contents/ui/EditAccount.qml b/components/package/contents/ui/EditAccount.qml
new file mode 100644
index 00000000..e3e049fa
--- /dev/null
+++ b/components/package/contents/ui/EditAccount.qml
@@ -0,0 +1,138 @@
1/*
2 * Copyright (C) 2016 Michael Bohlender, <michael.bohlender@kdemail.net>
3 * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20import QtQuick 2.7
21import QtQuick.Layouts 1.1
22import QtQuick.Controls 1.4 as Controls
23import QtQuick.Controls 2.0 as Controls2
24import org.kde.kirigami 1.0 as Kirigami
25
26import org.kube.framework.accounts 1.0 as KubeAccounts
27
28Item {
29 id: root
30 property string accountId
31
32 KubeAccounts.AccountFactory {
33 id: accountFactory
34 accountId: root.accountId
35 }
36
37 Item {
38
39 anchors {
40 fill: parent
41 margins: Kirigami.Units.largeSpacing * 2
42 }
43
44 Kirigami.Heading {
45 id: heading
46 text: loader.item.heading
47 color: Kirigami.Theme.highlightColor
48 }
49
50 Kirigami.Label {
51 id: subHeadline
52
53 anchors {
54 left: heading.left
55 top: heading.bottom
56 }
57
58 width: parent.width
59 text: loader.item.subheadline
60 color: Kirigami.Theme.disabledTextColor
61 wrapMode: Text.Wrap
62 }
63
64 Item {
65 id: accountEdit
66 anchors {
67 top:subHeadline.bottom
68 bottom: spacer.top
69 left: parent.left
70 right: parent.right
71 topMargin: Kirigami.Units.largeSpacing * 2
72 }
73
74 Loader {
75 id: loader
76 anchors.fill: parent
77 source: accountFactory.uiPath
78 onLoaded: item.accountId = root.accountId
79 }
80 }
81
82 Item {
83 id: spacer
84 Layout.fillHeight: true
85 anchors {
86 top:accountEdit.bottom
87 bottom: footer.top
88 left: parent.left
89 right: parent.right
90 }
91 }
92
93 //This is where we should place the account wizard ui
94 GridLayout {
95 id: footer
96 anchors {
97 top:spacer.bottom
98 bottom: parent.bottom
99 left: parent.left
100 right: parent.right
101 topMargin: Kirigami.Units.largeSpacing * 2
102 }
103
104 columns: 2
105 columnSpacing: Kirigami.Units.largeSpacing
106 rowSpacing: Kirigami.Units.largeSpacing
107
108 Item {
109 Layout.fillHeight: true
110 }
111
112 Kirigami.Label {
113 text: ""
114 }
115
116 Item {
117 Layout.fillWidth: true
118
119 Controls.Button {
120 text: "Discard"
121
122 onClicked: {
123 dialog.closeDialog()
124 }
125 }
126
127 Controls.Button {
128 anchors.right: parent.right
129 text: "Save"
130 onClicked: {
131 loader.item.save()
132 dialog.closeDialog()
133 }
134 }
135 }
136 }
137 }
138}
diff --git a/components/package/contents/ui/EditAccountDialog.qml b/components/package/contents/ui/EditAccountDialog.qml
index 19349f38..a7461640 100644
--- a/components/package/contents/ui/EditAccountDialog.qml
+++ b/components/package/contents/ui/EditAccountDialog.qml
@@ -21,28 +21,18 @@ import QtQuick.Layouts 1.1
21 21
22import org.kde.kirigami 1.0 as Kirigami 22import org.kde.kirigami 1.0 as Kirigami
23 23
24import org.kube.framework.settings 1.0 as KubeSettings
25import org.kube.framework.domain 1.0 as KubeFramework
26import org.kube.components 1.0 as KubeComponents 24import org.kube.components 1.0 as KubeComponents
27 25
28KubeComponents.OverlayDialog { 26KubeComponents.OverlayDialog {
29 id: root 27 id: dialog
30 28
31 property variant uiSource
32 property variant accountId 29 property variant accountId
30 EditAccount {
31 accountId: dialog.accountId
33 32
34 Item {
35 id: dialog
36 anchors.centerIn: parent 33 anchors.centerIn: parent
37 34
38 height: root.height * 0.8 35 height: dialog.height * 0.8
39 width: root.width * 0.8 36 width: dialog.width * 0.8
40
41 Loader {
42 anchors.fill: parent
43
44 source: root.uiSource
45 onLoaded: item.accountId = root.accountId
46 }
47 } 37 }
48} 38}
diff --git a/framework/accounts/accountfactory.cpp b/framework/accounts/accountfactory.cpp
index c590e4b6..9dbb402b 100644
--- a/framework/accounts/accountfactory.cpp
+++ b/framework/accounts/accountfactory.cpp
@@ -50,6 +50,12 @@ void AccountFactory::setAccountId(const QString &accountId)
50 }).exec(); 50 }).exec();
51} 51}
52 52
53void AccountFactory::setAccountType(const QString &type)
54{
55 mAccountType = type.toLatin1();
56 loadPackage();
57}
58
53void AccountFactory::loadPackage() 59void AccountFactory::loadPackage()
54{ 60{
55 auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.accounts." + mAccountType); 61 auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.accounts." + mAccountType);
diff --git a/framework/accounts/accountfactory.h b/framework/accounts/accountfactory.h
index 047454ae..b57854e5 100644
--- a/framework/accounts/accountfactory.h
+++ b/framework/accounts/accountfactory.h
@@ -23,12 +23,13 @@
23#include <QVariant> 23#include <QVariant>
24 24
25/** 25/**
26 * A factory to instantiate accountp plugins. 26 * A factory to instantiate account-plugins.
27 */ 27 */
28class AccountFactory : public QObject 28class AccountFactory : public QObject
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31 Q_PROPERTY(QString accountId MEMBER mAccountId WRITE setAccountId); 31 Q_PROPERTY(QString accountId MEMBER mAccountId WRITE setAccountId);
32 Q_PROPERTY(QString accountType MEMBER mAccountType WRITE setAccountType);
32 Q_PROPERTY(QString name MEMBER mName READ name NOTIFY accountLoaded); 33 Q_PROPERTY(QString name MEMBER mName READ name NOTIFY accountLoaded);
33 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded); 34 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY accountLoaded);
34 Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded); 35 Q_PROPERTY(QString uiPath MEMBER mUiPath NOTIFY accountLoaded);
@@ -36,6 +37,7 @@ public:
36 explicit AccountFactory(QObject *parent = Q_NULLPTR); 37 explicit AccountFactory(QObject *parent = Q_NULLPTR);
37 38
38 void setAccountId(const QString &); 39 void setAccountId(const QString &);
40 void setAccountType(const QString &);
39 QString name() const; 41 QString name() const;
40 42
41signals: 43signals:
diff --git a/framework/domain/settings/accountsettings.cpp b/framework/domain/settings/accountsettings.cpp
index d7c8c1c0..16791a7f 100644
--- a/framework/domain/settings/accountsettings.cpp
+++ b/framework/domain/settings/accountsettings.cpp
@@ -34,6 +34,15 @@ AccountSettings::AccountSettings(QObject *parent)
34{ 34{
35} 35}
36 36
37void AccountSettings::setAccountType(const QByteArray &type)
38{
39 mAccountType = type;
40}
41
42QByteArray AccountSettings::accountType() const
43{
44 return mAccountType;
45}
37 46
38void AccountSettings::setAccountIdentifier(const QByteArray &id) 47void AccountSettings::setAccountIdentifier(const QByteArray &id)
39{ 48{
@@ -134,18 +143,32 @@ QValidator *AccountSettings::smtpServerValidator() const
134 143
135void AccountSettings::saveAccount() 144void AccountSettings::saveAccount()
136{ 145{
137 qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier; 146 if (mAccountIdentifier.isEmpty()) {
138 Q_ASSERT(!mAccountIdentifier.isEmpty()); 147 auto account = ApplicationDomainType::createEntity<SinkAccount>();
139 SinkAccount account(mAccountIdentifier); 148 mAccountIdentifier = account.identifier();
140 account.setAccountType("imap"); 149 Q_ASSERT(!mAccountType.isEmpty());
141 account.setName(mName); 150 account.setAccountType(mAccountType);
142 account.setIcon(mIcon); 151 account.setName(mName);
143 Q_ASSERT(!account.identifier().isEmpty()); 152 account.setIcon(mIcon);
144 Store::modify(account) 153 Store::create(account)
145 .onError([](const KAsync::Error &error) { 154 .onError([](const KAsync::Error &error) {
146 qWarning() << "Error while creating account: " << error.errorMessage;; 155 qWarning() << "Error while creating account: " << error.errorMessage;;
147 }) 156 })
148 .exec(); 157 .exec();
158 } else {
159 qDebug() << "Saving account " << mAccountIdentifier << mMailtransportIdentifier;
160 Q_ASSERT(!mAccountIdentifier.isEmpty());
161 SinkAccount account(mAccountIdentifier);
162 account.setAccountType(mAccountType);
163 account.setName(mName);
164 account.setIcon(mIcon);
165 Q_ASSERT(!account.identifier().isEmpty());
166 Store::modify(account)
167 .onError([](const KAsync::Error &error) {
168 qWarning() << "Error while creating account: " << error.errorMessage;;
169 })
170 .exec();
171 }
149} 172}
150 173
151void AccountSettings::loadAccount() 174void AccountSettings::loadAccount()
@@ -153,6 +176,7 @@ void AccountSettings::loadAccount()
153 Q_ASSERT(!mAccountIdentifier.isEmpty()); 176 Q_ASSERT(!mAccountIdentifier.isEmpty());
154 Store::fetchOne<SinkAccount>(Query().filter(mAccountIdentifier)) 177 Store::fetchOne<SinkAccount>(Query().filter(mAccountIdentifier))
155 .then([this](const SinkAccount &account) { 178 .then([this](const SinkAccount &account) {
179 mAccountType = account.getAccountType().toLatin1();
156 mIcon = account.getIcon(); 180 mIcon = account.getIcon();
157 mName = account.getName(); 181 mName = account.getName();
158 emit changed(); 182 emit changed();
diff --git a/framework/domain/settings/accountsettings.h b/framework/domain/settings/accountsettings.h
index 08215a32..f0cecf9b 100644
--- a/framework/domain/settings/accountsettings.h
+++ b/framework/domain/settings/accountsettings.h
@@ -25,6 +25,7 @@ class AccountSettings : public QObject
25{ 25{
26 Q_OBJECT 26 Q_OBJECT
27 Q_PROPERTY(QByteArray accountIdentifier READ accountIdentifier WRITE setAccountIdentifier) 27 Q_PROPERTY(QByteArray accountIdentifier READ accountIdentifier WRITE setAccountIdentifier)
28 Q_PROPERTY(QByteArray accountType READ accountType WRITE setAccountType)
28 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY changed) 29 Q_PROPERTY(QString icon MEMBER mIcon NOTIFY changed)
29 Q_PROPERTY(QString accountName MEMBER mName NOTIFY changed) 30 Q_PROPERTY(QString accountName MEMBER mName NOTIFY changed)
30 31
@@ -50,6 +51,9 @@ public:
50 void setAccountIdentifier(const QByteArray &); 51 void setAccountIdentifier(const QByteArray &);
51 QByteArray accountIdentifier() const; 52 QByteArray accountIdentifier() const;
52 53
54 void setAccountType(const QByteArray &);
55 QByteArray accountType() const;
56
53 void setPath(const QUrl &); 57 void setPath(const QUrl &);
54 QUrl path() const; 58 QUrl path() const;
55 59
@@ -87,6 +91,7 @@ protected:
87 void removeIdentity(); 91 void removeIdentity();
88 92
89 QByteArray mAccountIdentifier; 93 QByteArray mAccountIdentifier;
94 QByteArray mAccountType;
90 QString mIcon; 95 QString mIcon;
91 QString mName; 96 QString mName;
92 97