blob: ca6bf17a77b5761b450edf39aa4d82f1d1d6b201 (
plain)
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
pragma ComponentBehavior: Bound
import qs.components
import qs.services
import qs.config
import qs.utils
import Quickshell
import QtQuick
Column {
id: root
required property PersistentProperties visibilities
padding: Appearance.padding.large
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
spacing: Appearance.spacing.large
SessionButton {
id: logout
icon: "logout"
command: Config.session.commands.logout
KeyNavigation.down: shutdown
Connections {
target: root.visibilities
function onSessionChanged(): void {
if (root.visibilities.session)
logout.focus = true;
}
function onLauncherChanged(): void {
if (root.visibilities.session && !root.visibilities.launcher)
logout.focus = true;
}
}
}
SessionButton {
id: shutdown
icon: "power_settings_new"
command: Config.session.commands.shutdown
KeyNavigation.up: logout
KeyNavigation.down: hibernate
}
AnimatedImage {
width: Config.session.sizes.button
height: Config.session.sizes.button
sourceSize.width: width
sourceSize.height: height
playing: visible
asynchronous: true
speed: 0.7
source: Paths.expandTilde(Config.paths.sessionGif)
}
SessionButton {
id: hibernate
icon: "downloading"
command: Config.session.commands.hibernate
KeyNavigation.up: shutdown
KeyNavigation.down: reboot
}
SessionButton {
id: reboot
icon: "cached"
command: Config.session.commands.reboot
KeyNavigation.up: hibernate
}
component SessionButton: StyledRect {
id: button
required property string icon
required property list<string> command
implicitWidth: Config.session.sizes.button
implicitHeight: Config.session.sizes.button
radius: Appearance.rounding.large
color: button.activeFocus ? Colours.palette.m3secondaryContainer : Colours.tPalette.m3surfaceContainer
Keys.onEnterPressed: Quickshell.execDetached(button.command)
Keys.onReturnPressed: Quickshell.execDetached(button.command)
Keys.onEscapePressed: root.visibilities.session = false
Keys.onPressed: event => {
if (!Config.session.vimKeybinds)
return;
if (event.modifiers & Qt.ControlModifier) {
if (event.key === Qt.Key_J && KeyNavigation.down) {
KeyNavigation.down.focus = true;
event.accepted = true;
} else if (event.key === Qt.Key_K && KeyNavigation.up) {
KeyNavigation.up.focus = true;
event.accepted = true;
}
} else if (event.key === Qt.Key_Tab && KeyNavigation.down) {
KeyNavigation.down.focus = true;
event.accepted = true;
} else if (event.key === Qt.Key_Backtab || (event.key === Qt.Key_Tab && (event.modifiers & Qt.ShiftModifier))) {
if (KeyNavigation.up) {
KeyNavigation.up.focus = true;
event.accepted = true;
}
}
}
StateLayer {
radius: parent.radius
color: button.activeFocus ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface
function onClicked(): void {
Quickshell.execDetached(button.command);
}
}
MaterialIcon {
anchors.centerIn: parent
text: button.icon
color: button.activeFocus ? Colours.palette.m3onSecondaryContainer : Colours.palette.m3onSurface
font.pointSize: Appearance.font.size.extraLarge
font.weight: 500
}
}
}
|