2021-12-22 23:29:00 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import QtQuick 2.1
|
|
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
|
2026-03-07 03:08:07 +00:00
|
|
|
import org.kde.kirigami as Kirigami
|
2021-12-22 23:29:00 +00:00
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2021-12-22 23:29:00 +00:00
|
|
|
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
|
|
|
|
|
import org.kde.plasma.components 3.0 as PlasmaComponents
|
|
|
|
|
|
|
|
|
|
QuickSettingsDelegate {
|
|
|
|
|
id: root
|
|
|
|
|
|
|
|
|
|
iconItem: icon
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2022-04-07 01:55:06 +00:00
|
|
|
// scale animation on press
|
2026-05-21 09:12:44 +00:00
|
|
|
zoomScale: mouseArea.pressed ? root.pressedScale : 1
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2022-06-03 23:29:46 +00:00
|
|
|
background: Item {
|
|
|
|
|
// very simple shadow for performance
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.top: parent.top
|
|
|
|
|
anchors.topMargin: 1
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
|
height: parent.height
|
2024-07-15 22:45:33 +00:00
|
|
|
|
|
|
|
|
radius: Kirigami.Units.cornerRadius
|
2022-06-03 23:29:46 +00:00
|
|
|
color: Qt.rgba(0, 0, 0, 0.075)
|
|
|
|
|
}
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2022-06-03 23:29:46 +00:00
|
|
|
// background
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
2024-07-15 22:45:33 +00:00
|
|
|
radius: Kirigami.Units.cornerRadius
|
2025-09-18 13:29:53 +00:00
|
|
|
border.pixelAligned: false
|
|
|
|
|
border.width: 1
|
2022-06-03 23:29:46 +00:00
|
|
|
border.color: root.enabled ? root.enabledButtonBorderColor : root.disabledButtonBorderColor
|
|
|
|
|
color: {
|
|
|
|
|
if (root.enabled) {
|
2026-04-29 06:39:34 +00:00
|
|
|
if (mouseArea.pressed) {
|
|
|
|
|
return root.enabledButtonPressedColor
|
|
|
|
|
}
|
|
|
|
|
return mouseArea.containsMouse ? root.enabledButtonHoverColor : root.enabledButtonColor
|
2022-06-03 23:29:46 +00:00
|
|
|
} else {
|
2026-04-29 06:39:34 +00:00
|
|
|
if (mouseArea.pressed) {
|
|
|
|
|
return root.disabledButtonPressedColor
|
|
|
|
|
}
|
|
|
|
|
return mouseArea.containsMouse ? root.disabledButtonHoverColor : root.disabledButtonColor
|
2022-06-03 23:29:46 +00:00
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
2026-04-29 06:39:34 +00:00
|
|
|
|
|
|
|
|
Behavior on color {
|
2026-05-21 09:12:44 +00:00
|
|
|
MobileShell.MotionColorAnimation { type: MobileShell.Motion.EffectsFast }
|
2026-04-29 06:39:34 +00:00
|
|
|
}
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2023-11-15 07:13:05 +00:00
|
|
|
MobileShell.HapticsEffect {
|
2022-11-11 16:56:40 +00:00
|
|
|
id: haptics
|
|
|
|
|
}
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
contentItem: MouseArea {
|
|
|
|
|
id: mouseArea
|
2026-04-29 06:39:34 +00:00
|
|
|
hoverEnabled: true
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2022-11-11 16:56:40 +00:00
|
|
|
onPressed: haptics.buttonVibrate();
|
2021-12-22 23:29:00 +00:00
|
|
|
onClicked: root.delegateClick()
|
2022-04-29 20:15:53 +00:00
|
|
|
onPressAndHold: {
|
2022-11-11 16:56:40 +00:00
|
|
|
haptics.buttonVibrate();
|
2022-04-29 20:15:53 +00:00
|
|
|
root.delegatePressAndHold();
|
|
|
|
|
}
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2022-04-07 02:08:47 +00:00
|
|
|
cursorShape: Qt.PointingHandCursor
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2023-08-18 09:08:07 +00:00
|
|
|
Kirigami.Icon {
|
2021-12-22 23:29:00 +00:00
|
|
|
id: icon
|
|
|
|
|
anchors.centerIn: parent
|
2023-07-25 01:13:52 +00:00
|
|
|
implicitWidth: Kirigami.Units.iconSizes.smallMedium
|
2021-12-22 23:29:00 +00:00
|
|
|
implicitHeight: width
|
|
|
|
|
source: root.icon
|
2026-05-17 06:57:06 +00:00
|
|
|
Kirigami.Theme.inherit: false
|
|
|
|
|
Kirigami.Theme.colorSet: Kirigami.Theme.Window
|
|
|
|
|
isMask: true
|
|
|
|
|
color: Kirigami.Theme.textColor
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|