diff --git a/src/qml/WLAN/ConnectDialog.qml b/src/qml/WLAN/ConnectDialog.qml new file mode 100644 index 0000000..b42cdc7 --- /dev/null +++ b/src/qml/WLAN/ConnectDialog.qml @@ -0,0 +1,126 @@ +/* + * 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.12 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +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 + + 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 | Qt.WindowStaysOnTopHint + + signal connect(var devicePath, var specificPath, var password) + + property var name: "" + property var devicePath: "" + property var specificPath: "" + property var securityType: "" + + onVisibleChanged: { + if (visible) + passwordField.forceActiveFocus() + } + + headerItem: Item { + Label { + anchors.centerIn: parent + text: qsTr("Enter Password") + } + } + + ColumnLayout { + id: _mainLayout + anchors.fill: parent + anchors.margins: FishUI.Units.largeSpacing + anchors.topMargin: 0 + spacing: FishUI.Units.largeSpacing + + Label { + text: qsTr("Enter the password for %1").arg(control.name) + color: FishUI.Theme.disabledTextColor + wrapMode: Text.WordWrap + } + + TextField { + id: passwordField + focus: true + echoMode: TextInput.Password + selectByMouse: true + placeholderText: qsTr("Password") + + validator: RegExpValidator { + regExp: { + if (control.securityType === NM.Enums.StaticWep) + return /^(?:[\x20-\x7F]{5}|[0-9a-fA-F]{10}|[\x20-\x7F]{13}|[0-9a-fA-F]{26}){1}$/; + return /^(?:[\x20-\x7F]{8,64}){1}$/; + } + } + + onAccepted: { + control.emitSignal() + } + + Keys.onEscapePressed: { + control.visible = false + } + + Layout.fillWidth: true + } + + RowLayout { + spacing: FishUI.Units.largeSpacing + + Button { + text: qsTr("Cancel") + Layout.fillWidth: true + onClicked: control.visible = false + } + + Button { + text: qsTr("Connect") + flat: true + Layout.fillWidth: true + enabled: passwordField.acceptableInput + onClicked: control.emitSignal() + } + } + } + + function emitSignal() { + control.connect(control.devicePath, control.specificPath, passwordField.text) + control.visible = false + } +} diff --git a/src/qml/WLAN/WifiItem.qml b/src/qml/WLAN/WifiItem.qml index 607a9b5..6f1715b 100644 --- a/src/qml/WLAN/WifiItem.qml +++ b/src/qml/WLAN/WifiItem.qml @@ -67,7 +67,15 @@ Item { if (busyIndicator.visible) return - additionalSettings.toggle() + if ((!model.uuid || predictableWirelessPassword)) { + connectDialog.name = model.itemUniqueName + connectDialog.securityType = model.securityType + connectDialog.devicePath = model.devicePath + connectDialog.specificPath = model.specificPath + connectDialog.show() + } else { + additionalSettings.toggle() + } // if (model.uuid || !predictableWirelessPassword) { // if (connectionState === NM.Enums.Deactivated) { diff --git a/src/qml/WLAN/WifiView.qml b/src/qml/WLAN/WifiView.qml index 346e5cc..ae2716c 100644 --- a/src/qml/WLAN/WifiView.qml +++ b/src/qml/WLAN/WifiView.qml @@ -27,6 +27,20 @@ ColumnLayout { id: _contentLayout spacing: FishUI.Units.largeSpacing + ConnectDialog { + id: connectDialog + + onConnect: { + handler.addAndActivateConnection(connectDialog.devicePath, + connectDialog.specificPath, + password) + + console.log(connectDialog.devicePath + ", " + + connectDialog.specificPath + ", " + + password) + } + } + RowLayout { spacing: FishUI.Units.smallSpacing * 1.5 diff --git a/src/qml/Wallpaper/Main.qml b/src/qml/Wallpaper/Main.qml index 62ca11a..44cace1 100644 --- a/src/qml/Wallpaper/Main.qml +++ b/src/qml/Wallpaper/Main.qml @@ -121,7 +121,7 @@ ItemPage { // Preload image Image { anchors.centerIn: parent - width: 48 + width: 32 height: width sourceSize: Qt.size(width, height) source: FishUI.Theme.darkMode ? "qrc:/images/dark/picture.svg" diff --git a/src/resources.qrc b/src/resources.qrc index 0c71438..178c725 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -143,5 +143,6 @@ images/sidebar/dark/defaultapps.svg qml/Notification/Main.qml images/sidebar/dark/notifications.svg + qml/WLAN/ConnectDialog.qml diff --git a/translations/en_US.ts b/translations/en_US.ts index 438025d..66b9b71 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -14,6 +14,34 @@ Bluetooth is disabled + + ConnectDialog + + + Enter Password + + + + + Enter the password for %1 + + + + + Password + Password + + + + Cancel + Cancel + + + + Connect + + + LanguagePage @@ -395,42 +423,42 @@ - + 2 Minutes - + 5 Minutes - + 10 Minutes - + 15 Minutes - + 30 Minutes - + Never - + Hibernate after screen is turned off - + Lock screen after screen is turned off @@ -1039,24 +1067,24 @@ WifiItem - - + + Password Password - + Cancel Cancel - - + + Connect - + Disconnect @@ -1064,7 +1092,7 @@ WifiView - + WLAN diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index 6f21bb2..7ede622 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -14,6 +14,34 @@ 蓝牙已禁用 + + ConnectDialog + + + Enter Password + 输入密码 + + + + Enter the password for %1 + 输入 %1 密码 + + + + Password + 密码 + + + + Cancel + 取消 + + + + Connect + 连接 + + LanguagePage @@ -395,42 +423,42 @@ 关闭屏幕 - + 2 Minutes 2分钟 - + 5 Minutes 5分钟 - + 10 Minutes 10分钟 - + 15 Minutes 15分钟 - + 30 Minutes 30分钟 - + Never 永不 - + Hibernate after screen is turned off 关闭屏幕后休眠 - + Lock screen after screen is turned off 关闭屏幕后锁屏 @@ -1039,24 +1067,24 @@ WifiItem - - + + Password 密码 - + Cancel 取消 - - + + Connect 连接 - + Disconnect 断开连接 @@ -1064,7 +1092,7 @@ WifiView - + WLAN 无线网络