-
Notifications
You must be signed in to change notification settings - Fork 1
/
mainwindow.cpp
43 lines (35 loc) · 1.3 KB
/
mainwindow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QSettings>
MainWindow::MainWindow(QWidget* parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
auto pil { QSerialPortInfo::availablePorts() };
std::sort(pil.begin(), pil.end(), [](auto&& pi1, auto&& pi2) {
return pi1.portName().mid(3).toInt() < pi2.portName().mid(3).toInt();
});
for (auto&& portInfo : pil)
ui->comboBox->addItem(portInfo.portName());
connect(&ut, &UT70X::valueChanged, ui->doubleSpinBox, &QDoubleSpinBox::setValue);
connect(&ut, &UT70X::unit, ui->doubleSpinBox, &QDoubleSpinBox::setSuffix);
QSettings settings;
settings.beginGroup("MainWindow");
ui->comboBox->setCurrentIndex(settings.value("comboBox").toInt());
restoreGeometry(settings.value("geometry").toByteArray());
restoreState(settings.value("state").toByteArray());
}
MainWindow::~MainWindow()
{
QSettings settings;
settings.beginGroup("MainWindow");
settings.setValue("comboBox", ui->comboBox->currentIndex());
settings.setValue("geometry", saveGeometry());
settings.setValue("state", saveState());
delete ui;
}
void MainWindow::on_pushButton_clicked(bool /*checked*/)
{
ut.initSerial(ui->comboBox->currentText());
}