PowerMaster/source/dvieSecondaryWindow.cpp

82 lines
2.0 KiB
C++
Raw Normal View History

2024-11-07 12:08:56 +08:00
#include "dvieSecondaryWindow.h"
#include "./ui_dvieSecondaryWindow.h"
#include "transparentMask.h"
2024-11-14 09:19:14 +08:00
#include "dvieMainWindow.h"
2024-11-07 12:08:56 +08:00
#include "dashboardFrame.h"
2024-11-14 09:19:14 +08:00
#include <QCloseEvent>
2024-11-07 12:08:56 +08:00
DvieSecondaryWindow::DvieSecondaryWindow(const QString& strName, QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::dvieSecondaryWindow)
2024-11-14 09:19:14 +08:00
, m_pMainWindow(nullptr)
, m_pTransparentMask(nullptr)
2024-11-07 12:08:56 +08:00
, m_pDashboardFrame(nullptr)
{
ui->setupUi(this);
setProperty("windowType", "secondary");
m_strName = strName;
2024-11-14 09:19:14 +08:00
QString strDashboard = strName + "_dashboardFrame";
m_pDashboardFrame = new DashboardFrame(strDashboard, dashboardFrame::ft_secondary, this);
2024-11-07 12:08:56 +08:00
ui->centralLayout->addWidget(m_pDashboardFrame);
}
DvieSecondaryWindow::~DvieSecondaryWindow()
{
delete ui;
}
2024-11-14 09:19:14 +08:00
void DvieSecondaryWindow::showTransparentMask()
{
if(m_pTransparentMask == nullptr)
m_pTransparentMask = new TransparentMask(this);
m_pTransparentMask->setGeometry(ui->topWidget->geometry());
m_pTransparentMask->show();
}
void DvieSecondaryWindow::hideTransparentMask()
{
if(m_pTransparentMask != nullptr && m_pTransparentMask->isVisible())
m_pTransparentMask->hide();
}
2024-11-14 09:19:14 +08:00
void DvieSecondaryWindow::closeEvent(QCloseEvent* e)
{
if(m_pMainWindow)
m_pMainWindow->removeSecondartWindow(m_strName);
else
QMainWindow::closeEvent(e);
}
QString DvieSecondaryWindow::name()
{
return m_strName;
}
DashboardFrame* DvieSecondaryWindow::dashboardFrame()
{
return m_pDashboardFrame;
}
DashboardFrame* DvieSecondaryWindow::getDashboardFrame(const QString& strName)
{
if(m_pMainWindow)
return m_pMainWindow->getDashboardFrame(strName);
else
return nullptr;
}
void DvieSecondaryWindow::setMainWindow(DvieMainWindow* mainWindow)
{
m_pMainWindow = mainWindow;
}
void DvieSecondaryWindow::creatSecondaryWindowAndAddDashboard(QPoint pos, Dashboard* dashboard)
{
if(m_pMainWindow)
m_pMainWindow->creatSecondaryWindowAndAddDashboard(pos, dashboard);
}