containment:expose and use AbilityHost.Indicators

work/spdx
Michail Vourlakos 4 years ago
parent bdcfaae9c0
commit 962db78bb9

@ -0,0 +1,119 @@
/*
* Copyright 2021 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.plasmoid 2.0
import org.kde.latte.abilities.items 0.1 as AbilityItem
import "./privates" as Ability
Ability.IndicatorsPrivate {
configuration: view && view.indicator && view.indicator.configuration ? view.indicator.configuration : null
resources: view && view.indicator && view.indicator.resources ? view.indicator.resources : null
isEnabled: view && view.indicator ? (view.indicator.enabled
&& view.indicator.pluginIsReady
&& view.indicator.configuration)
: false
type: view && view.indicator ? view.indicator.type : "org.kde.latte.default"
indicatorComponent: view && view.indicator ? view.indicator.component : null
info {
enabledForApplets: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("enabledForApplets")
&& indicatorLevel.item.enabledForApplets
needsIconColors: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("needsIconColors")
&& indicatorLevel.item.needsIconColors
needsMouseEventCoordinates: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("needsMouseEventCoordinates")
&& indicatorLevel.item.needsMouseEventCoordinates
providesFrontLayer: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("providesFrontLayer")
&& indicatorLevel.item.providesFrontLayer
providesHoveredAnimation: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("providesHoveredAnimation")
&& indicatorLevel.item.providesHoveredAnimation
providesClickedAnimation: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("providesClickedAnimation")
&& indicatorLevel.item.providesClickedAnimation
extraMaskThickness: {
if (indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("extraMaskThickness")) {
return indicatorLevel.item.extraMaskThickness;
}
return 0;
}
minThicknessPadding: {
if (indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("minThicknessPadding")) {
return indicatorLevel.item.minThicknessPadding;
}
return 0;
}
minLengthPadding: {
if (indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("minLengthPadding")) {
return indicatorLevel.item.minLengthPadding;
}
return 0;
}
lengthPadding: {
if (indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("lengthPadding")) {
return indicatorLevel.item.lengthPadding;
}
return 0.08;
}
appletLengthPadding: {
if (indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("appletLengthPadding")) {
return indicatorLevel.item.appletLengthPadding;
}
return -1;
}
svgPaths: indicatorLevel.isLoaded && indicatorLevel.item.hasOwnProperty("svgImagePaths") ?
indicatorLevel.item.svgImagePaths : []
}
readonly property Component plasmaStyleComponent: view && view.indicator ? view.indicator.plasmaComponent : null
//! Metrics and values provided from an invisible indicator
AbilityItem.IndicatorLevel{
id: indicatorLevel
opacity: 0
level.isDrawn: true
level.isBackground: true
level.indicator: AbilityItem.IndicatorObject{
animations: root.animations
metrics: root.metrics
host: root.indicators
}
readonly property bool isLoaded: active && item
}
}

@ -0,0 +1,110 @@
/*
* Copyright 2021 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.latte.abilities.host 0.1 as AbilityHost
AbilityHost.Indicators {
id: _indicators
property QtObject view: null
Connections {
target: _indicators.info
onSvgPathsChanged: {
if (_indicators.isEnabled) {
view.indicator.resources.setSvgImagePaths(svgPaths);
}
}
}
Connections {
target:_indicators
onIsEnabledChanged: {
if (_indicators.isEnabled) {
view.indicator.resources.setSvgImagePaths(_indicators.info.svgPaths);
}
}
}
//! Bindings in order to inform View::Indicator
Binding{
target: view && view.indicator ? view.indicator : null
property:"enabledForApplets"
when: view && view.indicator
value: _indicators.info.enabledForApplets
}
//! Bindings in order to inform View::Indicator::Info
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"needsIconColors"
when: view && view.indicator
value: _indicators.info.needsIconColors
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"needsMouseEventCoordinates"
when: view && view.indicator
value: _indicators.info.needsMouseEventCoordinates
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"providesClickedAnimation"
when: view && view.indicator
value: _indicators.info.providesClickedAnimation
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"providesHoveredAnimation"
when: view && view.indicator
value: _indicators.info.providesHoveredAnimation
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"providesFrontLayer"
when: view && view.indicator
value: _indicators.info.providesFrontLayer
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"extraMaskThickness"
when: view && view.indicator
value: _indicators.info.extraMaskThickness
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"minLengthPadding"
when: view && view.indicator
value: _indicators.info.minLengthPadding
}
Binding{
target: view && view.indicator ? view.indicator.info : null
property:"minThicknessPadding"
when: view && view.indicator
value: _indicators.info.minThicknessPadding
}
}

@ -307,6 +307,7 @@ Item {
property Item animations: null
property Item debug: null
property Item indexer: null
property Item indicators: null
property Item launchers: null
property Item layouter: null
property Item layouts: null
@ -759,7 +760,7 @@ Item {
id: appletIndicatorObj
animations: appletItem.animations
metrics: appletItem.metrics
host: root.indicators
host: appletItem.indicators
isApplet: true

@ -142,6 +142,7 @@ Item{
readonly property Item actions: Actions{}
readonly property Item applet: mainCommunicator.requires
readonly property Item debug: appletItem.debug.publicApi
readonly property Item indicators: appletItem.indicators.publicApi
readonly property Item metrics: appletItem.metrics.publicApi
readonly property Item myView: appletItem.myView
readonly property Item userRequests: appletItem.userRequests

@ -1,202 +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.plasmoid 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.latte.abilities.items 0.1 as AbilityItem
Item{
id: managerIndicator
readonly property QtObject configuration: latteView && latteView.indicator && latteView.indicator.configuration ? latteView.indicator.configuration : null
readonly property QtObject resources: latteView && latteView.indicator && latteView.indicator.resources ? latteView.indicator.resources : null
readonly property bool isEnabled: latteView && latteView.indicator ? (latteView.indicator.enabled
&& latteView.indicator.pluginIsReady
&& latteView.indicator.configuration)
: false
readonly property real padding: Math.max(info.minLengthPadding, info.lengthPadding)
readonly property string type: latteView && latteView.indicator ? latteView.indicator.type : "org.kde.latte.default"
readonly property bool infoLoaded: metricsLoader.active && metricsLoader.item
readonly property Component plasmaStyleComponent: latteView && latteView.indicator ? latteView.indicator.plasmaComponent : null
readonly property Component indicatorComponent: latteView && latteView.indicator ? latteView.indicator.component : null
readonly property Item info: Item{
readonly property bool enabledForApplets: infoLoaded && metricsLoader.item.hasOwnProperty("enabledForApplets")
&& metricsLoader.item.enabledForApplets
readonly property bool needsIconColors: infoLoaded && metricsLoader.item.hasOwnProperty("needsIconColors")
&& metricsLoader.item.needsIconColors
readonly property bool needsMouseEventCoordinates: infoLoaded && metricsLoader.item.hasOwnProperty("needsMouseEventCoordinates")
&& metricsLoader.item.needsMouseEventCoordinates
readonly property bool providesFrontLayer: infoLoaded && metricsLoader.item.hasOwnProperty("providesFrontLayer")
&& metricsLoader.item.providesFrontLayer
readonly property bool providesHoveredAnimation: infoLoaded && metricsLoader.item.hasOwnProperty("providesHoveredAnimation")
&& metricsLoader.item.providesHoveredAnimation
readonly property bool providesClickedAnimation: infoLoaded && metricsLoader.item.hasOwnProperty("providesClickedAnimation")
&& metricsLoader.item.providesClickedAnimation
readonly property int extraMaskThickness: {
if (infoLoaded && metricsLoader.item.hasOwnProperty("extraMaskThickness")) {
return metricsLoader.item.extraMaskThickness;
}
return 0;
}
readonly property real minThicknessPadding: {
if (infoLoaded && metricsLoader.item.hasOwnProperty("minThicknessPadding")) {
return metricsLoader.item.minThicknessPadding;
}
return 0;
}
readonly property real minLengthPadding: {
if (infoLoaded && metricsLoader.item.hasOwnProperty("minLengthPadding")) {
return metricsLoader.item.minLengthPadding;
}
return 0;
}
readonly property real lengthPadding: {
if (infoLoaded && metricsLoader.item.hasOwnProperty("lengthPadding")) {
return metricsLoader.item.lengthPadding;
}
return 0.08;
}
readonly property real appletLengthPadding: {
if (infoLoaded && metricsLoader.item.hasOwnProperty("appletLengthPadding")) {
return metricsLoader.item.appletLengthPadding;
}
return -1;
}
readonly property variant svgPaths: infoLoaded && metricsLoader.item.hasOwnProperty("svgImagePaths") ?
metricsLoader.item.svgImagePaths : []
onSvgPathsChanged: {
if (managerIndicator.isEnabled) {
latteView.indicator.resources.setSvgImagePaths(svgPaths);
}
}
Connections {
target: managerIndicator
onIsEnabledChanged: {
if (managerIndicator.isEnabled) {
latteView.indicator.resources.setSvgImagePaths(managerIndicator.info.svgPaths);
}
}
}
}
//! Metrics and values provided from an invisible indicator
AbilityItem.IndicatorLevel{
id: metricsLoader
opacity: 0
level.isDrawn: true
level.isBackground: true
level.indicator: AbilityItem.IndicatorObject{
animations: root.animations
metrics: root.metrics
host: managerIndicator
}
}
//! Bindings in order to inform View::Indicator
Binding{
target: latteView && latteView.indicator ? latteView.indicator : null
property:"enabledForApplets"
when: latteView && latteView.indicator
value: managerIndicator.info.enabledForApplets
}
//! Bindings in order to inform View::Indicator::Info
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"needsIconColors"
when: latteView && latteView.indicator
value: managerIndicator.info.needsIconColors
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"needsMouseEventCoordinates"
when: latteView && latteView.indicator
value: managerIndicator.info.needsMouseEventCoordinates
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"providesClickedAnimation"
when: latteView && latteView.indicator
value: managerIndicator.info.providesClickedAnimation
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"providesHoveredAnimation"
when: latteView && latteView.indicator
value: managerIndicator.info.providesHoveredAnimation
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"providesFrontLayer"
when: latteView && latteView.indicator
value: managerIndicator.info.providesFrontLayer
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"extraMaskThickness"
when: latteView && latteView.indicator
value: managerIndicator.info.extraMaskThickness
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"minLengthPadding"
when: latteView && latteView.indicator
value: managerIndicator.info.minLengthPadding
}
Binding{
target: latteView && latteView.indicator ? latteView.indicator.info : null
property:"minThicknessPadding"
when: latteView && latteView.indicator
value: managerIndicator.info.minThicknessPadding
}
}

@ -37,7 +37,6 @@ import "abilities" as Ability
import "applet" as Applet
import "colorizer" as Colorizer
import "editmode" as EditMode
import "indicators" as Indicators
import "layouts" as Layouts
import "./background" as Background
import "./debugger" as Debugger
@ -1137,6 +1136,7 @@ Item {
animations: _animations
debug: _debug
indexer: _indexer
indicators: _indicators
launchers: _launchers
layouter: _layouter
layouts: layoutsContainer
@ -1345,8 +1345,9 @@ Item {
layouts: layoutsContainer
}
Indicators.Manager{
Ability.Indicators{
id: _indicators
view: latteView
}
Ability.Launchers {

@ -22,16 +22,15 @@ import QtQuick 2.7
import "./indicators" as IndicatorTypes
Item{
property QtObject configuration: null
property QtObject resources: null
property bool isEnabled: false
readonly property real padding: Math.max(info.minLengthPadding, info.lengthPadding)
property string type: "org.kde.latte.default"
property Component plasmaStyleComponent
property QtObject configuration: null
property QtObject resources: null
property Component indicatorComponent
property IndicatorTypes.IndicatorInfo info: IndicatorTypes.IndicatorInfo{

@ -4,6 +4,7 @@ Animations 0.1 Animations.qml
AppletRequirements 0.1 AppletRequirements.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

@ -0,0 +1,41 @@
/*
* Copyright 2021 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.latte.abilities.definition 0.1 as AbilityDefinition
AbilityDefinition.Indicators {
id: apis
readonly property Item publicApi: Item {
readonly property alias isEnabled: apis.isEnabled
readonly property alias padding: apis.padding
readonly property alias type: apis.type
readonly property alias configuration: apis.configuration
readonly property alias resources: apis.resources
readonly property alias indicatorComponent: apis.indicatorComponent
readonly property alias info: apis.info
}
}

@ -2,6 +2,7 @@ module org.kde.latte.abilities.host
Animations 0.1 Animations.qml
Debug 0.1 Debug.qml
Indicators 0.1 Indicators.qml
Metrics 0.1 Metrics.qml
MyView 0.1 MyView.qml
ParabolicEffect 0.1 ParabolicEffect.qml

Loading…
Cancel
Save