diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-22 14:19:43 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-02-22 15:57:44 +0100 |
commit | cb2b1a35e14031f15155243aee12fc862cb65ebf (patch) | |
tree | cc6a28ef675953d41b9eeb98b21325d9a7b030b4 /framework | |
parent | b08e78c52a0b6a3c725ce58e0c3fb0bfcdf2bc55 (diff) | |
download | kube-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.
Diffstat (limited to 'framework')
-rw-r--r-- | framework/accounts/accountfactory.cpp | 6 | ||||
-rw-r--r-- | framework/accounts/accountfactory.h | 4 | ||||
-rw-r--r-- | framework/domain/settings/accountsettings.cpp | 48 | ||||
-rw-r--r-- | framework/domain/settings/accountsettings.h | 5 |
4 files changed, 50 insertions, 13 deletions
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 | ||
53 | void AccountFactory::setAccountType(const QString &type) | ||
54 | { | ||
55 | mAccountType = type.toLatin1(); | ||
56 | loadPackage(); | ||
57 | } | ||
58 | |||
53 | void AccountFactory::loadPackage() | 59 | void 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 | */ |
28 | class AccountFactory : public QObject | 28 | class 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 | ||
41 | signals: | 43 | signals: |
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 | ||
37 | void AccountSettings::setAccountType(const QByteArray &type) | ||
38 | { | ||
39 | mAccountType = type; | ||
40 | } | ||
41 | |||
42 | QByteArray AccountSettings::accountType() const | ||
43 | { | ||
44 | return mAccountType; | ||
45 | } | ||
37 | 46 | ||
38 | void AccountSettings::setAccountIdentifier(const QByteArray &id) | 47 | void AccountSettings::setAccountIdentifier(const QByteArray &id) |
39 | { | 48 | { |
@@ -134,18 +143,32 @@ QValidator *AccountSettings::smtpServerValidator() const | |||
134 | 143 | ||
135 | void AccountSettings::saveAccount() | 144 | void 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 | ||
151 | void AccountSettings::loadAccount() | 174 | void 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 | ||