aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/network/NetworkTile.qml
blob: d88ad351018ae7117e3f0d7ab88b3f89228f6a65 (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
// 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 "../.."

// The state line under the tile label: a green dot, the link's name, and its
// local IP. One row per active link, because the API exposes no route metric
// and the tile will not guess which link carries traffic.
Column {
    id: tile

    required property var net

    width: parent ? parent.width : implicitWidth
    spacing: 2

    Row {
        visible: tile.net.wiredUp
        width: tile.width
        spacing: 5

        Rectangle {
            anchors.verticalCenter: parent.verticalCenter
            width: 7; height: 7; radius: 4
            color: Theme.green
        }

        Text {
            width: parent.width - 12
            elide: Text.ElideRight
            text: {
                const ip = tile.net.ipFor(tile.net.wiredName);
                return tile.net.wiredName + (ip !== "" ? "  " + ip : "");
            }
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
            color: Theme.text
        }
    }

    Row {
        visible: tile.net.wifiUp
        width: tile.width
        spacing: 5

        Rectangle {
            anchors.verticalCenter: parent.verticalCenter
            width: 7; height: 7; radius: 4
            color: Theme.green
        }

        Text {
            width: parent.width - 12
            elide: Text.ElideRight
            text: {
                const ip = tile.net.ipFor(tile.net.wifiDevice ? tile.net.wifiDevice.name : "");
                return tile.net.wifiSsid + (ip !== "" ? "  " + ip : "");
            }
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
            color: Theme.text
        }
    }

    Text {
        width: tile.width
        elide: Text.ElideRight
        visible: !tile.net.wiredUp && !tile.net.wifiUp
        text: tile.net.wifiOn ? "Disconnected" : "Off"
        font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
        color: Theme.subtext
    }
}