Warning, /libraries/kirigami-addons/src/formcard/FormHeader.qml is written in an unsupported language. File is not indexed.
0001 /* 0002 * SPDX-FileCopyrightText: 2022 Devin Lin <devin@kde.org> 0003 * SPDX-FileCopyrightText: 2023 James Graham <james.h.graham@protonmail.com> 0004 * SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 import QtQuick 2.15 0008 import QtQuick.Controls 2.15 as QQC2 0009 import QtQuick.Templates 2.15 as T 0010 import QtQuick.Layouts 1.15 0011 0012 import org.kde.kirigami 2.19 as Kirigami 0013 0014 /** 0015 * @brief A header item for a form card. 0016 * 0017 * @note The header should be placed above the card in a layout not as a child. 0018 */ 0019 Item { 0020 id: root 0021 0022 /** 0023 * @brief This property holds the header title. 0024 * 0025 * @property string title 0026 */ 0027 property alias title: headerContent.text 0028 0029 property alias trailing: header.data 0030 0031 /** 0032 * @brief The maximum width of the header. 0033 */ 0034 property real maximumWidth: Kirigami.Units.gridUnit * 30 0035 0036 property list<T.Action> actions 0037 0038 /** 0039 * @brief These properties hold the padding around the heading. 0040 */ 0041 property real topPadding: Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0042 property real bottomPadding: Kirigami.Units.smallSpacing 0043 property real leftPadding: cardWidthRestricted ? Kirigami.Units.smallSpacing : Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0044 property real rightPadding: cardWidthRestricted ? Kirigami.Units.smallSpacing : Kirigami.Units.largeSpacing + Kirigami.Units.smallSpacing 0045 0046 /** 0047 * @brief Whether the card's width is being restricted. 0048 */ 0049 readonly property bool cardWidthRestricted: root.width > root.maximumWidth 0050 0051 Kirigami.Theme.colorSet: Kirigami.Theme.View 0052 Kirigami.Theme.inherit: false 0053 0054 Layout.fillWidth: true 0055 0056 implicitHeight: header.implicitHeight 0057 implicitWidth: header.implicitWidth + header.anchors.leftMargin + header.anchors.rightMargin 0058 0059 RowLayout { 0060 id: header 0061 0062 anchors { 0063 fill: parent 0064 leftMargin: root.cardWidthRestricted ? Math.round((root.width - root.maximumWidth) / 2) : 0 0065 rightMargin: root.cardWidthRestricted ? Math.round((root.width - root.maximumWidth) / 2) : 0 0066 } 0067 0068 QQC2.Label { 0069 id: headerContent 0070 0071 topPadding: root.topPadding 0072 bottomPadding: root.bottomPadding 0073 leftPadding: root.leftPadding 0074 rightPadding: root.rightPadding 0075 0076 font.weight: Font.DemiBold 0077 wrapMode: Text.WordWrap 0078 Accessible.role: Accessible.Heading 0079 Layout.fillWidth: true 0080 } 0081 0082 Repeater { 0083 model: root.actions 0084 0085 QQC2.ToolButton { 0086 required property var modelData 0087 0088 action: modelData 0089 visible: modelData 0090 } 0091 } 0092 } 0093 }