Kstars

KSINDITextField.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.Layouts 1.2
6 import QtQuick.Controls 2.0
7 
8 import "../../constants" 1.0
9 import "../../modules"
10 
11 
12 Flow {
13  id: textRow
14  spacing: 5 * Num.dp
15  anchors {
16  left: parent.left
17  right: parent.right
18  }
19 
20  property Item textField: field
21  property bool isNumber: true // false - text, true - number
22 
23  property string deviceName
24  property string propName
25  property string fieldName
26 
27  KSTextField {
28  id: field
29  }
30 
31  Button {
32  text: xi18n("Set")
33  onClicked: {
34  if(isNumber) {
35  ClientManagerLite.sendNewINDINumber(deviceName, propName, fieldName, field.text)
36  } else {
37  ClientManagerLite.sendNewINDIText(deviceName, propName, fieldName, field.text)
38  }
39  Qt.inputMethod.hide()
40  }
41  }
42 
43  Connections {
44  target: ClientManagerLite
45  onNewINDINumber: {
46  if(isNumber) {
47  if(textRow.deviceName == deviceName) {
48  if(textRow.propName == propName) {
49  if(textRow.fieldName == numberName) {
50  field.text = value
51  }
52  }
53  }
54  }
55  }
56  onNewINDIText: {
57  if(!isNumber) {
58  if(textRow.deviceName == deviceName) {
59  if(textRow.propName == propName) {
60  if(textRow.fieldName == fieldName) {
61  field.text = text
62  }
63  }
64  }
65  }
66  }
67  }
68 }
QTextStream & right(QTextStream &stream)
QTextStream & left(QTextStream &stream)
QString xi18n(const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &s)
QTextStream & right(QTextStream &s)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Aug 13 2022 04:01:54 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.