8
8
#include " startup.h"
9
9
#include " ui_startup.h"
10
10
#include " ozwcore.h"
11
+ #include " util.h"
11
12
12
13
Startup::Startup (QWidget *parent) :
13
14
QDialog(parent),
@@ -20,13 +21,17 @@ Startup::Startup(QWidget *parent) :
20
21
ui->remoteport ->setMaximumWidth (w+8 );
21
22
QObject::connect (ui->startlocal , &QPushButton::clicked, this , &Startup::localPressed);
22
23
QObject::connect (ui->startremote , &QPushButton::clicked, this , &Startup::remotePressed);
24
+ QString selected;
23
25
foreach (QSerialPortInfo spinfo, QSerialPortInfo::availablePorts ()) {
24
26
#if defined(Q_OS_MACOS)
25
27
if (spinfo.portName ().startsWith (" tty" , Qt::CaseInsensitive))
26
28
continue ;
27
29
#endif
28
- ui->serialport ->addItem (spinfo.systemLocation ());
30
+ ui->serialport ->addItem (spinfo.portName (), spinfo.systemLocation ());
31
+ if (QSettings ().value (" connection/serialport" ) == spinfo.systemLocation ())
32
+ selected = spinfo.portName ();
29
33
}
34
+ ui->serialport ->setCurrentText (selected);
30
35
// ui->enableserver->setChecked(QSettings().value("connection/startserver", true).toBool());
31
36
ui->enableserver ->setChecked (true );
32
37
QUrl server = QUrl::fromUserInput (QSettings ().value (" connection/remotehost" , " ws://localhost:1983" ).toString ());
@@ -42,7 +47,7 @@ Startup::~Startup()
42
47
43
48
void Startup::localPressed () {
44
49
45
- this ->m_serialPort = ui->serialport ->currentText ();
50
+ this ->m_serialPort = ui->serialport ->currentData (). toString ();
46
51
this ->m_remote = false ;
47
52
this ->m_startServer = ui->enableserver ->isChecked ();
48
53
this ->setResult (DialogCode::Accepted);
0 commit comments