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.
work/spdx
Michail Vourlakos 4 years ago
parent 6f2369962b
commit 50c9eed11b

@ -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

@ -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);
}
}
}

@ -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

@ -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);
}
}
}

@ -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*/

@ -1,5 +1,5 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
* Copyright 2021 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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);
}
}

@ -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
}
}

@ -1,91 +0,0 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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}
}

@ -1,45 +0,0 @@
/*
* Copyright 2019 Michail Vourlakos <mvourlakos@gmail.com>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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;
}
}
Loading…
Cancel
Save