fix: 合并main,解决冲突

pull/6/head
cbwu 7 months ago
commit 7827e364c7

File diff suppressed because it is too large Load Diff

@ -2,30 +2,21 @@
#include "ui_gddcSet.h"
#include <QSettings>
//#pragma execution_character_set(“utf-8”)
// #pragma execution_character_set(“utf-8”)
GDDCSet::GDDCSet(QWidget *parent)
: QWidget(parent)
, ui(new Ui::GDDCSet)
{
GDDCSet::GDDCSet(QWidget *parent) : QWidget(parent), ui(new Ui::GDDCSet) {
ui->setupUi(this);
initWindow();
initParam();
initUDPSocket();
}
GDDCSet::~GDDCSet()
{
delete ui;
}
void GDDCSet::initWindow()
{
GDDCSet::~GDDCSet() { delete ui; }
void GDDCSet::initWindow() {
this->setWindowTitle("通信设置");
setAttribute(Qt::WA_QuitOnClose,false);
setAttribute(Qt::WA_QuitOnClose, false);
//交付时隐藏部分未开发接口
// 交付时隐藏部分未开发接口
ui->label_5->hide();
ui->label_6->hide();
ui->lineEdit_playURL2->hide();
@ -33,22 +24,19 @@ void GDDCSet::initWindow()
ui->groupBox_2->hide();
ui->radioButton_NetCtrlTCP->hide();
}
void GDDCSet::initUDPSocket()
{
}
void GDDCSet::initParam()
{
//m_myPairNetwork("",0,"",0);
void GDDCSet::initUDPSocket() {}
void GDDCSet::initParam() {
// m_myPairNetwork("",0,"",0);
// QSettings setting("./sentence.ini",QSettings::IniFormat);
// setting.setIniCodec(QTextCodec::codecForName("UTF-8")); //重点
ui->comboBox_streamType->addItem("RTSP");
//ui->comboBox_streamType->addItem("UDP Raw");
//ui->comboBox_streamType->addItem("UDP 422");
//ui->comboBox_streamType->addItem("UDP TS");
ui->comboBox_playURL1->addItem("rtsp://192.168.1.160:554/live/track0");
ui->comboBox_playURL1->addItem("rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid");
// ui->comboBox_streamType->addItem("UDP Raw");
// ui->comboBox_streamType->addItem("UDP 422");
// ui->comboBox_streamType->addItem("UDP TS");
ui->comboBox_playURL1->addItem("rtsp://192.168.55.65:554/live/track0");
ui->comboBox_playURL1->addItem(
"rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid");
ui->comboBox_playURL1->setEditable(true);
/*"rtsp://192.168.1.160:554/live/track0"*/
@ -57,172 +45,154 @@ void GDDCSet::initParam()
ui->radioButton_NetCtrlUDP->setChecked(true);
ui->radioButton_NetCtrlTCP->setChecked(false);
//读取本机网络设备
QString urlFile = QCoreApplication::applicationDirPath()+"/config.ini";
QString name = QDir::currentPath()+"./config.ini";
// 读取本机网络设备
QString urlFile = QCoreApplication::applicationDirPath() + "/config.ini";
QString name = QDir::currentPath() + "./config.ini";
m_configIniPath = name.toLatin1();
char* strSysIniName = m_configIniPath.data();//系统配置文件路径
char *strSysIniName = m_configIniPath.data(); // 系统配置文件路径
char inBuf[100];
::GetPrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", "-1", inBuf, 100, strSysIniName);
::GetPrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", "-1",
inBuf, 100, strSysIniName);
m_playURL2 = QString::fromUtf8(inBuf);
ui->lineEdit_playURL2->setText(m_playURL2);
::GetPrivateProfileStringA("光电吊舱-推流", "推流URL", "-1", inBuf, 100, strSysIniName);
::GetPrivateProfileStringA("光电吊舱-推流", "推流URL", "-1", inBuf, 100,
strSysIniName);
m_pushURL = QString::fromUtf8(inBuf);
ui->lineEdit_pushURL->setText(m_pushURL);
::GetPrivateProfileStringA("光电吊舱-网络控制", "远端IP", "-1", inBuf, 100, strSysIniName);
::GetPrivateProfileStringA("光电吊舱-网络控制", "远端IP", "-1", inBuf, 100,
strSysIniName);
m_myPairNetwork.setRemoteIP(QString::fromUtf8(inBuf));
::GetPrivateProfileStringA("光电吊舱-网络控制", "远端Port", "-1", inBuf, 100, strSysIniName);
::GetPrivateProfileStringA("光电吊舱-网络控制", "远端Port", "-1", inBuf, 100,
strSysIniName);
m_myPairNetwork.setRemotePort(atoi(inBuf));
::GetPrivateProfileStringA("光电吊舱-网络控制", "本地IP", "-1", inBuf, 100, strSysIniName);
::GetPrivateProfileStringA("光电吊舱-网络控制", "本地IP", "-1", inBuf, 100,
strSysIniName);
m_myPairNetwork.setLocalIP(QString::fromUtf8(inBuf));
::GetPrivateProfileStringA("光电吊舱-网络控制", "本地Port", "-1", inBuf, 100, strSysIniName);
::GetPrivateProfileStringA("光电吊舱-网络控制", "本地Port", "-1", inBuf, 100,
strSysIniName);
m_myPairNetwork.setLocalPort(atoi(inBuf));
ui->lineEdit_NetCtrlRemoteIp->setText(m_myPairNetwork.getRemoteIP());
ui->lineEdit_NetCtrlRemotePort->setText(QString::number(m_myPairNetwork.getRemotePort()));
ui->lineEdit_NetCtrlRemotePort->setText(
QString::number(m_myPairNetwork.getRemotePort()));
ui->lineEdit_NetCtrlLocalIp->setText(m_myPairNetwork.getLocalIP());
ui->lineEdit_NetCtrlLocalPort->setText(QString::number(m_myPairNetwork.getLocalPort()));
ui->lineEdit_NetCtrlLocalPort->setText(
QString::number(m_myPairNetwork.getLocalPort()));
}
//视频连接-显示窗口1-连接
void GDDCSet::on_pushButton_ConnectURL1_clicked()
{
// 视频连接-显示窗口1-连接
void GDDCSet::on_pushButton_ConnectURL1_clicked() {
saveDataToLocalIni();
if(ui->pushButton_ConnectURL1->text()=="连接")
{
if (ui->pushButton_ConnectURL1->text() == "连接") {
emit SignalStartConnect(1);
ui->pushButton_ConnectURL1->setText("断开");
}
else
{
} else {
emit SignalStopConnect(1);
ui->pushButton_ConnectURL1->setText("连接");
}
}
//视频连接-显示窗口2-连接
void GDDCSet::on_pushButton_ConnectURL2_clicked()
{
// 视频连接-显示窗口2-连接
void GDDCSet::on_pushButton_ConnectURL2_clicked() {
saveDataToLocalIni();
if(ui->pushButton_ConnectURL2->text()=="连接")
{
if (ui->pushButton_ConnectURL2->text() == "连接") {
emit SignalStartConnect(2);
ui->pushButton_ConnectURL2->setText("断开");
}
else
{
} else {
emit SignalStopConnect(2);
ui->pushButton_ConnectURL2->setText("连接");
}
}
//串口控制-刷新
void GDDCSet::on_pushButton_serialControlRefalsh_clicked()
{
// 串口控制-刷新
void GDDCSet::on_pushButton_serialControlRefalsh_clicked() {
saveDataToLocalIni();
}
//串口控制-连接
void GDDCSet::on_pushButton_serialControlConnect_clicked()
{
// 串口控制-连接
void GDDCSet::on_pushButton_serialControlConnect_clicked() {
saveDataToLocalIni();
if(ui->pushButton_serialControlConnect->text()=="连接")
{
if (ui->pushButton_serialControlConnect->text() == "连接") {
emit SignalStartConnect(3);
ui->pushButton_serialControlConnect->setText("断开");
}
else
{
} else {
emit SignalStopConnect(3);
ui->pushButton_serialControlConnect->setText("连接");
}
}
//网络控制-连接
void GDDCSet::on_pushButton_NetCtrlConnect_clicked()
{
// 网络控制-连接
void GDDCSet::on_pushButton_NetCtrlConnect_clicked() {
saveDataToLocalIni();
if(ui->pushButton_NetCtrlConnect->text()=="连接")
{
if(ui->radioButton_NetCtrlUDP->isChecked())
{
if (ui->pushButton_NetCtrlConnect->text() == "连接") {
if (ui->radioButton_NetCtrlUDP->isChecked()) {
emit SignalStartConnect(4);
}
else
{
} else {
emit SignalStartConnect(5);
}
ui->pushButton_NetCtrlConnect->setText("断开");
}
else
{
} else {
emit SignalStopConnect(4);
emit SignalStopConnect(5);
ui->pushButton_NetCtrlConnect->setText("连接");
}
}
//推流
void GDDCSet::on_pushButton_pushURL_clicked()
{
// 推流
void GDDCSet::on_pushButton_pushURL_clicked() {
saveDataToLocalIni();
if(ui->pushButton_pushURL->text()=="推送")
{
if (ui->pushButton_pushURL->text() == "推送") {
emit SignalStartConnect(6);
ui->pushButton_pushURL->setText("停止推送");
}
else
{
} else {
emit SignalStopConnect(6);
ui->pushButton_pushURL->setText("推送");
}
}
//保存数据至本地ini文件
void GDDCSet::saveDataToLocalIni()
{
char* strSysIniName = m_configIniPath.data();//系统配置文件路径
char* inBuf;
// 保存数据至本地ini文件
void GDDCSet::saveDataToLocalIni() {
char *strSysIniName = m_configIniPath.data(); // 系统配置文件路径
char *inBuf;
QByteArray ba;
m_myPairNetwork.setLocalIP(ui->lineEdit_NetCtrlLocalIp->text());
ba = m_myPairNetwork.getLocalIP().toLocal8Bit();
inBuf = ba.data();//toLatin1,toUtf8
::WritePrivateProfileStringA("光电吊舱-网络控制", "本地IP", inBuf, strSysIniName);
inBuf = ba.data(); // toLatin1,toUtf8
::WritePrivateProfileStringA("光电吊舱-网络控制", "本地IP", inBuf,
strSysIniName);
m_myPairNetwork.setLocalPort(ui->lineEdit_NetCtrlLocalPort->text().toInt());
_itoa_s(m_myPairNetwork.getLocalPort(),inBuf,10,10);//要转换的数字,存放转换结果的字符串,存放结果的字符数组长度,转化的进制数2表示2进制10表示10进制
::WritePrivateProfileStringA("光电吊舱-网络控制", "本地Port", inBuf, strSysIniName);
_itoa_s(
m_myPairNetwork.getLocalPort(), inBuf, 10,
10); // 要转换的数字,存放转换结果的字符串,存放结果的字符数组长度,转化的进制数2表示2进制10表示10进制
::WritePrivateProfileStringA("光电吊舱-网络控制", "本地Port", inBuf,
strSysIniName);
m_myPairNetwork.setRemoteIP(ui->lineEdit_NetCtrlRemoteIp->text());
ba = m_myPairNetwork.getRemoteIP().toLocal8Bit();
inBuf = ba.data();
::WritePrivateProfileStringA("光电吊舱-网络控制", "远端IP", inBuf, strSysIniName);
::WritePrivateProfileStringA("光电吊舱-网络控制", "远端IP", inBuf,
strSysIniName);
m_myPairNetwork.setRemotePort(ui->lineEdit_NetCtrlRemotePort->text().toInt());
_itoa_s(m_myPairNetwork.getRemotePort(),inBuf,10,10);
::WritePrivateProfileStringA("光电吊舱-网络控制", "远端Port", inBuf, strSysIniName);
_itoa_s(m_myPairNetwork.getRemotePort(), inBuf, 10, 10);
::WritePrivateProfileStringA("光电吊舱-网络控制", "远端Port", inBuf,
strSysIniName);
m_playURL2 = ui->lineEdit_playURL2->text();
ba = m_playURL2.toLocal8Bit();
inBuf = ba.data();
::WritePrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", inBuf, strSysIniName);
::WritePrivateProfileStringA("光电吊舱-视频连接-显示窗口2", "播放URL", inBuf,
strSysIniName);
m_pushURL = ui->lineEdit_pushURL->text();
ba = m_pushURL.toLocal8Bit();
inBuf = ba.data();
::WritePrivateProfileStringA("光电吊舱-推流", "推流URL", inBuf, strSysIniName);
::WritePrivateProfileStringA("光电吊舱-推流", "推流URL", inBuf,
strSysIniName);
m_playURL1 = ui->comboBox_playURL1->currentText();
}

@ -1,14 +1,13 @@
#include "gddcdlg.h"
#include "ui_gddcdlg.h"
#include <QDateTime>
#include <QDir>
#include <QNetworkInterface>
#include <QTabBar>
#include <QTabWidget>
#include <windows.h>
#include <QDir>
#include <iostream>
#include <windows.h>
#include <wtsapi32.h>
#include <iostream>
#pragma comment(lib, "Wtsapi32.lib")
using namespace std;
@ -17,14 +16,15 @@ DWORD GetmPid(LPCWSTR ProcessName) {
DWORD Count;
DWORD i = 0;
BOOL result =WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &wts, &Count);
if(result == 0){
BOOL result =
WTSEnumerateProcessesW(WTS_CURRENT_SERVER_HANDLE, 0, 1, &wts, &Count);
if (result == 0) {
cout << "WTSEnumerateProcessesW Error" << endl;
return 1;
}
cout << "WTSEnumerateProcessesW Success" << endl;
for (i;i < Count; i++) {
for (i; i < Count; i++) {
if (lstrcmpiW(wts[i].pProcessName, ProcessName) == 0) {
DWORD pid = wts[i].ProcessId;
cout << "find pid:" << pid << endl;
@ -37,29 +37,20 @@ DWORD GetmPid(LPCWSTR ProcessName) {
WTSFreeMemory(wts);
}
#define CONFIG_PATH "config.ini"
#define CMDPAGEHIGHT 210
#define STATEPAGEWIDTH 250
GDDCdlg::GDDCdlg(QWidget *parent)
: QWidget(parent)
, ui(new Ui::GDDCdlg)
{
GDDCdlg::GDDCdlg(QWidget *parent) : QWidget(parent), ui(new Ui::GDDCdlg) {
ui->setupUi(this);
initWindow();
initParam();
initSignalSlot();
}
GDDCdlg::~GDDCdlg()
{
//停止所有通信
GDDCdlg::~GDDCdlg() {
// 停止所有通信
stopConnectURL1();
stopConnectURL2();
stopConnectSerialCtrl();
@ -72,82 +63,81 @@ GDDCdlg::~GDDCdlg()
delete ui;
}
//初始化window
void GDDCdlg::initWindow()
{
// 初始化window
void GDDCdlg::initWindow() {
QPalette palette;
//设置主窗口背景颜色
palette.setColor(QPalette::Window,QColor(50, 50, 50));
// 设置主窗口背景颜色
palette.setColor(QPalette::Window, QColor(50, 50, 50));
this->setPalette(palette);
//嵌入到主窗口
setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
// 嵌入到主窗口
setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
hide();
m_DlgGDDCSet = new GDDCSet();
m_GDDCCmdDlg = new GDDCCmdDlg(this);
m_GDDCStateDlg = new GDDCStateInfo(this);
ui->pushButShowStatePage->setIcon(QIcon(":/res/right.png"));
ui->pushButShowCmdPage->setIcon(QIcon(":/res/down.png"));
}
//初始化参数
void GDDCdlg::initParam()
{
// 初始化参数
void GDDCdlg::initParam() {
pointSelectionTracking = false;
Is_openVideo = false;
isCmdPageShow = true;
isStatePageShow = true;
m_DCcmdBuffer.resize(cmdLength);
detectionAreaSetting = false;
connectFlag.resize(12,false);
ui->pushButShowCmdPage->setIcon(QIcon(":/res/down.png"));
ui->pushButShowStatePage->setIcon(QIcon(":/res/right.png"));
connectFlag.resize(12, false);
}
//初始化信号与槽
void GDDCdlg::initSignalSlot()
{
// 初始化信号与槽
void GDDCdlg::initSignalSlot() {
/*******有四种方式*******/
//方式一
connect(ui->pushButtonSet,SIGNAL(clicked()),this,SLOT(pushButtonSet_clicked()));
//方式二
//connect(ui->pushButtonSet,&QPushButton::clicked,this,&::GDDCdlg::pushButtonSet_clicked);
//方式三
//connect(ui->pushButtonSet, QOverload<bool>::of(&QPushButton::clicked),this,&::GDDCdlg::pushButtonSet_clicked);
//方式四
//connect(ui->pushButtonSet,&QPushButton::clicked,[=](bool check){pushButtonSet_clicked();});
connect(ui->pushButShowCmdPage,SIGNAL(clicked()),this,SLOT(pushButShowCmdPage_clicked())); //控制页面隐藏显示按钮
connect(ui->pushButShowStatePage,SIGNAL(clicked()),this,SLOT(pushButShowStatePage_clicked())); //状态页面隐藏显示按钮
connect(m_DlgGDDCSet,SIGNAL(SignalStartConnect(int)),this,SLOT(startConnect(int))); //开始连接
connect(m_DlgGDDCSet,SIGNAL(SignalStopConnect(int)),this,SLOT(stopConnect(int))); //停止连接
}
//槽函数开始连接
void GDDCdlg::startConnect(int type)
{
switch(type)
{
case 1://播放视频1
// 方式一
connect(ui->pushButtonSet, SIGNAL(clicked()), this,
SLOT(pushButtonSet_clicked()));
// 方式二
// connect(ui->pushButtonSet,&QPushButton::clicked,this,&::GDDCdlg::pushButtonSet_clicked);
// 方式三
// connect(ui->pushButtonSet,
// QOverload<bool>::of(&QPushButton::clicked),this,&::GDDCdlg::pushButtonSet_clicked);
// 方式四
// connect(ui->pushButtonSet,&QPushButton::clicked,[=](bool
// check){pushButtonSet_clicked();});
connect(ui->pushButShowCmdPage, SIGNAL(clicked()), this,
SLOT(pushButShowCmdPage_clicked())); // 控制页面隐藏显示按钮
connect(ui->pushButShowStatePage, SIGNAL(clicked()), this,
SLOT(pushButShowStatePage_clicked())); // 状态页面隐藏显示按钮
connect(m_DlgGDDCSet, SIGNAL(SignalStartConnect(int)), this,
SLOT(startConnect(int))); // 开始连接
connect(m_DlgGDDCSet, SIGNAL(SignalStopConnect(int)), this,
SLOT(stopConnect(int))); // 停止连接
}
// 槽函数开始连接
void GDDCdlg::startConnect(int type) {
switch (type) {
case 1: // 播放视频1
stopConnectURL2();
startConnectURL1();
break;
case 2://播放视频2
case 2: // 播放视频2
stopConnectURL1();
startConnectURL2();
break;
case 3://串口控制
case 3: // 串口控制
startConnectSerialCtrl();
break;
case 4://UDP控制
case 4: // UDP控制
stopConnectTCPCtrl();
startConnectUDPCtrl();
break;
case 5://TCP控制
case 5: // TCP控制
stopConnectUDPCtrl();
startConnectTCPCtrl();
break;
case 6://视频(1)推流
case 6: // 视频(1)推流
startPushURL();
break;
default:
@ -155,11 +145,9 @@ void GDDCdlg::startConnect(int type)
}
}
//槽函数停止连接
void GDDCdlg::stopConnect(int type)
{
switch(type)
{
// 槽函数停止连接
void GDDCdlg::stopConnect(int type) {
switch (type) {
case 1:
stopConnectURL1();
break;
@ -178,7 +166,7 @@ void GDDCdlg::stopConnect(int type)
case 6:
stopPushURL();
break;
default :
default:
break;
}
}
@ -196,87 +184,79 @@ void GDDCdlg::stopConnect(int type)
// return true;
// }
//鼠标左键
void GDDCdlg::mousePressEvent(QMouseEvent *event)
{
//如果鼠标左键按下
// 鼠标左键
void GDDCdlg::mousePressEvent(QMouseEvent *event) {
// 如果鼠标左键按下
if (event->type() == QEvent::MouseButtonPress) {
//AI检测区域设置
if(m_GDDCCmdDlg->detectionAreaSetting==true)
{
// AI检测区域设置
if (m_GDDCCmdDlg->detectionAreaSetting == true) {
QPointF sPoint1 = event->globalPosition();
sPoint1 = QCursor::pos();
QPointF widgetPoint = ui->WgtffmpegVideo->mapFromGlobal(sPoint1);
double a = ui->WgtffmpegVideo->width();
double b = ui->WgtffmpegVideo->height();
double dir = 1920/a*widgetPoint.rx()-960;
double pitch = -(1080/b*widgetPoint.ry()-540);
double dir = 1920 / a * widgetPoint.rx() - 960;
double pitch = -(1080 / b * widgetPoint.ry() - 540);
m_GDDCCmdDlg->ui->lineEdit_6_1->setText(QString::number((int)dir));
m_GDDCCmdDlg->ui->lineEdit_6_2->setText(QString::number((int)pitch));
}
//目标跟踪
if(m_GDDCCmdDlg->pointSelectionTracking == true)
{
// 目标跟踪
if (m_GDDCCmdDlg->pointSelectionTracking == true) {
QPointF sPoint1 = event->globalPosition();
QPointF widgetPoint = ui->WgtffmpegVideo->mapFromGlobal(sPoint1);
double a = ui->WgtffmpegVideo->width();
double b = ui->WgtffmpegVideo->height();
double dir = 1920/a*widgetPoint.rx()-960;
double pitch = -(1080/b*widgetPoint.ry()-540);
double dir = 1920 / a * widgetPoint.rx() - 960;
double pitch = -(1080 / b * widgetPoint.ry() - 540);
std::byte buffer[10];
buffer[0] = (std::byte)0x3A;
buffer[1] = (std::byte)(dir);
buffer[2] = (std::byte)((int)dir>>8);
buffer[2] = (std::byte)((int)dir >> 8);
buffer[3] = (std::byte)pitch;
buffer[4] = (std::byte)((int)pitch>>8);
buffer[4] = (std::byte)((int)pitch >> 8);
buffer[5] = (std::byte)0x00;
buffer[6] = (std::byte)0x00;
buffer[7] = (std::byte)0x00;
buffer[8] = (std::byte)0x00;
buffer[9] = (std::byte)0x00;
//发送5次
sendCurDate(buffer,3);
// 发送5次
sendCurDate(buffer, 3);
}
}
}
//鼠标移动
void GDDCdlg::mouseMoveEvent(QMouseEvent *event)
{
if(m_GDDCCmdDlg->detectionAreaSetting==true)
{
// 鼠标移动
void GDDCdlg::mouseMoveEvent(QMouseEvent *event) {
if (m_GDDCCmdDlg->detectionAreaSetting == true) {
qDebug() << this->geometry().x();
qDebug() << this->geometry().y();
QPointF sPoint1=event->globalPosition();
//qDebug()<<"相对于屏幕坐标1:"<<"("<<sPoint1.rx()<<","<<sPoint1.ry()<<")";
QPointF sPoint1 = event->globalPosition();
// qDebug()<<"相对于屏幕坐标1:"<<"("<<sPoint1.rx()<<","<<sPoint1.ry()<<")";
QPointF sPoint2=QCursor::pos();
//qDebug()<<"相对于屏幕坐标2:"<<"("<<sPoint2.rx()<<","<<sPoint2.ry()<<")";
QPointF sPoint2 = QCursor::pos();
// qDebug()<<"相对于屏幕坐标2:"<<"("<<sPoint2.rx()<<","<<sPoint2.ry()<<")";
QPointF windowPoint=this->mapFromGlobal(sPoint2);
//qDebug()<<"相对于窗口坐标:"<<"("<<windowPoint.rx()<<","<<windowPoint.ry()<<")";
QPointF windowPoint = this->mapFromGlobal(sPoint2);
// qDebug()<<"相对于窗口坐标:"<<"("<<windowPoint.rx()<<","<<windowPoint.ry()<<")";
QPointF widgetPoint=ui->WgtffmpegVideo->mapFromGlobal(sPoint1);
//qDebug()<<"相对于控件坐标:"<<"("<<widgetPoint.rx()<<","<<widgetPoint.ry()<<")";
QPointF widgetPoint = ui->WgtffmpegVideo->mapFromGlobal(sPoint1);
// qDebug()<<"相对于控件坐标:"<<"("<<widgetPoint.rx()<<","<<widgetPoint.ry()<<")";
//更新LineEdit信息
// 更新LineEdit信息
double a = ui->WgtffmpegVideo->width();
double b = ui->WgtffmpegVideo->height();
double dir = 1920/a*widgetPoint.rx()-960;
double pitch = -(1080/b*widgetPoint.ry()-540);
double dir = 1920 / a * widgetPoint.rx() - 960;
double pitch = -(1080 / b * widgetPoint.ry() - 540);
m_GDDCCmdDlg->ui->lineEdit_6_1->setText(QString::number((int)dir));
m_GDDCCmdDlg->ui->lineEdit_6_2->setText(QString::number((int)pitch));
}
}
//区域重绘
void GDDCdlg::resizeEvent(QResizeEvent *event)
{
resizeUI(); //重新设置布局
// 区域重绘
void GDDCdlg::resizeEvent(QResizeEvent *event) {
resizeUI(); // 重新设置布局
}
//重新设置布局
void GDDCdlg::resizeUI()
{
// 重新设置布局
void GDDCdlg::resizeUI() {
/* -------------->x
* | (0,0)
* |
@ -287,31 +267,42 @@ void GDDCdlg::resizeUI()
*/
double GDDCPageHeight = (double)(this->height());
double GDDCPageWidth = (double)(this->width());
//qDebug()<<"宽度,高度:"<<GDDCPageHeight<<GDDCPageWidth;
// qDebug()<<"宽度,高度:"<<GDDCPageHeight<<GDDCPageWidth;
/******控制区位置和大小设置*****/
double cmdAreaHeight;
double cmdAreaWidth;
if(m_GDDCStateDlg->isVisible()){cmdAreaWidth = GDDCPageWidth-STATEPAGEWIDTH;}
else{cmdAreaWidth = GDDCPageWidth;}
if(m_GDDCCmdDlg->isVisible()){cmdAreaHeight = CMDPAGEHIGHT;}
else{cmdAreaHeight = 0;}
m_GDDCCmdDlg->setGeometry(0,GDDCPageHeight-cmdAreaHeight,(int)cmdAreaWidth,(int)cmdAreaHeight);
m_GDDCCmdDlg->ui->tabWidget->setGeometry(0,0,(int)cmdAreaWidth,(int)cmdAreaHeight);
if (isStatePageShow) {
cmdAreaWidth = GDDCPageWidth - STATEPAGEWIDTH;
} else {
cmdAreaWidth = GDDCPageWidth;
}
if (isCmdPageShow) {
cmdAreaHeight = CMDPAGEHIGHT;
} else {
cmdAreaHeight = 0;
}
m_GDDCCmdDlg->setGeometry(0, GDDCPageHeight - cmdAreaHeight,
(int)cmdAreaWidth, (int)cmdAreaHeight);
m_GDDCCmdDlg->ui->tabWidget->setGeometry(0, 0, (int)cmdAreaWidth,
(int)cmdAreaHeight);
/*********状态区位置和大小设置***********/
double stateAreaHeight = GDDCPageHeight;
double stateAreaWidth;
if(m_GDDCStateDlg->isVisible()){stateAreaWidth = STATEPAGEWIDTH;}
else{stateAreaWidth = 0;}
m_GDDCStateDlg->setGeometry(GDDCPageWidth-stateAreaWidth,0,stateAreaWidth,stateAreaHeight);
m_GDDCStateDlg->ui->tableViewShowIState->setGeometry(0,0,stateAreaWidth,stateAreaHeight);
if (isStatePageShow) {
stateAreaWidth = STATEPAGEWIDTH;
} else {
stateAreaWidth = 0;
}
m_GDDCStateDlg->setGeometry(GDDCPageWidth - stateAreaWidth, 0, stateAreaWidth,
stateAreaHeight);
m_GDDCStateDlg->ui->tableViewShowIState->setGeometry(0, 0, stateAreaWidth,
stateAreaHeight);
/*******视频区位置和大小设置********/
double VideoAreaHeight = GDDCPageHeight-cmdAreaHeight; //视频区高度
double VideoAreaWidth = GDDCPageWidth-stateAreaWidth; //视频区宽度
double VideoAreaHeight = GDDCPageHeight - cmdAreaHeight; // 视频区高度
double VideoAreaWidth = GDDCPageWidth - stateAreaWidth; // 视频区宽度
// //高度值相对比较大
// if(VideoAreaHeight*16>VideoAreaWidth*9)
// {
@ -322,246 +313,213 @@ void GDDCdlg::resizeUI()
// //宽度值相对比较大
// else
// {
// double setVideoAreaHeight = VideoAreaHeight;//等于吊舱页面高度-控制区高度
// double setVideoAreaWidth = VideoAreaHeight*16/9;
// double setVideoAreaHeight =
// VideoAreaHeight;//等于吊舱页面高度-控制区高度 double setVideoAreaWidth
// = VideoAreaHeight*16/9;
// ui->WgtffmpegVideo->setGeometry(0.5*(VideoAreaWidth-setVideoAreaWidth),0,(int)setVideoAreaWidth,(int)setVideoAreaHeight);
// }
ui->WgtffmpegVideo->setGeometry(0,0,(int)VideoAreaWidth,(int)VideoAreaHeight);
ui->WgtffmpegVideo->setGeometry(0, 0, (int)VideoAreaWidth,
(int)VideoAreaHeight);
/**************设置按钮****************/
ui->pushButtonSet->setGeometry(GDDCPageWidth-stateAreaWidth-45,0,40,40);
ui->pushButtonSet->setGeometry(GDDCPageWidth - stateAreaWidth - 45, 0, 40,
40);
/**********控制页显示隐藏按钮********/
ui->pushButShowCmdPage->setGeometry(cmdAreaWidth*0.5,GDDCPageHeight-cmdAreaHeight-20,50,20);
ui->pushButShowCmdPage->setGeometry(
cmdAreaWidth * 0.5, GDDCPageHeight - cmdAreaHeight - 15, 50, 15);
ui->pushButShowCmdPage->raise();
/**********状态页显示隐藏按钮********/
ui->pushButShowStatePage->setGeometry(GDDCPageWidth-stateAreaWidth-20,(stateAreaHeight-cmdAreaHeight)*0.5,20,50);
ui->pushButShowStatePage->setGeometry(GDDCPageWidth - stateAreaWidth - 15,
(stateAreaHeight - cmdAreaHeight) * 0.5,
15, 50);
ui->pushButShowStatePage->raise();
}
//定时器处理
void GDDCdlg::GDDCControlTimeOut()
{
if(sendTimes>0)
{
sendTimes-=1;
// 定时器处理
void GDDCdlg::GDDCControlTimeOut() {
if (sendTimes > 0) {
sendTimes -= 1;
//UDP控制
if(connectFlag[3])
{
udpSocket->writeDatagram(m_DCcmdBuffer,m_DlgGDDCSet->m_myPairNetwork.getRemoteAddr(),m_DlgGDDCSet->m_myPairNetwork.getRemotePort());
// UDP控制
if (connectFlag[3]) {
udpSocket->writeDatagram(m_DCcmdBuffer,
m_DlgGDDCSet->m_myPairNetwork.getRemoteAddr(),
m_DlgGDDCSet->m_myPairNetwork.getRemotePort());
}
//TCP控制
//串口控制
// TCP控制
// 串口控制
if(sendTimes==0)
{
if (sendTimes == 0) {
clearTJDCCmdBuffer();
}
}
else
{
} else {
UpdateDataTJDC();
//UDP控制
if(connectFlag[3])
{
udpSocket->writeDatagram(m_DCcmdBuffer,m_DlgGDDCSet->m_myPairNetwork.getRemoteAddr(),m_DlgGDDCSet->m_myPairNetwork.getRemotePort());
// UDP控制
if (connectFlag[3]) {
udpSocket->writeDatagram(m_DCcmdBuffer,
m_DlgGDDCSet->m_myPairNetwork.getRemoteAddr(),
m_DlgGDDCSet->m_myPairNetwork.getRemotePort());
}
//TCP控制
//串口控制
// TCP控制
// 串口控制
}
}
//更新m_DCcmdBuffer
void GDDCdlg::UpdateDataTJDC()
{
// 更新m_DCcmdBuffer
void GDDCdlg::UpdateDataTJDC() {
m_GDDCCmdDlg->UpdateDataTJDC();
m_DCcmdBuffer = m_GDDCCmdDlg->m_DCcmdBuffer;
}
//赋值后清空TJDCCmdBuffer
void GDDCdlg::clearTJDCCmdBuffer()
{
m_GDDCCmdDlg->clearTJDCCmdBuffer();
}
// 赋值后清空TJDCCmdBuffer
void GDDCdlg::clearTJDCCmdBuffer() { m_GDDCCmdDlg->clearTJDCCmdBuffer(); }
//设置发送数据和次数
void GDDCdlg::sendCurDate(std::byte *buffer, int num)
{
// 设置发送数据和次数
void GDDCdlg::sendCurDate(std::byte *buffer, int num) {
sendTimes = num;
for(int i=0;i<10;++i)
{
for (int i = 0; i < 10; ++i) {
m_GDDCCmdDlg->TJDCCmdBuffer[i] = buffer[i];
}
UpdateDataTJDC();
}
//播放视频1
void GDDCdlg::startConnectURL1()
{
if(!connectFlag[0])
{
connectFlag[0] = true ;
//Is_openVideo = true;
//ui->WgtffmpegVideo->Isplay(Is_openVideo);
//ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo;
// 播放视频1
void GDDCdlg::startConnectURL1() {
if (!connectFlag[0]) {
connectFlag[0] = true;
// Is_openVideo = true;
// ui->WgtffmpegVideo->Isplay(Is_openVideo);
// ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo;
ui->WgtffmpegVideo->play();
ui->WgtffmpegVideo->setUrl(m_DlgGDDCSet->m_playURL1);
}
}
//关闭视频1
void GDDCdlg::stopConnectURL1()
{
if(connectFlag[0])
{
connectFlag[0] = false ;
//Is_openVideo = false;
//ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo;
// 关闭视频1
void GDDCdlg::stopConnectURL1() {
if (connectFlag[0]) {
connectFlag[0] = false;
// Is_openVideo = false;
// ui->WgtffmpegVideo->m_PlayStatus = Is_openVideo;
ui->WgtffmpegVideo->stop();
}
}
//播放视频2
void GDDCdlg::startConnectURL2()
{
if(!connectFlag[1])
{
connectFlag[1] = true ;
// 播放视频2
void GDDCdlg::startConnectURL2() {
if (!connectFlag[1]) {
connectFlag[1] = true;
}
}
//关闭视频2
void GDDCdlg::stopConnectURL2()
{
if(connectFlag[1])
{
connectFlag[1] = false ;
// 关闭视频2
void GDDCdlg::stopConnectURL2() {
if (connectFlag[1]) {
connectFlag[1] = false;
}
}
void GDDCdlg::startConnectSerialCtrl()
{
if(!connectFlag[2])
{
connectFlag[2] = true ;
void GDDCdlg::startConnectSerialCtrl() {
if (!connectFlag[2]) {
connectFlag[2] = true;
}
}
void GDDCdlg::stopConnectSerialCtrl()
{
if(connectFlag[2])
{
connectFlag[2] = false ;
void GDDCdlg::stopConnectSerialCtrl() {
if (connectFlag[2]) {
connectFlag[2] = false;
}
}
//开始UDP控制通信
void GDDCdlg::startConnectUDPCtrl()
{
if(!connectFlag[3])
{
// 开始UDP控制通信
void GDDCdlg::startConnectUDPCtrl() {
if (!connectFlag[3]) {
/*启动定时器*/
GDDCControlTimer = new QTimer();
GDDCControlTimer->setInterval(100);
connect(GDDCControlTimer,&QTimer::timeout,this,[=](){
GDDCControlTimeOut();
});
connect(GDDCControlTimer, &QTimer::timeout, this,
[=]() { GDDCControlTimeOut(); });
GDDCControlTimer->start();
//创建udp socket对象
// 创建udp socket对象
udpSocket = new QUdpSocket(this);
/*接收*/
//QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();//获取本机ip
// QList<QHostAddress> ipAddressesList =
// QNetworkInterface::allAddresses();//获取本机ip
udpSocket->bind(m_DlgGDDCSet->m_myPairNetwork.getLocalPort());
connect(udpSocket,SIGNAL(readyRead()),this,SLOT(UDPMessageReceive()));
connect(udpSocket, SIGNAL(readyRead()), this, SLOT(UDPMessageReceive()));
connectFlag[3] = true;
}
}
//停止UDP控制通信
void GDDCdlg::stopConnectUDPCtrl()
{
if(connectFlag[3])
{
//关闭定时器
// 停止UDP控制通信
void GDDCdlg::stopConnectUDPCtrl() {
if (connectFlag[3]) {
// 关闭定时器
GDDCControlTimer->stop();
delete GDDCControlTimer;
udpSocket->abort();//关闭套接字,并丢缓冲区中的所有待处理数据
udpSocket->abort(); // 关闭套接字,并丢缓冲区中的所有待处理数据
delete udpSocket;
connectFlag[3] = false;
}
}
//开始TCP控制通信
void GDDCdlg::startConnectTCPCtrl()
{
if(!connectFlag[4])
{
// 开始TCP控制通信
void GDDCdlg::startConnectTCPCtrl() {
if (!connectFlag[4]) {
connectFlag[4] = true;
}
}
//停止TCP控制通信
void GDDCdlg::stopConnectTCPCtrl()
{
if(connectFlag[4])
{
// 停止TCP控制通信
void GDDCdlg::stopConnectTCPCtrl() {
if (connectFlag[4]) {
connectFlag[4] = false;
}
}
//开始视频推流
void GDDCdlg::startPushURL()
{
if(!connectFlag[5])
{
// 开始视频推流
void GDDCdlg::startPushURL() {
if (!connectFlag[5]) {
process = new QProcess();
connect(process,&QProcess::readyReadStandardOutput,this,[=]()mutable{ //
QString Output=process->readAllStandardOutput();
qDebug()<<"Output:"<<Output;
connect(process, &QProcess::readyReadStandardOutput, this, [=]() mutable {
QString Output = process->readAllStandardOutput();
qDebug() << "Output:" << Output;
});
connect(process,&QProcess::readyReadStandardError,this,[=]()mutable{
QString Error=process->readAllStandardError();
qDebug()<<"Error:"<<Error;
connect(process, &QProcess::readyReadStandardError, this, [=]() mutable {
QString Error = process->readAllStandardError();
qDebug() << "Error Output:" << Error;
});
//process->start("cmd",QStringList()<<"/c"<<"ffmpeg -i rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid -c copy -f flv rtmp://182.92.130.23/app/test");
// process->start("cmd",QStringList()<<"/c"<<"ffmpeg -i
// rtmp://liteavapp.qcloud.com/live/liteavdemoplayerstreamid -c copy -f flv
// rtmp://182.92.130.23/app/test");
QStringList m_cmd;
QString str;
str = "ffmpeg -i "+m_DlgGDDCSet->m_playURL1+" -c copy -f flv "+m_DlgGDDCSet->m_pushURL;
//str = "TaskList";
m_cmd<<"/c"<<str;
//m_cmd<<"/c"<<"ping"<<"baidu.com";
process->start("cmd",m_cmd);
str = "ffmpeg -i " + m_DlgGDDCSet->m_playURL1 + " -c copy -f flv " +
m_DlgGDDCSet->m_pushURL;
// str = "TaskList";
m_cmd << "/c" << str;
// m_cmd<<"/c"<<"ping"<<"baidu.com";
process->start("cmd", m_cmd);
connectFlag[5] = true;
//process->waitForStarted(); //等待程序启动
//process->waitForFinished(); //等待程序关闭
// process->waitForStarted(); //等待程序启动
// process->waitForFinished(); //等待程序关闭
}
}
//停止视频推流
void GDDCdlg::stopPushURL()
{
if(connectFlag[5])
{
if(process!=nullptr)
{
// 停止视频推流
void GDDCdlg::stopPushURL() {
if (connectFlag[5]) {
if (process != nullptr) {
process->terminate();
process->close();
process->kill();
@ -573,76 +531,64 @@ void GDDCdlg::stopPushURL()
}
delete process;
//推流进程未自动关闭,手动关闭
// 推流进程未自动关闭,手动关闭
int pids = GetmPid(L"ffmpeg.exe");
qDebug()<<"ffmpeg.exe进程的pid为:"<<pids;
//QString cmd;
//cmd = "taskkill /pid "+QString::number(pids)+" -f";
qDebug() << "ffmpeg.exe进程的pid为:" << pids;
// QString cmd;
// cmd = "taskkill /pid "+QString::number(pids)+" -f";
QStringList m_cmd;
m_cmd<<"/c"<<"taskkill /pid "<<QString::number(pids)<<" -f";
QProcess::startDetached("cmd",m_cmd);
m_cmd << "/c" << "taskkill /pid " << QString::number(pids) << " -f";
QProcess::startDetached("cmd", m_cmd);
}
connectFlag[5] = false;
}
}
//设置页面弹出
void GDDCdlg::pushButtonSet_clicked()
{
// 设置页面弹出
void GDDCdlg::pushButtonSet_clicked() {
m_DlgGDDCSet->show();
m_DlgGDDCSet->activateWindow();
}
//udp数据接收
void GDDCdlg::UDPMessageReceive()
{
// udp数据接收
void GDDCdlg::UDPMessageReceive() {
QByteArray data;
data.resize(udpSocket->pendingDatagramSize());
QHostAddress addr;
quint16 port;
udpSocket->readDatagram(data.data(),data.size(),&addr,&port);
udpSocket->readDatagram(data.data(), data.size(), &addr, &port);
//吊舱状态数据更新
m_GDDCStateDlg->UDPMessageReceive(data,data.size());
// 吊舱状态数据更新
m_GDDCStateDlg->UDPMessageReceive(data, data.size());
}
//控制页面隐藏与显示
void GDDCdlg::pushButShowCmdPage_clicked()
{
if(isCmdPageShow)
{
// 控制页面隐藏与显示
void GDDCdlg::pushButShowCmdPage_clicked() {
if (isCmdPageShow) {
m_GDDCCmdDlg->setVisible(false);
isCmdPageShow = false;
resizeUI();
ui->pushButShowCmdPage->setIcon(QIcon(":/res/up.png"));
//ui->pushButton->setGeometry(this->width()/2,this->height()-50,50,50);
}
else
{
// ui->pushButton->setGeometry(this->width()/2,this->height()-50,50,50);
} else {
m_GDDCCmdDlg->setVisible(true);
isCmdPageShow = true;
resizeUI();
ui->pushButShowCmdPage->setIcon(QIcon(":/res/down.png"));
//ui->pushButton->setGeometry(this->width()/2,ui->tabWidget->height(),50,50);
// ui->pushButton->setGeometry(this->width()/2,ui->tabWidget->height(),50,50);
}
}
//状态页面隐藏与显示
void GDDCdlg::pushButShowStatePage_clicked()
{
if(isStatePageShow)
{
// 状态页面隐藏与显示
void GDDCdlg::pushButShowStatePage_clicked() {
if (isStatePageShow) {
m_GDDCStateDlg->setVisible(false);
isStatePageShow = false;
resizeUI();
ui->pushButShowStatePage->setIcon(QIcon(":/res/left.png"));
}
else
{
} else {
m_GDDCStateDlg->setVisible(true);
isStatePageShow = true;
resizeUI();
ui->pushButShowStatePage->setIcon(QIcon(":/res/right.png"));
//ui->pushButton->setGeometry(this->width()/2,ui->tabWidget->height(),50,50);
// ui->pushButton->setGeometry(this->width()/2,ui->tabWidget->height(),50,50);
}
}

@ -137,29 +137,6 @@
</size>
</property>
</widget>
<widget class="QTableView" name="tableViewShowIState">
<property name="geometry">
<rect>
<x>750</x>
<y>130</y>
<width>256</width>
<height>192</height>
</rect>
</property>
<property name="styleSheet">
<string notr="true"/>
</property>
</widget>
<widget class="QWidget" name="subWidgetCmd" native="true">
<property name="geometry">
<rect>
<x>260</x>
<y>380</y>
<width>331</width>
<height>71</height>
</rect>
</property>
</widget>
<widget class="QPushButton" name="pushButShowStatePage">
<property name="geometry">
<rect>

@ -1,11 +1,16 @@
SOURCES += \
$$PWD/deviceStateDlg.cpp \
$$PWD/homepagesetingwidget.cpp \
$$PWD/homepagedlg.cpp
$$PWD/homepagedlg.cpp \
$$PWD/networkDetection.cpp
HEADERS += \
$$PWD/deviceStateDlg.h \
$$PWD/homepagesetingwidget.h \
$$PWD/homepagedlg.h
$$PWD/homepagedlg.h \
$$PWD/networkDetection.h
FORMS += \
$$PWD/deviceStateDlg.ui \
$$PWD/homepagesetingwidget.ui \
$$PWD/homepagedlg.ui \

@ -0,0 +1,285 @@
#include "deviceStateDlg.h"
#include "ui_deviceStateDlg.h"
deviceStateDlg::deviceStateDlg(QWidget *parent)
: QWidget(parent), ui(new Ui::deviceStateDlg) {
ui->setupUi(this);
initWindow();
initParam();
}
deviceStateDlg::~deviceStateDlg() {
stopNetDetn();
delete m_timer;
delete ui;
}
void deviceStateDlg::initWindow() {
// 嵌入到主窗口
setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
hide();
QString stateButtonStyle =
/*正常情况下样式*/
"QPushButton{"
//"image: url(:/res/lamp/grey.png)-23px 0px no-repeat;"
"border-radius: 13px;"
"border-style: solid;"
"border-width: 1px;"
"padding: 5px;"
"}";
ui->pushButton_state_GDDC->setStyleSheet(stateButtonStyle);
ui->pushButton_state_LLink->setStyleSheet(stateButtonStyle);
ui->pushButton_state_3DCamra->setStyleSheet(stateButtonStyle);
ui->pushButton_state_KuSatelliteComm->setStyleSheet(stateButtonStyle);
ui->pushButton_state_PDT->setStyleSheet(stateButtonStyle);
ui->pushButton_state_adHocNetwork->setStyleSheet(stateButtonStyle);
ui->pushButton_state_rescue->setStyleSheet(stateButtonStyle);
//"image: url(:/res/lamp/grey.png)-23px 0px no-repeat;"
QIcon greyIcon(":/res/lamp/grey.png");
ui->pushButton_state_GDDC->setIcon(greyIcon);
ui->pushButton_state_LLink->setIcon(greyIcon);
ui->pushButton_state_3DCamra->setIcon(greyIcon);
ui->pushButton_state_KuSatelliteComm->setIcon(greyIcon);
ui->pushButton_state_PDT->setIcon(greyIcon);
ui->pushButton_state_adHocNetwork->setIcon(greyIcon);
ui->pushButton_state_rescue->setIcon(greyIcon);
ui->pushButton_state_GDDC->setIconSize(QSize(35, 35));
ui->pushButton_state_LLink->setIconSize(QSize(35, 35));
ui->pushButton_state_3DCamra->setIconSize(QSize(35, 35));
ui->pushButton_state_KuSatelliteComm->setIconSize(QSize(35, 35));
ui->pushButton_state_PDT->setIconSize(QSize(35, 35));
ui->pushButton_state_adHocNetwork->setIconSize(QSize(35, 35));
ui->pushButton_state_rescue->setIconSize(QSize(35, 35));
ui->lineEdit_1_GDDC->setText("--");
ui->lineEdit_2_GDDC->setText("--");
ui->lineEdit_3_GDDC->setText("--");
ui->lineEdit_1_Llink->setText("--");
ui->lineEdit_2_Llink->setText("--");
ui->lineEdit_3_Llink->setText("--");
ui->lineEdit_1_3DCamra->setText("--");
ui->lineEdit_2_3DCamra->setText("--");
ui->lineEdit_3_3DCamra->setText("--");
ui->lineEdit_1_KuSatelliteComm->setText("--");
ui->lineEdit_2_KuSatelliteComm->setText("--");
ui->lineEdit_3_KuSatelliteComm->setText("--");
ui->lineEdit_1_PDT->setText("--");
ui->lineEdit_2_PDT->setText("--");
ui->lineEdit_3_PDT->setText("--");
ui->lineEdit_1_adHocNetwork->setText("--");
ui->lineEdit_2_adHocNetwork->setText("--");
ui->lineEdit_3_adHocNetwork->setText("--");
ui->lineEdit_1_rescue->setText("--");
ui->lineEdit_2_rescue->setText("--");
ui->lineEdit_3_rescue->setText("--");
m_timer = new QTimer();
m_timer->setInterval(2000);
connect(m_timer, SIGNAL(timeout()), this, SLOT(onTimeOut()));
m_timer->start();
}
void deviceStateDlg::initParam() {
// 172.10.1.183 -n 2 -w 500"
cmdlist[0] << "/c" << "ping" << "172.10.1.183";
cmdlist[1] << "/c" << "ping" << "172.10.1.183";
cmdlist[2] << "/c" << "ping" << "www.baidu.com";
cmdlist[3] << "/c" << "ping" << "www.baidu.com";
startNetDetn();
}
// 接收线程结果
void deviceStateDlg::receiveResult(int id, QString result) {
// qDebug() << result;
switch (id) {
case 0:
if (result == "在线") {
ui->pushButton_state_GDDC->setIcon(QIcon(":/res/lamp/green.png"));
} else {
ui->pushButton_state_GDDC->setIcon(QIcon(":/res/lamp/red.png"));
}
break;
case 1:
if (result == "在线") {
ui->pushButton_state_LLink->setIcon(QIcon(":/res/lamp/green.png"));
} else {
ui->pushButton_state_LLink->setIcon(QIcon(":/res/lamp/red.png"));
}
break;
case 2:
if (result == "在线") {
ui->pushButton_state_adHocNetwork->setIcon(QIcon(":/res/lamp/green.png"));
} else {
ui->pushButton_state_adHocNetwork->setIcon(QIcon(":/res/lamp/red.png"));
}
break;
case 3:
if (result == "在线") {
ui->pushButton_state_KuSatelliteComm->setIcon(
QIcon(":/res/lamp/green.png"));
} else {
ui->pushButton_state_KuSatelliteComm->setIcon(
QIcon(":/res/lamp/red.png"));
}
break;
default:
break;
}
}
// 接收更改的IP
void deviceStateDlg::setDeviceIP(int id, QString ip) {
QString strIp;
strIp = stringIPSelect(ip);
switch (id) {
case HomePageSetingWidget::L_Link:
cmdlist[1].clear();
cmdlist[1] << "/c" << "ping" << strIp;
m_networkDetection[1]->DyChangeCmdList(cmdlist[1]); // 更新到网络检测线程
break;
case HomePageSetingWidget::Adhoc_Network:
cmdlist[2].clear();
cmdlist[2] << "/c" << "ping" << strIp;
m_networkDetection[2]->DyChangeCmdList(cmdlist[2]); // 更新到网络检测线程
break;
case HomePageSetingWidget::Satelite_Comm:
cmdlist[3].clear();
cmdlist[3] << "/c" << "ping" << strIp;
m_networkDetection[3]->DyChangeCmdList(cmdlist[3]); // 更新到网络检测线程
break;
default:
break;
}
}
// 字符串网络地址截取
QString deviceStateDlg::stringIPSelect(QString str) {
int start, end; // str = https://192.168.1.2/22
start = str.indexOf("//");
if (start != 0) {
start += 2;
QString str2 = str.remove(0, start); // 192.168.1.2/224//115
end = str2.indexOf("/");
if (end != -1) {
end += 1;
str2.truncate(end);
return str2;
} else {
return str2;
}
} else {
end = str.indexOf("/");
if (end != -1) {
end += 1;
str.truncate(end);
return str;
} else {
return str;
}
}
// index = str.indexOf("http://")
}
// 开始网络监测
void deviceStateDlg::startNetDetn() {
for (int i = 0; i < deviceNum; ++i) {
m_networkDetection[i] = new networkDetection();
m_workerThread[i] = new QThread();
m_networkDetection[i]->moveToThread(m_workerThread[i]);
m_workerThread[i]->start();
connect(m_networkDetection[i], SIGNAL(resultReady(int, QString)), this,
SLOT(receiveResult(int, QString))); // 接收线程运行结果
switch (i) {
case 0:
connect(this, &deviceStateDlg::startThread0, m_networkDetection[i],
&networkDetection::dowork); // 线程开始处理数据
emit startThread0(i, cmdlist[i]); // 启用线程信号
break;
case 1:
connect(this, &deviceStateDlg::startThread1, m_networkDetection[i],
&networkDetection::dowork); // 线程开始处理数据
emit startThread1(i, cmdlist[i]); // 启用线程信号
break;
case 2:
connect(this, &deviceStateDlg::startThread2, m_networkDetection[i],
&networkDetection::dowork); // 线程开始处理数据
emit startThread2(i, cmdlist[i]); // 启用线程信号
break;
case 3:
connect(this, &deviceStateDlg::startThread3, m_networkDetection[i],
&networkDetection::dowork); // 线程开始处理数据
emit startThread3(i, cmdlist[i]); // 启用线程信号
break;
case 4:
connect(this, &deviceStateDlg::startThread4, m_networkDetection[i],
&networkDetection::dowork); // 线程开始处理数据
emit startThread4(i, cmdlist[i]); // 启用线程信号
break;
default:
break;
}
}
}
// 停止网络监测
void deviceStateDlg::stopNetDetn() {
for (int i = 0; i < deviceNum; ++i) {
m_networkDetection[i]->stop(); // 线程退出循环
m_workerThread[i]->quit(); // 退出线程请求
m_workerThread[i]->wait(); // 使线程正常退出。
m_workerThread[i]->deleteLater();
m_workerThread[i] = nullptr;
m_networkDetection[i]->deleteLater();
m_networkDetection[i] = nullptr;
}
}
void deviceStateDlg::on_pushButton_homePage_GDDC_clicked() {
emit switchToDevicePage(0);
}
void deviceStateDlg::on_pushButton_homePage_LLink_clicked() {
emit switchToDevicePage(1);
}
void deviceStateDlg::on_pushButton_homePage_adHocNetwork_clicked() {
emit switchToDevicePage(2);
}
void deviceStateDlg::on_pushButton_homePage_rescue_clicked() {
emit switchToDevicePage(5);
}
void deviceStateDlg::on_pushButton_homePage_PDT_clicked() {
emit switchToDevicePage(3);
}
void deviceStateDlg::on_pushButton_homePage_3DCamra_clicked() {
emit switchToDevicePage(6);
}
void deviceStateDlg::on_pushButton_homePage_KuSatelliteComm_clicked() {
emit switchToDevicePage(4);
}
void deviceStateDlg::onTimeOut() {
// QProcess *m_process = new QProcess();
// QStringList m_cmd;
// // m_cmd << "/c" << "ping" << "baidu.com -n 2 -w 1000";
// m_cmd << "/c" << "ping" << "172.10.1.183";
// QString result;
// m_process->start("cmd", m_cmd);
// m_process->waitForFinished(); // 等待指令执行完毕
// result = m_process->readAll(); // 获取指令执行结果
// qDebug() << result;
// if (result.contains(QString("TTL="))) // 若包含TTL=字符串则认为网络在线
// {
// qDebug() << "在线";
// ui->pushButton_state_GDDC->setIcon(QIcon(":/res/lamp/green.png"));
// } else {
// qDebug() << "离线";
// ui->pushButton_state_GDDC->setIcon(QIcon(":/res/lamp/red.png"));
// }
// m_process->kill();
}

@ -0,0 +1,64 @@
#ifndef DEVICESTATEDLG_H
#define DEVICESTATEDLG_H
#include "homepagesetingwidget.h"
#include "networkDetection.h"
#include <QProcess>
#include <QThread>
#include <QTimer>
#include <QWidget>
#define deviceNum 5
namespace Ui {
class deviceStateDlg;
}
class deviceStateDlg : public QWidget {
Q_OBJECT
public:
explicit deviceStateDlg(QWidget *parent = nullptr);
~deviceStateDlg();
void initWindow();
void initParam();
signals:
void switchToDevicePage(int id); // 发送切换到设备页信号
// QVector<void (*)(int, QStringList)> startThread(int, QStringList);
void startThread0(int, QStringList); // 启动线程
void startThread1(int, QStringList); // 启动线程
void startThread2(int, QStringList); // 启动线程
void startThread3(int, QStringList); // 启动线程
void startThread4(int, QStringList); // 启动线程
private slots:
void on_pushButton_homePage_GDDC_clicked();
void on_pushButton_homePage_LLink_clicked();
void on_pushButton_homePage_adHocNetwork_clicked();
void on_pushButton_homePage_rescue_clicked();
void on_pushButton_homePage_PDT_clicked();
void on_pushButton_homePage_3DCamra_clicked();
void on_pushButton_homePage_KuSatelliteComm_clicked();
void receiveResult(int, QString); // 接收线程结果
private:
Ui::deviceStateDlg *ui;
public:
QStringList cmdlist[deviceNum]; // 0光电吊舱1L链 2 自组网3ku卫通 4
networkDetection *m_networkDetection[deviceNum];
QThread *m_workerThread[deviceNum];
QTimer *m_timer;
void setDeviceIP(int, QString);
QString stringIPSelect(QString);
void startNetDetn();
void stopNetDetn();
public slots:
void onTimeOut();
};
#endif // DEVICESTATEDLG_H

File diff suppressed because it is too large Load Diff

@ -5,90 +5,94 @@
#include <qsettings.h>
HomePageDlg::HomePageDlg(QWidget *parent)
: QWidget(parent)
, ui(new Ui::HomePageDlg)
, _lLinkIp("")
, _adHocNetwork("")
, _satelliteComm("")
{
: QWidget(parent), ui(new Ui::HomePageDlg), _lLinkIp(""), _adHocNetwork(""),
_satelliteComm("") {
ui->setupUi(this);
QPalette palette;
//设置主窗口背景颜色
palette.setColor(QPalette::Window,QColor(50, 50, 50));
// 设置主窗口背景颜色
palette.setColor(QPalette::Window, QColor(50, 50, 50));
this->setPalette(palette);
//嵌入到主窗口
setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
// 嵌入到主窗口
setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint);
hide();
settingWidget = new HomePageSetingWidget(this);
settingWidget->setWindowFlags(Qt::Window); // 设置为独立窗口
m_deviceStateDlg = new deviceStateDlg(this); // 状态嵌入窗口
m_deviceStateDlg->show();
initSettingUrl();
initButton();
}
HomePageDlg::~HomePageDlg()
{
delete ui;
}
HomePageDlg::~HomePageDlg() { delete ui; }
/*************************************************
* @func getUrl
* @brief url
* @param
**************************************************/
void HomePageDlg::getUrl(std::unordered_map<QString, QString>& urlMap)
{
* @func getUrl
* @brief url
* @param
**************************************************/
void HomePageDlg::getUrl(std::unordered_map<QString, QString> &urlMap) {
urlMap = _urlMap;
}
/*************************************************
* @func
* @brief
* @param
* @return
**************************************************/
void HomePageDlg::initSettingUrl()
{
QString urlFile = QCoreApplication::applicationDirPath()+"/config.ini";
std::unique_ptr<QSettings> configIni = std::make_unique<QSettings>(urlFile,QSettings::IniFormat);
* @func
* @brief
* @param
* @return
**************************************************/
void HomePageDlg::initSettingUrl() {
QString urlFile = QCoreApplication::applicationDirPath() + "/config.ini";
std::unique_ptr<QSettings> configIni =
std::make_unique<QSettings>(urlFile, QSettings::IniFormat);
_lLinkIp = configIni->value("L链/IP").toString();
_adHocNetwork = configIni->value("宽带自组网/IP").toString();
_satelliteComm = configIni->value("机载卫通/IP").toString();
_urlMap.insert({"L链",_lLinkIp});
_urlMap.insert({"宽带自组网",_adHocNetwork});
_urlMap.insert({"机载卫通",_satelliteComm});
_urlMap.insert({"L链", _lLinkIp});
_urlMap.insert({"宽带自组网", _adHocNetwork});
_urlMap.insert({"机载卫通", _satelliteComm});
settingWidget->setUrl(_urlMap);
}
/**
* @brief HomePageDlg::initButton
*/
void HomePageDlg::initButton()
{
void HomePageDlg::initButton() {
QIcon icon;
icon.addFile(":/res/settings.png");
QPushButton* btn = new QPushButton;
btn->setParent(this);
btn->setMinimumSize(40,40);
btn->setMaximumSize(40,40);
btn->setIconSize(QSize(30,30));
btn->setIcon(icon);
m_settingBtn = new QPushButton;
m_settingBtn->setParent(this);
m_settingBtn->setMinimumSize(40, 40);
m_settingBtn->setMaximumSize(40, 40);
m_settingBtn->setIconSize(QSize(30, 30));
m_settingBtn->setIcon(icon);
//点击主页按钮弹出设置页面1
connect(btn,&QPushButton::clicked,this,[&](){
//qDebug() << "homepagedlg上的设置按钮点击了";
if(settingWidget->isVisible())
// 点击主页按钮弹出设置页面1
connect(m_settingBtn, &QPushButton::clicked, this, [&]() {
// qDebug() << "homepagedlg上的设置按钮点击了";
if (settingWidget->isVisible())
settingWidget->close();
else
settingWidget->show();
});
}
void HomePageDlg::on_pushButton_clicked()
{
emit sendUrl(_urlMap);
// 设置页面设置ip后更新网络检测页面ip
connect(settingWidget, &HomePageSetingWidget::sendOnlyUrl, this,
[&](unsigned char urlIndex, QString url) {
m_deviceStateDlg->setDeviceIP(urlIndex, url);
});
}
void HomePageDlg::on_pushButton_clicked() { emit sendUrl(_urlMap); }
// 区域重绘
void HomePageDlg::resizeEvent(QResizeEvent *event) {
double HomePageHeight = (double)(this->height());
double HomePageWidth = (double)(this->width());
m_settingBtn->setGeometry(HomePageWidth - 40, 0, 40, 40);
m_deviceStateDlg->move(0.5 * (HomePageWidth - m_deviceStateDlg->width()),
0.5 * (HomePageHeight - m_deviceStateDlg->height()));
}

@ -4,6 +4,8 @@
#include <QWidget>
#include <unordered_map>
#include "Src/HomePage/homepagesetingwidget.h"
#include "QPushButton"
#include "deviceStateDlg.h"
namespace Ui {
class HomePageDlg;
@ -18,7 +20,7 @@ public:
~HomePageDlg();
QPixmap m_pixmap;
HomePageSetingWidget* settingWidget;
deviceStateDlg* m_deviceStateDlg;
void getUrl(std::unordered_map<QString,QString>& urlMap);
private:
Ui::HomePageDlg *ui;
@ -29,6 +31,10 @@ private:
QString _adHocNetwork;
QString _satelliteComm;
std::unordered_map<QString,QString> _urlMap;
QPushButton* m_settingBtn;
protected:
void resizeEvent(QResizeEvent *event);
signals:
void sendUrl(std::unordered_map<QString,QString> urlMap);
private slots:

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>892</width>
<height>653</height>
<width>940</width>
<height>460</height>
</rect>
</property>
<property name="minimumSize">
@ -20,60 +20,13 @@
<string>Form</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="1" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>GroupBox</string>
</property>
</widget>
</item>
<item row="0" column="3">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QWidget" name="widget" native="true">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="image" native="true">
<property name="toolTip">
<string/>
</property>
<property name="statusTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="whatsThis">
<string/>
</property>
<property name="styleSheet">
<string notr="true">image: url(:/res/981csNew.png);</string>
</property>
</widget>
</item>
<item>
<widget class="QWidget" name="widget_2" native="true"/>
</item>
</layout>
</widget>
</item>
</layout>
</item>
<item row="1" column="1">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>GroupBox</string>
<widget class="QFrame" name="frame">
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QGroupBox" name="groupBox_4">
<property name="title">
<string>GroupBox</string>
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
</widget>
</item>

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>725</width>
<height>443</height>
<height>404</height>
</rect>
</property>
<property name="windowTitle">
@ -17,15 +17,9 @@
<iconset resource="../../mainwindow.qrc">
<normaloff>:/res/settings.png</normaloff>:/res/settings.png</iconset>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QFrame" name="frame_2">
<property name="geometry">
<rect>
<x>30</x>
<y>10</y>
<width>661</width>
<height>181</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Shape::StyledPanel</enum>
</property>
@ -41,27 +35,27 @@
<property name="frameShadow">
<enum>QFrame::Shadow::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QGroupBox" name="lLinkGroupBox">
<widget class="QGroupBox" name="netGroupBox_2">
<property name="title">
<string>L链</string>
<string>卫通</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QLabel" name="label">
<widget class="QLabel" name="label_3">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="lLinkLineEdit"/>
<widget class="QLineEdit" name="sateliteLineEdit"/>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
@ -70,17 +64,29 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="lLinkButton">
<property name="maximumSize">
<widget class="QPushButton" name="sateliteButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
@ -100,7 +106,17 @@
<string>宽带自组网</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="4" column="1">
<item row="0" column="1">
<widget class="QLineEdit" name="netLineEdit"/>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<spacer name="horizontalSpacer_2">
@ -112,7 +128,7 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<width>20</width>
<height>20</height>
</size>
</property>
@ -120,9 +136,21 @@
</item>
<item>
<widget class="QPushButton" name="netButton">
<property name="maximumSize">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
@ -133,39 +161,29 @@
</item>
</layout>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="netLineEdit"/>
</item>
</layout>
</widget>
</item>
<item>
<widget class="QGroupBox" name="netGroupBox_2">
<widget class="QGroupBox" name="lLinkGroupBox">
<property name="title">
<string>卫通</string>
<string>L链</string>
</property>
<layout class="QGridLayout" name="gridLayout_3">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QLabel" name="label_3">
<widget class="QLabel" name="label">
<property name="text">
<string>IP:</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="sateliteLineEdit"/>
<widget class="QLineEdit" name="lLinkLineEdit"/>
</item>
<item row="4" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item row="0" column="2">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<spacer name="horizontalSpacer_3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
@ -174,17 +192,29 @@
</property>
<property name="sizeHint" stdset="0">
<size>
<width>60</width>
<width>20</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QPushButton" name="sateliteButton">
<property name="maximumSize">
<widget class="QPushButton" name="lLinkButton">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>100</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>200</width>
<height>16777215</height>
</size>
</property>
@ -258,6 +288,8 @@
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<resources>
<include location="../../mainwindow.qrc"/>

@ -0,0 +1,42 @@
#include "networkDetection.h"
networkDetection::networkDetection(QObject *parent) : QObject(parent) {
flagRun = true;
CmdListChanged = false;
m_process = new QProcess(this);
}
networkDetection::~networkDetection() { delete m_process; }
void networkDetection::dowork(int id, QStringList cmdlist) {
m_cmd = cmdlist;
m_id = id;
QString result;
while (flagRun) {
m_process->start("cmd", m_cmd);
m_process->waitForFinished(); // 等待指令执行完毕
result = m_process->readAll(); // 获取指令执行结果
// qDebug() << result;
if (result.contains(QString("TTL="))) // 若包含TTL=字符串则认为网络在线
{
// qDebug() << "在线";
emit resultReady(m_id, "在线");
} else {
// qDebug() << "离线";
emit resultReady(m_id, "离线");
}
// if (CmdListChanged) {
// CmdListChanged = false;
// return;
// }
// QThread::sleep(2); // 加sleep降低CPU占用率
}
}
void networkDetection::stop() { flagRun = false; }
void networkDetection::DyChangeCmdList(QStringList changeCmdList) {
m_cmd.clear();
m_cmd = changeCmdList;
CmdListChanged = true;
}

@ -0,0 +1,35 @@
#ifndef NETWORKDETECTION_H
#define NETWORKDETECTION_H
#include <QDebug>
#include <QObject>
#include <QProcess>
#include <QThread>
// #include <synchapi.h>
class networkDetection : public QObject {
Q_OBJECT
public:
networkDetection(QObject *parent = nullptr);
~networkDetection();
public slots:
void dowork(int, QStringList);
void stop();
signals:
void resultReady(int, QString);
public:
void DyChangeCmdList(QStringList);
private:
int m_id;
QStringList m_cmd;
public:
bool flagRun; // 运行标志
bool CmdListChanged; // 指令列表改变标志
QProcess *m_process; // 执行CMD
};
#endif // NETWORKDETECTION_H

@ -51,4 +51,5 @@ void EncodeModelCamera::ReadData() {
if (crc16 == Rcrc) {
emit UDP_Receive(array);
}
cameraUDP->writeDatagram(cmdArray, QHostAddress("172.10.1.237"), 10001);
}

@ -1,151 +1,163 @@
#include "cffmpeg_decode.h"
Cffmpeg_decode::Cffmpeg_decode()
{
Cffmpeg_decode::Cffmpeg_decode() {
fmtCtx = avformat_alloc_context();
pkt = av_packet_alloc();
yuvFrame = av_frame_alloc();
rgbFrame = av_frame_alloc();
}
Cffmpeg_decode::~Cffmpeg_decode()
{
if(!pkt) av_packet_free(&pkt);
if(!yuvFrame) av_frame_free(&yuvFrame);
if(!rgbFrame) av_frame_free(&rgbFrame);
if(!videoCodecCtx) avcodec_free_context(&videoCodecCtx);
if(!videoCodecCtx) avcodec_close(videoCodecCtx);
if(!fmtCtx) avformat_close_input(&fmtCtx);
Cffmpeg_decode::~Cffmpeg_decode() {
if (!pkt)
av_packet_free(&pkt);
if (!yuvFrame)
av_frame_free(&yuvFrame);
if (!rgbFrame)
av_frame_free(&rgbFrame);
if (!videoCodecCtx)
avcodec_free_context(&videoCodecCtx);
if (!videoCodecCtx)
avcodec_close(videoCodecCtx);
if (!fmtCtx)
avformat_close_input(&fmtCtx);
}
void Cffmpeg_decode::setUrl(QString url)
{
_url = url;
}
void Cffmpeg_decode::setUrl(QString url) { _url = url; }
bool Cffmpeg_decode::open_input_file()
{
if(_url.isEmpty()) return 0;
bool Cffmpeg_decode::open_input_file() {
if (_url.isEmpty())
return 0;
AVDictionary* avdic = NULL;
av_dict_set(&avdic, "buffer_size", "2048000", 0); //设置缓存大小1080p可将值调大
av_dict_set(&avdic, "rtsp_transport", "udp", 0); //以udp方式打开如果以tcp方式打开将udp替换为tcp
av_dict_set(&avdic, "listen_timeout", "2", 0); //设置超时断开连接时间,单位微秒
av_dict_set(&avdic, "max_delay", "3000", 0); //设置最大时延
AVDictionary *avdic = NULL;
// 设置缓存大小1080p可将值调大
av_dict_set(&avdic, "buffer_size", "2048000", 0);
// 以udp方式打开如果以tcp方式打开将udp替换为tcp
av_dict_set(&avdic, "rtsp_transport", "tcp", 0);
// 设置超时断开连接时间,单位微秒//listen_timeout
// av_dict_set(&avdic, "listen_timeout", "200000", 0);
av_dict_set(&avdic, "stimeout", "200000", 0);
av_dict_set(&avdic, "max_delay", "3", 0); // 设置最大时延
av_dict_set(&avdic, "tune", "zerolatency", 0);
av_dict_set(&avdic, "preset", "ultrafast", 0);
fmtCtx->flags |= AVFMT_FLAG_NONBLOCK;
if(avformat_open_input(&fmtCtx,_url.toLocal8Bit().data(),NULL,&avdic)<0){
if (avformat_open_input(&fmtCtx, _url.toUtf8().data(), NULL, &avdic) < 0) {
printf("Cannot open input file.\n");
return 0;
}
if(avformat_find_stream_info(fmtCtx,NULL)<0){
if (avformat_find_stream_info(fmtCtx, NULL) < 0) {
printf("Cannot find any stream in file.\n");
return 0;
}
int streamCnt=fmtCtx->nb_streams;
for(int i=0;i<streamCnt;i++){
if(fmtCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO){
int streamCnt = fmtCtx->nb_streams;
for (int i = 0; i < streamCnt; i++) {
if (fmtCtx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
videoStreamIndex = i;
continue;
}
}
if(videoStreamIndex==-1){
if (videoStreamIndex == -1) {
printf("Cannot find video stream in file.\n");
return 0;
}
AVCodecParameters *videoCodecPara = fmtCtx->streams[videoStreamIndex]->codecpar;
AVCodecParameters *videoCodecPara =
fmtCtx->streams[videoStreamIndex]->codecpar;
if(!(videoCodec = avcodec_find_decoder(videoCodecPara->codec_id))){
if (!(videoCodec = avcodec_find_decoder(videoCodecPara->codec_id))) {
printf("Cannot find valid decode codec.\n");
return 0;
}
if(!(videoCodecCtx = avcodec_alloc_context3(videoCodec))){
if (!(videoCodecCtx = avcodec_alloc_context3(videoCodec))) {
printf("Cannot find valid decode codec context.\n");
return 0;
}
if(avcodec_parameters_to_context(videoCodecCtx,videoCodecPara)<0){
if (avcodec_parameters_to_context(videoCodecCtx, videoCodecPara) < 0) {
printf("Cannot initialize parameters.\n");
return 0;
}
if(avcodec_open2(videoCodecCtx,videoCodec,NULL)<0){
if (avcodec_open2(videoCodecCtx, videoCodec, NULL) < 0) {
printf("Cannot open codec.\n");
return 0;
}
img_ctx = sws_getContext(videoCodecCtx->width,
videoCodecCtx->height,
videoCodecCtx->pix_fmt,
videoCodecCtx->width,
videoCodecCtx->height,
AV_PIX_FMT_RGB32,
SWS_BICUBIC,NULL,NULL,NULL);
numBytes = av_image_get_buffer_size(AV_PIX_FMT_RGB32,videoCodecCtx->width,videoCodecCtx->height,1);
out_buffer = (unsigned char *)av_malloc(numBytes*sizeof(unsigned char));
int res = av_image_fill_arrays(
rgbFrame->data,rgbFrame->linesize,
out_buffer,AV_PIX_FMT_RGB32,
videoCodecCtx->width,videoCodecCtx->height,1);
if(res<0){
qDebug()<<"Fill arrays failed.";
img_ctx = sws_getContext(videoCodecCtx->width, videoCodecCtx->height,
videoCodecCtx->pix_fmt, videoCodecCtx->width,
videoCodecCtx->height, AV_PIX_FMT_RGB32, SWS_BICUBIC,
NULL, NULL, NULL);
numBytes = av_image_get_buffer_size(AV_PIX_FMT_RGB32, videoCodecCtx->width,
videoCodecCtx->height, 1);
out_buffer = (unsigned char *)av_malloc(numBytes * sizeof(unsigned char));
int res = av_image_fill_arrays(rgbFrame->data, rgbFrame->linesize, out_buffer,
AV_PIX_FMT_RGB32, videoCodecCtx->width,
videoCodecCtx->height, 1);
if (res < 0) {
qDebug() << "Fill arrays failed.";
return 0;
}
return true;
}
//线程里持续执行
void Cffmpeg_decode::run()
{
if(!open_input_file()){
qDebug()<<"Please open video file first.";
// 线程里持续执行
void Cffmpeg_decode::run() {
if (!open_input_file()) {
qDebug() << "Please open video file first.";
emit sendConnectFail(1);
IsstopPlay = true;
return;
}
while(av_read_frame(fmtCtx,pkt)>=0)
{
if(pkt->stream_index == videoStreamIndex){
if(avcodec_send_packet(videoCodecCtx,pkt)>=0){
while (av_read_frame(fmtCtx, pkt) >= 0) {
if (pkt->stream_index == videoStreamIndex) {
if (avcodec_send_packet(videoCodecCtx, pkt) >= 0) {
int ret;
while((ret=avcodec_receive_frame(videoCodecCtx,yuvFrame))>=0)
{
while ((ret = avcodec_receive_frame(videoCodecCtx, yuvFrame)) >= 0) {
if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
return;
else if (ret < 0) {
fprintf(stderr, "Error during decoding\n");
exit(1);
}
sws_scale(img_ctx,
yuvFrame->data,yuvFrame->linesize,
0,videoCodecCtx->height,
rgbFrame->data,rgbFrame->linesize);
sws_scale(img_ctx, yuvFrame->data, yuvFrame->linesize, 0,
videoCodecCtx->height, rgbFrame->data, rgbFrame->linesize);
QImage img(out_buffer,
videoCodecCtx->width,videoCodecCtx->height,
QImage img(out_buffer, videoCodecCtx->width, videoCodecCtx->height,
QImage::Format_RGB32);
emit sendQImage(img);
//int m_timeframe= ((double)videoCodecCtx->framerate.den / videoCodecCtx->framerate.num)*1000;
// int m_timeframe= ((double)videoCodecCtx->framerate.den /
// videoCodecCtx->framerate.num)*1000;
QThread::msleep(28);
}
}
av_packet_unref(pkt);
}
if(IsstopPlay)
{
if (IsstopPlay) {
break;
}
}
qDebug()<<"All video play done";
qDebug() << "All video play done";
}
// 退出
void Cffmpeg_decode::stop() {
IsstopPlay = true;
if (!pkt)
av_packet_free(&pkt);
if (!yuvFrame)
av_frame_free(&yuvFrame);
if (!rgbFrame)
av_frame_free(&rgbFrame);
if (!videoCodecCtx)
avcodec_free_context(&videoCodecCtx);
if (!videoCodecCtx)
avcodec_close(videoCodecCtx);
if (!fmtCtx)
avformat_close_input(&fmtCtx);
}

@ -1,68 +1,63 @@
#ifndef CFFMPEG_DECODE_H
#define CFFMPEG_DECODE_H
#include <QDebug>
#include <QImage>
#include <QWidget>
#include <QPaintEvent>
#include <QThread>
#include <QPainter>
#include <QDebug>
#include <QThread>
#include <QWidget>
extern "C"{
extern "C" {
#include "libavcodec/avcodec.h"
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/frame.h>
#include <libavutil/samplefmt.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
#include <libavutil/parseutils.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavutil/parseutils.h>
#include <libavutil/samplefmt.h>
#include <libswscale/swscale.h>
#include <libavformat/avformat.h>
}
//class Cffmpeg_decode: public QThread
class Cffmpeg_decode: public QObject
{
// class Cffmpeg_decode: public QThread
class Cffmpeg_decode : public QObject {
public:
explicit Cffmpeg_decode();
~Cffmpeg_decode();
Q_OBJECT
public:
void setUrl(QString url);
bool open_input_file();
bool IsstopPlay= false;
bool IsstopPlay = false;
void stop();
public slots:
void run();
signals:
void sendQImage(QImage);
void sendConnectFail(int);
private:
AVFormatContext *fmtCtx =NULL;
const AVCodec *videoCodec =NULL;
AVCodecContext *videoCodecCtx=NULL;
AVFormatContext *fmtCtx = NULL;
const AVCodec *videoCodec = NULL;
AVCodecContext *videoCodecCtx = NULL;
AVPacket *pkt = NULL;
AVFrame *yuvFrame = NULL;
AVFrame *rgbFrame = NULL;
struct SwsContext *img_ctx=NULL;
struct SwsContext *img_ctx = NULL;
unsigned char *out_buffer=nullptr;
unsigned char *out_buffer = nullptr;
int videoStreamIndex =-1;
int videoStreamIndex = -1;
int numBytes = -1;
QString _url;
};

@ -3,117 +3,99 @@
#include <QMessageBox>
ffmpegvideoDlg::ffmpegvideoDlg(QWidget *parent)
: QWidget(parent)
, ui(new Ui::ffmpegvideoDlg)
{
: QWidget(parent), ui(new Ui::ffmpegvideoDlg) {
ui->setupUi(this);
iniWindow();
}
ffmpegvideoDlg::~ffmpegvideoDlg()
{
ffmpegvideoDlg::~ffmpegvideoDlg() {
stop();
delete ui;
}
void ffmpegvideoDlg::iniWindow()
{
QString VideoFilePath = QDir::currentPath()+"./Video";
QDir VideoDir (VideoFilePath);
if(!VideoDir.exists())
{
void ffmpegvideoDlg::iniWindow() {
QString VideoFilePath = QDir::currentPath() + "./Video";
QDir VideoDir(VideoFilePath);
if (!VideoDir.exists()) {
VideoDir.mkdir(VideoFilePath);
qDebug()<<"文件夹创建成功";
qDebug() << "文件夹创建成功";
}
}
void ffmpegvideoDlg::setUrl(QString url)
{
ffmpeg->setUrl(url);
}
void ffmpegvideoDlg::setUrl(QString url) { ffmpeg->setUrl(url); }
void ffmpegvideoDlg::play()
{
if(!m_PlayStatus)
{
void ffmpegvideoDlg::play() {
if (!m_PlayStatus) {
m_PlayStatus = true;
ffmpeg = new Cffmpeg_decode;
ffmpeg->IsstopPlay = false;
ffmpeg->moveToThread(&workerThread);
connect(&workerThread,&QThread::finished,ffmpeg,&QObject::deleteLater); //线程发送结束标志
connect(this, &ffmpegvideoDlg::operate, ffmpeg, &Cffmpeg_decode::run); //线程开始处理数据
connect(ffmpeg,SIGNAL(sendQImage(QImage)),this,SLOT(receiveQImage(QImage))); //发送解析的图片
connect(ffmpeg,SIGNAL(sendConnectFail(int)),this,SLOT(showMessagBox(int))); //发送错误信息提示
connect(&workerThread, &QThread::finished, ffmpeg,
&QObject::deleteLater); // 线程发送结束标志
connect(this, &ffmpegvideoDlg::operate, ffmpeg,
&Cffmpeg_decode::run); // 线程开始处理数据
connect(ffmpeg, SIGNAL(sendQImage(QImage)), this,
SLOT(receiveQImage(QImage))); // 发送解析的图片
connect(ffmpeg, SIGNAL(sendConnectFail(int)), this,
SLOT(showMessagBox(int))); // 发送错误信息提示
workerThread.start();
emit this->operate(); //启用线程信号
emit this->operate(); // 启用线程信号
}
}
void ffmpegvideoDlg::stop()
{
if(m_PlayStatus)
{
void ffmpegvideoDlg::stop() {
if (m_PlayStatus) {
ffmpeg->stop();
m_PlayStatus = false;
ffmpeg->IsstopPlay = true; //线程结束标志
workerThread.quit(); //线程退出时自动delete线程里的类
ffmpeg->IsstopPlay = true; // 线程结束标志
workerThread.quit(); // 线程退出时自动delete线程里的类
workerThread.wait();
img.fill(Qt::black);
}
}
//绘图事件
void ffmpegvideoDlg::paintEvent(QPaintEvent *)
{
// 绘图事件
void ffmpegvideoDlg::paintEvent(QPaintEvent *) {
QPainter painter(this);
painter.drawImage(m_ax,m_ay,img);
painter.drawImage(m_ax, m_ay, img);
}
//区域大小改变事件
void ffmpegvideoDlg::resizeEvent(QResizeEvent *event)
{
//区域1920*1080自适应
// 区域大小改变事件
void ffmpegvideoDlg::resizeEvent(QResizeEvent *event) {
// 区域1920*1080自适应
double VideoAreaHeight = this->height();
double VideoAreaWidth = this->width();
//高度值相对比较大
if(VideoAreaHeight*16>VideoAreaWidth*9)
{
// 高度值相对比较大
if (VideoAreaHeight * 16 > VideoAreaWidth * 9) {
m_setVideoAreaWidth = VideoAreaWidth;
m_setVideoAreaHeight = VideoAreaWidth*9/16;
m_setVideoAreaHeight = VideoAreaWidth * 9 / 16;
m_ax = 0;
m_ay = 0.5*(VideoAreaHeight-m_setVideoAreaHeight);
m_ay = 0.5 * (VideoAreaHeight - m_setVideoAreaHeight);
}
//宽度值相对比较大
else
{
// 宽度值相对比较大
else {
m_setVideoAreaHeight = VideoAreaHeight;
m_setVideoAreaWidth = VideoAreaHeight*16/9;
m_ax = 0.5*(VideoAreaWidth-m_setVideoAreaWidth);
m_setVideoAreaWidth = VideoAreaHeight * 16 / 9;
m_ax = 0.5 * (VideoAreaWidth - m_setVideoAreaWidth);
m_ay = 0;
}
}
void ffmpegvideoDlg::receiveQImage(const QImage &rImg)
{
void ffmpegvideoDlg::receiveQImage(const QImage &rImg) {
//img = rImg.scaled(this->size());
QSize imgsize(m_setVideoAreaWidth,m_setVideoAreaHeight);
// img = rImg.scaled(this->size());
QSize imgsize(m_setVideoAreaWidth, m_setVideoAreaHeight);
img = rImg.scaled(imgsize);
update();
}
//显示不同提示消息
void ffmpegvideoDlg::showMessagBox(int type)
{
// 显示不同提示消息
void ffmpegvideoDlg::showMessagBox(int type) {
switch (type) {
case 1:
QMessageBox::information(NULL,tr("提示"),"获取视频失败",QMessageBox::Ok);
QMessageBox::information(NULL, tr("提示"), "获取视频失败", QMessageBox::Ok);
break;
default:
break;
}
}
bool ffmpegvideoDlg::Isplay(bool IsstopPlay)
{
bool ffmpegvideoDlg::Isplay(bool IsstopPlay) {
return ffmpeg->IsstopPlay = IsstopPlay;
}

@ -1,27 +1,26 @@
#ifndef FFMPEGVIDEODLG_H
#define FFMPEGVIDEODLG_H
#include "cffmpeg_decode.h"
#include <QDebug>
#include <QDir>
#include <QImage>
#include <QWidget>
#include <QPaintEvent>
#include <QThread>
#include <QPainter>
#include <QDebug>
#include <QDir>
#include "cffmpeg_decode.h"
#include <QThread>
#include <QWidget>
extern "C"{
extern "C" {
#include <libavcodec/avcodec.h>
#include <libavutil/channel_layout.h>
#include <libavutil/common.h>
#include <libavutil/frame.h>
#include <libavutil/samplefmt.h>
#include <libavutil/opt.h>
#include <libavutil/imgutils.h>
#include <libavutil/parseutils.h>
#include <libavutil/mem.h>
#include <libavutil/opt.h>
#include <libavutil/parseutils.h>
#include <libavutil/samplefmt.h>
#include <libswscale/swscale.h>
@ -32,8 +31,7 @@ namespace Ui {
class ffmpegvideoDlg;
}
class ffmpegvideoDlg : public QWidget
{
class ffmpegvideoDlg : public QWidget {
Q_OBJECT
public:
@ -43,16 +41,14 @@ public:
private:
Ui::ffmpegvideoDlg *ui;
public:
void iniWindow();
void setUrl(QString url);
void play();
void stop();
bool Isplay(bool IsstopPlay);
bool m_PlayStatus =false;
bool m_PlayStatus = false;
double m_setVideoAreaWidth;
double m_setVideoAreaHeight;

@ -1,20 +1,17 @@
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include "Src/WebPage/cwebengineview.h"
#include "Src/HomePage/homepagesetingwidget.h"
#include "Src/WebPage/CustomWebEnginePage.h"
#include "Src/WebPage/cwebengineview.h"
#include "global.h"
#include <QToolBar>
#include <QFlags>
#include "ui_mainwindow.h"
#include <QAction>
#include <QFile>
#include <QFlags>
#include <QToolBar>
#include <qpushbutton.h>
#include <QAction>
#include "Src/HomePage/homepagesetingwidget.h"
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, mWeb(nullptr)
{
: QMainWindow(parent), ui(new Ui::MainWindow), mWeb(nullptr) {
ui->setupUi(this);
initFile();
@ -25,76 +22,71 @@ MainWindow::MainWindow(QWidget *parent)
initSignalSlot();
process = new QProcess(this);
//apply the qss
// apply the qss
QFile file(":/res/Qss/qss.qss");
if(file.open(QFile::ReadOnly))
{
//file.open(QFile::ReadOnly);
if (file.open(QFile::ReadOnly)) {
// file.open(QFile::ReadOnly);
QString style = QLatin1String(file.readAll());
qApp->setStyleSheet(style);
// qDebug()<<style;
file.close();
}
else
{
} else {
qDebug()<<"Open file fail "<<Qt::endl;
qDebug() << "Open file fail " << Qt::endl;
}
QString appDir = QCoreApplication::applicationDirPath()+"/app";
QString appDir = QCoreApplication::applicationDirPath() + "/app";
qDebug()<<"Open file fail "<<appDir;
qDebug() << "Open file fail " << appDir;
}
MainWindow::~MainWindow()
{
MainWindow::~MainWindow() {
delete m_SDFPDlg;
delete m_GDDCdlg;
delete m_HomePagedlg;
delete mWeb;
delete process;
delete ui;
if(m_ModelCameraDlg!=nullptr) delete m_ModelCameraDlg;
if (m_ModelCameraDlg != nullptr)
delete m_ModelCameraDlg;
}
/**
* @brief MainWindow::initFile .ini
*/
void MainWindow::initFile()
{
QString urlFile = QCoreApplication::applicationDirPath()+"/config.ini";
void MainWindow::initFile() {
QString urlFile = QCoreApplication::applicationDirPath() + "/config.ini";
QFile file(urlFile);
if(!file.open(QIODevice::ReadWrite))
{
if (!file.open(QIODevice::ReadWrite)) {
return;
}
}
void MainWindow::initWindow()
{
void MainWindow::initWindow() {
setWindowIcon(QIcon(":/res/SDFP.png"));
//设置主窗口背景颜色
// 设置主窗口背景颜色
QPalette palette;
palette.setColor(QPalette::Window,g_themeColor);
palette.setColor(QPalette::Window, g_themeColor);
this->setPalette(palette);
this->setWindowTitle("载荷应用软件");
this->resize(1450,860);
//this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);//隐藏边框
this->resize(1450, 860);
// this->setWindowFlags(Qt::Window | Qt::FramelessWindowHint);//隐藏边框
m_SDFPDlg = new SDFPDlg(this);
m_GDDCdlg = new GDDCdlg(this);
m_HomePagedlg = new HomePageDlg(this);
m_ModelCameraDlg = new ModelCameraDlg(this);
m_rescueLoadWidget = new RescueLoadWidget(this);
//使用信号槽函数获取配置文件中的IP
connect(m_HomePagedlg, &HomePageDlg::sendUrl, this, [](std::unordered_map<QString,QString> urlMap){
// 使用信号槽函数获取配置文件中的IP
connect(m_HomePagedlg, &HomePageDlg::sendUrl, this,
[](std::unordered_map<QString, QString> urlMap) {
qDebug() << "L链" << urlMap["L链"];
qDebug() << "宽带自组网" << urlMap["宽带自组网"];
qDebug() << "机载卫通" << urlMap["机载卫通"];
});
//使用类中的get方法获取配置文件中的IP
// 使用类中的get方法获取配置文件中的IP
m_HomePagedlg->getUrl(m_urlMap);
qDebug() << "=============设备配置================";
@ -118,8 +110,9 @@ void MainWindow::initWindow()
satelliteCommWeb->setPage(new CustomWebEnginePage());
satelliteCommWeb->load(QUrl(m_urlMap["机载卫通"]));
//接收主页面设置窗口的url数据传递并设置
connect(m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendOnlyUrl, this, [&](unsigned char urlIndex, QString url){
// 接收主页面设置窗口的url数据传递并设置
connect(m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendOnlyUrl,
this, [&](unsigned char urlIndex, QString url) {
switch (urlIndex) {
case HomePageSetingWidget::L_Link:
lLinkWeb->load(QUrl(url));
@ -135,8 +128,9 @@ void MainWindow::initWindow()
}
});
//接收主页面设置窗口的url数据传递并设置 一键设置
connect(m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendAllUrl, this, [&](std::unordered_map<QString,QString> urlMap){
// 接收主页面设置窗口的url数据传递并设置 一键设置
connect(m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendAllUrl, this,
[&](std::unordered_map<QString, QString> urlMap) {
lLinkWeb->load(QUrl(urlMap["L链"]));
adHocNetworkWeb->load(QUrl(urlMap["宽带自组网"]));
satelliteCommWeb->load(QUrl(urlMap["机载卫通"]));
@ -153,10 +147,8 @@ void MainWindow::initWindow()
ui->stackedWidget->addWidget(m_ModelCameraDlg);
// 初始栈窗口显示主页
ui->stackedWidget->setCurrentWidget(m_SDFPDlg);
}
void MainWindow::initButton()
{
void MainWindow::initButton() {
int sizeX = 30;
int sizeY = 30;
int FixedWidth = 80;
@ -169,15 +161,15 @@ void MainWindow::initButton()
ui->toolButton_7->setIcon(QIcon(":/res/research.png"));
ui->toolButton_8->setIcon(QIcon(":/res/3D.png"));
ui->toolButton_9->setIcon(QIcon(":/res/SDFP3.png"));
ui->toolButton->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_2->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_3->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_4->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_5->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_6->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_7->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_8->setIconSize(QSize(sizeX,sizeY));
ui->toolButton_9->setIconSize(QSize(sizeX*1.2,sizeY*1.2));
ui->toolButton->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_2->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_3->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_4->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_5->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_6->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_7->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_8->setIconSize(QSize(sizeX, sizeY));
ui->toolButton_9->setIconSize(QSize(sizeX * 1.2, sizeY * 1.2));
ui->toolButton->setText("主页");
ui->toolButton_2->setText("光电吊舱");
ui->toolButton_3->setText("L链");
@ -214,11 +206,9 @@ void MainWindow::initButton()
ui->toolButton_7->setStyleSheet(g_ToolBtnStyle);
ui->toolButton_8->setStyleSheet(g_ToolBtnStyle);
ui->toolButton_9->setStyleSheet(g_ToolBtnStyle);
//ui->pushButton->setStyleSheet(g_PushBtnStyle);
// ui->pushButton->setStyleSheet(g_PushBtnStyle);
}
void MainWindow::initMenuBar()
{
void MainWindow::initMenuBar() {
// QMenuBar *menuBar = new QMenuBar(this);
// this->setMenuBar(menuBar);
@ -239,23 +229,26 @@ void MainWindow::initMenuBar()
// menuBar->addMenu(menu7);
// menuBar->setStyleSheet("QMenuBar{color:rgb(255,255,255);background:rgb(0,0,0);}");//设置颜色
}
void MainWindow::initToolBar()
{
void MainWindow::initToolBar() {
// QToolBar *toolBar = new QToolBar("toolBar",this);
// this->addToolBar(Qt::LeftToolBarArea,toolBar);
// toolBar->setFloatable(false);//设置可浮动
// toolBar->setMovable(true);//可移动
// //QAction *actionToolBar = new QAction(/*QIcon("res/主页.png"),*/"主页",this);
// QAction *actionToolBar = new QAction(QIcon(":/res/SDFP.png"),"主 页",this);
// QAction *actionToolBar2 = new QAction(QIcon(":/res/GDDC.png"),"光电吊舱",this);
// QAction *actionToolBar3 = new QAction(QIcon(":/res/LChain.png"),"L 链",this);
// QAction *actionToolBar4 = new QAction(QIcon(":/res/adHoc.png"),"自组网 ",this);
// QAction *actionToolBar5 = new QAction(QIcon(":/res/PDTColony.png"),"PDT集群",this);
// QAction *actionToolBar6 = new QAction(QIcon(":/res/Kusatellite.png"),"Ku卫通",this);
// QAction *actionToolBar7 = new QAction(QIcon(":/res/SearchPayload.png"),"搜集载荷",this);
// QAction *actionToolBar8 = new QAction(QIcon(":/res/3DModeling.png"),"三维建模",this);
// //QAction *actionToolBar = new
// QAction(/*QIcon("res/主页.png"),*/"主页",this); QAction *actionToolBar =
// new QAction(QIcon(":/res/SDFP.png"),"主 页",this); QAction *actionToolBar2
// = new QAction(QIcon(":/res/GDDC.png"),"光电吊舱",this); QAction
// *actionToolBar3 = new QAction(QIcon(":/res/LChain.png"),"L 链",this);
// QAction *actionToolBar4 = new QAction(QIcon(":/res/adHoc.png"),"自组网
// ",this); QAction *actionToolBar5 = new
// QAction(QIcon(":/res/PDTColony.png"),"PDT集群",this); QAction
// *actionToolBar6 = new
// QAction(QIcon(":/res/Kusatellite.png"),"Ku卫通",this); QAction
// *actionToolBar7 = new
// QAction(QIcon(":/res/SearchPayload.png"),"搜集载荷",this); QAction
// *actionToolBar8 = new
// QAction(QIcon(":/res/3DModeling.png"),"三维建模",this);
// toolBar->addAction(actionToolBar);
// toolBar->addAction(actionToolBar2);
@ -292,111 +285,135 @@ void MainWindow::initToolBar()
/*"QAction:hover{background-color:white; color: green;}"*/
/*"QAction:pressed{background-color:rgb(100, 100, 100);}");*/
}
//初始化信号与槽
void MainWindow::initSignalSlot()
{
connect(ui->toolButton,SIGNAL(clicked()),this,SLOT(toolButton_clicked()));
connect(ui->toolButton_2,SIGNAL(clicked()),this,SLOT(toolButton_2_clicked()));
connect(ui->toolButton_3,SIGNAL(clicked()),this,SLOT(toolButton_3_clicked()));
connect(ui->toolButton_4,SIGNAL(clicked()),this,SLOT(toolButton_4_clicked()));
connect(ui->toolButton_5,SIGNAL(clicked()),this,SLOT(toolButton_5_clicked()));
connect(ui->toolButton_6,SIGNAL(clicked()),this,SLOT(toolButton_6_clicked()));
connect(ui->toolButton_7,SIGNAL(clicked()),this,SLOT(toolButton_7_clicked()));
connect(ui->toolButton_8,SIGNAL(clicked()),this,SLOT(toolButton_8_clicked()));
connect(ui->toolButton_9,SIGNAL(clicked()),this,SLOT(toolButton_9_clicked()));
// 初始化信号与槽
void MainWindow::initSignalSlot() {
connect(ui->toolButton, SIGNAL(clicked()), this, SLOT(toolButton_clicked()));
connect(ui->toolButton_2, SIGNAL(clicked()), this,
SLOT(toolButton_2_clicked()));
connect(ui->toolButton_3, SIGNAL(clicked()), this,
SLOT(toolButton_3_clicked()));
connect(ui->toolButton_4, SIGNAL(clicked()), this,
SLOT(toolButton_4_clicked()));
connect(ui->toolButton_5, SIGNAL(clicked()), this,
SLOT(toolButton_5_clicked()));
connect(ui->toolButton_6, SIGNAL(clicked()), this,
SLOT(toolButton_6_clicked()));
connect(ui->toolButton_7, SIGNAL(clicked()), this,
SLOT(toolButton_7_clicked()));
connect(ui->toolButton_8, SIGNAL(clicked()), this,
SLOT(toolButton_8_clicked()));
connect(ui->toolButton_9, SIGNAL(clicked()), this,
SLOT(toolButton_9_clicked()));
connect(m_HomePagedlg->m_deviceStateDlg, &deviceStateDlg::switchToDevicePage,
this, [&](int id) {
switch (id) {
case 0:
toolButton_2_clicked(); // 光电吊舱
break;
case 1:
toolButton_3_clicked(); // L链
break;
case 2:
toolButton_4_clicked(); // 自组网
break;
case 3:
toolButton_5_clicked(); // PDT集群
break;
case 4:
toolButton_6_clicked(); // Ku卫通
break;
case 5:
toolButton_7_clicked(); // 搜救载荷
break;
case 6:
toolButton_8_clicked(); // 三维建模
break;
default:
break;
}
});
}
//主页
void MainWindow::toolButton_clicked()
{
// 主页
void MainWindow::toolButton_clicked() {
changeBtnColor(1);
//m_HomePagedlg->move(130,80);
// m_HomePagedlg->move(130,80);
ui->stackedWidget->setCurrentWidget(m_HomePagedlg);
process->kill();
}
//光电吊舱
void MainWindow::toolButton_2_clicked()
{
// 光电吊舱
void MainWindow::toolButton_2_clicked() {
changeBtnColor(2);
//m_GDDCdlg->move(130,80);
//m_GDDCdlg->show(); //显示窗口
// m_GDDCdlg->move(130,80);
// m_GDDCdlg->show(); //显示窗口
ui->stackedWidget->setCurrentWidget(m_GDDCdlg);
}
//L链
void MainWindow::toolButton_3_clicked()
{
// L链
void MainWindow::toolButton_3_clicked() {
changeBtnColor(3);
// mWeb->load(QUrl("http://192.168.1.10"));
ui->stackedWidget->setCurrentWidget(lLinkWeb);
}
//自组网
void MainWindow::toolButton_4_clicked()
{
// 自组网
void MainWindow::toolButton_4_clicked() {
changeBtnColor(4);
// mWeb->load(QUrl("http://192.168.1.10"));
// mWeb->show();
ui->stackedWidget->setCurrentWidget(adHocNetworkWeb);
//process->kill();
// process->kill();
}
//PDT集群
void MainWindow::toolButton_5_clicked()
{
// PDT集群
void MainWindow::toolButton_5_clicked() {
changeBtnColor(5);
// mWeb->load(QUrl("http://192.168.150.1"));
// mWeb->show();
ui->stackedWidget->setCurrentWidget(mWeb);
}
//Ku卫通
void MainWindow::toolButton_6_clicked()
{
// Ku卫通
void MainWindow::toolButton_6_clicked() {
changeBtnColor(6);
// mWeb->load(QUrl("http://192.168.0.2"));
// mWeb->show();
ui->stackedWidget->setCurrentWidget(satelliteCommWeb);
}
//搜救载荷
void MainWindow::toolButton_7_clicked()
{
// 搜救载荷
void MainWindow::toolButton_7_clicked() {
changeBtnColor(7);
ui->stackedWidget->setCurrentWidget(m_rescueLoadWidget);
}
//三维建模
void MainWindow::toolButton_8_clicked()
{
// 三维建模
void MainWindow::toolButton_8_clicked() {
changeBtnColor(8);
ui->stackedWidget->setCurrentWidget(m_ModelCameraDlg);
//ui->stackedWidget->setCurrentWidget(mWeb);
//process->setWorkingDirectory("D:/QTdemo/playerApp/app"); // 设置工作目录
//process->start("D:/QTdemo/playerApp/app/XCOM V2.0.exe"); // 启动exe并传递参数
// ui->stackedWidget->setCurrentWidget(mWeb);
// process->setWorkingDirectory("D:/QTdemo/playerApp/app"); // 设置工作目录
// process->start("D:/QTdemo/playerApp/app/XCOM V2.0.exe"); //
// 启动exe并传递参数
//process->setWorkingDirectory("D:/Software/TCPUDPDbg"); // 设置工作目录
//process->start("D:/Software/TCPUDPDbg/TCPUDPDbg.exe"); // 启动exe并传递参数
// process->setWorkingDirectory("D:/Software/TCPUDPDbg"); // 设置工作目录
// process->start("D:/Software/TCPUDPDbg/TCPUDPDbg.exe"); // 启动exe并传递参数
}
//时代飞鹏
void MainWindow::toolButton_9_clicked()
{
// 时代飞鹏
void MainWindow::toolButton_9_clicked() {
changeBtnColor(9);
ui->stackedWidget->setCurrentWidget(m_SDFPDlg);
}
//更新主界面按钮颜色
void MainWindow::changeBtnColor(int num)
{
// 更新主界面按钮颜色
void MainWindow::changeBtnColor(int num) {
initButton();
switch (num)
{
switch (num) {
case 1:
ui->toolButton->setStyleSheet(g_ToolBtnSelStyle);
break;
@ -424,8 +441,5 @@ void MainWindow::changeBtnColor(int num)
case 9:
ui->toolButton_9->setStyleSheet(g_ToolBtnSelStyle);
break;
}
}

@ -20,5 +20,15 @@
<file>res/SDFP2.png</file>
<file>res/SDFP3.png</file>
<file>res/settings2.png</file>
<file>res/lamp/black.png</file>
<file>res/lamp/blue.png</file>
<file>res/lamp/green.png</file>
<file>res/lamp/grey.png</file>
<file>res/lamp/grey1.png</file>
<file>res/lamp/grey3.png</file>
<file>res/lamp/orange.png</file>
<file>res/lamp/red.png</file>
<file>res/lamp/white.png</file>
<file>res/lamp/yellow.png</file>
</qresource>
</RCC>

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1113</width>
<height>416</height>
<width>829</width>
<height>497</height>
</rect>
</property>
<property name="sizePolicy">

Binary file not shown.

After

Width:  |  Height:  |  Size: 839 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 817 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 837 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 838 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 854 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 760 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 863 B

Loading…
Cancel
Save