From 8be388b89321ca9880978a5e347747288a3f905b Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 17 Mar 2019 15:05:11 +0200 Subject: [PATCH] improve vastly the indicators arch independence --- .../package/contents/ui/VisibilityManager.qml | 2 +- .../package/contents/ui/applet/AppletItem.qml | 3 - .../contents/ui/applet/ItemWrapper.qml | 2 +- .../contents/ui/applet/indicator/Loader.qml | 59 +++---------------- .../contents/ui/applet/indicator/Manager.qml | 32 ---------- .../contents/ui/indicators/Manager.qml | 59 ++++++++++++++++++- .../contents/ui/indicators/Manager.qml | 36 ++++++++++- .../package/contents/ui/task/IconItem.qml | 2 +- .../package/contents/ui/task/TaskItem.qml | 3 - .../contents/ui/task/indicator/Loader.qml | 38 +----------- .../contents/ui/task/indicator/Manager.qml | 28 --------- 11 files changed, 103 insertions(+), 161 deletions(-) diff --git a/containment/package/contents/ui/VisibilityManager.qml b/containment/package/contents/ui/VisibilityManager.qml index e60f19b88..dd1c45678 100644 --- a/containment/package/contents/ui/VisibilityManager.qml +++ b/containment/package/contents/ui/VisibilityManager.qml @@ -72,7 +72,7 @@ Item{ readonly property int marginBetweenContentsAndRuler: 10 property int extraThickMask: marginBetweenContentsAndRuler + Math.max(indicatorsExtraThickMask, shadowsExtraThickMask) //! this is set from indicators when they need extra thickness mask size - property int indicatorsExtraThickMask: 0 + readonly property int indicatorsExtraThickMask: indicators.info.extraMaskThickness property int shadowsExtraThickMask: { var shadowMaxNeededMargin = 0.15 * root.maxIconSize; diff --git a/containment/package/contents/ui/applet/AppletItem.qml b/containment/package/contents/ui/applet/AppletItem.qml index f2139c8b9..9c311094e 100644 --- a/containment/package/contents/ui/applet/AppletItem.qml +++ b/containment/package/contents/ui/applet/AppletItem.qml @@ -64,9 +64,6 @@ Item { property bool appletBlocksParabolicEffect: communicator.parabolicEffectLocked property bool lockZoom: false - property bool indicatorNeedsIconColors: false - property bool indicatorProvidesFrontLayer: false - property bool isActive: (isExpanded && applet.pluginName !== root.plasmoidName && applet.pluginName !== "org.kde.activeWindowControl" diff --git a/containment/package/contents/ui/applet/ItemWrapper.qml b/containment/package/contents/ui/applet/ItemWrapper.qml index 4ddb99229..5d17a3a54 100644 --- a/containment/package/contents/ui/applet/ItemWrapper.qml +++ b/containment/package/contents/ui/applet/ItemWrapper.qml @@ -460,7 +460,7 @@ Item{ return ""; } - providesColors: appletItem.indicatorNeedsIconColors && source != "" + providesColors: indicators.info.needsIconColors && source != "" usesPlasmaTheme: communicator.appletIconItemIsShown() ? communicator.appletIconItem.usesPlasmaTheme : false Binding{ diff --git a/containment/package/contents/ui/applet/indicator/Loader.qml b/containment/package/contents/ui/applet/indicator/Loader.qml index 61f07f475..40f14a4a6 100644 --- a/containment/package/contents/ui/applet/indicator/Loader.qml +++ b/containment/package/contents/ui/applet/indicator/Loader.qml @@ -25,60 +25,15 @@ Loader{ id: indicatorLoader anchors.fill: parent - active: manager && manager.active && (isBackLayer || (!isBackLayer && indicatorProvidesFrontLayer)) - sourceComponent: manager.sourceComponent - - property bool isBackLayer: true - property Item manager - - //! Used when the indicators require more thickness in the view mask - //! e.g. when the Latte indicators are glowing in reverse order - Binding { - target: visibilityManager - property: "indicatorsExtraThickMask" - value: { - if (indicatorLoader.isBackLayer - && indicatorLoader.active - && indicatorLoader.item - && indicatorLoader.item.hasOwnProperty("extraMaskThickness")) { - return indicatorLoader.item.extraMaskThickness; - } - - return 0; + active: manager && manager.active && (isBackLayer || (!isBackLayer && indicators.info.providesFrontLayer)) + sourceComponent: { + if (!indicators.common.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { + return indicators.plasmaStyleComponent; } - } - - //! Used when the indicators need icon colors in orde to be painted - //! properly, for example the Unity indicator - Binding { - target: appletItem - property: "indicatorNeedsIconColors" - value: { - if (indicatorLoader.isBackLayer - && indicatorLoader.active - && indicatorLoader.item - && indicatorLoader.item.hasOwnProperty("needsIconColors")) { - return indicatorLoader.item.needsIconColors; - } - return false; - } + return indicators.indicatorComponent; } - //! Used when the indicators property also a front layer - //! to be drawn above the icon - Binding { - target: appletItem - property: "indicatorProvidesFrontLayer" - value: { - if (indicatorLoader.isBackLayer - && indicatorLoader.active - && indicatorLoader.item - && indicatorLoader.item.hasOwnProperty("providesFrontLayer")) { - return indicatorLoader.item.providesFrontLayer; - } - - return false; - } - } + property bool isBackLayer: true + property Item manager } diff --git a/containment/package/contents/ui/applet/indicator/Manager.qml b/containment/package/contents/ui/applet/indicator/Manager.qml index 427b53216..35dc9f492 100644 --- a/containment/package/contents/ui/applet/indicator/Manager.qml +++ b/containment/package/contents/ui/applet/indicator/Manager.qml @@ -28,23 +28,6 @@ Item{ readonly property bool active: (indicators.common.indicatorsEnabled && appletItem.communicatorAlias.activeIndicatorEnabled && indicators.common.indicatorsForApplets) || (!indicators.common.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) - readonly property Component sourceComponent: { - if (!indicators.common.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { - return plasmaStyleIndicator; - } - - switch (indicators.common.indicatorStyle) { - case Latte.Types.LatteIndicator: - return latteStyleIndicator; - case Latte.Types.PlasmaIndicator: - return plasmaStyleIndicator; - case Latte.Types.UnityIndicator: - return unityStyleIndicator; - default: - return latteStyleIndicator; - }; - } - /* Indicators Properties in order use them*/ readonly property bool isTask: false readonly property bool isApplet: true @@ -79,19 +62,4 @@ Item{ //! grouped options readonly property Item common: indicators.common readonly property Item explicit: indicators.explicit - - Component { - id: latteStyleIndicator - Latte.LatteIndicator{} - } - - Component { - id: plasmaStyleIndicator - Latte.PlasmaIndicator{} - } - - Component{ - id:unityStyleIndicator - Latte.UnityIndicator{} - } } diff --git a/containment/package/contents/ui/indicators/Manager.qml b/containment/package/contents/ui/indicators/Manager.qml index 456507a46..0b2bdcee1 100644 --- a/containment/package/contents/ui/indicators/Manager.qml +++ b/containment/package/contents/ui/indicators/Manager.qml @@ -27,11 +27,42 @@ import org.kde.latte 0.2 as Latte import "options" as Options Item{ - id: manager + id: managerIndicator readonly property Item common: commonOptions readonly property Item explicit: explicitOptions.item + readonly property Component plasmaStyleComponent: plasmaStyleIndicator + + readonly property Component indicatorComponent: { + switch (indicators.common.indicatorStyle) { + case Latte.Types.LatteIndicator: + return latteStyleIndicator; + case Latte.Types.PlasmaIndicator: + return plasmaStyleIndicator; + case Latte.Types.UnityIndicator: + return unityStyleIndicator; + default: + return latteStyleIndicator; + }; + } + + readonly property Item info: Item{ + readonly property bool needsIconColors: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("needsIconColors") + && metricsLoader.item.needsIconColors + readonly property bool providesFrontLayer: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesFrontLayer") + && metricsLoader.item.providesFrontLayer + + readonly property int extraMaskThickness: { + if (metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("extraMaskThickness")) { + return metricsLoader.item.extraMaskThickness; + } + + return 0; + } + } + + Options.Common { id: commonOptions } @@ -50,5 +81,31 @@ Item{ } } + //! Indicators Components + Component { + id: latteStyleIndicator + Latte.LatteIndicator{} + } + + Component { + id: plasmaStyleIndicator + Latte.PlasmaIndicator{} + } + + Component{ + id:unityStyleIndicator + Latte.UnityIndicator{} + } + + //! Metrics and values provided from an invisible indicator + Loader{ + id: metricsLoader + opacity: 0 + + readonly property bool isBackLayer: true + readonly property Item manager: managerIndicator + + sourceComponent: managerIndicator.indicatorComponent + } } diff --git a/plasmoid/package/contents/ui/indicators/Manager.qml b/plasmoid/package/contents/ui/indicators/Manager.qml index b711b2e9f..8df60dcab 100644 --- a/plasmoid/package/contents/ui/indicators/Manager.qml +++ b/plasmoid/package/contents/ui/indicators/Manager.qml @@ -27,11 +27,28 @@ import org.kde.latte 0.2 as Latte import "options" as Options Item{ - id: manager + id: managerIndicator readonly property Item common: commonOptions readonly property Item explicit: explicitOptions + readonly property Component indicatorComponent: latteStyleIndicator + + readonly property Item info: Item{ + readonly property bool needsIconColors: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("needsIconColors") + && metricsLoader.item.needsIconColors + readonly property bool providesFrontLayer: metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("providesFrontLayer") + && metricsLoader.item.providesFrontLayer + + readonly property int extraMaskThickness: { + if (metricsLoader.active && metricsLoader.item && metricsLoader.item.hasOwnProperty("extraMaskThickness")) { + return metricsLoader.item.extraMaskThickness; + } + + return 0; + } + } + Options.Common { id: commonOptions } @@ -40,8 +57,21 @@ Item{ id : explicitOptions } - Item { - id: emptyExplicitOptions + //! Indicators Components + Component { + id: latteStyleIndicator + Latte.LatteIndicator{} + } + + //! Metrics and values provided from an invisible indicator + Loader{ + id: metricsLoader + opacity: 0 + + readonly property bool isBackLayer: true + readonly property Item manager: managerIndicator + + sourceComponent: managerIndicator.indicatorComponent } } diff --git a/plasmoid/package/contents/ui/task/IconItem.qml b/plasmoid/package/contents/ui/task/IconItem.qml index 9b23a82c9..6563cd443 100644 --- a/plasmoid/package/contents/ui/task/IconItem.qml +++ b/plasmoid/package/contents/ui/task/IconItem.qml @@ -153,7 +153,7 @@ Item{ width: Math.round(newTempSize) //+ 2*taskIcon.shadowSize height: Math.round(width) source: decoration - providesColors: taskItem.indicatorNeedsIconColors + providesColors: indicators.info.needsIconColors opacity: root.enableShadows ? 0 : 1 visible: !taskItem.isSeparator && !badgesLoader.active diff --git a/plasmoid/package/contents/ui/task/TaskItem.qml b/plasmoid/package/contents/ui/task/TaskItem.qml index f57aacbc6..b74c65f15 100644 --- a/plasmoid/package/contents/ui/task/TaskItem.qml +++ b/plasmoid/package/contents/ui/task/TaskItem.qml @@ -104,9 +104,6 @@ MouseArea{ property bool inPopup: false property bool inRemoveStage: false - property bool indicatorNeedsIconColors: false - property bool indicatorProvidesFrontLayer: false - property bool isAbleToShowPreview: true property bool isActive: (IsActive === true) ? true : false property bool isDemandingAttention: (IsDemandingAttention === true) ? true : false diff --git a/plasmoid/package/contents/ui/task/indicator/Loader.qml b/plasmoid/package/contents/ui/task/indicator/Loader.qml index bb383fc1d..19d0eb101 100644 --- a/plasmoid/package/contents/ui/task/indicator/Loader.qml +++ b/plasmoid/package/contents/ui/task/indicator/Loader.qml @@ -36,8 +36,8 @@ Loader { property bool isBackLayer: true property Item manager - active: manager && manager.active && (isBackLayer || (!isBackLayer && taskItem.indicatorProvidesFrontLayer)) - sourceComponent: manager.sourceComponent + active: manager && manager.active && (isBackLayer || (!isBackLayer && indicators.info.providesFrontLayer)) + sourceComponent: indicators.indicatorComponent width: { if (locked) { @@ -59,38 +59,4 @@ Loader { property real visualLockedWidth: root.iconSize + root.internalWidthMargins property real visualLockedHeight: root.iconSize + root.internalHeightMargins - - //! Used when the indicators need icon colors in orde to be painted - //! properly, for example the Unity indicator - Binding { - target: taskItem - property: "indicatorNeedsIconColors" - value: { - if (indicatorLoader.isBackLayer - && indicatorLoader.active - && indicatorLoader.item - && indicatorLoader.item.hasOwnProperty("needsIconColors")) { - return indicatorLoader.item.needsIconColors; - } - - return false; - } - } - - //! Used when the indicators property also a front layer - //! to be drawn above the icon - Binding { - target: taskItem - property: "indicatorProvidesFrontLayer" - value: { - if (indicatorLoader.isBackLayer - && indicatorLoader.active - && indicatorLoader.item - && indicatorLoader.item.hasOwnProperty("providesFrontLayer")) { - return indicatorLoader.item.providesFrontLayer; - } - - return false; - } - } } diff --git a/plasmoid/package/contents/ui/task/indicator/Manager.qml b/plasmoid/package/contents/ui/task/indicator/Manager.qml index 2e3bedc80..035aaca29 100644 --- a/plasmoid/package/contents/ui/task/indicator/Manager.qml +++ b/plasmoid/package/contents/ui/task/indicator/Manager.qml @@ -63,32 +63,4 @@ Item { //! grouped options readonly property Item common: indicators.common readonly property Item explicit: indicators.explicit - - readonly property Component sourceComponent: { - switch (indicators.common.indicatorStyle) { - case Latte.Types.LatteIndicator: - return latteIndicatorComponent; - case Latte.Types.PlasmaIndicator: - return plasmaIndicatorComponent; - case Latte.Types.UnityIndicator: - return unityIndicatorComponent; - default: - return latteIndicatorComponent; - }; - } - - Component{ - id:latteIndicatorComponent - Latte.LatteIndicator{} - } - - Component{ - id: plasmaIndicatorComponent - Latte.PlasmaIndicator{} - } - - Component{ - id:unityIndicatorComponent - Latte.UnityIndicator{} - } }