summaryrefslogtreecommitdiffstats
path: root/framework
diff options
context:
space:
mode:
Diffstat (limited to 'framework')
-rw-r--r--framework/qml/ExtensionPoint.qml37
-rw-r--r--framework/qml/MailViewer.qml11
-rw-r--r--framework/qmldir1
-rw-r--r--framework/src/extensionmodel.cpp24
-rw-r--r--framework/src/extensionmodel.h5
5 files changed, 72 insertions, 6 deletions
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
19import QtQuick 2.7
20
21import org.kube.framework 1.0 as Kube
22
23Repeater {
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
45GridView 1.0 GridView.qml 45GridView 1.0 GridView.qml
46ScrollHelper 1.0 ScrollHelper.qml 46ScrollHelper 1.0 ScrollHelper.qml
47ModelIndexRetriever 1.0 ModelIndexRetriever.qml 47ModelIndexRetriever 1.0 ModelIndexRetriever.qml
48ExtensionPoint 1.0 ExtensionPoint.qml
48singleton Messages 1.0 Messages.qml 49singleton Messages 1.0 Messages.qml
49singleton Notifications 1.0 Notifications.qml 50singleton Notifications 1.0 Notifications.qml
50singleton Colors 1.0 Colors.qml 51singleton 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
48void ExtensionModel::load() 48void 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
109void ExtensionModel::setExtensionPoint(const QString &extensionPoint)
110{
111 mExtensionPoint = extensionPoint;
112 QTimer::singleShot(0, this, &ExtensionModel::load);
113}
114
115QString ExtensionModel::extensionPoint() const
116{
117 return mExtensionPoint;
118}
119
104QVariant ExtensionModel::data(const QModelIndex &idx, int role) const 120QVariant 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)
32public: 33public:
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
54private slots: 58private slots:
@@ -57,6 +61,7 @@ private slots:
57private: 61private:
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}