From b5a98f41ee9b86d96142b6136e84e47af912befa Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Fri, 3 Mar 2017 20:25:53 +0200 Subject: [PATCH] fix #188,fix launchers behavior for Plasma>=5.9 --- liblattedock/quickwindowsystem.cpp | 8 +++++++- liblattedock/quickwindowsystem.h | 5 ++++- plasmoid/contents/ui/ContextMenu.qml | 7 ++++++- plasmoid/contents/ui/main.qml | 30 ++++++++++++++++++++++++++++ 4 files changed, 47 insertions(+), 3 deletions(-) diff --git a/liblattedock/quickwindowsystem.cpp b/liblattedock/quickwindowsystem.cpp index e56bcafa8..17e87baca 100644 --- a/liblattedock/quickwindowsystem.cpp +++ b/liblattedock/quickwindowsystem.cpp @@ -19,6 +19,7 @@ */ #include "quickwindowsystem.h" +#include #include @@ -33,7 +34,7 @@ QuickWindowSystem::QuickWindowSystem(QObject *parent) : //! TODO: Wayland compositing active } else { connect(KWindowSystem::self(), &KWindowSystem::compositingChanged - , this, [&](bool enabled){ + , this, [&](bool enabled) { if (m_compositing == enabled) return; @@ -55,4 +56,9 @@ bool QuickWindowSystem::compositingActive() const return m_compositing; } +uint QuickWindowSystem::frameworksVersion() const +{ + return Plasma::version(); +} + } //end of namespace diff --git a/liblattedock/quickwindowsystem.h b/liblattedock/quickwindowsystem.h index b29b9da3c..a35ce10db 100644 --- a/liblattedock/quickwindowsystem.h +++ b/liblattedock/quickwindowsystem.h @@ -35,18 +35,21 @@ class QuickWindowSystem final : public QObject { Q_OBJECT Q_PROPERTY(bool compositingActive READ compositingActive NOTIFY compositingChanged FINAL) + Q_PROPERTY(uint frameworksVersion READ frameworksVersion NOTIFY frameworksVersionChanged) public: explicit QuickWindowSystem(QObject *parent = nullptr); virtual ~QuickWindowSystem(); bool compositingActive() const; + uint frameworksVersion() const; signals: void compositingChanged(); + void frameworksVersionChanged(); private: - bool m_compositing : 1; + bool m_compositing : 1; }; static QObject *windowsystem_qobject_singletontype_provider(QQmlEngine *engine, QJSEngine *scriptEngine) diff --git a/plasmoid/contents/ui/ContextMenu.qml b/plasmoid/contents/ui/ContextMenu.qml index 98706021d..c9e8e2212 100644 --- a/plasmoid/contents/ui/ContextMenu.qml +++ b/plasmoid/contents/ui/ContextMenu.qml @@ -571,8 +571,10 @@ PlasmaComponents.ContextMenu { onClicked: { if (tasksModel.launcherPosition(visualParent.m.LauncherUrlWithoutIcon) != -1) { tasksModel.requestRemoveLauncher(visualParent.m.LauncherUrlWithoutIcon); + root.updateLaunchersNewArchitecture(); } else { tasksModel.requestAddLauncher(visualParent.m.LauncherUrlWithoutIcon); + root.updateLaunchersNewArchitecture(); } } } @@ -595,7 +597,10 @@ PlasmaComponents.ContextMenu { text: i18n("Remove Launcher") - onClicked: tasksModel.requestRemoveLauncher(visualParent.m.LauncherUrlWithoutIcon); + onClicked: { + tasksModel.requestRemoveLauncher(visualParent.m.LauncherUrlWithoutIcon); + root.updateLaunchersNewArchitecture(); + } } PlasmaComponents.MenuItem { diff --git a/plasmoid/contents/ui/main.qml b/plasmoid/contents/ui/main.qml index dad4ea040..f0a076dc6 100644 --- a/plasmoid/contents/ui/main.qml +++ b/plasmoid/contents/ui/main.qml @@ -197,12 +197,42 @@ Item { ///// + function updateLaunchersNewArchitecture(){ + ///frameworks 5.29.0 provide id 335104 + + //work only after Plasma 5.9 and frameworks 5.29 + if (Latte.WindowSystem.frameworksVersion < 335104) { + return; + } + + var launchers = []; + var tasks = icList.contentItem.children; + + var len = tasks.length + for(var i=0; i=0) { + launchers.push(task.m.LauncherUrlWithoutIcon); + } + } + ActivitiesTools.updateLaunchers(launchers); + } + onDragSourceChanged: { if (dragSource == null) { root.draggingFinished(); root.signalActionsBlockHiding(-1); //root.signalDraggingState(false); + updateLaunchersNewArchitecture(); tasksModel.syncLaunchers(); } else { root.signalActionsBlockHiding(1);