Plasma

Heading.qml
1 /*
2  SPDX-FileCopyrightText: 2012 Sebastian K├╝gler <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 import QtQuick 2.0
8 import org.kde.plasma.core 2.0 as PlasmaCore
9 import org.kde.plasma.components 3.0
10 
11 
12 /**
13  * A heading label used for subsections of texts.
14  *
15  * The characteristics of the text will be automatically set according to the
16  * plasma theme. Use this components for section titles or headings in your UI,
17  * for example page or section titles.
18  *
19  * Example usage:
20  *
21  * @code
22  * import org.kde.plasma.extras 2.0 as PlasmaExtras
23  * [...]
24  * Column {
25  * PlasmaExtras.Heading { text: "Fruit sweetness on the rise"; level: 1 }
26  * PlasmaExtras.Heading { text: "Apples in the sunlight"; level: 2 }
27  * PlasmaExtras.Paragraph { text: "Long text about fruit and apples [...]" }
28  * [...]
29  * }
30  * @endcode
31  *
32  * The most important property is "text", which applies to the text property of
33  * Label. See PlasmaComponents Label and primitive QML Text element API for
34  * additional properties, methods and signals.
35  */
36 Label {
37  id: heading
38 
39  /**
40  * level: int
41  * The level determines how big the section header is display, values
42  * between 1 (big) and 5 (small) are accepted
43  */
44  property int level: 1
45 
46  /**
47  * step: int
48  * adjust the point size in between a level and another.
49  */
50  property int step: 0
51 
52  lineHeight: 1.2
53  font.pointSize: headerPointSize(level)
54  wrapMode: Text.WordWrap
55 
56  function headerPointSize(l) {
57  var n = PlasmaCore.Theme.defaultFont.pointSize;
58  var s;
59  switch (l) {
60  case 1:
61  return Math.round(n * 1.50) + step;
62  case 2:
63  return Math.round(n * 1.30) + step;
64  case 3:
65  return Math.round(n * 1.20) + step;
66  case 4:
67  return Math.round(n * 1.10) + step;
68  default:
69  return n + step;
70  }
71  }
72 }
This is a label which uses the plasma theme.
Definition: qml/Label.qml:25
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Sep 27 2021 22:42:25 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.