-
Notifications
You must be signed in to change notification settings - Fork 48
fix: Fix the abnormal display of network panel height #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -69,6 +69,8 @@ class DockContentWidget : public QWidget | |||||||||||||||||||||||||
| m_mainLayout->setContentsMargins(margin); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| void setMinHeight(int minHeight) { m_minHeight = minHeight; } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| public Q_SLOTS: | ||||||||||||||||||||||||||
| void updateSize() { | ||||||||||||||||||||||||||
| 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()); | ||||||||||||||||||||||||||
| m_netView->setMaxHeight(h); | ||||||||||||||||||||||||||
|
|
@@ -90,6 +92,24 @@ class DockContentWidget : public QWidget | |||||||||||||||||||||||||
| return QWidget::eventFilter(watch, event); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| void showEvent(QShowEvent *event) override | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| updateSize(); | ||||||||||||||||||||||||||
| QWidget::showEvent(event); | ||||||||||||||||||||||||||
| QMetaObject::invokeMethod(this, [this]() { | ||||||||||||||||||||||||||
| updateSize(); | ||||||||||||||||||||||||||
| resize(size()); | ||||||||||||||||||||||||||
| }, Qt::QueuedConnection); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| void hideEvent(QHideEvent *event) override | ||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||
| QWidget::hideEvent(event); | ||||||||||||||||||||||||||
| m_minHeight = -1; | ||||||||||||||||||||||||||
| // 隐藏时更新尺寸为折叠状态,确保下次显示时初始尺寸正确 | ||||||||||||||||||||||||||
| QMetaObject::invokeMethod(this, "updateSize", Qt::QueuedConnection); | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
Comment on lines
+107
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Mixed styles of QMetaObject::invokeMethod reduce type safety and consistency. In
Suggested change
|
||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| private: | ||||||||||||||||||||||||||
| QVBoxLayout *m_mainLayout; | ||||||||||||||||||||||||||
| NetView *m_netView; | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (complexity): Consider extracting the deferred sizing behavior into a shared helper to centralize logic and avoid string-based invokeMethod usage while preserving current show/hide behavior.
You can reduce the new complexity by centralizing the deferred sizing logic and avoiding the string-based
invokeMethodwhile keeping behavior (immediate + deferred updates, min-height reset, resize) intact.1. Centralize deferred sizing
Extract the queued sizing logic to a small helper, used from both
showEventandhideEvent. This removes duplication and makes the async behavior explicit:2. Simplify
showEventandhideEventwith the helperReuse the helper so the control flow is easy to follow and you no longer need the string-based overload:
This keeps all current behavior (immediate sizing on show, deferred re-sizes, min-height reset on hide) but removes duplicated lambdas, avoids string-based
invokeMethod, and makes the deferred sizing semantics clear and centralized.