new procedure of widget explorer
similar to activity switcher
This commit is contained in:
parent
daa747d0a6
commit
e495c7cde4
@ -24,22 +24,10 @@ import org.kde.plasma.extras 2.0 as PlasmaExtras
|
||||
import org.kde.qtextracomponents 2.0
|
||||
import QtQuick.Window 2.1
|
||||
|
||||
PlasmaCore.Dialog {
|
||||
id: dialog
|
||||
location: PlasmaCore.Types.LeftEdge
|
||||
|
||||
Component.onCompleted: dialog.visible = true;
|
||||
onVisibleChanged: {
|
||||
if (!visible) {
|
||||
widgetExplorer.close();
|
||||
}
|
||||
}
|
||||
mainItem: Item {
|
||||
Item {
|
||||
id: main
|
||||
|
||||
Text {
|
||||
text: Screen.height+" "+main.height
|
||||
}
|
||||
width: 240
|
||||
height: 800//Screen.height
|
||||
//this is used to perfectly align the filter field and delegates
|
||||
@ -371,4 +359,4 @@ PlasmaCore.Dialog {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,20 @@ Rectangle {
|
||||
|
||||
property Item containment
|
||||
|
||||
function toggleWidgetExplorer(explorerObject) {
|
||||
console.log("Widget Explorer toggled");
|
||||
|
||||
if (0&&sidePanel.visible) {
|
||||
explorerObject.close()
|
||||
sidePanel.visible = false;
|
||||
} else {
|
||||
explorerObject.parent = sidePanelStack
|
||||
explorerObject.anchors.fill = parent;
|
||||
sidePanel.visible = true;
|
||||
sidePanel.height = containment.availableScreenRegion(containment.screen)[0].height;
|
||||
}
|
||||
}
|
||||
|
||||
function toggleActivityManager() {
|
||||
console.log("Activity manger toggled");
|
||||
|
||||
|
@ -464,8 +464,10 @@ void ShellCorona::handleContainmentAdded(Plasma::Containment* c)
|
||||
|
||||
void ShellCorona::showWidgetExplorer()
|
||||
{
|
||||
QPoint cursorPos = QCursor::pos();
|
||||
foreach (DesktopView *view, d->views) {
|
||||
if (view->screen()->geometry().contains(cursorPos)) {
|
||||
if (!d->widgetExplorer) {
|
||||
|
||||
QString expqml = package().filePath("widgetexplorer");
|
||||
qDebug() << "Script to load for WidgetExplorer: " << expqml;
|
||||
d->widgetExplorer = new WidgetExplorer();
|
||||
@ -480,6 +482,13 @@ void ShellCorona::showWidgetExplorer()
|
||||
// FIXME: try harder to find a suitable containment?
|
||||
qWarning() << "containment not set, don't know where to add the applet.";
|
||||
}
|
||||
//The view QML has to provide something to display the activity explorer
|
||||
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "toggleWidgetExplorer", Q_ARG(QVariant, QVariant::fromValue(d->widgetExplorer.data())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShellCorona::toggleActivityManager()
|
||||
|
@ -302,8 +302,8 @@ void WidgetExplorerPrivate::appletRemoved(Plasma::Applet *applet)
|
||||
|
||||
//WidgetExplorer
|
||||
|
||||
WidgetExplorer::WidgetExplorer(QObject *parent)
|
||||
:QObject(parent),
|
||||
WidgetExplorer::WidgetExplorer(QQuickItem *parent)
|
||||
:QQuickItem(parent),
|
||||
d(new WidgetExplorerPrivate(this))
|
||||
{
|
||||
setLocation(Plasma::Types::LeftEdge);
|
||||
@ -326,9 +326,9 @@ void WidgetExplorer::setLocation(Plasma::Types::Location loc)
|
||||
emit(locationChanged(loc));
|
||||
}
|
||||
|
||||
WidgetExplorer::Location WidgetExplorer::location()
|
||||
Plasma::Types::Location WidgetExplorer::location() const
|
||||
{
|
||||
return (WidgetExplorer::Location)d->location;
|
||||
return d->location;
|
||||
}
|
||||
|
||||
Qt::Orientation WidgetExplorer::orientation() const
|
||||
@ -357,6 +357,8 @@ void WidgetExplorer::setSource(const QUrl &source)
|
||||
d->qmlObject->setSource(source);
|
||||
d->qmlObject->engine()->rootContext()->setContextProperty("widgetExplorer", this);
|
||||
d->qmlObject->completeInitialization();
|
||||
QQuickItem *i = qobject_cast<QQuickItem *>(d->qmlObject->rootObject());
|
||||
i->setParentItem(this);
|
||||
}
|
||||
|
||||
QUrl WidgetExplorer::source() const
|
||||
|
@ -24,7 +24,7 @@
|
||||
#define WIDGETEXPLORER_H
|
||||
|
||||
#include <QAction>
|
||||
#include <QObject>
|
||||
#include <QQuickItem>
|
||||
|
||||
#include "plasmaappletitemmodel_p.h"
|
||||
|
||||
@ -49,7 +49,7 @@ Q_SIGNALS:
|
||||
void separatorChanged();
|
||||
};
|
||||
|
||||
class WidgetExplorer : public QObject
|
||||
class WidgetExplorer : public QQuickItem
|
||||
{
|
||||
|
||||
Q_OBJECT
|
||||
@ -77,7 +77,7 @@ class WidgetExplorer : public QObject
|
||||
/**
|
||||
* Plasma location of the panel containment the controller is associated to
|
||||
*/
|
||||
Q_PROPERTY(Location location READ location NOTIFY locationChanged)
|
||||
Q_PROPERTY(Plasma::Types::Location location READ location NOTIFY locationChanged)
|
||||
Q_ENUMS(Location)
|
||||
|
||||
/**
|
||||
@ -86,23 +86,7 @@ class WidgetExplorer : public QObject
|
||||
Q_PROPERTY(Qt::Orientation orientation READ orientation NOTIFY orientationChanged)
|
||||
|
||||
public:
|
||||
/**
|
||||
* The Location enumeration describes where on screen an element, such as an
|
||||
* Applet or its managing container, is positioned on the screen.
|
||||
**/
|
||||
enum Location {
|
||||
Floating = 0, /**< Free floating. Neither geometry or z-ordering
|
||||
is described precisely by this value. */
|
||||
Desktop, /**< On the planar desktop layer, extending across
|
||||
the full screen from edge to edge */
|
||||
FullScreen, /**< Full screen */
|
||||
TopEdge, /**< Along the top of the screen*/
|
||||
BottomEdge, /**< Along the bottom of the screen*/
|
||||
LeftEdge, /**< Along the left side of the screen */
|
||||
RightEdge /**< Along the right side of the screen */
|
||||
};
|
||||
|
||||
explicit WidgetExplorer(QObject *parent = 0);
|
||||
explicit WidgetExplorer(QQuickItem *parent = 0);
|
||||
~WidgetExplorer();
|
||||
|
||||
QString application();
|
||||
@ -146,8 +130,7 @@ public:
|
||||
|
||||
|
||||
void setLocation(const Plasma::Types::Location loc);
|
||||
//FIXME: it's asymmetric due to the problems of QML of exporting enums
|
||||
WidgetExplorer::Location location();
|
||||
Plasma::Types::Location location() const;
|
||||
|
||||
Qt::Orientation orientation() const;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user