Warning, /frameworks/kirigami/src/controls/Heading.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2012 by Sebastian Kügler <sebas@kde.org> 0003 * 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.0 0008 import QtQuick.Controls 2.0 as QQC2 0009 import org.kde.kirigami 2.4 as Kirigami 0010 0011 /** 0012 * @brief A heading label used for subsections of texts. 0013 * 0014 * The characteristics of the text will be automatically set according to the 0015 * Kirigami.PlatformTheme. Use this components for section titles or headings in your UI, 0016 * for example page or section titles. 0017 * 0018 * Example usage: 0019 * @code{.qml} 0020 * import org.kde.kirigami 2.4 as Kirigami 0021 * [...] 0022 * Column { 0023 * Kirigami.Heading { 0024 * text: "Apples in the sunlight" 0025 * level: 2 0026 * } 0027 * [...] 0028 * } 0029 * @endcode 0030 * 0031 * @see QtQuick.Controls.Label 0032 * @see QtQuick.Text 0033 * @see <a href="https://develop.kde.org/docs/getting-started/kirigami/style-typography">Typography in Kirigami</a> 0034 * @see <a href="https://develop.kde.org/hig/style/typography">KDE Human Interface Guidelines on Typography</a> 0035 * @inherit QtQuick.Controls.Label 0036 */ 0037 QQC2.Label { 0038 id: heading 0039 0040 /** 0041 * @brief This property holds the level of the heading, determining its font size. 0042 * 0043 * Acceptable values range from 1 (big) to 5 (small). 0044 * 0045 * default: ``1`` 0046 */ 0047 property int level: 1 0048 0049 /** 0050 * @brief This property holds the point size between heading levels. 0051 * 0052 * default: ``0`` 0053 * 0054 * @deprecated 0055 */ 0056 property int step: 0 0057 0058 /** 0059 * @brief This enumeration defines heading types. 0060 * 0061 * This enum helps with heading visibility (making it less or more important). 0062 */ 0063 enum Type { 0064 Normal, 0065 Primary, 0066 Secondary 0067 } 0068 0069 /** 0070 * @brief This property holds the heading type. 0071 * 0072 * The following values are allowed: 0073 * * ``Kirigami.Heading.Type.Normal``: Creates a normal heading (default). 0074 * * ``Kirigami.Heading.Type.Primary``: Makes the heading more prominent. Useful 0075 * when making the heading bigger is not enough. 0076 * * ``Kirigami.Heading.Type.Secondary``: Makes the heading less prominent. 0077 * Useful when an heading is for a less important section in an application. 0078 * 0079 * @since KDE Frameworks 5.82 0080 * @property Kirigami.Heading.Type type 0081 */ 0082 property int type: Kirigami.Heading.Type.Normal 0083 0084 font.pointSize: __headerPointSize(level) 0085 font.weight: type === Kirigami.Heading.Type.Primary ? Font.DemiBold : Font.Normal 0086 0087 opacity: type === Kirigami.Heading.Type.Secondary ? 0.7 : 1 0088 0089 Accessible.role: Accessible.Heading 0090 0091 // TODO KF6: Remove this public method 0092 function headerPointSize(l) { 0093 console.warn("org.kde.plasma.extras/Heading::headerPointSize() is deprecated. Use font.pointSize directly instead"); 0094 return __headerPointSize(l); 0095 } 0096 0097 // 0098 // W A R N I N G 0099 // ------------- 0100 // 0101 // This method is not part of the Kirigami API. It exists purely as an 0102 // implementation detail. It may change from version to 0103 // version without notice, or even be removed. 0104 // 0105 // We mean it. 0106 // 0107 function __headerPointSize(level) { 0108 const n = Kirigami.Theme.defaultFont.pointSize; 0109 switch (level) { 0110 case 1: 0111 return n * 1.35 + step; 0112 case 2: 0113 return n * 1.20 + step; 0114 case 3: 0115 return n * 1.15 + step; 0116 case 4: 0117 return n * 1.10 + step; 0118 default: 0119 return n + step; 0120 } 0121 } 0122 }