KCMUtils

GridViewInternal.qml
1/*
2 SPDX-FileCopyrightText: 2019 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
10
11GridView {
12 id: view
13
14 property int implicitCellWidth: Kirigami.Units.gridUnit * 10
15 property int implicitCellHeight: Math.round(implicitCellWidth / 1.6) + Kirigami.Units.gridUnit*3
16
17 /**
18 * Allow to highlight the selected item with Kirigami.Theme.neutralTextColor
19 */
20 property bool neutralHighlight: false
21
22 onCurrentIndexChanged: positionViewAtIndex(currentIndex, GridView.Contain);
23
24 QtObject {
25 id: internal
26 readonly property int availableWidth: scroll.width - internal.scrollBarSpace - 4
27 readonly property int scrollBarSpace: scroll.QQC2.ScrollBar.vertical.width
28 }
29 anchors {
30 fill: parent
31 margins: 2
32 leftMargin: 2 + (scroll.QQC2.ScrollBar.vertical.visible ? 0 : Math.round(internal.scrollBarSpace / 2))
33 }
34 clip: true
35 activeFocusOnTab: true
36
37 Keys.onTabPressed: event => nextItemInFocusChain().forceActiveFocus(Qt.TabFocusReason)
38 Keys.onBacktabPressed: event => nextItemInFocusChain(false).forceActiveFocus(Qt.TabFocusReason)
39
40 cellWidth: Math.floor(internal.availableWidth / Math.max(Math.floor(internal.availableWidth / (implicitCellWidth + Kirigami.Units.gridUnit)), (Kirigami.Settings.isMobile ? 1 : 2)))
41 cellHeight: Kirigami.Settings.isMobile ? cellWidth/1.6 + Kirigami.Units.gridUnit : implicitCellHeight
42
43 keyNavigationEnabled: true
44 keyNavigationWraps: true
45 highlightMoveDuration: 0
46
47 remove: Transition {
48 ParallelAnimation {
49 NumberAnimation { property: "scale"; to: 0.5; duration: Kirigami.Units.longDuration }
50 NumberAnimation { property: "opacity"; to: 0.0; duration: Kirigami.Units.longDuration }
51 }
52 }
53
54 removeDisplaced: Transition {
55 SequentialAnimation {
56 // wait for the "remove" animation to finish
57 PauseAnimation { duration: Kirigami.Units.longDuration }
58 NumberAnimation { properties: "x,y"; duration: Kirigami.Units.longDuration }
59 }
60 }
61
62 Loader {
63 anchors.centerIn: parent
64 width: parent.width - (Kirigami.Units.gridUnit * 8)
65 active: parent.count === 0 && !startupTimer.running
66 opacity: active && status === Loader.Ready ? 1 : 0
67 visible: opacity > 0
68 Behavior on opacity {
69 OpacityAnimator {
70 duration: Kirigami.Units.longDuration
71 easing.type: Easing.InOutQuad
72 }
73 }
74 sourceComponent: Kirigami.PlaceholderMessage {
75 anchors.centerIn: parent
76 icon.name: "edit-none"
77 text: i18nd("kcmutils6", "No items found")
78 }
79 }
80
81 // The view can take a bit of time to initialize itself when the KCM first
82 // loads, during which time count is 0, which would cause the placeholder
83 // message to appear for a moment and then disappear. To prevent this, let's
84 // suppress it appearing for a moment after the KCM loads.
85 Timer {
86 id: startupTimer
87 interval: Kirigami.Units.humanMoment
88 running: false
89 }
90 Component.onCompleted: {
91 startupTimer.start()
92 }
93}
Q_SCRIPTABLE CaptureState status()
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
Type type(const QSqlDatabase &db)
bool remove(const QString &column, const QVariant &value)
QString name(StandardAction id)
KGuiItem properties()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 17 2024 11:48:59 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.