qml: msgpopup: Qt6 changes

Use anchors preferentially, and nest the title bar elements.
This commit is contained in:
Tom Dewey 2024-07-17 10:37:38 +01:00 committed by Tom Dewey
parent 9b14f88ba6
commit f4f43c7124

View file

@ -11,12 +11,13 @@ import "qmlcomponents"
Popup { Popup {
id: msgpopup id: msgpopup
x: 75 x: (parent.width-width)/2
y: (parent.height-height)/2 y: (parent.height-height)/2
width: parent.width-150 width: 550
height: msgpopupbody.implicitHeight+150 height: msgpopupbody.implicitHeight+150
padding: 0 padding: 0
closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside closePolicy: Popup.CloseOnEscape | Popup.CloseOnPressOutside
modal: true
property alias title: msgpopupheader.text property alias title: msgpopupheader.text
property alias text: msgpopupbody.text property alias text: msgpopupbody.text
@ -29,23 +30,27 @@ Popup {
// background of title // background of title
Rectangle { Rectangle {
id: msgpopup_title_background
color: "#f5f5f5" color: "#f5f5f5"
anchors.right: parent.right anchors.left: parent.left
anchors.top: parent.top anchors.top: parent.top
height: 35 height: 35
width: parent.width width: parent.width
}
// line under title Text {
Rectangle { id: msgpopupheader
color: "#afafaf" horizontalAlignment: Text.AlignHCenter
width: parent.width anchors.fill: parent
y: 35 anchors.topMargin: 10
implicitHeight: 1 font.family: roboto.name
font.bold: true
} }
Text { Text {
id: msgx
text: "X" text: "X"
Layout.alignment: Qt.AlignRight
horizontalAlignment: Text.AlignRight
verticalAlignment: Text.AlignVCenter
anchors.right: parent.right anchors.right: parent.right
anchors.top: parent.top anchors.top: parent.top
anchors.rightMargin: 25 anchors.rightMargin: 25
@ -61,20 +66,22 @@ Popup {
} }
} }
} }
}
// line under title
Rectangle {
id: msgpopup_title_separator
color: "#afafaf"
width: parent.width
anchors.top: msgpopup_title_background.bottom
height: 1
}
ColumnLayout { ColumnLayout {
spacing: 20 spacing: 20
anchors.fill: parent anchors.top: msgpopup_title_separator.bottom
anchors.left: parent.left
Text { anchors.right: parent.right
id: msgpopupheader anchors.bottom: parent.bottom
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
Layout.fillWidth: true
Layout.topMargin: 10
font.family: roboto.name
font.bold: true
}
Text { Text {
id: msgpopupbody id: msgpopupbody
@ -82,10 +89,11 @@ Popup {
wrapMode: Text.Wrap wrapMode: Text.Wrap
textFormat: Text.StyledText textFormat: Text.StyledText
font.family: roboto.name font.family: roboto.name
Layout.maximumWidth: msgpopup.width-50
Layout.fillHeight: true Layout.fillHeight: true
Layout.leftMargin: 25 Layout.leftMargin: 25
Layout.rightMargin: 25
Layout.topMargin: 25 Layout.topMargin: 25
Layout.alignment: Qt.AlignVCenter | Qt.AlignHCenter
Accessible.name: text.replace(/<\/?[^>]+(>|$)/g, "") Accessible.name: text.replace(/<\/?[^>]+(>|$)/g, "")
} }
@ -93,6 +101,7 @@ Popup {
Layout.alignment: Qt.AlignCenter | Qt.AlignBottom Layout.alignment: Qt.AlignCenter | Qt.AlignBottom
Layout.bottomMargin: 10 Layout.bottomMargin: 10
spacing: 20 spacing: 20
id: buttons
ImButtonRed { ImButtonRed {
text: qsTr("NO") text: qsTr("NO")
@ -128,8 +137,6 @@ Popup {
font.family: roboto.name font.family: roboto.name
visible: msgpopup.quitButton visible: msgpopup.quitButton
} }
Text { text: " " }
} }
} }