Wifi.qml 4.22 KB
Newer Older
1
/*
2
 *   Copyright 2017 Martin Kacej <m.kacej@atlas.sk>
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 23 24
import QtQuick.Layouts 1.2
import org.kde.plasma.components 2.0 as PlasmaComponents
import org.kde.plasma.extras 2.0 as PlasmaExtras
Martin Kacej's avatar
Martin Kacej committed
25
import org.kde.plasma.networkmanagement 0.2 as PlasmaNM
Martin Kacej's avatar
Martin Kacej committed
26
import org.kde.kirigami 2.2 as Kirigami
27

Martin Kacej's avatar
Martin Kacej committed
28
Kirigami.ApplicationItem {
29 30
    id: main
    objectName: "wifiMain"
Martin Kacej's avatar
Martin Kacej committed
31 32 33 34 35
    //width: units.gridUnit * 30
    //height: width * 1.5

    pageStack.defaultColumnWidth: Kirigami.Units.gridUnit * 25
    pageStack.initialPage: formLayout
36

Jan Grulich's avatar
Jan Grulich committed
37
    PlasmaNM.Handler {
Martin Kacej's avatar
Martin Kacej committed
38 39
        id: handler
    }
40

Martin Kacej's avatar
Martin Kacej committed
41 42
    PlasmaNM.EnabledConnections {
        id: enabledConnections
43

Martin Kacej's avatar
Martin Kacej committed
44
        onWirelessEnabledChanged: {
45
            wifiSwitchButton.checked = wifiSwitchButton.enabled && enabled
Martin Kacej's avatar
Martin Kacej committed
46 47
        }
    }
48

Martin Kacej's avatar
Martin Kacej committed
49 50 51 52
    contextDrawer: Kirigami.ContextDrawer {
           id: contextDrawer
       }

Martin Kacej's avatar
Martin Kacej committed
53 54 55
    PlasmaNM.NetworkModel {
        id: connectionModel
    }
56

57 58
    PlasmaNM.MobileProxyModel {
        id: mobileProxyModel
Martin Kacej's avatar
Martin Kacej committed
59
        sourceModel: connectionModel
Jan Grulich's avatar
Jan Grulich committed
60
    }
61

62
    Item {
63 64 65 66
        id: formLayout
        anchors {
            fill: parent
        }
Jan Grulich's avatar
Jan Grulich committed
67 68
        RowLayout {
            id: layoutrow
69
            width: parent.width
70

Martin Kacej's avatar
Martin Kacej committed
71
            Controls.Label {
72 73 74 75
                anchors.left: parent.left
                text: i18n("Wifi")
                Layout.fillWidth: true
            }
76

77
            Controls.Switch {
78
                id: wifiSwitchButton
Martin Kacej's avatar
Martin Kacej committed
79
                checked: enabled && enabledConnections.wirelessEnabled
80
                enabled: enabledConnections.wirelessHwEnabled
81
                onClicked: {
Martin Kacej's avatar
Martin Kacej committed
82
                    handler.enableWireless(checked);
83 84 85
                }
            }
        }
86

Martin Kacej's avatar
Martin Kacej committed
87

88
        Rectangle {
Martin Kacej's avatar
bug  
Martin Kacej committed
89 90
            id: separator
            anchors.top: layoutrow.bottom
91
            width: parent.width
Jan Grulich's avatar
Jan Grulich committed
92
            height: units.gridUnit / 8
93 94
            border.color: "grey"
        }
95

Martin Kacej's avatar
Martin Kacej committed
96
        Controls.Label {
Jan Grulich's avatar
Jan Grulich committed
97 98
            id: label
            anchors {
Martin Kacej's avatar
bug  
Martin Kacej committed
99
                left: parent.left
100
                top: separator.bottom
Martin Kacej's avatar
Martin Kacej committed
101
                topMargin: units.gridUnit
Martin Kacej's avatar
bug  
Martin Kacej committed
102
            }
Martin Kacej's avatar
Martin Kacej committed
103 104
            text: i18n("Available wifi networks")
            font.bold: true
105 106 107
            Layout.fillWidth: true
        }

Martin Kacej's avatar
Martin Kacej committed
108
        Kirigami.ScrollablePage {
Jan Grulich's avatar
Jan Grulich committed
109
            id: wifiarea
Martin Kacej's avatar
bug  
Martin Kacej committed
110
            anchors {
111
                top: label.bottom
Martin Kacej's avatar
Martin Kacej committed
112
                bottomMargin: units.gridUnit * 2
Martin Kacej's avatar
bug  
Martin Kacej committed
113 114 115 116
                bottom: parent.bottom
                left: parent.left
                right: parent.right
            }
117

Martin Kacej's avatar
bug  
Martin Kacej committed
118
            ListView {
Jan Grulich's avatar
Jan Grulich committed
119
                id: view
Martin Kacej's avatar
bug  
Martin Kacej committed
120 121 122 123 124
                anchors.fill: parent
                clip: true
                width: parent.width
                currentIndex: -1
                boundsBehavior: Flickable.StopAtBounds
125
                model: mobileProxyModel
126
                delegate: RowItemDelegate {}
127
            }
Martin Kacej's avatar
Martin Kacej committed
128 129


130
        }
131

Martin Kacej's avatar
Martin Kacej committed
132
        Controls.Button {
Jan Grulich's avatar
Jan Grulich committed
133 134
            id: customConnectionButton
            anchors.top: wifiarea.bottom
135
            anchors.topMargin:  units.gridUnit
Jan Grulich's avatar
Jan Grulich committed
136
            text: i18n("Add custom connection")
Martin Kacej's avatar
Martin Kacej committed
137 138 139 140
            onClicked: {
                applicationWindow().pageStack.push(connectionEditorDialogcomponent)
                            //Qt.resolvedUrl("./ConnectionEditorDialog.qml"))
            }
141 142
        }
    }
Martin Kacej's avatar
bug  
Martin Kacej committed
143

Martin Kacej's avatar
Martin Kacej committed
144 145 146
    Component {
        id: connectionEditorDialogcomponent
        ConnectionEditorDialog {
147 148 149
        }
    }

Martin Kacej's avatar
Martin Kacej committed
150 151 152 153
    Component {
        id: networkDetailsViewComponent
        NetworkDetailsView {
            id: networkDetailsViewComponentView
154 155 156
        }
    }
}