NetworkDetailsView.qml 3.86 KB
Newer Older
Jan Grulich's avatar
Jan Grulich committed
1
/*
2
 *   Copyright 2017 Martin Kacej <m.kacej@atlas.sk>
Jan Grulich's avatar
Jan Grulich committed
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
 *
 *   This program is free software; you can redistribute it and/or modify
 *   it under the terms of the GNU Library General Public License as
 *   published by the Free Software Foundation; either version 2 or
 *   (at your option) any later version.
 *
 *   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 Library General Public License for more details
 *
 *   You should have received a copy of the GNU Library General Public
 *   License along with this program; if not, write to the
 *   Free Software Foundation, Inc.,
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

Martin Kacej's avatar
Martin Kacej committed
20 21
import QtQuick 2.6
import QtQuick.Controls 2.2 as Controls
22
import QtQuick.Layouts 1.2
Martin Kacej's avatar
Martin Kacej committed
23
import org.kde.kirigami 2.2 as Kirigami
24

Martin Kacej's avatar
Martin Kacej committed
25
Kirigami.ScrollablePage{
26
    property var details
27 28
    property alias signal_strength: signalStrengthLabel.text
    property alias signal_speed: linkSpeedLabel.text
Martin Kacej's avatar
Martin Kacej committed
29 30
    property alias ip_address: ipAddressLabel.text
    property alias security: securityLabel.text
Martin Kacej's avatar
Martin Kacej committed
31
    property var activeMap: ({})
Martin Kacej's avatar
Martin Kacej committed
32 33

    Column {
34
        Column {
Martin Kacej's avatar
Martin Kacej committed
35 36 37
            id: staticInfo
            anchors.bottomMargin: units.gridUnit

38 39 40
            Row {
                spacing: units.gridUnit / 2

Martin Kacej's avatar
Martin Kacej committed
41
                Controls.Label {
42 43 44 45
                    font.weight: Font.Bold
                    text: i18n("Strength:")
                }

Martin Kacej's avatar
Martin Kacej committed
46
                Controls.Label {
47 48
                    id: signalStrengthLabel
                }
Martin Kacej's avatar
Martin Kacej committed
49
            }
50 51 52 53

            Row {
                spacing: units.gridUnit / 2

Martin Kacej's avatar
Martin Kacej committed
54
                Controls.Label {
55 56 57 58
                    font.weight: Font.Bold
                    text: i18n("Link Speed:")
                }

Martin Kacej's avatar
Martin Kacej committed
59
                Controls.Label {
60 61
                    id: linkSpeedLabel
                }
Martin Kacej's avatar
Martin Kacej committed
62
            }
63 64 65 66

            Row {
                spacing: units.gridUnit / 2

Martin Kacej's avatar
Martin Kacej committed
67
                Controls.Label {
68 69 70 71
                    font.weight: Font.Bold
                    text: i18n("Security:")
                }

Martin Kacej's avatar
Martin Kacej committed
72
                Controls.Label {
73 74
                    id: securityLabel
                }
Martin Kacej's avatar
Martin Kacej committed
75
            }
76 77 78 79

            Row {
                spacing: units.gridUnit / 2

Martin Kacej's avatar
Martin Kacej committed
80
                Controls.Label {
81 82 83 84
                    font.weight: Font.Bold
                    text: i18n("IP Address:")
                }

Martin Kacej's avatar
Martin Kacej committed
85
                Controls.Label {
86 87
                    id: ipAddressLabel
                }
Martin Kacej's avatar
Martin Kacej committed
88 89 90
            }
        }

Martin Kacej's avatar
Martin Kacej committed
91 92 93 94
        SecuritySection {
            id: detailsSecuritySection
        }

Martin Kacej's avatar
Martin Kacej committed
95
        RowLayout {
Martin Kacej's avatar
Martin Kacej committed
96

Martin Kacej's avatar
Martin Kacej committed
97
            Controls.Label {
Martin Kacej's avatar
Martin Kacej committed
98 99 100
                anchors.left: parent.left
                text: i18n("Advanced options")
            }
Martin Kacej's avatar
Martin Kacej committed
101
            Controls.Switch {
Martin Kacej's avatar
Martin Kacej committed
102 103 104 105
                id: advancedOptionsSwitch
                checked: false
            }
        }
106

107
        IPDetailsSection {
Martin Kacej's avatar
Martin Kacej committed
108 109
            id: detailsIP
            visible: advancedOptionsSwitch.checked
110 111
        }
    }
112 113 114 115 116 117 118 119
    actions {
        right: Kirigami.Action {
            iconName: "cancel"
            onTriggered: {
                applicationWindow().pageStack.pop()
            }
        }
    }
120

Jan Grulich's avatar
Jan Grulich committed
121
    function fillDetails() {
Martin Kacej's avatar
Martin Kacej committed
122
        var d = {}
Jan Grulich's avatar
Jan Grulich committed
123
        for (var i = 0; i < (details.length / 2); i++){
Martin Kacej's avatar
Martin Kacej committed
124
            d[details[(i * 2)]] = details[(i * 2) + 1]
125
        }
Martin Kacej's avatar
Martin Kacej committed
126

127 128
        if (d['Access point (SSID)'])
            detailsDialog.titleText = d['Access point (SSID)']
Martin Kacej's avatar
Martin Kacej committed
129
        signal_strength = d['Signal strength']
130
        if (d['IPv4 Address'])
131
            ip_address = detailsIP.address = d['IPv4 Address']
132 133 134 135
        if (d['Security type'])
            security = d['Security type']
        if (d['Connection speed'])
            signal_speed = d['Connection speed']
Martin Kacej's avatar
Martin Kacej committed
136
    }
137
    function clearDetails() {
Martin Kacej's avatar
Martin Kacej committed
138 139
        signal_speed = signal_strength = ip_address = 0
        security = "Unknown"
140 141
    }
}