Port the network proxy page to mobileform

This commit is contained in:
Gary Wang
2022-11-16 23:07:37 +08:00
committed by Carl Schwan
parent 73e7f3eaf1
commit ff98e378e6

View File

@@ -6,6 +6,7 @@ import QtQuick.Controls 2.15 as QQC2
import QtQuick.Layouts 1.15 import QtQuick.Layouts 1.15
import org.kde.kirigami 2.15 as Kirigami import org.kde.kirigami 2.15 as Kirigami
import org.kde.kirigamiaddons.labs.mobileform 0.1 as MobileForm
import org.kde.neochat 1.0 import org.kde.neochat 1.0
@@ -15,55 +16,90 @@ Kirigami.ScrollablePage {
property bool proxyConfigChanged: false property bool proxyConfigChanged: false
ColumnLayout { ColumnLayout {
Kirigami.FormLayout { MobileForm.FormCard {
Layout.topMargin: Kirigami.Units.largeSpacing
Layout.fillWidth: true Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
MobileForm.FormCardHeader {
title: i18n("Network Proxy")
}
MobileForm.FormRadioDelegate {
text: i18n("System Default")
checked: currentType === 0
enabled: !Config.isProxyTypeImmutable
onToggled: {
currentType = 0
}
}
MobileForm.FormRadioDelegate {
text: i18n("HTTP")
checked: currentType === 1
enabled: !Config.isProxyTypeImmutable
onToggled: {
currentType = 1
}
}
MobileForm.FormRadioDelegate {
text: i18n("Socks5")
checked: currentType === 2
enabled: !Config.isProxyTypeImmutable
onToggled: {
currentType = 2
}
}
}
}
QQC2.RadioButton { MobileForm.FormCard {
Kirigami.FormData.label: i18n("Network Proxy") Layout.topMargin: Kirigami.Units.largeSpacing
text: i18n("System Default") Layout.fillWidth: true
checked: currentType === 0 contentItem: ColumnLayout {
enabled: !Config.isProxyTypeImmutable spacing: 0
onToggled: { MobileForm.FormCardHeader {
currentType = 0 title: i18n("Proxy Settings")
} }
} // TODO: switch to FormTextFieldDelegate once kirigami-addons got a new release
QQC2.RadioButton { MobileForm.AbstractFormDelegate {
text: i18n("HTTP") Layout.fillWidth: true
checked: currentType === 1 contentItem: RowLayout {
enabled: !Config.isProxyTypeImmutable QQC2.Label {
onToggled: { text: i18n("Host")
currentType = 1 Layout.fillWidth: true
}
QQC2.TextField {
id: hostField
Kirigami.FormData.label: i18n("Proxy Host")
text: Config.proxyHost
inputMethodHints: Qt.ImhUrlCharactersOnly
onEditingFinished: {
proxyConfigChanged = true
}
}
}
} }
} MobileForm.AbstractFormDelegate {
QQC2.RadioButton { Layout.fillWidth: true
text: i18n("Socks5") contentItem: RowLayout {
checked: currentType === 2 QQC2.Label {
enabled: !Config.isProxyTypeImmutable text: i18n("Peeker width")
onToggled: { Layout.fillWidth: true
currentType = 2 }
} QQC2.SpinBox {
} id: portField
QQC2.TextField { Kirigami.FormData.label: i18n("Proxy Port")
id: hostField value: Config.proxyPort
Kirigami.FormData.label: i18n("Proxy Host") from: 0
text: Config.proxyHost to: 65536
inputMethodHints: Qt.ImhUrlCharactersOnly validator: IntValidator {bottom: from; top: to}
onEditingFinished: { textFromValue: function(value, locale) {
proxyConfigChanged = true return value // it will add a thousands separator if we don't do this, not sure why
} }
} onValueChanged: {
QQC2.SpinBox { proxyConfigChanged = true
id: portField }
Kirigami.FormData.label: i18n("Proxy Port") }
value: Config.proxyPort }
from: 0
to: 65536
validator: IntValidator {bottom: from; top: to}
textFromValue: function(value, locale) {
return value // it will add a thousands separator if we don't do this, not sure why
}
onValueChanged: {
proxyConfigChanged = true
} }
} }
} }