Kstars

KSButtonsSwitchRow.qml
1 // SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
2 // SPDX-License-Identifier: GPL-2.0-or-later
3 
4 import QtQuick 2.6
5 import QtQuick.Controls 1.4
6 import QtQuick.Window 2.2
7 import "../../constants" 1.0
8 import QtQuick.Layouts 1.2
9 
10 Flow {
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 sendNewSwitch(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-2022 The KDE developers.
Generated on Fri Aug 19 2022 03:57:51 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.