2022-08-28 21:48:51 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Eike Hein <hein@kde.org>
|
|
|
|
|
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
import QtQuick 2.15
|
2022-08-28 21:48:51 +00:00
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
import org.kde.plasma.plasmoid 2.0
|
|
|
|
import org.kde.kirigami 2.20 as Kirigami
|
|
|
|
import org.kde.ksvg 1.0 as KSvg
|
2022-08-28 21:48:51 +00:00
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
KSvg.SvgItem {
|
2022-08-28 21:48:51 +00:00
|
|
|
id: actionButton
|
|
|
|
|
|
|
|
width: {
|
|
|
|
if (!visible) {
|
|
|
|
return 0;
|
|
|
|
}
|
2024-08-09 01:20:25 +00:00
|
|
|
switch (Plasmoid.configuration.iconSize) {
|
|
|
|
case 0: return Kirigami.Units.iconSizes.small;
|
|
|
|
case 1: return Kirigami.Units.iconSizes.small;
|
|
|
|
case 2: return Kirigami.Units.iconSizes.smallMedium;
|
|
|
|
case 3: return Kirigami.Units.iconSizes.smallMedium;
|
|
|
|
case 4: return Kirigami.Units.iconSizes.smallMedium;
|
|
|
|
case 5: return Kirigami.Units.iconSizes.medium;
|
|
|
|
case 6: return Kirigami.Units.iconSizes.large;
|
|
|
|
default: return Kirigami.Units.iconSizes.small;
|
2022-08-28 21:48:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
height: width
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
signal clicked()
|
2022-08-28 21:48:51 +00:00
|
|
|
|
|
|
|
property string element
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
svg: KSvg.Svg {
|
|
|
|
imagePath: "widgets/action-overlays"
|
|
|
|
multipleImages: true
|
|
|
|
size: "16x16"
|
|
|
|
}
|
2022-08-28 21:48:51 +00:00
|
|
|
elementId: element + "-normal"
|
|
|
|
|
|
|
|
Behavior on opacity {
|
2024-08-09 01:20:25 +00:00
|
|
|
NumberAnimation { duration: Kirigami.Units.shortDuration }
|
2022-08-28 21:48:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: actionButtonMouseArea
|
|
|
|
|
|
|
|
anchors.fill: actionButton
|
|
|
|
|
|
|
|
acceptedButtons: Qt.LeftButton
|
|
|
|
hoverEnabled: true
|
|
|
|
|
2024-08-09 01:20:25 +00:00
|
|
|
onClicked: mouse => actionButton.clicked()
|
2022-08-28 21:48:51 +00:00
|
|
|
|
|
|
|
states: [
|
|
|
|
State {
|
|
|
|
name: "hover"
|
|
|
|
when: actionButtonMouseArea.containsMouse && !actionButtonMouseArea.pressed
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: actionButton
|
|
|
|
elementId: actionButton.element + "-hover"
|
|
|
|
}
|
|
|
|
},
|
|
|
|
State {
|
|
|
|
name: "pressed"
|
|
|
|
when: actionButtonMouseArea.pressed
|
|
|
|
|
|
|
|
PropertyChanges {
|
|
|
|
target: actionButton
|
|
|
|
elementId: actionButton.element + "-pressed"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|