Skip to content

Commit

Permalink
Fix double * for long names of changed documents
Browse files Browse the repository at this point in the history
We used to elide the right part of the name, and needed to take care of
not eliding the * away in that case. Now we elide in the middle, and in
that case the * may not be added to the elided text again.

Change-Id: I646b51d315e141a65df67841e163826e7136c118
Reviewed-by: Christian Stenger <[email protected]>
  • Loading branch information
e4z9 committed Nov 23, 2022
1 parent b771608 commit 373200a
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/plugins/coreplugin/manhattanstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -874,21 +874,24 @@ void ManhattanStyle::drawControl(ControlElement element, const QStyleOption *opt
editRect.adjust(0, 0, -13, 0);
}

Qt::TextElideMode elideMode = Qt::ElideRight;
if (widget && widget->dynamicPropertyNames().contains("elidemode"))
elideMode = widget->property("elidemode").value<Qt::TextElideMode>();

QLatin1Char asterisk('*');
int elideWidth = editRect.width();

bool notElideAsterisk = widget && widget->property("notelideasterisk").toBool()
bool notElideAsterisk = elideMode == Qt::ElideRight && widget
&& widget->property("notelideasterisk").toBool()
&& cb->currentText.endsWith(asterisk)
&& option->fontMetrics.horizontalAdvance(cb->currentText) > elideWidth;
&& option->fontMetrics.horizontalAdvance(cb->currentText)
> elideWidth;

QString text;
if (notElideAsterisk) {
elideWidth -= option->fontMetrics.horizontalAdvance(asterisk);
text = asterisk;
}
Qt::TextElideMode elideMode = Qt::ElideRight;
if (widget && widget->dynamicPropertyNames().contains("elidemode"))
elideMode = widget->property("elidemode").value<Qt::TextElideMode>();
text.prepend(option->fontMetrics.elidedText(cb->currentText, elideMode, elideWidth));

if (creatorTheme()->flag(Theme::ComboBoxDrawTextShadow)
Expand Down

0 comments on commit 373200a

Please sign in to comment.