From 4152535e5115663912f3cc94de7bf772455fd08d Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 2 Jan 2017 12:02:35 +0200 Subject: [PATCH] expose dock settings into tasks plasmoid --- app/dockview.cpp | 36 ++++++++++++++++++++++++++++ app/dockview.h | 1 + containment/contents/ui/main.qml | 4 ++++ plasmoid/contents/ui/ContextMenu.qml | 36 +++++++++++++++++++++++++--- 4 files changed, 74 insertions(+), 3 deletions(-) diff --git a/app/dockview.cpp b/app/dockview.cpp index 16390ed05..cc9dde755 100644 --- a/app/dockview.cpp +++ b/app/dockview.cpp @@ -33,6 +33,7 @@ #include #include +#include #include #include @@ -567,6 +568,41 @@ void DockView::restoreConfig() // setAlignment(static_cast(readEntry("alignment", Dock::Center).toInt())); } +QVariantList DockView::containmentActions() +{ + QVariantList actions; + + /*if (containment()->corona()->immutability() != Plasma::Types::Mutable) { + return actions; + }*/ + + //FIXME: the trigger string it should be better to be supported this way + //const QString trigger = Plasma::ContainmentActions::eventToString(event); + const QString trigger = "RightButton;NoModifier"; + + Plasma::ContainmentActions *plugin = containment()->containmentActions().value(trigger); + + if (!plugin) { + return actions; + } + + if (plugin->containment() != containment()) { + plugin->setContainment(containment()); + + // now configure it + KConfigGroup cfg(containment()->corona()->config(), "ActionPlugins"); + cfg = KConfigGroup(&cfg, QString::number(containment()->containmentType())); + KConfigGroup pluginConfig = KConfigGroup(&cfg, trigger); + plugin->restore(pluginConfig); + } + + foreach (QAction *ac, plugin->contextualActions()) { + actions << QVariant::fromValue(ac); + } + + return actions; +} + } //!END SLOTS //!END namespace diff --git a/app/dockview.h b/app/dockview.h index 6ca543bbd..66ee2a7d5 100644 --- a/app/dockview.h +++ b/app/dockview.h @@ -103,6 +103,7 @@ public: public slots: Q_INVOKABLE void addNewDock(); + Q_INVOKABLE QVariantList containmentActions(); //used from the configuration window Q_INVOKABLE QList freeEdges() const; Q_INVOKABLE void initialize(); diff --git a/containment/contents/ui/main.qml b/containment/contents/ui/main.qml index b24c304ee..8a322769e 100644 --- a/containment/contents/ui/main.qml +++ b/containment/contents/ui/main.qml @@ -732,6 +732,10 @@ DragDrop.DropArea { root.clearZoomSignal(); } + function containmentActions(){ + return dock.containmentActions(); + } + function containsMouse(){ var result = root.outsideContainsMouse(); diff --git a/plasmoid/contents/ui/ContextMenu.qml b/plasmoid/contents/ui/ContextMenu.qml index dc77710c4..dc3ec103d 100644 --- a/plasmoid/contents/ui/ContextMenu.qml +++ b/plasmoid/contents/ui/ContextMenu.qml @@ -590,12 +590,10 @@ PlasmaComponents.ContextMenu { onClicked: tasksModel.requestRemoveLauncher(visualParent.m.LauncherUrlWithoutIcon); } - - - PlasmaComponents.MenuItem { property QtObject configureAction: null + visible: !nowDockPanel enabled: configureAction && configureAction.enabled text: configureAction ? configureAction.text : "" @@ -606,6 +604,37 @@ PlasmaComponents.ContextMenu { Component.onCompleted: configureAction = plasmoid.action("configure") } + PlasmaComponents.MenuItem { + id: containmentMenuItem + + visible: nowDockPanel + enabled: visible + + icon: "latte-dock" + text: "Latte" + + PlasmaComponents.ContextMenu { + id: containmentSubMenu + + visualParent: containmentMenuItem.action + + function refresh() { + clearMenuItems(); + + var actionList = nowDockPanel.containmentActions(); + + for (var i=0; i