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 { Window {
id: popup id: popup
width: cl.implicitWidth+cl.spacing width: Math.min(550, optionsStack.minimumWidth)
height: Math.min(420, optionsStack.minimumHeight)
minimumWidth: width minimumWidth: width
maximumWidth: width // Deliberately do not set a maximum width - if the user wants to resize, let them.
minimumHeight: 125 //maximumWidth: width
height: Math.min(750, cl.implicitHeight)
minimumHeight: height
// Deliberately do not set a maximum height - if the user wants to resize, let them.
//maximumHeight: height
title: qsTr("OS Customization") title: qsTr("OS Customization")
property bool initialized: false property bool initialized: false
@ -31,33 +37,16 @@ Window {
signal saveSettingsSignal(var settings) 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: { Keys.onEscapePressed: {
popup.close() 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 { TabBar {
id: bar id: bar
Layout.fillWidth: true
anchors.top: parent.top
anchors.left: parent.left
anchors.right: parent.right
TabButton { TabButton {
text: qsTr("General") 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 { 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 currentIndex: bar.currentIndex
ColumnLayout { ColumnLayout {
@ -282,6 +288,7 @@ Window {
Text { Text {
text: qsTr("Wireless LAN country:") text: qsTr("Wireless LAN country:")
color: chkWifi.checked ? "black" : "grey" color: chkWifi.checked ? "black" : "grey"
Layout.leftMargin: 40
} }
// Spacer item // Spacer item
Item { Item {
@ -381,14 +388,16 @@ Window {
Text { Text {
text: qsTr("Set authorized_keys for '%1':").arg(fieldUserName.text) text: qsTr("Set authorized_keys for '%1':").arg(fieldUserName.text)
color: radioPubKeyAuthentication.checked ? "black" : "grey" color: radioPubKeyAuthentication.checked ? "black" : "grey"
textFormat: Text.PlainText // textFormat: Text.PlainText
Layout.leftMargin: 40 Layout.leftMargin: 40
} }
TextArea { TextArea {
id: fieldPublicKey id: fieldPublicKey
enabled: radioPubKeyAuthentication.checked enabled: radioPubKeyAuthentication.checked
textFormat: TextEdit.PlainText
wrapMode: TextEdit.WrapAnywhere wrapMode: TextEdit.WrapAnywhere
Layout.minimumWidth: 400 Layout.fillWidth: true
Layout.minimumWidth: 350
Layout.leftMargin: 40 Layout.leftMargin: 40
selectByMouse: true selectByMouse: true
} }
@ -423,13 +432,16 @@ Window {
} }
} }
} }
}
}
RowLayout { RowLayout {
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom id: buttonsRow
Layout.bottomMargin: 10 anchors.right: parent.right
spacing: 20 anchors.left: parent.left
anchors.bottom: parent.bottom
Item {
Layout.fillWidth: true
}
ImButtonRed { ImButtonRed {
text: qsTr("SAVE") text: qsTr("SAVE")
@ -479,7 +491,8 @@ Window {
} }
} }
Text { text: " " } Item {
Layout.fillWidth: true
} }
} }