9import QtQuick.Controls as QQC2
10import org.kde.kirigami as Kirigami
18Kirigami.ShadowedImage {
29 property alias titleIcon: headingIcon.source
37 property alias title: heading.text
46 property int titleAlignment: Qt.AlignTop | Qt.AlignLeft
58 property alias titleLevel: heading.level
68 property alias titleWrapMode: heading.wrapMode
80 property bool checkable: false
94 property bool checked: false
96 property int leftPadding: headingIcon.valid ? Kirigami.Units.smallSpacing * 2 : Kirigami.Units.largeSpacing
97 property int topPadding: headingIcon.valid ? Kirigami.Units.smallSpacing * 2 : Kirigami.Units.largeSpacing
98 property int rightPadding: headingIcon.valid ? Kirigami.Units.smallSpacing * 2 : Kirigami.Units.largeSpacing
99 property int bottomPadding: headingIcon.valid ? Kirigami.Units.smallSpacing * 2 : Kirigami.Units.largeSpacing
101 property int implicitWidth: Layout.preferredWidth
103 readonly property bool empty: title.length === 0 &&
104 source.toString().length === 0 &&
108 signal toggled(bool checked)
110 Layout.fillWidth: true
112 Layout.preferredWidth: titleLayout.implicitWidth || sourceSize.width
113 Layout.preferredHeight: titleLayout.completed && source.toString().length > 0 ? width/(sourceSize.width / sourceSize.height) : Layout.minimumHeight
114 Layout.minimumHeight: titleLayout.implicitHeight > 0 ? titleLayout.implicitHeight + Kirigami.Units.smallSpacing * 2 : 0
116 onTitleAlignmentChanged: {
118 titleLayout.anchors.top = undefined
119 titleLayout.anchors.verticalCenter = undefined
120 titleLayout.anchors.bottom = undefined
121 shadowedRectangle.anchors.top = undefined
122 shadowedRectangle.anchors.verticalCenter = undefined
123 shadowedRectangle.anchors.bottom = undefined
125 if (root.titleAlignment & Qt.AlignTop) {
126 titleLayout.anchors.top = root.top
127 shadowedRectangle.anchors.top = root.top
129 else if (root.titleAlignment & Qt.AlignVCenter) {
130 titleLayout.anchors.verticalCenter = root.verticalCenter
131 shadowedRectangle.anchors.verticalCenter = root.verticalCenter
133 else if (root.titleAlignment & Qt.AlignBottom) {
134 titleLayout.anchors.bottom = root.bottom
135 shadowedRectangle.anchors.bottom = root.bottom
139 titleLayout.anchors.left = undefined
140 titleLayout.anchors.horizontalCenter = undefined
141 titleLayout.anchors.right = undefined
142 if (root.titleAlignment & Qt.AlignRight) {
143 titleLayout.anchors.right = root.right
145 else if (root.titleAlignment & Qt.AlignHCenter) {
146 titleLayout.anchors.horizontalCenter = root.horizontalCenter
148 else if (root.titleAlignment & Qt.AlignLeft) {
149 titleLayout.anchors.left = root.left
152 fillMode: Image.PreserveAspectCrop
157 Component.onCompleted: {
158 titleLayout.completed =
true;
161 Kirigami.ShadowedRectangle {
162 id: shadowedRectangle
167 height: Math.min(parent.height, titleLayout.height * 1.5)
172 corners.topLeftRadius: root.titleAlignment &
Qt.AlignTop ? root.corners.topLeftRadius : 0
173 corners.topRightRadius: root.titleAlignment &
Qt.AlignTop ? root.corners.topRightRadius : 0
174 corners.bottomLeftRadius: root.titleAlignment &
Qt.AlignBottom ? root.corners.bottomLeftRadius : 0
175 corners.bottomRightRadius: root.titleAlignment &
Qt.AlignBottom ? root.corners.bottomRightRadius : 0
177 visible: root.source.toString().length !== 0 && root.title.length !== 0 && ((root.titleAlignment &
Qt.AlignTop) || (root.titleAlignment &
Qt.AlignVCenter) || (root.titleAlignment &
Qt.AlignBottom))
182 property bool completed:
false
184 leftMargin: root.leftPadding
185 topMargin: root.topPadding
186 rightMargin: root.rightPadding
187 bottomMargin: root.bottomPadding
189 width: Math.min(implicitWidth, parent.width -root.leftPadding -root.rightPadding - (checkboxLoader.active ? Kirigami.Units.largeSpacing : 0))
190 height: Math.min(implicitHeight, parent.height -root.topPadding -root.bottomPadding)
193 Layout.minimumWidth: Kirigami.Units.iconSizes.large
194 Layout.minimumHeight: width
200 Layout.fillWidth:
true
201 Layout.fillHeight:
true
202 verticalAlignment: Text.AlignVCenter
203 visible: text.length > 0
205 color: root.source.
toString().
length > 0 ?
"white" : Kirigami.Theme.textColor
206 wrapMode: Text.NoWrap
207 elide: Text.ElideRight
216 topMargin: root.topPadding
218 active: root.checkable
219 sourceComponent: QQC2.CheckBox {
220 checked: root.checked
221 onToggled: root.toggled(checked);
QStringView level(QStringView ifopt)
qsizetype length() const const
QString toString() const const
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)