aboutsummaryrefslogtreecommitdiffstats
path: root/appearance/IdleTab.qml
blob: f932fac16c89a31141c867e8ba83b132b0246821 (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
// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
// published by the Free Software Foundation.
//
// This program 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.

import QtQuick

Flickable {
    contentHeight: col.implicitHeight
    clip: true

    Column {
        id: col
        width: parent.width
        spacing: 10

        Text {
            text: "Commands are fixed. Only the timeout and whether a listener runs are editable."
            color: Theme.overlay
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
        }

        Repeater {
            model: Hypridle.listeners
            Rectangle {
                required property var modelData
                required property int index
                width: col.width
                implicitHeight: 40
                radius: 8
                color: Qt.alpha(Theme.surface, modelData.enabled ? 0.4 : 0.2)
                opacity: modelData.enabled ? 1 : 0.6

                Row {
                    anchors.fill: parent
                    anchors.margins: 8
                    spacing: 10

                    Toggle {
                        anchors.verticalCenter: parent.verticalCenter
                        checked: modelData.enabled
                        onToggled: Hypridle.listeners = Hypridle.listeners.map(
                            (l, i) => i === index ? Object.assign({}, l, { enabled: checked }) : l)
                    }
                    Text {
                        anchors.verticalCenter: parent.verticalCenter
                        width: 150
                        text: Hypridle.describe(modelData)
                        color: Theme.text
                        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
                    }
                    Field {
                        anchors.verticalCenter: parent.verticalCenter
                        width: 70
                        value: String(modelData.timeout)
                        placeholder: "seconds"
                        onEdited: Hypridle.listeners = Hypridle.listeners.map(
                            (l, i) => i === index
                                ? Object.assign({}, l, { timeout: parseInt(value, 10) || 0 }) : l)
                    }
                    Text {
                        anchors.verticalCenter: parent.verticalCenter
                        text: `${Math.floor(modelData.timeout / 60)}:${String(modelData.timeout % 60).padStart(2, "0")}`
                        color: Theme.subtext
                        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
                    }
                    Text {
                        anchors.verticalCenter: parent.verticalCenter
                        width: parent.width - 380
                        elide: Text.ElideRight
                        text: modelData.onTimeout
                        color: Theme.overlay
                        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 5 }
                    }
                }
            }
        }

        Tab {
            text: "Save + Restart hypridle"
            selected: true
            onClicked: Hypridle.save()
        }
    }
}