From 4ca024b018bb2a168e4b3fa36fd5347234a5eb46 Mon Sep 17 00:00:00 2001 From: wanghaoyu <1580258873@qq.com> Date: Thu, 15 Aug 2024 09:46:08 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=E4=B8=BB=E9=A1=B5=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AE=BE=E7=BD=AE=E6=8C=89=E9=92=AE=EF=BC=8C=E5=8F=AF=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E9=A1=B5=E9=9D=A2=E8=AF=BB=E5=8F=96=E7=9A=84url?= =?UTF-8?q?=EF=BC=8C=E5=AE=9E=E6=97=B6=E6=9B=B4=E6=96=B0=E5=B9=B6=E4=BF=9D?= =?UTF-8?q?=E5=AD=98=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HomePageDlg.qrc | 1 - PayloadAPP.pro | 9 +- .../HomePage/homepagedlg.cpp | 31 ++ homepagedlg.h => Src/HomePage/homepagedlg.h | 4 + homepagedlg.ui => Src/HomePage/homepagedlg.ui | 0 Src/HomePage/homepagesetingwidget.cpp | 83 ++++++ Src/HomePage/homepagesetingwidget.h | 47 ++++ Src/HomePage/homepagesetingwidget.ui | 266 ++++++++++++++++++ mainwindow.cpp | 26 +- mainwindow.h | 2 +- 10 files changed, 462 insertions(+), 7 deletions(-) delete mode 100644 HomePageDlg.qrc rename homepagedlg.cpp => Src/HomePage/homepagedlg.cpp (66%) rename homepagedlg.h => Src/HomePage/homepagedlg.h (85%) rename homepagedlg.ui => Src/HomePage/homepagedlg.ui (100%) create mode 100644 Src/HomePage/homepagesetingwidget.cpp create mode 100644 Src/HomePage/homepagesetingwidget.h create mode 100644 Src/HomePage/homepagesetingwidget.ui diff --git a/HomePageDlg.qrc b/HomePageDlg.qrc deleted file mode 100644 index 7646d2b..0000000 --- a/HomePageDlg.qrc +++ /dev/null @@ -1 +0,0 @@ - diff --git a/PayloadAPP.pro b/PayloadAPP.pro index f6b1c55..05f1bea 100644 --- a/PayloadAPP.pro +++ b/PayloadAPP.pro @@ -17,13 +17,14 @@ SOURCES += \ Src/GDDC/gddcCmdDlg.cpp \ Src/GDDC/gddcSet.cpp \ Src/GDDC/gddcStateInfo.cpp \ + Src/HomePage/homepagesetingwidget.cpp \ cffmpeg_decode.cpp \ customwebenginepage.cpp \ cwebengineview.cpp \ ffmpegvideodlg.cpp \ Src/GDDC/gddcdlg.cpp \ global.cpp \ - homepagedlg.cpp \ + Src/HomePage/homepagedlg.cpp \ main.cpp \ mainwindow.cpp \ qweb.cpp \ @@ -36,13 +37,14 @@ HEADERS += \ Src/GDDC/gddcSet.h \ Src/GDDC/gddcStateInfo.h \ Src/GDDC/structDefineMyslef.h \ + Src/HomePage/homepagesetingwidget.h \ cffmpeg_decode.h \ customwebenginepage.h \ cwebengineview.h \ ffmpegvideodlg.h \ Src/GDDC/gddcdlg.h \ global.h \ - homepagedlg.h \ + Src/HomePage/homepagedlg.h \ mainwindow.h \ qweb.h \ rescueload.h \ @@ -52,9 +54,10 @@ FORMS += \ Src/GDDC/gddcCmdDlg.ui \ Src/GDDC/gddcSet.ui \ Src/GDDC/gddcStateInfo.ui \ + Src/HomePage/homepagesetingwidget.ui \ ffmpegvideodlg.ui \ Src/GDDC/gddcdlg.ui \ - homepagedlg.ui \ + Src/HomePage/homepagedlg.ui \ mainwindow.ui \ qweb.ui \ rescueloadwidget.ui diff --git a/homepagedlg.cpp b/Src/HomePage/homepagedlg.cpp similarity index 66% rename from homepagedlg.cpp rename to Src/HomePage/homepagedlg.cpp index b6a0223..78326dd 100644 --- a/homepagedlg.cpp +++ b/Src/HomePage/homepagedlg.cpp @@ -1,6 +1,7 @@ #include "homepagedlg.h" #include "ui_homepagedlg.h" #include +#include #include HomePageDlg::HomePageDlg(QWidget *parent) @@ -18,7 +19,12 @@ HomePageDlg::HomePageDlg(QWidget *parent) //嵌入到主窗口 setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint); hide(); + + settingWidget = new HomePageSetingWidget(this); + settingWidget->setWindowFlags(Qt::Window); // 设置为独立窗口 + initSettingUrl(); + initButton(); } HomePageDlg::~HomePageDlg() @@ -54,6 +60,31 @@ void HomePageDlg::initSettingUrl() _urlMap.insert({"L链",_lLinkIp}); _urlMap.insert({"宽带自组网",_adHocNetwork}); _urlMap.insert({"机载卫通",_satelliteComm}); + + settingWidget->setUrl(_urlMap); +} +/** + * @brief 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); + + //点击主页按钮弹出设置页面 + connect(btn,&QPushButton::clicked,this,[&](){ + //qDebug() << "homepagedlg上的设置按钮点击了"; + if(settingWidget->isVisible()) + settingWidget->close(); + else + settingWidget->show(); + }); } void HomePageDlg::on_pushButton_clicked() diff --git a/homepagedlg.h b/Src/HomePage/homepagedlg.h similarity index 85% rename from homepagedlg.h rename to Src/HomePage/homepagedlg.h index c49ea6e..4e3ec79 100644 --- a/homepagedlg.h +++ b/Src/HomePage/homepagedlg.h @@ -3,6 +3,8 @@ #include #include +#include "Src/HomePage/homepagesetingwidget.h" + namespace Ui { class HomePageDlg; } @@ -15,11 +17,13 @@ public: explicit HomePageDlg(QWidget *parent = nullptr); ~HomePageDlg(); QPixmap m_pixmap; + HomePageSetingWidget* settingWidget; void getUrl(std::unordered_map& urlMap); private: Ui::HomePageDlg *ui; void initSettingUrl(); + void initButton(); QString _lLinkIp; QString _adHocNetwork; diff --git a/homepagedlg.ui b/Src/HomePage/homepagedlg.ui similarity index 100% rename from homepagedlg.ui rename to Src/HomePage/homepagedlg.ui diff --git a/Src/HomePage/homepagesetingwidget.cpp b/Src/HomePage/homepagesetingwidget.cpp new file mode 100644 index 0000000..d5dc648 --- /dev/null +++ b/Src/HomePage/homepagesetingwidget.cpp @@ -0,0 +1,83 @@ +#include "homepagesetingwidget.h" +#include "ui_homepagesetingwidget.h" + +HomePageSetingWidget::HomePageSetingWidget(QWidget *parent) + : QWidget(parent) + , ui(new Ui::HomePageSetingWidget) + , _lLinkIp(""), _adHocNetwork(""), _satelliteComm("") +{ + ui->setupUi(this); + urlFile = QCoreApplication::applicationDirPath()+"/config.ini"; + _configIni = std::make_unique(urlFile,QSettings::IniFormat); +} + +HomePageSetingWidget::~HomePageSetingWidget() +{ + delete ui; +} + +/** + * @brief HomePageSetingWidget::setUrl 初始话后从.ini文件中读取的数据显示 + * @param urlMap + */ +void HomePageSetingWidget::setUrl(std::unordered_map& urlMap) +{ + _lLinkIp = urlMap["L链"]; + _adHocNetwork = urlMap["宽带自组网"]; + _satelliteComm = urlMap["机载卫通"]; + initEdit(); +} + +/** + * @brief HomePageSetingWidget::initEdit 初始化Edit控件参数 + */ +void HomePageSetingWidget::initEdit() +{ + ui->lLinkLineEdit->setText(_lLinkIp); + ui->netLineEdit->setText(_adHocNetwork); + ui->sateliteLineEdit->setText(_satelliteComm); +} + +void HomePageSetingWidget::on_lLinkButton_clicked() +{ + //写参数到配置文件 + _lLinkIp = ui->lLinkLineEdit->text(); + _configIni->setValue("L链/IP", _lLinkIp); + emit sendOnlyUrl(L_Link,_lLinkIp); +} + +void HomePageSetingWidget::on_netButton_clicked() +{ + //写参数到配置文件 + _adHocNetwork = ui->netLineEdit->text(); + _configIni->setValue("宽带自组网/IP", _adHocNetwork); + emit sendOnlyUrl(Adhoc_Network,_adHocNetwork); +} + + +void HomePageSetingWidget::on_sateliteButton_clicked() +{ + //写参数到配置文件 + _satelliteComm = ui->sateliteLineEdit->text(); + _configIni->setValue("机载卫通/IP", _satelliteComm); + emit sendOnlyUrl(Satelite_Comm,_satelliteComm); +} + + +void HomePageSetingWidget::on_oneKeyButton_clicked() +{ + //写参数到配置文件 + _lLinkIp = ui->lLinkLineEdit->text(); + _configIni->setValue("L链/IP", _lLinkIp); + _adHocNetwork = ui->netLineEdit->text(); + _configIni->setValue("宽带自组网/IP", _adHocNetwork); + _satelliteComm = ui->sateliteLineEdit->text(); + _configIni->setValue("机载卫通/IP", _satelliteComm); + + std::unordered_map urlMap; + urlMap.insert({"L链",_lLinkIp}); + urlMap.insert({"宽带自组网",_adHocNetwork}); + urlMap.insert({"机载卫通",_satelliteComm}); + emit sendAllUrl(urlMap); +} + diff --git a/Src/HomePage/homepagesetingwidget.h b/Src/HomePage/homepagesetingwidget.h new file mode 100644 index 0000000..c335a5a --- /dev/null +++ b/Src/HomePage/homepagesetingwidget.h @@ -0,0 +1,47 @@ +#ifndef HOMEPAGESETINGWIDGET_H +#define HOMEPAGESETINGWIDGET_H + +#include +#include + +namespace Ui { +class HomePageSetingWidget; +} + +class HomePageSetingWidget : public QWidget +{ + Q_OBJECT + +public: + explicit HomePageSetingWidget(QWidget *parent = nullptr); + ~HomePageSetingWidget(); +private: + Ui::HomePageSetingWidget *ui; + QString _lLinkIp; //L链 + QString _adHocNetwork; //自组网 + QString _satelliteComm; //PDT + std::unique_ptr _configIni; //配置文件写入 + QString urlFile; //配置文件路径 +private: + void initEdit(); +public: + void setUrl(std::unordered_map& urlMap); + +private slots: + void on_lLinkButton_clicked(); + void on_netButton_clicked(); + void on_sateliteButton_clicked(); + void on_oneKeyButton_clicked(); +signals: + void sendOnlyUrl(unsigned char urlIndex, QString url); //发送信号给网页显示 + void sendAllUrl(std::unordered_map urlMap); +public: + enum urlEnum:unsigned char + { + L_Link = 1, + Adhoc_Network, + Satelite_Comm + }; +}; + +#endif // HOMEPAGESETINGWIDGET_H diff --git a/Src/HomePage/homepagesetingwidget.ui b/Src/HomePage/homepagesetingwidget.ui new file mode 100644 index 0000000..a678061 --- /dev/null +++ b/Src/HomePage/homepagesetingwidget.ui @@ -0,0 +1,266 @@ + + + HomePageSetingWidget + + + + 0 + 0 + 725 + 443 + + + + 设置 + + + + :/res/settings.png:/res/settings.png + + + + + 30 + 10 + 661 + 181 + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + QFrame::Shape::StyledPanel + + + QFrame::Shadow::Raised + + + + + + L链 + + + + + + IP: + + + + + + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 60 + 20 + + + + + + + + + 100 + 16777215 + + + + 设置 + + + + + + + + + + + + 宽带自组网 + + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 60 + 20 + + + + + + + + + 100 + 16777215 + + + + 设置 + + + + + + + + + IP: + + + + + + + + + + + + + 卫通 + + + + + + IP: + + + + + + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 60 + 20 + + + + + + + + + 100 + 16777215 + + + + 设置 + + + + + + + + + + + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 450 + 20 + + + + + + + + + 0 + 0 + + + + + 160 + 30 + + + + 一键设置 + + + + + + + Qt::Orientation::Horizontal + + + QSizePolicy::Policy::Fixed + + + + 15 + 20 + + + + + + + + + + + + + + diff --git a/mainwindow.cpp b/mainwindow.cpp index bfdce92..955bf7c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -8,7 +8,7 @@ #include #include #include - +#include "Src/HomePage/homepagesetingwidget.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) @@ -92,7 +92,6 @@ void MainWindow::initWindow() }); //使用类中的get方法获取配置文件中的IP - m_HomePagedlg->getUrl(m_urlMap); qDebug() << "=============设备配置================"; @@ -116,6 +115,29 @@ 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){ + switch (urlIndex) { + case HomePageSetingWidget::L_Link: + lLinkWeb->load(QUrl(url)); + break; + case HomePageSetingWidget::Adhoc_Network: + lLinkWeb->load(QUrl(url)); + break; + case HomePageSetingWidget::Satelite_Comm: + lLinkWeb->load(QUrl(url)); + break; + default: + break; + } + }); + + //接收主页面设置窗口的url数据传递并设置 一键设置 + connect(m_HomePagedlg->settingWidget, &HomePageSetingWidget::sendAllUrl, this, [&](std::unordered_map urlMap){ + lLinkWeb->load(QUrl(urlMap["L链"])); + adHocNetworkWeb->load(QUrl(urlMap["宽带自组网"])); + satelliteCommWeb->load(QUrl(urlMap["机载卫通"])); + }); // 设置栈窗口,多页面共享同一窗口 ui->stackedWidget->addWidget(mWeb); ui->stackedWidget->addWidget(lLinkWeb); diff --git a/mainwindow.h b/mainwindow.h index 720e795..d4e85cb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -3,7 +3,7 @@ #include #include "Src/GDDC/gddcdlg.h" -#include "homepagedlg.h" +#include "Src/HomePage/homepagedlg.h" #include "rescueloadwidget.h" #include #include