From 52b95779ad8e1480a0d5f44dde34eefec12c0f06 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 23 Oct 2013 22:49:17 +0200 Subject: [PATCH] functionality for widget explorer is there --- .../desktop/contents/views/Desktop.qml | 59 ++++++++++++++----- src/shell/widgetexplorer/widgetexplorer.cpp | 8 ++- src/shell/widgetexplorer/widgetexplorer.h | 1 + 3 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml index 1f7149e7c..d03e90af5 100644 --- a/src/shell/qmlpackages/desktop/contents/views/Desktop.qml +++ b/src/shell/qmlpackages/desktop/contents/views/Desktop.qml @@ -33,37 +33,68 @@ Rectangle { function toggleWidgetExplorer(explorerObject) { console.log("Widget Explorer toggled"); - if (0&&sidePanel.visible) { - explorerObject.close() - sidePanel.visible = false; + sidePanelStack.pop(blankPage); + + if (sidePanelStack.state == "widgetExplorer") { + explorerObject.close(); + sidePanelStack.state = "closed"; } else { - explorerObject.parent = sidePanelStack - explorerObject.anchors.fill = parent; - sidePanel.visible = true; - sidePanel.height = containment.availableScreenRegion(containment.screen)[0].height; + sidePanelStack.push(explorerObject); + explorerObject.closed.connect(function(){sidePanelStack.state = "closed";}); + sidePanelStack.state = "widgetExplorer"; } } function toggleActivityManager() { console.log("Activity manger toggled"); - if (sidePanel.visible) { - sidePanelStack.source = ''; - sidePanel.visible = false; + sidePanelStack.pop(blankPage); + + if (sidePanelStack.state == "activitySwitcher") { + sidePanelStack.state = "closed"; } else { - sidePanelStack.source = Qt.resolvedUrl("../activityswitcher/ActivitySwitcher.qml"); - sidePanel.visible = true; - sidePanel.height = containment.availableScreenRegion(containment.screen)[0].height; + sidePanelStack.push(Qt.resolvedUrl("../activityswitcher/ActivitySwitcher.qml")); + sidePanelStack.state = "activitySwitcher"; } } PlasmaCore.Dialog { id: sidePanel location: PlasmaCore.Types.LeftEdge - mainItem: Loader { + mainItem: PlasmaComponents.PageStack { id: sidePanelStack + state: "closed" width: 250 height: 500 + initialPage: Item { + id: blankPage + } + + states: [ + State { + name: "closed" + PropertyChanges { + target: sidePanel + visible: false + } + }, + State { + name: "widgetExplorer" + PropertyChanges { + target: sidePanel + visible: true + height: containment.availableScreenRegion(containment.screen)[0].height; + } + }, + State { + name: "activitySwitcher" + PropertyChanges { + target: sidePanel + visible: true + height: containment.availableScreenRegion(containment.screen)[0].height; + } + } + ] } } diff --git a/src/shell/widgetexplorer/widgetexplorer.cpp b/src/shell/widgetexplorer/widgetexplorer.cpp index dc1668ab2..c15f955dd 100644 --- a/src/shell/widgetexplorer/widgetexplorer.cpp +++ b/src/shell/widgetexplorer/widgetexplorer.cpp @@ -23,6 +23,8 @@ #include #include +#include +#include #include #include @@ -359,6 +361,10 @@ void WidgetExplorer::setSource(const QUrl &source) 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 @@ -520,7 +526,7 @@ void WidgetExplorer::uninstall(const QString &pluginName) void WidgetExplorer::close() { - //d->qmlObject->engine()->rootContext()->setContextProperty("widgetExplorer", 0); + emit closed(); deleteLater(); } diff --git a/src/shell/widgetexplorer/widgetexplorer.h b/src/shell/widgetexplorer/widgetexplorer.h index 10b1f5e49..aebd26130 100644 --- a/src/shell/widgetexplorer/widgetexplorer.h +++ b/src/shell/widgetexplorer/widgetexplorer.h @@ -154,6 +154,7 @@ Q_SIGNALS: void orientationChanged(); void widgetsMenuActionsChanged(); void extraActionsChanged(); + void closed(); public Q_SLOTS: /**