KCMUtils

PluginSelector.qml
1/*
2 SPDX-FileCopyrightText: 2022 Alexander Lohnau <alexander.lohnau@gmx.de>
3 SPDX-License-Identifier: LGPL-2.0-or-later
4*/
5
6import QtQuick
7import QtQuick.Controls as QQC2
8import QtQuick.Layouts
9
10import org.kde.kirigami as Kirigami
11
12import org.kde.kcmutils.private as KCMUtilsPrivate
13import "private" as Private
14
15/**
16 * ListView for showing plugins with their info and configuration.
17 * If extra butons should be added, a custom KPluginDelegate with the additionalActions
18 * property should be defined.
19 *
20 * @since 6.0, this got renamed from KPluginSelector to PluginSelector
21 */
22ListView {
23 id: pluginSelector
24 // KPluginModel which contains the plugins that should be displayed
25 required property QtObject sourceModel
26 // Query that is typed into the search field. Ideally, this is part of the KCM header
27 property var query
28 // PluginDelegate should be used with this, it contains an ActionToolBar that is incredibly expensive to construct,
29 // make sure to cache delegates a fair amount right out of the box.
30 cacheBuffer: parent.height * 2
31
32 clip: true
33
34 // Don't select anything by default as selection is not used here
35 currentIndex: -1
36
37 model: KCMUtilsPrivate.ProxyModel {
38 id: proxyModel
39 model: pluginSelector.sourceModel
40 query: pluginSelector.query ?? ""
41 }
42
43 delegate: PluginDelegate {
44 }
45
46 section.property: "category"
47 section.delegate: Kirigami.ListSectionHeader {
48 width: pluginSelector.width
49 text: section
50 }
51
52 Kirigami.OverlaySheet {
53 id: internalAboutDialog
54 parent: pluginSelector.Window.window?.contentItem ?? null
55 property var metaDataInfo
56
57 Loader {
58 active: internalAboutDialog.metaDataInfo !== undefined
59 sourceComponent: ColumnLayout {
60 Private.AboutPlugin {
61 metaData: internalAboutDialog.metaDataInfo
62 Layout.maximumWidth: Math.min(Kirigami.Units.gridUnit * 30, Math.round(pluginSelector.width * 0.8))
63 }
64 }
65 }
66 }
67 // Only for internal usage in KPluginDelegate!
68 property var __aboutDialog: internalAboutDialog
69
70 Loader {
71 anchors.centerIn: parent
72 width: parent.width - (Kirigami.Units.gridUnit * 8)
73 active: pluginSelector.count === 0 && !startupTimer.running
74 opacity: active && status === Loader.Ready ? 1 : 0
75 visible: opacity > 0
76 Behavior on opacity {
77 OpacityAnimator {
78 duration: Kirigami.Units.longDuration
79 easing.type: Easing.InOutQuad
80 }
81 }
82 sourceComponent: Kirigami.PlaceholderMessage {
83 icon.name: "edit-none"
84 text: pluginSelector.query && pluginSelector.query.length > 0 ? i18nd("kcmutils6", "No matches") : i18nd("kcmutils6", "No plugins found")
85 }
86 }
87
88 // The view can take a bit of time to initialize itself when the KCM first
89 // loads, during which time count is 0, which would cause the placeholder
90 // message to appear for a moment and then disappear. To prevent this, let's
91 // suppress it appearing for a moment after the KCM loads.
92 Timer {
93 id: startupTimer
94 interval: Kirigami.Units.humanMoment
95 running: false
96 }
97 Component.onCompleted: {
98 startupTimer.start()
99 }
100}
Q_SCRIPTABLE CaptureState status()
QString i18nd(const char *domain, const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:53:48 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.