Warning, /frameworks/kcmutils/src/qml/components/private/GridViewInternal.qml is written in an unsupported language. File is not indexed.

0001 /*
0002     SPDX-FileCopyrightText: 2019 Marco Martin <mart@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 import QtQuick 2.15
0008 import QtQuick.Controls 2.2 as QQC2
0009 import org.kde.kirigami 2.19 as Kirigami
0010 
0011 
0012 GridView {
0013     id: view
0014 
0015     property int implicitCellWidth: Kirigami.Units.gridUnit * 10
0016     property int implicitCellHeight: Math.round(implicitCellWidth / 1.6) + Kirigami.Units.gridUnit*3
0017 
0018     /**
0019      * Allow to highlight the selected item with Kirigami.Theme.neutralTextColor
0020      */
0021     property bool neutralHighlight: false
0022 
0023     onCurrentIndexChanged: positionViewAtIndex(currentIndex, GridView.Contain);
0024 
0025     QtObject {
0026         id: internal
0027         readonly property int availableWidth: scroll.width - internal.scrollBarSpace - 4
0028         readonly property int scrollBarSpace: scroll.QQC2.ScrollBar.vertical.width
0029     }
0030     anchors {
0031         fill: parent
0032         margins: 2
0033         leftMargin: 2 + (scroll.QQC2.ScrollBar.vertical.visible ? 0 : Math.round(internal.scrollBarSpace / 2))
0034     }
0035     clip: true
0036     activeFocusOnTab: true
0037 
0038     Keys.onTabPressed: nextItemInFocusChain().forceActiveFocus(Qt.TabFocusReason)
0039     Keys.onBacktabPressed: nextItemInFocusChain(false).forceActiveFocus(Qt.TabFocusReason)
0040 
0041     cellWidth: Math.floor(internal.availableWidth / Math.max(Math.floor(internal.availableWidth / (implicitCellWidth + Kirigami.Units.gridUnit)), (Kirigami.Settings.isMobile ? 1 : 2)))
0042     cellHeight: Kirigami.Settings.isMobile ? cellWidth/1.6 + Kirigami.Units.gridUnit : implicitCellHeight
0043 
0044     keyNavigationEnabled: true
0045     keyNavigationWraps: true
0046     highlightMoveDuration: 0
0047 
0048     remove: Transition {
0049         ParallelAnimation {
0050             NumberAnimation { property: "scale"; to: 0.5; duration: Kirigami.Units.longDuration }
0051             NumberAnimation { property: "opacity"; to: 0.0; duration: Kirigami.Units.longDuration }
0052         }
0053     }
0054 
0055     removeDisplaced: Transition {
0056         SequentialAnimation {
0057             // wait for the "remove" animation to finish
0058             PauseAnimation { duration: Kirigami.Units.longDuration }
0059             NumberAnimation { properties: "x,y"; duration: Kirigami.Units.longDuration }
0060         }
0061     }
0062 
0063     Loader {
0064         anchors.centerIn: parent
0065         width: parent.width - (Kirigami.Units.gridUnit * 8)
0066         active: parent.count === 0 && !startupTimer.running
0067         opacity: active && status === Loader.Ready ? 1 : 0
0068         visible: opacity > 0
0069         Behavior on opacity {
0070             OpacityAnimator {
0071                 duration: Kirigami.Units.longDuration
0072                 easing.type: Easing.InOutQuad
0073             }
0074         }
0075         sourceComponent: Kirigami.PlaceholderMessage {
0076             anchors.centerIn: parent
0077             icon.name: "edit-none"
0078             text: i18n("No items found")
0079         }
0080     }
0081 
0082     // The view can take a bit of time to initialize itself when the KCM first
0083     // loads, during which time count is 0, which would cause the placeholder
0084     // message to appear for a moment and then disappear. To prevent this, let's
0085     // suppress it appearing for a moment after the KCM loads.
0086     Timer {
0087         id: startupTimer
0088         interval: Kirigami.Units.humanMoment
0089         running: false
0090     }
0091     Component.onCompleted: {
0092         startupTimer.start()
0093     }
0094 }