diff --git a/src/qml/WiFiConnectionDialog.qml b/src/qml/WiFiConnectionDialog.qml new file mode 100644 index 00000000..b7f7f80c --- /dev/null +++ b/src/qml/WiFiConnectionDialog.qml @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2023 - Arseniy Movshev + * 2022 - Ed Beroset + * 2017-2022 - Chupligin Sergey + * 2021 - Darrel Griët + * 2016 - Sylvia van Os + * 2015 - Florent Revest + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* A large proportion of this code has been referenced from Nemomobile-UX Glacier-Settings, published at https://github.com/nemomobile-ux/glacier-settings/blob/master/src/plugins/wifi/WifiSettings.qml + */ + +import QtQuick 2.9 +import org.asteroid.controls 1.0 +import org.asteroid.utils 1.0 +import Connman 0.2 +import QtQuick.VirtualKeyboard 2.4 + +Item { + id: dialogItem + property var modelData + + property real rowHeight: Dims.h(25) + property real rowMargin: Dims.w(15) + + InputPanel { + id: inputPanel + z: 99 + visible: active + anchors.left: parent.left + anchors.top: parent.top + anchors.topMargin: -Dims.h(25) + height: Dims.h(100) + + width: Dims.w(100) + externalLanguageSwitchEnabled: false + } + + UserAgent { + id: userAgent + onUserInputRequested: { + var view = { + "fields": [] + } + for (var key in fields) { + view.fields.push({ + "name": key, + "id": key.toLowerCase(), + "type": fields[key]["Type"], + "requirement": fields[key]["Requirement"] + }) + console.log(key + ":") + for (var inkey in fields[key]) { + console.log(" " + inkey + ": " + fields[key][inkey]) + } + } + userAgent.sendUserReply({"Passphrase": passphraseField.text}) + } + + onErrorReported: { + console.log("Got error from model: " + error) + failDialog.subLabelText = error + failDialog.open() + } + } + Connections { + target: modelData + function onConnectRequestFailed(error) { + console.log(error) + } + + function onConnectedChanged(connected) { + if(connected) { + layerStack.pop(layerStack.currentLayer) + } + } + } + Flickable { + anchors.fill: parent + contentHeight: contentColumn.implicitHeight + Column { + id: contentColumn + width: parent.width + Item {height: Dims.h(15); width: parent.width} + Marquee { + anchors { + left: parent.left + right: parent.right + leftMargin: dialogItem.rowMargin + rightMargin: dialogItem.rowMargin + } + text: modelData.name + font.pixelSize: Dims.l(6) + height: Dims.l(8) + } + Column { + id: loginFieldsColumn + visible: !(modelData.connected || modelData.favorite) + anchors { + left: parent.left + right: parent.right + leftMargin: dialogItem.rowMargin + rightMargin: dialogItem.rowMargin + } + Label { + id: identityLabel + text: qsTrId("id-wifi-login")+":" + font.pixelSize: Dims.l(6) + visible: modelData.securityType === NetworkService.SecurityIEEE802 + } + + TextField { + id: identityField + text: modelData.identity + width: parent.width + visible: modelData.securityType === NetworkService.SecurityIEEE802 + } + + Label { + id: passphraseLabel + text: qsTrId("id-wifi-password")+":" + font.pixelSize: Dims.l(6) + visible: !(modelData.securityType == NetworkService.SecurityNone) + } + + TextField { + id: passphraseField + text: modelData.passphrase + echoMode: TextInput.Password //smartwatches are hard to type on. it is worth adding a 'show password' button for this field + width: parent.width + height: dialogItem.rowHeight + visible: !(modelData.securityType == NetworkService.SecurityNone) + } + } + Column { + visible: modelData.connected + width: parent.width + Label { + anchors { + left: parent.left + right: parent.right + leftMargin: dialogItem.rowMargin + rightMargin: dialogItem.rowMargin + } + text: "IP: " + modelData.ipv4["Address"] + horizontalAlignment: Text.AlignHCenter + font.pixelSize: Dims.l(6) + } + LabeledActionButton { + width: parent.width + height: dialogItem.rowHeight + text: qsTrId("id-wifi-disconnect") + icon: "ios-close-circle-outline" + onClicked: { + modelData.requestDisconnect() + layerStack.pop(layerStack.currentLayer) + } + } + } + LabeledSwitch { + id: autoConnectCheckBox + width: parent.width + height: dialogItem.rowHeight + text: qsTrId("id-wifi-autoconnect") + checked: modelData.autoConnect + } + LabeledActionButton { + visible: modelData.connected || modelData.favorite + width: parent.width + height: dialogItem.rowHeight + text: qsTrId("id-wifi-removenetwork") + icon: "ios-remove-circle-outline" + onClicked: { + modelData.remove() + layerStack.pop(layerStack.currentLayer) + } + } + + IconButton { + iconName: "ios-checkmark-circle-outline" + height: width + width: Dims.w(20) + anchors.horizontalCenter: parent.horizontalCenter + onClicked: { + if(!modelData.connected) { + modelData.passphrase = passphraseField.text + modelData.identity = identityField.text + } + modelData.autoConnect = autoConnectCheckBox.checked + modelData.requestConnect() + } + } + } + } +} diff --git a/src/qml/WiFiPage.qml b/src/qml/WiFiPage.qml new file mode 100644 index 00000000..708653c8 --- /dev/null +++ b/src/qml/WiFiPage.qml @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2023 - Arseniy Movshev + * 2017-2022 - Chupligin Sergey + * 2021 - Darrel Griët + * 2016 - Sylvia van Os + * 2015 - Florent Revest + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, 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 General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/* A large proportion of this code has been referenced from Nemomobile-UX Glacier-Settings, published at https://github.com/nemomobile-ux/glacier-settings/blob/master/src/plugins/wifi/WifiSettings.qml + */ + +import QtQuick 2.9 +import org.asteroid.controls 1.0 +import org.asteroid.utils 1.0 +import Connman 0.2 +import QtQuick.VirtualKeyboard 2.4 + +Item { + id: root + TechnologyModel { + id: wifiModel + name: "wifi" + onCountChanged: { + console.log("COUNT CHANGE " + count) + } + onScanRequestFinished: { + console.log("SCAN FINISH") + } + } + + NetworkTechnology { + id: wifiStatus + path: "/net/connman/technology/wifi" + onPoweredChanged: { + console.log("POWER CHANGE ") + powered + if (powered) + wifiModel.requestScan() + } + } + + ListView { + id: wifiList + model: wifiModel + width: parent.width*0.7 + anchors.horizontalCenter: parent.horizontalCenter + height: parent.height + header: Item { + //this is literally a statuspage + width: root.width + height: wifiStatus.powered ? width*0.6 : root.height + Behavior on height { NumberAnimation { duration: 100 } } + anchors.horizontalCenter: parent.horizontalCenter + Rectangle { + id: statusIconBackground + anchors.centerIn: parent + anchors.verticalCenterOffset: -parent.width*0.13 + color: "black" + radius: width/2 + opacity: wifiStatus.powered ? 0.4 : 0.2 + width: parent.width*0.25 + height: width + Icon { + id: statusIcon + anchors.fill: statusIconBackground + anchors.margins: parent.width*0.12 + name: wifiStatus.powered ? "ios-wifi" : "ios-wifi-outline" + } + MouseArea { + id: statusMA + enabled: true + anchors.fill: parent + onClicked: wifiStatus.powered = !wifiStatus.powered + } + } + + + Label { + id: statusLabel + font.pixelSize: parent.width*0.07 + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + wrapMode: Text.Wrap + anchors.left: parent.left; anchors.right: parent.right + anchors.leftMargin: parent.width*0.04; anchors.rightMargin: anchors.leftMargin + anchors.verticalCenter: parent.verticalCenter + anchors.verticalCenterOffset: parent.width*0.15 + text: "

