diff --git a/mobile/wifi/package/contents/ui/ConnectionItemDelegate.qml b/mobile/wifi/package/contents/ui/ConnectionItemDelegate.qml index acd4fce7..0ac247a4 100644 --- a/mobile/wifi/package/contents/ui/ConnectionItemDelegate.qml +++ b/mobile/wifi/package/contents/ui/ConnectionItemDelegate.qml @@ -1,158 +1,152 @@ /* * Copyright 2017 Martin Kacej * * 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. */ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 as Controls import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kirigami 2.2 as Kirigami Kirigami.SwipeListItem { enabled: true //backgroundColor: theme.backgroundColor property var map : [] property bool predictableWirelessPassword: !Uuid && Type == PlasmaNM.Enums.Wireless && (SecurityType == PlasmaNM.Enums.StaticWep || SecurityType == PlasmaNM.Enums.WpaPsk || SecurityType == PlasmaNM.Enums.Wpa2Psk) RowLayout { anchors.leftMargin: Kirigami.Units.largeSpacing * 5 spacing: Kirigami.Units.largeSpacing Kirigami.Separator {} Item { Layout.preferredWidth: Kirigami.Units.gridUnit Layout.preferredHeight: Kirigami.Units.gridUnit PlasmaCore.SvgItem { id: connectionSvgIcon elementId: mobileProxyModel.showSavedMode ? "network-wireless-connected-100" : ConnectionIcon svg: PlasmaCore.Svg { multipleImages: true imagePath: "icons/network" colorGroup: PlasmaCore.ColorScope.colorGroup } } Controls.BusyIndicator { id: connectingIndicator anchors { horizontalCenter: connectionSvgIcon.horizontalCenter verticalCenter: connectionSvgIcon.verticalCenter } running: ConnectionState == PlasmaNM.Enums.Activating visible: running } } Controls.Label { id: connectionNameLabel Layout.fillWidth: true visible: !connectionPasswordField.visible elide: Text.ElideRight font.weight: ConnectionState == PlasmaNM.Enums.Activated ? Font.DemiBold : Font.Normal font.italic: ConnectionState == PlasmaNM.Enums.Activating ? true : false text: ItemUniqueName textFormat: Text.PlainText } PasswordField { id: connectionPasswordField Layout.fillWidth: true implicitWidth: Kirigami.Units.gridUnit *16 securityType: SecurityType visible: false onVisibleChanged: { if (visible) forceActiveFocus() connectionPasswordField.text = "" } onAccepted: { if (acceptableInput) handler.addAndActivateConnection(DevicePath, SpecificPath, connectionPasswordField.text); } } } actions: [ Kirigami.Action { iconName: "network-connect" visible: ConnectionState != PlasmaNM.Enums.Activated && Signal > 0 onTriggered: changeState() }, Kirigami.Action { iconName: "network-disconnect" visible: ConnectionState == PlasmaNM.Enums.Activated onTriggered: handler.deactivateConnection(ConnectionPath, DevicePath) }, Kirigami.Action { iconName: "configure" visible: (Uuid != "")? true : false onTriggered: { kcm.push("NetworkSettings.qml", {path: ConnectionPath}) } }, Kirigami.Action { iconName: "entry-delete" visible: (Uuid != "")? true : false - onTriggered: forgetNetwork() + onTriggered: handler.removeConnection(ConnectionPath) } ] onClicked: { changeState() } function changeState() { if (Signal === 0) return if (Uuid || !predictableWirelessPassword || connectionPasswordField.visible) { if (ConnectionState == PlasmaNM.Enums.Deactivated) { if (!predictableWirelessPassword && !Uuid) { handler.addAndActivateConnection(DevicePath, SpecificPath); } else if (connectionPasswordField.visible) { if (connectionPasswordField.text != "") { handler.addAndActivateConnection(DevicePath, SpecificPath, connectionPasswordFieldField.text); connectionPasswordField.visible = false; } else { connectionPasswordField.visible = false; } } else { handler.activateConnection(ConnectionPath, DevicePath, SpecificPath); } } else{ //show popup } } else if (predictableWirelessPassword) { connectionPasswordField.visible = true; } } - - function forgetNetwork() { - deleteConnectionDialog.name = ItemUniqueName - deleteConnectionDialog.dbusPath = ConnectionPath - deleteConnectionDialog.open() - } } diff --git a/mobile/wifi/package/contents/ui/main.qml b/mobile/wifi/package/contents/ui/main.qml index c2066e6d..cccb99cc 100644 --- a/mobile/wifi/package/contents/ui/main.qml +++ b/mobile/wifi/package/contents/ui/main.qml @@ -1,199 +1,163 @@ /* * Copyright 2017 Martin Kacej * * 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. */ import QtQuick 2.6 import QtQuick.Layouts 1.2 import QtQuick.Controls 2.2 as Controls import org.kde.plasma.networkmanagement 0.2 as PlasmaNM import org.kde.kirigami 2.10 as Kirigami import org.kde.kcm 1.1 SimpleKCM { id: main PlasmaNM.Handler { id: handler } PlasmaNM.EnabledConnections { id: enabledConnections onWirelessEnabledChanged: { wifiSwitchButton.checked = wifiSwitchButton.enabled && enabled } } PlasmaNM.NetworkModel { id: connectionModel } PlasmaNM.MobileProxyModel { id: mobileProxyModel sourceModel: connectionModel showSavedMode: false } Component.onCompleted: handler.requestScan() Timer { id: scanTimer interval: 10200 repeat: true running: parent.visible onTriggered: handler.requestScan() } header: Kirigami.InlineMessage { id: inlineError Layout.fillWidth: true showCloseButton: true visible: false type: Kirigami.MessageType.Warning Connections { target: handler onConnectionActivationFailed: { inlineError.text = message; inlineError.visible = true; } } } ListView { id: view anchors.fill: parent clip: true width: parent.width currentIndex: -1 boundsBehavior: Flickable.StopAtBounds section.property: "Section" section.delegate: Kirigami.ListSectionHeader { text: section } model: mobileProxyModel delegate: ConnectionItemDelegate {} } actions.main: Kirigami.Action { iconName: enabledConnections.wirelessEnabled ? "network-wireless-disconnected" : "network-wireless-connected" text: enabledConnections.wirelessEnabled ? i18n("Disable Wi-Fi") : i18n("Enable Wi-Fi") onTriggered: handler.enableWireless(!enabledConnections.wirelessEnabled); } actions.contextualActions: [ Kirigami.Action { iconName: "edit" text: i18n("Add custom connection") onTriggered: { kcm.push("ConnectionEditor.qml") contextDrawer.close() } }, Kirigami.Action { iconName: "edit" text: i18n("Create Hotspot") onTriggered: { kcm.push("TetheringSetting.qml") contextDrawer.close() } }, Kirigami.Action { iconName: "edit" text: i18n("Saved Connections") checkable: true checked: false onTriggered: { mobileProxyModel.showSavedMode = !mobileProxyModel.showSavedMode } } ] /* footer: Controls.Button { width: parent.width text: "ContextualActions" iconName: "edit" onClicked: bottomDrawer.open() } Kirigami.OverlayDrawer { id: bottomDrawer edge: Qt.BottomEdge contentItem: Item { implicitHeight: childrenRect.height + Kirigami.Units.gridUnit ColumnLayout{ anchors.centerIn: parent Controls.Button { text: "Add custom connection" onClicked: applicationWindow().pageStack.push(connectionEditorDialogComponent) } Controls.Button { text: "Create Hotspot" onClicked: showPassiveNotification("Open tethering") } Item { Layout.minimumHeight: Units.gridUnit * 4 } } } } */ - Kirigami.OverlayDrawer { - id: deleteConnectionDialog - property var name - property var dbusPath - edge: Qt.BottomEdge - - contentItem: Column { - anchors.centerIn: parent - spacing: Kirigami.Units.largeSpacing - bottomPadding: Kirigami.Units.largeSpacing - - Controls.Label { - anchors.horizontalCenter: parent.horizontalCenter - text: i18n("Delete connection %1 from device?", deleteConnectionDialog.name) - } - Controls.Button { - text: i18n("Delete") - anchors.horizontalCenter: parent.horizontalCenter - onClicked: { - handler.removeConnection(deleteConnectionDialog.dbusPath) - deleteConnectionDialog.close() - } - } - Controls.Button { - text: i18n("Cancel") - anchors.horizontalCenter: parent.horizontalCenter - onClicked: deleteConnectionDialog.close() - } - } - onVisibleChanged: { - if (!visible) { - deleteConnectionDialog.name = "" - deleteConnectionDialog.dbusPath = "" - } - } - } }