PowerMaster/source/dvieMainWindow.cpp

93 lines
2.8 KiB
C++
Raw Normal View History

2024-10-10 16:59:51 +08:00
#include "dvieMainWindow.h"
#include "./ui_dvieMainWindow.h"
#include "transparentMask.h"
#include "dashboardFrame.h"
2024-11-14 09:19:14 +08:00
#include "dvieSecondaryWindow.h"
#include <QDateTime>
2024-10-10 16:59:51 +08:00
DvieMainWindow::DvieMainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::dvieMainWindow)
, m_pTransparentMask(nullptr)
, m_pDashboardFrame(nullptr)
2024-10-10 16:59:51 +08:00
{
ui->setupUi(this);
2024-11-07 12:08:56 +08:00
setProperty("windowType", "main");
2024-10-10 16:59:51 +08:00
2024-11-14 09:19:14 +08:00
m_pDashboardFrame = new DashboardFrame("mainDVIE_dashboardFrame", dashboardFrame::ft_main, this);
ui->centralLayout->addWidget(m_pDashboardFrame);
2024-10-10 16:59:51 +08:00
}
DvieMainWindow::~DvieMainWindow()
{
delete ui;
}
void DvieMainWindow::resizeEvent(QResizeEvent* event)
{
if(m_pTransparentMask && m_pTransparentMask->isVisible())
m_pTransparentMask->setGeometry(ui->topWidget->geometry());
QMainWindow::resizeEvent(event);
}
void DvieMainWindow::showTransparentMask()
{
if(m_pTransparentMask == nullptr)
m_pTransparentMask = new TransparentMask(this);
m_pTransparentMask->setGeometry(ui->topWidget->geometry());
m_pTransparentMask->show();
}
void DvieMainWindow::hideTransparentMask()
{
if(m_pTransparentMask && m_pTransparentMask->isVisible())
m_pTransparentMask->hide();
}
2024-11-14 09:19:14 +08:00
DashboardFrame* DvieMainWindow::dashboardFrame()
{
return m_pDashboardFrame;
}
DashboardFrame* DvieMainWindow::getDashboardFrame(const QString& strName)
{
DashboardFrame* frame = nullptr;
if(m_pDashboardFrame->objectName() == strName)
frame = m_pDashboardFrame;
else
{
int nIndex = strName.indexOf("_dashboardFrame");
if(nIndex != -1)
{
QString strDVIEWindowName = strName.left(nIndex);
//qDebug() << strDVIEWindowName;
2024-11-14 09:19:14 +08:00
auto itr = m_hashSecondaryWindow.find(strDVIEWindowName);
if(itr != m_hashSecondaryWindow.end())
frame = itr.value()->dashboardFrame();
}
}
return frame;
}
void DvieMainWindow::creatSecondaryWindowAndAddDashboard(QPoint pos, Dashboard* dashboard)
{
QString strName = "secondaryDVIE_" + QDateTime::currentDateTime().toString("yyMMdd-HHmmss");
DvieSecondaryWindow* secondartWindow = new DvieSecondaryWindow(strName, this);
secondartWindow->setMainWindow(this);
secondartWindow->move(pos);
secondartWindow->show();
if(secondartWindow->dashboardFrame())
secondartWindow->dashboardFrame()->addDashboard(dashboard);
2024-11-14 09:19:14 +08:00
m_hashSecondaryWindow.insert(strName, secondartWindow);
//qDebug() << m_hashSecondaryWindow.count();
}
void DvieMainWindow::removeSecondartWindow(QString& strName)
{
DvieSecondaryWindow* secondartWindow = m_hashSecondaryWindow.take(strName);
if(secondartWindow)
secondartWindow->deleteLater(); //不要直接delete因为后续还需要该对象做一些其它工作
//qDebug() << m_hashSecondaryWindow.count();
}