aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/deckit/DeckItControlModule.qml
blob: 311de1cc8949a4f1eb8f48d23fe1892a6d2b6258 (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
// 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
import "../.."

// deck-it's runtime controls in the drawer: its state, Start, Stop and
// Restart. Its settings stay in the settings window's deck-it pages.
Module {
    name: "deckit-run"
    label: "deck-it"
    // nf-md-tablet, as on the Server page.
    icon: "󰓶"

    page: Component {
        Page {
            title: "deck-it"
            Column {
                width: parent.width
                spacing: 12
                // `deck-it status` polls only while this page is open.
                Component.onCompleted: DeckIt.watchers++
                Component.onDestruction: DeckIt.watchers--

                Text {
                    width: parent.width
                    wrapMode: Text.Wrap
                    text: ({ start: "Starting…", stop: "Stopping…", restart: "Restarting…" })[DeckIt.busy]
                          ?? DeckIt.summary
                    color: DeckIt.healthy ? Theme.green : DeckIt.running ? Theme.yellow : Theme.red
                    font { family: Theme.fontFamily; pixelSize: Theme.fontSize }
                }
                Row {
                    spacing: 8
                    Button {
                        text: "Start"
                        enabled: !DeckIt.busy && !!DeckIt.status && !DeckIt.running
                        onClicked: DeckIt.control("start")
                    }
                    Button {
                        text: "Stop"
                        enabled: !DeckIt.busy && DeckIt.running
                        onClicked: DeckIt.control("stop")
                    }
                    Button {
                        text: "Restart"
                        enabled: !DeckIt.busy && DeckIt.running
                        onClicked: DeckIt.control("restart")
                    }
                }
            }
        }
    }
}