From d0fd982933e3095bc07e66b3d461111441b320af Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 29 Oct 2013 20:55:00 +0100 Subject: [PATCH] rework widget explorer models as component --- .../contents/explorer/WidgetExplorer.qml | 7 ++++++- .../desktop/contents/views/Desktop.qml | 4 +++- src/shell/shellcorona.cpp | 3 +++ src/shell/widgetexplorer/widgetexplorer.cpp | 19 ++++++++++++++++++- src/shell/widgetexplorer/widgetexplorer.h | 6 ++++++ 5 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/shell/qmlpackages/desktop/contents/explorer/WidgetExplorer.qml b/src/shell/qmlpackages/desktop/contents/explorer/WidgetExplorer.qml index 61bf99952..8c6befb07 100644 --- a/src/shell/qmlpackages/desktop/contents/explorer/WidgetExplorer.qml +++ b/src/shell/qmlpackages/desktop/contents/explorer/WidgetExplorer.qml @@ -23,7 +23,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.extras 2.0 as PlasmaExtras import org.kde.qtextracomponents 2.0 import QtQuick.Window 2.1 - +import org.kde.plasma.private.shell 2.0 Item { id: main @@ -39,6 +39,11 @@ Item { property Item getWidgetsButton property Item categoryButton + WidgetExplorer { + id:widgetExplorer + desktopView: desktop + } + PlasmaComponents.ContextMenu { id: categoriesDialog visualParent: main.categoryButton diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index 710fb7b29..a99144813 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -21,6 +21,8 @@ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import "../activitymanager" +import "../explorer" + Rectangle { id: root @@ -39,7 +41,7 @@ Rectangle { explorerObject.close(); sidePanelStack.state = "closed"; } else { - sidePanelStack.push(explorerObject); + sidePanelStack.push(Qt.resolvedUrl("../explorer/WidgetExplorer.qml")); explorerObject.closed.connect(function(){sidePanelStack.state = "closed";}); sidePanelStack.state = "widgetExplorer"; } diff --git a/src/shell/shellcorona.cpp b/src/shell/shellcorona.cpp index 8fdf6c254..9dedfee60 100644 --- a/src/shell/shellcorona.cpp +++ b/src/shell/shellcorona.cpp @@ -92,6 +92,9 @@ ShellCorona::ShellCorona(QObject *parent) { d->desktopDefaultsConfig = KConfigGroup(KSharedConfig::openConfig(package().filePath("defaults")), "Desktop"); + qmlRegisterType("org.kde.plasma.private.shell", 2, 0, "WidgetExplorer"); + qmlRegisterType(); + connect(&d->appConfigSyncTimer, &QTimer::timeout, this, &ShellCorona::syncAppConfig); diff --git a/src/shell/widgetexplorer/widgetexplorer.cpp b/src/shell/widgetexplorer/widgetexplorer.cpp index c15f955dd..aa335a330 100644 --- a/src/shell/widgetexplorer/widgetexplorer.cpp +++ b/src/shell/widgetexplorer/widgetexplorer.cpp @@ -37,6 +37,7 @@ #include #include +#include "desktopview.h" #include "kcategorizeditemsviewmodels_p.h" #include "plasmaappletitemmodel_p.h" @@ -63,7 +64,8 @@ public: containment(0), itemModel(w), filterModel(w), - qmlObject(new QmlObject(w)) + qmlObject(new QmlObject(w)), + desktopView(0) { } @@ -98,6 +100,7 @@ public: PlasmaAppletItemModel itemModel; KCategorizedItemsViewModels::DefaultFilterModel filterModel; DefaultItemFilterProxyModel filterItemModel; + DesktopView *desktopView; QmlObject *qmlObject; }; @@ -338,6 +341,20 @@ Qt::Orientation WidgetExplorer::orientation() const return d->orientation; } +DesktopView *WidgetExplorer::desktopView() +{ + return d->desktopView; +} + +void WidgetExplorer::setDesktopView(DesktopView *view) +{qWarning()<<"AAAAAAAAAAAAAAAAAAAAAAA"<desktopView = view; + if (view) { + setContainment(view->containment()); + } + emit desktopViewChanged(); +} + void WidgetExplorer::populateWidgetList(const QString &app) { d->application = app; diff --git a/src/shell/widgetexplorer/widgetexplorer.h b/src/shell/widgetexplorer/widgetexplorer.h index aebd26130..00a9607e2 100644 --- a/src/shell/widgetexplorer/widgetexplorer.h +++ b/src/shell/widgetexplorer/widgetexplorer.h @@ -34,6 +34,7 @@ namespace Plasma { class Applet; } class WidgetExplorerPrivate; + class DesktopView; //We need to access the separator property that is not exported by QAction class WidgetAction : public QAction @@ -85,6 +86,8 @@ class WidgetExplorer : public QQuickItem */ Q_PROPERTY(Qt::Orientation orientation READ orientation NOTIFY orientationChanged) + Q_PROPERTY(DesktopView *desktopView READ desktopView WRITE setDesktopView NOTIFY desktopViewChanged) + public: explicit WidgetExplorer(QQuickItem *parent = 0); ~WidgetExplorer(); @@ -134,6 +137,8 @@ public: Qt::Orientation orientation() const; + DesktopView *desktopView(); + void setDesktopView(DesktopView *view); QObject *widgetsModel() const; QObject *filterModel() const; @@ -155,6 +160,7 @@ Q_SIGNALS: void widgetsMenuActionsChanged(); void extraActionsChanged(); void closed(); + void desktopViewChanged(); public Q_SLOTS: /**