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