QuickSettingsFullDelegate.qml 2.82 KB
Newer Older
1
2
3
4
5
6
7
/*
 *   SPDX-FileCopyrightText: 2015 Marco Martin <notmart@gmail.com>
 *   SPDX-FileCopyrightText: 2021 Devin Lin <devin@kde.org>
 *
 *   SPDX-License-Identifier: LGPL-2.0-or-later
 */

8
import QtQuick 2.15
9
10
11
12
13
14
import QtQuick.Layouts 1.1

import org.kde.kirigami 2.12 as Kirigami

import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.private.nanoshell 2.0 as NanoShell
15
import org.kde.plasma.private.mobileshell 1.0 as MobileShell
16
17
18
19
20
21
import org.kde.plasma.components 3.0 as PlasmaComponents

import "../../components" as Components

QuickSettingsDelegate {
    id: root
22
    
23
24
25
    padding: PlasmaCore.Units.smallSpacing * 2
    iconItem: icon
    
26
    // scale animation on press
27
    zoomScale: (MobileShell.MobileShellSettings.animationsEnabled && mouseArea.pressed) ? 0.9 : 1
28
    
29
    background: Rectangle {       
30
        anchors.fill: parent
31
        radius: PlasmaCore.Units.smallSpacing
32
        border.width: 1
33
34
35
36
37
38
39
40
41
42
43
44
        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
            }
        }
    }
    
    contentItem: MouseArea {
        id: mouseArea
45
46
        
        onPressed: MobileShell.Haptics.buttonVibrate()
47
        onClicked: root.delegateClick()
48
49
50
51
52
        onPressAndHold: {
            MobileShell.Haptics.buttonVibrate();
            root.delegatePressAndHold();
        }
        
53
        cursorShape: Qt.PointingHandCursor
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
        
        PlasmaCore.IconItem {
            id: icon
            anchors.top: parent.top
            anchors.left: parent.left
            implicitWidth: PlasmaCore.Units.iconSizes.small
            implicitHeight: width
            source: root.icon
        }
        
        ColumnLayout {
            id: column
            spacing: PlasmaCore.Units.smallSpacing
            anchors.right: parent.right
            anchors.left: parent.left
            anchors.bottom: parent.bottom
            
            PlasmaComponents.Label {
                Layout.fillWidth: true
                elide: Text.ElideRight
                text: root.text
75
                font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 0.75 // TODO base height off of size of delegate
76
                font.weight: Font.Bold
77
            }
78
79
            
            Components.MarqueeLabel {
80
                // if no status is given, just use On/Off
81
                inputText: root.status ? root.status : (root.enabled ? i18n("On") : i18n("Off"))
82
                opacity: 0.6
83
84
                
                Layout.fillWidth: true
85
                font.pointSize: PlasmaCore.Theme.defaultFont.pointSize * 0.75
86
87
88
89
90
            }
        }
    }
}