KCMUtils

KPluginDelegate.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.Controls 2.4 as Controls
9 
10 import QtQuick.Layouts 1.1
11 
12 import org.kde.kirigami 2.5 as Kirigami
13 import org.kde.kcm 1.5 as KCM
14 
15 /// @since 5.94
16 // Not using Kirigami.CheckableListItem despite having a checkbox because we
17 // need the checkbox to be highlighted by KCM.SettingHighlighter, and
18 // CheckableListItem doesn't have that built in.
19 Kirigami.BasicListItem {
20  id: listItem
21 
22  property list<QQC2.Action> additionalActions
23  signal configTriggered()
24 
25  leading: QQC2.CheckBox {
26  checkState: model.enabled ? Qt.Checked : Qt.Unchecked;
27 
28  onToggled: model.enabled = checkState
29 
30  KCM.SettingHighlighter {
31  highlight: parent.checked !== model.enabledByDefault
32  }
33  }
34 
35  icon: model.icon
36  label: model.name
37  subtitle: model.description
38 
39  // Don't need highlight or hover effects; there is no concept of selection here
40  hoverEnabled: false
41 
42  // Some items don't have subtitles and we want everything to have a consistent height
43  reserveSpaceForSubtitle: true
44 
45  // Take care of displaying the actions
46  property var infoAction: Kirigami.Action {
47  icon.name: "dialog-information"
48  tooltip: i18nc("@info:tooltip", "About")
49  onTriggered: {
50  const aboutDialog = listItem.parent.parent.__aboutDialog
51  aboutDialog.metaDataInfo = model.metaData
52  aboutDialog.open()
53  }
54  }
55  property var configureAction: Kirigami.Action {
56  visible: model.config.isValid
57  enabled: model.enabled
58  icon.name: "configure"
59  tooltip: i18nc("@info:tooltip", "Configure...")
60  onTriggered: listItem.configTriggered()
61  }
62 
63  // Put this in an intermediary property so that we can append to the list
64  property var __allActions: []
65  Component.onCompleted: {
66  const tmp = [];
67  tmp.push(infoAction)
68  tmp.push(configureAction)
69  for (let i = 0; i < additionalActions.length; i++) {
70  tmp.push(additionalActions[i])
71  }
72  __allActions = tmp
73  }
74  trailing: Kirigami.ActionToolBar {
75  actions: __allActions
76  }
77 }
QString i18nc(const char *context, 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.