10import QtQuick.Controls as QQC2
11import org.kde.kirigami as Kirigami
63 property bool wideMode: width >= lay.wideImplicitWidth
72 property list<Item> twinFormLayouts
74 onTwinFormLayoutsChanged: {
75 for (
const twinFormLayout of twinFormLayouts) {
76 if (!(root in twinFormLayout.children[0].reverseTwins)) {
77 twinFormLayout.children[0].reverseTwins.push(root)
78 Qt.callLater(() => twinFormLayout.children[0].reverseTwinsChanged());
83 Component.onCompleted: {
84 relayoutTimer.triggered();
87 Component.onDestruction: {
88 for (
const twinFormLayout of twinFormLayouts) {
89 const child = twinFormLayout.children[0];
90 child.reverseTwins = child.reverseTwins.filter(value => value !== root);
94 implicitWidth: lay.wideImplicitWidth
95 implicitHeight: lay.implicitHeight
96 Layout.preferredHeight: lay.implicitHeight
97 Layout.fillWidth:
true
98 Accessible.role: Accessible.Form
102 property int wideImplicitWidth
103 columns: root.wideMode ? 2 : 1
104 rowSpacing: Kirigami.Units.smallSpacing
105 columnSpacing: Kirigami.Units.largeSpacing
113 restoreMode: Binding.RestoreBinding
119 value: root.implicitWidth
120 restoreMode: Binding.RestoreBinding
123 horizontalCenter: root.wideMode ? root.horizontalCenter : undefined
124 left: root.wideMode ? undefined : root.left
127 property var reverseTwins: []
128 property var knownItems: []
129 property var buddies: []
130 property int knownItemsImplicitWidth: {
132 for (
const item of knownItems) {
133 if (typeof item.Layout ===
"undefined") {
143 const actualWidth = item.Layout.preferredWidth > 0
144 ? item.Layout.preferredWidth
145 : item.implicitWidth;
147 hint = Math.max(hint, item.Layout.minimumWidth, Math.min(actualWidth, item.Layout.maximumWidth));
151 property int buddiesImplicitWidth: {
154 for (
const buddy of buddies) {
155 if (buddy.visible && buddy.item !== null && !buddy.item.Kirigami.FormData.isSection) {
156 hint = Math.max(hint, buddy.implicitWidth);
161 readonly
property var actualTwinFormLayouts: {
163 const list = lay.reverseTwins.slice();
164 for (
const parentLay of twinFormLayouts) {
165 if (!parentLay || !parentLay.hasOwnProperty(
"children")) {
168 list.push(parentLay);
169 for (
const childLay of parentLay.children[0].reverseTwins) {
170 if (childLay && !(childLay in list)) {
183 lay.wideImplicitWidth = lay.implicitWidth;
187 onImplicitWidthChanged: hintCompression.restart();
191 Layout.preferredWidth: {
192 let
hint = lay.buddiesImplicitWidth;
193 for (
const item of lay.actualTwinFormLayouts) {
194 if (item && item.hasOwnProperty(
"children")) {
195 hint = Math.max(hint, item.children[0].buddiesImplicitWidth);
200 Layout.preferredHeight: 2
203 Layout.preferredWidth: {
204 let
hint = Math.min(root.width, lay.knownItemsImplicitWidth);
205 for (
const item of lay.actualTwinFormLayouts) {
206 if (item.hasOwnProperty(
"children")) {
207 hint = Math.max(hint, item.children[0].knownItemsImplicitWidth);
212 Layout.preferredHeight: 2
235 function effectiveLayout(item) {
239 const verticalAlignment =
240 item.Kirigami.FormData.labelAlignment !== 0
241 ? item.Kirigami.FormData.labelAlignment
244 if (item.Kirigami.FormData.isSection) {
245 return Qt.AlignHCenter;
248 return Qt.AlignRight | verticalAlignment;
250 return Qt.AlignLeft |
Qt.AlignBottom;
257 function effectiveTextLayout(item) {
261 if (root.wideMode && !item.Kirigami.FormData.isSection) {
262 return item.Kirigami.FormData.labelAlignment !== 0 ? item.Kirigami.FormData.labelAlignment : Text.AlignVCenter;
264 return Text.AlignBottom;
272 const __items = root.children;
274 for (let i = 2; i < __items.length; ++i) {
275 const item = __items[i];
278 if (lay.knownItems.indexOf(item) !== -1 || item instanceof Repeater) {
281 lay.knownItems.push(item);
283 const itemContainer = itemComponent.createObject(temp, { item });
286 if (item.Kirigami.FormData.label.length > 0 && item.Kirigami.FormData.isSection) {
287 placeHolderComponent.createObject(lay, { item });
290 const buddy = buddyComponent.createObject(lay, { item, index: i - 2 });
292 itemContainer.parent = lay;
293 lay.buddies.push(buddy);
295 lay.knownItemsChanged();
296 lay.buddiesChanged();
297 hintCompression.triggered();
301 onChildrenChanged: relayoutTimer.restart();
310 enabled: item?.
enabled ??
false
311 visible: item?.visible ??
false
314 implicitWidth: item !== null ? Math.max(item.implicitWidth, 1) : 0
315 implicitHeight: item !== null ? Math.max(item.implicitHeight, 1) : 0
316 Layout.preferredWidth: item !== null ? Math.max(1, item.Layout.preferredWidth > 0 ? item.Layout.preferredWidth : Math.ceil(item.implicitWidth)) : 0
317 Layout.preferredHeight: item !== null ? Math.max(1, item.Layout.preferredHeight > 0 ? item.Layout.preferredHeight : Math.ceil(item.implicitHeight)) : 0
319 Layout.minimumWidth: item?.Layout.minimumWidth ?? 0
320 Layout.minimumHeight: item?.Layout.minimumHeight ?? 0
322 Layout.maximumWidth: item?.Layout.maximumWidth ?? 0
323 Layout.maximumHeight: item?.Layout.maximumHeight ?? 0
326 Layout.fillWidth: item !== null && (item instanceof TextInput || item.Layout.fillWidth || item.Kirigami.FormData.isSection)
327 Layout.columnSpan: item?.Kirigami.FormData.isSection ? lay.columns : 1
333 onXChanged:
if (item !== null) { item.x = x + lay.x; }
335 onYChanged:
if (item !== null) { item.y = y + lay.y; }
336 onWidthChanged:
if (item !== null) { item.width = width; }
337 Component.onCompleted: item.x = x + lay.x;
340 function onXChanged() {
349 id: placeHolderComponent
353 enabled: item?.
enabled ??
false
354 visible: item?.visible ??
false
356 width: Kirigami.Units.smallSpacing
357 height: Kirigami.Units.smallSpacing
358 Layout.topMargin: item?.height > 0 ? Kirigami.Units.smallSpacing : 0
374 enabled: item?.
enabled ??
false
375 visible: (item?.visible && (root.wideMode || text.length > 0)) ??
false
376 Kirigami.MnemonicData.enabled: item?.Kirigami.FormData.buddyFor?.activeFocusOnTab ??
false
377 Kirigami.MnemonicData.controlType: Kirigami.MnemonicData.FormLabel
378 Kirigami.MnemonicData.label: item?.Kirigami.FormData.label ??
""
379 text: Kirigami.MnemonicData.richTextLabel
380 type: item?.Kirigami.FormData.isSection ? Kirigami.Heading.Type.Primary : Kirigami.Heading.Type.Normal
382 level: item?.Kirigami.FormData.isSection ? 3 : 5
384 Layout.columnSpan: item?.Kirigami.FormData.isSection ? lay.columns : 1
385 Layout.preferredHeight: {
389 if (item.Kirigami.FormData.label.length > 0) {
392 if (item.Kirigami.FormData.isSection && labelItem.index !== 0) {
393 return implicitHeight + Kirigami.Units.largeSpacing * 2;
395 else if (root.wideMode && !(item.Kirigami.FormData.buddyFor instanceof QQC2.TextArea)) {
396 return Math.max(implicitHeight, item.Kirigami.FormData.buddyFor.height)
398 return implicitHeight;
400 return Kirigami.Units.smallSpacing;
403 Layout.alignment: temp.effectiveLayout(item)
404 verticalAlignment: temp.effectiveTextLayout(item)
406 Layout.fillWidth: !root.wideMode
413 if (root.wideMode && item.Kirigami.FormData.buddyFor.parent !== root) {
414 return item.Kirigami.FormData.buddyFor.y;
416 if (index === 0 || root.wideMode) {
419 return Kirigami.Units.largeSpacing * 2;
427 sequence: labelItem.Kirigami.MnemonicData.sequence
428 onActivated: labelItem.item.Kirigami.FormData.buddyFor.forceActiveFocus()
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)
QTextStream & left(QTextStream &stream)