File tree Expand file tree Collapse file tree 2 files changed +21
-0
lines changed
Expand file tree Collapse file tree 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -69,6 +69,8 @@ class DockContentWidget : public QWidget
6969 m_mainLayout->setContentsMargins (margin);
7070 }
7171 void setMinHeight (int minHeight) { m_minHeight = minHeight; }
72+
73+ public Q_SLOTS:
7274 void updateSize () {
7375 auto h = Dock::DOCK_POPUP_WIDGET_MAX_HEIGHT - 20 - m_mainLayout->contentsMargins ().top () - (m_netCheckBtn->isVisible () ? (m_netSetBtn->height () + m_netCheckBtn->height () + 10 ) : m_netSetBtn->height ());
7476 m_netView->setMaxHeight (h);
@@ -90,6 +92,24 @@ class DockContentWidget : public QWidget
9092 return QWidget::eventFilter (watch, event);
9193 }
9294
95+ void showEvent (QShowEvent *event) override
96+ {
97+ updateSize ();
98+ QWidget::showEvent (event);
99+ QMetaObject::invokeMethod (this , [this ]() {
100+ updateSize ();
101+ resize (size ());
102+ }, Qt::QueuedConnection);
103+ }
104+
105+ void hideEvent (QHideEvent *event) override
106+ {
107+ QWidget::hideEvent (event);
108+ m_minHeight = -1 ;
109+ // 隐藏时更新尺寸为折叠状态,确保下次显示时初始尺寸正确
110+ QMetaObject::invokeMethod (this , " updateSize" , Qt::QueuedConnection);
111+ }
112+
93113private:
94114 QVBoxLayout *m_mainLayout;
95115 NetView *m_netView;
Original file line number Diff line number Diff line change @@ -413,6 +413,7 @@ void NetView::showEvent(QShowEvent *event)
413413 if (m_shouldUpdateExpand)
414414 m_manager->exec (NetManager::ToggleExpand, " " );
415415 m_shouldUpdateExpand = false ;
416+ updateGeometries ();
416417}
417418
418419void NetView::hideEvent (QHideEvent *event)
You can’t perform that action at this time.
0 commit comments