实现dataPanel数据展示面板可以随外部对话框大小变化时进行同步缩放
This commit is contained in:
parent
62f8b197f1
commit
60e3e4035f
|
|
@ -26,6 +26,7 @@ public:
|
||||||
void setActive(bool);
|
void setActive(bool);
|
||||||
void addPanel(const QString&);
|
void addPanel(const QString&);
|
||||||
void removePanel(const QString&);
|
void removePanel(const QString&);
|
||||||
|
void resizePanel(double, double);
|
||||||
void deleteSubWidgets();
|
void deleteSubWidgets();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
|
||||||
|
|
@ -57,6 +57,11 @@ public:
|
||||||
void setName(const QString&);
|
void setName(const QString&);
|
||||||
const QString& getName();
|
const QString& getName();
|
||||||
|
|
||||||
|
void setInitialSize(const QSize&);
|
||||||
|
void setDisplayAreaSize(const QSize&);
|
||||||
|
void resizeByRatio(double, double); //通过缩放比例做resize,在所属dasboard的resizeEvent中调用
|
||||||
|
void resizeByNewSize(const QSize&); //通过新的尺寸(所在区域)做resize,当所属dashboard被激活(显示)时调用
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool event(QEvent*);
|
bool event(QEvent*);
|
||||||
/*void keyPressEvent(QKeyEvent*);
|
/*void keyPressEvent(QKeyEvent*);
|
||||||
|
|
@ -85,6 +90,7 @@ private:
|
||||||
|
|
||||||
bool m_bMouseEnter;
|
bool m_bMouseEnter;
|
||||||
QString m_strName;
|
QString m_strName;
|
||||||
|
QSize m_displayAreaSize;
|
||||||
QRect m_curGeometry;
|
QRect m_curGeometry;
|
||||||
CustomMenu* m_pToolMenu;
|
CustomMenu* m_pToolMenu;
|
||||||
QWidget* m_pContentWidget;
|
QWidget* m_pContentWidget;
|
||||||
|
|
|
||||||
|
|
@ -17,8 +17,10 @@ public:
|
||||||
PanelConfigurationWidget(QWidget *parent = nullptr);
|
PanelConfigurationWidget(QWidget *parent = nullptr);
|
||||||
~PanelConfigurationWidget();
|
~PanelConfigurationWidget();
|
||||||
|
|
||||||
|
//void zoomContent(int, int);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//void showEvent(QShowEvent*);
|
void resizeEvent(QResizeEvent*) override;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void sgl_configure();
|
void sgl_configure();
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ void CustomTab::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
|
||||||
m_bDragging = true;
|
m_bDragging = true;
|
||||||
Qt::DropAction dropAction = drag->exec();
|
Qt::DropAction dropAction = drag->exec();
|
||||||
qDebug() << dropAction;
|
//qDebug() << dropAction;
|
||||||
//exec之后的语句都会在drg操作完成之后(鼠标抬起)执行
|
//exec之后的语句都会在drg操作完成之后(鼠标抬起)执行
|
||||||
delete drag;
|
delete drag;
|
||||||
m_bLeftButtonPressed = false;
|
m_bLeftButtonPressed = false;
|
||||||
|
|
@ -94,7 +94,7 @@ void CustomTab::mouseMoveEvent(QMouseEvent* event)
|
||||||
|
|
||||||
if(dropAction == Qt::IgnoreAction) //创建新的dvieSecondaryWindow
|
if(dropAction == Qt::IgnoreAction) //创建新的dvieSecondaryWindow
|
||||||
{
|
{
|
||||||
qDebug() << "create dvieSecondaryWindow on" << QCursor::pos();
|
//qDebug() << "create dvieSecondaryWindow on" << QCursor::pos();
|
||||||
m_pDashboard->frame()->moveDashboardToNewDVIEWindow(text(), QCursor::pos());
|
m_pDashboard->frame()->moveDashboardToNewDVIEWindow(text(), QCursor::pos());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,11 +114,21 @@ void Dashboard::setActive(bool bActive)
|
||||||
{
|
{
|
||||||
m_pDisplayAreaLayout->addWidget(m_pDisplayArea);
|
m_pDisplayAreaLayout->addWidget(m_pDisplayArea);
|
||||||
m_pDisplayArea->show();
|
m_pDisplayArea->show();
|
||||||
|
for(int n = 0; n < m_dataPanels.count(); n++)
|
||||||
|
{
|
||||||
|
//让所有dataPanel根据当前area的size进行同步缩放
|
||||||
|
m_dataPanels.at(n)->resizeByNewSize(m_pDisplayArea->size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(!bActive && m_pDisplayAreaLayout)
|
else if(!bActive && m_pDisplayAreaLayout)
|
||||||
{
|
{
|
||||||
m_pDisplayAreaLayout->removeWidget(m_pDisplayArea);
|
m_pDisplayAreaLayout->removeWidget(m_pDisplayArea);
|
||||||
m_pDisplayArea->hide();
|
m_pDisplayArea->hide();
|
||||||
|
for(int n = 0; n < m_dataPanels.count(); n++)
|
||||||
|
{
|
||||||
|
//让所有dataPanel记录area当前的size,当再次被激活时若size发生变化,让所有dataPanel进行同步缩放
|
||||||
|
m_dataPanels.at(n)->setDisplayAreaSize(m_pDisplayArea->size());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_pTab->setActive(bActive);
|
m_pTab->setActive(bActive);
|
||||||
|
|
@ -131,11 +141,13 @@ void Dashboard::addPanel(const QString& strType)
|
||||||
QString strDefaultName = "dataPanel-" + QString::number(m_nPanenlNameNumber);
|
QString strDefaultName = "dataPanel-" + QString::number(m_nPanenlNameNumber);
|
||||||
m_nPanenlNameNumber++;
|
m_nPanenlNameNumber++;
|
||||||
panel->setName(strDefaultName);
|
panel->setName(strDefaultName);
|
||||||
//panel->setStyleSheet("QDialog{background-color:transparent;}");
|
int nPanelWidth = m_pDisplayArea->width() * 0.25;
|
||||||
|
int nPanelHeight = nPanelWidth * 0.56; //16:9宽高比
|
||||||
|
panel->setInitialSize(QSize(nPanelWidth, nPanelHeight));
|
||||||
int nCount = m_dataPanels.count();
|
int nCount = m_dataPanels.count();
|
||||||
//QPoint originPoint = m_pDisplayArea->mapToGlobal(QPoint(0, 0));
|
//QPoint originPoint = m_pDisplayArea->mapToGlobal(QPoint(0, 0));
|
||||||
int nX = /*originPoint.x() +*/ (m_pDisplayArea->width() - panel->width()) * 0.5 + nCount * 10;
|
int nX = /*originPoint.x() +*/ (m_pDisplayArea->width() - nPanelWidth) * 0.5 + nCount * 10;
|
||||||
int nY = /*originPoint.y() +*/ (m_pDisplayArea->height() - panel->height()) * 0.5 + nCount * 10;
|
int nY = /*originPoint.y() +*/ (m_pDisplayArea->height() - nPanelHeight) * 0.5 + nCount * 10;
|
||||||
panel->move(nX, nY);
|
panel->move(nX, nY);
|
||||||
panel->show();
|
panel->show();
|
||||||
m_dataPanels.push_back(panel);
|
m_dataPanels.push_back(panel);
|
||||||
|
|
@ -160,6 +172,12 @@ void Dashboard::removePanel(const QString& strName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Dashboard::resizePanel(double ratioX, double ratioY)
|
||||||
|
{
|
||||||
|
for(int n = 0; n < m_dataPanels.count(); n++)
|
||||||
|
m_dataPanels.at(n)->resizeByRatio(ratioX, ratioY);
|
||||||
|
}
|
||||||
|
|
||||||
void Dashboard::contextMenu_tab(const QPoint& pos)
|
void Dashboard::contextMenu_tab(const QPoint& pos)
|
||||||
{
|
{
|
||||||
QPoint originPoint = m_pTab->mapToGlobal(QPoint(0, 0));
|
QPoint originPoint = m_pTab->mapToGlobal(QPoint(0, 0));
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,9 @@ bool DashboardFrame::eventFilter(QObject* obj, QEvent* event)
|
||||||
|
|
||||||
void DashboardFrame::resizeEvent(QResizeEvent* event)
|
void DashboardFrame::resizeEvent(QResizeEvent* event)
|
||||||
{
|
{
|
||||||
|
//qDebug() << "oldSize:" << event->oldSize() << " size:" << event->size();
|
||||||
|
if(event->oldSize() != QSize(-1, -1)) //Qt默认的初始化创建过程中会有从QSize(-1, -1)的变化,需要忽略
|
||||||
|
{
|
||||||
if(m_pTransparentMask && m_pTransparentMask->isVisible())
|
if(m_pTransparentMask && m_pTransparentMask->isVisible())
|
||||||
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
m_pTransparentMask->setGeometry(0, 0, this->width(), this->height());
|
||||||
|
|
||||||
|
|
@ -100,6 +103,13 @@ void DashboardFrame::resizeEvent(QResizeEvent* event)
|
||||||
m_pDashboardNamingDialog->move(nX, nY);
|
m_pDashboardNamingDialog->move(nX, nY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
double ratioX = (double)event->size().width() / (double)event->oldSize().width();
|
||||||
|
double ratioY = (double)event->size().height() / (double)event->oldSize().height();
|
||||||
|
//qDebug() << ratioX << ", " << ratioY;
|
||||||
|
if(m_curActiveDashboard)
|
||||||
|
m_curActiveDashboard->resizePanel(ratioX, ratioY);
|
||||||
|
}
|
||||||
|
|
||||||
QWidget::resizeEvent(event);
|
QWidget::resizeEvent(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -371,6 +381,7 @@ void DashboardFrame::setCurrentDashboard(const QString& strName)
|
||||||
CustomTab* tab = m_listDashboard.at(n)->tab();
|
CustomTab* tab = m_listDashboard.at(n)->tab();
|
||||||
m_pDashboardTabBar->ensureWidgetVisible(tab);
|
m_pDashboardTabBar->ensureWidgetVisible(tab);
|
||||||
m_curActiveDashboard = m_listDashboard.at(n);
|
m_curActiveDashboard = m_listDashboard.at(n);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ DataPanel::DataPanel(QWidget *parent)
|
||||||
|
|
||||||
m_pConfigurationWidget = new PanelConfigurationWidget();
|
m_pConfigurationWidget = new PanelConfigurationWidget();
|
||||||
setWiget(m_pConfigurationWidget);
|
setWiget(m_pConfigurationWidget);
|
||||||
resize(533, 300);
|
//resize(533, 300);
|
||||||
|
|
||||||
m_pCustomBorderContainer = new CustomBorderContainer(this);
|
m_pCustomBorderContainer = new CustomBorderContainer(this);
|
||||||
m_pCustomBorderContainer->setOperationOption(CustomBorderContainer::WidgetMovable | CustomBorderContainer::WidgetResizable | CustomBorderContainer::WidgetAutoAdjustGeometry);
|
m_pCustomBorderContainer->setOperationOption(CustomBorderContainer::WidgetMovable | CustomBorderContainer::WidgetResizable | CustomBorderContainer::WidgetAutoAdjustGeometry);
|
||||||
|
|
@ -216,6 +216,72 @@ const QString& DataPanel::getName()
|
||||||
return m_strName;
|
return m_strName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DataPanel::setInitialSize(const QSize& size)
|
||||||
|
{
|
||||||
|
resize(size);
|
||||||
|
m_pCustomBorderContainer->updateBorder();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataPanel::setDisplayAreaSize(const QSize& size)
|
||||||
|
{
|
||||||
|
m_displayAreaSize = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DataPanel::resizeByRatio(double ratioX, double ratioY)
|
||||||
|
{
|
||||||
|
QString strCurState = m_pToolWidget->ui->btnFullScree->property("currentState").toString();
|
||||||
|
if(strCurState == "exitFullScreen") //当前是全屏状态
|
||||||
|
setGeometry(0, 0, parentWidget()->width(), parentWidget()->height());
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QRect geometry = this->geometry();
|
||||||
|
QRect newGeometry;
|
||||||
|
//double转换为int默认只取整数部分,因此ratio若<1,执行默认操作,反之向上取整
|
||||||
|
if(ratioX < 1)
|
||||||
|
{
|
||||||
|
newGeometry.setX(geometry.x() * ratioX);
|
||||||
|
newGeometry.setWidth(geometry.width() * ratioX);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newGeometry.setX(qCeil(geometry.x() * ratioX));
|
||||||
|
newGeometry.setWidth(qCeil(geometry.width() * ratioX));
|
||||||
|
}
|
||||||
|
if(ratioY < 1)
|
||||||
|
{
|
||||||
|
newGeometry.setY(geometry.y() * ratioY);
|
||||||
|
newGeometry.setHeight(geometry.height() * ratioY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
newGeometry.setY(qCeil(geometry.y() * ratioY));
|
||||||
|
newGeometry.setHeight(qCeil(geometry.height() * ratioY));
|
||||||
|
}
|
||||||
|
if(newGeometry.x() < 0)
|
||||||
|
newGeometry.setX(0);
|
||||||
|
if(newGeometry.y() < 0)
|
||||||
|
newGeometry.setY(0);
|
||||||
|
|
||||||
|
setGeometry(newGeometry);
|
||||||
|
|
||||||
|
// qDebug() << geometry.x() << "," << geometry.y() << "," << geometry.width() << "," << geometry.height();
|
||||||
|
// qDebug() << ratioX << "," << ratioY;
|
||||||
|
// qDebug() << newGeometry.x() << "," << newGeometry.y() << "," << newGeometry.width() << "," << newGeometry.height();
|
||||||
|
}
|
||||||
|
|
||||||
|
m_curGeometry = QRect(m_curGeometry.x() * ratioX, m_curGeometry.y() * ratioY, m_curGeometry.width() * ratioX, m_curGeometry.height() * ratioY);
|
||||||
|
m_pCustomBorderContainer->updateBorder();
|
||||||
|
}
|
||||||
|
void DataPanel::resizeByNewSize(const QSize& newSize)
|
||||||
|
{
|
||||||
|
if(m_displayAreaSize == newSize)
|
||||||
|
return;
|
||||||
|
|
||||||
|
double ratioX = (double)newSize.width() / (double)m_displayAreaSize.width();
|
||||||
|
double ratioY = (double)newSize.height() / (double)m_displayAreaSize.height();
|
||||||
|
resizeByRatio(ratioX, ratioY);
|
||||||
|
}
|
||||||
|
|
||||||
void DataPanel::onToolBtnClicked_setting()
|
void DataPanel::onToolBtnClicked_setting()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
@ -259,6 +325,7 @@ void DataPanel::onToolBtnClicked_fullScreen()
|
||||||
m_pCustomBorderContainer->setOperationOption(CustomBorderContainer::WidgetMovable | CustomBorderContainer::WidgetResizable | CustomBorderContainer::WidgetAutoAdjustGeometry);
|
m_pCustomBorderContainer->setOperationOption(CustomBorderContainer::WidgetMovable | CustomBorderContainer::WidgetResizable | CustomBorderContainer::WidgetAutoAdjustGeometry);
|
||||||
m_pCustomBorderContainer->showBorderDraw();
|
m_pCustomBorderContainer->showBorderDraw();
|
||||||
setGeometry(m_curGeometry);
|
setGeometry(m_curGeometry);
|
||||||
|
m_pCustomBorderContainer->updateBorder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ DashboardFrame* DvieMainWindow::getDashboardFrame(const QString& strName)
|
||||||
if(nIndex != -1)
|
if(nIndex != -1)
|
||||||
{
|
{
|
||||||
QString strDVIEWindowName = strName.left(nIndex);
|
QString strDVIEWindowName = strName.left(nIndex);
|
||||||
qDebug() << strDVIEWindowName;
|
//qDebug() << strDVIEWindowName;
|
||||||
auto itr = m_hashSecondaryWindow.find(strDVIEWindowName);
|
auto itr = m_hashSecondaryWindow.find(strDVIEWindowName);
|
||||||
if(itr != m_hashSecondaryWindow.end())
|
if(itr != m_hashSecondaryWindow.end())
|
||||||
frame = itr.value()->dashboardFrame();
|
frame = itr.value()->dashboardFrame();
|
||||||
|
|
@ -75,11 +75,11 @@ void DvieMainWindow::creatSecondaryWindowAndAddDashboard(QPoint pos, Dashboard*
|
||||||
{
|
{
|
||||||
QString strName = "secondaryDVIE_" + QDateTime::currentDateTime().toString("yyMMdd-HHmmss");
|
QString strName = "secondaryDVIE_" + QDateTime::currentDateTime().toString("yyMMdd-HHmmss");
|
||||||
DvieSecondaryWindow* secondartWindow = new DvieSecondaryWindow(strName, this);
|
DvieSecondaryWindow* secondartWindow = new DvieSecondaryWindow(strName, this);
|
||||||
if(secondartWindow->dashboardFrame())
|
|
||||||
secondartWindow->dashboardFrame()->addDashboard(dashboard);
|
|
||||||
secondartWindow->setMainWindow(this);
|
secondartWindow->setMainWindow(this);
|
||||||
secondartWindow->move(pos);
|
secondartWindow->move(pos);
|
||||||
secondartWindow->show();
|
secondartWindow->show();
|
||||||
|
if(secondartWindow->dashboardFrame())
|
||||||
|
secondartWindow->dashboardFrame()->addDashboard(dashboard);
|
||||||
m_hashSecondaryWindow.insert(strName, secondartWindow);
|
m_hashSecondaryWindow.insert(strName, secondartWindow);
|
||||||
//qDebug() << m_hashSecondaryWindow.count();
|
//qDebug() << m_hashSecondaryWindow.count();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ int main(int argc, char *argv[])
|
||||||
// int a = 1;
|
// int a = 1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
QString osName = QSysInfo::productType();
|
// QString osName = QSysInfo::productType();
|
||||||
qDebug() << "Operating System Name:" << osName;
|
// qDebug() << "Operating System Name:" << osName;
|
||||||
|
|
||||||
// qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
// qputenv("QT_ENABLE_HIGHDPI_SCALING", "1");
|
||||||
// QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
// QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,37 @@ PanelConfigurationWidget::~PanelConfigurationWidget()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PanelConfigurationWidget::resizeEvent(QResizeEvent* event)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*void PanelConfigurationWidget::zoomContent(int ratioX, int ratioY)
|
||||||
|
{
|
||||||
|
//子部件gemometry & frot
|
||||||
|
QRect geometry;
|
||||||
|
QFont font;
|
||||||
|
//lable
|
||||||
|
font = ui->label->font();
|
||||||
|
int pixelSize = font.pixelSize();
|
||||||
|
font.setPixelSize(pixelSize * ratioY);
|
||||||
|
ui->label->setFont(font);
|
||||||
|
//configureButton
|
||||||
|
font = ui->btnConfigure->font();
|
||||||
|
pixelSize = font.pixelSize();
|
||||||
|
font.setPixelSize(pixelSize * ratioY);
|
||||||
|
ui->btnConfigure->setFont(font);
|
||||||
|
QSize iconSize = ui->btnConfigure->iconSize();
|
||||||
|
iconSize.setWidth(iconSize.width() * ratioX);
|
||||||
|
iconSize.setHeight(iconSize.height() * ratioY);
|
||||||
|
ui->btnConfigure->setIconSize(iconSize);
|
||||||
|
geometry = ui->btnConfigure->geometry();
|
||||||
|
int width = geometry.width() * ratioX;
|
||||||
|
int height = geometry.height() * ratioY;
|
||||||
|
ui->btnConfigure->setMaximumSize(width, height);
|
||||||
|
ui->btnConfigure->setMinimumSize(width, height);
|
||||||
|
}*/
|
||||||
|
|
||||||
void PanelConfigurationWidget::onBtnClicked_configure()
|
void PanelConfigurationWidget::onBtnClicked_configure()
|
||||||
{
|
{
|
||||||
emit sgl_configure();
|
emit sgl_configure();
|
||||||
|
|
|
||||||
|
|
@ -6,8 +6,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>998</width>
|
<width>1168</width>
|
||||||
<height>607</height>
|
<height>676</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue