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
|
|
|
|
|
|
|
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
|
|
|
|
|
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
|
2023-03-18 19:28:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell.shellsettingsplugin as ShellSettings
|
2021-12-22 23:29:00 +00:00
|
|
|
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
|
2023-03-18 19:28:17 +00:00
|
|
|
zoomScale: (ShellSettings.Settings.animationsEnabled && mouseArea.pressed) ? 0.9 : 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) {
|
|
|
|
|
return mouseArea.pressed ? root.enabledButtonPressedColor : root.enabledButtonColor
|
|
|
|
|
} else {
|
|
|
|
|
return mouseArea.pressed ? root.disabledButtonPressedColor : root.disabledButtonColor
|
|
|
|
|
}
|
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
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|