-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathsetcom.cpp
More file actions
101 lines (88 loc) · 2.21 KB
/
Copy pathsetcom.cpp
File metadata and controls
101 lines (88 loc) · 2.21 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/**
****************************************************************************************
*
* @file setcom.cpp
*
* @brief setting com port
*
* Copyright (C) ViewTool 2018
*
* $Rev: 1.0$
*
* Change History:
* 12/21/18: Initial release, working on capturing BLE data, see captured data in file: 2018.12.21-14.52.34.txt
*
****************************************************************************************
*/
#include "common.h"
#include "app_config.h"
#include "setcom.h"
#include "ui_setcom.h"
#include <QtGui>
#ifdef Q_OS_WIN32
#include <Windows.h>
#endif
QString comStr;
QString baudrateStr;
extern int _com;
extern int _baudrate;
int com_port_setting_done = 1;
setCom::setCom(QWidget *parent) :
QDialog(parent),
ui(new Ui::setCom)
{
ui->setupUi(this);
ui->portStrEdit->hide();
connect(ui->serialcomboBox,SIGNAL(currentTextChanged(QString)),this,SLOT(slotTextChange(QString)));
#ifdef Q_OS_MACOS
ui->portStrEdit->show();
ui->serialcomboBox->hide();
#endif
}
void setCom::set_com(int a, long b)
{
str1 = QString::number(a, 10);
str2 = QString::number(b, 10);
ui->serialcomboBox->setEditable(true);
ui->serialcomboBox->setEditText(str1);
ui->BandcomboBox->setEditable(true);
ui->BandcomboBox->setEditText(str2);
}
void setCom::set_com(QString a, long b) //for mac
{
str1 = a;
str2 = QString::number(b, 10);
ui->portStrEdit->setText(str1);
ui->BandcomboBox->setEditable(true);
ui->BandcomboBox->setEditText(str2);
}
void setCom::on_okpushButton_clicked()
{
QString strComport, strBaudrate;
strComport = QString::number(_com, 10);
strBaudrate = QString::number(_baudrate, 10);
QString fileName = "setcom.ini";
QFile file(fileName);
#ifdef Q_OS_MACOS
comStr = ui->portStrEdit->text();
#else
comStr = ui->serialcomboBox->currentText();
#endif
baudrateStr = ui->BandcomboBox->currentText();
if (file.open(QFile::WriteOnly | QFile::Text))
{
QTextStream out(&file);
out << comStr << '|' << baudrateStr;
}
com_port_setting_done = 0;
accept();
}
setCom::~setCom()
{
delete ui;
}
void setCom::slotTextChange(QString str)
{
if(str == "other")
ui->portStrEdit->show();
}