From 8fbc0a449377afc200a443c2c2d513f59f5dad61 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 30 Oct 2013 10:51:27 +0100 Subject: [PATCH] widgetexplorer is a pure qobject doesn't try to load qml --- src/shell/widgetexplorer/widgetexplorer.cpp | 72 +-------------------- src/shell/widgetexplorer/widgetexplorer.h | 36 +---------- 2 files changed, 6 insertions(+), 102 deletions(-) diff --git a/src/shell/widgetexplorer/widgetexplorer.cpp b/src/shell/widgetexplorer/widgetexplorer.cpp index 4dc15833f..1e6f3515b 100644 --- a/src/shell/widgetexplorer/widgetexplorer.cpp +++ b/src/shell/widgetexplorer/widgetexplorer.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #include @@ -64,7 +63,6 @@ public: containment(0), itemModel(w), filterModel(w), - qmlObject(new QmlObject(w)), desktopView(0) { } @@ -72,7 +70,6 @@ public: void initFilters(); void initRunningApplets(); void containmentDestroyed(); - void setLocation(Plasma::Types::Location loc); /** * Tracks a new running applet @@ -84,9 +81,6 @@ public: */ void appletRemoved(Plasma::Applet *applet); - //this orientation is just for convenience, is the location that is important - Qt::Orientation orientation; - Plasma::Types::Location location; WidgetExplorer *q; QString application; Plasma::Containment *containment; @@ -101,8 +95,6 @@ public: KCategorizedItemsViewModels::DefaultFilterModel filterModel; DefaultItemFilterProxyModel filterItemModel; DesktopView *desktopView; - - QmlObject *qmlObject; }; void WidgetExplorerPrivate::initFilters() @@ -154,28 +146,6 @@ void WidgetExplorerPrivate::initFilters() } -void WidgetExplorerPrivate::setLocation(const Plasma::Types::Location loc) -{ - Qt::Orientation orient; - if (loc == Plasma::Types::LeftEdge || loc == Plasma::Types::RightEdge) { - orient = Qt::Vertical; - } else { - orient = Qt::Horizontal; - } - - if (location == loc) { - return; - } - - location = loc; - - if (orientation == orient) { - return; - } - - emit q->orientationChanged(); -} - QObject *WidgetExplorer::widgetsModel() const { return &d->filterItemModel; @@ -307,11 +277,10 @@ void WidgetExplorerPrivate::appletRemoved(Plasma::Applet *applet) //WidgetExplorer -WidgetExplorer::WidgetExplorer(QQuickItem *parent) - :QQuickItem(parent), - d(new WidgetExplorerPrivate(this)) +WidgetExplorer::WidgetExplorer(QObject *parent) + : QObject(parent), + d(new WidgetExplorerPrivate(this)) { - setLocation(Plasma::Types::LeftEdge); populateWidgetList(); d->initRunningApplets(); d->filterItemModel.setSortCaseSensitivity(Qt::CaseInsensitive); @@ -325,21 +294,6 @@ WidgetExplorer::~WidgetExplorer() delete d; } -void WidgetExplorer::setLocation(Plasma::Types::Location loc) -{ - d->setLocation(loc); - emit(locationChanged(loc)); -} - -Plasma::Types::Location WidgetExplorer::location() const -{ - return d->location; -} - -Qt::Orientation WidgetExplorer::orientation() const -{ - return d->orientation; -} DesktopView *WidgetExplorer::desktopView() { @@ -370,25 +324,6 @@ QString WidgetExplorer::application() return d->application; } -void WidgetExplorer::setSource(const QUrl &source) -{ - d->qmlObject->setInitializationDelayed(true); - d->qmlObject->setSource(source); - d->qmlObject->engine()->rootContext()->setContextProperty("widgetExplorer", this); - d->qmlObject->completeInitialization(); - QQuickItem *i = qobject_cast(d->qmlObject->rootObject()); - i->setParentItem(this); - //set anchors - QQmlExpression expr(d->qmlObject->engine()->rootContext(), d->qmlObject->rootObject(), "parent"); - QQmlProperty prop(d->qmlObject->rootObject(), "anchors.fill"); - prop.write(expr.evaluate()); -} - -QUrl WidgetExplorer::source() const -{ - return d->qmlObject->source(); -} - void WidgetExplorer::setContainment(Plasma::Containment *containment) { if (d->containment != containment) { @@ -402,7 +337,6 @@ void WidgetExplorer::setContainment(Plasma::Containment *containment) connect(d->containment, SIGNAL(destroyed(QObject*)), this, SLOT(containmentDestroyed())); connect(d->containment, SIGNAL(immutabilityChanged(Plasma::Types::ImmutabilityType)), this, SLOT(immutabilityChanged(Plasma::Types::ImmutabilityType))); - setLocation(containment->location()); } d->initRunningApplets(); diff --git a/src/shell/widgetexplorer/widgetexplorer.h b/src/shell/widgetexplorer/widgetexplorer.h index 00a9607e2..e40b984b0 100644 --- a/src/shell/widgetexplorer/widgetexplorer.h +++ b/src/shell/widgetexplorer/widgetexplorer.h @@ -24,7 +24,7 @@ #define WIDGETEXPLORER_H #include -#include +#include #include "plasmaappletitemmodel_p.h" @@ -50,7 +50,7 @@ Q_SIGNALS: void separatorChanged(); }; -class WidgetExplorer : public QQuickItem +class WidgetExplorer : public QObject { Q_OBJECT @@ -75,37 +75,14 @@ class WidgetExplorer : public QQuickItem */ Q_PROPERTY(QList extraActions READ extraActions NOTIFY extraActionsChanged) - /** - * Plasma location of the panel containment the controller is associated to - */ - Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged) - Q_ENUMS(Location) - - /** - * Orientation the controller will be disaplayed, depends from location - */ - 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); + explicit WidgetExplorer(QObject *parent = 0); ~WidgetExplorer(); QString application(); - /** - * Sets the path of the QML file to parse and execute - * - * @param path the absolute path of a QML file - */ - void setSource(const QUrl &source); - - /** - * @return the absolute path of the current QML file - */ - QUrl source() const; - /** * Populates the widget list for the given application. This must be called * before the widget explorer will be usable as the widget list will remain @@ -132,11 +109,6 @@ public: Plasma::Corona *corona() const; - void setLocation(const Plasma::Types::Location loc); - Plasma::Types::Location location() const; - - Qt::Orientation orientation() const; - DesktopView *desktopView(); void setDesktopView(DesktopView *view); @@ -155,8 +127,6 @@ public: //Q_INVOKABLE QPoint tooltipPosition(QGraphicsObject *item, int tipWidth, int tipHeight); Q_SIGNALS: - void locationChanged(Plasma::Types::Location loc); - void orientationChanged(); void widgetsMenuActionsChanged(); void extraActionsChanged(); void closed();