Port proxy page to formcard

This commit is contained in:
Tobias Fella
2023-09-01 17:06:27 +02:00
parent ddd690f6d5
commit 7ba63eb680

View File

@@ -6,104 +6,91 @@ 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.kirigamiaddons.formcard 1.0 as FormCard
import org.kde.neochat 1.0 import org.kde.neochat 1.0
Kirigami.ScrollablePage { FormCard.FormCardPage {
id: root
title: i18nc("@title:window", "General") title: i18nc("@title:window", "General")
property int currentType property int currentType
property bool proxyConfigChanged: false property bool proxyConfigChanged: false
topPadding: 0 FormCard.FormHeader {
leftPadding: 0 title: i18n("Network Proxy")
rightPadding: 0 }
ColumnLayout { FormCard.FormCard {
spacing: 0 FormCard.FormRadioDelegate {
MobileForm.FormHeader { text: i18n("System Default")
Layout.fillWidth: true checked: currentType === 0
title: i18n("Network Proxy") enabled: !Config.isProxyTypeImmutable
} onToggled: {
MobileForm.FormCard { currentType = 0
Layout.fillWidth: true
contentItem: ColumnLayout {
spacing: 0
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
}
}
} }
} }
FormCard.FormRadioDelegate {
MobileForm.FormHeader { text: i18n("HTTP")
Layout.fillWidth: true checked: currentType === 1
title: i18n("Proxy Settings") enabled: !Config.isProxyTypeImmutable
onToggled: {
currentType = 1
}
} }
MobileForm.FormCard { FormCard.FormRadioDelegate {
Layout.fillWidth: true text: i18n("Socks5")
contentItem: ColumnLayout { checked: currentType === 2
spacing: 0 enabled: !Config.isProxyTypeImmutable
MobileForm.FormTextFieldDelegate { onToggled: {
id: hostField currentType = 2
label: i18n("Host") }
text: Config.proxyHost }
inputMethodHints: Qt.ImhUrlCharactersOnly }
onEditingFinished: {
proxyConfigChanged = true FormCard.FormHeader {
} title: i18n("Proxy Settings")
} }
MobileForm.FormSpinBoxDelegate { FormCard.FormCard {
id: portField FormCard.FormTextFieldDelegate {
label: i18n("Port") id: hostField
value: Config.proxyPort label: i18n("Host")
from: 0 text: Config.proxyHost
to: 65536 inputMethodHints: Qt.ImhUrlCharactersOnly
textFromValue: function(value, locale) { onEditingFinished: {
return value // it will add a thousands separator if we don't do this, not sure why proxyConfigChanged = true
} }
onValueChanged: { }
proxyConfigChanged = true FormCard.FormSpinBoxDelegate {
} id: portField
} label: i18n("Port")
MobileForm.FormTextFieldDelegate { value: Config.proxyPort
id: userField from: 0
label: i18n("User") to: 65536
text: Config.proxyUser textFromValue: function(value, locale) {
inputMethodHints: Qt.ImhUrlCharactersOnly return value // it will add a thousands separator if we don't do this, not sure why
onEditingFinished: { }
proxyConfigChanged = true onValueChanged: {
} proxyConfigChanged = true
} }
MobileForm.FormTextFieldDelegate { }
id: passwordField FormCard.FormTextFieldDelegate {
label: i18n("Password") id: userField
text: Config.proxyPassword label: i18n("User")
echoMode: TextInput.Password text: Config.proxyUser
inputMethodHints: Qt.ImhUrlCharactersOnly inputMethodHints: Qt.ImhUrlCharactersOnly
onEditingFinished: { onEditingFinished: {
proxyConfigChanged = true proxyConfigChanged = true
} }
} }
FormCard.FormTextFieldDelegate {
id: passwordField
label: i18n("Password")
text: Config.proxyPassword
echoMode: TextInput.Password
inputMethodHints: Qt.ImhUrlCharactersOnly
onEditingFinished: {
proxyConfigChanged = true
} }
} }
} }