" + (wifiStatus.powered ? qsTrId("id-wifi-on"): qsTrId("id-wifi-off")) + "

\n" + (wifiStatus.connected ? qsTrId("id-wifi-connected") : qsTrId("id-wifi-disconnected")) + } + } + + footer: Item {height: wifiStatus.powered ? root.height*0.15 : 0; width: parent.width} + + delegate: MouseArea { + property var wifiName: modelData.name + visible: wifiStatus.powered + width: wifiList.width + height: wifiStatus.powered ? width*0.23 : 0 + Marquee { + id: wifiNameLabel + text: wifiName + height: parent.height*0.6 + width: parent.width + } + Label { + anchors.top: wifiNameLabel.bottom + anchors.horizontalCenter: parent.horizontalCenter + opacity: 0.8 + font.pixelSize: parent.width*0.07 + font.weight: Font.Thin + text: { + if (modelData.connected) { + qsTrId("id-wifi-connected") + } else if (modelData.favorite){ + qsTrId("id-wifi-saved") + } else { + qsTrId("id-wifi-notsetup") + } + } + } + onClicked: { + if (modelData.favorite && !modelData.connected) { + modelData.requestConnect() + } else { + layerStack.push(connectionDialog, {modelData: modelData}) + } + } + onPressAndHold: layerStack.push(connectionDialog, {modelData: modelData}) + } + } + + Component { + id: connectionDialog + WiFiConnectionDialog {} + } +} + diff --git a/src/qml/main.qml b/src/qml/main.qml index 6ebdfd87..03a6b600 100644 --- a/src/qml/main.qml +++ b/src/qml/main.qml @@ -33,6 +33,7 @@ Application { Component { id: timezoneLayer; TimezonePage { } } Component { id: languageLayer; LanguagePage { } } Component { id: bluetoothLayer; BluetoothPage { } } + Component { id: wifiLayer; WiFiPage { } } Component { id: displayLayer; DisplayPage { } } Component { id: soundLayer; SoundPage { } } Component { id: nightstandLayer; NightstandPage { } } @@ -141,6 +142,55 @@ Application { iconName: "ios-bluetooth-outline" onClicked: layerStack.push(bluetoothLayer) } + ListItem { + //% "WiFi" + title: qsTrId("id-wifi-page") + iconName: "ios-wifi-outline" + onClicked: layerStack.push(wifiLayer) + } + ListItem { + //% "Display" + title: qsTrId("id-display-page") + iconName: "ios-sunny-outline" + onClicked: layerStack.push(displayLayer) + } + ListItem { + //% "Sound" + title: qsTrId("id-sound-page") + iconName: "ios-volume-up" + onClicked: layerStack.push(soundLayer) + visible: DeviceInfo.hasSpeaker + } + ListItem { + //% "Nightstand" + title: qsTrId("id-nightstand-page") + iconName: "ios-moon-outline" + onClicked: layerStack.push(nightstandLayer) + } + ListItem { + //% "Units" + title: qsTrId("id-units-page") + iconName: "ios-speedometer-outline" + onClicked: layerStack.push(unitsLayer) + } + ListItem { + //% "Wallpaper" + title: qsTrId("id-wallpaper-page") + iconName: "ios-images-outline" + onClicked: layerStack.push(wallpaperLayer) + } + ListItem { + //% "Watchface" + title: qsTrId("id-watchface-page") + iconName: "ios-color-wand-outline" + onClicked: layerStack.push(watchfaceLayer) + } + ListItem { + //% "Launcher" + title: qsTrId("id-launcher-page") + iconName: "ios-apps-outline" + onClicked: layerStack.push(launcherLayer) + } ListItem { //% "USB" title: qsTrId("id-usb-page") diff --git a/src/resources.qrc b/src/resources.qrc index 46916774..76ae05b9 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -14,6 +14,8 @@ qml/WallpaperPage.qml qml/WatchfacePage.qml qml/WatchfaceSelector.qml + qml/WiFiConnectionDialog.qml + qml/WiFiPage.qml qml/LauncherPage.qml qml/USBPage.qml qml/PowerPage.qml