diff --git a/src/qml/WLAN/Main.qml b/src/qml/WLAN/Main.qml index 6adca08..9a7c72a 100644 --- a/src/qml/WLAN/Main.qml +++ b/src/qml/WLAN/Main.qml @@ -58,6 +58,14 @@ ItemPage { id: configuration } + NewNetworkDialog { + id: newNetworkDialog + + onConnect: { + wifiSettings.addOtherConnection(ssid, username, pwd, type) + } + } + Component.onCompleted: { handler.requestScan() } @@ -88,6 +96,12 @@ ItemPage { } } + StandardButton { + Layout.fillWidth: true + text: qsTr("Add other...") + onClicked: newNetworkDialog.show() + } + // Hotspot // 还未完善 // RoundedItem { diff --git a/src/qml/WLAN/NewNetworkDialog.qml b/src/qml/WLAN/NewNetworkDialog.qml new file mode 100644 index 0000000..ee6fe23 --- /dev/null +++ b/src/qml/WLAN/NewNetworkDialog.qml @@ -0,0 +1,155 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Kate Leet + * + * 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 + * 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 . + */ + +import QtQuick 2.4 +import QtQuick.Controls 2.4 +import QtQuick.Layouts 1.3 +import QtGraphicalEffects 1.0 + +import FishUI 1.0 as FishUI +import Cutefish.NetworkManagement 1.0 as NM + +FishUI.Window { + id: control + + width: contentWidth + height: contentHeight + minimumWidth: contentWidth + minimumHeight: contentHeight + maximumWidth: contentWidth + maximumHeight: contentHeight + modality: Qt.WindowModal + + property int contentWidth: _mainLayout.implicitWidth + header.height + FishUI.Units.largeSpacing * 2 + property int contentHeight: _mainLayout.implicitHeight + header.height + FishUI.Units.largeSpacing * 2 + + visible: false + minimizeButtonVisible: false + + background.color: FishUI.Theme.secondBackgroundColor + flags: Qt.Dialog | Qt.FramelessWindowHint + + signal connect(var ssid, var username, var pwd, var type) + + onVisibleChanged: { + if (visible) { + _userNameTextField.forceActiveFocus() + } else { + _nameTextField.clear() + _userNameTextField.clear() + _passwordTextField.clear() + securitybox.currentIndex = 2 + } + } + + ColumnLayout { + id: _mainLayout + anchors.fill: parent + anchors.margins: FishUI.Units.largeSpacing + anchors.topMargin: 0 + spacing: FishUI.Units.largeSpacing + + GridLayout { + columns: 2 + columnSpacing: FishUI.Units.largeSpacing * 2 + rowSpacing: FishUI.Units.largeSpacing + + Label { + text: qsTr("Name") + } + + TextField { + id: _nameTextField + placeholderText: qsTr("Network Name") + Layout.fillWidth: true + Keys.onEscapePressed: control.close() + } + + Label { + text: qsTr("Security") + } + + ComboBox { + id: securitybox + Layout.fillWidth: true + currentIndex: 2 + model: [ qsTr("None"), "WEP", "WPA/WPA2", "WPA3" ] + } + + Label { + visible: securitybox.currentIndex === 1 + text: qsTr("UserName") + } + + TextField { + id: _userNameTextField + visible: securitybox.currentIndex === 1 + placeholderText: qsTr("Password") + focus: true + Layout.fillWidth: true + Keys.onEscapePressed: control.close() + } + + Label { + visible: securitybox.currentIndex != 0 + text: qsTr("Password") + } + + TextField { + visible: securitybox.currentIndex != 0 + id: _passwordTextField + placeholderText: qsTr("Password") + echoMode: TextInput.Password + Layout.fillWidth: true + Keys.onEscapePressed: control.close() + } + } + + RowLayout { + spacing: FishUI.Units.largeSpacing + + Button { + text: qsTr("Cancel") + Layout.fillWidth: true + onClicked: control.close() + } + + Button { + enabled: _nameTextField.text != "" + & (_passwordTextField.text.length > 7 | securitybox.currentIndex === 0) + flat: true + text: qsTr("Join") + Layout.fillWidth: true + onClicked: { + var security_type = securitybox.currentText + + if (security_type.currentIndex === 0) + type = "None" + + control.connect(_nameTextField.text, + _userNameTextField.text, + _passwordTextField.text, + security_type) + + control.close() + } + } + } + } +} diff --git a/src/qml/WLAN/WifiView.qml b/src/qml/WLAN/WifiView.qml index ae2716c..ea6c8f7 100644 --- a/src/qml/WLAN/WifiView.qml +++ b/src/qml/WLAN/WifiView.qml @@ -20,6 +20,8 @@ import QtQuick 2.12 import QtQuick.Controls 2.12 import QtQuick.Layouts 1.12 +import "../" + import FishUI 1.0 as FishUI import Cutefish.NetworkManagement 1.0 as NM diff --git a/src/resources.qrc b/src/resources.qrc index 178c725..e02233f 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -144,5 +144,6 @@ qml/Notification/Main.qml images/sidebar/dark/notifications.svg qml/WLAN/ConnectDialog.qml + qml/WLAN/NewNetworkDialog.qml diff --git a/translations/en_US.ts b/translations/en_US.ts index eb000c2..73a6563 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -544,6 +544,11 @@ WLAN + + + Add other... + + @@ -656,6 +661,7 @@ + Save @@ -746,34 +752,34 @@ - + Select file - + HTTP Proxy - - - + + + Port - + Also use this proxy for FTP - + FTP Proxy - + SOCKS Proxy @@ -828,6 +834,51 @@ + + NewNetworkDialog + + + Name + + + + + Network Name + + + + + Security + + + + + None + + + + + UserName + + + + + + + Password + Password + + + + Cancel + Cancel + + + + Join + + + PairDialog @@ -1107,7 +1158,7 @@ WifiView - + WLAN diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 822a54d..8e4f137 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -544,6 +544,11 @@ WLAN 无线网络 + + + Add other... + 添加其他网络... + @@ -656,6 +661,7 @@ + Save 保存 @@ -746,34 +752,34 @@ 使用手动配置的代理服务器 - + Select file 选择文件 - + HTTP Proxy HTTP 代理 - - - + + + Port 端口 - + Also use this proxy for FTP 将此代理用于 FTP - + FTP Proxy FTP 代理 - + SOCKS Proxy SOCKS 代理 @@ -828,6 +834,51 @@ 勿扰模式 + + NewNetworkDialog + + + Name + 名称 + + + + Network Name + 网络名称 + + + + Security + 安全性 + + + + None + + + + + UserName + 用户名 + + + + + + Password + 密码 + + + + Cancel + 取消 + + + + Join + 添加 + + PairDialog @@ -1107,7 +1158,7 @@ WifiView - + WLAN 无线网络