KCMUtils

KPluginSelector.qml
1 /*
2  SPDX-FileCopyrightText: 2022 Alexander Lohnau <[email protected]>
3  SPDX-License-Identifier: LGPL-2.0-or-later
4 */
5 
6 import QtQuick 2.5
7 import QtQuick.Controls 2.5 as QQC2
8 import QtQuick.Layouts 1.1
9 
10 import org.kde.kirigami 2.19 as Kirigami
11 
12 import org.kde.kcmutils.private 1.0 as KCMUtilsPrivate
13 import "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 5.94
21  */
22 ListView {
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 
29  clip: true
30 
31  // Don't select anything by default as selection is not used here
32  currentIndex: -1
33 
34  model: KCMUtilsPrivate.ProxyModel {
35  id: proxyModel
36  model: pluginSelector.sourceModel
37  query: pluginSelector.query ?? ""
38  }
39 
40  delegate: KPluginDelegate {
41  }
42 
43  section.property: "category"
44  section.delegate: Kirigami.ListSectionHeader {
45  width: pluginSelector.width
46  text: section
47  }
48 
49  Kirigami.OverlaySheet {
50  id: internalAboutDialog
51  parent: pluginSelector.parent
52  property var metaDataInfo
53  background: Rectangle {
54  Kirigami.Theme.inherit: false
55  Kirigami.Theme.colorSet: Kirigami.Theme.Window
56  color: Kirigami.Theme.backgroundColor
57  }
58 
59  contentItem: Loader {
60  active: internalAboutDialog.metaDataInfo !== undefined
61  sourceComponent: ColumnLayout {
62  Private.AboutPlugin {
63  metaData: internalAboutDialog.metaDataInfo
64  Layout.maximumWidth: Math.min(Kirigami.Units.gridUnit * 30, Math.round(pluginSelector.width * 0.8))
65  }
66  }
67  }
68  }
69  // Only for internal usage in KPluginDelegate!
70  property var __aboutDialog: internalAboutDialog
71 
72  Loader {
73  anchors.centerIn: parent
74  width: parent.width - (Kirigami.Units.gridUnit * 8)
75  active: pluginSelector.count === 0 && !startupTimer.running
76  opacity: active && status === Loader.Ready ? 1 : 0
77  visible: opacity > 0
78  Behavior on opacity {
79  OpacityAnimator {
80  duration: Kirigami.Units.longDuration
81  easing.type: Easing.InOutQuad
82  }
83  }
84  sourceComponent: Kirigami.PlaceholderMessage {
85  icon.name: "edit-none"
86  text: pluginSelector.query && pluginSelector.query.length > 0 ? i18n("No matches") : i18n("No plugins found")
87  }
88  }
89 
90  // The view can take a bit of time to initialize itself when the KCM first
91  // loads, during which time count is 0, which would cause the placeholder
92  // message to appear for a moment and then disappear. To prevent this, let's
93  // suppress it appearing for a moment after the KCM loads.
94  Timer {
95  id: startupTimer
96  interval: Kirigami.Units.humanMoment
97  running: false
98  }
99  Component.onCompleted: {
100  startupTimer.start()
101  }
102 }
std::optional< QSqlQuery > query(const QString &queryStatement)
QString i18n(const char *text, const TYPE &arg...)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sun Jun 26 2022 03:51:23 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.