Kirigami2

CardsLayout.qml
1 /*
2  * SPDX-FileCopyrightText: 2018 Marco Martin <[email protected]>
3  *
4  * SPDX-License-Identifier: LGPL-2.0-or-later
5  */
6 
7 import QtQuick 2.6
8 import QtQuick.Controls 2.0 as Controls
9 import QtQuick.Layouts 1.2
10 import org.kde.kirigami 2.4 as Kirigami
11 
26 GridLayout {
33  property int maximumColumns: 2
34 
44  property int maximumColumnWidth: Kirigami.Units.gridUnit * 20
45 
52  property int minimumColumnWidth: Kirigami.Units.gridUnit * 12
53 
54  columns: Math.max(1, Math.min(maximumColumns > 0 ? maximumColumns : Infinity,
55  Math.floor(width/minimumColumnWidth),
56  Math.ceil(width/maximumColumnWidth)));
57 
58  rowSpacing: Kirigami.Units.largeSpacing * columns
59  columnSpacing: Kirigami.Units.largeSpacing * columns
60 
61 
62  //NOTE: this default width which defaults to 2 columns is just to remove a binding loop on columns
63  width: maximumColumnWidth*2 + Kirigami.Units.largeSpacing
64  //same computation of columns, but on the parent size
65  Layout.preferredWidth: maximumColumnWidth * Math.max(1, Math.min(maximumColumns > 0 ? maximumColumns : Infinity,
66  Math.floor(parent.width/minimumColumnWidth),
67  Math.ceil(parent.width/maximumColumnWidth))) + Kirigami.Units.largeSpacing * (columns - 1)
68 
69  Layout.maximumWidth: Layout.preferredWidth
70  Layout.alignment: Qt.AlignHCenter
71 
72  Component.onCompleted: childrenChanged()
73  onChildrenChanged: {
74  for (var i = 0; i < children.length; ++i) {
75  children[i].Layout.fillHeight = true;
76  }
77  }
78 }
Definition: icon.h:18
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Sep 29 2020 22:44:07 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.