2026-05-04 18:34:54 +00:00
|
|
|
// SPDX-FileCopyrightText: 2026 Marco Allegretti
|
|
|
|
|
// SPDX-License-Identifier: EUPL-1.2
|
|
|
|
|
|
|
|
|
|
import QtQuick
|
|
|
|
|
|
|
|
|
|
import org.kde.kirigami as Kirigami
|
|
|
|
|
import org.kde.plasma.components 3.0 as PC3
|
2026-05-21 09:13:36 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2026-05-04 18:34:54 +00:00
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
|
id: button
|
|
|
|
|
|
|
|
|
|
property string iconName
|
|
|
|
|
property string toolTipText
|
|
|
|
|
property bool checked: false
|
2026-05-21 09:13:36 +00:00
|
|
|
readonly property int shortAnimationDuration: MobileShell.Motion.duration(MobileShell.Motion.EffectsFast)
|
2026-05-04 18:34:54 +00:00
|
|
|
|
|
|
|
|
signal triggered()
|
|
|
|
|
|
|
|
|
|
function _mix(base, overlay, ratio) {
|
|
|
|
|
return Qt.rgba(
|
|
|
|
|
base.r + (overlay.r - base.r) * ratio,
|
|
|
|
|
base.g + (overlay.g - base.g) * ratio,
|
|
|
|
|
base.b + (overlay.b - base.b) * ratio,
|
|
|
|
|
base.a + (overlay.a - base.a) * ratio)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
width: Kirigami.Units.iconSizes.smallMedium + Kirigami.Units.smallSpacing * 2
|
|
|
|
|
height: width
|
|
|
|
|
hoverEnabled: enabled
|
|
|
|
|
cursorShape: enabled ? Qt.PointingHandCursor : Qt.ArrowCursor
|
|
|
|
|
opacity: enabled ? 1 : 0.35
|
|
|
|
|
|
|
|
|
|
onClicked: button.triggered()
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
radius: Kirigami.Units.cornerRadius
|
|
|
|
|
color: button.containsPress
|
|
|
|
|
? button._mix(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, 0.16)
|
|
|
|
|
: button.checked
|
|
|
|
|
? button._mix(Kirigami.Theme.backgroundColor, Kirigami.Theme.highlightColor, button.containsMouse ? 0.22 : 0.16)
|
|
|
|
|
: button.containsMouse
|
|
|
|
|
? button._mix(Kirigami.Theme.backgroundColor, Kirigami.Theme.textColor, 0.08)
|
|
|
|
|
: "transparent"
|
|
|
|
|
|
|
|
|
|
Behavior on color {
|
2026-05-21 09:13:36 +00:00
|
|
|
MobileShell.MotionColorAnimation { type: MobileShell.Motion.EffectsFast; duration: button.shortAnimationDuration }
|
2026-05-04 18:34:54 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Kirigami.Icon {
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
width: Kirigami.Units.iconSizes.small
|
|
|
|
|
height: width
|
|
|
|
|
source: button.iconName
|
|
|
|
|
active: button.containsMouse || button.checked
|
2026-05-17 06:57:06 +00:00
|
|
|
isMask: true
|
|
|
|
|
color: Kirigami.Theme.textColor
|
2026-05-04 18:34:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PC3.ToolTip {
|
|
|
|
|
text: button.toolTipText
|
|
|
|
|
visible: button.containsMouse && button.toolTipText.length > 0
|
|
|
|
|
}
|
|
|
|
|
}
|