更新网络调试助手
This commit is contained in:
@@ -21,9 +21,19 @@ bool App::HexReceiveTcpServer = false;
|
||||
bool App::AsciiTcpServer = false;
|
||||
bool App::DebugTcpServer = false;
|
||||
bool App::AutoSendTcpServer = false;
|
||||
bool App::SelectAllTcpServer = false;
|
||||
int App::IntervalTcpServer = 1000;
|
||||
QString App::TcpListenIP = "127.0.0.1";
|
||||
int App::TcpListenPort = 6000;
|
||||
bool App::SelectAllTcpServer = false;
|
||||
|
||||
bool App::HexSendUdpClient = false;
|
||||
bool App::HexReceiveUdpClient = false;
|
||||
bool App::AsciiUdpClient = false;
|
||||
bool App::DebugUdpClient = false;
|
||||
bool App::AutoSendUdpClient = false;
|
||||
int App::IntervalUdpClient = 1000;
|
||||
QString App::UdpServerIP = "127.0.0.1";
|
||||
int App::UdpServerPort = 6000;
|
||||
|
||||
bool App::HexSendUdpServer = false;
|
||||
bool App::HexReceiveUdpServer = false;
|
||||
@@ -31,9 +41,9 @@ bool App::AsciiUdpServer = false;
|
||||
bool App::DebugUdpServer = false;
|
||||
bool App::AutoSendUdpServer = false;
|
||||
int App::IntervalUdpServer = 1000;
|
||||
QString App::UdpListenIP = "127.0.0.1";
|
||||
int App::UdpListenPort = 6000;
|
||||
QString App::UdpServerIP = "127.0.0.1";
|
||||
int App::UdpServerPort = 6000;
|
||||
bool App::SelectAllUdpServer = false;
|
||||
|
||||
void App::readConfig()
|
||||
{
|
||||
@@ -63,10 +73,22 @@ void App::readConfig()
|
||||
App::HexReceiveTcpServer = set.value("HexReceiveTcpServer").toBool();
|
||||
App::AsciiTcpServer = set.value("AsciiTcpServer").toBool();
|
||||
App::DebugTcpServer = set.value("DebugTcpServer").toBool();
|
||||
App::AutoSendTcpServer = set.value("AutoSendTcpServer").toBool();
|
||||
App::SelectAllTcpServer = set.value("SelectAllTcpServer").toBool();
|
||||
App::IntervalTcpServer = set.value("IntervalTcpServer").toInt();
|
||||
App::AutoSendTcpServer = set.value("AutoSendTcpServer").toBool();
|
||||
App::IntervalTcpServer = set.value("IntervalTcpServer").toInt();
|
||||
App::TcpListenIP = set.value("TcpListenIP").toString();
|
||||
App::TcpListenPort = set.value("TcpListenPort").toInt();
|
||||
App::SelectAllTcpServer = set.value("SelectAllTcpServer").toBool();
|
||||
set.endGroup();
|
||||
|
||||
set.beginGroup("UdpClientConfig");
|
||||
App::HexSendUdpClient = set.value("HexSendUdpClient").toBool();
|
||||
App::HexReceiveUdpClient = set.value("HexReceiveUdpClient").toBool();
|
||||
App::AsciiUdpClient = set.value("AsciiUdpClient").toBool();
|
||||
App::DebugUdpClient = set.value("DebugUdpClient").toBool();
|
||||
App::AutoSendUdpClient = set.value("AutoSendUdpClient").toBool();
|
||||
App::IntervalUdpClient = set.value("IntervalUdpClient").toInt();
|
||||
App::UdpServerIP = set.value("UdpServerIP").toString();
|
||||
App::UdpServerPort = set.value("UdpServerPort").toInt();
|
||||
set.endGroup();
|
||||
|
||||
set.beginGroup("UdpServerConfig");
|
||||
@@ -75,10 +97,10 @@ void App::readConfig()
|
||||
App::AsciiUdpServer = set.value("AsciiUdpServer").toBool();
|
||||
App::DebugUdpServer = set.value("DebugUdpServer").toBool();
|
||||
App::AutoSendUdpServer = set.value("AutoSendUdpServer").toBool();
|
||||
App::IntervalUdpServer = set.value("IntervalUdpServer").toInt();
|
||||
App::UdpServerIP = set.value("UdpServerIP").toString();
|
||||
App::UdpServerPort = set.value("UdpServerPort").toInt();
|
||||
App::IntervalUdpServer = set.value("IntervalUdpServer").toInt();
|
||||
App::UdpListenIP = set.value("UdpListenIP").toString();
|
||||
App::UdpListenPort = set.value("UdpListenPort").toInt();
|
||||
App::SelectAllUdpServer = set.value("SelectAllUdpServer").toBool();
|
||||
set.endGroup();
|
||||
}
|
||||
|
||||
@@ -104,10 +126,21 @@ void App::writeConfig()
|
||||
set.setValue("HexSendTcpServer", App::HexSendTcpServer);
|
||||
set.setValue("HexReceiveTcpServer", App::HexReceiveTcpServer);
|
||||
set.setValue("DebugTcpServer", App::DebugTcpServer);
|
||||
set.setValue("AutoSendTcpServer", App::AutoSendTcpServer);
|
||||
set.setValue("SelectAllTcpServer", App::SelectAllTcpServer);
|
||||
set.setValue("IntervalTcpServer", App::IntervalTcpServer);
|
||||
set.setValue("AutoSendTcpServer", App::AutoSendTcpServer);
|
||||
set.setValue("IntervalTcpServer", App::IntervalTcpServer);
|
||||
set.setValue("TcpListenIP", App::TcpListenIP);
|
||||
set.setValue("TcpListenPort", App::TcpListenPort);
|
||||
set.setValue("SelectAllTcpServer", App::SelectAllTcpServer);
|
||||
set.endGroup();
|
||||
|
||||
set.beginGroup("UdpClientConfig");
|
||||
set.setValue("HexSendUdpClient", App::HexSendUdpClient);
|
||||
set.setValue("HexReceiveUdpClient", App::HexReceiveUdpClient);
|
||||
set.setValue("DebugUdpClient", App::DebugUdpClient);
|
||||
set.setValue("AutoSendUdpClient", App::AutoSendUdpClient);
|
||||
set.setValue("IntervalUdpClient", App::IntervalUdpClient);
|
||||
set.setValue("UdpServerIP", App::UdpServerIP);
|
||||
set.setValue("UdpServerPort", App::UdpServerPort);
|
||||
set.endGroup();
|
||||
|
||||
set.beginGroup("UdpServerConfig");
|
||||
@@ -115,11 +148,11 @@ void App::writeConfig()
|
||||
set.setValue("HexReceiveUdpServer", App::HexReceiveUdpServer);
|
||||
set.setValue("DebugUdpServer", App::DebugUdpServer);
|
||||
set.setValue("AutoSendUdpServer", App::AutoSendUdpServer);
|
||||
set.setValue("IntervalUdpServer", App::IntervalUdpServer);
|
||||
set.setValue("UdpServerIP", App::UdpServerIP);
|
||||
set.setValue("UdpServerPort", App::UdpServerPort);
|
||||
set.setValue("IntervalUdpServer", App::IntervalUdpServer);
|
||||
set.setValue("UdpListenIP", App::UdpListenIP);
|
||||
set.setValue("UdpListenPort", App::UdpListenPort);
|
||||
set.endGroup();
|
||||
set.setValue("SelectAllUdpServer", App::SelectAllUdpServer);
|
||||
set.endGroup();
|
||||
}
|
||||
|
||||
void App::newConfig()
|
||||
|
||||
@@ -28,9 +28,20 @@ public:
|
||||
static bool AsciiTcpServer; //ASCII模式
|
||||
static bool DebugTcpServer; //启用数据调试
|
||||
static bool AutoSendTcpServer; //自动发送数据
|
||||
static bool SelectAllTcpServer; //选中所有
|
||||
static int IntervalTcpServer; //发送数据间隔
|
||||
static int IntervalTcpServer; //发送数据间隔
|
||||
static QString TcpListenIP; //监听地址
|
||||
static int TcpListenPort; //监听端口
|
||||
static bool SelectAllTcpServer; //选中所有
|
||||
|
||||
//UDP客户端配置参数
|
||||
static bool HexSendUdpClient; //16进制发送
|
||||
static bool HexReceiveUdpClient; //16进制接收
|
||||
static bool AsciiUdpClient; //ASCII模式
|
||||
static bool DebugUdpClient; //启用数据调试
|
||||
static bool AutoSendUdpClient; //自动发送数据
|
||||
static int IntervalUdpClient; //发送数据间隔
|
||||
static QString UdpServerIP; //服务器IP
|
||||
static int UdpServerPort; //服务器端口
|
||||
|
||||
//UDP服务器配置参数
|
||||
static bool HexSendUdpServer; //16进制发送
|
||||
@@ -38,10 +49,10 @@ public:
|
||||
static bool AsciiUdpServer; //ASCII模式
|
||||
static bool DebugUdpServer; //启用数据调试
|
||||
static bool AutoSendUdpServer; //自动发送数据
|
||||
static int IntervalUdpServer; //发送数据间隔
|
||||
static QString UdpServerIP; //服务器IP
|
||||
static int UdpServerPort; //服务器端口
|
||||
static int IntervalUdpServer; //发送数据间隔
|
||||
static QString UdpListenIP; //监听地址
|
||||
static int UdpListenPort; //监听端口
|
||||
static bool SelectAllUdpServer; //选中所有
|
||||
|
||||
//读写配置参数及其他操作
|
||||
static void readConfig(); //读取配置参数
|
||||
|
||||
@@ -17,7 +17,7 @@ QUIWidget::QUIWidget(QWidget *parent) : QDialog(parent)
|
||||
}
|
||||
|
||||
QUIWidget::~QUIWidget()
|
||||
{
|
||||
{
|
||||
}
|
||||
|
||||
bool QUIWidget::eventFilter(QObject *watched, QEvent *event)
|
||||
@@ -369,7 +369,7 @@ void QUIWidget::setIconMain(const QChar &str, quint32 size)
|
||||
void QUIWidget::setPixmap(QUIWidget::Widget widget, const QString &file, const QSize &size)
|
||||
{
|
||||
//按照宽高比自动缩放
|
||||
QPixmap pix = QPixmap(file);
|
||||
QPixmap pix = QPixmap(file);
|
||||
pix = pix.scaled(size, Qt::KeepAspectRatio);
|
||||
if (widget == QUIWidget::Lab_Ico) {
|
||||
this->labIco->setPixmap(pix);
|
||||
@@ -454,12 +454,12 @@ void QUIWidget::setExitAll(bool exitAll)
|
||||
void QUIWidget::setMainWidget(QWidget *mainWidget)
|
||||
{
|
||||
//一个QUI窗体对象只能设置一个主窗体
|
||||
if (this->mainWidget == 0) {
|
||||
if (this->mainWidget == 0) {
|
||||
//将子窗体添加到布局
|
||||
this->widget->layout()->addWidget(mainWidget);
|
||||
//自动设置大小
|
||||
resize(mainWidget->width(), mainWidget->height() + this->widgetTitle->height());
|
||||
this->mainWidget = mainWidget;
|
||||
this->mainWidget = mainWidget;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -917,6 +917,7 @@ void QUITipBox::initControl()
|
||||
sizePolicy1.setVerticalStretch(0);
|
||||
sizePolicy1.setHeightForWidth(labTime->sizePolicy().hasHeightForWidth());
|
||||
labTime->setSizePolicy(sizePolicy1);
|
||||
labTime->setAlignment(Qt::AlignCenter);
|
||||
horizontalLayout2->addWidget(labTime);
|
||||
|
||||
widgetMenu = new QWidget(widgetTitle);
|
||||
@@ -943,6 +944,7 @@ void QUITipBox::initControl()
|
||||
btnMenu_Close->setFocusPolicy(Qt::NoFocus);
|
||||
btnMenu_Close->setFlat(true);
|
||||
|
||||
widgetTitle->setMinimumHeight(TitleMinSize);
|
||||
horizontalLayout->addWidget(btnMenu_Close);
|
||||
horizontalLayout2->addWidget(widgetMenu);
|
||||
verticalLayout->addWidget(widgetTitle);
|
||||
@@ -1039,7 +1041,7 @@ void QUITipBox::setTip(const QString &title, const QString &tip, bool fullScreen
|
||||
this->labInfo->setAlignment(center ? Qt::AlignCenter : Qt::AlignLeft);
|
||||
this->setWindowTitle(this->labTitle->text());
|
||||
|
||||
QRect rect = fullScreen ? qApp->desktop()->availableGeometry() : qApp->desktop()->geometry();
|
||||
QRect rect = fullScreen ? qApp->desktop()->geometry() : qApp->desktop()->availableGeometry();
|
||||
int width = rect.width();
|
||||
int height = rect.height();
|
||||
int x = width - this->width();
|
||||
|
||||
@@ -89,6 +89,7 @@ void TcpServer::incomingConnection(int handle)
|
||||
connect(client, SIGNAL(receiveData(QString, int, QString)), this, SIGNAL(receiveData(QString, int, QString)));
|
||||
|
||||
QString ip = client->peerAddress().toString();
|
||||
ip = ip.replace("::ffff:", "");
|
||||
int port = client->peerPort();
|
||||
client->setIP(ip);
|
||||
client->setPort(port);
|
||||
@@ -113,12 +114,7 @@ void TcpServer::disconnected()
|
||||
|
||||
bool TcpServer::start()
|
||||
{
|
||||
#if (QT_VERSION > QT_VERSION_CHECK(5,0,0))
|
||||
bool ok = listen(QHostAddress::AnyIPv4, App::TcpListenPort);
|
||||
#else
|
||||
bool ok = listen(QHostAddress::Any, App::TcpListenPort);
|
||||
#endif
|
||||
|
||||
bool ok = listen(QHostAddress(App::TcpListenIP), App::TcpListenPort);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user