diff options
-rw-r--r-- | CMakeLists.txt | 5 | ||||
-rw-r--r-- | components/kube/qml/Kube.qml | 1 | ||||
-rw-r--r-- | extensions/CMakeLists.txt | 7 | ||||
-rw-r--r-- | extensions/api/CMakeLists.txt | 12 | ||||
-rw-r--r-- | extensions/api/qmldir | 4 | ||||
-rw-r--r-- | extensions/api/src/CMakeLists.txt | 25 | ||||
-rw-r--r-- | extensions/api/src/extensionapi.cpp | 89 | ||||
-rw-r--r-- | extensions/api/src/extensionapi.h | 30 | ||||
-rw-r--r-- | extensions/api/src/extensionapiplugin.cpp | 42 | ||||
-rw-r--r-- | extensions/api/src/extensionapiplugin.h | 33 | ||||
-rw-r--r-- | extensions/fileasexpense/qml/main.qml | 32 | ||||
-rw-r--r-- | framework/qml/ExtensionPoint.qml | 37 | ||||
-rw-r--r-- | framework/qml/MailViewer.qml | 11 | ||||
-rw-r--r-- | framework/qmldir | 1 | ||||
-rw-r--r-- | framework/src/extensionmodel.cpp | 24 | ||||
-rw-r--r-- | framework/src/extensionmodel.h | 5 | ||||
-rw-r--r-- | views/conversation/qml/View.qml | 1 |
17 files changed, 353 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 350dfea2..321cacf7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -11,6 +11,8 @@ cmake_policy(SET CMP0053 NEW) | |||
11 | cmake_policy(SET CMP0063 NEW) | 11 | cmake_policy(SET CMP0063 NEW) |
12 | 12 | ||
13 | option(EXPERIMENTAL_VIEWS "Install experimental views" OFF) | 13 | option(EXPERIMENTAL_VIEWS "Install experimental views" OFF) |
14 | #Do not enable this unless you actually distribute a custom extension. | ||
15 | option(ENABLE_EXTENSION "Enable custom kube extensions" OFF) | ||
14 | 16 | ||
15 | include(CPack) | 17 | include(CPack) |
16 | include(FeatureSummary) | 18 | include(FeatureSummary) |
@@ -41,3 +43,6 @@ add_subdirectory(applications) | |||
41 | add_subdirectory(views) | 43 | add_subdirectory(views) |
42 | add_subdirectory(accounts) | 44 | add_subdirectory(accounts) |
43 | add_subdirectory(tests) | 45 | add_subdirectory(tests) |
46 | if (${ENABLE_EXTENSION}) | ||
47 | add_subdirectory(extensions) | ||
48 | endif() | ||
diff --git a/components/kube/qml/Kube.qml b/components/kube/qml/Kube.qml index bb161d8e..61933908 100644 --- a/components/kube/qml/Kube.qml +++ b/components/kube/qml/Kube.qml | |||
@@ -160,6 +160,7 @@ Controls2.ApplicationWindow { | |||
160 | Repeater { | 160 | Repeater { |
161 | model: Kube.ExtensionModel { | 161 | model: Kube.ExtensionModel { |
162 | id: extensionModel | 162 | id: extensionModel |
163 | extensionPoint: "views" | ||
163 | sortOrder: ["composer", "conversation", "people"] | 164 | sortOrder: ["composer", "conversation", "people"] |
164 | } | 165 | } |
165 | Kube.IconButton { | 166 | Kube.IconButton { |
diff --git a/extensions/CMakeLists.txt b/extensions/CMakeLists.txt new file mode 100644 index 00000000..b8412096 --- /dev/null +++ b/extensions/CMakeLists.txt | |||
@@ -0,0 +1,7 @@ | |||
1 | macro(install_extension name extensionpoint) | ||
2 | install(DIRECTORY ${name}/qml/ DESTINATION ${QML_INSTALL_DIR}/org/kube/extensions/${extensionpoint}/${name}) | ||
3 | #install(FILES ${name}/metadata.json DESTINATION ${QML_INSTALL_DIR}/org/kube/extensions/${name}) | ||
4 | endmacro() | ||
5 | |||
6 | add_subdirectory(api) | ||
7 | install_extension(fileasexpense mailview) | ||
diff --git a/extensions/api/CMakeLists.txt b/extensions/api/CMakeLists.txt new file mode 100644 index 00000000..82a5c7b0 --- /dev/null +++ b/extensions/api/CMakeLists.txt | |||
@@ -0,0 +1,12 @@ | |||
1 | include(GenerateExportHeader) | ||
2 | include(ECMGenerateHeaders) | ||
3 | include(CMakePackageConfigHelpers) | ||
4 | |||
5 | set(EXTENSIONAPI_INSTALL_DIR ${QML_INSTALL_DIR}/org/kube/extensionapi) | ||
6 | |||
7 | install(DIRECTORY qml/ DESTINATION ${EXTENSIONAPI_INSTALL_DIR}) | ||
8 | install(FILES qmldir DESTINATION ${EXTENSIONAPI_INSTALL_DIR}) | ||
9 | |||
10 | add_subdirectory(src) | ||
11 | |||
12 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) | ||
diff --git a/extensions/api/qmldir b/extensions/api/qmldir new file mode 100644 index 00000000..405785e5 --- /dev/null +++ b/extensions/api/qmldir | |||
@@ -0,0 +1,4 @@ | |||
1 | module org.kube.extensionapi | ||
2 | depends org.kube.framework 1.0 | ||
3 | |||
4 | plugin extensionapiplugin | ||
diff --git a/extensions/api/src/CMakeLists.txt b/extensions/api/src/CMakeLists.txt new file mode 100644 index 00000000..f7e543dc --- /dev/null +++ b/extensions/api/src/CMakeLists.txt | |||
@@ -0,0 +1,25 @@ | |||
1 | add_definitions("-Wall -std=c++14 -g") | ||
2 | set(CMAKE_CXX_VISIBILITY_PRESET default) | ||
3 | |||
4 | find_package(Qt5 COMPONENTS REQUIRED Core Concurrent Quick Qml WebEngineWidgets Test WebEngine Gui) | ||
5 | find_package(KF5Mime 4.87.0 CONFIG REQUIRED) | ||
6 | find_package(Sink 0.6.0 CONFIG REQUIRED) | ||
7 | |||
8 | include_directories(../../../framework/src/domain/mime ${KMIME_INCLUDES}) | ||
9 | |||
10 | add_library(extensionapiplugin SHARED extensionapiplugin.cpp extensionapi.cpp) | ||
11 | target_link_libraries(extensionapiplugin | ||
12 | kubeframework | ||
13 | KF5::Mime | ||
14 | sink | ||
15 | Qt5::Core | ||
16 | Qt5::Quick | ||
17 | Qt5::Qml | ||
18 | Qt5::WebEngineWidgets | ||
19 | Qt5::Test | ||
20 | Qt5::WebEngine | ||
21 | Qt5::Gui | ||
22 | ) | ||
23 | install(TARGETS extensionapiplugin DESTINATION ${EXTENSIONAPI_INSTALL_DIR}) | ||
24 | |||
25 | feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) | ||
diff --git a/extensions/api/src/extensionapi.cpp b/extensions/api/src/extensionapi.cpp new file mode 100644 index 00000000..3e6689b9 --- /dev/null +++ b/extensions/api/src/extensionapi.cpp | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | Copyright (c) 2018 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 "extensionapi.h" | ||
20 | |||
21 | #include <mailtemplates.h> | ||
22 | #include <KMime/KMimeMessage> | ||
23 | #include <sink/store.h> | ||
24 | #include <sink/log.h> | ||
25 | |||
26 | #include <QDebug> | ||
27 | |||
28 | static void send(const QByteArray &message, const QByteArray &accountId) | ||
29 | { | ||
30 | using namespace Sink; | ||
31 | using namespace Sink::ApplicationDomain; | ||
32 | |||
33 | Q_ASSERT(!accountId.isEmpty()); | ||
34 | Query query; | ||
35 | query.containsFilter<SinkResource::Capabilities>(ResourceCapabilities::Mail::transport); | ||
36 | query.filter<SinkResource::Account>(accountId); | ||
37 | auto job = Store::fetchAll<SinkResource>(query) | ||
38 | .then([=](const QList<SinkResource::Ptr> &resources) { | ||
39 | if (!resources.isEmpty()) { | ||
40 | auto resourceId = resources[0]->identifier(); | ||
41 | SinkLog() << "Sending message via resource: " << resourceId; | ||
42 | Mail mail(resourceId); | ||
43 | mail.setMimeMessage(message); | ||
44 | return Store::create(mail) | ||
45 | .then<void>([=] { | ||
46 | //Trigger a sync, but don't wait for it. | ||
47 | Store::synchronize(Sink::SyncScope{}.resourceFilter(resourceId)).exec(); | ||
48 | }); | ||
49 | } | ||
50 | SinkWarning() << "Failed to find a mailtransport resource"; | ||
51 | return KAsync::error<void>(0, "Failed to find a MailTransport resource."); | ||
52 | }) | ||
53 | .then([&] (const KAsync::Error &) { | ||
54 | SinkLog() << "Message was sent: "; | ||
55 | }); | ||
56 | job.exec(); | ||
57 | } | ||
58 | |||
59 | static QStringList toStringList(const QVariantList &list) | ||
60 | { | ||
61 | QStringList s; | ||
62 | for (const auto &e : list) { | ||
63 | s << e.toString(); | ||
64 | } | ||
65 | return s; | ||
66 | } | ||
67 | |||
68 | Q_INVOKABLE void ExtensionApi::forwardMail(const QVariantMap &map) | ||
69 | { | ||
70 | SinkLog() << "Forwarding mail " << map; | ||
71 | auto mailObject = map.value("mail").value<Sink::ApplicationDomain::Mail::Ptr>(); | ||
72 | Q_ASSERT(mailObject); | ||
73 | KMime::Message::Ptr msg(new KMime::Message); | ||
74 | msg->setContent(KMime::CRLFtoLF(mailObject->getMimeMessage())); | ||
75 | msg->parse(); | ||
76 | |||
77 | MailTemplates::forward(msg, [map] (const KMime::Message::Ptr &fwdMessage) { | ||
78 | auto msg = fwdMessage; | ||
79 | msg->subject()->fromUnicodeString(map.value("subject").toString(), "utf8"); | ||
80 | auto list = toStringList(map.value("to").toList()); | ||
81 | for (const auto &address : list) { | ||
82 | KMime::Types::Mailbox mb; | ||
83 | mb.fromUnicodeString(address); | ||
84 | msg->to()->addAddress(mb); | ||
85 | } | ||
86 | msg->assemble(); | ||
87 | send(msg->encodedContent(true), map.value("accountId").toByteArray()); | ||
88 | }); | ||
89 | } | ||
diff --git a/extensions/api/src/extensionapi.h b/extensions/api/src/extensionapi.h new file mode 100644 index 00000000..305d1206 --- /dev/null +++ b/extensions/api/src/extensionapi.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | Copyright (c) 2018 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 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QObject> | ||
23 | |||
24 | class ExtensionApi : public QObject | ||
25 | { | ||
26 | Q_OBJECT | ||
27 | |||
28 | public: | ||
29 | Q_INVOKABLE void forwardMail(const QVariantMap &map); | ||
30 | }; | ||
diff --git a/extensions/api/src/extensionapiplugin.cpp b/extensions/api/src/extensionapiplugin.cpp new file mode 100644 index 00000000..3f399e36 --- /dev/null +++ b/extensions/api/src/extensionapiplugin.cpp | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | Copyright (c) 2018 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 | |||
20 | #include "extensionapiplugin.h" | ||
21 | |||
22 | #include "extensionapi.h" | ||
23 | |||
24 | #include <QtQml> | ||
25 | |||
26 | void ExtensionApiPlugin::initializeEngine(QQmlEngine *engine, const char *uri) | ||
27 | { | ||
28 | Q_UNUSED(uri); | ||
29 | Q_UNUSED(engine); | ||
30 | } | ||
31 | |||
32 | static QObject *extensionApiSingleton(QQmlEngine *engine, QJSEngine *scriptEngine) | ||
33 | { | ||
34 | Q_UNUSED(engine) | ||
35 | Q_UNUSED(scriptEngine) | ||
36 | return new ExtensionApi; | ||
37 | } | ||
38 | |||
39 | void ExtensionApiPlugin::registerTypes (const char *uri) | ||
40 | { | ||
41 | qmlRegisterSingletonType<ExtensionApi>(uri, 1, 0, "ExtensionApi", extensionApiSingleton); | ||
42 | } | ||
diff --git a/extensions/api/src/extensionapiplugin.h b/extensions/api/src/extensionapiplugin.h new file mode 100644 index 00000000..e23e5cc4 --- /dev/null +++ b/extensions/api/src/extensionapiplugin.h | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | Copyright (c) 2018 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 | |||
20 | #pragma once | ||
21 | |||
22 | #include <QQmlEngine> | ||
23 | #include <QQmlExtensionPlugin> | ||
24 | |||
25 | class ExtensionApiPlugin : public QQmlExtensionPlugin | ||
26 | { | ||
27 | Q_OBJECT | ||
28 | Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface") | ||
29 | |||
30 | public: | ||
31 | void registerTypes(const char *uri) Q_DECL_OVERRIDE; | ||
32 | void initializeEngine(QQmlEngine *engine, const char *uri) Q_DECL_OVERRIDE; | ||
33 | }; | ||
diff --git a/extensions/fileasexpense/qml/main.qml b/extensions/fileasexpense/qml/main.qml new file mode 100644 index 00000000..b53951f2 --- /dev/null +++ b/extensions/fileasexpense/qml/main.qml | |||
@@ -0,0 +1,32 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
3 | * | ||
4 | * 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 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | import org.kube.framework 1.0 as Kube | ||
21 | import org.kube.extensionapi 1.0 | ||
22 | |||
23 | Kube.Button { | ||
24 | property variant context: {} | ||
25 | visible: true | ||
26 | activeFocusOnTab: false | ||
27 | |||
28 | text: qsTr("File as Expense") | ||
29 | onClicked: { | ||
30 | ExtensionApi.forwardMail({mail: context.mail, to: ["test1@kolab.org"], subject: "Expense: " + context.subject, accountId: context.accountId}) | ||
31 | } | ||
32 | } | ||
diff --git a/framework/qml/ExtensionPoint.qml b/framework/qml/ExtensionPoint.qml new file mode 100644 index 00000000..4f66b20e --- /dev/null +++ b/framework/qml/ExtensionPoint.qml | |||
@@ -0,0 +1,37 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 Christian Mollekopf, <mollekopf@kolabsys.com> | ||
3 | * | ||
4 | * 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 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
17 | */ | ||
18 | |||
19 | import QtQuick 2.7 | ||
20 | |||
21 | import org.kube.framework 1.0 as Kube | ||
22 | |||
23 | Repeater { | ||
24 | id: root | ||
25 | property alias extensionPoint: extensionModel.extensionPoint | ||
26 | property variant context: {} | ||
27 | |||
28 | model: Kube.ExtensionModel { | ||
29 | id: extensionModel | ||
30 | } | ||
31 | Loader { | ||
32 | source: root.model.findSource(model.name, "main.qml") | ||
33 | onLoaded: { | ||
34 | item.context = root.context | ||
35 | } | ||
36 | } | ||
37 | } | ||
diff --git a/framework/qml/MailViewer.qml b/framework/qml/MailViewer.qml index 2a1af3a6..e9759d72 100644 --- a/framework/qml/MailViewer.qml +++ b/framework/qml/MailViewer.qml | |||
@@ -348,6 +348,8 @@ Rectangle { | |||
348 | } | 348 | } |
349 | Item { | 349 | Item { |
350 | id: footer | 350 | id: footer |
351 | property var mail: model.mail | ||
352 | property string subject: model.subject | ||
351 | 353 | ||
352 | anchors.bottom: parent.bottom | 354 | anchors.bottom: parent.bottom |
353 | 355 | ||
@@ -373,13 +375,12 @@ Rectangle { | |||
373 | } | 375 | } |
374 | } | 376 | } |
375 | 377 | ||
376 | Grid { | 378 | Row { |
377 | anchors { | 379 | anchors { |
378 | verticalCenter: parent.verticalCenter | 380 | verticalCenter: parent.verticalCenter |
379 | right: parent.right | 381 | right: parent.right |
380 | rightMargin: Kube.Units.largeSpacing | 382 | rightMargin: Kube.Units.largeSpacing |
381 | } | 383 | } |
382 | columns: 2 | ||
383 | spacing: Kube.Units.smallSpacing | 384 | spacing: Kube.Units.smallSpacing |
384 | 385 | ||
385 | Kube.Button { | 386 | Kube.Button { |
@@ -405,6 +406,12 @@ Rectangle { | |||
405 | } | 406 | } |
406 | } | 407 | } |
407 | } | 408 | } |
409 | Row { | ||
410 | Kube.ExtensionPoint { | ||
411 | extensionPoint: "extensions/mailview" | ||
412 | context: {"mail": footer.mail, "subject": footer.subject, "accountId": currentAccount} | ||
413 | } | ||
414 | } | ||
408 | } | 415 | } |
409 | } | 416 | } |
410 | 417 | ||
diff --git a/framework/qmldir b/framework/qmldir index 80146b8e..4a6f40ef 100644 --- a/framework/qmldir +++ b/framework/qmldir | |||
@@ -45,6 +45,7 @@ TreeView 1.0 TreeView.qml | |||
45 | GridView 1.0 GridView.qml | 45 | GridView 1.0 GridView.qml |
46 | ScrollHelper 1.0 ScrollHelper.qml | 46 | ScrollHelper 1.0 ScrollHelper.qml |
47 | ModelIndexRetriever 1.0 ModelIndexRetriever.qml | 47 | ModelIndexRetriever 1.0 ModelIndexRetriever.qml |
48 | ExtensionPoint 1.0 ExtensionPoint.qml | ||
48 | singleton Messages 1.0 Messages.qml | 49 | singleton Messages 1.0 Messages.qml |
49 | singleton Notifications 1.0 Notifications.qml | 50 | singleton Notifications 1.0 Notifications.qml |
50 | singleton Colors 1.0 Colors.qml | 51 | singleton Colors 1.0 Colors.qml |
diff --git a/framework/src/extensionmodel.cpp b/framework/src/extensionmodel.cpp index e3fab7d8..5f42aa7a 100644 --- a/framework/src/extensionmodel.cpp +++ b/framework/src/extensionmodel.cpp | |||
@@ -47,12 +47,17 @@ QHash<int, QByteArray> ExtensionModel::roleNames() const | |||
47 | 47 | ||
48 | void ExtensionModel::load() | 48 | void ExtensionModel::load() |
49 | { | 49 | { |
50 | auto model = new QStandardItemModel(this); | 50 | if (auto m = sourceModel()) { |
51 | 51 | setSourceModel(nullptr); | |
52 | delete m; | ||
53 | } | ||
52 | auto engine = qmlEngine(this); | 54 | auto engine = qmlEngine(this); |
53 | Q_ASSERT(engine); | 55 | if (!engine) { |
56 | return; | ||
57 | } | ||
58 | auto model = new QStandardItemModel(this); | ||
54 | for (const auto &path : engine->importPathList()) { | 59 | for (const auto &path : engine->importPathList()) { |
55 | QDir dir{path + "/org/kube/views"}; | 60 | QDir dir{path + "/org/kube/" + mExtensionPoint}; |
56 | for (const auto &pluginName : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { | 61 | for (const auto &pluginName : dir.entryList(QDir::Dirs | QDir::NoDotAndDotDot)) { |
57 | const auto pluginPath = dir.path() + "/" + pluginName; | 62 | const auto pluginPath = dir.path() + "/" + pluginName; |
58 | mPaths.insert(pluginName, pluginPath); | 63 | mPaths.insert(pluginName, pluginPath); |
@@ -101,6 +106,17 @@ QVariantList ExtensionModel::sortOrder() const | |||
101 | return {}; | 106 | return {}; |
102 | } | 107 | } |
103 | 108 | ||
109 | void ExtensionModel::setExtensionPoint(const QString &extensionPoint) | ||
110 | { | ||
111 | mExtensionPoint = extensionPoint; | ||
112 | QTimer::singleShot(0, this, &ExtensionModel::load); | ||
113 | } | ||
114 | |||
115 | QString ExtensionModel::extensionPoint() const | ||
116 | { | ||
117 | return mExtensionPoint; | ||
118 | } | ||
119 | |||
104 | QVariant ExtensionModel::data(const QModelIndex &idx, int role) const | 120 | QVariant ExtensionModel::data(const QModelIndex &idx, int role) const |
105 | { | 121 | { |
106 | return QSortFilterProxyModel::data(idx, role); | 122 | return QSortFilterProxyModel::data(idx, role); |
diff --git a/framework/src/extensionmodel.h b/framework/src/extensionmodel.h index 5360cc2f..07601e57 100644 --- a/framework/src/extensionmodel.h +++ b/framework/src/extensionmodel.h | |||
@@ -29,6 +29,7 @@ class ExtensionModel : public QSortFilterProxyModel | |||
29 | Q_OBJECT | 29 | Q_OBJECT |
30 | 30 | ||
31 | Q_PROPERTY(QVariantList sortOrder WRITE setSortOrder READ sortOrder) | 31 | Q_PROPERTY(QVariantList sortOrder WRITE setSortOrder READ sortOrder) |
32 | Q_PROPERTY(QString extensionPoint WRITE setExtensionPoint READ extensionPoint) | ||
32 | public: | 33 | public: |
33 | 34 | ||
34 | ExtensionModel(QObject *parent = Q_NULLPTR); | 35 | ExtensionModel(QObject *parent = Q_NULLPTR); |
@@ -49,6 +50,9 @@ public: | |||
49 | void setSortOrder(const QVariantList &order); | 50 | void setSortOrder(const QVariantList &order); |
50 | QVariantList sortOrder() const; | 51 | QVariantList sortOrder() const; |
51 | 52 | ||
53 | void setExtensionPoint(const QString &order); | ||
54 | QString extensionPoint() const; | ||
55 | |||
52 | Q_INVOKABLE QString findSource(const QString &extensionName, const QString &sourceName); | 56 | Q_INVOKABLE QString findSource(const QString &extensionName, const QString &sourceName); |
53 | 57 | ||
54 | private slots: | 58 | private slots: |
@@ -57,6 +61,7 @@ private slots: | |||
57 | private: | 61 | private: |
58 | QStringList mSortOrder; | 62 | QStringList mSortOrder; |
59 | QHash<QString, QString> mPaths; | 63 | QHash<QString, QString> mPaths; |
64 | QString mExtensionPoint; | ||
60 | }; | 65 | }; |
61 | 66 | ||
62 | } | 67 | } |
diff --git a/views/conversation/qml/View.qml b/views/conversation/qml/View.qml index 5f0d362d..c0e44144 100644 --- a/views/conversation/qml/View.qml +++ b/views/conversation/qml/View.qml | |||
@@ -26,6 +26,7 @@ import QtQuick.Layouts 1.1 | |||
26 | import org.kube.framework 1.0 as Kube | 26 | import org.kube.framework 1.0 as Kube |
27 | 27 | ||
28 | FocusScope { | 28 | FocusScope { |
29 | property alias currentAccount: accountFolderview.currentAccount | ||
29 | SplitView { | 30 | SplitView { |
30 | anchors.fill: parent | 31 | anchors.fill: parent |
31 | Rectangle { | 32 | Rectangle { |