parent
e4cb943bf5
commit
02b18e8133
Binary file not shown.
@ -0,0 +1,58 @@
|
||||
#include "QTCPDebugUI.h"
|
||||
#include "lpGlobalData.h"
|
||||
#include <QDateTime>
|
||||
QTCPDebugUI::QTCPDebugUI(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
{
|
||||
ui.setupUi(this);
|
||||
connect(ui.checkBox_Recv, SIGNAL(stateChanged(int)), this, SLOT(onStateChange(int)));
|
||||
connect(ui.checkBox_Send, SIGNAL(stateChanged(int)), this, SLOT(onStateChange(int)));
|
||||
}
|
||||
|
||||
QTCPDebugUI::~QTCPDebugUI()
|
||||
{
|
||||
}
|
||||
|
||||
void QTCPDebugUI::appendRecvData(QByteArray data)
|
||||
{
|
||||
QString msg = QString("recv %1->%2").arg(QDateTime::currentDateTime().toString("hh:mm:ss")).arg(QString(data));
|
||||
ui.plainTextEdit->appendPlainText(msg);
|
||||
}
|
||||
|
||||
void QTCPDebugUI::appendSendData(QByteArray data)
|
||||
{
|
||||
QString msg = QString("send %1->%2").arg(QDateTime::currentDateTime().toString("hh:mm:ss")).arg(QString(data));
|
||||
ui.plainTextEdit->appendPlainText(msg);
|
||||
}
|
||||
|
||||
void QTCPDebugUI::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
lpGlobalData::instance()->bShowRecv = false;
|
||||
lpGlobalData::instance()->bShowSend = false;
|
||||
}
|
||||
|
||||
void QTCPDebugUI::showEvent(QShowEvent *event)
|
||||
{
|
||||
ui.plainTextEdit->clear();
|
||||
ui.checkBox_Recv->setChecked(false);
|
||||
ui.checkBox_Send->setChecked(false);
|
||||
}
|
||||
|
||||
Q_SLOT void QTCPDebugUI::onStateChange(int state)
|
||||
{
|
||||
QString strObj = sender()->objectName();
|
||||
if (strObj == "checkBox_Recv")
|
||||
{
|
||||
if (state > 0)
|
||||
lpGlobalData::instance()->bShowRecv = true;
|
||||
else
|
||||
lpGlobalData::instance()->bShowRecv = false;
|
||||
}
|
||||
else if (strObj == "checkBox_Send")
|
||||
{
|
||||
if (state > 0)
|
||||
lpGlobalData::instance()->bShowSend = true;
|
||||
else
|
||||
lpGlobalData::instance()->bShowSend = false;
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,26 @@
|
||||
#ifndef _QTCPDEBUG_H_
|
||||
#define _QTCPDEBUG_H_
|
||||
|
||||
#include <QWidget>
|
||||
#include "ui_QTCPDebugUI.h"
|
||||
|
||||
class QTCPDebugUI : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
QTCPDebugUI(QWidget *parent = Q_NULLPTR);
|
||||
~QTCPDebugUI();
|
||||
|
||||
void appendRecvData(QByteArray data);
|
||||
void appendSendData(QByteArray data);
|
||||
protected:
|
||||
virtual void closeEvent(QCloseEvent *event);
|
||||
virtual void showEvent(QShowEvent *event);
|
||||
|
||||
Q_SLOT void onStateChange(int state);
|
||||
private:
|
||||
Ui::QTCPDebugUI ui;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>QTCPDebugUI</class>
|
||||
<widget class="QWidget" name="QTCPDebugUI">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>575</width>
|
||||
<height>407</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>QTCPDebugUI</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_Recv">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>显示接收数据</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QCheckBox" name="checkBox_Send">
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>12</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>显示发送数据</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="0" column="0" rowspan="3">
|
||||
<widget class="QPlainTextEdit" name="plainTextEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@ -0,0 +1,9 @@
|
||||
#include "lpGlobalData.h"
|
||||
|
||||
lpGlobalData::lpGlobalData()
|
||||
{
|
||||
}
|
||||
|
||||
lpGlobalData::~lpGlobalData()
|
||||
{
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
#ifndef _LPGLOBALDATA_H_
|
||||
#define _LPGLOBALDATA_H_
|
||||
|
||||
#include <QObject>
|
||||
#include "lp_singleton_base.h"
|
||||
class lpGlobalData : public lp_singleton_base<lpGlobalData>
|
||||
{
|
||||
public:
|
||||
lpGlobalData();
|
||||
~lpGlobalData();
|
||||
bool bShowRecv{ false };
|
||||
bool bShowSend{ false };
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Binary file not shown.
Loading…
Reference in New Issue