make the c++ widget explorer a pure import
This commit is contained in:
parent
d0fd982933
commit
10a1a422e9
@ -39,8 +39,10 @@ Item {
|
||||
property Item getWidgetsButton
|
||||
property Item categoryButton
|
||||
|
||||
signal closed()
|
||||
|
||||
WidgetExplorer {
|
||||
id:widgetExplorer
|
||||
id: widgetExplorer
|
||||
desktopView: desktop
|
||||
}
|
||||
|
||||
@ -214,7 +216,7 @@ Item {
|
||||
}
|
||||
PlasmaComponents.ToolButton {
|
||||
iconSource: "window-close"
|
||||
onClicked: widgetExplorer.close()
|
||||
onClicked: main.closed()
|
||||
}
|
||||
}
|
||||
Component.onCompleted: {
|
||||
@ -236,7 +238,7 @@ Item {
|
||||
PlasmaComponents.ToolButton {
|
||||
anchors.right: parent.right
|
||||
iconSource: "window-close"
|
||||
onClicked: widgetExplorer.close()
|
||||
onClicked: main.closed()
|
||||
}
|
||||
PlasmaComponents.TextField {
|
||||
anchors {
|
||||
|
@ -32,17 +32,16 @@ Rectangle {
|
||||
|
||||
property Item containment
|
||||
|
||||
function toggleWidgetExplorer(explorerObject) {
|
||||
function toggleWidgetExplorer() {
|
||||
console.log("Widget Explorer toggled");
|
||||
|
||||
sidePanelStack.pop(blankPage);
|
||||
|
||||
if (sidePanelStack.state == "widgetExplorer") {
|
||||
explorerObject.close();
|
||||
sidePanelStack.state = "closed";
|
||||
} else {
|
||||
sidePanelStack.push(Qt.resolvedUrl("../explorer/WidgetExplorer.qml"));
|
||||
explorerObject.closed.connect(function(){sidePanelStack.state = "closed";});
|
||||
var page = sidePanelStack.push(Qt.resolvedUrl("../explorer/WidgetExplorer.qml"));
|
||||
page.closed.connect(function(){sidePanelStack.state = "closed";});
|
||||
sidePanelStack.state = "widgetExplorer";
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,6 @@ public:
|
||||
Private(ShellCorona *corona)
|
||||
: q(corona),
|
||||
desktopWidget(QApplication::desktop()),
|
||||
widgetExplorer(nullptr),
|
||||
activityController(new KActivities::Controller(q)),
|
||||
activityConsumer(new KActivities::Consumer(q))
|
||||
{
|
||||
@ -66,7 +65,6 @@ public:
|
||||
QString shell;
|
||||
QDesktopWidget * desktopWidget;
|
||||
QList <DesktopView *> views;
|
||||
QPointer<WidgetExplorer> widgetExplorer;
|
||||
KActivities::Controller *activityController;
|
||||
KActivities::Consumer *activityConsumer;
|
||||
QHash <Plasma::Containment *, PanelView *> panelViews;
|
||||
@ -459,39 +457,22 @@ void ShellCorona::updateScreenOwner(int wasScreen, int isScreen, Plasma::Contain
|
||||
void ShellCorona::handleContainmentAdded(Plasma::Containment* c)
|
||||
{
|
||||
connect(c, &Plasma::Containment::showAddWidgetsInterface,
|
||||
this, &ShellCorona::showWidgetExplorer);
|
||||
this, &ShellCorona::toggleWidgetExplorer);
|
||||
connect(c, &QObject::destroyed, [=] (QObject *o) {
|
||||
d->loadingDesktops.remove(static_cast<Plasma::Containment *>(o));
|
||||
});
|
||||
}
|
||||
|
||||
void ShellCorona::showWidgetExplorer()
|
||||
void ShellCorona::toggleWidgetExplorer()
|
||||
{
|
||||
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();
|
||||
d->widgetExplorer.data()->setSource(QUrl::fromLocalFile(expqml));
|
||||
}
|
||||
Plasma::Containment *c = 0;
|
||||
c = dynamic_cast<Plasma::Containment*>(sender());
|
||||
if (c) {
|
||||
qDebug() << "Found containment.";
|
||||
d->widgetExplorer.data()->setContainment(c);
|
||||
} else {
|
||||
// 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())));
|
||||
view->rootObject()->metaObject()->invokeMethod(view->rootObject(), "toggleWidgetExplorer");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
void ShellCorona::toggleActivityManager()
|
||||
|
@ -127,7 +127,7 @@ private Q_SLOTS:
|
||||
void checkLoadingDesktopsComplete();
|
||||
void createWaitingPanels();
|
||||
void handleContainmentAdded(Plasma::Containment *c);
|
||||
void showWidgetExplorer();
|
||||
void toggleWidgetExplorer();
|
||||
void toggleActivityManager();
|
||||
void syncAppConfig();
|
||||
void setDashboardShown(bool show);
|
||||
|
@ -347,7 +347,7 @@ DesktopView *WidgetExplorer::desktopView()
|
||||
}
|
||||
|
||||
void WidgetExplorer::setDesktopView(DesktopView *view)
|
||||
{qWarning()<<"AAAAAAAAAAAAAAAAAAAAAAA"<<view;
|
||||
{
|
||||
d->desktopView = view;
|
||||
if (view) {
|
||||
setContainment(view->containment());
|
||||
|
Loading…
x
Reference in New Issue
Block a user