Warning, /frameworks/kcmutils/src/qml/components/PluginSelector.qml is written in an unsupported language. File is not indexed.
0001 /*
0002 SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
0003 SPDX-License-Identifier: LGPL-2.0-or-later
0004 */
0005
0006 import QtQuick
0007 import QtQuick.Controls 2.5 as QQC2
0008 import QtQuick.Layouts 1.1
0009
0010 import org.kde.kirigami 2.19 as Kirigami
0011
0012 import org.kde.kcmutils.private as KCMUtilsPrivate
0013 import "private" as Private
0014
0015 /**
0016 * ListView for showing plugins with their info and configuration.
0017 * If extra butons should be added, a custom KPluginDelegate with the additionalActions
0018 * property should be defined.
0019 *
0020 * @since 6.0, this got renamed from KPluginSelector to PluginSelector
0021 */
0022 ListView {
0023 id: pluginSelector
0024 // KPluginModel which contains the plugins that should be displayed
0025 required property QtObject sourceModel
0026 // Query that is typed into the search field. Ideally, this is part of the KCM header
0027 property var query
0028
0029 clip: true
0030
0031 // Don't select anything by default as selection is not used here
0032 currentIndex: -1
0033
0034 model: KCMUtilsPrivate.ProxyModel {
0035 id: proxyModel
0036 model: pluginSelector.sourceModel
0037 query: pluginSelector.query ?? ""
0038 }
0039
0040 delegate: PluginDelegate {
0041 }
0042
0043 section.property: "category"
0044 section.delegate: Kirigami.ListSectionHeader {
0045 width: pluginSelector.width
0046 text: section
0047 }
0048
0049 Kirigami.OverlaySheet {
0050 id: internalAboutDialog
0051 parent: pluginSelector.Window.window?.contentItem ?? null
0052 property var metaDataInfo
0053
0054 Loader {
0055 active: internalAboutDialog.metaDataInfo !== undefined
0056 sourceComponent: ColumnLayout {
0057 Private.AboutPlugin {
0058 metaData: internalAboutDialog.metaDataInfo
0059 Layout.maximumWidth: Math.min(Kirigami.Units.gridUnit * 30, Math.round(pluginSelector.width * 0.8))
0060 }
0061 }
0062 }
0063 }
0064 // Only for internal usage in KPluginDelegate!
0065 property var __aboutDialog: internalAboutDialog
0066
0067 Loader {
0068 anchors.centerIn: parent
0069 width: parent.width - (Kirigami.Units.gridUnit * 8)
0070 active: pluginSelector.count === 0 && !startupTimer.running
0071 opacity: active && status === Loader.Ready ? 1 : 0
0072 visible: opacity > 0
0073 Behavior on opacity {
0074 OpacityAnimator {
0075 duration: Kirigami.Units.longDuration
0076 easing.type: Easing.InOutQuad
0077 }
0078 }
0079 sourceComponent: Kirigami.PlaceholderMessage {
0080 icon.name: "edit-none"
0081 text: pluginSelector.query && pluginSelector.query.length > 0 ? i18n("No matches") : i18n("No plugins found")
0082 }
0083 }
0084
0085 // The view can take a bit of time to initialize itself when the KCM first
0086 // loads, during which time count is 0, which would cause the placeholder
0087 // message to appear for a moment and then disappear. To prevent this, let's
0088 // suppress it appearing for a moment after the KCM loads.
0089 Timer {
0090 id: startupTimer
0091 interval: Kirigami.Units.humanMoment
0092 running: false
0093 }
0094 Component.onCompleted: {
0095 startupTimer.start()
0096 }
0097 }