aboutsummaryrefslogtreecommitdiff
path: root/modules/system/quickshell/ConnectivityBox.qml
blob: e1fb03f0d5ad9a4357101a67be990f71432491d8 (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
import QtQuick
import QtQuick.Layouts
import Quickshell
import Quickshell.Networking
import Quickshell.Bluetooth

Squircle {
    id: root
    cornerRadius: 16
    fillColor: Theme.surface
    Layout.fillWidth: true
    Layout.preferredHeight: 140

    ColumnLayout {
        anchors.fill: parent
        anchors.margins: 12
        spacing: 0 // Using spacers for better control

        // WiFi Row
        Item {
            Layout.fillWidth: true
            height: 50
            scale: wifiArea.pressed ? 0.96 : 1.0
            Behavior on scale { NumberAnimation { duration: 150; easing.type: Easing.OutCubic } }

            RowLayout {
                anchors.fill: parent
                spacing: 12
                
                IconCircle {
                    source: "network-wireless"
                    active: Networking.wifiEnabled
                    size: 32
                    Layout.alignment: Qt.AlignVCenter
                }

                ColumnLayout {
                    spacing: 0
                    Layout.alignment: Qt.AlignVCenter
                    Layout.fillWidth: true
                    Text {
                        text: "Wi-Fi"
                        color: Theme.text
                        font.pixelSize: 13
                        font.weight: Font.DemiBold
                    }
                    Text {
                        text: {
                            const vs = Networking.devices?.values || []
                            for (const device of vs) {
                                if (device.scannerEnabled !== undefined) {
                                    const nets = device.networks?.values || []
                                    for (const n of nets) if (n.connected) return n.name
                                }
                            }
                            return Networking.wifiEnabled ? "On" : "Off"
                        }
                        color: Theme.textMuted
                        font.pixelSize: 12
                        font.weight: Font.Medium
                        elide: Text.ElideRight
                        Layout.maximumWidth: 80
                    }
                }
            }

            MouseArea {
                id: wifiArea
                anchors.fill: parent
                onClicked: Qt.callLater(() => GlobalState.open("Wifi"))
            }
        }

        Item { Layout.fillHeight: true } // Spacer

        // Bluetooth Row
        Item {
            Layout.fillWidth: true
            height: 50
            scale: btArea.pressed ? 0.96 : 1.0
            Behavior on scale { NumberAnimation { duration: 150; easing.type: Easing.OutCubic } }

            RowLayout {
                anchors.fill: parent
                spacing: 12
                
                IconCircle {
                    source: "bluetooth-active"
                    active: Bluetooth.defaultAdapter?.enabled ?? false
                    size: 32
                    Layout.alignment: Qt.AlignVCenter
                }

                ColumnLayout {
                    spacing: 0
                    Layout.alignment: Qt.AlignVCenter
                    Layout.fillWidth: true
                    Text {
                        text: "Bluetooth"
                        color: Theme.text
                        font.pixelSize: 13
                        font.weight: Font.DemiBold
                    }
                    Text {
                        text: Bluetooth.defaultAdapter?.enabled ? "On" : "Off"
                        color: Theme.textMuted
                        font.pixelSize: 12
                        font.weight: Font.Medium
                        Layout.fillWidth: true
                    }
                }
            }

            MouseArea {
                id: btArea
                anchors.fill: parent
                onClicked: Qt.callLater(() => GlobalState.open("Bluetooth"))
            }
        }
    }
}