qml: OptionsPopup: Resize, rework scene graph

This commit is contained in:
Tom Dewey 2024-07-22 16:50:15 +01:00 committed by Tom Dewey
parent c693b5e3f7
commit 3fed45ef43

View file

@ -12,11 +12,17 @@ import "qmlcomponents"
Window {
id: popup
width: cl.implicitWidth+cl.spacing
width: Math.min(550, optionsStack.minimumWidth)
height: Math.min(420, optionsStack.minimumHeight)
minimumWidth: width
maximumWidth: width
minimumHeight: 125
height: Math.min(750, cl.implicitHeight)
// Deliberately do not set a maximum width - if the user wants to resize, let them.
//maximumWidth: width
minimumHeight: height
// Deliberately do not set a maximum height - if the user wants to resize, let them.
//maximumHeight: height
title: qsTr("OS Customization")
property bool initialized: false
@ -31,33 +37,16 @@ Window {
signal saveSettingsSignal(var settings)
ColumnLayout {
id: cl
spacing: 10
anchors.fill: parent
// Keys handlers can only be attached to Items. Window is not an
// Item, but ColumnLayout is, so put this handler here.
Keys.onEscapePressed: {
popup.close()
}
ScrollView {
id: popupbody
font.family: roboto.name
//Layout.maximumWidth: popup.width-30
Layout.fillWidth: true
Layout.fillHeight: true
Layout.leftMargin: 10
Layout.rightMargin: 10
Layout.topMargin: 10
clip: true
//ScrollBar.vertical.policy: ScrollBar.AlwaysOn
ColumnLayout {
TabBar {
id: bar
Layout.fillWidth: true
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
TabButton {
text: qsTr("General")
@ -75,9 +64,26 @@ Window {
}
}
GroupBox {
ScrollView {
id: popupbody
font.family: roboto.name
anchors.right: parent.right
anchors.left: parent.left
anchors.top: bar.bottom
anchors.bottom: buttonsRow.top
clip: true
//ScrollBar.vertical.policy: ScrollBar.AlwaysOn
StackLayout {
width: parent.width
id: optionsStack
anchors.top: parent.top
anchors.right: parent.right
anchors.left: parent.left
anchors.rightMargin: 10
anchors.leftMargin: 10
currentIndex: bar.currentIndex
ColumnLayout {
@ -282,6 +288,7 @@ Window {
Text {
text: qsTr("Wireless LAN country:")
color: chkWifi.checked ? "black" : "grey"
Layout.leftMargin: 40
}
// Spacer item
Item {
@ -381,14 +388,16 @@ Window {
Text {
text: qsTr("Set authorized_keys for '%1':").arg(fieldUserName.text)
color: radioPubKeyAuthentication.checked ? "black" : "grey"
textFormat: Text.PlainText
// textFormat: Text.PlainText
Layout.leftMargin: 40
}
TextArea {
id: fieldPublicKey
enabled: radioPubKeyAuthentication.checked
textFormat: TextEdit.PlainText
wrapMode: TextEdit.WrapAnywhere
Layout.minimumWidth: 400
Layout.fillWidth: true
Layout.minimumWidth: 350
Layout.leftMargin: 40
selectByMouse: true
}
@ -423,13 +432,16 @@ Window {
}
}
}
}
}
RowLayout {
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom
Layout.bottomMargin: 10
spacing: 20
id: buttonsRow
anchors.right: parent.right
anchors.left: parent.left
anchors.bottom: parent.bottom
Item {
Layout.fillWidth: true
}
ImButtonRed {
text: qsTr("SAVE")
@ -479,7 +491,8 @@ Window {
}
}
Text { text: " " }
Item {
Layout.fillWidth: true
}
}