mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: 修复时尚模型下图标铺满任务栏的显示问题
时尚模式下,计算任务栏的图标的尺寸和任务栏应用区域尺寸的时候,没有考虑托盘区域的尺寸,导致应用区域的尺寸过大,当图标铺满任务栏的时候,将整个任务栏挤出到屏幕外 Log: 修复任务栏时尚模式下的图标的显示问题 Influence: 时尚模式下,不断向任务栏添加图标,知道铺满,观察任务栏是否在屏幕可见区域内 Task: https://pms.uniontech.com/task-view-150049.html Change-Id: Ie3a3a459df7dd4fb127f6e7daa2e8b1c60a88c30
This commit is contained in:
parent
e663e4ac16
commit
1e87fd5122
@ -268,7 +268,7 @@ void MainPanelControl::updateMainPanelLayout()
|
||||
*/
|
||||
void MainPanelControl::addFixedAreaItem(int index, QWidget *wdg)
|
||||
{
|
||||
if(m_position == Position::Top || m_position == Position::Bottom){
|
||||
if(m_position == Position::Top || m_position == Position::Bottom) {
|
||||
wdg->setMaximumSize(height(),height());
|
||||
} else {
|
||||
wdg->setMaximumSize(width(),width());
|
||||
@ -1006,6 +1006,8 @@ QSize MainPanelControl::suitableSize(const Position &position, int screenSize, d
|
||||
|
||||
// 如果是特效模式
|
||||
int totalLength = static_cast<int>(screenSize / ratio);
|
||||
// 减去插件区域的尺寸
|
||||
totalLength -= trayAreaSize();
|
||||
// 需要参与计算的图标的总数
|
||||
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + m_recentLayout->count() + m_toolSonLayout->count();
|
||||
int multiWindowCount = m_multiWindowLayout->count();
|
||||
@ -1116,6 +1118,27 @@ int MainPanelControl::getScreenSize() const
|
||||
return screenRect.height();
|
||||
}
|
||||
|
||||
int MainPanelControl::trayAreaSize() const
|
||||
{
|
||||
if (m_displayMode == Dock::DisplayMode::Efficient)
|
||||
return (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom ? m_tray->width() : m_tray->height());
|
||||
|
||||
int length = 0;
|
||||
QWidgetList topLevelWidgets = qApp->topLevelWidgets();
|
||||
for (QWidget *widget : topLevelWidgets) {
|
||||
MainWindowBase *topWindow = qobject_cast<MainWindowBase *>(widget);
|
||||
if (!topWindow)
|
||||
continue;
|
||||
|
||||
if (topWindow->windowType() != MainWindowBase::DockWindowType::MainWindow)
|
||||
length += (m_position == Dock::Position::Top || m_position == Dock::Position::Bottom ? topWindow->width() : topWindow->height());
|
||||
|
||||
length += topWindow->dockSpace();
|
||||
}
|
||||
|
||||
return length;
|
||||
}
|
||||
|
||||
/**重新计算任务栏上应用图标、插件图标的大小,并设置
|
||||
* @brief MainPanelControl::resizeDockIcon
|
||||
*/
|
||||
@ -1125,10 +1148,8 @@ void MainPanelControl::resizeDockIcon()
|
||||
int tray_item_size = 0;
|
||||
// 总宽度
|
||||
if (m_displayMode == DisplayMode::Fashion) {
|
||||
int iconCount = 0;
|
||||
// 时尚模式
|
||||
int totalLength = getScreenSize();
|
||||
iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count();
|
||||
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count();
|
||||
if (m_recentAreaWidget->isVisible())
|
||||
iconCount += m_recentLayout->count();
|
||||
|
||||
@ -1138,6 +1159,15 @@ void MainPanelControl::resizeDockIcon()
|
||||
if (iconCount <= 0)
|
||||
return;
|
||||
|
||||
int totalLength = getScreenSize() - trayAreaSize();
|
||||
|
||||
if (m_fixedSpliter->isVisible())
|
||||
totalLength -= SPLITER_SIZE;
|
||||
if (m_appSpliter->isVisible())
|
||||
totalLength -= SPLITER_SIZE;
|
||||
if (m_recentSpliter->isVisible())
|
||||
totalLength -= SPLITER_SIZE;
|
||||
|
||||
// 余数
|
||||
int yu = (totalLength % iconCount);
|
||||
// icon宽度 = (总宽度-余数)/icon个数
|
||||
@ -1161,9 +1191,14 @@ void MainPanelControl::resizeDockIcon()
|
||||
iconSize = (totalLength - yu) / iconCount;
|
||||
} else {
|
||||
int totalLength = ((m_position == Position::Top) || (m_position == Position::Bottom)) ? width() : height();
|
||||
totalLength -= m_tray->width();
|
||||
totalLength -= trayAreaSize();
|
||||
// 减去3个分割线的宽度
|
||||
totalLength -= 3 * SPLITER_SIZE;
|
||||
if (m_fixedSpliter->isVisible())
|
||||
totalLength -= SPLITER_SIZE;
|
||||
if (m_appSpliter->isVisible())
|
||||
totalLength -= SPLITER_SIZE;
|
||||
if (m_recentSpliter->isVisible())
|
||||
totalLength -= SPLITER_SIZE;
|
||||
|
||||
int pluginItemCount = 0;
|
||||
int calcPluginItemCount = 0;
|
||||
@ -1221,9 +1256,6 @@ void MainPanelControl::resizeDockIcon()
|
||||
if (tray_item_size < 20)
|
||||
tray_item_size = 20;
|
||||
|
||||
// 减去插件图标的大小后重新计算固定图标和应用图标的平均大小
|
||||
totalLength -= m_tray->width();//tray_item_size * pluginCount;
|
||||
|
||||
// 余数
|
||||
yu = (totalLength % iconCount);
|
||||
// icon宽度 = (总宽度-余数)/icon个数
|
||||
|
@ -78,6 +78,7 @@ private:
|
||||
void removeFixedAreaItem(QWidget *wdg);
|
||||
void removeAppAreaItem(QWidget *wdg);
|
||||
int getScreenSize() const;
|
||||
int trayAreaSize() const;
|
||||
|
||||
// 拖拽相关
|
||||
void startDrag(DockItem *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user