KCMUtils

SettingStateBinding.qml
1/*
2 SPDX-FileCopyrightText: 2020 Kevin Ottens <kevin.ottens@enioka.com>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7import QtQuick
8import org.kde.kcmutils as KCMUtils
9import org.kde.kcmutils.private as KCMUtilsPrivate
10
11/**
12 * SettingStateBinding automatically impacts the representation
13 * of an item based on the state of a setting. It will disable
14 * the item if the setting is immutable and use a visual indicator
15 * for the state of the setting.
16 *
17 * This is a higher level convenience wrapper for KCMUtils.SettingStateProxy
18 * and KCMUtils.SettingStateIndicator.
19 *
20 * @since 6.0
21 */
22Loader {
23 id: root
24
25 active: typeof kcm !== "undefined" && root.target !== null
26
27 /**
28 * target: Item
29 * The graphical element whose state we want to manage based on a setting
30 * If target is not set, it will try to find the visual parent item
31 */
32 property Item target: root.parent
34 /**
35 * configObject: KCoreConfigSkeleton
36 * The config object which will be monitored for setting state changes
37 */
38 property alias configObject: settingState.configObject
39
40 /**
41 * settingName: string
42 * The name of the setting in the config object to be monitored
43 */
44 property alias settingName: settingState.settingName
45
46 /**
47 * extraEnabledConditions: bool
48 * SettingStateBinding will manage the enabled property of the target
49 * based on the immutability state of the setting it represents. But,
50 * sometimes that enabled state needs to bind to other properties as
51 * well to be computed properly. This extra condition will thus be
52 * combined with the immutability state of the setting to determine
53 * the effective enabled state of the target.
54 */
55 property bool extraEnabledConditions: true
56
57 /**
58 * nonDefaultHighlightVisible: bool
59 * Expose whether the non default highlight is visible.
60 * Allow one to implement highlight with custom items.
61 */
62 readonly property bool nonDefaultHighlightVisible: root.active && root.item.highlight && kcm.defaultsIndicatorsVisible
63
64 Binding {
65 when: root.active
66 target: root.target
67 property: "enabled"
68 value: extraEnabledConditions && !settingState.immutable
69 }
70
71 KCMUtils.SettingStateProxy {
72 id: settingState
73 }
74
75 sourceComponent: KCMUtilsPrivate.SettingHighlighterPrivate {
76 id: helper
77 defaultIndicatorVisible: kcm.defaultsIndicatorsVisible
78 highlight: !settingState.defaulted
79 target: root.target
80 }
81}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:02:19 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.