From 262dfa6b09ced0242d92c197e64430169f0124c1 Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Wed, 27 Mar 2019 09:14:16 +0200 Subject: [PATCH] Indicators protocol change attributes to level --introduce a new class called level which contains all the needed information concerning indicator level and at the same time the bridge that provides information for the specific indicator states --- .../package/contents/ui/applet/AppletItem.qml | 12 ++++-- .../ui/applet/indicator/LevelOptions.qml | 39 +++++++++++++++++++ .../contents/ui/applet/indicator/Loader.qml | 8 ++-- .../contents/ui/indicators/Manager.qml | 9 +++-- .../components/IndicatorItem.qml | 4 +- .../org.kde.latte.plasma/package/ui/main.qml | 4 +- .../org.kde.latte.unity/package/ui/main.qml | 4 +- .../package/contents/ui/task/TaskItem.qml | 12 ++++-- .../ui/task/indicator/LevelOptions.qml | 39 +++++++++++++++++++ .../contents/ui/task/indicator/Loader.qml | 8 ++-- 10 files changed, 111 insertions(+), 28 deletions(-) create mode 100644 containment/package/contents/ui/applet/indicator/LevelOptions.qml create 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 d0631032a..d0955982d 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -507,8 +507,10 @@ Item { //! Indicator Back Layer Indicator.Loader{ id: indicatorBackLayer - bridge: indicatorBridge - isBackground: true + level: Indicator.LevelOptions { + isBackground: true + bridge: indicatorBridge + } } ItemWrapper{ @@ -541,8 +543,10 @@ Item { //! Indicator Front Layer Indicator.Loader{ id: indicatorFrontLayer - bridge: indicatorBridge - isBackground: false + level: Indicator.LevelOptions { + isForeground: true + bridge: indicatorBridge + } } //! Applet Shortcut Visual Badge diff --git a/containment/package/contents/ui/applet/indicator/LevelOptions.qml b/containment/package/contents/ui/applet/indicator/LevelOptions.qml new file mode 100644 index 000000000..31e4d5ee3 --- /dev/null +++ b/containment/package/contents/ui/applet/indicator/LevelOptions.qml @@ -0,0 +1,39 @@ +/* +* 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.latte 0.2 as Latte + +Item { + id: level + + property bool isBackground: true + property bool isForeground: false + + property Item bridge + + onIsBackgroundChanged: { + isForeground = !isBackground; + } + + onIsForegroundChanged: { + isBackground = !isForeground; + } +} diff --git a/containment/package/contents/ui/applet/indicator/Loader.qml b/containment/package/contents/ui/applet/indicator/Loader.qml index 0d5756dc3..7cf9362e4 100644 --- a/containment/package/contents/ui/applet/indicator/Loader.qml +++ b/containment/package/contents/ui/applet/indicator/Loader.qml @@ -21,11 +21,11 @@ import QtQuick 2.7 import org.kde.latte 0.2 as Latte -Loader{ +Loader { id: indicatorLoader anchors.fill: parent - active: bridge && bridge.active && (isBackground || (isForeground && indicators.info.providesFrontLayer)) + active: level.bridge && level.bridge.active && (level.isBackground || (level.isForeground && indicators.info.providesFrontLayer)) sourceComponent: { if (!indicators.enabledForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { return indicators.plasmaStyleComponent; @@ -34,7 +34,5 @@ Loader{ return indicators.indicatorComponent; } - property bool isBackground: true - readonly property bool isForeground: !isBackground - property Item bridge + property Item level } diff --git a/containment/package/contents/ui/indicators/Manager.qml b/containment/package/contents/ui/indicators/Manager.qml index e666f6da5..2117be696 100644 --- a/containment/package/contents/ui/indicators/Manager.qml +++ b/containment/package/contents/ui/indicators/Manager.qml @@ -61,10 +61,11 @@ Item{ opacity: 0 active: managerIndicator.isEnabled - readonly property bool isBackground: true - readonly property bool isForeground: false - readonly property Item bridge: AppletIndicator.Bridge{ - appletIsValid: false + readonly property Item level: AppletIndicator.LevelOptions { + isBackground: true + bridge: AppletIndicator.Bridge{ + appletIsValid: false + } } sourceComponent: managerIndicator.indicatorComponent diff --git a/declarativeimports/components/IndicatorItem.qml b/declarativeimports/components/IndicatorItem.qml index f48921a80..0787eb48e 100644 --- a/declarativeimports/components/IndicatorItem.qml +++ b/declarativeimports/components/IndicatorItem.qml @@ -20,6 +20,6 @@ import QtQuick 2.7 Item { - readonly property Item indicator: parent && parent.hasOwnProperty("bridge") ? parent.bridge : null - readonly property Item attributes: parent + readonly property Item level: parent && parent.hasOwnProperty("level") ? parent.level : null + readonly property Item indicator: parent && parent.hasOwnProperty("level") ? parent.level.bridge : null } diff --git a/indicators/org.kde.latte.plasma/package/ui/main.qml b/indicators/org.kde.latte.plasma/package/ui/main.qml index 08cafdcaf..5ad6884e5 100644 --- a/indicators/org.kde.latte.plasma/package/ui/main.qml +++ b/indicators/org.kde.latte.plasma/package/ui/main.qml @@ -31,7 +31,7 @@ LatteComponents.IndicatorItem { Loader{ id: backLayer anchors.fill: parent - active: attributes.isBackground + active: level.isBackground sourceComponent: BackLayer{} } @@ -40,7 +40,7 @@ LatteComponents.IndicatorItem { Loader{ id: frontLayer anchors.fill: parent - active: attributes.isForeground && !indicator.isApplet && indicator.isGroup + active: level.isForeground && !indicator.isApplet && indicator.isGroup sourceComponent: FrontLayer{} } diff --git a/indicators/org.kde.latte.unity/package/ui/main.qml b/indicators/org.kde.latte.unity/package/ui/main.qml index 46e0c08a3..440be7605 100644 --- a/indicators/org.kde.latte.unity/package/ui/main.qml +++ b/indicators/org.kde.latte.unity/package/ui/main.qml @@ -55,7 +55,7 @@ LatteComponents.IndicatorItem { Loader{ id: backLayer anchors.fill: parent - active: attributes.isBackground + active: level.isBackground sourceComponent: BackLayer{} } @@ -64,7 +64,7 @@ LatteComponents.IndicatorItem { Loader{ id: frontLayer anchors.fill: parent - active: attributes.isForeground + active: level.isForeground sourceComponent:FrontLayer{} } diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index 468de34be..430177a09 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -427,16 +427,20 @@ MouseArea{ Indicator.Loader{ id: indicatorBackLayer - bridge: indicatorBridge - isBackground: true + level: Indicator.LevelOptions { + isBackground: true + bridge: indicatorBridge + } } Wrapper{id: wrapper} Indicator.Loader{ id: indicatorFrontLayer - bridge: indicatorBridge - isBackground: false + level: Indicator.LevelOptions { + isForeground: true + bridge: indicatorBridge + } } } diff --git a/plasmoid/package/contents/ui/task/indicator/LevelOptions.qml b/plasmoid/package/contents/ui/task/indicator/LevelOptions.qml new file mode 100644 index 000000000..31e4d5ee3 --- /dev/null +++ b/plasmoid/package/contents/ui/task/indicator/LevelOptions.qml @@ -0,0 +1,39 @@ +/* +* 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.latte 0.2 as Latte + +Item { + id: level + + property bool isBackground: true + property bool isForeground: false + + property Item bridge + + onIsBackgroundChanged: { + isForeground = !isBackground; + } + + onIsForegroundChanged: { + isBackground = !isForeground; + } +} diff --git a/plasmoid/package/contents/ui/task/indicator/Loader.qml b/plasmoid/package/contents/ui/task/indicator/Loader.qml index a7df7364a..cc0781f18 100644 --- a/plasmoid/package/contents/ui/task/indicator/Loader.qml +++ b/plasmoid/package/contents/ui/task/indicator/Loader.qml @@ -34,11 +34,7 @@ Loader { anchors.horizontalCenter: !root.vertical ? parent.horizontalCenter : undefined anchors.verticalCenter: root.vertical ? parent.verticalCenter : undefined - property bool isBackground: true - readonly property bool isForeground: !isBackground - property Item bridge - - active: bridge && bridge.active && (isBackground || (isForeground && indicators.info.providesFrontLayer)) + active: level.bridge && level.bridge.active && (level.isBackground || (level.isForeground && indicators.info.providesFrontLayer)) sourceComponent: indicators.indicatorComponent width: { @@ -61,4 +57,6 @@ Loader { property real visualLockedWidth: root.iconSize + root.internalWidthMargins property real visualLockedHeight: root.iconSize + root.internalHeightMargins + + property Item level }