ConnectionEditorDialog.qml 2.93 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
23 24
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.kirigami 2.2 as Kirigami
26

Martin Kacej's avatar
Martin Kacej committed
27
Kirigami.ScrollablePage{
28 29
    property var details
    property var str: 0
30 31 32
    property var connection : ({})
    property var wirelessSettings: ({})
    property var enabledSaving: (editorIpSection.enabledSave && editorSecuritySection.enabledSave && ssidField.text)
Martin Kacej's avatar
bug  
Martin Kacej committed
33

Martin Kacej's avatar
Martin Kacej committed
34 35
    title: i18n("Connection Editor")

Martin Kacej's avatar
Martin Kacej committed
36 37
    ColumnLayout{
        id: columnlayout
Martin Kacej's avatar
Martin Kacej committed
38
        anchors.horizontalCenter: parent.horizontalCenter
Martin Kacej's avatar
bug  
Martin Kacej committed
39

Martin Kacej's avatar
Martin Kacej committed
40
        Controls.Label {
Jan Grulich's avatar
Jan Grulich committed
41
            text: i18n("SSID")
42
            font.weight: Font.Bold
Martin Kacej's avatar
Martin Kacej committed
43
            anchors.horizontalCenter: parent.horizontalCenter
44
        }
Martin Kacej's avatar
bug  
Martin Kacej committed
45

Martin Kacej's avatar
Martin Kacej committed
46
        Controls.TextField {
47
            id: ssidField
Martin Kacej's avatar
Martin Kacej committed
48
            anchors.horizontalCenter: parent.horizontalCenter
Martin Kacej's avatar
Martin Kacej committed
49
            placeholderText: i18n("None")
50
        }
Martin Kacej's avatar
bug  
Martin Kacej committed
51

52
        IPDetailsSection {
53
            id: editorIpSection
Martin Kacej's avatar
Martin Kacej committed
54 55
            width: parent.width
            anchors.horizontalCenter: parent.horizontalCenter
56 57
        }

Jan Grulich's avatar
Jan Grulich committed
58
        SecuritySection {
59 60
            id: editorSecuritySection
            anchors.topMargin: units.gridUnit
Martin Kacej's avatar
Martin Kacej committed
61 62
            anchors.horizontalCenter: parent.horizontalCenter
            width: parent.width
Martin Kacej's avatar
Martin Kacej committed
63
        }
Martin Kacej's avatar
Martin Kacej committed
64
    }
Martin Kacej's avatar
Martin Kacej committed
65

Martin Kacej's avatar
Martin Kacej committed
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
    actions {
        left: Kirigami.Action {
            text: "save"
            enabled: enabledSaving
            onTriggered: {
                save()
                applicationWindow().pageStack.pop()
            }
        }
        right: Kirigami.Action {
            iconName: "cancel"
            onTriggered: {
                applicationWindow().pageStack.pop()
            }
        }
Martin Kacej's avatar
Martin Kacej committed
81
    }
Martin Kacej's avatar
Martin Kacej committed
82 83 84



85
    function save() {
86 87
        var m = ({});
        connection["id"] = ssidField.text
88
        connection["type"] = "802-11-wireless"
89 90 91 92 93 94
        wirelessSettings["mode"] = "infrastructure"
        m["connection"] = connection
        m["ipv4"] = editorIpSection.ipmap
        m["802-11-wireless"] = wirelessSettings
        handler.addConnectionFromQML(m)
        console.info('Connection saved '+ connection["id"])
Martin Kacej's avatar
Martin Kacej committed
95
    }
96
}