summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--accounts/maildir/CMakeLists.txt7
-rw-r--r--accounts/maildir/maildiraccountplugin.cpp2
-rw-r--r--accounts/maildir/package/contents/ui/MaildirAccountSettings.qml8
-rw-r--r--accounts/maildir/package/metadata.desktop8
-rw-r--r--accounts/maildir/qmldir4
-rw-r--r--components/package/contents/ui/Settings.qml23
-rw-r--r--framework/domain/CMakeLists.txt5
-rw-r--r--framework/domain/accountfactory.cpp72
-rw-r--r--framework/domain/accountfactory.h48
-rw-r--r--framework/domain/mailplugin.cpp2
10 files changed, 165 insertions, 14 deletions
diff --git a/accounts/maildir/CMakeLists.txt b/accounts/maildir/CMakeLists.txt
index d83ae0be..5307c5b0 100644
--- a/accounts/maildir/CMakeLists.txt
+++ b/accounts/maildir/CMakeLists.txt
@@ -22,6 +22,7 @@ find_package(Qt5 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui)
22set (QT_MIN_VERSION "5.4.0") 22set (QT_MIN_VERSION "5.4.0")
23find_package(Sink CONFIG REQUIRED) 23find_package(Sink CONFIG REQUIRED)
24find_package(KF5Async CONFIG REQUIRED) 24find_package(KF5Async CONFIG REQUIRED)
25find_package(KF5 REQUIRED COMPONENTS Package)
25 26
26include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/) 27include_directories(SYSTEM ${KDE_INSTALL_FULL_INCLUDEDIR}/KF5/)
27 28
@@ -34,7 +35,7 @@ add_library(maildiraccountplugin SHARED ${SRCS})
34qt5_use_modules(maildiraccountplugin Core Quick Qml) 35qt5_use_modules(maildiraccountplugin Core Quick Qml)
35target_link_libraries(maildiraccountplugin sink) 36target_link_libraries(maildiraccountplugin sink)
36 37
37install(TARGETS maildiraccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir) 38kpackage_install_package(package org.kube.accounts.maildir "genericqml")
38install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir)
39install(FILES package/contents/ui/MaildirAccountSettings.qml DESTINATION ${QML_INSTALL_DIR}/org/kde/kube/accounts/maildir)
40 39
40install(TARGETS maildiraccountplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/maildir)
41install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/accounts/maildir)
diff --git a/accounts/maildir/maildiraccountplugin.cpp b/accounts/maildir/maildiraccountplugin.cpp
index 0033613b..2c3c8c4d 100644
--- a/accounts/maildir/maildiraccountplugin.cpp
+++ b/accounts/maildir/maildiraccountplugin.cpp
@@ -6,6 +6,6 @@
6 6
7void MaildirAccountPlugin::registerTypes (const char *uri) 7void MaildirAccountPlugin::registerTypes (const char *uri)
8{ 8{
9 Q_ASSERT(uri == QLatin1String("org.kde.kube.accounts.maildir")); 9 Q_ASSERT(uri == QLatin1String("org.kube.accounts.maildir"));
10 qmlRegisterType<MaildirSettings>(uri, 1, 0, "MaildirSettings"); 10 qmlRegisterType<MaildirSettings>(uri, 1, 0, "MaildirSettings");
11} 11}
diff --git a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
index 77cf739f..a2564500 100644
--- a/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
+++ b/accounts/maildir/package/contents/ui/MaildirAccountSettings.qml
@@ -19,14 +19,18 @@ import QtQuick 2.4
19import QtQuick.Controls 1.4 19import QtQuick.Controls 1.4
20import QtQuick.Layouts 1.1 20import QtQuick.Layouts 1.1
21 21
22import org.kde.kube.settings 1.0 as KubeSettings 22import org.kube.framework.settings 1.0 as KubeSettings
23import org.kde.kube.accounts.maildir 1.0 as MaildirAccount 23import org.kde.kube.accounts.maildir 1.0 as MaildirAccount
24import org.kube.components 1.0 as KubeComponents
24 25
25Rectangle { 26Rectangle {
26 id: root 27 id: root
27 property string accountId 28 property string accountId
28 property string accountName: "Maildir" 29 property string accountName: "Maildir"
29 30
31 KubeComponents.ColorPalette {
32 id: colorPalette
33 }
30 color: colorPalette.background 34 color: colorPalette.background
31 35
32 GridLayout { 36 GridLayout {
@@ -82,7 +86,7 @@ Rectangle {
82 86
83 KubeSettings.Settings { 87 KubeSettings.Settings {
84 id: accountSettings 88 id: accountSettings
85 identifier: "account." + modelData 89 identifier: "account." + accountId
86 property string primaryIdentity: "current" 90 property string primaryIdentity: "current"
87 } 91 }
88 KubeSettings.Settings { 92 KubeSettings.Settings {
diff --git a/accounts/maildir/package/metadata.desktop b/accounts/maildir/package/metadata.desktop
new file mode 100644
index 00000000..12d444e9
--- /dev/null
+++ b/accounts/maildir/package/metadata.desktop
@@ -0,0 +1,8 @@
1[Desktop Entry]
2Name=Kube Maildir Accounts Plugin
3X-KDE-PluginInfo-Name=org.kube.accounts.maildir
4Exec=kpackagelauncherqml -a org.kube.accounts.maildir
5X-Plasma-MainScript=ui/MaildirAccountSettings.qml
6X-KDE-ServiceTypes=KPackage/GenericQML
7Icon=kmail2
8Type=Service
diff --git a/accounts/maildir/qmldir b/accounts/maildir/qmldir
index 70ecc786..5e4861c0 100644
--- a/accounts/maildir/qmldir
+++ b/accounts/maildir/qmldir
@@ -1,5 +1,3 @@
1module org.kde.kube.accounts.maildir 1module org.kube.accounts.maildir
2
3AccountSettings 1.0 MaildirAccountSettings.qml
4 2
5plugin maildiraccountplugin 3plugin maildiraccountplugin
diff --git a/components/package/contents/ui/Settings.qml b/components/package/contents/ui/Settings.qml
index 6d653c7b..692ddd0a 100644
--- a/components/package/contents/ui/Settings.qml
+++ b/components/package/contents/ui/Settings.qml
@@ -19,8 +19,10 @@ import QtQuick 2.4
19import QtQuick.Controls 1.4 19import QtQuick.Controls 1.4
20import QtQuick.Layouts 1.1 20import QtQuick.Layouts 1.1
21 21
22import org.kde.plasma.core 2.0 as PlasmaCore
23
22import org.kube.framework.settings 1.0 as KubeSettings 24import org.kube.framework.settings 1.0 as KubeSettings
23import org.kde.kube.accounts.maildir 1.0 as Maildir 25import org.kube.framework.domain 1.0 as KubeFramework
24 26
25Rectangle { 27Rectangle {
26 id: root 28 id: root
@@ -63,8 +65,23 @@ Rectangle {
63 spacing: 5 65 spacing: 5
64 Repeater { 66 Repeater {
65 model: contextSettings.accounts 67 model: contextSettings.accounts
66 delegate: Maildir.AccountSettings { //This should be retrieved from the accounts plugin: KubeAccounts { identifier: modelData }.settingsUi 68 delegate: Rectangle {
67 accountId: modelData 69 KubeFramework.AccountFactory {
70 id: accountFactory
71 accountId: modelData
72 }
73 PlasmaCore.IconItem {
74 anchors {
75 verticalCenter: parent.verticalCenter
76 left: parent.left
77 // leftMargin: unit.size * 3
78 }
79 source: accountFactory.icon
80 }
81 Label {
82 text: accountFactory.name
83 }
84 Loader { source: accountFactory.uiPath }
68 } 85 }
69 } 86 }
70 } 87 }
diff --git a/framework/domain/CMakeLists.txt b/framework/domain/CMakeLists.txt
index 361b816b..10a8c065 100644
--- a/framework/domain/CMakeLists.txt
+++ b/framework/domain/CMakeLists.txt
@@ -12,18 +12,19 @@ set(mailplugin_SRCS
12 mailtransport.cpp 12 mailtransport.cpp
13 mailtemplates.cpp 13 mailtemplates.cpp
14 retriever.cpp 14 retriever.cpp
15 accountfactory.cpp
15) 16)
16add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data") 17add_definitions(-DMAIL_DATA_DIR="${CMAKE_CURRENT_SOURCE_DIR}/data")
17 18
18find_package(CURL 7.20.0 REQUIRED) 19find_package(CURL 7.20.0 REQUIRED)
20find_package(KF5 REQUIRED COMPONENTS Package)
19 21
20include_directories(${CURL_INCLUDE_DIRS}) 22include_directories(${CURL_INCLUDE_DIRS})
21 23
22add_library(mailplugin SHARED ${mailplugin_SRCS}) 24add_library(mailplugin SHARED ${mailplugin_SRCS})
23 25
24qt5_use_modules(mailplugin Core Quick Qml WebKitWidgets) 26qt5_use_modules(mailplugin Core Quick Qml WebKitWidgets)
25 27target_link_libraries(mailplugin actionplugin settingsplugin sink KF5::Otp KF5::Codecs KF5::Package ${CURL_LIBRARIES})
26target_link_libraries(mailplugin actionplugin settingsplugin sink KF5::Otp KF5::Codecs ${CURL_LIBRARIES})
27 28
28install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/domain) 29install(TARGETS mailplugin DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/domain)
29install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/domain) 30install(FILES qmldir DESTINATION ${QML_INSTALL_DIR}/org/kube/framework/domain)
diff --git a/framework/domain/accountfactory.cpp b/framework/domain/accountfactory.cpp
new file mode 100644
index 00000000..d54f70a2
--- /dev/null
+++ b/framework/domain/accountfactory.cpp
@@ -0,0 +1,72 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsystems.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 "accountfactory.h"
20
21#include <QQmlComponent>
22#include <QQmlEngine>
23#include <QDebug>
24
25#include <KPackage/PackageLoader>
26
27AccountFactory::AccountFactory(QObject *parent)
28 : QObject(parent)
29{
30
31}
32
33QString AccountFactory::name() const
34{
35 return "Maildir";
36}
37
38QString AccountFactory::icon() const
39{
40 return "icon";
41}
42
43QVariant AccountFactory::ui() const
44{
45 return createComponent(getAccountType());
46}
47
48QByteArray AccountFactory::getAccountType() const
49{
50 return "maildir";
51}
52
53QString AccountFactory::uiPath() const
54{
55 auto accountType = getAccountType();
56 auto package = KPackage::PackageLoader::self()->loadPackage("KPackage/GenericQML", "org.kube.accounts." + accountType);
57 Q_ASSERT(package.isValid());
58 return package.filePath("mainscript");
59}
60
61QVariant AccountFactory::createComponent(const QByteArray &accountType) const const
62{
63 qWarning() << "Trying to load accounts package " << accountType << mAccountId;
64 auto engine = qmlEngine(this);
65 Q_ASSERT(engine);
66 auto component = new QQmlComponent(engine, QUrl::fromLocalFile(uiPath()), QQmlComponent::PreferSynchronous);
67 for (const auto &error : component->errors()) {
68 qWarning() << error.toString();
69 }
70 Q_ASSERT(component->isReady());
71 return QVariant::fromValue(component);
72}
diff --git a/framework/domain/accountfactory.h b/framework/domain/accountfactory.h
new file mode 100644
index 00000000..0c6afe50
--- /dev/null
+++ b/framework/domain/accountfactory.h
@@ -0,0 +1,48 @@
1/*
2 Copyright (c) 2016 Christian Mollekopf <mollekopf@kolabsystems.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
20#pragma once
21
22#include <QObject>
23#include <QVariant>
24
25/**
26 * A factory to instantiate accountp plugins.
27 */
28class AccountFactory : public QObject
29{
30 Q_OBJECT
31 Q_PROPERTY(QString accountId MEMBER mAccountId);
32 Q_PROPERTY(QString name READ name);
33 Q_PROPERTY(QString icon READ icon);
34 Q_PROPERTY(QVariant ui READ ui);
35 Q_PROPERTY(QString uiPath READ uiPath);
36public:
37 explicit AccountFactory(QObject *parent = Q_NULLPTR);
38
39 QString name() const;
40 QString icon() const;
41 QVariant ui() const;
42 QString uiPath() const;
43
44 Q_INVOKABLE QVariant createComponent(const QByteArray &accountType) const;
45private:
46 QByteArray getAccountType() const;
47 QString mAccountId;
48};
diff --git a/framework/domain/mailplugin.cpp b/framework/domain/mailplugin.cpp
index c45666c1..dd438114 100644
--- a/framework/domain/mailplugin.cpp
+++ b/framework/domain/mailplugin.cpp
@@ -25,6 +25,7 @@
25#include "composercontroller.h" 25#include "composercontroller.h"
26#include "messageparser.h" 26#include "messageparser.h"
27#include "retriever.h" 27#include "retriever.h"
28#include "accountfactory.h"
28 29
29#include <QtQml> 30#include <QtQml>
30 31
@@ -37,4 +38,5 @@ void MailPlugin::registerTypes (const char *uri)
37 qmlRegisterType<ComposerController>(uri, 1, 0, "ComposerController"); 38 qmlRegisterType<ComposerController>(uri, 1, 0, "ComposerController");
38 qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser"); 39 qmlRegisterType<MessageParser>(uri, 1, 0, "MessageParser");
39 qmlRegisterType<Retriever>(uri, 1, 0, "Retriever"); 40 qmlRegisterType<Retriever>(uri, 1, 0, "Retriever");
41 qmlRegisterType<AccountFactory>(uri, 1, 0, "AccountFactory");
40} 42}