Skip to content

Commit e403f7c

Browse files
committed
made pin code simpler
1 parent e23055b commit e403f7c

File tree

1 file changed

+20
-62
lines changed

1 file changed

+20
-62
lines changed

qml/Pin.qml

Lines changed: 20 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ Item {
4545
property alias numberVisible: numberText.visible // visibility of the number
4646
property string description: "Test" // descriptive text for the pin
4747
property bool editable: getEditable() // editability of the pin
48-
property var textInput: leftTextInput.visible? leftTextInput: rightTextInput // currently active text input
48+
property alias textInput: descriptionTextInput // currently active text input
4949
property string infoText: getInfoText() // info text for the pin
5050
property int configMode: 0 // active config mode: 0=function, 1=gpio dir, 2=gpio value
5151
property double uneditableOpacitiy: (configMode == 0)?(displayUneditablePins?1.0:0.1):0.2
@@ -145,11 +145,11 @@ Item {
145145
Text {
146146
x: main.width/2
147147
y: main.width/2
148-
font.pixelSize: rightInfoText.font.pixelSize
148+
font.pixelSize: 0
149149
text: "<b>P" + portNumber + "_" + pinNumber + "</b><br>" +
150150
infoText + " (" + (pinmuxActive?type:defaultFunction) + ")" +
151151
((kernelPinNumber != 0)?"<br>" + qsTr("Kernel Pin: ") + kernelPinNumber:"") +
152-
((pruPinNumber != 0)?"<br>" + qsTr("PRU Pin; ") + pruPinNumber:"")
152+
((pruPinNumber != 0)?"<br>" + qsTr("PRU Pin: ") + pruPinNumber:"")
153153
}
154154
}
155155

@@ -259,59 +259,16 @@ Item {
259259
}
260260

261261
TextInput {
262-
id: rightTextInput
262+
id: descriptionTextInput
263263
anchors.verticalCenter: parent.verticalCenter
264-
anchors.left: parent.right
265-
anchors.leftMargin: parent.width * 0.8
264+
anchors.left: rightSide ? parent.right : undefined
265+
anchors.leftMargin: parent.width * 0.8
266+
anchors.right: rightSide ? undefined : parent.left
267+
anchors.rightMargin: anchors.leftMargin
266268
width: parent.width*8
267-
horizontalAlignment: TextInput.AlignLeft
269+
horizontalAlignment: rightSide ? TextInput.AlignLeft : TextInput.AlignRight
268270
font.pixelSize: parent.width*0.9
269-
visible: !previewActive && main.rightSide
270-
readOnly: !main.editable
271-
selectByMouse: true
272-
273-
MouseArea {
274-
anchors.fill: parent
275-
cursorShape: main.editable? Qt.IBeamCursor: Qt.ArrowCursor
276-
enabled: false
277-
}
278-
279-
Binding { target: main; property: "description"; value: rightTextInput.text }
280-
Binding { target: rightTextInput; property: "text"; value: main.description }
281-
282-
Keys.onPressed: {
283-
if ((event.key === Qt.Key_Menu) || (event.key === Qt.Key_Return)) {
284-
var target
285-
switch (main.configMode) {
286-
case 0: target = comboBox; break;
287-
case 1: target = comboBox2; break;
288-
case 2: target = comboBox3; break;
289-
}
290-
target.forceActiveFocus()
291-
}
292-
}
293-
}
294-
295-
Text {
296-
id: rightInfoText
297-
anchors.verticalCenter: rightTextInput.verticalCenter
298-
anchors.left: rightTextInput.left
299-
width: rightTextInput.width
300-
horizontalAlignment: rightTextInput.horizontalAlignment
301-
font: rightTextInput.font
302-
visible: previewActive && main.rightSide
303-
text: main.infoText
304-
}
305-
306-
TextInput {
307-
id: leftTextInput
308-
anchors.verticalCenter: parent.verticalCenter
309-
anchors.right: parent.left
310-
anchors.rightMargin: rightTextInput.anchors.leftMargin
311-
width: rightTextInput.width
312-
horizontalAlignment: TextInput.AlignRight
313-
font.pixelSize: rightTextInput.font.pixelSize
314-
visible: !previewActive && !main.rightSide
271+
visible: !previewActive
315272
readOnly: !main.editable
316273
selectByMouse: true
317274

@@ -321,8 +278,8 @@ Item {
321278
enabled: false
322279
}
323280

324-
Binding { target: main; property: "description"; value: leftTextInput.text}
325-
Binding { target: leftTextInput; property: "text"; value: main.description}
281+
Binding { target: main; property: "description"; value: descriptionTextInput.text }
282+
Binding { target: descriptionTextInput; property: "text"; value: main.description }
326283

327284
Keys.onPressed: {
328285
if ((event.key === Qt.Key_Menu) || (event.key === Qt.Key_Return)) {
@@ -338,13 +295,14 @@ Item {
338295
}
339296

340297
Text {
341-
id: leftInfoText
342-
anchors.verticalCenter: leftTextInput.verticalCenter
343-
anchors.right: leftTextInput.right
344-
width: leftTextInput.width
345-
horizontalAlignment: leftTextInput.horizontalAlignment
346-
font: leftTextInput.font
347-
visible: previewActive && !main.rightSide
298+
id: descriptionInfoText
299+
anchors.verticalCenter: descriptionTextInput.verticalCenter
300+
anchors.left: rightSide ? descriptionTextInput.left : undefined
301+
anchors.right: rightSide ? undefined : descriptionTextInput.right
302+
width: descriptionTextInput.width
303+
horizontalAlignment: descriptionTextInput.horizontalAlignment
304+
font: descriptionTextInput.font
305+
visible: previewActive
348306
text: main.infoText
349307
}
350308

0 commit comments

Comments
 (0)