You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
442 lines
15 KiB
C++
442 lines
15 KiB
C++
#include "mainwindow.h"
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <QAction>
|
|
#include <QFile>
|
|
#include <QFlags>
|
|
#include <QJsonArray>
|
|
#include <QJsonDocument>
|
|
#include <QJsonObject>
|
|
#include <QNetworkCookie>
|
|
#include <QToolBar>
|
|
#include <QWebEngineCookieStore>
|
|
#include <QWebEngineProfile>
|
|
|
|
#include "Src/HomePage/homepagesetingwidget.h"
|
|
#include "Src/WebPage/CustomWebEnginePage.h"
|
|
#include "Src/WebPage/cwebengineview.h"
|
|
#include "global.h"
|
|
#include "ui_mainwindow.h"
|
|
|
|
MainWindow::MainWindow(QWidget *parent)
|
|
: QMainWindow(parent), ui(new Ui::MainWindow) {
|
|
ui->setupUi(this);
|
|
|
|
initFile();
|
|
initWindow();
|
|
initButton();
|
|
initSignalSlot();
|
|
processPDT = new QProcess(this);
|
|
// apply the qss
|
|
QFile file(":/res/Qss/qss.qss");
|
|
if (file.open(QFile::ReadOnly)) {
|
|
// file.open(QFile::ReadOnly);
|
|
QString style = QLatin1String(file.readAll());
|
|
|
|
qApp->setStyleSheet(style);
|
|
// qDebug()<<style;
|
|
file.close();
|
|
} else {
|
|
qDebug() << "Open file fail " << Qt::endl;
|
|
}
|
|
|
|
QString appDir = QCoreApplication::applicationDirPath() + "/app";
|
|
qDebug() << "Open file fail " << appDir;
|
|
|
|
initUAVIDMap();
|
|
initNotifyManager();
|
|
}
|
|
|
|
MainWindow::~MainWindow() {
|
|
delete m_SDFPDlg;
|
|
delete m_GDDCdlg;
|
|
delete m_HomePagedlg;
|
|
// delete processPDT;
|
|
// delete mWeb;
|
|
delete lLinkWeb;
|
|
delete adHocNetworkWeb;
|
|
delete satelliteCommWeb;
|
|
if (m_ModelCameraDlg != nullptr) delete m_ModelCameraDlg;
|
|
if (processPDT != nullptr) {
|
|
if (processPDT->state() == QProcess::NotRunning) processPDT->kill();
|
|
processPDT->deleteLater();
|
|
}
|
|
delete ui;
|
|
}
|
|
/**
|
|
* @brief MainWindow::initFile 初始化配置文件 .ini
|
|
*/
|
|
void MainWindow::initFile() {
|
|
QString urlFile = QCoreApplication::applicationDirPath() + "/config.ini";
|
|
QFile file(urlFile);
|
|
if (!file.open(QIODevice::ReadWrite)) {
|
|
return;
|
|
}
|
|
}
|
|
void MainWindow::initWindow() {
|
|
setWindowIcon(QIcon(":/res/SDFP3.png"));
|
|
|
|
// 设置主窗口背景颜色
|
|
QPalette palette;
|
|
palette.setColor(QPalette::Window, g_themeColor);
|
|
this->setPalette(palette);
|
|
this->setWindowTitle("载荷应用软件");
|
|
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_rescueLoadWidget = new RescueLoadWidget(this);
|
|
|
|
// 使用类中的get方法获取配置文件中的IP
|
|
m_allSetMap = m_HomePagedlg->settingWidget->getAllParam();
|
|
m_GDDCdlg->setGlobalSetMap(m_allSetMap);
|
|
/*qDebug() << "=============设备配置================";
|
|
qDebug() << "光电吊舱------";
|
|
qDebug() << "远端ip" << m_allSetMap["光电吊舱"].net.remoteIp;
|
|
qDebug() << "L链----------";
|
|
qDebug() << "ULR:" << m_allSetMap["L链"].url;
|
|
qDebug() << "宽带自组网-----";
|
|
qDebug() << "URL:" << m_allSetMap["宽带自组网"].url;
|
|
qDebug() << "机载卫通------";
|
|
qDebug() << "URL:" << m_allSetMap["机载卫通"].url;
|
|
qDebug() << "三维建模------";
|
|
qDebug() << "远端ip:" << m_allSetMap["三维建模"].net.remoteIp;
|
|
qDebug() << "远端端口:" << m_allSetMap["三维建模"].net.remotePort;
|
|
qDebug() << "本地ip:" << m_allSetMap["三维建模"].net.localIp;
|
|
qDebug() << "本地端口:" << m_allSetMap["三维建模"].net.localPort;*/
|
|
|
|
// mWeb = new CWebEngineView();
|
|
// mWeb->setPage(new CustomWebEnginePage());
|
|
// mWeb->load(QUrl("http://192.168.150.1"));
|
|
lLinkWeb = new CWebEngineView();
|
|
lLinkWeb->setPage(new CustomWebEnginePage());
|
|
lLinkWeb->load(QUrl(m_allSetMap["L-Link"].url));
|
|
connect(lLinkWeb->page(), &QWebEnginePage::loadFinished, this, [=]() {
|
|
// QString jsScript = R"(
|
|
// var usernameField =
|
|
// document.querySelector('input[name="username"]'); if
|
|
// (usernameField) {
|
|
// usernameField.value = 'admin'; // 填充用户名
|
|
// }
|
|
// )";
|
|
QString jsScript = R"(
|
|
var button = document.getElementById('clickButt');
|
|
if (button) {
|
|
button.onclick = function(event){
|
|
var usernameField =
|
|
document.querySelector('input[name="username"]');
|
|
if(usernameField) {
|
|
usernameField.value = 'admin'; // 填充用户名
|
|
}
|
|
}
|
|
}
|
|
)";
|
|
lLinkWeb->page()->runJavaScript(jsScript);
|
|
});
|
|
|
|
adHocNetworkWeb = new CWebEngineView();
|
|
adHocNetworkWeb->setPage(new CustomWebEnginePage());
|
|
adHocNetworkWeb->load(QUrl(m_allSetMap["HocNetwork"].url));
|
|
|
|
satelliteCommWeb = new CWebEngineView();
|
|
satelliteCommWeb->setPage(new CustomWebEnginePage());
|
|
satelliteCommWeb->load(QUrl(m_allSetMap["SatelliteComm"].url));
|
|
|
|
m_ModelCameraDlg = new ModelCameraDlg(this);
|
|
emit m_ModelCameraDlg->sendNetParam_signal(m_allSetMap["ModelCamera"].net);
|
|
// 接收主页面设置窗口的url数据传递并设置
|
|
connect(
|
|
m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendOneSet, this,
|
|
[&](unsigned char urlIndex, settingStruct settings) {
|
|
switch (urlIndex) {
|
|
case HomePageSetingWidget::GDDC:
|
|
// dosomething
|
|
m_GDDCdlg->m_DlgGDDCSet->initPullURL(settings.net.remoteIp);
|
|
break;
|
|
case HomePageSetingWidget::L_Link:
|
|
lLinkWeb->load(QUrl(settings.url));
|
|
break;
|
|
case HomePageSetingWidget::Adhoc_Network:
|
|
adHocNetworkWeb->load(QUrl(settings.url));
|
|
break;
|
|
case HomePageSetingWidget::Satelite_Comm:
|
|
satelliteCommWeb->load(QUrl(settings.url));
|
|
break;
|
|
case HomePageSetingWidget::ModelCamera:
|
|
m_ModelCameraDlg->sendNetParam_signal(settings.net);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
|
|
// 设置栈窗口,多页面共享同一窗口
|
|
ui->stackedWidget->addWidget(m_SDFPDlg);
|
|
ui->stackedWidget->addWidget(m_HomePagedlg);
|
|
ui->stackedWidget->addWidget(m_GDDCdlg);
|
|
// ui->stackedWidget->addWidget(mWeb);
|
|
ui->stackedWidget->addWidget(lLinkWeb);
|
|
ui->stackedWidget->addWidget(adHocNetworkWeb);
|
|
ui->stackedWidget->addWidget(satelliteCommWeb);
|
|
ui->stackedWidget->addWidget(m_rescueLoadWidget);
|
|
ui->stackedWidget->addWidget(m_ModelCameraDlg);
|
|
// 初始栈窗口显示主页
|
|
ui->stackedWidget->setCurrentWidget(m_SDFPDlg);
|
|
}
|
|
|
|
void MainWindow::initButton() {
|
|
int sizeX = 30;
|
|
int sizeY = 30;
|
|
int FixedWidth = 80;
|
|
ui->toolButton->setIcon(QIcon(":/res/home.png"));
|
|
ui->toolButton_2->setIcon(QIcon(":/res/GDDC.png"));
|
|
ui->toolButton_3->setIcon(QIcon(":/res/LChain.png"));
|
|
ui->toolButton_4->setIcon(QIcon(":/res/wifi4G.png"));
|
|
ui->toolButton_5->setIcon(QIcon(":/res/PDT.png"));
|
|
ui->toolButton_6->setIcon(QIcon(":/res/Ku.png"));
|
|
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->setText("主页");
|
|
ui->toolButton_2->setText("光电吊舱");
|
|
ui->toolButton_3->setText("L链");
|
|
ui->toolButton_4->setText("自组网");
|
|
ui->toolButton_5->setText("PDT集群");
|
|
ui->toolButton_6->setText("机载卫通");
|
|
ui->toolButton_7->setText("搜救载荷");
|
|
ui->toolButton_8->setText("三维建模");
|
|
ui->toolButton_9->setText("时代飞鹏");
|
|
ui->toolButton->setFixedWidth(FixedWidth);
|
|
ui->toolButton_2->setFixedWidth(FixedWidth);
|
|
ui->toolButton_3->setFixedWidth(FixedWidth);
|
|
ui->toolButton_4->setFixedWidth(FixedWidth);
|
|
ui->toolButton_5->setFixedWidth(FixedWidth);
|
|
ui->toolButton_6->setFixedWidth(FixedWidth);
|
|
ui->toolButton_7->setFixedWidth(FixedWidth);
|
|
ui->toolButton_8->setFixedWidth(FixedWidth);
|
|
ui->toolButton_9->setFixedWidth(FixedWidth);
|
|
ui->toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_2->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_3->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_4->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_5->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_6->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_7->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_8->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton_9->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
|
|
ui->toolButton->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_2->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_3->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_4->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_5->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_6->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_7->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_8->setStyleSheet(g_ToolBtnStyle);
|
|
ui->toolButton_9->setStyleSheet(g_ToolBtnStyle);
|
|
// ui->pushButton->setStyleSheet(g_PushBtnStyle);
|
|
}
|
|
|
|
// 初始化信号与槽
|
|
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() {
|
|
changeBtnColor(1);
|
|
ui->stackedWidget->setCurrentWidget(m_HomePagedlg);
|
|
}
|
|
|
|
// 光电吊舱
|
|
void MainWindow::toolButton_2_clicked() {
|
|
changeBtnColor(2);
|
|
ui->stackedWidget->setCurrentWidget(m_GDDCdlg);
|
|
}
|
|
|
|
// 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() {
|
|
changeBtnColor(4);
|
|
// mWeb->load(QUrl("http://192.168.1.10"));
|
|
// mWeb->show();
|
|
ui->stackedWidget->setCurrentWidget(adHocNetworkWeb);
|
|
}
|
|
|
|
// PDT集群
|
|
void MainWindow::toolButton_5_clicked() {
|
|
changeBtnColor(5);
|
|
|
|
QString pdtDirPath = QCoreApplication::applicationDirPath() + "/NMC7.0";
|
|
QString exePath = pdtDirPath + "/NMC.exe";
|
|
// qDebug() << "*********PDT Path:" << pdtDirPath;
|
|
processPDT->setWorkingDirectory(pdtDirPath); // 设置工作目录
|
|
processPDT->start(exePath); //
|
|
}
|
|
|
|
// Ku卫通
|
|
void MainWindow::toolButton_6_clicked() {
|
|
changeBtnColor(6);
|
|
ui->stackedWidget->setCurrentWidget(satelliteCommWeb);
|
|
}
|
|
|
|
// 搜救载荷
|
|
void MainWindow::toolButton_7_clicked() {
|
|
changeBtnColor(7);
|
|
ui->stackedWidget->setCurrentWidget(m_rescueLoadWidget);
|
|
}
|
|
|
|
// 三维建模
|
|
void MainWindow::toolButton_8_clicked() {
|
|
changeBtnColor(8);
|
|
ui->stackedWidget->setCurrentWidget(m_ModelCameraDlg);
|
|
}
|
|
// 时代飞鹏
|
|
void MainWindow::toolButton_9_clicked() {
|
|
changeBtnColor(9);
|
|
ui->stackedWidget->setCurrentWidget(m_SDFPDlg);
|
|
}
|
|
|
|
// 更新主界面按钮颜色
|
|
void MainWindow::changeBtnColor(int num) {
|
|
initButton();
|
|
switch (num) {
|
|
case 1:
|
|
ui->toolButton->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 2:
|
|
ui->toolButton_2->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 3:
|
|
ui->toolButton_3->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 4:
|
|
ui->toolButton_4->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 5:
|
|
ui->toolButton_5->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 6:
|
|
ui->toolButton_6->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 7:
|
|
ui->toolButton_7->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 8:
|
|
ui->toolButton_8->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
case 9:
|
|
ui->toolButton_9->setStyleSheet(g_ToolBtnSelStyle);
|
|
break;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @brief 初始化UAVID与推流APPName的映射关系
|
|
*/
|
|
void MainWindow::initUAVIDMap() {
|
|
// 内蒙
|
|
g_mapAppName[5] = "nmyj";
|
|
g_mapAppName[7] = "nmyj";
|
|
|
|
// 江苏
|
|
for (int i = 8; i < 13; ++i) {
|
|
g_mapAppName[i] = "jsyj";
|
|
}
|
|
// 河南
|
|
g_mapAppName[13] = "hnyj";
|
|
for (int i = 15; i < 23; ++i) {
|
|
g_mapAppName[i] = "hnyj";
|
|
}
|
|
g_mapAppName[25] = "hnyj";
|
|
g_mapAppName[26] = "hnyj";
|
|
|
|
// 测试
|
|
g_mapAppName[99] = "testyj";
|
|
}
|
|
|
|
void MainWindow::initNotifyManager() {
|
|
g_notifyManager = new NotifyManager(this, this);
|
|
g_notifyManager->setMaxCount(5);
|
|
g_notifyManager->setDisplayTime(2000);
|
|
g_notifyManager->setNotifyWndSize(300, 60);
|
|
}
|
|
|
|
bool MainWindow::nativeEvent(const QByteArray &eventType, void *message,
|
|
qintptr *result) {
|
|
#ifdef Q_OS_WIN
|
|
MSG *msg = (MSG *)message;
|
|
if (msg->message == WM_SYSCOMMAND) {
|
|
if (61587 == msg->wParam) { // 单击事件
|
|
return true;
|
|
}
|
|
if (61539 == msg->wParam) { // 双击事件
|
|
return true;
|
|
}
|
|
}
|
|
#endif
|
|
return QMainWindow::nativeEvent(eventType, message, result);
|
|
}
|