KdeConnect.qml 2.07 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import QtQuick 2.9
import QtQuick.Window 2.3
import QtQuick.Layouts 1.3
import QtQml.Models 2.2
import QtQuick.Controls 2.2 as Controls
import org.kde.kirigami 2.11 as Kirigami
import org.kde.kdeconnect 1.0 as KDEConnect

AbstractIndicator {
    id: connectionIcon
    icon.name: "kdeconnect"
    property var window

    KDEConnect.DevicesModel {
        id: allDevicesModel
    }

    Repeater {
        model: allDevicesModel
        delegate: Item {
            property bool pairingRequest: device.hasPairingRequests
22
            property var bigscreenIface: KDEConnect.BigscreenDbusInterfaceFactory.create(device.id())
23

24
25
26
27
28
29
30
31
32
            Connections {
                target: bigscreenIface
                onMessageReceived: message => {
                    if (mycroftLoader.item) {
                        mycroftLoader.item.sendText(message);
                    }
                }
            }
            
33
            onPairingRequestChanged: {
34
                if (pairingRequest) {
35
                    var component = Qt.createComponent("PairWindow.qml");
36
                    if (component.status != Component.Ready)
37
                    {
38
                        if (component.status == Component.Error) {
39
40
41
42
43
44
                            console.debug("Error: "+ component.errorString());
                        }
                        return;
                    } else {
                        window = component.createObject("root", {currentDevice: device})
                        window.show()
45
                        window.requestActivate()
46
47
48
49
50
51
                    }
                } else {
                    console.log("pairing request timedout/closed")
                    window.close()
                }
            }
52
53
            
            
54
55
56
        }
    }
    
57
58
59
60
61
    Loader {
        id: mycroftLoader
        source: Qt.resolvedUrl("MycroftConnect.qml") ? Qt.resolvedUrl("MycroftConnect.qml") : null
    }
    
62
63
64
65
66
    onClicked: {
        feedbackWindow.open(i18n("KDE Connect"), "kdeconnect");
        plasmoid.nativeInterface.executeCommand("plasma-settings -s -m kcm_mediacenter_kdeconnect")
    }
}