| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- import QtQuick 2.6
- import QtQuick.Window 2.2
- import QtQuick.Controls 1.5
- import QtQuick.Controls.Styles 1.4
- Item {
- property double address: 0
- signal addressModified()
-
- function setAddrByte(bnum, val)
- {
- if(bnum >= 0 && bnum < 4)
- {
- var shft = bnum * 8;
- var mask = ~(0x000000FF << shft)
- var newv = (address & mask) | (parseInt(val) << shft);
- if(address !== newv)
- {
- address = newv;
- addressModified();
- }
- }
- }
- Rectangle {
- x: 0
- y: 0
- width: 40
- height: 25
- border.width: 1
- border.color: "black"
- TextInput {
- id: idb3
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pointSize: 8
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator{bottom: 0; top: 255;}
- text: (parseInt(address, 10) >> 24) & 0xFF
- KeyNavigation.tab: idb2
- onAccepted: {
- setAddrByte(3, text);
- }
- onActiveFocusChanged: {
- if(!activeFocus)
- setAddrByte(3, text);
- else
- selectAll();
- }
- }
- }
- Rectangle {
- x: 40
- y: 0
- width: 10
- height: 25
- Text {
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignBottom
- font.pointSize: 8
- text: "."
- }
- }
- Rectangle {
- x: 50
- y: 0
- width: 40
- height: 25
- border.width: 1
- border.color: "black"
- TextInput {
- id: idb2
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pointSize: 8
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator{bottom: 0; top: 255;}
- text: (parseInt(address, 10) >> 16) & 0xFF
- KeyNavigation.tab: idb1
- onAccepted: {
- setAddrByte(2, text);
- }
- onActiveFocusChanged: {
- if(!activeFocus)
- setAddrByte(2, text);
- else
- selectAll();
- }
- }
- }
- Rectangle {
- x: 90
- y: 0
- width: 10
- height: 25
- Text {
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignBottom
- font.pointSize: 8
- text: "."
- }
- }
- Rectangle {
- x: 100
- y: 0
- width: 40
- height: 25
- border.width: 1
- border.color: "black"
- TextInput {
- id: idb1
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pointSize: 8
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator{bottom: 0; top: 255;}
- text: (parseInt(address, 10) >> 8) & 0xFF
- KeyNavigation.tab: idb0
- onAccepted: {
- setAddrByte(1, text);
- }
- onActiveFocusChanged: {
- if(!activeFocus)
- setAddrByte(1, text);
- else
- selectAll();
- }
- }
- }
- Rectangle {
- x: 140
- y: 0
- width: 10
- height: 25
- Text {
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignBottom
- font.pointSize: 8
- text: "."
- }
- }
- Rectangle {
- x: 150
- y: 0
- width: 40
- height: 25
- border.width: 1
- border.color: "black"
- TextInput {
- id: idb0
- anchors.fill: parent
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
- font.pointSize: 8
- inputMethodHints: Qt.ImhDigitsOnly
- validator: IntValidator{bottom: 0; top: 255;}
- text: parseInt(address, 10) & 0xFF
- KeyNavigation.tab: idb3
- onAccepted: {
- setAddrByte(0, text);
- }
- onActiveFocusChanged: {
- if(!activeFocus)
- setAddrByte(0, text);
- else
- selectAll();
- }
- }
- }
- }
|