From 8e277235690e23876d70de50ea57c9ce739ce79b Mon Sep 17 00:00:00 2001 From: reionwong Date: Mon, 15 Nov 2021 15:09:29 +0800 Subject: [PATCH] Add proxy settings(GUI Only) --- src/images/sidebar/dark/proxy.svg | 14 ++ src/qml/Proxy/Main.qml | 208 ++++++++++++++++++++++++++++++ src/qml/SideBar.qml | 17 ++- src/qml/WLAN/Main.qml | 4 +- src/qml/WLAN/WifiView.qml | 5 +- src/resources.qrc | 2 + translations/en_US.ts | 103 +++++++++++---- translations/zh_CN.ts | 101 ++++++++++++--- 8 files changed, 405 insertions(+), 49 deletions(-) create mode 100755 src/images/sidebar/dark/proxy.svg create mode 100644 src/qml/Proxy/Main.qml diff --git a/src/images/sidebar/dark/proxy.svg b/src/images/sidebar/dark/proxy.svg new file mode 100755 index 0000000..34a5fa3 --- /dev/null +++ b/src/images/sidebar/dark/proxy.svg @@ -0,0 +1,14 @@ + + + + + + image/svg+xml + + + + + + + + diff --git a/src/qml/Proxy/Main.qml b/src/qml/Proxy/Main.qml new file mode 100644 index 0000000..a770612 --- /dev/null +++ b/src/qml/Proxy/Main.qml @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2021 CutefishOS Team. + * + * Author: Reion Wong + * + * 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 QtQml 2.15 +import QtQuick.Controls 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Dialogs 1.2 + +import FishUI 1.0 as FishUI +import Cutefish.Settings 1.0 +import "../" + +ItemPage { + headerTitle: qsTr("Proxy") + + Binding { + target: ftpProxyTextField + property: "text" + value: httpProxyField.text + when: forFtpCheckBox.checked + restoreMode: Binding.RestoreNone + } + + Binding { + target: ftpProxyPortField + property: "text" + value: httpProxyPortField.text + when: forFtpCheckBox.checked + restoreMode: Binding.RestoreNone + } + + Scrollable { + anchors.fill: parent + contentHeight: layout.implicitHeight + + ColumnLayout { + id: layout + anchors.fill: parent + spacing: FishUI.Units.largeSpacing * 2 + + RoundedItem { + id: mainItem + spacing: FishUI.Units.largeSpacing + + RadioButton { + id: noProxyRadioButton + checked: true + text: qsTr("No Proxy") + } + + RadioButton { + id: autoDiscoverProxyRadioButton + text: qsTr("Detect proxy configuration automatically") + } + + RadioButton { + id: autoScriptProxyRadioButton + text: qsTr("Use proxy auto configuration URL") + } + + RadioButton { + id: manualProxyRadioButton + text: qsTr("Use manually specified proxy configuration") + } + } + + RoundedItem { + id: proxyItem + visible: !noProxyRadioButton.checked && !autoDiscoverProxyRadioButton.checked + + RowLayout { + id: autoScriptProxyLayout + spacing: FishUI.Units.largeSpacing + visible: autoScriptProxyRadioButton.checked + + TextField { + id: autoScriptField + Layout.fillWidth: true + height: 40 + } + + Button { + text: qsTr("Select file") + flat: true + onClicked: fileDialog.open() + } + } + + // ---------------------- + GridLayout { + visible: manualProxyRadioButton.checked + columns: 4 + columnSpacing: FishUI.Units.largeSpacing + rowSpacing: FishUI.Units.largeSpacing + + Label { + text: qsTr("HTTP Proxy") + } + + TextField { + id: httpProxyField + Layout.fillWidth: true + height: 40 + } + + Label { + text: qsTr("Port") + } + + TextField { + id: httpProxyPortField + height: 40 + Layout.preferredWidth: 80 + } + + Item { + width: 1 + } + + CheckBox { + id: forFtpCheckBox + text: qsTr("Also use this proxy for FTP") + Layout.fillWidth: true + checked: true + } + + Item { + width: 1 + } + + Item { + width: 1 + } + + // FTP + Label { + text: qsTr("FTP Proxy") + } + + TextField { + id: ftpProxyTextField + Layout.fillWidth: true + height: 40 + enabled: !forFtpCheckBox.checked + } + + Label { + text: qsTr("Port") + } + + TextField { + id: ftpProxyPortField + height: 40 + Layout.preferredWidth: 80 + enabled: !forFtpCheckBox.checked + } + + // SOCKS + Label { + text: qsTr("SOCKS Proxy") + } + + TextField { + Layout.fillWidth: true + height: 40 + } + + Label { + text: qsTr("Port") + } + + TextField { + height: 40 + Layout.preferredWidth: 80 + } + } + } + + Item { + height: FishUI.Units.smallSpacing + } + } + } + + FileDialog { + id: fileDialog + onAccepted: { + autoScriptField.text = fileDialog.fileUrl.toString().replace("file://", "") + } + } +} diff --git a/src/qml/SideBar.qml b/src/qml/SideBar.qml index 84da208..9dd6945 100644 --- a/src/qml/SideBar.qml +++ b/src/qml/SideBar.qml @@ -87,11 +87,20 @@ Item { category: qsTr("Network and connection") } +// ListElement { +// title: qsTr("VPN") +// name: "vpn" +// page: "qrc:/qml/VPN/Main.qml" +// iconSource: "bluetooth.svg" +// iconColor: "#0067FF" +// category: qsTr("Network and connection") +// } + ListElement { - title: qsTr("VPN") - name: "vpn" - page: "qrc:/qml/VPN/Main.qml" - iconSource: "bluetooth.svg" + title: qsTr("Proxy") + name: "proxy" + page: "qrc:/qml/Proxy/Main.qml" + iconSource: "proxy.svg" iconColor: "#0067FF" category: qsTr("Network and connection") } diff --git a/src/qml/WLAN/Main.qml b/src/qml/WLAN/Main.qml index 3a60cc7..6adca08 100644 --- a/src/qml/WLAN/Main.qml +++ b/src/qml/WLAN/Main.qml @@ -58,7 +58,9 @@ ItemPage { id: configuration } - Component.onCompleted: handler.requestScan() + Component.onCompleted: { + handler.requestScan() + } Timer { id: scanTimer diff --git a/src/qml/WLAN/WifiView.qml b/src/qml/WLAN/WifiView.qml index 2cc7b8e..346e5cc 100644 --- a/src/qml/WLAN/WifiView.qml +++ b/src/qml/WLAN/WifiView.qml @@ -65,7 +65,6 @@ ColumnLayout { ListView { id: wirelessView Layout.fillWidth: true - Layout.preferredHeight: { var totalHeight = 0 for (var i = 0; i < wirelessView.visibleChildren.length; ++i) { @@ -74,6 +73,10 @@ ColumnLayout { return totalHeight } + Component.onCompleted: { + wirelessView.contentY = 0 + } + clip: true model: NM.AppletProxyModel { diff --git a/src/resources.qrc b/src/resources.qrc index 3a32491..0ce393b 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -121,5 +121,7 @@ images/dock_straight.svg qml/Bluetooth/PairDialog.qml qml/VPN/Main.qml + qml/Proxy/Main.qml + images/sidebar/dark/proxy.svg diff --git a/translations/en_US.ts b/translations/en_US.ts index 5fb3d82..f68fa64 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -622,6 +622,63 @@ VPN + + + Proxy + + + + + No Proxy + + + + + Detect proxy configuration automatically + + + + + Use proxy auto configuration URL + + + + + Use manually specified proxy configuration + + + + + Select file + + + + + HTTP Proxy + + + + + + + Port + + + + + Also use this proxy for FTP + + + + + FTP Proxy + + + + + SOCKS Proxy + + PairDialog @@ -672,12 +729,12 @@ SideBar - + User - + Display @@ -690,7 +747,7 @@ - + Network and connection @@ -700,26 +757,31 @@ - + + Proxy + + + + Display and appearance - + Appearance Appearance - + Mouse - + Fonts @@ -729,59 +791,54 @@ Bluetooth - - VPN - - - - + Background - + Dock - - - + + + System - + Touchpad - + Date & Time - + Language Language - + Battery - + Power - + About About diff --git a/translations/zh_CN.ts b/translations/zh_CN.ts index d1b047c..e4145fc 100644 --- a/translations/zh_CN.ts +++ b/translations/zh_CN.ts @@ -622,6 +622,63 @@ VPN VPN + + + Proxy + 代理 + + + + No Proxy + 不使用代理 + + + + Detect proxy configuration automatically + 自动检测代理配置 + + + + Use proxy auto configuration URL + 使用代理自动配置 URL + + + + Use manually specified proxy configuration + 使用手动配置的代理服务器 + + + + Select file + 选择文件 + + + + HTTP Proxy + HTTP 代理 + + + + + + Port + 端口 + + + + Also use this proxy for FTP + 将此代理用于 FTP + + + + FTP Proxy + FTP 代理 + + + + SOCKS Proxy + SOCKS 代理 + PairDialog @@ -672,7 +729,7 @@ SideBar - + Display 显示 @@ -680,7 +737,7 @@ - + Network and connection 网络与连接 @@ -690,41 +747,46 @@ 以太网络 - + + Proxy + 代理 + + + Display and appearance 显示与外观 - + Appearance 外观 - + Mouse 鼠标 - + Fonts 字体 - + Dock 程序坞 - + User 用户 - + Background 背景 @@ -739,49 +801,48 @@ 蓝牙 - VPN - VPN + VPN - - - + + + System 系统 - + Touchpad 触摸版 - + Date & Time 日期和时间 - + Language 语言 - + Battery 电池 - + Power 电源 - + About 关于