From ac890e2a3e3a610fd12817dfb246ae4164a612ab Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Tue, 26 Jan 2021 19:58:40 +0200 Subject: [PATCH] plasmoid:use all new AbilityClient.Indicators --- .../abilities/client/Indicators.qml | 71 +++++++++++++++++++ .../client/indicators/LatteConfiguration.qml | 16 ++--- .../client/indicators}/LatteIndicator.qml | 67 +++++++++++------ declarativeimports/abilities/client/qmldir | 1 + .../package/contents/ui/AppletAbilities.qml | 6 ++ .../contents/ui/indicators/Manager.qml | 65 ----------------- plasmoid/package/contents/ui/main.qml | 7 -- .../package/contents/ui/task/IconItem.qml | 4 +- .../package/contents/ui/task/TaskItem.qml | 2 +- 9 files changed, 134 insertions(+), 105 deletions(-) create mode 100644 declarativeimports/abilities/client/Indicators.qml rename plasmoid/package/contents/ui/indicators/options/Latte.qml => declarativeimports/abilities/client/indicators/LatteConfiguration.qml (70%) rename {plasmoid/package/contents/ui/indicators/styles => declarativeimports/abilities/client/indicators}/LatteIndicator.qml (77%) delete mode 100644 plasmoid/package/contents/ui/indicators/Manager.qml diff --git a/declarativeimports/abilities/client/Indicators.qml b/declarativeimports/abilities/client/Indicators.qml new file mode 100644 index 000000000..9596b358d --- /dev/null +++ b/declarativeimports/abilities/client/Indicators.qml @@ -0,0 +1,71 @@ +/* +* Copyright 2021 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.0 + +import org.kde.latte.abilities.definition 0.1 as AbilityDefinition + +import "./indicators" as LocalIndicator + +AbilityDefinition.Indicators { + property Item bridge: null + + isEnabled: ref.indicators.isEnabled + type: ref.indicators.type + info: ref.indicators.info + configuration: ref.indicators.configuration + resources: ref.indicators.resources + indicatorComponent: ref.indicators.indicatorComponent + + Item { + id: ref + readonly property Item indicators: bridge ? bridge.indicators : local + } + + readonly property AbilityDefinition.Indicators local: AbilityDefinition.Indicators { + isEnabled: true + type: "org.kde.latte.default" + + info.needsIconColors: false + info.needsMouseEventCoordinates: false + info.providesFrontLayer: false + info.providesHoveredAnimation: false + info.providesClickedAnimation: false + info.extraMaskThickness: 0 + info.lengthPadding: 0.08 + info.minThicknessPadding: 0 + info.minLengthPadding:0 + + configuration: localLatteConfiguration + resources: null + + indicatorComponent: latteLocalIndicator + + //! Local Latte Indicator Configuration + LocalIndicator.LatteConfiguration{ + id: localLatteConfiguration + } + + //! Local Latte Indicator implementation + Component { + id: latteLocalIndicator + LocalIndicator.LatteIndicator{} + } + } +} diff --git a/plasmoid/package/contents/ui/indicators/options/Latte.qml b/declarativeimports/abilities/client/indicators/LatteConfiguration.qml similarity index 70% rename from plasmoid/package/contents/ui/indicators/options/Latte.qml rename to declarativeimports/abilities/client/indicators/LatteConfiguration.qml index 0fb76ac36..055def6fa 100644 --- a/plasmoid/package/contents/ui/indicators/options/Latte.qml +++ b/declarativeimports/abilities/client/indicators/LatteConfiguration.qml @@ -19,19 +19,17 @@ import QtQuick 2.7 -import org.kde.plasma.plasmoid 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore - Item{ readonly property string styleName: "Latte" - readonly property bool extraDotOnActive: plasmoid.configuration.dotsOnActive - readonly property bool minimizedTaskColoredDifferently: plasmoid.configuration.threeColorsWindows readonly property int activeStyle: 0 //LineIndicator - - //!glow options - readonly property bool glowEnabled: plasmoid.configuration.showGlow - readonly property bool glow3D: false + readonly property bool minimizedTaskColoredDifferently: false + readonly property bool extraDotOnActive: false + readonly property bool glowEnabled: false + readonly property bool enabledForApplets: true readonly property int glowApplyTo: 2 /*All*/ + readonly property bool glow3D: true readonly property real glowOpacity: 0.35 + readonly property real lengthPadding: 0.08 + readonly property bool reversed: false } diff --git a/plasmoid/package/contents/ui/indicators/styles/LatteIndicator.qml b/declarativeimports/abilities/client/indicators/LatteIndicator.qml similarity index 77% rename from plasmoid/package/contents/ui/indicators/styles/LatteIndicator.qml rename to declarativeimports/abilities/client/indicators/LatteIndicator.qml index 8f11c9024..c2af12989 100644 --- a/plasmoid/package/contents/ui/indicators/styles/LatteIndicator.qml +++ b/declarativeimports/abilities/client/indicators/LatteIndicator.qml @@ -25,14 +25,20 @@ import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.latte.core 0.2 as LatteCore import org.kde.latte.components 1.0 as LatteComponents LatteComponents.IndicatorItem{ id: root + extraMaskThickness: reversedEnabled && glowEnabled ? 1.7 * (factor * indicator.maxIconSize) : 0 + + enabledForApplets: indicator && indicator.configuration ? indicator.configuration.enabledForApplets : true + lengthPadding: indicator && indicator.configuration ? indicator.configuration.lengthPadding : 0.08 readonly property real factor: 0.08 - readonly property int size: indicator ? factor * indicator.currentIconSize : factor * 64 - readonly property int extraMaskThickness: reversedEnabled && glowEnabled ? 1.7 * (factor * indicator.maxIconSize) : 0 + readonly property int size: factor * indicator.currentIconSize + + readonly property int screenEdgeMargin: plasmoid.location === PlasmaCore.Types.Floating || reversedEnabled ? 0 : indicator.screenEdgeMargin property real textColorBrightness: colorBrightness(theme.textColor) @@ -44,24 +50,21 @@ LatteComponents.IndicatorItem{ return isActiveColor; } - property color notActiveColor: indicator && indicator.isMinimized ? minimizedColor : isActiveColor + + property color notActiveColor: indicator.isMinimized ? minimizedColor : isActiveColor //! Common Options - readonly property bool reversedEnabled: indicator && indicator.general ? indicator.general.reversed : false + readonly property bool reversedEnabled: indicator.configuration.reversed //! Configuration Options - readonly property bool configurationEnabled: (indicator!==null) - && (indicator.configuration !== null) - && (indicator.configuration.glow3D !== undefined) - - readonly property bool extraDotOnActive: configurationEnabled ? indicator.configuration.extraDotOnActive : true - readonly property bool minimizedTaskColoredDifferently: configurationEnabled ? indicator.configuration.minimizedTaskColoredDifferently : false - readonly property int activeStyle: configurationEnabled ? indicator.configuration.activeStyle : 0 /*Line*/ + readonly property bool extraDotOnActive: indicator.configuration.extraDotOnActive + readonly property bool minimizedTaskColoredDifferently: indicator.configuration.minimizedTaskColoredDifferently + readonly property int activeStyle: indicator.configuration.activeStyle //!glow options - readonly property bool glowEnabled: configurationEnabled ? indicator.configuration.glowEnabled : true - readonly property bool glow3D: configurationEnabled ? indicator.configuration.glow3D : false - readonly property int glowApplyTo: configurationEnabled ? indicator.configuration.glowApplyTo : 2 /*All*/ - readonly property real glowOpacity: configurationEnabled ? indicator.configuration.glowOpacity : 0.35 + readonly property bool glowEnabled: indicator.configuration.glowEnabled + readonly property bool glow3D: indicator.configuration.glow3D + readonly property int glowApplyTo: indicator.configuration.glowApplyTo + readonly property real glowOpacity: indicator.configuration.glowOpacity /*Rectangle{ anchors.fill: parent @@ -94,6 +97,10 @@ LatteComponents.IndicatorItem{ LatteComponents.GlowPoint{ id:firstPoint opacity: { + if (indicator.isEmptySpace) { + return 0; + } + if (indicator.isTask) { return indicator.isLauncher || (indicator.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 } @@ -107,8 +114,7 @@ LatteComponents.IndicatorItem{ size: root.size glow3D: glow3D - animation: Math.max(1.65 * 3 * appletAbilities.animations.duration.large, - 3 * indicator.durationTime * appletAbilities.animations.duration.large) + animation: Math.max(1.65*3*LatteCore.Environment.longDuration,indicator.durationTime*3*LatteCore.Environment.longDuration) location: plasmoid.location glowOpacity: root.glowOpacity contrastColor: indicator.shadowColor @@ -127,9 +133,9 @@ LatteComponents.IndicatorItem{ showBorder: glowEnabled && glow3D property int stateWidth: indicator.isGroup ? root.width - secondPoint.width : root.width - spacer.width - property int stateHeight: indicator.isGroup ? root.height - secondPoint.height : root.width - spacer.height + property int stateHeight: indicator.isGroup ? root.height - secondPoint.height : root.height - spacer.height - property int animationTime: indicator.durationTime* (0.7 * appletAbilities.animations.duration.large) + property int animationTime: indicator.durationTime* (0.7*LatteCore.Environment.longDuration) property bool isActive: indicator.hasActive || indicator.isActive @@ -223,8 +229,7 @@ LatteComponents.IndicatorItem{ size: root.size glow3D: glow3D - animation: Math.max(1.65 * 3 * appletAbilities.animations.duration.large, - 3 * indicator.durationTime * appletAbilities.animations.duration.large) + animation: Math.max(1.65*3*LatteCore.Environment.longDuration,indicator.durationTime*3*LatteCore.Environment.longDuration) location: plasmoid.location glowOpacity: root.glowOpacity contrastColor: indicator.shadowColor @@ -255,6 +260,11 @@ LatteComponents.IndicatorItem{ anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:parent.left; right:undefined;} } + PropertyChanges{ + target: mainIndicatorElement + anchors.leftMargin: root.screenEdgeMargin; anchors.rightMargin: 0; anchors.topMargin:0; anchors.bottomMargin:0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; + } }, State { name: "bottom" @@ -267,6 +277,11 @@ LatteComponents.IndicatorItem{ anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:undefined; bottom:parent.bottom; left:undefined; right:undefined;} } + PropertyChanges{ + target: mainIndicatorElement + anchors.leftMargin: 0; anchors.rightMargin: 0; anchors.topMargin:0; anchors.bottomMargin: root.screenEdgeMargin; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; + } }, State { name: "top" @@ -278,6 +293,11 @@ LatteComponents.IndicatorItem{ anchors{ verticalCenter:undefined; horizontalCenter:parent.horizontalCenter; top:parent.top; bottom:undefined; left:undefined; right:undefined;} } + PropertyChanges{ + target: mainIndicatorElement + anchors.leftMargin: 0; anchors.rightMargin: 0; anchors.topMargin: root.screenEdgeMargin; anchors.bottomMargin:0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; + } }, State { name: "right" @@ -289,6 +309,11 @@ LatteComponents.IndicatorItem{ anchors{ verticalCenter:parent.verticalCenter; horizontalCenter:undefined; top:undefined; bottom:undefined; left:undefined; right:parent.right;} } + PropertyChanges{ + target: mainIndicatorElement + anchors.leftMargin: 0; anchors.rightMargin: root.screenEdgeMargin; anchors.topMargin:0; anchors.bottomMargin:0; + anchors.horizontalCenterOffset: 0; anchors.verticalCenterOffset: 0; + } } ] } diff --git a/declarativeimports/abilities/client/qmldir b/declarativeimports/abilities/client/qmldir index 487b2abc2..124dbbe23 100644 --- a/declarativeimports/abilities/client/qmldir +++ b/declarativeimports/abilities/client/qmldir @@ -3,6 +3,7 @@ module org.kde.latte.abilities.client Animations 0.1 Animations.qml Debug 0.1 Debug.qml Indexer 0.1 Indexer.qml +Indicators 0.1 Indicators.qml Metrics 0.1 Metrics.qml MyView 0.1 MyView.qml ParabolicEffect 0.1 ParabolicEffect.qml diff --git a/plasmoid/package/contents/ui/AppletAbilities.qml b/plasmoid/package/contents/ui/AppletAbilities.qml index b2e7c858c..b3f98c5f6 100644 --- a/plasmoid/package/contents/ui/AppletAbilities.qml +++ b/plasmoid/package/contents/ui/AppletAbilities.qml @@ -37,6 +37,7 @@ Item { readonly property alias debug: _debug readonly property alias indexer: _indexer readonly property alias launchers: _launchers + readonly property alias indicators: _indicators readonly property alias metrics: _metrics readonly property alias myView: _myView readonly property alias parabolic: _parabolic @@ -60,6 +61,11 @@ Item { layout: _abilityContainer.layout } + AbilityClient.Indicators { + id: _indicators + bridge: _abilityContainer.bridge + } + Ability.Launchers { id: _launchers bridge: _abilityContainer.bridge diff --git a/plasmoid/package/contents/ui/indicators/Manager.qml b/plasmoid/package/contents/ui/indicators/Manager.qml deleted file mode 100644 index e83afe5cb..000000000 --- a/plasmoid/package/contents/ui/indicators/Manager.qml +++ /dev/null @@ -1,65 +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.plasmoid 2.0 -import org.kde.plasma.core 2.0 as PlasmaCore - -import "options" as IndicatorOptions -import "styles" as IndicatorStyles - -import org.kde.latte.abilities.items 0.1 as AbilityItem - -Item{ - id: managerIndicator - - readonly property Item configuration: explicitOptions - readonly property QtObject resources: null - - - readonly property bool isEnabled: true - readonly property string type: "org.kde.latte.default" - - readonly property Component indicatorComponent: latteStyleIndicator - - readonly property Item info: Item{ - readonly property bool needsIconColors: false - readonly property bool needsMouseEventCoordinates: false - readonly property bool providesFrontLayer: false - readonly property bool providesHoveredAnimation: false - readonly property bool providesClickedAnimation: false - readonly property int extraMaskThickness: 0 - readonly property real lengthPadding: 0.08 - readonly property real minThicknessPadding: 0 - readonly property real minLengthPadding:0 - } - - AbilityItem.IndicatorObject { - id: explicitOptions - isTask: true - } - - //! Indicators Components - Component { - id: latteStyleIndicator - IndicatorStyles.LatteIndicator{} - } -} - diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 266735507..166cfe5a7 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -202,7 +202,6 @@ Item { readonly property rect screenGeometry: latteView ? latteView.screenGeometry : plasmoid.screenGeometry property Item latteView: null - readonly property Item indicators: latteView ? latteView.indicators : indicatorsStandaloneLoader.item //END Latte Dock Panel properties readonly property bool inEditMode: latteInEditMode || plasmoid.userConfiguring @@ -302,12 +301,6 @@ Item { && (GraphicsInfo.api !== GraphicsInfo.Unknown) } - Loader { - id: indicatorsStandaloneLoader - active: !appletAbilities.myView.isReady && !plasmoid.configuration.isInLatteDock - source: "indicators/Manager.qml" - } - Binding { target: root property: "alignment" diff --git a/plasmoid/package/contents/ui/task/IconItem.qml b/plasmoid/package/contents/ui/task/IconItem.qml index 9ba595ded..9b8dfa967 100644 --- a/plasmoid/package/contents/ui/task/IconItem.qml +++ b/plasmoid/package/contents/ui/task/IconItem.qml @@ -160,7 +160,7 @@ Item{ source: decoration smooth: taskItem.abilities.parabolic.factor.zoom === 1 ? true : false - providesColors: root.indicators ? root.indicators.info.needsIconColors : false + providesColors: taskItem.abilities.indicators.info.needsIconColors opacity: root.enableShadows && taskWithShadow.active @@ -558,7 +558,7 @@ Item{ source: badgesLoader.active ? badgesLoader : iconImageBuffer visible: !isSeparator - opacity: taskItem.containsMouse && !clickedAnimation.running && !indicators.info.providesHoveredAnimation ? 1 : 0 + opacity: taskItem.containsMouse && !clickedAnimation.running && !taskItem.abilities.indicators.info.providesHoveredAnimation ? 1 : 0 brightness: 0.30 contrast: 0.1 diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index 379483854..e4cbb93ef 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -508,7 +508,7 @@ Item { id: taskIndicatorObj animations: taskItem.abilities.animations metrics: taskItem.abilities.metrics - host: root.indicators + host: taskItem.abilities.indicators isTask: true isLauncher: taskItem.isLauncher || root.disableAllWindowsFunctionality