From f7550112e49857e9445909201b31f0bc52216dc6 Mon Sep 17 00:00:00 2001 From: duanshengchao <519970194@qq.com> Date: Tue, 24 Dec 2024 20:17:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=9B=B4=E6=94=B9dataPanel?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CMakeLists.txt | 8 ++++++++ include/dataPanel.h | 1 + source/dataPanel.cpp | 29 +++++++++++++++++++++++++---- ui/dataPanel.ui | 6 +++--- ui/panelConfigurationWidget.ui | 7 +++---- 5 files changed, 40 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 333c7cc..8bf43c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,13 @@ set(UTIL_FILES util/Chart/qcustomplot.cpp ) +set(DATAPANEL_FILES + dataPanel/dpBaseWidget.h + dataPanel/dpBaseWidget.cpp + dataPanel/dpLineChart.h + dataPanel/dpLineChart.cpp +) + # 包含源文件目录 INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}) @@ -111,6 +118,7 @@ if(${QT_VERSION_MAJOR} GREATER_EQUAL 6) ${CPP_SOURCE_FILES} ${UI_FILES} ${UTIL_FILES} + ${DATAPANEL_FILES} resource/PowerMaster.qrc ) # Define target properties for Android with Qt 6 as: diff --git a/include/dataPanel.h b/include/dataPanel.h index 92a01c6..3d0e36b 100644 --- a/include/dataPanel.h +++ b/include/dataPanel.h @@ -89,6 +89,7 @@ private: void autoSetGeometry(); //在缩放和移动时以其它panel和parent的border为依据自动调整 bool m_bMouseEnter; + bool m_bConfigurationComplete; QString m_strName; QSize m_displayAreaSize; QRect m_curGeometry; diff --git a/source/dataPanel.cpp b/source/dataPanel.cpp index c7b2c80..a4ba18e 100644 --- a/source/dataPanel.cpp +++ b/source/dataPanel.cpp @@ -32,15 +32,28 @@ DataPanel::DataPanel(QWidget *parent) m_strName = ""; m_bMouseEnter = false; + m_bConfigurationComplete = false; m_pContentWidget = nullptr; m_pScrollArea = nullptr; + + QWidget* centralWidget = new QWidget(this); + centralWidget->setObjectName("centralWidget"); + centralWidget->setStyleSheet("QWidget #centralWidget{\n" + " border:2px solid rgb(76,88,105);\n" + " background-color:rgba(36,43,50,250);\n" + "}\n"); + QBoxLayout* centralLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); + centralLayout->setContentsMargins(0, 0, 0, 0); + centralLayout->addWidget(centralWidget); + setLayout(centralLayout); m_pLayout = new QBoxLayout(QBoxLayout::TopToBottom, this); m_pLayout->setContentsMargins(0, 0, 0, 0); m_pLayout->setSpacing(0); - setLayout(m_pLayout); + centralWidget->setLayout(m_pLayout); - m_pConfigurationWidget = new PanelConfigurationWidget(); - setWiget(m_pConfigurationWidget); + m_pConfigurationWidget = new PanelConfigurationWidget(this); + m_pConfigurationWidget->raise(); + //setWiget(m_pConfigurationWidget); //resize(533, 300); m_pCustomBorderContainer = new CustomBorderContainer(this); @@ -76,9 +89,17 @@ bool DataPanel::event(QEvent* event) if (pKeyEvent->key() == Qt::Key_Escape) return true; } - else if(event->type() == QEvent::Resize) + else if(event->type() == QEvent::Show) { m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3); + m_pConfigurationWidget->move((this->width() - m_pConfigurationWidget->width()) * 0.5, (this->height() - m_pConfigurationWidget->height()) * 0.5); + } + else if(event->type() == QEvent::Resize || event->type() == QEvent::Move) + { + if(m_pToolWidget->isVisible()) + m_pToolWidget->move(this->width() - m_pToolWidget->width() - 8, 3); + if(m_pConfigurationWidget->isVisible()) + m_pConfigurationWidget->move((this->width() - m_pConfigurationWidget->width()) * 0.5, (this->height() - m_pConfigurationWidget->height()) * 0.5); } else if(event->type() == QEvent::MouseButtonPress) { diff --git a/ui/dataPanel.ui b/ui/dataPanel.ui index b004001..bf8b054 100644 --- a/ui/dataPanel.ui +++ b/ui/dataPanel.ui @@ -30,11 +30,11 @@ 0 - + - QWidget #contentWidget + QWidget #centralWidget { -border:1px solid rgb(76,88,105); +border:2px solid rgb(76,88,105); background-color:rgba(36,43,50,250); } diff --git a/ui/panelConfigurationWidget.ui b/ui/panelConfigurationWidget.ui index 2fcb3e7..0fb221e 100644 --- a/ui/panelConfigurationWidget.ui +++ b/ui/panelConfigurationWidget.ui @@ -6,8 +6,8 @@ 0 0 - 710 - 400 + 365 + 94 @@ -37,8 +37,7 @@ QWidget #contentWidget { -border:2px solid rgb(76,88,105); -background-color:rgb(24,32,38); +background-color:transparent; }