aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/deckit/DeckItGeneralPage.qml
blob: 776099afe39a667be3a1b2a067bc766b43bfe17e (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
// 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 Quickshell
import QtQuick
import "../.."
import "../qtmaildir"
import "Modules.js" as Modules

// deck-it's General page: the intro, Start, Display and Advanced. Every field
// edits the draft of ~/.config/deck-it/config.toml shared by the four deck-it
// pages; an emptied field unsets the key, so deck-it's shipped default (the
// placeholder) applies.
Column {
    id: col
    spacing: 6
    readonly property var st: DeckIt.store
    function def(section, key) { return col.st.fallback(section, key); }

    Small { text: DeckIt.path + ", only the keys that differ from deck-it's defaults. Saved changes apply when deck-it restarts." }
    Small { visible: DeckIt.defaultsError !== ""; color: Theme.red; text: DeckIt.defaultsError }
    Component.onCompleted: DeckIt.watchers++
    Component.onDestruction: DeckIt.watchers--

    Heading { text: "Start" }
    Item {
        objectName: "autostart/"
        width: col.width
        height: 34
        Text {
            id: asLabel
            anchors { left: parent.left; verticalCenter: parent.verticalCenter }
            width: 160
            text: "Start at login"
            color: Theme.subtext
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
        }
        Switch {
            id: asSwitch
            anchors { left: asLabel.right; leftMargin: 8; verticalCenter: parent.verticalCenter }
            checked: DeckIt.autostart
            onToggled: on => DeckIt.setAutostart(on)
        }
        Text {
            anchors { left: asSwitch.right; leftMargin: 10; verticalCenter: parent.verticalCenter }
            text: DeckIt.autostartCmd + ", in autostart.lua; applies at next login"
            color: Theme.subtext
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
        }
    }
    Small { visible: DeckIt.autostartError !== ""; color: Theme.red; text: DeckIt.autostartError }
    Setting { store: col.st; section: "wifi"; key: "address"; label: "Wi-Fi address"
              placeholder: "ip:port"
              hint: "From the tablet's Wireless debugging screen. The port changes whenever it is switched on; empty tries the last address, then mDNS." }

    Heading { text: "Display" }
    BoolSetting { store: col.st; section: "display"; key: "enabled"; label: "Second display"
                  fallback: col.def("display", "enabled") ?? true
                  hint: "a headless monitor streamed to AVNC; off runs the dashboard alone" }
    Setting { store: col.st; section: "display"; key: "resolution"; label: "Resolution"
              placeholder: col.st.placeholder("display", "resolution"); hint: "WIDTHxHEIGHT, or auto to ask the tablet." }
    Setting { store: col.st; section: "display"; key: "position"; label: "Position"
              placeholder: col.st.placeholder("display", "position")
              hint: "auto-below centres it under the first monitor; any Hyprland position works." }
    Setting { store: col.st; section: "display"; key: "scale"; label: "Scale"; kind: "float"; min: 0.25; max: 4
              placeholder: col.st.placeholder("display", "scale") }
    Setting { store: col.st; section: "display"; key: "refresh"; label: "Refresh"; kind: "int"; min: 1; max: 240
              placeholder: col.st.placeholder("display", "refresh") }
    Setting { store: col.st; section: "display"; key: "name"; label: "Output name"
              placeholder: col.st.placeholder("display", "name") }

    Heading { objectName: "modules/tabs"; text: "Tabs" }
    Small { text: "The tablet's tabs beside the Dashboard." }
    Repeater {
        model: Modules.tabs(Object.keys(col.def("modules") ?? {}))
        BoolSetting {
            required property string modelData
            store: col.st; section: "modules"; key: modelData; label: Modules.name(modelData)
            fallback: col.def("modules", modelData) ?? true
        }
    }

    Heading { text: "Advanced" }
    Setting { store: col.st; section: "ports"; key: "command_center"; label: "Dashboard port"; kind: "int"; min: 1024; max: 65535
              placeholder: col.st.placeholder("ports", "command_center"); hint: "On the tablet's localhost, through adb reverse." }
    Setting { store: col.st; section: "ports"; key: "display"; label: "Display port"; kind: "int"; min: 1024; max: 65535
              placeholder: col.st.placeholder("ports", "display") }
    ChoiceSetting { store: col.st; section: ""; key: "hyprland"; label: "Hyprland config"
                    fallbackLabel: "Default (" + (col.def("", "hyprland") ?? "auto") + ")"
                    options: [{ value: "auto", label: "auto" }, { value: "lua", label: "lua" }, { value: "classic", label: "classic" }] }
    Setting { store: col.st; section: "icons"; key: "theme"; label: "Fallback icon theme"
              placeholder: col.st.placeholder("icons", "theme"); hint: "Used only when keystone sets no icon theme." }
}