mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
fix: 修复窗口特效关闭后任务栏预览时文字截断的问题
激活窗口标题宽度计算错误 Log: Bug: https://pms.uniontech.com/zentao/bug-view-110343.html Influence: 任务栏-关闭窗口特效-预览时文字显示正常,标题过长时显示省略号 Change-Id: Idd948564d721398201555fa99fae483055b23b88
This commit is contained in:
parent
a3fa0a60ff
commit
4258dd5690
@ -182,7 +182,7 @@ void AppSnapshot::setWindowInfo(const WindowInfo &info)
|
||||
{
|
||||
m_windowInfo = info;
|
||||
QFontMetrics fm(m_title->font());
|
||||
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, width() - m_closeBtn2D->width());
|
||||
QString strTtile = m_title->fontMetrics().elidedText(m_windowInfo.title, Qt::ElideRight, SNAP_WIDTH - SNAP_CLOSE_BTN_WIDTH - SNAP_CLOSE_BTN_MARGIN);
|
||||
m_title->setText(strTtile);
|
||||
updateTitle();
|
||||
|
||||
|
@ -185,19 +185,23 @@ void PreviewContainer::adjustSize(bool composite)
|
||||
count = qMin(count, screenWidth / SNAP_HEIGHT_WITHOUT_COMPOSITE);
|
||||
const int h = SNAP_HEIGHT_WITHOUT_COMPOSITE * count + MARGIN * 2 + SPACING * (count - 1);
|
||||
|
||||
// 根据appitem title 设置自适应宽度
|
||||
auto appSnapshot = static_cast<AppSnapshot *>(m_windowListLayout->itemAt(0)->widget());
|
||||
|
||||
auto font = appSnapshot->layout()->itemAt(0)->widget()->font();
|
||||
QFontMetrics fontMetrics(font);
|
||||
const int titleWidth = fontMetrics.boundingRect(appSnapshot->title()).width();
|
||||
|
||||
// 获取 appitem title 的最大宽度
|
||||
int titleWidth = fontMetrics.boundingRect(appSnapshot->title()).width();
|
||||
for (int i = 0; i < m_windowListLayout->count(); i++) {
|
||||
auto otherWidget = static_cast<AppSnapshot *>(m_windowListLayout->itemAt(i)->widget());
|
||||
titleWidth = qMax(titleWidth, fontMetrics.boundingRect(otherWidget->title()).width());
|
||||
}
|
||||
|
||||
// 关闭按键的宽度和边缘间距的和,调整标题居中
|
||||
const int closeBtnMargin = 2 * (SNAP_CLOSE_BTN_WIDTH + SNAP_CLOSE_BTN_MARGIN);
|
||||
if (titleWidth < SNAP_WIDTH - closeBtnMargin) {
|
||||
if (titleWidth < SNAP_WIDTH - closeBtnMargin)
|
||||
setFixedSize(titleWidth + closeBtnMargin, h);
|
||||
} else {
|
||||
else
|
||||
setFixedSize(SNAP_WIDTH, h);
|
||||
}
|
||||
}
|
||||
|
||||
//根据计算的数量,将相应的预览界面添加到布局并显示,其他的暂时不添加,减少界面刷新次数
|
||||
|
Loading…
x
Reference in New Issue
Block a user