KDeclarative

GridViewKCM.qml
1 /*
2  SPDX-FileCopyrightText: 2017 Marco Martin <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 
7 import QtQuick 2.7
8 import QtQuick.Layouts 1.1
9 import QtQuick.Controls 2.2 as QtControls
10 import org.kde.kirigami 2.2 as Kirigami
11 import org.kde.kcm 1.1 as KCM
12 
13 /**
14  * This component is intended to be used as the root item for KCMs that are based upon
15  * a grid view of thumbnails, such as the theme or wallpaper selectors.
16  * It contains a GridView as its main item.
17  * It is possible to specify a header and footer component.
18  * @code
19  * import org.kde.kcm 1.1 as KCM
20  * KCM.GridViewKCM {
21  * header: Item {...}
22  * view.model: kcm.model
23  * view.delegate: KCM.GridDelegate {...}
24  * footer: Item {...}
25  * }
26  * @endcode
27  */
29  id: root
30 
31  /**
32  * view: GridView
33  * Exposes the internal GridView: in order to set a model or a delegate to it,
34  * use the following code:
35  * @code
36  * import org.kde.kcm 1.1 as KCM
37  * KCM.GridViewKCM {
38  * ...
39  * view.model: kcm.model
40  * view.delegate: KCM.GridDelegate {...}
41  * ...
42  * }
43  * @endcode
44  */
45  property alias view: scroll.view
46 
47  implicitWidth: {
48  var width = 0;
49 
50  // Show three columns at once, every colum occupies implicitCellWidth + Units.gridUnit
51  width += 3 * (view.implicitCellWidth + Kirigami.Units.gridUnit);
52 
53  var scrollBar = scroll.QtControls.ScrollBar.vertical;
54  width += scrollBar.width + scrollBar.leftPadding + scrollBar.rightPadding;
55 
56  width += scroll.leftPadding + scroll.rightPadding
57  width += root.leftPadding + root.rightPadding;
58 
59  return width;
60  }
61  implicitHeight: view.implicitCellHeight * 3 + (header ? header.height : 0) + (footer ? footer.height : 0) + Kirigami.Units.gridUnit
62 
63  flickable: scroll.view
64 
65  KCM.GridView {
66  id: scroll
67  anchors.fill: parent
68  }
69 }
This component is intended to be used as root item for KCMs with arbitrary content.
Definition: AbstractKCM.qml:35
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Mon Mar 8 2021 22:38:52 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.