containment:expose and use AbilityHost.Indicators
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
|
||||
}
|
||||
}
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue