diff --git a/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml b/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml --- a/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml +++ b/applets/batterymonitor/package/contents/ui/CompactRepresentation.qml @@ -29,6 +29,7 @@ id: root Layout.minimumWidth: units.iconSizes.small * view.count Layout.minimumHeight: units.iconSizes.small + hoverEnabled: true property real itemSize: Math.min(root.height, root.width/view.count) onClicked: plasmoid.expanded = !plasmoid.expanded @@ -58,21 +59,32 @@ property real iconSize: Math.min(width, height) - BatteryIcon { - id: batteryIcon - anchors.centerIn: parent - hasBattery: batteryContainer.hasBattery - percent: batteryContainer.percent - pluggedIn: batteryContainer.pluggedIn - height: isConstrained ? batteryContainer.iconSize : batteryContainer.iconSize - batteryLabel.height - width: height + Item { + id: batteryItem + + anchors.fill: batteryContainer + + BatteryIcon { + id: batteryIcon + anchors.centerIn: parent + hasBattery: batteryContainer.hasBattery + percent: batteryContainer.percent + pluggedIn: batteryContainer.pluggedIn + height: batteryContainer.iconSize + width: height + } + + BadgeOverlay { + anchors.fill: batteryIcon + text: batteryContainer.hasBattery ? i18nc("battery percentage below battery icon", "%1%", percent) : i18nc("short symbol to signal there is no battery currently available", "-") + icon: batteryIcon + visible: plasmoid.configuration.showPercentage + } } - BadgeOverlay { - anchors.fill: batteryIcon - text: batteryContainer.hasBattery ? i18nc("battery percentage below battery icon", "%1%", percent) : i18nc("short symbol to signal there is no battery currently available", "-") - icon: batteryIcon - visible: plasmoid.configuration.showPercentage + IconEffects { + source: batteryItem + iconActive: root.containsMouse } } } diff --git a/applets/notifications/package/contents/ui/CompactRepresentation.qml b/applets/notifications/package/contents/ui/CompactRepresentation.qml --- a/applets/notifications/package/contents/ui/CompactRepresentation.qml +++ b/applets/notifications/package/contents/ui/CompactRepresentation.qml @@ -23,12 +23,15 @@ import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.workspace.components 2.0 import org.kde.quickcharts 1.0 as Charts MouseArea { id: compactRoot + hoverEnabled: true + readonly property bool inPanel: (plasmoid.location === PlasmaCore.Types.TopEdge || plasmoid.location === PlasmaCore.Types.RightEdge || plasmoid.location === PlasmaCore.Types.BottomEdge @@ -107,6 +110,11 @@ } } + IconEffects { + source: notificationIcon + iconActive: visible && compactRoot.containsMouse + } + PlasmaCore.IconItem { id: dndIcon anchors.fill: parent @@ -116,6 +124,11 @@ visible: opacity > 0 } + IconEffects { + source: dndIcon + iconActive: visible && compactRoot.containsMouse + } + states: [ State { // active process when: compactRoot.jobsCount > 0 diff --git a/components/workspace/IconEffects.qml b/components/workspace/IconEffects.qml new file mode 100644 --- /dev/null +++ b/components/workspace/IconEffects.qml @@ -0,0 +1,86 @@ +/* + * Copyright 2020 Konrad Materka + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Library General Public License as + * published by the Free Software Foundation; either version 2, or + * (at your option) any later version. + * + * This program 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 Library General Public + * License along with this program; if not, write to the + * Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +import QtQuick 2.0 +import QtGraphicalEffects 1.12 + +/** + * @brief Applies effects to icons. + * @description PlasmaCore.IconItem applies effects to activated and disabled icons. + * Some icons can't be handle PlasmaCore.IconItem, for example SvgItem. + * This component applies icon effects to such items. + * @see PlasmaCore.IconItem + */ +Item { + id: iconEffects + + /** + * source: variant + * This property defines the source item for which the effect is going to be applied. + */ + property var source + + /** + * iconActive: bool + * When set to true, this property enables the "active" effect. + * By default, the property is set to false. + */ + property bool iconActive: false + + /** + * iconEnabled: bool + * When set to true, this property enables the "disabled" effect. + * By default, the property is set to false. + */ + property bool iconDisabled: false + + GammaAdjust { + id: activeEffect + parent: source.parent + visible: source.visible + Component.onCompleted: anchors.fill = source + + source: iconEffects.source + gamma: (iconActive && !iconDisabled) ? 1.0 / 0.7 : 1.0 + + Behavior on gamma { + PropertyAnimation { + easing.type: Easing.InOutQuad + duration: 250 + } + } + } + + Desaturate { + id: disabledEffect + parent: source.parent + visible: source.visible + anchors.fill: activeEffect + + source: activeEffect + desaturation: iconDisabled ? 1.0 : 0.0 + + Behavior on desaturation { + PropertyAnimation { + easing.type: Easing.InOutQuad + duration: 250 + } + } + } +} diff --git a/components/workspace/qmldir b/components/workspace/qmldir --- a/components/workspace/qmldir +++ b/components/workspace/qmldir @@ -1,4 +1,4 @@ module org.kde.plasma.workspace.components BatteryIcon 2.0 BatteryIcon.qml - +IconEffects 2.0 IconEffects.qml