mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
fix: set limit width to textLabel to correct text elide behavior
Log: 设置宽度限制以纠正文本省略行为
This commit is contained in:
parent
9661d3568f
commit
83865c93de
@ -95,11 +95,11 @@ QWidget *StandardQuickItem::iconWidget(QWidget *parent)
|
||||
|
||||
QLabel *labelText = new QLabel(widget);
|
||||
labelText->setObjectName("textLabel");
|
||||
labelText->setFixedHeight(TEXTHEIGHT);
|
||||
labelText->setFixedWidth(this->width());
|
||||
updatePluginName(labelText);
|
||||
labelText->setAlignment(Qt::AlignCenter);
|
||||
labelText->setFont(DFontSizeManager::instance()->t10());
|
||||
labelText->setFixedHeight(TEXTHEIGHT);
|
||||
labelText->setFixedWidth(70);
|
||||
updatePluginName(labelText);
|
||||
layout->addWidget(imageLabel);
|
||||
layout->addSpacing(7);
|
||||
layout->addWidget(labelText);
|
||||
@ -157,13 +157,14 @@ void StandardQuickItem::updatePluginName(QLabel *textLabel)
|
||||
if (text.isEmpty())
|
||||
text = pluginItem()->pluginDisplayName();
|
||||
QFontMetrics ftm(textLabel->font());
|
||||
if (ftm.boundingRect(text).width() > textLabel->width()) {
|
||||
if (ftm.boundingRect(text).width() > 70) {
|
||||
this->setToolTip(text);
|
||||
} else {
|
||||
this->setToolTip("");
|
||||
}
|
||||
text = ftm.elidedText(text, Qt::TextElideMode::ElideMiddle, textLabel->width());
|
||||
text = ftm.elidedText(text, Qt::TextElideMode::ElideMiddle, 70);
|
||||
textLabel->setText(text);
|
||||
qInfo() << "text update to: " << text;
|
||||
}
|
||||
|
||||
void StandardQuickItem::doUpdate()
|
||||
|
Loading…
x
Reference in New Issue
Block a user