KCMUtils

GridViewKCM.qml
1/*
2 SPDX-FileCopyrightText: 2017 Marco Martin <mart@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import QtQuick.Controls as QQC2
9import org.kde.kirigami as Kirigami
10import org.kde.kcmutils as KCMutils
11
12/**
13 * This component is intended to be used as the root item for KCMs that are based upon
14 * a grid view of thumbnails, such as the theme or wallpaper selectors.
15 * It contains a GridView as its main item.
16 * It is possible to specify a header and footer component.
17 * @code
18 * import org.kde.kcmutils as KCMutils
19 *
20 * KCMutils.GridViewKCM {
21 * header: Item { }
22 * view.model: kcm.model
23 * view.delegate: KCMutils.GridDelegate { }
24 * footer: Item { }
25 * }
26 * @endcode
27 */
28KCMutils.AbstractKCM {
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.kcmutils as KCMutils
37 *
38 * KCMutils.GridViewKCM {
39 * view.model: kcm.model
40 * view.delegate: KCMutils.GridDelegate { }
41 * }
42 * @endcode
43 */
44 property alias view: scroll.view
45
46 /**
47 * framedView: bool
48 * Whether to draw a frame around the KCM's inner scrollable grid view.
49 * Default: false
50 */
51 framedView: false
52
53 implicitWidth: {
54 let width = 0;
55
56 // Show three columns at once, every column occupies implicitCellWidth + Units.gridUnit
57 width += 3 * (view.implicitCellWidth + Kirigami.Units.gridUnit);
58
59 const scrollBar = scroll.QQC2.ScrollBar.vertical;
60 width += scrollBar.width + scrollBar.leftPadding + scrollBar.rightPadding;
61
62 width += scroll.leftPadding + scroll.rightPadding
63 width += root.leftPadding + root.rightPadding;
64
65 return width;
66 }
67 implicitHeight: view.implicitCellHeight * 3 + (header ? header.height : 0) + (footer ? footer.height : 0) + Kirigami.Units.gridUnit
68
69 flickable: scroll.view
70
71 KCMutils.GridView {
72 id: scroll
73 anchors.fill: parent
74 framedView: root.framedView
75 }
76}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:15:20 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.