QSerialPortTerminalにKOZOS用XMODEM送信機能追加
Revision | ff29a4733bdb1be644aab51fa6a955ad46ddbd12 (tree) |
---|---|
Zeit | 2012-05-19 00:07:23 |
Autor | arakaki <alucky4416@user...> |
Commiter | arakaki |
ADD: Select OtherPort
@@ -28,15 +28,20 @@ QSerialPortTerminal::QSerialPortTerminal( QWidget* parent ) | ||
28 | 28 | comboBoxPortName->addItem("COM6", QVariant::fromValue(QString("COM6"))); |
29 | 29 | comboBoxPortName->addItem("COM7", QVariant::fromValue(QString("COM7"))); |
30 | 30 | comboBoxPortName->addItem("COM8", QVariant::fromValue(QString("COM8"))); |
31 | + comboBoxPortName->addItem("Other", QVariant::fromValue(QString("Other"))); | |
31 | 32 | comboBoxPortName->setCurrentIndex(0); //COM1 |
33 | + lineEditOtherPort->setText("COM"); | |
32 | 34 | #endif |
33 | 35 | |
34 | 36 | #ifdef _TTY_POSIX_ |
35 | 37 | comboBoxPortName->addItem("ttyS0", QVariant::fromValue(QString("/dev/ttyS0"))); |
36 | 38 | comboBoxPortName->addItem("ttyS1", QVariant::fromValue(QString("/dev/ttyS1"))); |
37 | 39 | comboBoxPortName->addItem("ttyUSB0", QVariant::fromValue(QString("/dev/ttyUSB0"))); |
40 | + comboBoxPortName->addItem("Other", QVariant::fromValue(QString("Other"))); | |
38 | 41 | comboBoxPortName->setCurrentIndex(0); //ttyS0 |
42 | + lineEditOtherPort->setText("/dev/"); | |
39 | 43 | #endif |
44 | + lineEditOtherPort->setEnabled(false); | |
40 | 45 | |
41 | 46 | comboBoxBaudRate->addItem("110", QVariant::fromValue(BAUD110)); |
42 | 47 | comboBoxBaudRate->addItem("300", QVariant::fromValue(BAUD300)); |
@@ -78,6 +83,7 @@ QSerialPortTerminal::QSerialPortTerminal( QWidget* parent ) | ||
78 | 83 | connect(pushButtonSend, SIGNAL(clicked()), this, SLOT(slot_sendPort())); |
79 | 84 | connect(pushButtonSendFile, SIGNAL(clicked()), this, SLOT(slot_sendPortToFile())); |
80 | 85 | connect(pushButtonClear, SIGNAL(clicked()), this, SLOT(slot_clear())); |
86 | + connect(comboBoxPortName, SIGNAL(currentIndexChanged(int)), this, SLOT(slot_chgPort(int))); | |
81 | 87 | |
82 | 88 | /*Codecs list*/ |
83 | 89 | QMap<QString, QTextCodec *> codecMap; |
@@ -144,6 +150,20 @@ void QSerialPortTerminal::updatetextEditReceive() | ||
144 | 150 | |
145 | 151 | void QSerialPortTerminal::slot_openPort() |
146 | 152 | { |
153 | + //Settings parameters | |
154 | + QVariant temp; | |
155 | + | |
156 | + if (comboBoxPortName->currentIndex()+1 == comboBoxPortName->count()) { // select Other? | |
157 | + if (lineEditOtherPort->text().isEmpty()) { | |
158 | + QMessageBox::warning(this, tr("QSerialPortTerminal"), tr("Other Port name is empty.")); | |
159 | + return; | |
160 | + } | |
161 | + serialPort->setPort(lineEditOtherPort->text()); //Port | |
162 | + } else { | |
163 | + temp = comboBoxPortName->itemData(comboBoxPortName->currentIndex()); | |
164 | + serialPort->setPort(temp.value<QString>()); //Port | |
165 | + } | |
166 | + | |
147 | 167 | groupBoxSettings->setEnabled(false); |
148 | 168 | pushButtonOpen->setEnabled(false); |
149 | 169 | pushButtonClose->setEnabled(true); |
@@ -153,12 +173,6 @@ void QSerialPortTerminal::slot_openPort() | ||
153 | 173 | if (serialPort->isOpen()) |
154 | 174 | serialPort->close(); |
155 | 175 | |
156 | - //Settings parameters | |
157 | - QVariant temp; | |
158 | - | |
159 | - temp = comboBoxPortName->itemData(comboBoxPortName->currentIndex()); | |
160 | - serialPort->setPort(temp.value<QString>()); //Port | |
161 | - | |
162 | 176 | temp = comboBoxBaudRate->itemData(comboBoxBaudRate->currentIndex()); |
163 | 177 | serialPort->setBaudRate(temp.value<BaudRateType>()); //BaudRate |
164 | 178 |
@@ -237,6 +251,14 @@ void QSerialPortTerminal::slot_clear() | ||
237 | 251 | { |
238 | 252 | textEditReceive->clear(); |
239 | 253 | } |
254 | +void QSerialPortTerminal::slot_chgPort(int index) | |
255 | +{ | |
256 | + if (index+1 == comboBoxPortName->count()) { // Other? | |
257 | + lineEditOtherPort->setEnabled(true); | |
258 | + } else { | |
259 | + lineEditOtherPort->setEnabled(false); | |
260 | + } | |
261 | +} | |
240 | 262 | |
241 | 263 | void QSerialPortTerminal::slot_sendPortToFile() |
242 | 264 | { |
@@ -31,6 +31,7 @@ private slots: | ||
31 | 31 | void slot_closePort(); |
32 | 32 | void slot_sendPort(); |
33 | 33 | void slot_clear(); |
34 | + void slot_chgPort(int); | |
34 | 35 | void slot_sendPortToFile(); |
35 | 36 | void slot_stopSendPortToFile(); |
36 | 37 |
@@ -6,8 +6,8 @@ | ||
6 | 6 | <rect> |
7 | 7 | <x>0</x> |
8 | 8 | <y>0</y> |
9 | - <width>613</width> | |
10 | - <height>352</height> | |
9 | + <width>670</width> | |
10 | + <height>407</height> | |
11 | 11 | </rect> |
12 | 12 | </property> |
13 | 13 | <property name="windowTitle"> |
@@ -39,7 +39,7 @@ | ||
39 | 39 | <item row="0" column="1"> |
40 | 40 | <widget class="QComboBox" name="comboBoxPortName"/> |
41 | 41 | </item> |
42 | - <item row="1" column="0"> | |
42 | + <item row="2" column="0"> | |
43 | 43 | <widget class="QLabel" name="labelBaudRate"> |
44 | 44 | <property name="sizePolicy"> |
45 | 45 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
@@ -52,10 +52,10 @@ | ||
52 | 52 | </property> |
53 | 53 | </widget> |
54 | 54 | </item> |
55 | - <item row="1" column="1"> | |
55 | + <item row="2" column="1"> | |
56 | 56 | <widget class="QComboBox" name="comboBoxBaudRate"/> |
57 | 57 | </item> |
58 | - <item row="2" column="0"> | |
58 | + <item row="3" column="0"> | |
59 | 59 | <widget class="QLabel" name="labelData"> |
60 | 60 | <property name="sizePolicy"> |
61 | 61 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
@@ -68,10 +68,10 @@ | ||
68 | 68 | </property> |
69 | 69 | </widget> |
70 | 70 | </item> |
71 | - <item row="2" column="1"> | |
71 | + <item row="3" column="1"> | |
72 | 72 | <widget class="QComboBox" name="comboBoxDataBits"/> |
73 | 73 | </item> |
74 | - <item row="3" column="0"> | |
74 | + <item row="4" column="0"> | |
75 | 75 | <widget class="QLabel" name="labelParity"> |
76 | 76 | <property name="sizePolicy"> |
77 | 77 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
@@ -84,10 +84,10 @@ | ||
84 | 84 | </property> |
85 | 85 | </widget> |
86 | 86 | </item> |
87 | - <item row="3" column="1"> | |
87 | + <item row="4" column="1"> | |
88 | 88 | <widget class="QComboBox" name="comboBoxParity"/> |
89 | 89 | </item> |
90 | - <item row="4" column="0"> | |
90 | + <item row="5" column="0"> | |
91 | 91 | <widget class="QLabel" name="labelStop"> |
92 | 92 | <property name="sizePolicy"> |
93 | 93 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
@@ -100,10 +100,10 @@ | ||
100 | 100 | </property> |
101 | 101 | </widget> |
102 | 102 | </item> |
103 | - <item row="4" column="1"> | |
103 | + <item row="5" column="1"> | |
104 | 104 | <widget class="QComboBox" name="comboBoxStopBits"/> |
105 | 105 | </item> |
106 | - <item row="5" column="0"> | |
106 | + <item row="6" column="0"> | |
107 | 107 | <widget class="QLabel" name="labelFlowControl"> |
108 | 108 | <property name="sizePolicy"> |
109 | 109 | <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> |
@@ -116,9 +116,38 @@ | ||
116 | 116 | </property> |
117 | 117 | </widget> |
118 | 118 | </item> |
119 | - <item row="5" column="1"> | |
119 | + <item row="6" column="1"> | |
120 | 120 | <widget class="QComboBox" name="comboBoxFlowControl"/> |
121 | 121 | </item> |
122 | + <item row="1" column="0"> | |
123 | + <widget class="QLabel" name="labelOtherPort"> | |
124 | + <property name="sizePolicy"> | |
125 | + <sizepolicy hsizetype="Fixed" vsizetype="Preferred"> | |
126 | + <horstretch>0</horstretch> | |
127 | + <verstretch>0</verstretch> | |
128 | + </sizepolicy> | |
129 | + </property> | |
130 | + <property name="text"> | |
131 | + <string> Other : </string> | |
132 | + </property> | |
133 | + </widget> | |
134 | + </item> | |
135 | + <item row="1" column="1"> | |
136 | + <widget class="QLineEdit" name="lineEditOtherPort"> | |
137 | + <property name="enabled"> | |
138 | + <bool>false</bool> | |
139 | + </property> | |
140 | + <property name="sizePolicy"> | |
141 | + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> | |
142 | + <horstretch>0</horstretch> | |
143 | + <verstretch>0</verstretch> | |
144 | + </sizepolicy> | |
145 | + </property> | |
146 | + <property name="text"> | |
147 | + <string>/dev/</string> | |
148 | + </property> | |
149 | + </widget> | |
150 | + </item> | |
122 | 151 | </layout> |
123 | 152 | </widget> |
124 | 153 | </item> |
@@ -225,6 +254,11 @@ | ||
225 | 254 | </item> |
226 | 255 | <item> |
227 | 256 | <widget class="QTextEdit" name="textEditReceive"> |
257 | + <property name="font"> | |
258 | + <font> | |
259 | + <pointsize>10</pointsize> | |
260 | + </font> | |
261 | + </property> | |
228 | 262 | <property name="readOnly"> |
229 | 263 | <bool>true</bool> |
230 | 264 | </property> |