From 50c9eed11b8f3cc1e57c4626545e38ecd9665b43 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Mon, 25 Jan 2021 19:59:45 +0200 Subject: [PATCH] upgrade plasmoid to IndicatorLevet items --plasmoid is now using the IndicatorLevel Ability Item cleanly. Now everything is ready in order to provide the full Indicators Ability. --- .../package/contents/ui/applet/AppletItem.qml | 2 - .../contents/ui/applet/IndicatorLevel.qml | 16 +++- declarativeimports/abilities/host/Debug.qml | 1 + .../abilities/items/IndicatorLevel.qml | 17 +--- .../abilities/items/IndicatorObject.qml | 4 +- .../Loader.qml => IndicatorLevel.qml} | 28 ++---- .../package/contents/ui/task/TaskItem.qml | 87 ++++++++++++------ .../contents/ui/task/indicator/Bridge.qml | 91 ------------------- .../ui/task/indicator/LevelOptions.qml | 45 --------- 9 files changed, 87 insertions(+), 204 deletions(-) rename plasmoid/package/contents/ui/task/{indicator/Loader.qml => IndicatorLevel.qml} (80%) delete mode 100644 plasmoid/package/contents/ui/task/indicator/Bridge.qml delete mode 100644 plasmoid/package/contents/ui/task/indicator/LevelOptions.qml diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index 145cc3290..359c3585a 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -792,7 +792,6 @@ Item { //! Indicator Back Layer IndicatorLevel{ id: indicatorBackLayer - visualParent: appletItem indicatorsHost: indicators level.isBackground: true level.indicator: appletIndicatorObj @@ -841,7 +840,6 @@ Item { //! Indicator Front Layer IndicatorLevel{ id: indicatorFrontLayer - visualParent: appletItem indicatorsHost: indicators level.isForeground: true level.indicator: appletIndicatorObj diff --git a/containment/package/contents/ui/applet/IndicatorLevel.qml b/containment/package/contents/ui/applet/IndicatorLevel.qml index 4370a707e..74f35b103 100644 --- a/containment/package/contents/ui/applet/IndicatorLevel.qml +++ b/containment/package/contents/ui/applet/IndicatorLevel.qml @@ -24,7 +24,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte.abilities.items 0.1 as AbilityItem AbilityItem.IndicatorLevel { - id: indicatorLoader + id: indicatorLevel anchors.bottom: (plasmoid.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined anchors.top: (plasmoid.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined anchors.left: (plasmoid.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined @@ -71,4 +71,18 @@ AbilityItem.IndicatorLevel { //! and as such always look centered even when applet are aligned to length screen edge property real visualLockedWidth: Math.min(appletItem.metrics.iconSize, appletWrapper.width) + appletItem.internalWidthMargins property real visualLockedHeight: Math.min(appletItem.metrics.iconSize, appletWrapper.height) + appletItem.internalHeightMargins + + Connections { + target: appletItem + enabled: indicatorsHost.isEnabled && indicatorsHost.info.needsMouseEventCoordinates + onMousePressed: { + var fixedPos = indicatorLevel.mapFromItem(appletItem, x, y); + indicatorLevel.level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), button); + } + + onMouseReleased: { + var fixedPos = indicatorLevel.mapFromItem(appletItem, x, y); + indicatorLevel.level.mouseReleased(Math.round(fixedPos.x), Math.round(fixedPos.y), button); + } + } } diff --git a/declarativeimports/abilities/host/Debug.qml b/declarativeimports/abilities/host/Debug.qml index a9854d691..f84d3059f 100644 --- a/declarativeimports/abilities/host/Debug.qml +++ b/declarativeimports/abilities/host/Debug.qml @@ -25,6 +25,7 @@ AbilityDefinition.Debug { id: apis readonly property Item publicApi: Item { + readonly property alias eventsSinkEnabled: apis.eventsSinkEnabled readonly property alias graphicsEnabled: apis.graphicsEnabled readonly property alias inputMaskEnabled: apis.inputMaskEnabled readonly property alias layouterEnabled: apis.layouterEnabled diff --git a/declarativeimports/abilities/items/IndicatorLevel.qml b/declarativeimports/abilities/items/IndicatorLevel.qml index b752d8d86..cffca30b6 100644 --- a/declarativeimports/abilities/items/IndicatorLevel.qml +++ b/declarativeimports/abilities/items/IndicatorLevel.qml @@ -26,25 +26,10 @@ import "./indicators" as IndicatorItem Loader { id: indicatorLevelLoader active: level.isDrawn && indicatorsHost.isEnabled && (level.isBackground || (level.isForeground && indicatorsHost.info.providesFrontLayer)) - sourceComponent: indicatorsHost.indicatorComponent + sourceComponent: indicatorsHost ? indicatorsHost.indicatorComponent : null - property Item visualParent: null property Item indicatorsHost: null readonly property IndicatorItem.LevelOptions level: IndicatorItem.LevelOptions{} - - Connections { - target: visualParent - enabled: visualParent && indicatorsHost.info.needsMouseEventCoordinates - onMousePressed: { - var fixedPos = indicatorLevelLoader.mapFromItem(appletItem, x, y); - level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), button); - } - - onMouseReleased: { - var fixedPos = indicatorLevelLoader.mapFromItem(appletItem, x, y); - level.mouseReleased(Math.round(fixedPos.x), Math.round(fixedPos.y), button); - } - } } diff --git a/declarativeimports/abilities/items/IndicatorObject.qml b/declarativeimports/abilities/items/IndicatorObject.qml index b23e68458..940490bff 100644 --- a/declarativeimports/abilities/items/IndicatorObject.qml +++ b/declarativeimports/abilities/items/IndicatorObject.qml @@ -57,8 +57,8 @@ Item{ property real panelOpacity: 1.0 property color shadowColor: "black" - property bool animationsEnabled: _indicator.animations ? indicator.animations.active : true - property real durationTime: _indicator.animations ? indicator.animations.speedFactor.current : 2 + property bool animationsEnabled: _indicator.animations ? _indicator.animations.active : true + property real durationTime: _indicator.animations ? _indicator.animations.speedFactor.current : 2 property bool progressVisible: false /*since 0.9.2*/ property real progress: 0 /*since 0.9.2*/ diff --git a/plasmoid/package/contents/ui/task/indicator/Loader.qml b/plasmoid/package/contents/ui/task/IndicatorLevel.qml similarity index 80% rename from plasmoid/package/contents/ui/task/indicator/Loader.qml rename to plasmoid/package/contents/ui/task/IndicatorLevel.qml index 51b69ba3f..bd0bd4f1d 100644 --- a/plasmoid/package/contents/ui/task/indicator/Loader.qml +++ b/plasmoid/package/contents/ui/task/IndicatorLevel.qml @@ -1,5 +1,5 @@ /* -* Copyright 2019 Michail Vourlakos +* Copyright 2021 Michail Vourlakos * * This file is part of Latte-Dock * @@ -22,8 +22,10 @@ import QtQuick 2.7 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -Loader { - id: indicatorLoader +import org.kde.latte.abilities.items 0.1 as AbilityItem + +AbilityItem.IndicatorLevel { + id: indicatorLevel anchors.bottom: (root.location === PlasmaCore.Types.BottomEdge) ? parent.bottom : undefined anchors.top: (root.location === PlasmaCore.Types.TopEdge) ? parent.top : undefined anchors.left: (root.location === PlasmaCore.Types.LeftEdge) ? parent.left : undefined @@ -32,14 +34,6 @@ Loader { anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined anchors.verticalCenter: root.vertical ? parent.verticalCenter : undefined - active: level.bridge && level.bridge.active && indicators.isEnabled && (level.isBackground || (level.isForeground && indicators.info.providesFrontLayer)) - sourceComponent: { - if (!indicators) { - return; - } - return indicators.indicatorComponent; - } - width: { if (locked) { return visualLockedWidth; @@ -56,6 +50,8 @@ Loader { return root.vertical ? taskItem.wrapper.height - 2*taskItem.wrapper.mScale*taskItem.abilities.metrics.margin.length : taskItem.wrapper.height; } + level.isDrawn: !taskItem.isSeparator && !taskItem.isHidden && indicatorsHost.isEnabled + readonly property bool locked: inAttentionAnimation || inNewWindowAnimation || inBouncingAnimation property real visualLockedWidth: root.vertical ? taskItem.abilities.metrics.margin.screenEdge + taskItem.abilities.metrics.iconSize + root.internalWidthMargins : @@ -63,19 +59,15 @@ Loader { property real visualLockedHeight: !root.vertical ? taskItem.abilities.metrics.margin.screenEdge + taskItem.abilities.metrics.iconSize + root.internalHeightMargins : taskItem.abilities.metrics.iconSize + root.internalHeightMargins - //! Connections !// - - property Item level - Connections { target: taskItem.mouseArea - enabled: indicators ? indicators.info.needsMouseEventCoordinates : false + enabled: indicatorsHost ? indicatorsHost.info.needsMouseEventCoordinates : false onPressed: { - var fixedPos = indicatorLoader.mapFromItem(taskItem, mouse.x, mouse.y); + var fixedPos = indicatorLevel.mapFromItem(taskItem, mouse.x, mouse.y); level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), mouse.button); } onReleased: { - var fixedPos = indicatorLoader.mapFromItem(taskItem, mouse.x, mouse.y); + var fixedPos = indicatorLevel.mapFromItem(taskItem, mouse.x, mouse.y); level.mousePressed(Math.round(fixedPos.x), Math.round(fixedPos.y), mouse.button); } } diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index ead13511e..37c2be046 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -31,8 +31,9 @@ import org.kde.plasma.private.taskmanager 0.1 as TaskManagerApplet import org.kde.latte.core 0.2 as LatteCore import org.kde.latte.private.tasks 0.1 as LatteTasks +import org.kde.latte.abilities.items 0.1 as AbilityItem + import "animations" as TaskAnimations -import "indicator" as Indicator Item { id: taskItem @@ -137,7 +138,7 @@ Item { property bool isForcedHidden: false property bool isLauncher: (IsLauncher === true) ? true : false property bool hasShownLauncher: (taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrl) - || taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrlWithIcon)) + || taskItem.abilities.launchers.inCurrentActivity(taskItem.launcherUrlWithIcon)) && !root.inActivityChange /*update trigger when changing current activity*/ property bool isMinimized: (IsMinimized === true) ? true : false property bool isSeparator: false @@ -166,8 +167,8 @@ Item { property int windowsMinimizedCount: subWindows.windowsMinimized //! are set by the indicator - property int iconOffsetX: 0 - property int iconOffsetY: 0 + readonly property int iconOffsetX: indicatorBackLayer.level.requested.iconOffsetX + readonly property int iconOffsetY: indicatorBackLayer.level.requested.iconOffsetY property string activity: tasksModel.activity @@ -503,29 +504,57 @@ Item { width: wrapper.width height: wrapper.height - Indicator.Bridge{ - id: indicatorBridge + AbilityItem.IndicatorObject { + id: taskIndicatorObj + animations: taskItem.abilities.animations + metrics: taskItem.abilities.metrics + indicatorsHost: root.indicators + + isTask: true + isLauncher: taskItem.isLauncher || root.disableAllWindowsFunctionality + isStartup: !root.disableAllWindowsFunctionality && taskItem.isStartup + isWindow: !root.disableAllWindowsFunctionality && taskItem.isWindow + + isActive: !root.disableAllWindowsFunctionality && (taskItem.hasActive + || (root.showPreviews + && (taskItem.isWindow || taskItem.isGroupParent) + && windowsPreviewDlg.activeItem + && (windowsPreviewDlg.activeItem === taskItem)) ) + + isGroup: !root.disableAllWindowsFunctionality && taskItem.isGroupParent + isHovered: taskItem.containsMouse + isMinimized: !root.disableAllWindowsFunctionality && taskItem.isMinimized + isPressed: taskItem.pressed + inAttention: !root.disableAllWindowsFunctionality && taskItem.inAttention + inRemoving: taskItem.inRemoveStage + + isSquare: true + + hasActive: !root.disableAllWindowsFunctionality && taskItem.hasActive + hasMinimized: !root.disableAllWindowsFunctionality && taskItem.hasMinimized + hasShown: !root.disableAllWindowsFunctionality && taskItem.hasShown + windowsCount: !root.disableAllWindowsFunctionality ? taskItem.windowsCount : 0 + windowsMinimizedCount: !root.disableAllWindowsFunctionality ? taskItem.windowsMinimizedCount : 0 + + scaleFactor: taskItem.wrapper.mScale + panelOpacity: root.currentPanelOpacity + shadowColor: root.appShadowColorSolid + + progressVisible: wrapper.progressVisible /*since 0.9.2*/ + progress: wrapper.progress /*since 0.9.2*/ + + palette: root.enforceLattePalette ? latteBridge.palette.applyTheme : theme + + iconBackgroundColor: taskItem.wrapper.backgroundColor + iconGlowColor: taskItem.wrapper.glowColor } - Indicator.Loader{ + //! Indicator Back Layer + IndicatorLevel{ id: indicatorBackLayer - level: Indicator.LevelOptions { - id: backLevelOptions - isBackground: true - bridge: indicatorBridge - - Binding { - target: taskItem - property: "iconOffsetX" - value: backLevelOptions.requested.iconOffsetX - } - - Binding { - target: taskItem - property: "iconOffsetY" - value: backLevelOptions.requested.iconOffsetY - } - } + indicatorsHost: root.indicators + level.isBackground: true + level.indicator: taskIndicatorObj Loader{ anchors.fill: parent @@ -541,12 +570,12 @@ Item { Wrapper{id: _wrapper} - Indicator.Loader{ + //! Indicator Front Layer + IndicatorLevel{ id: indicatorFrontLayer - level: Indicator.LevelOptions { - isForeground: true - bridge: indicatorBridge - } + indicatorsHost: root.indicators + level.isForeground: true + level.indicator: taskIndicatorObj } } diff --git a/plasmoid/package/contents/ui/task/indicator/Bridge.qml b/plasmoid/package/contents/ui/task/indicator/Bridge.qml deleted file mode 100644 index 75ed8cbbe..000000000 --- a/plasmoid/package/contents/ui/task/indicator/Bridge.qml +++ /dev/null @@ -1,91 +0,0 @@ -/* -* Copyright 2019 Michail Vourlakos -* -* This file is part of Latte-Dock -* -* Latte-Dock is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* Latte-Dock is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -import QtQuick 2.7 - -import org.kde.plasma.core 2.0 as PlasmaCore - -import "../../indicators/options" as TaskIndicator - -Item { - id: indicatorBridge - property bool taskIsValid: true - - readonly property bool active: indicators ? indicators.isEnabled : false - readonly property bool locked: taskIsValid ? (inAttentionAnimation || inNewWindowAnimation) : false - - /* Indicators Properties in order for indicators to use them*/ - readonly property bool isTask: true - readonly property bool isApplet: false - readonly property bool isEmptySpace: false /*since 0.9.3*/ - - readonly property bool isLauncher: taskIsValid ? taskItem.isLauncher || root.disableAllWindowsFunctionality : true - readonly property bool isStartup: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.isStartup : false - readonly property bool isWindow: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.isWindow : false - - readonly property bool isActive: taskIsValid && !root.disableAllWindowsFunctionality ? (taskItem.hasActive - || (root.showPreviews - && (taskItem.isWindow || taskItem.isGroupParent) - && windowsPreviewDlg.activeItem - && (windowsPreviewDlg.activeItem === taskItem)) ) : false - - readonly property bool isGroup: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.isGroupParent : false - readonly property bool isHovered: taskIsValid ? taskItem.containsMouse : false - readonly property bool isMinimized: taskIsValid && !root.disableAllWindowsFunctionality? taskItem.isMinimized : false - readonly property bool isPressed: taskIsValid ? taskItem.pressed : false - readonly property bool inAttention: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.inAttention : false - readonly property bool inRemoving: taskIsValid ? taskItem.inRemoveStage : false - - readonly property bool isSquare: true - - readonly property bool hasActive: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.hasActive : false - readonly property bool hasMinimized: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.hasMinimized : false - readonly property bool hasShown: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.hasShown : false - readonly property int windowsCount: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.windowsCount : 0 - readonly property int windowsMinimizedCount: taskIsValid && !root.disableAllWindowsFunctionality ? taskItem.windowsMinimizedCount : 0 - - readonly property int currentIconSize: taskIsValid ? taskItem.abilities.metrics.iconSize : metrics.iconSize - readonly property int maxIconSize: taskIsValid ? taskItem.abilities.metrics.maxIconSize : metrics.iconSize - readonly property real scaleFactor: taskIsValid ? taskItem.wrapper.mScale : 1 - readonly property real panelOpacity: root.currentPanelOpacity - readonly property color shadowColor: root.appShadowColorSolid - - readonly property bool animationsEnabled: taskIsValid ? taskItem.abilities.animations.active : appletAbilities.animations.active - readonly property real durationTime: taskIsValid ? taskItem.abilities.animations.speedFactor.current : appletAbilities.animations.speedFactor.current - - readonly property bool progressVisible: wrapper.progressVisible /*since 0.9.2*/ - readonly property real progress: wrapper.progress /*since 0.9.2*/ - - readonly property int screenEdgeMargin: taskIsValid ? taskItem.abilities.metrics.margin.screenEdge : metrics.margin.screenEdge /*since 0.10*/ - - readonly property variant svgs: indicators ? indicators.svgs : [] - - readonly property QtObject palette: enforceLattePalette ? latteBridge.palette.applyTheme : theme - - //!icon colors - property color iconBackgroundColor: taskIsValid ? taskItem.wrapper.backgroundColor : "black" - property color iconGlowColor: taskIsValid ? taskItem.wrapper.glowColor : "white" - - //! grouped options - readonly property Item shared: indicators ? indicators : emptyOptions - readonly property QtObject configuration: indicators ? indicators.configuration : null - readonly property QtObject resources: indicators ? indicators.resources : null - - Item{id: emptyOptions} -} diff --git a/plasmoid/package/contents/ui/task/indicator/LevelOptions.qml b/plasmoid/package/contents/ui/task/indicator/LevelOptions.qml deleted file mode 100644 index 8c664d5e7..000000000 --- a/plasmoid/package/contents/ui/task/indicator/LevelOptions.qml +++ /dev/null @@ -1,45 +0,0 @@ -/* -* Copyright 2019 Michail Vourlakos -* -* This file is part of Latte-Dock -* -* Latte-Dock is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License as -* published by the Free Software Foundation; either version 2 of -* the License, or (at your option) any later version. -* -* Latte-Dock is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -import QtQuick 2.7 - -Item { - id: level - - signal mousePressed(int x, int y, int button); - signal mouseReleased(int x, int y, int button); - - property bool isBackground: true - property bool isForeground: false - - readonly property Item requested: Item{ - property int iconOffsetX: 0 - property int iconOffsetY: 0 - } - - property Item bridge - - onIsBackgroundChanged: { - isForeground = !isBackground; - } - - onIsForegroundChanged: { - isBackground = !isForeground; - } -}