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 2.7
8import QtQuick.Controls 2.2 as QQC2
9import org.kde.kirigami 2.2 as Kirigami
10import org.kde.kcmutils as KCM
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 KCM
19 * KCM.GridViewKCM {
20 * header: Item {...}
21 * view.model: kcm.model
22 * view.delegate: KCM.GridDelegate {...}
23 * footer: Item {...}
24 * }
25 * @endcode
26 */
27KCM.AbstractKCM {
28 id: root
29
30 /**
31 * view: GridView
32 * Exposes the internal GridView: in order to set a model or a delegate to it,
33 * use the following code:
34 * @code
35 * import org.kde.kcmutils as KCM
36 * KCM.GridViewKCM {
37 * ...
38 * view.model: kcm.model
39 * view.delegate: KCM.GridDelegate {...}
40 * ...
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 KCM.GridView {
72 id: scroll
73 anchors.fill: parent
74 framedView: root.framedView
75 }
76
77}
A ScrollView containing a GridView, with the default behavior about sizing and background as recommen...
Definition GridView.qml:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:17:56 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.