|
|
|
#include "homepagedlg.h"
|
|
|
|
#include "ui_homepagedlg.h"
|
|
|
|
#include <QDir>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include <qsettings.h>
|
|
|
|
|
|
|
|
HomePageDlg::HomePageDlg(QWidget *parent)
|
|
|
|
: QWidget(parent)
|
|
|
|
, ui(new Ui::HomePageDlg)
|
|
|
|
, _lLinkIp("")
|
|
|
|
, _adHocNetwork("")
|
|
|
|
, _satelliteComm("")
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
QPalette palette;
|
|
|
|
//设置主窗口背景颜色
|
|
|
|
palette.setColor(QPalette::Window,QColor(50, 50, 50));
|
|
|
|
this->setPalette(palette);
|
|
|
|
//嵌入到主窗口
|
|
|
|
setWindowFlags(Qt::CustomizeWindowHint|Qt::FramelessWindowHint);
|
|
|
|
hide();
|
|
|
|
|
|
|
|
settingWidget = new HomePageSetingWidget(this);
|
|
|
|
settingWidget->setWindowFlags(Qt::Window); // 设置为独立窗口
|
|
|
|
|
|
|
|
initSettingUrl();
|
|
|
|
initButton();
|
|
|
|
}
|
|
|
|
|
|
|
|
HomePageDlg::~HomePageDlg()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************
|
|
|
|
* @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);
|
|
|
|
|
|
|
|
_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});
|
|
|
|
|
|
|
|
settingWidget->setUrl(_urlMap);
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* @brief HomePageDlg::initButton 初始化按钮位置
|
|
|
|
*/
|
|
|
|
void HomePageDlg::initButton()
|
|
|
|
{
|
|
|
|
QIcon icon;
|
|
|
|
icon.addFile(":/res/settings.png");
|
|
|
|
btn = new QPushButton;
|
|
|
|
btn->setParent(this);
|
|
|
|
btn->setMinimumSize(40,40);
|
|
|
|
btn->setMaximumSize(40,40);
|
|
|
|
btn->setIconSize(QSize(30,30));
|
|
|
|
btn->setIcon(icon);
|
|
|
|
|
|
|
|
//点击主页按钮弹出设置页面1
|
|
|
|
connect(btn,&QPushButton::clicked,this,[&](){
|
|
|
|
//qDebug() << "homepagedlg上的设置按钮点击了";
|
|
|
|
if(settingWidget->isVisible())
|
|
|
|
settingWidget->close();
|
|
|
|
else
|
|
|
|
settingWidget->show();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void HomePageDlg::on_pushButton_clicked()
|
|
|
|
{
|
|
|
|
emit sendUrl(_urlMap);
|
|
|
|
}
|
|
|
|
//区域重绘
|
|
|
|
void HomePageDlg::resizeEvent(QResizeEvent *event)
|
|
|
|
{
|
|
|
|
double GDDCPageHeight = (double)(this->height());
|
|
|
|
double GDDCPageWidth = (double)(this->width());
|
|
|
|
btn->setGeometry(GDDCPageWidth-40,0,40,40);
|
|
|
|
}
|
|
|
|
|