From 0d568c81d5cbd7aeb41a1328fae0f0cbf7b8433b Mon Sep 17 00:00:00 2001 From: Michail Vourlakos Date: Sun, 17 Mar 2019 13:47:39 +0200 Subject: [PATCH] update indicators architecture to be independent --first steps in order to support completely independent indicators that can be downloaded/installed/used online --- .../contents/ui/applet/indicator/Manager.qml | 24 ++-- .../contents/ui/indicators/Manager.qml | 49 +++++++++ .../contents/ui/indicators/options/Common.qml | 35 ++++++ .../contents/ui/indicators/options/Latte.qml | 37 +++++++ .../contents/ui/indicators/options/Plasma.qml | 30 +++++ containment/package/contents/ui/main.qml | 24 ++-- liblatte2/qml/indicators/LatteIndicator.qml | 104 +++++++++--------- liblatte2/qml/indicators/PlasmaIndicator.qml | 54 ++++----- liblatte2/qml/indicators/UnityIndicator.qml | 46 ++++---- .../contents/ui/indicators/Manager.qml | 49 +++++++++ .../contents/ui/indicators/options/Common.qml | 35 ++++++ .../contents/ui/indicators/options/Latte.qml | 37 +++++++ plasmoid/package/contents/ui/main.qml | 18 ++- .../contents/ui/task/indicator/Manager.qml | 20 +--- 14 files changed, 405 insertions(+), 157 deletions(-) create mode 100644 containment/package/contents/ui/indicators/Manager.qml create mode 100644 containment/package/contents/ui/indicators/options/Common.qml create mode 100644 containment/package/contents/ui/indicators/options/Latte.qml create mode 100644 containment/package/contents/ui/indicators/options/Plasma.qml create mode 100644 plasmoid/package/contents/ui/indicators/Manager.qml create mode 100644 plasmoid/package/contents/ui/indicators/options/Common.qml create mode 100644 plasmoid/package/contents/ui/indicators/options/Latte.qml diff --git a/containment/package/contents/ui/applet/indicator/Manager.qml b/containment/package/contents/ui/applet/indicator/Manager.qml index 654764c5e..427b53216 100644 --- a/containment/package/contents/ui/applet/indicator/Manager.qml +++ b/containment/package/contents/ui/applet/indicator/Manager.qml @@ -25,15 +25,15 @@ Item{ id: indicatorManager anchors.fill: parent - readonly property bool active: (root.indicatorsEnabled && appletItem.communicatorAlias.activeIndicatorEnabled && root.indicatorsForApplets) - || (!root.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) + readonly property bool active: (indicators.common.indicatorsEnabled && appletItem.communicatorAlias.activeIndicatorEnabled && indicators.common.indicatorsForApplets) + || (!indicators.common.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) readonly property Component sourceComponent: { - if (!root.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { + if (!indicators.common.indicatorsForApplets && appletItem.communicatorAlias.overlayLatteIconIsActive) { return plasmaStyleIndicator; } - switch (root.indicatorStyle) { + switch (indicators.common.indicatorStyle) { case Latte.Types.LatteIndicator: return latteStyleIndicator; case Latte.Types.PlasmaIndicator: @@ -72,22 +72,14 @@ Item{ readonly property real scaleFactor: appletItem.wrapperAlias.zoomScale readonly property color shadowColor: root.appShadowColorSolid - readonly property bool dotsOnActive: root.dotsOnActive - readonly property bool multiColorEnabled: root.threeColorsWindows - readonly property bool reversedEnabled: root.reverseLinesPosition - readonly property int activeIndicatorType: root.activeIndicatorType - readonly property bool usePlasmaTabsStyle: !root.indicatorsForApplets - - //!glow options - readonly property bool glowEnabled: root.showGlow - readonly property int glowOption: root.glowOption - readonly property real glowOpacity: root.glowOpacity - readonly property bool glow3D: root.glow3D - //!icon colors property color backgroundColor: appletItem.wrapperAlias.overlayIconLoader.backgroundColor property color glowColor: appletItem.wrapperAlias.overlayIconLoader.glowColor + //! grouped options + readonly property Item common: indicators.common + readonly property Item explicit: indicators.explicit + Component { id: latteStyleIndicator Latte.LatteIndicator{} diff --git a/containment/package/contents/ui/indicators/Manager.qml b/containment/package/contents/ui/indicators/Manager.qml new file mode 100644 index 000000000..3f01cc466 --- /dev/null +++ b/containment/package/contents/ui/indicators/Manager.qml @@ -0,0 +1,49 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +import "options" as Options + +Item{ + id: manager + + readonly property Item common: commonOptions + readonly property Item explicit: explicitOptions.active ? explicitOptions.item : emptyExplicitOptions + + Options.Common { + id: commonOptions + } + + Loader{ + id: explicitOptions + active: commonOptions.indicatorStyle === Latte.Types.LatteIndicator + source: "options/Latte.qml" + } + + Item { + id: emptyExplicitOptions + } +} + diff --git a/containment/package/contents/ui/indicators/options/Common.qml b/containment/package/contents/ui/indicators/options/Common.qml new file mode 100644 index 000000000..f52a308ed --- /dev/null +++ b/containment/package/contents/ui/indicators/options/Common.qml @@ -0,0 +1,35 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +Item{ + id: common + + readonly property bool indicatorsEnabled: plasmoid.configuration.indicatorsEnabled + readonly property bool indicatorsForApplets: plasmoid.configuration.indicatorsForApplets + readonly property bool reversedEnabled: plasmoid.configuration.reverseLinesPosition + + readonly property int indicatorStyle: plasmoid.configuration.indicatorStyle +} diff --git a/containment/package/contents/ui/indicators/options/Latte.qml b/containment/package/contents/ui/indicators/options/Latte.qml new file mode 100644 index 000000000..25c38a66d --- /dev/null +++ b/containment/package/contents/ui/indicators/options/Latte.qml @@ -0,0 +1,37 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +Item{ + readonly property bool dotsOnActive: plasmoid.configuration.dotsOnActive + readonly property bool multiColorEnabled: plasmoid.configuration.threeColorsWindows + readonly property int activeIndicatorType: plasmoid.configuration.activeIndicatorType + + //!glow options + readonly property bool glowEnabled: plasmoid.configuration.showGlow + readonly property bool glow3D: plasmoid.configuration.glow3D + readonly property int glowOption: plasmoid.configuration.glowOption + readonly property real glowOpacity: plasmoid.configuration.glowOpacity/100 +} diff --git a/containment/package/contents/ui/indicators/options/Plasma.qml b/containment/package/contents/ui/indicators/options/Plasma.qml new file mode 100644 index 000000000..bb29671e1 --- /dev/null +++ b/containment/package/contents/ui/indicators/options/Plasma.qml @@ -0,0 +1,30 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +Item{ + readonly property bool usePlasmaTabsStyle: !commonOptions.indicatorsForApplets +} + diff --git a/containment/package/contents/ui/main.qml b/containment/package/contents/ui/main.qml index f32034af8..b45d26107 100644 --- a/containment/package/contents/ui/main.qml +++ b/containment/package/contents/ui/main.qml @@ -34,7 +34,7 @@ import org.kde.latte 0.2 as Latte import "applet" as Applet import "colorizer" as Colorizer import "editmode" as EditMode - +import "indicators" as Indicators import "../code/LayoutManager.js" as LayoutManager DragDrop.DropArea { @@ -317,7 +317,7 @@ DragDrop.DropArea { property int lengthIntMargin: lengthIntMarginFactor * root.iconSize property int lengthExtMargin: lengthExtMarginFactor * root.iconSize - property real lengthIntMarginFactor: plasmoid.configuration.indicatorsEnabled ? plasmoid.configuration.lengthIntMargin / 100 : 0 + property real lengthIntMarginFactor: indicators.common.indicatorsEnabled ? plasmoid.configuration.lengthIntMargin / 100 : 0 property real lengthExtMarginFactor: plasmoid.configuration.lengthExtMargin / 100 property real thickMarginFactor: { @@ -367,7 +367,9 @@ DragDrop.DropArea { property Item toolBox property Item latteAppletContainer property Item latteApplet - property Item parabolicManager: _parabolicManager + readonly property Item indicatorsManager: indicators + readonly property Item parabolicManager: _parabolicManager + property QtObject latteView: null property QtObject shortcutsEngine: null @@ -383,10 +385,6 @@ DragDrop.DropArea { property bool enableShadows: plasmoid.configuration.shadows || (root.forceTransparentPanel && plasmoid.configuration.shadows>0) property bool dockIsHidden: latteView ? latteView.visibility.isHidden : true property bool groupTasksByDefault: plasmoid.configuration.groupTasksByDefault - property bool dotsOnActive: plasmoid.configuration.dotsOnActive - property bool reverseLinesPosition: plasmoid.configuration.reverseLinesPosition - property bool showGlow: plasmoid.configuration.showGlow - property bool glow3D: plasmoid.configuration.glow3D property bool showInfoBadge: plasmoid.configuration.showInfoBadge property bool showProgressBadge: plasmoid.configuration.showProgressBadge @@ -399,17 +397,11 @@ DragDrop.DropArea { property bool showOnlyCurrentDesktop: plasmoid.configuration.showOnlyCurrentDesktop property bool showOnlyCurrentActivity: plasmoid.configuration.showOnlyCurrentActivity - property bool threeColorsWindows: plasmoid.configuration.threeColorsWindows property bool titleTooltips: plasmoid.configuration.titleTooltips property bool unifiedGlobalShortcuts: plasmoid.configuration.unifiedGlobalShortcuts readonly property bool hasInternalSeparator: latteApplet ? latteApplet.hasInternalSeparator : false - property bool indicatorsEnabled: plasmoid.configuration.indicatorsEnabled - property bool indicatorsForApplets: plasmoid.configuration.indicatorsForApplets - property int indicatorStyle: plasmoid.configuration.indicatorStyle - property int activeIndicatorType: plasmoid.configuration.activeIndicatorType - property int animationStep: { if (!universalSettings || universalSettings.mouseSensitivity === Latte.Types.HighSensitivity) { return 1; @@ -419,8 +411,6 @@ DragDrop.DropArea { return Math.max(5, root.iconSize / 10); } } - property int glowOption: plasmoid.configuration.glowOption - property real glowOpacity: plasmoid.configuration.glowOpacity/100 property int latteAppletHoveredIndex: latteApplet ? latteApplet.hoveredIndex : -1 property int launchersGroup: plasmoid.configuration.launchersGroup @@ -1712,6 +1702,10 @@ DragDrop.DropArea { id: _parabolicManager } + Indicators.Manager{ + id: indicators + } + ///////////////END components PlasmaCore.ColorScope{ diff --git a/liblatte2/qml/indicators/LatteIndicator.qml b/liblatte2/qml/indicators/LatteIndicator.qml index b32aa5a81..cccafe312 100644 --- a/liblatte2/qml/indicators/LatteIndicator.qml +++ b/liblatte2/qml/indicators/LatteIndicator.qml @@ -32,23 +32,23 @@ import "../code/ColorizerTools.js" as ColorizerTools Item{ id: indicatorRoot + readonly property Item options: parent.manager readonly property real factor: 0.08 - readonly property int size: factor * parentItem.currentIconSize - readonly property int extraMaskThickness: parentItem.reversedEnabled && parentItem.glowEnabled ? 1.7 * (factor * parentItem.maxIconSize) : 0 - readonly property Item parentItem: parent.manager + readonly property int size: factor * options.currentIconSize + readonly property int extraMaskThickness: options.common.reversedEnabled && options.explicit.glowEnabled ? 1.7 * (factor * options.maxIconSize) : 0 property real textColorBrightness: ColorizerTools.colorBrightness(theme.textColor) property color isActiveColor: theme.buttonFocusColor property color minimizedColor: { - if (parentItem.multiColorEnabled) { + if (options.explicit.multiColorEnabled) { return (textColorBrightness > 127.5 ? Qt.darker(theme.textColor, 1.7) : Qt.lighter(theme.textColor, 7)); } return isActiveColor; } - property color notActiveColor: parentItem.isMinimized ? minimizedColor : isActiveColor + property color notActiveColor: options.isMinimized ? minimizedColor : isActiveColor /*Rectangle{ anchors.fill: parent @@ -71,47 +71,47 @@ Item{ Latte.GlowPoint{ id:firstPoint opacity: { - if (parentItem.isTask) { - return parentItem.isLauncher || (parentItem.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 + if (options.isTask) { + return options.isLauncher || (options.inRemoving && !activeAndReverseAnimation.running) ? 0 : 1 } - if (parentItem.isApplet) { - return (parentItem.isActive || activeAndReverseAnimation.running) ? 1 : 0 + if (options.isApplet) { + return (options.isActive || activeAndReverseAnimation.running) ? 1 : 0 } } - basicColor: parentItem.isActive || (parentItem.isGroup && parentItem.hasShown) ? indicatorRoot.isActiveColor : indicatorRoot.notActiveColor + basicColor: options.isActive || (options.isGroup && options.hasShown) ? indicatorRoot.isActiveColor : indicatorRoot.notActiveColor size: indicatorRoot.size - glow3D: parentItem.glow3D - animation: Math.max(1.65*3*units.longDuration,parentItem.durationTime*3*units.longDuration) + glow3D: options.explicit.glow3D + animation: Math.max(1.65*3*units.longDuration,options.durationTime*3*units.longDuration) location: plasmoid.location - glowOpacity: parentItem.glowOpacity - contrastColor: parentItem.shadowColor + glowOpacity: options.explicit.glowOpacity + contrastColor: options.shadowColor attentionColor: theme.negativeTextColor roundCorners: true - showAttention: parentItem.inAttention + showAttention: options.inAttention showGlow: { - if (parentItem.glowEnabled && (parentItem.glowOption === Latte.Types.GlowAll || showAttention )) + if (options.explicit.glowEnabled && (options.explicit.glowOption === Latte.Types.GlowAll || showAttention )) return true; - else if (parentItem.glowEnabled && parentItem.glowOption === Latte.Types.GlowOnlyOnActive && parentItem.hasActive) + else if (options.explicit.glowEnabled && options.explicit.glowOption === Latte.Types.GlowOnlyOnActive && options.hasActive) return true; else return false; } - showBorder: parentItem.glowEnabled && parentItem.glow3D + showBorder: options.explicit.glowEnabled && options.explicit.glow3D - property int stateWidth: parentItem.isGroup ? indicatorRoot.width - secondPoint.width : indicatorRoot.width - spacer.width - property int stateHeight: parentItem.isGroup ? indicatorRoot.height - secondPoint.height : indicatorRoot.width - spacer.height + property int stateWidth: options.isGroup ? indicatorRoot.width - secondPoint.width : indicatorRoot.width - spacer.width + property int stateHeight: options.isGroup ? indicatorRoot.height - secondPoint.height : indicatorRoot.width - spacer.height - property int animationTime: parentItem.durationTime* (0.7*units.longDuration) + property int animationTime: options.durationTime* (0.7*units.longDuration) - property bool isActive: parentItem.hasActive || parentItem.isActive + property bool isActive: options.hasActive || options.isActive property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical - property real scaleFactor: parentItem.scaleFactor + property real scaleFactor: options.scaleFactor function updateInitialSizes(){ if(indicatorRoot){ @@ -120,12 +120,12 @@ Item{ else height = indicatorRoot.size; - if(vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) + if(vertical && isActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator) height = stateHeight; else height = indicatorRoot.size; - if(!vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) + if(!vertical && isActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator) width = stateWidth; else width = indicatorRoot.size; @@ -134,26 +134,26 @@ Item{ onIsActiveChanged: { - if (parentItem.activeIndicatorType === Latte.Types.LineIndicator) + if (options.explicit.activeIndicatorType === Latte.Types.LineIndicator) activeAndReverseAnimation.start(); } onScaleFactorChanged: { - if(!activeAndReverseAnimation.running && !vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator){ + if(!activeAndReverseAnimation.running && !vertical && isActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator){ width = stateWidth; } - else if (!activeAndReverseAnimation.running && vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator){ + else if (!activeAndReverseAnimation.running && vertical && isActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator){ height = stateHeight; } } onStateWidthChanged:{ - if(!activeAndReverseAnimation.running && !vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) + if(!activeAndReverseAnimation.running && !vertical && isActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator) width = stateWidth; } onStateHeightChanged:{ - if(!activeAndReverseAnimation.running && vertical && isActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) + if(!activeAndReverseAnimation.running && vertical && isActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator) height = stateHeight; } @@ -162,18 +162,18 @@ Item{ Component.onCompleted: { updateInitialSizes(); - parentItem.onCurrentIconSizeChanged.connect(updateInitialSizes); + options.onCurrentIconSizeChanged.connect(updateInitialSizes); } Component.onDestruction: { - parentItem.onCurrentIconSizeChanged.disconnect(updateInitialSizes); + options.onCurrentIconSizeChanged.disconnect(updateInitialSizes); } NumberAnimation{ id: activeAndReverseAnimation target: firstPoint property: plasmoid.formFactor === PlasmaCore.Types.Vertical ? "height" : "width" - to: parentItem.hasActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator + to: options.hasActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator ? (plasmoid.formFactor === PlasmaCore.Types.Vertical ? firstPoint.stateHeight : firstPoint.stateWidth) : indicatorRoot.size duration: firstPoint.animationTime easing.type: Easing.InQuad @@ -194,32 +194,32 @@ Item{ height: width size: indicatorRoot.size - glow3D: parentItem.glow3D - animation: Math.max(1.65*3*units.longDuration,parentItem.durationTime*3*units.longDuration) + glow3D: options.explicit.glow3D + animation: Math.max(1.65*3*units.longDuration,options.durationTime*3*units.longDuration) location: plasmoid.location - glowOpacity: parentItem.glowOpacity - contrastColor: parentItem.shadowColor - showBorder: parentItem.glowEnabled && parentItem.glow3D + glowOpacity: options.explicit.glowOpacity + contrastColor: options.shadowColor + showBorder: options.explicit.glowEnabled && options.explicit.glow3D basicColor: state2Color roundCorners: true - showGlow: parentItem.glowEnabled && parentItem.glowOption === Latte.Types.GlowAll - visible: ( parentItem.isGroup && ((parentItem.dotsOnActive && parentItem.activeIndicatorType === Latte.Types.LineIndicator) - || parentItem.activeIndicatorType === Latte.Types.DotIndicator - || !parentItem.hasActive) )? true: false + showGlow: options.explicit.glowEnabled && options.explicit.glowOption === Latte.Types.GlowAll + visible: ( options.isGroup && ((options.explicit.dotsOnActive && options.explicit.activeIndicatorType === Latte.Types.LineIndicator) + || options.explicit.activeIndicatorType === Latte.Types.DotIndicator + || !options.hasActive) )? true: false //when there is no active window - property color state1Color: parentItem.hasShown ? indicatorRoot.isActiveColor : indicatorRoot.minimizedColor + property color state1Color: options.hasShown ? indicatorRoot.isActiveColor : indicatorRoot.minimizedColor //when there is active window - property color state2Color: parentItem.hasMinimized ? indicatorRoot.minimizedColor : indicatorRoot.isActiveColor + property color state2Color: options.hasMinimized ? indicatorRoot.minimizedColor : indicatorRoot.isActiveColor } } states: [ State { name: "left" - when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.LeftEdge && !options.common.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.RightEdge && options.common.reversedEnabled)) AnchorChanges { target: mainIndicatorElement @@ -229,8 +229,8 @@ Item{ }, State { name: "bottom" - when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.BottomEdge && !options.common.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.TopEdge && options.common.reversedEnabled)) AnchorChanges { target: mainIndicatorElement @@ -240,8 +240,8 @@ Item{ }, State { name: "top" - when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.TopEdge && !options.common.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.BottomEdge && options.common.reversedEnabled)) AnchorChanges { target: mainIndicatorElement @@ -251,8 +251,8 @@ Item{ }, State { name: "right" - when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) || - (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) + when: ((plasmoid.location === PlasmaCore.Types.RightEdge && !options.common.reversedEnabled) || + (plasmoid.location === PlasmaCore.Types.LeftEdge && options.common.reversedEnabled)) AnchorChanges { target: mainIndicatorElement diff --git a/liblatte2/qml/indicators/PlasmaIndicator.qml b/liblatte2/qml/indicators/PlasmaIndicator.qml index c894af87c..b82ecd35a 100644 --- a/liblatte2/qml/indicators/PlasmaIndicator.qml +++ b/liblatte2/qml/indicators/PlasmaIndicator.qml @@ -24,7 +24,7 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.latte 0.2 as Latte Item { - readonly property Item parentItem: parent.manager + readonly property Item options: parent.manager readonly property Item rootItem: parent readonly property bool providesFrontLayer: true @@ -39,31 +39,31 @@ Item { id: frame property string basePrefix: "normal" - imagePath: parentItem.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" + imagePath: options.explicit.usePlasmaTabsStyle ? "widgets/tabbar" : "widgets/tasks" prefix: { - if (parentItem.usePlasmaTabsStyle) { - if (!parentItem.isActive) { + if (options.explicit.usePlasmaTabsStyle) { + if (!options.isActive) { return ""; } - if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.RightEdge && options.common.reversedEnabled)) { return "west-active-tab"; } - if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.TopEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.BottomEdge && options.common.reversedEnabled)) { return "north-active-tab"; } - if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.RightEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.LeftEdge && options.common.reversedEnabled)) { return "east-active-tab"; } - if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.TopEdge && options.common.reversedEnabled)) { return "south-active-tab"; } @@ -76,23 +76,23 @@ Item { function taskPrefix(prefix) { var effectivePrefix; - if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.RightEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.LeftEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.RightEdge && options.common.reversedEnabled)) { effectivePrefix = "west-" + prefix; } - if ((plasmoid.location === PlasmaCore.Types.TopEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.BottomEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.TopEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.BottomEdge && options.common.reversedEnabled)) { effectivePrefix = "north-" + prefix; } - if ((plasmoid.location === PlasmaCore.Types.RightEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.LeftEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.RightEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.LeftEdge && options.common.reversedEnabled)) { effectivePrefix = "east-" + prefix; } - if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !parentItem.reversedEnabled) - || (plasmoid.location === PlasmaCore.Types.TopEdge && parentItem.reversedEnabled)) { + if ((plasmoid.location === PlasmaCore.Types.BottomEdge && !options.common.reversedEnabled) + || (plasmoid.location === PlasmaCore.Types.TopEdge && options.common.reversedEnabled)) { effectivePrefix = "south-" + prefix; } @@ -102,7 +102,7 @@ Item { states: [ State { name: "launcher" - when: parentItem.isLauncher || (parentItem.isApplet && !parentItem.isActive) + when: options.isLauncher || (options.isApplet && !options.isActive) PropertyChanges { target: frame @@ -111,7 +111,7 @@ Item { }, State { name: "hovered" - when: parentItem.isHovered && frame.hasElementPrefix("hover") + when: options.isHovered && frame.hasElementPrefix("hover") PropertyChanges { target: frame @@ -120,7 +120,7 @@ Item { }, State { name: "attention" - when: parentItem.inAttention + when: options.inAttention PropertyChanges { target: frame @@ -129,7 +129,7 @@ Item { }, State { name: "minimized" - when: parentItem.isMinimized + when: options.isMinimized PropertyChanges { target: frame @@ -138,7 +138,7 @@ Item { }, State { name: "active" - when: parentItem.isActive + when: options.isActive PropertyChanges { target: frame @@ -153,7 +153,7 @@ Item { Loader{ id: frontLayer anchors.fill: parent - active: !rootItem.isBackLayer && !parentItem.isApplet && parentItem.isGroup + active: !rootItem.isBackLayer && !options.isApplet && options.isGroup sourceComponent: Item { anchors.fill: parent @@ -166,7 +166,7 @@ Item { Item { id: iconBox anchors.centerIn: parent - width: parentItem.currentIconSize + width: options.currentIconSize height: width } diff --git a/liblatte2/qml/indicators/UnityIndicator.qml b/liblatte2/qml/indicators/UnityIndicator.qml index 3d42c19c1..23137abb3 100644 --- a/liblatte2/qml/indicators/UnityIndicator.qml +++ b/liblatte2/qml/indicators/UnityIndicator.qml @@ -29,7 +29,7 @@ import "../code/ColorizerTools.js" as ColorizerTools Item{ id: indicatorItem - readonly property Item parentItem: parent.manager + readonly property Item options: parent.manager readonly property Item rootItem: parent readonly property bool needsIconColors: true @@ -37,8 +37,8 @@ Item{ readonly property int thickness: plasmoid.formFactor === PlasmaCore.Types.Vertical ? width : height - readonly property int shownWindows: parentItem.windowsCount - parentItem.windowsMinimizedCount - readonly property int maxDrawnMinimizedWindows: shownWindows > 0 ? Math.min(parentItem.windowsMinimizedCount,2) : 3 + readonly property int shownWindows: options.windowsCount - options.windowsMinimizedCount + readonly property int maxDrawnMinimizedWindows: shownWindows > 0 ? Math.min(options.windowsMinimizedCount,2) : 3 readonly property real backColorBrightness: ColorizerTools.colorBrightness(theme.backgroundColor) readonly property color backgroundColor: backColorBrightness < 127 ? theme.backgroundColor : theme.textColor @@ -52,20 +52,20 @@ Item{ sourceComponent: Item{ Item{ id: rectangleItem - width: parentItem.isTask ? Math.min(parent.width, parent.height) : parent.width - height: parentItem.isTask ? width : parent.height + width: options.isTask ? Math.min(parent.width, parent.height) : parent.width + height: options.isTask ? width : parent.height anchors.centerIn: parent - property bool isActive: parentItem.isActive || (parentItem.isWindow && parentItem.hasActive) + property bool isActive: options.isActive || (options.isWindow && options.hasActive) readonly property int size: Math.min(parent.width, parent.height) Rectangle { id: unityRect anchors.fill: parent - visible: parentItem.isActive || (parentItem.isWindow && parentItem.hasShown) + visible: options.isActive || (options.isWindow && options.hasShown) - radius: parentItem.currentIconSize / 12 - color: parentItem.backgroundColor + radius: options.currentIconSize / 12 + color: options.backgroundColor clip: true } @@ -80,11 +80,11 @@ Item{ gradient: Gradient { GradientStop { position: 0.0; color: { - if (parentItem.isMinimized) { + if (options.isMinimized) { return "#aafcfcfc"; } - return parentItem.glowColor; + return options.glowColor; } } GradientStop { position: 0.6; color: "transparent" } @@ -93,7 +93,7 @@ Item{ states: [ State { name: "top" - when: !parentItem.reversedEnabled + when: !options.common.reversedEnabled AnchorChanges { target: glowGradient @@ -102,7 +102,7 @@ Item{ }, State { name: "bottom" - when: parentItem.reversedEnabled + when: options.common.reversedEnabled AnchorChanges { target: glowGradient @@ -126,7 +126,7 @@ Item{ states: [ State { name: "top" - when: !parentItem.reversedEnabled + when: !options.common.reversedEnabled AnchorChanges { target: glowMaskRect @@ -139,7 +139,7 @@ Item{ }, State { name: "bottom" - when: parentItem.reversedEnabled + when: options.common.reversedEnabled AnchorChanges { target: glowMaskRect @@ -166,7 +166,7 @@ Item{ Rectangle { id: borderRectangle anchors.fill: parent - visible: (parentItem.isTask && parentItem.isWindow) || (parentItem.isApplet && parentItem.isActive) + visible: (options.isTask && options.isWindow) || (options.isApplet && options.isActive) color: "transparent" border.width: 1 border.color: "#303030" @@ -203,15 +203,15 @@ Item{ readonly property bool reversed: true Repeater { - model: parentItem.isTask && (parentItem.isActive || parentItem.hasActive) ? 1 : 0 + model: options.isTask && (options.isActive || options.hasActive) ? 1 : 0 delegate: triangleComponent } } Grid { id: lowerIndicators - rows: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? 1 : Math.min(3, parentItem.windowsCount) - columns: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? Math.min(3, parentItem.windowsCount) : 1 + rows: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? 1 : Math.min(3, options.windowsCount) + columns: plasmoid.formFactor === PlasmaCore.Types.Horizontal ? Math.min(3, options.windowsCount) : 1 rowSpacing: 2 columnSpacing: 2 @@ -219,7 +219,7 @@ Item{ readonly property bool reversed: false Repeater { - model: Math.min(3, parentItem.windowsCount) + model: Math.min(3, options.windowsCount) delegate: triangleComponent } } @@ -230,7 +230,7 @@ Item{ id: triangleComponent Canvas { id: canvas - width: parentItem.currentIconSize / 6 + width: options.currentIconSize / 6 height: width rotation: { @@ -261,9 +261,9 @@ Item{ property color drawColor: theme.buttonFocusColor; property bool fillTriangle: { - if (!parent.alwaysActive && parentItem.windowsMinimizedCount!==0 + if (!parent.alwaysActive && options.windowsMinimizedCount!==0 && ((index < maxDrawnMinimizedWindows) - || (parentItem.windowsCount === parentItem.windowsMinimizedCount))) { + || (options.windowsCount === options.windowsMinimizedCount))) { return false; } diff --git a/plasmoid/package/contents/ui/indicators/Manager.qml b/plasmoid/package/contents/ui/indicators/Manager.qml new file mode 100644 index 000000000..3f01cc466 --- /dev/null +++ b/plasmoid/package/contents/ui/indicators/Manager.qml @@ -0,0 +1,49 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +import "options" as Options + +Item{ + id: manager + + readonly property Item common: commonOptions + readonly property Item explicit: explicitOptions.active ? explicitOptions.item : emptyExplicitOptions + + Options.Common { + id: commonOptions + } + + Loader{ + id: explicitOptions + active: commonOptions.indicatorStyle === Latte.Types.LatteIndicator + source: "options/Latte.qml" + } + + Item { + id: emptyExplicitOptions + } +} + diff --git a/plasmoid/package/contents/ui/indicators/options/Common.qml b/plasmoid/package/contents/ui/indicators/options/Common.qml new file mode 100644 index 000000000..1b487a494 --- /dev/null +++ b/plasmoid/package/contents/ui/indicators/options/Common.qml @@ -0,0 +1,35 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +Item{ + id: common + + readonly property bool indicatorsEnabled: true + readonly property bool indicatorsForApplets: plasmoid.configuration.indicatorsForApplets + readonly property bool reversedEnabled: plasmoid.configuration.reverseLinesPosition + + readonly property int indicatorStyle: Latte.Types.LatteIndicator +} diff --git a/plasmoid/package/contents/ui/indicators/options/Latte.qml b/plasmoid/package/contents/ui/indicators/options/Latte.qml new file mode 100644 index 000000000..76bacd217 --- /dev/null +++ b/plasmoid/package/contents/ui/indicators/options/Latte.qml @@ -0,0 +1,37 @@ +/* +* 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 org.kde.latte 0.2 as Latte + +Item{ + readonly property bool dotsOnActive: plasmoid.configuration.dotsOnActive + readonly property bool multiColorEnabled: plasmoid.configuration.threeColorsWindows + readonly property int activeIndicatorType: Latte.Types.LineIndicator + + //!glow options + readonly property bool glowEnabled: plasmoid.configuration.showGlow + readonly property bool glow3D: false + readonly property int glowOption: Latte.Types.GlowAll + readonly property real glowOpacity: 0.35 +} diff --git a/plasmoid/package/contents/ui/main.qml b/plasmoid/package/contents/ui/main.qml index 2410f0c9b..d8bf63345 100644 --- a/plasmoid/package/contents/ui/main.qml +++ b/plasmoid/package/contents/ui/main.qml @@ -157,10 +157,6 @@ Item { plasmoid.configuration.highlightWindows property bool mouseWheelActions: latteView ? latteView.mouseWheelActions : true property bool parabolicEffectEnabled: latteView ? latteView.parabolicEffectEnabled : zoomFactor>1 && !root.editMode - property bool reverseLinesPosition: latteView ? latteView.reverseLinesPosition : plasmoid.configuration.reverseLinesPosition - property bool dotsOnActive: latteView ? latteView.dotsOnActive : plasmoid.configuration.dotsOnActive - property bool showGlow: latteView ? latteView.showGlow : plasmoid.configuration.showGlow - property bool glow3D: latteView ? latteView.glow3D : false property bool showInfoBadge: latteView ? latteView.showInfoBadge : plasmoid.configuration.showInfoBadge property bool showProgressBadge: latteView ? latteView.showProgressBadge : plasmoid.configuration.showInfoBadge @@ -174,21 +170,15 @@ Item { property bool showWindowActions: latteView ? latteView.showWindowActions : plasmoid.configuration.showWindowActions property bool showWindowsOnlyFromLaunchers: latteView ? latteView.showWindowsOnlyFromLaunchers : false - property bool threeColorsWindows: latteView ? latteView.threeColorsWindows : plasmoid.configuration.threeColorsWindows property bool titleTooltips: latteView ? latteView.titleTooltips : false property alias windowPreviewIsShown: windowsPreviewDlg.visible - property bool indicatorsEnabled: latteView ? latteView.indicatorsEnabled : true - property int indicatorStyle: latteView ? latteView.indicatorStyle : Latte.Types.LatteIndicator - property int activeIndicatorType: latteView ? latteView.activeIndicatorType : Latte.Types.LineIndicator property int animationStep: latteView ? latteView.animationStep : 1 property int directRenderAnimationTime: latteView ? latteView.directRenderAnimationTime : 0 property int dockHoveredIndex : latteView ? latteView.hoveredIndex : -1 property int iconSize: latteView ? latteView.iconSize : Math.max(plasmoid.configuration.iconSize, 16) property int maxIconSize: latteView ? latteView.maxIconSize : iconSize - property int glowOption: latteView ? latteView.glowOption : Latte.Types.GlowAll - property real glowOpacity: latteView ? latteView.glowOpacity : 0.35 property int leftClickAction: latteView ? latteView.leftClickAction : Latte.Types.PresentWindows property int middleClickAction: latteView ? latteView.middleClickAction : plasmoid.configuration.middleClickAction @@ -247,6 +237,7 @@ Item { property var managedLayoutName: currentLayout ? currentLayout.name : "" property Item latteView: null + readonly property Item indicators: latteView ? latteView.indicatorsManager : indicatorsStandaloneLoader.item //END Latte Dock Panel properties //BEGIN Latte Dock Communicator @@ -355,6 +346,13 @@ Item { PlasmaCore.ColorScope{ id: colorScopePalette } + + Loader { + id: indicatorsStandaloneLoader + active: !latteView + source: "indicators/Manager.qml" + } + ///// function initializeHoveredIndex() { diff --git a/plasmoid/package/contents/ui/task/indicator/Manager.qml b/plasmoid/package/contents/ui/task/indicator/Manager.qml index 1a0a5dced..2e3bedc80 100644 --- a/plasmoid/package/contents/ui/task/indicator/Manager.qml +++ b/plasmoid/package/contents/ui/task/indicator/Manager.qml @@ -25,7 +25,7 @@ import org.kde.latte 0.2 as Latte Item { id: indicatorManager - readonly property bool active: root.indicatorsEnabled + readonly property bool active: indicators.common.indicatorsEnabled readonly property bool locked: inAttentionAnimation || inNewWindowAnimation /* Indicators Properties in order for indicators to use them*/ @@ -56,24 +56,16 @@ Item { readonly property real scaleFactor: taskItem.wrapperAlias.mScale readonly property color shadowColor: root.appShadowColorSolid - readonly property bool dotsOnActive: root.dotsOnActive - readonly property bool multiColorEnabled: root.threeColorsWindows - readonly property bool reversedEnabled: root.reverseLinesPosition - readonly property int activeIndicatorType: root.activeIndicatorType - readonly property bool usePlasmaTabsStyle: false - - //!glow options - readonly property bool glowEnabled: root.showGlow - readonly property int glowOption: root.glowOption - readonly property real glowOpacity: root.glowOpacity - readonly property bool glow3D: root.glow3D - //!icon colors property color backgroundColor: taskItem.wrapperAlias.backgroundColor property color glowColor: taskItem.wrapperAlias.glowColor + //! grouped options + readonly property Item common: indicators.common + readonly property Item explicit: indicators.explicit + readonly property Component sourceComponent: { - switch (root.indicatorStyle) { + switch (indicators.common.indicatorStyle) { case Latte.Types.LatteIndicator: return latteIndicatorComponent; case Latte.Types.PlasmaIndicator: