2022-01-09 02:28:03 +03:00
|
|
|
// SPDX-FileCopyrightText: 2021 Nheko Contributors
|
|
|
|
// SPDX-FileCopyrightText: 2022 Nheko Contributors
|
|
|
|
//
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2022-01-09 08:56:02 +03:00
|
|
|
import ".."
|
|
|
|
import "../ui"
|
2022-01-09 02:28:03 +03:00
|
|
|
import Qt.labs.platform 1.1 as Platform
|
|
|
|
import QtQuick 2.15
|
2022-01-11 06:12:42 +03:00
|
|
|
import QtQuick.Controls 2.15
|
2022-01-09 02:28:03 +03:00
|
|
|
import QtQuick.Layouts 1.2
|
2022-01-11 06:12:42 +03:00
|
|
|
import QtQuick.Window 2.15
|
2022-04-14 16:28:17 +03:00
|
|
|
import im.nheko
|
2022-04-15 03:58:44 +03:00
|
|
|
import im.nheko
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: userSettingsDialog
|
|
|
|
|
2022-01-11 06:12:42 +03:00
|
|
|
property int collapsePoint: 800
|
|
|
|
property bool collapsed: width < collapsePoint
|
2022-04-11 05:18:16 +03:00
|
|
|
color: timelineRoot.palette.window
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
ScrollView {
|
|
|
|
id: scroll
|
|
|
|
|
2022-04-11 05:18:16 +03:00
|
|
|
palette: timelineRoot.palette
|
2022-01-09 02:28:03 +03:00
|
|
|
ScrollBar.horizontal.visible: false
|
|
|
|
anchors.fill: parent
|
2022-02-20 11:45:37 +03:00
|
|
|
anchors.topMargin: (collapsed? backButton.height : 0)+Nheko.paddingLarge
|
|
|
|
leftPadding: collapsed? Nheko.paddingMedium : Nheko.paddingLarge
|
|
|
|
bottomPadding: Nheko.paddingLarge
|
2022-01-09 02:28:03 +03:00
|
|
|
contentWidth: availableWidth
|
|
|
|
|
2022-02-19 23:47:19 +03:00
|
|
|
ColumnLayout {
|
2022-01-09 02:28:03 +03:00
|
|
|
id: grid
|
|
|
|
|
2022-02-19 23:47:19 +03:00
|
|
|
spacing: Nheko.paddingMedium
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
anchors.fill: parent
|
2022-02-18 22:20:52 +03:00
|
|
|
anchors.leftMargin: userSettingsDialog.collapsed ? 0 : (userSettingsDialog.width-userSettingsDialog.collapsePoint) * 0.4 + Nheko.paddingLarge
|
2022-01-11 06:12:42 +03:00
|
|
|
anchors.rightMargin: anchors.leftMargin
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
Repeater {
|
|
|
|
model: UserSettingsModel
|
2022-02-19 23:47:19 +03:00
|
|
|
Layout.fillWidth:true
|
2022-01-09 02:28:03 +03:00
|
|
|
|
2022-02-19 23:47:19 +03:00
|
|
|
delegate: GridLayout {
|
|
|
|
columns: collapsed? 1 : 2
|
|
|
|
rows: collapsed? 2: 1
|
2022-01-09 02:28:03 +03:00
|
|
|
required property var model
|
|
|
|
id: r
|
|
|
|
|
|
|
|
Label {
|
|
|
|
Layout.alignment: Qt.AlignLeft
|
|
|
|
Layout.fillWidth: true
|
2022-04-11 05:18:16 +03:00
|
|
|
color: timelineRoot.palette.text
|
2022-01-09 02:28:03 +03:00
|
|
|
text: model.name
|
|
|
|
//Layout.column: 0
|
|
|
|
Layout.columnSpan: (model.type == UserSettingsModel.SectionTitle && !userSettingsDialog.collapsed) ? 2 : 1
|
|
|
|
//Layout.row: model.index
|
2022-02-18 22:20:52 +03:00
|
|
|
//Layout.minimumWidth: implicitWidth
|
2022-01-09 02:28:03 +03:00
|
|
|
Layout.leftMargin: model.type == UserSettingsModel.SectionTitle ? 0 : Nheko.paddingMedium
|
|
|
|
Layout.topMargin: model.type == UserSettingsModel.SectionTitle ? Nheko.paddingLarge : 0
|
2022-01-11 06:12:42 +03:00
|
|
|
font.pointSize: 1.1 * fontMetrics.font.pointSize
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
HoverHandler {
|
|
|
|
id: hovered
|
|
|
|
enabled: model.description ?? false
|
|
|
|
}
|
|
|
|
ToolTip.visible: hovered.hovered && model.description
|
|
|
|
ToolTip.text: model.description ?? ""
|
|
|
|
ToolTip.delay: Nheko.tooltipDelay
|
2022-02-18 22:20:52 +03:00
|
|
|
wrapMode: Text.Wrap
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
DelegateChooser {
|
|
|
|
id: chooser
|
|
|
|
|
|
|
|
roleValue: model.type
|
|
|
|
Layout.alignment: Qt.AlignRight
|
|
|
|
|
|
|
|
Layout.columnSpan: (model.type == UserSettingsModel.SectionTitle && !userSettingsDialog.collapsed) ? 2 : 1
|
|
|
|
Layout.preferredHeight: child.height
|
|
|
|
Layout.preferredWidth: Math.min(child.implicitWidth, child.width || 1000)
|
2022-02-20 11:45:37 +03:00
|
|
|
Layout.maximumWidth: model.type == UserSettingsModel.SectionTitle ? Number.POSITIVE_INFINITY : 400
|
2022-01-13 06:15:33 +03:00
|
|
|
Layout.fillWidth: model.type == UserSettingsModel.SectionTitle || model.type == UserSettingsModel.Options || model.type == UserSettingsModel.Number
|
2022-01-09 02:28:03 +03:00
|
|
|
Layout.rightMargin: model.type == UserSettingsModel.SectionTitle ? 0 : Nheko.paddingMedium
|
|
|
|
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.Toggle
|
|
|
|
ToggleButton {
|
|
|
|
checked: model.value
|
|
|
|
onCheckedChanged: model.value = checked
|
|
|
|
enabled: model.enabled
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.Options
|
|
|
|
ComboBox {
|
2022-01-13 06:15:33 +03:00
|
|
|
anchors.right: parent.right
|
|
|
|
width: Math.min(parent.width, implicitWidth)
|
2022-01-09 02:28:03 +03:00
|
|
|
model: r.model.values
|
|
|
|
currentIndex: r.model.value
|
|
|
|
onCurrentIndexChanged: r.model.value = currentIndex
|
2022-02-20 05:03:11 +03:00
|
|
|
|
|
|
|
WheelHandler{} // suppress scrolling changing values
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
2022-01-13 07:51:57 +03:00
|
|
|
roleValue: UserSettingsModel.Integer
|
2022-01-09 02:28:03 +03:00
|
|
|
|
|
|
|
SpinBox {
|
2022-01-13 06:15:33 +03:00
|
|
|
anchors.right: parent.right
|
|
|
|
width: Math.min(parent.width, implicitWidth)
|
2022-01-09 02:28:03 +03:00
|
|
|
from: model.valueLowerBound
|
|
|
|
to: model.valueUpperBound
|
|
|
|
stepSize: model.valueStep
|
|
|
|
value: model.value
|
|
|
|
onValueChanged: model.value = value
|
2022-01-13 07:51:57 +03:00
|
|
|
editable: true
|
2022-02-20 05:03:11 +03:00
|
|
|
|
|
|
|
WheelHandler{} // suppress scrolling changing values
|
2022-01-13 07:51:57 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.Double
|
|
|
|
|
|
|
|
SpinBox {
|
|
|
|
id: spinbox
|
|
|
|
|
|
|
|
readonly property double div: 100
|
|
|
|
readonly property int decimals: 2
|
|
|
|
|
|
|
|
anchors.right: parent.right
|
|
|
|
width: Math.min(parent.width, implicitWidth)
|
|
|
|
from: model.valueLowerBound * div
|
|
|
|
to: model.valueUpperBound * div
|
|
|
|
stepSize: model.valueStep * div
|
|
|
|
value: model.value * div
|
|
|
|
onValueChanged: model.value = value/div
|
|
|
|
editable: true
|
|
|
|
|
|
|
|
property real realValue: value / div
|
|
|
|
|
|
|
|
validator: DoubleValidator {
|
|
|
|
bottom: Math.min(spinbox.from/spinbox.div, spinbox.to/spinbox.div)
|
|
|
|
top: Math.max(spinbox.from/spinbox.div, spinbox.to/spinbox.div)
|
|
|
|
}
|
|
|
|
|
|
|
|
textFromValue: function(value, locale) {
|
|
|
|
return Number(value / spinbox.div).toLocaleString(locale, 'f', spinbox.decimals)
|
|
|
|
}
|
|
|
|
|
|
|
|
valueFromText: function(text, locale) {
|
|
|
|
return Number.fromLocaleString(locale, text) * spinbox.div
|
|
|
|
}
|
2022-02-20 05:03:11 +03:00
|
|
|
|
|
|
|
WheelHandler{} // suppress scrolling changing values
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.ReadOnlyText
|
2022-01-13 06:15:33 +03:00
|
|
|
TextEdit {
|
2022-04-11 05:18:16 +03:00
|
|
|
color: timelineRoot.palette.text
|
2022-01-09 02:28:03 +03:00
|
|
|
text: model.value
|
2022-01-13 06:15:33 +03:00
|
|
|
readOnly: true
|
|
|
|
selectByMouse: !Settings.mobileMode
|
|
|
|
textFormat: Text.PlainText
|
2022-01-09 02:28:03 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.SectionTitle
|
|
|
|
Item {
|
|
|
|
width: grid.width
|
|
|
|
height: fontMetrics.lineSpacing
|
|
|
|
Rectangle {
|
|
|
|
anchors.topMargin: Nheko.paddingSmall
|
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
2022-04-11 05:18:16 +03:00
|
|
|
color: timelineRoot.palette.buttonText
|
2022-01-09 02:28:03 +03:00
|
|
|
height: 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.KeyStatus
|
|
|
|
Text {
|
|
|
|
color: model.good ? "green" : Nheko.theme.error
|
|
|
|
text: model.value ? qsTr("CACHED") : qsTr("NOT CACHED")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.SessionKeyImportExport
|
|
|
|
RowLayout {
|
|
|
|
Button {
|
|
|
|
text: qsTr("IMPORT")
|
|
|
|
onClicked: UserSettingsModel.importSessionKeys()
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: qsTr("EXPORT")
|
|
|
|
onClicked: UserSettingsModel.exportSessionKeys()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
roleValue: UserSettingsModel.XSignKeysRequestDownload
|
|
|
|
RowLayout {
|
|
|
|
Button {
|
|
|
|
text: qsTr("DOWNLOAD")
|
|
|
|
onClicked: UserSettingsModel.downloadCrossSigningSecrets()
|
|
|
|
}
|
|
|
|
Button {
|
|
|
|
text: qsTr("REQUEST")
|
|
|
|
onClicked: UserSettingsModel.requestCrossSigningSecrets()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DelegateChoice {
|
|
|
|
Text {
|
|
|
|
text: model.value
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ImageButton {
|
2022-02-18 22:20:52 +03:00
|
|
|
id: backButton
|
2022-01-09 02:28:03 +03:00
|
|
|
anchors.top: parent.top
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.margins: Nheko.paddingMedium
|
|
|
|
width: Nheko.avatarSize
|
|
|
|
height: Nheko.avatarSize
|
|
|
|
image: ":/icons/icons/ui/angle-arrow-left.svg"
|
|
|
|
ToolTip.visible: hovered
|
|
|
|
ToolTip.text: qsTr("Back")
|
|
|
|
onClicked: mainWindow.pop()
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|