aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/modules/kdeconnect/KdeConnectRow.qml
blob: e4d4d9362bda0ec5d4c86f191ce442b54d6111ee (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
// 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 "../.."

// One KDE Connect device. The type glyph is a laptop only for a device the
// daemon reports as "desktop" (which is how it reports laptops too), and a
// phone for anything else, since the type strings are not a closed set.
Rectangle {
    id: row

    required property var kc
    required property var device

    implicitHeight: col.implicitHeight + 16
    radius: 8
    color: row.device.reachable ? Qt.alpha(Theme.accent, 0.10) : Qt.alpha(Theme.surface, 0.35)

    Column {
        id: col
        anchors { left: parent.left; right: parent.right; top: parent.top; margins: 10 }
        spacing: 8

        Item {
            width: parent.width
            implicitHeight: Math.max(name.implicitHeight, glyph.implicitHeight)

            Text {
                id: glyph
                anchors.verticalCenter: parent.verticalCenter
                text: row.device.type === "desktop" ? "\uf109" : "\uf10b"
                font { family: Theme.iconFamily; pixelSize: Theme.fontSize - 2 }
                color: Theme.subtext
            }

            Text {
                id: name
                anchors { left: glyph.right; leftMargin: 8; right: parent.right; verticalCenter: parent.verticalCenter }
                elide: Text.ElideRight
                text: row.device.name || row.device.id
                font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 2; bold: row.device.reachable }
                color: row.device.reachable ? Theme.accent : Theme.text
            }
        }

        Text {
            id: status
            width: parent.width
            text: {
                let s = row.device.paired
                    ? (row.device.reachable ? "Reachable" : "Not reachable")
                    : (row.device.reachable ? "Found" : "Not reachable");
                if (row.device.charge !== "")
                    s += "  " + row.device.charge + "%" + (row.device.charging ? " charging" : "");
                if (row.device.key !== "")
                    s += "  key " + row.device.key;
                return s;
            }
            font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
            color: Theme.subtext
            elide: Text.ElideRight
        }

        Row {
            width: parent.width
            spacing: 6

            Button {
                visible: row.device.reachable
                text: "Ring"
                onClicked: row.kc.ring(row.device.id)
            }

            Button {
                visible: row.device.reachable
                text: "Clipboard"
                onClicked: row.kc.clipboard(row.device.id)
            }

            Button {
                visible: row.device.reachable
                text: "Share"
                onClicked: row.kc.share(row.device.id)
            }

            Button {
                visible: row.device.reachable
                text: "Mount"
                onClicked: row.kc.mount(row.device.id)
            }

            Button {
                visible: row.device.paired
                text: "Unpair"
                danger: true
                onClicked: row.kc.unpair(row.device.id)
            }

            Button {
                visible: !row.device.paired && row.device.reachable
                text: "Pair"
                onClicked: row.kc.pair(row.device.id)
            }
        }
    }
}