Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
代码海贼团船长
ZTTY
提交
7d689397
Z
ZTTY
项目概览
代码海贼团船长
/
ZTTY
通知
45
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
ZTTY
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
7d689397
编写于
11月 04, 2022
作者:
代码海贼团船长
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
功能完善
上级
e9721c5e
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
78 addition
and
52 deletion
+78
-52
control/data/zsettings.cpp
control/data/zsettings.cpp
+20
-0
control/data/zsettings.h
control/data/zsettings.h
+8
-0
ui/home.cpp
ui/home.cpp
+27
-7
ui/home.ui
ui/home.ui
+7
-24
ui/singlesend.cpp
ui/singlesend.cpp
+13
-2
ui/singlesend.h
ui/singlesend.h
+2
-1
ui/singlesend.ui
ui/singlesend.ui
+1
-18
未找到文件。
control/data/zsettings.cpp
浏览文件 @
7d689397
...
...
@@ -88,3 +88,23 @@ void ZSettings::setHexFormalSend(bool checked) {
this
->
setValue
(
"SEND_HEX"
,
checked
);
this
->
endGroup
();
}
int
ZSettings
::
getCycleValue
()
const
{
return
this
->
value
(
"SINGLE/CYCLE"
).
toInt
();
}
void
ZSettings
::
setCycleValue
(
int
value
)
{
this
->
beginGroup
(
"SINGLE"
);
this
->
setValue
(
"CYCLE"
,
value
);
this
->
endGroup
();
}
bool
ZSettings
::
getIsSendEnter
()
const
{
return
this
->
value
(
"SINGLE/ENTER"
).
toBool
();
}
void
ZSettings
::
setSendEnter
(
bool
icChecked
)
{
this
->
beginGroup
(
"SINGLE"
);
this
->
setValue
(
"ENTER"
,
icChecked
);
this
->
endGroup
();
}
control/data/zsettings.h
浏览文件 @
7d689397
...
...
@@ -43,6 +43,14 @@ public:
bool
getHexFormalSend
()
const
;
//! 设置发送HEX
void
setHexFormalSend
(
bool
checked
);
//! 获取周期时间
int
getCycleValue
()
const
;
//! 设置周期时间
void
setCycleValue
(
int
value
);
//! 获取是否发送新行
bool
getIsSendEnter
()
const
;
//! 设置是否发送新行
void
setSendEnter
(
bool
icChecked
);
virtual
~
ZSettings
();
};
...
...
ui/home.cpp
浏览文件 @
7d689397
...
...
@@ -5,8 +5,10 @@
// You may need to build the project (run Qt uic code generator) to get "ui_Home.h" resolved
#include <QTime>
#include <QMessageBox>
#include <QFileDialog>
#include <QComboBox>
#include <QMetaEnum>
#include <QtConcurrent/QtConcurrent>
#include "home.h"
#include "ui_Home.h"
...
...
@@ -19,6 +21,10 @@ Home::Home(QWidget *parent) : QWidget(parent), ui(new Ui::Home),mpZControl(ZCont
mpSingleSend
=
new
SingleSend
();
ui
->
tabWidget
->
addTab
(
mpSingleSend
,
tr
(
"单条发送"
));
connect
(
mpSingleSend
,
SIGNAL
(
signalSerialWrite
(
QByteArray
)),
this
,
SLOT
(
slotSerialWrite
(
QByteArray
)));
connect
(
mpSingleSend
,
&
SingleSend
::
signalClearSendInfo
,[
=
](){
this
->
m_SendNumber
=
0
;
ui
->
label_SendNumber
->
setText
(
tr
(
"发送:%0"
).
arg
(
m_SendNumber
));
});
mpMultipleSend
=
new
MultipleSend
();
ui
->
tabWidget
->
addTab
(
mpMultipleSend
,
tr
(
"多条发送"
));
...
...
@@ -54,6 +60,27 @@ Home::Home(QWidget *parent) : QWidget(parent), ui(new Ui::Home),mpZControl(ZCont
connect
(
mpZControl
->
getMpSerialPort
(),
SIGNAL
(
error
(
QSerialPort
::
SerialPortError
)),
this
,
SLOT
(
slotSerialError
(
QSerialPort
::
SerialPortError
)));
connect
(
mpZControl
->
getMpSerialPort
(),
SIGNAL
(
signalSerialPortListChange
(
const
QStringList
&
,
QString
)),
this
,
SLOT
(
slotSerialPortListChange
(
const
QStringList
&
,
QString
)));
connect
(
ui
->
pBn_TtySet
,
SIGNAL
(
clicked
()),
this
,
SLOT
(
slotPBnTtySetClicked
()));
connect
(
ui
->
pBn_Clear
,
&
QPushButton
::
clicked
,[
=
](){
m_RecNumber
=
0
;
ui
->
label_RecNumber
->
setText
(
tr
(
"接收:%0"
).
arg
(
m_RecNumber
));
});
connect
(
ui
->
pBn_Save
,
&
QPushButton
::
clicked
,[
=
](){
QString
fileName
=
QFileDialog
::
getSaveFileName
(
this
,
tr
(
"选择文件夹"
),
"./"
,
"文本(*.txt);;所有文件(*)"
);
if
(
fileName
.
isEmpty
())
{
return
;
}
QtConcurrent
::
run
([
=
](){
QFile
file
(
fileName
);
if
(
!
file
.
open
(
QIODevice
::
WriteOnly
))
{
QMessageBox
::
warning
(
this
,
tr
(
"提示"
),
tr
(
"文件保存失败。"
));
return
;
}
file
.
write
(
ui
->
tEdit_Rec
->
toPlainText
().
toLocal8Bit
());
file
.
close
();
});
});
}
Home
::~
Home
()
{
...
...
@@ -67,13 +94,6 @@ void Home::timerEvent(QTimerEvent *event) {
QObject
::
timerEvent
(
event
);
QString
currentTimeStr
=
QTime
::
currentTime
().
toString
(
"hh:mm:ss"
);
ui
->
label_CurrentTime
->
setText
(
tr
(
"当前时间 %0"
).
arg
(
currentTimeStr
));
// static int updateHz = 0;
// if(!mpZControl->getMpSerialPort()->isOpen()&&updateHz%2==0) {
// ui->cbBox_Tty->clear();
// ui->cbBox_Tty->addItems(mpZControl->getMpSerialPort()->getTtyList());
// }
// updateHz++;
}
void
Home
::
slotPBnTtySetClicked
()
{
...
...
ui/home.ui
浏览文件 @
7d689397
...
...
@@ -41,13 +41,6 @@
<item
row=
"3"
column=
"9"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"cbBox_Stop"
/>
</item>
<item
row=
"9"
column=
"8"
>
<widget
class=
"QCheckBox"
name=
"ckBox_Rts"
>
<property
name=
"text"
>
<string>
RTS
</string>
</property>
</widget>
</item>
<item
row=
"5"
column=
"9"
colspan=
"2"
>
<widget
class=
"QComboBox"
name=
"cbBox_Parity"
/>
</item>
...
...
@@ -65,9 +58,6 @@
</property>
</widget>
</item>
<item
row=
"10"
column=
"9"
>
<widget
class=
"QSpinBox"
name=
"spin_TimeLine"
/>
</item>
<item
row=
"13"
column=
"5"
>
<widget
class=
"Line"
name=
"line_2"
>
<property
name=
"orientation"
>
...
...
@@ -105,13 +95,6 @@
</property>
</widget>
</item>
<item
row=
"9"
column=
"9"
colspan=
"2"
>
<widget
class=
"QCheckBox"
name=
"ckBox_AutoSave"
>
<property
name=
"text"
>
<string>
自动保存
</string>
</property>
</widget>
</item>
<item
row=
"13"
column=
"7"
>
<widget
class=
"Line"
name=
"line_3"
>
<property
name=
"orientation"
>
...
...
@@ -133,13 +116,6 @@
</property>
</widget>
</item>
<item
row=
"10"
column=
"10"
>
<widget
class=
"QLabel"
name=
"label_TimeLine"
>
<property
name=
"text"
>
<string>
ms
</string>
</property>
</widget>
</item>
<item
row=
"13"
column=
"1"
>
<widget
class=
"Line"
name=
"line_4"
>
<property
name=
"orientation"
>
...
...
@@ -255,6 +231,13 @@ p, li { white-space: pre-wrap; }
</property>
</widget>
</item>
<item
row=
"10"
column=
"9"
>
<widget
class=
"QCheckBox"
name=
"ckBox_Rts"
>
<property
name=
"text"
>
<string>
RTS
</string>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
...
...
ui/singlesend.cpp
浏览文件 @
7d689397
...
...
@@ -12,6 +12,14 @@
SingleSend
::
SingleSend
(
QWidget
*
parent
)
:
QWidget
(
parent
),
ui
(
new
Ui
::
SingleSend
),
mpControl
(
ZControl
::
instance
())
{
ui
->
setupUi
(
this
);
connect
(
ui
->
pBn_Clear
,
&
QPushButton
::
clicked
,[
=
](){
ui
->
tEdit_Send
->
clear
();
emit
signalClearSendInfo
();
});
ui
->
spin_Cycle
->
setValue
(
mpControl
->
getMpSettings
()
->
getCycleValue
());
ui
->
ckBox_SendEnter
->
setChecked
(
mpControl
->
getMpSettings
()
->
getIsSendEnter
());
ui
->
ckBox_HexSend
->
setChecked
(
mpControl
->
getMpSettings
()
->
getHexFormalSend
());
m_CurrentArray
=
mpControl
->
getMpSettings
()
->
getTextSend
();
switch
(
ui
->
ckBox_HexSend
->
checkState
()){
...
...
@@ -19,7 +27,7 @@ SingleSend::SingleSend(QWidget *parent) :
ui
->
tEdit_Send
->
setText
(
QString
::
fromLocal8Bit
(
m_CurrentArray
));
break
;
case
Qt
::
Checked
:
ui
->
tEdit_Send
->
setText
(
m_CurrentArray
.
toHex
(
'
%
c
'
));
ui
->
tEdit_Send
->
setText
(
m_CurrentArray
.
toHex
(
' '
));
break
;
}
connect
(
ui
->
tEdit_Send
,
SIGNAL
(
textChanged
()),
this
,
SLOT
(
slotTextSendChanged
()));
...
...
@@ -31,6 +39,8 @@ SingleSend::SingleSend(QWidget *parent) :
SingleSend
::~
SingleSend
()
{
mpControl
->
getMpSettings
()
->
setTextSend
(
m_CurrentArray
);
mpControl
->
getMpSettings
()
->
setHexFormalSend
(
ui
->
ckBox_HexSend
->
isChecked
());
mpControl
->
getMpSettings
()
->
setSendEnter
(
ui
->
ckBox_SendEnter
->
isChecked
());
mpControl
->
getMpSettings
()
->
setCycleValue
(
ui
->
spin_Cycle
->
value
());
delete
ui
;
}
...
...
@@ -42,6 +52,7 @@ void SingleSend::slotpBnSendClicked() {
{
return
;
}
ui
->
ckBox_SendEnter
->
isChecked
()
?
m_CurrentArray
.
append
(
'\n'
)
:
m_CurrentArray
;
emit
signalSerialWrite
(
m_CurrentArray
);
}
}
...
...
@@ -52,7 +63,7 @@ void SingleSend::slotHexSendStateChanged(int state) {
ui
->
tEdit_Send
->
setText
(
QString
::
fromLocal8Bit
(
m_CurrentArray
));
break
;
case
Qt
::
Checked
:
ui
->
tEdit_Send
->
setText
(
m_CurrentArray
.
toHex
(
'
%
c
'
));
ui
->
tEdit_Send
->
setText
(
m_CurrentArray
.
toHex
(
' '
));
break
;
}
}
...
...
ui/singlesend.h
浏览文件 @
7d689397
...
...
@@ -26,6 +26,7 @@ public:
virtual
~
SingleSend
()
override
;
signals:
void
signalSerialWrite
(
QByteArray
array
);
void
signalClearSendInfo
();
private
slots
:
//! 点击发送
void
slotpBnSendClicked
();
...
...
@@ -33,9 +34,9 @@ private slots:
void
slotHexSendStateChanged
(
int
state
);
//! 发送端文本改变
void
slotTextSendChanged
();
//! 循环发送
void
slotTimerSendStateChanged
(
int
state
);
private:
Ui
::
SingleSend
*
ui
;
ZControl
*
mpControl
;
...
...
ui/singlesend.ui
浏览文件 @
7d689397
...
...
@@ -110,22 +110,5 @@
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>
pBn_Clear
</sender>
<signal>
clicked()
</signal>
<receiver>
tEdit_Send
</receiver>
<slot>
clear()
</slot>
<hints>
<hint
type=
"sourcelabel"
>
<x>
911
</x>
<y>
75
</y>
</hint>
<hint
type=
"destinationlabel"
>
<x>
752
</x>
<y>
72
</y>
</hint>
</hints>
</connection>
</connections>
<connections/>
</ui>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录