diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 22:30:07 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-03-03 22:30:07 +0100 |
commit | fd31aa9b05ea215e8071cf76fe21ec746204f3a3 (patch) | |
tree | fd656cf389060e6a5c7ef3253d3337e0a48864c8 | |
parent | 54c3e5912b0d64bad5a1c66bc96f0552ac5e21f5 (diff) | |
download | kube-fd31aa9b05ea215e8071cf76fe21ec746204f3a3.tar.gz kube-fd31aa9b05ea215e8071cf76fe21ec746204f3a3.zip |
Added a maildir configuration controller that can edit the config in
sink.
The property binding only works when using actual QObject::property'ies.
It doesn't work at all with Q_PROPERTY, even with a NOTIFY signal.
-rw-r--r-- | accounts/maildir/CMakeLists.txt | 15 | ||||
-rw-r--r-- | accounts/maildir/maildiraccountplugin.cpp | 11 | ||||
-rw-r--r-- | accounts/maildir/maildiraccountplugin.h | 13 | ||||
-rw-r--r-- | accounts/maildir/maildirsettings.cpp | 55 | ||||
-rw-r--r-- | accounts/maildir/maildirsettings.h | 38 | ||||
-rw-r--r-- | accounts/maildir/package/contents/ui/MaildirAccountSettings.qml | 40 | ||||
-rw-r--r-- | accounts/maildir/qmldir | 2 | ||||
-rw-r--r-- | applications/kube-mail/package/contents/ui/Settings.qml | 7 |
8 files changed, 162 insertions, 19 deletions
diff --git a/accounts/maildir/CMakeLists.txt b/accounts/maildir/CMakeLists.txt index 7e9894b1..d83ae0be 100644 --- a/accounts/maildir/CMakeLists.txt +++ b/accounts/maildir/CMakeLists.txt | |||
@@ -20,8 +20,21 @@ include(KDECompilerSettings) | |||
20 | find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui) | 20 | find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui) |
21 | 21 | ||
22 | set (QT_MIN_VERSION "5.4.0") | 22 | set (QT_MIN_VERSION "5.4.0") |
23 | find_package(KF5 REQUIRED COMPONENTS Package) | 23 | find_package(Sink CONFIG REQUIRED) |
24 | find_package(KF5Async CONFIG REQUIRED) | ||
24 | 25 | ||
26 | include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/) | ||
27 | |||
28 | set(SRCS | ||
29 | maildirsettings.cpp | ||
30 | maildiraccountplugin.cpp | ||
31 | ) | ||
32 | |||
33 | add_library(maildiraccountplugin SHARED ${SRCS}) | ||
34 | qt5_use_modules(maildiraccountplugin Core Quick Qml) | ||
35 | target_link_libraries(maildiraccountplugin sink) | ||
36 | |||
37 | install(TARGETS maildiraccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir) | ||
25 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir) | 38 | install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir) |
26 | install(FILES package/contents/ui/MaildirAccountSettings.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir) | 39 | install(FILES package/contents/ui/MaildirAccountSettings.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir) |
27 | 40 | ||
diff --git a/accounts/maildir/maildiraccountplugin.cpp b/accounts/maildir/maildiraccountplugin.cpp new file mode 100644 index 00000000..0033613b --- /dev/null +++ b/accounts/maildir/maildiraccountplugin.cpp | |||
@@ -0,0 +1,11 @@ | |||
1 | #include "maildiraccountplugin.h" | ||
2 | |||
3 | #include "maildirsettings.h" | ||
4 | |||
5 | #include <QtQml> | ||
6 | |||
7 | void MaildirAccountPlugin::registerTypes (const char *uri) | ||
8 | { | ||
9 | Q_ASSERT(uri == QLatin1String("org.kde.kube.accounts.maildir")); | ||
10 | qmlRegisterType<MaildirSettings>(uri, 1, 0, "MaildirSettings"); | ||
11 | } | ||
diff --git a/accounts/maildir/maildiraccountplugin.h b/accounts/maildir/maildiraccountplugin.h new file mode 100644 index 00000000..aad73dd6 --- /dev/null +++ b/accounts/maildir/maildiraccountplugin.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #pragma once | ||
2 | |||
3 | #include <QQmlEngine> | ||
4 | #include <QQmlExtensionPlugin> | ||
5 | |||
6 | class MaildirAccountPlugin : public QQmlExtensionPlugin | ||
7 | { | ||
8 | Q_OBJECT | ||
9 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
10 | |||
11 | public: | ||
12 | virtual void registerTypes(const char *uri); | ||
13 | }; | ||
diff --git a/accounts/maildir/maildirsettings.cpp b/accounts/maildir/maildirsettings.cpp new file mode 100644 index 00000000..4a3b1a00 --- /dev/null +++ b/accounts/maildir/maildirsettings.cpp | |||
@@ -0,0 +1,55 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #include "maildirsettings.h" | ||
20 | |||
21 | #include <sink/store.h> | ||
22 | #include <QDebug> | ||
23 | |||
24 | MaildirSettings::MaildirSettings(QObject *parent) | ||
25 | : QObject(parent) | ||
26 | { | ||
27 | } | ||
28 | |||
29 | void MaildirSettings::setIdentifier(const QByteArray &id) | ||
30 | { | ||
31 | mIdentifier = id; | ||
32 | Sink::Store::fetchOne<Sink::ApplicationDomain::SinkResource>(Sink::Query::IdentityFilter(mIdentifier) + Sink::Query::RequestedProperties(QList<QByteArray>() << "path")) | ||
33 | .then<void, Sink::ApplicationDomain::SinkResource>([this](const Sink::ApplicationDomain::SinkResource &resource) { | ||
34 | setProperty("path", resource.getProperty("path")); | ||
35 | }).exec(); | ||
36 | } | ||
37 | |||
38 | QByteArray MaildirSettings::identifier() const | ||
39 | { | ||
40 | return mIdentifier; | ||
41 | } | ||
42 | |||
43 | void MaildirSettings::save() | ||
44 | { | ||
45 | if (!mIdentifier.isEmpty()) { | ||
46 | Sink::ApplicationDomain::SinkResource resource(mIdentifier); | ||
47 | resource.setProperty("path", property("path")); | ||
48 | Sink::Store::modify(resource).exec(); | ||
49 | } else { | ||
50 | Sink::ApplicationDomain::SinkResource resource; | ||
51 | resource.setProperty("path", property("path")); | ||
52 | Sink::Store::create(resource).exec(); | ||
53 | } | ||
54 | } | ||
55 | |||
diff --git a/accounts/maildir/maildirsettings.h b/accounts/maildir/maildirsettings.h new file mode 100644 index 00000000..c0ad95c3 --- /dev/null +++ b/accounts/maildir/maildirsettings.h | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsys.com> | ||
3 | |||
4 | This library is free software; you can redistribute it and/or modify it | ||
5 | under the terms of the GNU Library General Public License as published by | ||
6 | the Free Software Foundation; either version 2 of the License, or (at your | ||
7 | option) any later version. | ||
8 | |||
9 | This library is distributed in the hope that it will be useful, but WITHOUT | ||
10 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public | ||
12 | License for more details. | ||
13 | |||
14 | You should have received a copy of the GNU Library General Public License | ||
15 | along with this library; see the file COPYING.LIB. If not, write to the | ||
16 | Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
17 | 02110-1301, USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include <QObject> | ||
22 | |||
23 | class MaildirSettings : public QObject | ||
24 | { | ||
25 | Q_OBJECT | ||
26 | Q_PROPERTY(QByteArray identifier READ identifier WRITE setIdentifier) | ||
27 | |||
28 | public: | ||
29 | MaildirSettings(QObject *parent = 0); | ||
30 | |||
31 | void setIdentifier(const QByteArray &); | ||
32 | QByteArray identifier() const; | ||
33 | |||
34 | Q_INVOKABLE void save(); | ||
35 | |||
36 | private: | ||
37 | QByteArray mIdentifier; | ||
38 | }; | ||
diff --git a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml index 5ba9f0c1..77cf739f 100644 --- a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml +++ b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml | |||
@@ -20,12 +20,12 @@ import QtQuick.Controls 1.4 | |||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 |
21 | 21 | ||
22 | import org.kde.kube.settings 1.0 as KubeSettings | 22 | import org.kde.kube.settings 1.0 as KubeSettings |
23 | // import org.kde.kube.accounts.maildir 1.0 as MaildirAccount | 23 | import org.kde.kube.accounts.maildir 1.0 as MaildirAccount |
24 | 24 | ||
25 | Rectangle { | 25 | Rectangle { |
26 | id: root | 26 | id: root |
27 | property string accountId | 27 | property string accountId |
28 | property string accountName | 28 | property string accountName: "Maildir" |
29 | 29 | ||
30 | color: colorPalette.background | 30 | color: colorPalette.background |
31 | 31 | ||
@@ -40,35 +40,45 @@ Rectangle { | |||
40 | text: "Account: " + accountName | 40 | text: "Account: " + accountName |
41 | } | 41 | } |
42 | 42 | ||
43 | Label { text: "Path" } | ||
44 | TextField { | ||
45 | id: path | ||
46 | placeholderText: "path" | ||
47 | Layout.fillWidth: true | ||
48 | } | ||
49 | |||
50 | Text { | ||
51 | Layout.columnSpan: 2 | ||
52 | Layout.fillWidth: true | ||
53 | text: "Smtp:" | ||
54 | } | ||
55 | |||
43 | Label { text: "Username" } | 56 | Label { text: "Username" } |
44 | TextField { | 57 | TextField { |
45 | id: username | 58 | id: username |
46 | text: "username" | 59 | placeholderText: "username" |
47 | Layout.fillWidth: true | 60 | Layout.fillWidth: true |
48 | } | 61 | } |
49 | 62 | ||
50 | Label { text: "Password" } | 63 | Label { text: "Password" } |
51 | TextField { | 64 | TextField { |
52 | id: password | 65 | id: password |
53 | text: "password" | 66 | placeholderText: "password" |
54 | Layout.fillWidth: true | 67 | Layout.fillWidth: true |
55 | } | 68 | } |
56 | 69 | ||
57 | Label { text: "Server" } | 70 | Label { text: "Server" } |
58 | TextField { | 71 | TextField { |
59 | id: server | 72 | id: server |
60 | text: "server" | 73 | placeholderText: "server" |
61 | Layout.fillWidth: true | 74 | Layout.fillWidth: true |
62 | } | 75 | } |
63 | 76 | ||
64 | //If we had a settings controller | 77 | MaildirAccount.MaildirSettings { |
65 | // MaildirAccount.SmtpSettings { | 78 | id: maildirSettings |
66 | // id: smtpSettings | 79 | identifier: "org.kde.maildir.instance1" |
67 | // identifier: accountId | 80 | property alias path: path.text |
68 | // property alias username: username.text | 81 | } |
69 | // property alias password: password.text | ||
70 | // property alias server: server.text | ||
71 | // } | ||
72 | 82 | ||
73 | KubeSettings.Settings { | 83 | KubeSettings.Settings { |
74 | id: accountSettings | 84 | id: accountSettings |
@@ -92,8 +102,8 @@ Rectangle { | |||
92 | id: button | 102 | id: button |
93 | text: "Save" | 103 | text: "Save" |
94 | onClicked: { | 104 | onClicked: { |
95 | smtpSettings.save(); | 105 | transportSettings.save(); |
96 | root.visible = false; | 106 | maildirSettings.save(); |
97 | } | 107 | } |
98 | } | 108 | } |
99 | } | 109 | } |
diff --git a/accounts/maildir/qmldir b/accounts/maildir/qmldir index 40e6be1c..70ecc786 100644 --- a/accounts/maildir/qmldir +++ b/accounts/maildir/qmldir | |||
@@ -1,3 +1,5 @@ | |||
1 | module org.kde.kube.accounts.maildir | 1 | module org.kde.kube.accounts.maildir |
2 | 2 | ||
3 | AccountSettings 1.0 MaildirAccountSettings.qml | 3 | AccountSettings 1.0 MaildirAccountSettings.qml |
4 | |||
5 | plugin maildiraccountplugin | ||
diff --git a/applications/kube-mail/package/contents/ui/Settings.qml b/applications/kube-mail/package/contents/ui/Settings.qml index a3ea32f0..da44d331 100644 --- a/applications/kube-mail/package/contents/ui/Settings.qml +++ b/applications/kube-mail/package/contents/ui/Settings.qml | |||
@@ -55,19 +55,20 @@ Rectangle { | |||
55 | id: contextSettings | 55 | id: contextSettings |
56 | identifier: "applicationcontext" | 56 | identifier: "applicationcontext" |
57 | property string currentAccountId: "current" | 57 | property string currentAccountId: "current" |
58 | property var availableAccountTypes: ["maildir"] | ||
59 | property var accounts: ["current"] | ||
58 | } | 60 | } |
59 | 61 | ||
60 | Column { | 62 | Column { |
61 | spacing: 5 | 63 | spacing: 5 |
62 | Repeater { | 64 | Repeater { |
63 | model: ["current"] //Get from context settings | 65 | model: contextSettings.accounts |
64 | delegate: Maildir.AccountSettings { //This should be retrieved from the accounts plugin: KubeAccounts { identifier: modelData }.settingsUi | 66 | delegate: Maildir.AccountSettings { //This should be retrieved from the accounts plugin: KubeAccounts { identifier: modelData }.settingsUi |
65 | accountId: modelData | 67 | accountId: modelData |
66 | accountName: "Maildir" | ||
67 | } | 68 | } |
68 | } | 69 | } |
69 | } | 70 | } |
70 | 71 | ||
71 | //Add possibility to add more accounts | 72 | //TODO: Add possibility to add more accounts |
72 | } | 73 | } |
73 | } | 74 | } |