Kstars

KSButtonsSwitchRow.qml
1// SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4import QtQuick 2.6
5import QtQuick.Controls 1.4
6import QtQuick.Window 2.2
7import "../../constants" 1.0
8import QtQuick.Layouts 1.2
9
10Flow {
11 id:buttonsRow
12 property bool checkBox: false
13 property string propName: ""
14 property string deviceName: ""
15 property bool exclusive: false
16 Layout.fillWidth: true
17 spacing: 10 * Num.dp
18
19 Connections {
20 target: ClientManagerLite
21 onNewINDISwitch: {
22 if(buttonsRow.deviceName == deviceName) {
23 if(buttonsRow.propName == propName) {
24 for(var i = 0; i < children.length; ++i) {
25 if(children[i].switchName == switchName) {
26 children[i].checked = isOn
27 }
28 }
29 }
30 }
31 }
32 }
33
34 function addButton(propText, switchName, initChecked, enabled) {
35 var buttonComp = Qt.createComponent("KSButtonSwitch.qml");
36 var button = buttonComp.createObject(this)
37 button.text = propText
38 button.switchName = switchName
39 button.parentRow = this
40 button.checked = initChecked
41 button.enabled = enabled
42 }
43
44 function addCheckBox(propText, switchName, initChecked, enabled) {
45 var checkBoxComp = Qt.createComponent("KSCheckBox.qml");
46 var checkBox = checkBoxComp.createObject(this)
47 checkBox.text = propText
48 checkBox.switchName = switchName
49 checkBox.parentRow = this
50 checkBox.checked = initChecked
51 checkBox.enabled = enabled
52 }
53
54 function sendNewProperty(switchName, button) {
55 ClientManagerLite.sendNewINDISwitch(deviceName,propName,switchName)
56 if(exclusive && button != null) {
57 for(var i = 0; i < children.length; ++i) {
58 if(children[i] !== button) {
59 children[i].checked = false
60 }
61 }
62 }
63 }
64}
65
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:04:46 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.