2021-12-22 23:29:00 +00:00
|
|
|
/*
|
|
|
|
|
* SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com>
|
|
|
|
|
* SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: LGPL-2.0-or-later
|
|
|
|
|
*/
|
|
|
|
|
|
2022-04-28 20:09:22 +00:00
|
|
|
import QtQuick 2.15
|
2021-12-22 23:29:00 +00:00
|
|
|
import QtQuick.Layouts 1.1
|
|
|
|
|
|
|
|
|
|
import org.kde.kirigami 2.12 as Kirigami
|
|
|
|
|
|
2023-09-05 15:34:49 +00:00
|
|
|
import org.kde.plasma.core as PlasmaCore
|
2023-11-02 11:08:17 +00:00
|
|
|
import org.kde.plasma.private.mobileshell as MobileShell
|
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
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2023-07-25 01:13:52 +00:00
|
|
|
padding: Kirigami.Units.smallSpacing * 2
|
2021-12-22 23:29:00 +00:00
|
|
|
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 color
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
2024-07-15 22:45:33 +00:00
|
|
|
radius: Kirigami.Units.cornerRadius
|
2022-06-03 23:29:46 +00:00
|
|
|
border.width: 1
|
|
|
|
|
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 01:55:06 +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.top: parent.top
|
|
|
|
|
anchors.left: parent.left
|
2023-07-25 01:13:52 +00:00
|
|
|
implicitWidth: Kirigami.Units.iconSizes.small
|
2021-12-22 23:29:00 +00:00
|
|
|
implicitHeight: width
|
|
|
|
|
source: root.icon
|
|
|
|
|
}
|
2024-07-15 22:45:33 +00:00
|
|
|
|
2021-12-22 23:29:00 +00:00
|
|
|
ColumnLayout {
|
|
|
|
|
id: column
|
2023-07-25 01:13:52 +00:00
|
|
|
spacing: Kirigami.Units.smallSpacing
|
2021-12-22 23:29:00 +00:00
|
|
|
anchors.right: parent.right
|
|
|
|
|
anchors.left: parent.left
|
|
|
|
|
anchors.bottom: parent.bottom
|
2023-07-25 02:46:50 +00:00
|
|
|
|
2024-06-29 20:33:33 +00:00
|
|
|
MobileShell.MarqueeLabel {
|
2021-12-22 23:29:00 +00:00
|
|
|
Layout.fillWidth: true
|
2024-06-29 20:33:33 +00:00
|
|
|
inputText: root.text
|
2023-07-25 01:13:52 +00:00
|
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.75 // TODO base height off of size of delegate
|
2022-04-07 00:32:38 +00:00
|
|
|
font.weight: Font.Bold
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
2023-07-25 02:46:50 +00:00
|
|
|
|
2023-11-02 11:08:17 +00:00
|
|
|
MobileShell.MarqueeLabel {
|
2021-12-22 23:29:00 +00:00
|
|
|
// if no status is given, just use On/Off
|
2022-05-20 13:59:58 +00:00
|
|
|
inputText: root.status ? root.status : (root.enabled ? i18n("On") : i18n("Off"))
|
2022-04-29 00:15:13 +00:00
|
|
|
opacity: 0.6
|
2023-07-25 02:46:50 +00:00
|
|
|
|
2022-04-28 20:09:22 +00:00
|
|
|
Layout.fillWidth: true
|
2023-07-25 01:13:52 +00:00
|
|
|
font.pointSize: Kirigami.Theme.defaultFont.pointSize * 0.75
|
2021-12-22 23:29:00 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|