8pragma ComponentBehavior: Bound
12import QtQuick.Controls as QQC2
13import org.kde.kirigami as Kirigami
67 property bool wideMode: width >= lay.wideImplicitWidth
76 property list<Item> twinFormLayouts
78 onTwinFormLayoutsChanged: {
79 for (
const twinFormLayout of twinFormLayouts) {
80 if (!(root in twinFormLayout.children[0].reverseTwins)) {
81 twinFormLayout.children[0].reverseTwins.push(root)
82 Qt.callLater(() => twinFormLayout.children[0].reverseTwinsChanged());
87 Component.onCompleted: {
88 relayoutTimer.triggered();
91 Component.onDestruction: {
92 for (
const twinFormLayout of twinFormLayouts) {
93 const child = twinFormLayout.children[0];
94 child.reverseTwins = child.reverseTwins.filter(value => value !== root);
98 implicitWidth: lay.wideImplicitWidth
99 implicitHeight: lay.implicitHeight
100 Layout.preferredHeight: lay.implicitHeight
101 Layout.fillWidth:
true
102 Accessible.role: Accessible.Form
106 property int wideImplicitWidth
107 columns: root.wideMode ? 2 : 1
108 rowSpacing: Kirigami.Units.smallSpacing
109 columnSpacing: Kirigami.Units.largeSpacing
117 restoreMode: Binding.RestoreBinding
123 value: root.implicitWidth
124 restoreMode: Binding.RestoreBinding
127 horizontalCenter: root.wideMode ? root.horizontalCenter : undefined
128 left: root.wideMode ? undefined : root.left
131 property var reverseTwins: []
132 property var knownItems: []
133 property var buddies: []
134 property int knownItemsImplicitWidth: {
136 for (
const item of knownItems) {
137 if (typeof item.Layout ===
"undefined") {
147 const actualWidth = item.Layout.preferredWidth > 0
148 ? item.Layout.preferredWidth
149 : item.implicitWidth;
151 hint = Math.max(hint, item.Layout.minimumWidth, Math.min(actualWidth, item.Layout.maximumWidth));
155 property int buddiesImplicitWidth: {
158 for (
const buddy of buddies) {
159 if (buddy.visible && buddy.item !== null && !buddy.item.Kirigami.FormData.isSection) {
160 hint = Math.max(hint, buddy.implicitWidth);
165 readonly
property var actualTwinFormLayouts: {
167 const list = lay.reverseTwins.slice();
168 for (
const parentLay of root.twinFormLayouts) {
169 if (!parentLay || !parentLay.hasOwnProperty(
"children")) {
172 list.push(parentLay);
173 for (
const childLay of parentLay.children[0].reverseTwins) {
174 if (childLay && !(childLay in list)) {
187 lay.wideImplicitWidth = lay.implicitWidth;
191 onImplicitWidthChanged: hintCompression.restart();
195 Layout.preferredWidth: {
196 let
hint = lay.buddiesImplicitWidth;
197 for (
const item of lay.actualTwinFormLayouts) {
198 if (item && item.hasOwnProperty(
"children")) {
199 hint = Math.max(hint, item.children[0].buddiesImplicitWidth);
204 Layout.preferredHeight: 2
207 Layout.preferredWidth: {
208 let
hint = Math.min(root.width, lay.knownItemsImplicitWidth);
209 for (
const item of lay.actualTwinFormLayouts) {
210 if (item.hasOwnProperty(
"children")) {
211 hint = Math.max(hint, item.children[0].knownItemsImplicitWidth);
216 Layout.preferredHeight: 2
239 function effectiveLayout(item:
Item): int {
243 const verticalAlignment =
244 item.Kirigami.FormData.labelAlignment !== 0
245 ? item.Kirigami.FormData.labelAlignment
248 if (item.Kirigami.FormData.isSection) {
249 return Qt.AlignHCenter;
252 return Qt.AlignRight | verticalAlignment;
254 return Qt.AlignLeft |
Qt.AlignBottom;
261 function effectiveTextLayout(item:
Item): int {
265 if (root.wideMode && !item.Kirigami.FormData.isSection) {
266 return item.Kirigami.FormData.labelAlignment !== 0 ? item.Kirigami.FormData.labelAlignment : Text.AlignVCenter;
268 return Text.AlignBottom;
276 const __items = root.children;
278 for (let i = 2; i < __items.length; ++i) {
279 const item = __items[i];
282 if (lay.knownItems.indexOf(item) !== -1 || item instanceof Repeater) {
285 lay.knownItems.push(item);
287 const itemContainer = itemComponent.createObject(temp, { item });
290 if (item.Kirigami.FormData.label.length > 0 && item.Kirigami.FormData.isSection) {
291 placeHolderComponent.createObject(lay, { item });
294 const buddy = buddyComponent.createObject(lay, { item, index: i - 2 });
296 itemContainer.parent = lay;
297 lay.buddies.push(buddy);
299 lay.knownItemsChanged();
300 lay.buddiesChanged();
301 hintCompression.triggered();
305 onChildrenChanged: relayoutTimer.restart();
314 enabled: item?.
enabled ??
false
315 visible: item?.visible ??
false
318 implicitWidth: item !== null ? Math.max(item.implicitWidth, 1) : 0
319 implicitHeight: item !== null ? Math.max(item.implicitHeight, 1) : 0
320 Layout.preferredWidth: item !== null ? Math.max(1, item.Layout.preferredWidth > 0 ? item.Layout.preferredWidth : Math.ceil(item.implicitWidth)) : 0
321 Layout.preferredHeight: item !== null ? Math.max(1, item.Layout.preferredHeight > 0 ? item.Layout.preferredHeight : Math.ceil(item.implicitHeight)) : 0
323 Layout.minimumWidth: item?.Layout.minimumWidth ?? 0
324 Layout.minimumHeight: item?.Layout.minimumHeight ?? 0
326 Layout.maximumWidth: item?.Layout.maximumWidth ?? 0
327 Layout.maximumHeight: item?.Layout.maximumHeight ?? 0
329 Layout.alignment:
Qt.AlignLeft |
Qt.AlignVCenter
330 Layout.fillWidth: item !== null && (item instanceof TextInput || item.Layout.fillWidth || item.Kirigami.FormData.isSection)
331 Layout.columnSpan: item?.Kirigami.FormData.isSection ? lay.columns : 1
337 onXChanged:
if (item !== null) { item.x = x + lay.x; }
339 onYChanged:
if (item !== null) { item.y = y + lay.y; }
340 onWidthChanged:
if (item !== null) { item.width = width; }
341 Component.onCompleted: item.
x = x + lay.x;
344 function onXChanged(): void {
345 if (container.item !== null) {
346 container.item.x = container.x + lay.x;
353 id: placeHolderComponent
357 enabled: item?.
enabled ??
false
358 visible: item?.visible ??
false
360 width: Kirigami.Units.smallSpacing
361 height: Kirigami.Units.smallSpacing
362 Layout.topMargin: item?.height > 0 ? Kirigami.Units.smallSpacing : 0
378 enabled: item?.
enabled ??
false
379 visible: (item?.visible && (root.wideMode || text.length > 0)) ??
false
380 Kirigami.MnemonicData.enabled: item?.Kirigami.FormData.buddyFor?.activeFocusOnTab ?? false
381 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.FormLabel
382 Kirigami.MnemonicData.
label: item?.Kirigami.FormData.
label ??
""
383 text: Kirigami.MnemonicData.richTextLabel
386 level: item?.Kirigami.FormData.isSection ? 3 : 5
388 Layout.columnSpan: item?.Kirigami.FormData.isSection ? lay.columns : 1
389 Layout.preferredHeight: {
393 if (item.Kirigami.FormData.label.length > 0) {
396 if (item.Kirigami.FormData.isSection && labelItem.index !== 0) {
397 return implicitHeight + Kirigami.Units.largeSpacing * 2;
399 else if (root.wideMode && !(item.Kirigami.FormData.buddyFor instanceof TextEdit)) {
400 return Math.max(implicitHeight, item.Kirigami.FormData.buddyFor.height)
402 return implicitHeight;
404 return Kirigami.Units.smallSpacing;
407 Layout.alignment: temp.effectiveLayout(item)
408 verticalAlignment: temp.effectiveTextLayout(item)
410 Layout.fillWidth: !root.wideMode
417 if (root.wideMode && item.Kirigami.FormData.buddyFor.parent !== root) {
418 return item.Kirigami.FormData.buddyFor.y;
420 if (index === 0 || root.wideMode) {
423 return Kirigami.Units.largeSpacing * 2;
431 sequence: labelItem.Kirigami.MnemonicData.sequence
432 onActivated: labelItem.item.Kirigami.FormData.buddyFor.forceActiveFocus()
A heading label used for subsections of texts.
Type type(const QSqlDatabase &db)
QAction * hint(const QObject *recvr, const char *slot, QObject *parent)
QStringView level(QStringView ifopt)
KIOCORE_EXPORT QStringList list(const QString &fileClass)
QString label(StandardShortcut id)
QTextStream & left(QTextStream &stream)