From acbf68cca31e447a081ee7fd968362dbd5b4c0b1 Mon Sep 17 00:00:00 2001 From: Zhang Qipeng Date: Thu, 7 Jan 2021 21:56:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=97=B6=E9=97=B4=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 任务栏参数变化时,时间插件没有同步刷新布局。 Log: 修复时间插件显示异常的问题。 Bug: https://pms.uniontech.com/zentao/bug-view-59013.html Bug: https://pms.uniontech.com/zentao/bug-view-60340.html Bug: https://pms.uniontech.com/zentao/bug-view-59126.html Change-Id: I6df9a6155dcff38758ef06b2ca12826761037fab --- frame/panel/mainpanelcontrol.cpp | 18 +++++++++++++++++- frame/panel/mainpanelcontrol.h | 1 + frame/window/mainwindow.cpp | 1 + plugins/datetime/datetimewidget.cpp | 5 ++--- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index 99746d82d..bdfdd993c 100755 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -342,6 +342,9 @@ void MainPanelControl::insertItem(int index, DockItem *item) break; } resizeDockIcon(); + QTimer::singleShot(0, [ = ] { + updatePluginsLayout(); + }); } void MainPanelControl::removeItem(DockItem *item) @@ -869,9 +872,22 @@ void MainPanelControl::moveAppSonWidget() m_appAreaSonWidget->move(rect.x(), rect.y()); } +void MainPanelControl::updatePluginsLayout() +{ + for (int i = 0; i < m_pluginLayout->count(); ++i) { + QLayout *layout = m_pluginLayout->itemAt(i)->layout(); + if (layout) { + PluginsItem *pItem = static_cast(layout->itemAt(0)->widget()); + if (pItem && pItem->sizeHint().width() != -1) { + pItem->updateGeometry(); + } + } + } +} + void MainPanelControl::itemUpdated(DockItem *item) { - item->parentWidget()->adjustSize(); + item->updateGeometry(); resizeDockIcon(); } diff --git a/frame/panel/mainpanelcontrol.h b/frame/panel/mainpanelcontrol.h index 6ca8b7fa7..e6ecb06af 100755 --- a/frame/panel/mainpanelcontrol.h +++ b/frame/panel/mainpanelcontrol.h @@ -65,6 +65,7 @@ public: void setPositonValue(Position position); void setDisplayMode(DisplayMode dislayMode); void getTrayVisableItemCount(); + void updatePluginsLayout(); MainPanelDelegate *delegate() const; void setDelegate(MainPanelDelegate *delegate); diff --git a/frame/window/mainwindow.cpp b/frame/window/mainwindow.cpp index 4e8c88f1d..598570229 100755 --- a/frame/window/mainwindow.cpp +++ b/frame/window/mainwindow.cpp @@ -254,6 +254,7 @@ void MainWindow::resizeEvent(QResizeEvent *event) // 任务栏大小、位置、模式改变都会触发resize,发射大小改变信号,供依赖项目更新位置 Q_EMIT panelGeometryChanged(); + m_mainPanel->updatePluginsLayout(); m_shadowMaskOptimizeTimer->start(); return DBlurEffectWidget::resizeEvent(event); diff --git a/plugins/datetime/datetimewidget.cpp b/plugins/datetime/datetimewidget.cpp index 227e789f1..50fbc0ef0 100644 --- a/plugins/datetime/datetimewidget.cpp +++ b/plugins/datetime/datetimewidget.cpp @@ -61,7 +61,6 @@ void DatetimeWidget::set24HourFormat(const bool value) m_24HourFormat = value; update(); - adjustSize(); if (isVisible()) { emit requestUpdateGeometry(); } @@ -86,7 +85,7 @@ void DatetimeWidget::setShortDateFormat(int type) default: m_shortDateFormat = "yyyy-MM-dd"; break; } update(); - adjustSize(); + if (isVisible()) { emit requestUpdateGeometry(); } @@ -104,7 +103,7 @@ void DatetimeWidget::setShortTimeFormat(int type) default: m_shortTimeFormat = "hh:mm"; break; } update(); - adjustSize(); + if (isVisible()) { emit requestUpdateGeometry(); }