Kirigami2

Heading.qml
1 /*
2  * SPDX-FileCopyrightText: 2012 by Sebastian K├╝gler <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.0
8 import QtQuick.Controls 2.0 as QQC2
9 import org.kde.kirigami 2.4
10 
11 /**
12  * A heading label used for subsections of texts.
13  *
14  * The characteristics of the text will be automatically set according to the
15  * Theme. Use this components for section titles or headings in your UI,
16  * for example page or section titles.
17  *
18  * Example usage:
19  *
20  * @code
21  * import org.kde.kirigami 2.4 as Kirigami
22  * [...]
23  * Column {
24  * Kirigami.Heading {
25  * text: "Apples in the sunlight"
26  * level: 2
27  * }
28  * [...]
29  * }
30  * @endcode
31  *
32  * The most important property is "text", which applies to the text property of
33  * Label. See the Label component from QtQuick.Controls 2 and primitive QML Text
34  * element API for additional properties, methods and signals.
35  *
36  * @inherit QtQuick.Controls.Label
37  */
38 QQC2.Label {
39  id: heading
40 
41  /**
42  * The level determines how big the section header is display, values
43  * between 1 (big) and 5 (small) are accepted. (default: 1)
44  */
45  property int level: 1
46 
47  /**
48  * Adjust the point size in between a level and another. (default: 0)
49  * @deprecated
50  */
51  property int step: 0
52 
53  enum Type {
54  Normal,
55  Primary,
56  Secondary
57  }
58 
59  /**
60  * The type of the heading. This can be:
61  *
62  * * Kirigami.Heading.Type.Normal: Create a normal heading (default)
63  * * Kirigami.Heading.Type.Primary: Makes the heading more prominent. Useful
64  * when making the heading bigger is not enough.
65  * * Kirigami.Heading.Type.Secondary: Makes the heading less prominent.
66  * Useful when an heading is for a less important section in an application.
67  *
68  * @since 5.82
69  */
70  property int type: Heading.Type.Normal
71 
72  font.pointSize: headerPointSize(level)
73  font.weight: type === Heading.Type.Primary ? Font.DemiBold : Font.Normal
74 
75  opacity: type === Heading.Type.Secondary ? 0.7 : 1
76 
77  Accessible.role: Accessible.Heading
78 
79  function headerPointSize(l) {
80  var n = Theme.defaultFont.pointSize;
81  var s;
82  switch (l) {
83  case 1:
84  return n * 1.35 + step;
85  case 2:
86  return n * 1.20 + step;
87  case 3:
88  return n * 1.15 + step;
89  case 4:
90  return n * 1.10 + step;
91  default:
92  return n + step;
93  }
94  }
95 }
A heading label used for subsections of texts.
Definition: Heading.qml:37
This is a label which uses the current Theme.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sun Oct 24 2021 22:39:10 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.