@@ -57,14 +57,19 @@ UI_settings_window::UI_settings_window(QWidget *parnt)
57
57
usbRadioButton->setChecked (true );
58
58
}
59
59
60
- lanRadioButton = new QRadioButton (" LAN" , this );
61
- lanRadioButton ->setAutoExclusive (true );
62
- lanRadioButton ->setGeometry (40 , 70 , 110 , 25 );
60
+ lanIPRadioButton = new QRadioButton (" LAN" , this );
61
+ lanIPRadioButton ->setAutoExclusive (true );
62
+ lanIPRadioButton ->setGeometry (40 , 70 , 110 , 25 );
63
63
if (mainwindow->devparms .connectiontype == 1 )
64
64
{
65
- lanRadioButton ->setChecked (true );
65
+ lanIPRadioButton ->setChecked (true );
66
66
}
67
67
68
+ hostnameLabel = new QLabel (this );
69
+ hostnameLabel->setGeometry (40 , 120 , 120 , 35 );
70
+ hostnameLabel->setText (" Hostname\n (overides IP-address)" );
71
+ hostnameLabel->setToolTip (" Leave empty if you want to use the above IP-address" );
72
+
68
73
comboBox1 = new QComboBox (this );
69
74
comboBox1->setGeometry (180 , 20 , 110 , 25 );
70
75
comboBox1->addItem (" /dev/usbtmc0" );
@@ -129,23 +134,34 @@ UI_settings_window::UI_settings_window(QWidget *parnt)
129
134
ipSpinbox4->setValue (100 );
130
135
}
131
136
137
+ if (settings.contains (" connection/hostname" ))
138
+ {
139
+ strncpy (mainwindow->devparms .hostname , settings.value (" connection/hostname" ).toString ().toLatin1 ().data (), 63 );
140
+ }
141
+
142
+ HostLineEdit = new QLineEdit (this );
143
+ HostLineEdit->setGeometry (180 , 120 , 240 , 25 );
144
+ HostLineEdit->setMaxLength (63 );
145
+ HostLineEdit->setText (mainwindow->devparms .hostname );
146
+ HostLineEdit->setToolTip (" Leave empty if you want to use the above IP-address" );
147
+
132
148
refreshLabel = new QLabel (this );
133
- refreshLabel->setGeometry (40 , 120 , 120 , 35 );
134
- refreshLabel->setText (" Screen update\n interval " );
149
+ refreshLabel->setGeometry (40 , 170 , 120 , 35 );
150
+ refreshLabel->setText (" Screen update\n interval " );
135
151
136
152
refreshSpinbox = new QSpinBox (this );
137
- refreshSpinbox->setGeometry (180 , 120 , 100 , 25 );
153
+ refreshSpinbox->setGeometry (180 , 170 , 100 , 25 );
138
154
refreshSpinbox->setSuffix (" mS" );
139
155
refreshSpinbox->setRange (50 , 2000 );
140
156
refreshSpinbox->setSingleStep (10 );
141
157
refreshSpinbox->setValue (mainwindow->devparms .screentimerival );
142
158
143
159
invScrShtLabel = new QLabel (this );
144
- invScrShtLabel->setGeometry (40 , 170 , 120 , 35 );
160
+ invScrShtLabel->setGeometry (40 , 220 , 120 , 35 );
145
161
invScrShtLabel->setText (" Screenshot invert\n colors" );
146
162
147
163
invScrShtCheckbox = new QCheckBox (this );
148
- invScrShtCheckbox->setGeometry (180 , 170 , 120 , 35 );
164
+ invScrShtCheckbox->setGeometry (180 , 220 , 120 , 35 );
149
165
invScrShtCheckbox->setTristate (false );
150
166
if (mainwindow->devparms .screenshot_inv )
151
167
{
@@ -157,11 +173,11 @@ UI_settings_window::UI_settings_window(QWidget *parnt)
157
173
}
158
174
159
175
showfpsLabel = new QLabel (this );
160
- showfpsLabel->setGeometry (40 , 220 , 120 , 35 );
176
+ showfpsLabel->setGeometry (40 , 270 , 120 , 35 );
161
177
showfpsLabel->setText (" Show frames\n per second" );
162
178
163
179
showfpsCheckbox = new QCheckBox (this );
164
- showfpsCheckbox->setGeometry (180 , 220 , 120 , 35 );
180
+ showfpsCheckbox->setGeometry (180 , 270 , 120 , 35 );
165
181
showfpsCheckbox->setTristate (false );
166
182
if (mainwindow->devparms .show_fps )
167
183
{
@@ -173,11 +189,11 @@ UI_settings_window::UI_settings_window(QWidget *parnt)
173
189
}
174
190
175
191
extendvertdivLabel = new QLabel (this );
176
- extendvertdivLabel->setGeometry (40 , 270 , 120 , 35 );
192
+ extendvertdivLabel->setGeometry (40 , 320 , 120 , 35 );
177
193
extendvertdivLabel->setText (" Use extended\n vertical range" );
178
194
179
195
extendvertdivCheckbox = new QCheckBox (this );
180
- extendvertdivCheckbox->setGeometry (180 , 270 , 120 , 35 );
196
+ extendvertdivCheckbox->setGeometry (180 , 320 , 120 , 35 );
181
197
extendvertdivCheckbox->setTristate (false );
182
198
if (mainwindow->devparms .use_extra_vertdivisions )
183
199
{
@@ -210,7 +226,7 @@ UI_settings_window::UI_settings_window(QWidget *parnt)
210
226
if (mainwindow->devparms .connected )
211
227
{
212
228
usbRadioButton->setEnabled (false );
213
- lanRadioButton ->setEnabled (false );
229
+ lanIPRadioButton ->setEnabled (false );
214
230
ipSpinbox1->setEnabled (false );
215
231
ipSpinbox2->setEnabled (false );
216
232
ipSpinbox3->setEnabled (false );
@@ -223,11 +239,12 @@ UI_settings_window::UI_settings_window(QWidget *parnt)
223
239
QObject::connect (applyButton, SIGNAL (clicked ()), this , SLOT (applyButtonClicked ()));
224
240
}
225
241
226
- QObject::connect (cancelButton, SIGNAL (clicked ()), this , SLOT (close ()));
227
- QObject::connect (refreshSpinbox, SIGNAL (valueChanged (int )), this , SLOT (refreshSpinboxChanged (int )));
228
- QObject::connect (invScrShtCheckbox, SIGNAL (stateChanged (int )), this , SLOT (invScrShtCheckboxChanged (int )));
229
- QObject::connect (showfpsCheckbox, SIGNAL (stateChanged (int )), this , SLOT (showfpsCheckboxChanged (int )));
230
- QObject::connect (extendvertdivCheckbox, SIGNAL (stateChanged (int )), this , SLOT (extendvertdivCheckboxChanged (int )));
242
+ QObject::connect (cancelButton, SIGNAL (clicked ()), this , SLOT (close ()));
243
+ QObject::connect (refreshSpinbox, SIGNAL (valueChanged (int )), this , SLOT (refreshSpinboxChanged (int )));
244
+ QObject::connect (invScrShtCheckbox, SIGNAL (stateChanged (int )), this , SLOT (invScrShtCheckboxChanged (int )));
245
+ QObject::connect (showfpsCheckbox, SIGNAL (stateChanged (int )), this , SLOT (showfpsCheckboxChanged (int )));
246
+ QObject::connect (extendvertdivCheckbox, SIGNAL (stateChanged (int )), this , SLOT (extendvertdivCheckboxChanged (int )));
247
+ QObject::connect (HostLineEdit, SIGNAL (textEdited (QString)), this , SLOT (hostnamechanged (QString)));
231
248
232
249
exec ();
233
250
}
@@ -268,6 +285,10 @@ void UI_settings_window::applyButtonClicked()
268
285
269
286
settings.setValue (" connection/ip" , dev_str);
270
287
288
+ strncpy (mainwindow->devparms .hostname , HostLineEdit->text ().toLatin1 ().data (), 64 );
289
+
290
+ settings.setValue (" connection/hostname" , mainwindow->devparms .hostname );
291
+
271
292
if (invScrShtCheckbox->checkState () == Qt::Checked)
272
293
{
273
294
mainwindow->devparms .screenshot_inv = 1 ;
@@ -388,6 +409,55 @@ void UI_settings_window::extendvertdivCheckboxChanged(int state)
388
409
}
389
410
390
411
412
+ void UI_settings_window::hostnamechanged (QString qstr)
413
+ {
414
+ int i, j, len, trunc=0 ;
415
+
416
+ char str[128 ];
417
+
418
+ strncpy (str, qstr.toLatin1 ().data (), 63 );
419
+
420
+ str[63 ] = 0 ;
421
+
422
+ len = strlen (str);
423
+
424
+ for (i=0 ; i<len; i++)
425
+ {
426
+ if (((str[i] < ' 0' ) && (str[i] != ' -' ) && (str[i] != ' .' )) ||
427
+ ((str[i] > ' 9' ) && (str[i] < ' A' )) ||
428
+ ((str[i] > ' Z' ) && (str[i] < ' a' )) ||
429
+ (str[i] > ' z' ))
430
+ {
431
+ for (j=i; j<len; j++)
432
+ {
433
+ str[j] = str[j+1 ];
434
+ }
435
+
436
+ len--;
437
+
438
+ i--;
439
+
440
+ trunc = 1 ;
441
+ }
442
+ }
443
+
444
+ for (i=0 ; i<len; i++)
445
+ {
446
+ if ((str[i] >= ' A' ) && (str[i] <= ' Z' ))
447
+ {
448
+ str[i] += 32 ;
449
+
450
+ trunc = 1 ;
451
+ }
452
+ }
453
+
454
+ if (trunc)
455
+ {
456
+ HostLineEdit->setText (str);
457
+ }
458
+ }
459
+
460
+
391
461
392
462
393
463
0 commit comments