1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
//
// This file is part of Sugar Dark, a theme for the Simple Display Desktop Manager.
//
// Copyright 2018 Marian Arlt
//
// Sugar Dark is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Sugar Dark is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Sugar Dark. If not, see <https://www.gnu.org/licenses/>.
//
import QtQuick 2.11
import QtQuick.Layouts 1.11
import QtQuick.Controls 2.4
RowLayout {
spacing: root.font.pointSize
property var suspend: ["Suspend", config.TranslateSuspend || textConstants.suspend, sddm.canSuspend]
property var hibernate: ["Hibernate", config.TranslateHibernate || textConstants.hibernate, sddm.canHibernate]
property var reboot: ["Reboot", config.TranslateReboot || textConstants.reboot, sddm.canReboot]
property var shutdown: ["Shutdown", config.TranslateShutdown || textConstants.shutdown, sddm.canPowerOff]
property Control exposedLogin
Repeater {
model: [suspend, hibernate, reboot, shutdown]
RoundButton {
id: icon
text: modelData[1]
font.pointSize: root.font.pointSize * 0.8
Layout.alignment: Qt.AlignHCenter
icon.source: modelData ? Qt.resolvedUrl("../Assets/" + modelData[0] + ".svgz") : ""
icon.height: 2 * Math.round((root.font.pointSize * 3) / 2)
icon.width: 2 * Math.round((root.font.pointSize * 3) / 2)
display: AbstractButton.TextUnderIcon
visible: modelData[2]
hoverEnabled: true
palette.buttonText: root.palette.text
background: Rectangle {
height: 2
color: "transparent"
width: parent.width
border.width: parent.visualFocus ? 1 : 0
border.color: "transparent"
anchors.top: parent.bottom
}
Keys.onReturnPressed: clicked()
onClicked: {
parent.forceActiveFocus()
index == 0 ? sddm.suspend() : index == 1 ? sddm.hibernate() : index == 2 ? sddm.reboot() : sddm.powerOff()
}
KeyNavigation.up: exposedLogin
KeyNavigation.left: index == 0 ? exposedLogin : parent.children[index-1]
states: [
State {
name: "pressed"
when: parent.children[index].down
PropertyChanges {
target: parent.children[index]
palette.buttonText: Qt.darker(root.palette.highlight, 1.1)
}
PropertyChanges {
target: parent.children[index].background
border.color: Qt.darker(root.palette.highlight, 1.1)
}
},
State {
name: "hovered"
when: parent.children[index].hovered
PropertyChanges {
target: parent.children[index]
palette.buttonText: Qt.lighter(root.palette.highlight, 1.1)
}
PropertyChanges {
target: parent.children[index].background
border.color: Qt.lighter(root.palette.highlight, 1.1)
}
},
State {
name: "focused"
when: parent.children[index].visualFocus
PropertyChanges {
target: parent.children[index]
palette.buttonText: root.palette.highlight
}
PropertyChanges {
target: parent.children[index].background
border.color: root.palette.highlight
}
}
]
transitions: [
Transition {
PropertyAnimation {
properties: "palette.buttonText, border.color"
duration: 150
}
}
]
}
}
}
|