Skip to content

Commit 530714f

Browse files
committed
qml: allow to configure when to show the header text in header control
1 parent df44897 commit 530714f

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/qml/controls/Header.qml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ColumnLayout {
1010
id: root
1111
property bool center: true
1212
required property string header
13+
property bool showHeader: true
1314
property int headerMargin
1415
property int headerSize: 28
1516
property bool headerBold: false
@@ -26,27 +27,32 @@ ColumnLayout {
2627
property bool wrap: true
2728

2829
spacing: 0
29-
Label {
30+
Loader {
3031
Layout.fillWidth: true
31-
topPadding: root.headerMargin
32-
font.family: "Inter"
33-
font.styleName: root.headerBold ? "Semi Bold" : "Regular"
34-
font.pixelSize: root.headerSize
35-
color: root.headerColor
36-
text: root.header
37-
horizontalAlignment: center ? Text.AlignHCenter : Text.AlignLeft
38-
wrapMode: wrap ? Text.WordWrap : Text.NoWrap
32+
active: root.showHeader && root.header.length > 0
33+
visible: active
34+
sourceComponent: Label {
35+
Layout.fillWidth: true
36+
topPadding: root.headerMargin
37+
font.family: "Inter"
38+
font.styleName: root.headerBold ? "Semi Bold" : "Regular"
39+
font.pixelSize: root.headerSize
40+
color: root.headerColor
41+
text: root.header
42+
horizontalAlignment: center ? Text.AlignHCenter : Text.AlignLeft
43+
wrapMode: wrap ? Text.WordWrap : Text.NoWrap
3944

40-
Behavior on color {
41-
ColorAnimation { duration: 150 }
45+
Behavior on color {
46+
ColorAnimation { duration: 150 }
47+
}
4248
}
4349
}
4450
Loader {
4551
Layout.fillWidth: true
4652
active: root.description.length > 0
4753
visible: active
4854
sourceComponent: Label {
49-
topPadding: root.descriptionMargin
55+
topPadding: showHeader ? root.descriptionMargin : root.headerMargin
5056
font.family: "Inter"
5157
font.styleName: root.descriptionBold ? "Semi Bold" : "Regular"
5258
font.pixelSize: root.descriptionSize

src/qml/controls/InformationPage.qml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Page {
2525
property bool center: true
2626
property int bannerMargin: 20
2727
required property string headerText
28+
property bool showHeader: true
2829
property int headerMargin: 30
2930
property int headerSize: 28
3031
property string description: ""
@@ -70,6 +71,7 @@ Page {
7071
headerBold: root.bold
7172
center: root.center
7273
header: root.headerText
74+
showHeader: root.showHeader
7375
headerMargin: root.headerMargin
7476
headerSize: root.headerSize
7577
description: root.description

0 commit comments

Comments
 (0)