Kstars

KSINDITextField.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.Layouts 1.2
6import QtQuick.Controls 2.0
7
8import "../../constants" 1.0
9import "../../modules"
10
11
12Flow {
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}
QString xi18n(const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:38:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.