Skip to content

Commit a975448

Browse files
pengfeixxdeepin-bot[bot]
authored andcommitted
fix: Fix the abnormal display of network panel height
Fix the abnormal display of network panel height Log: Fix the abnormal display of network panel height pms: BUG-311381
1 parent 3c098b1 commit a975448

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

dock-network-plugin/dockcontentwidget.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
93113
private:
94114
QVBoxLayout *m_mainLayout;
95115
NetView *m_netView;

net-view/window/netview.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

418419
void NetView::hideEvent(QHideEvent *event)

0 commit comments

Comments
 (0)