Fixed deprecated method QFontMetrics::width (#2509)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -320,7 +320,7 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||
|
||||
// fourtf: add again
|
||||
// if (word.width == -1) {
|
||||
word.width = metrics.width(word.text);
|
||||
word.width = metrics.horizontalAdvance(word.text);
|
||||
// }
|
||||
|
||||
// see if the text fits in the current line
|
||||
@@ -357,8 +357,9 @@ void TextElement::addToContainer(MessageLayoutContainer &container,
|
||||
auto isSurrogate = text.size() > i + 1 &&
|
||||
QChar::isHighSurrogate(text[i].unicode());
|
||||
|
||||
auto charWidth = isSurrogate ? metrics.width(text.mid(i, 2))
|
||||
: metrics.width(text[i]);
|
||||
auto charWidth = isSurrogate
|
||||
? metrics.horizontalAdvance(text.mid(i, 2))
|
||||
: metrics.horizontalAdvance(text[i]);
|
||||
|
||||
if (!container.fitsInLine(width + charWidth))
|
||||
{
|
||||
@@ -585,7 +586,7 @@ void IrcTextElement::addToContainer(MessageLayoutContainer &container,
|
||||
|
||||
// fourtf: add again
|
||||
// if (word.width == -1) {
|
||||
word.width = metrics.width(word.text);
|
||||
word.width = metrics.horizontalAdvance(word.text);
|
||||
// }
|
||||
|
||||
// see if the text fits in the current line
|
||||
@@ -632,8 +633,9 @@ void IrcTextElement::addToContainer(MessageLayoutContainer &container,
|
||||
auto isSurrogate = text.size() > i + 1 &&
|
||||
QChar::isHighSurrogate(text[i].unicode());
|
||||
|
||||
auto charWidth = isSurrogate ? metrics.width(text.mid(i, 2))
|
||||
: metrics.width(text[i]);
|
||||
auto charWidth = isSurrogate
|
||||
? metrics.horizontalAdvance(text.mid(i, 2))
|
||||
: metrics.horizontalAdvance(text[i]);
|
||||
|
||||
if (!container.fitsInLine(width + charWidth))
|
||||
{
|
||||
|
||||
@@ -43,8 +43,8 @@ void MessageLayoutContainer::begin(int width, float scale, MessageFlags flags)
|
||||
auto mediumFontMetrics =
|
||||
getApp()->fonts->getFontMetrics(FontStyle::ChatMedium, scale);
|
||||
this->textLineHeight_ = mediumFontMetrics.height();
|
||||
this->spaceWidth_ = mediumFontMetrics.width(' ');
|
||||
this->dotdotdotWidth_ = mediumFontMetrics.width("...");
|
||||
this->spaceWidth_ = mediumFontMetrics.horizontalAdvance(' ');
|
||||
this->dotdotdotWidth_ = mediumFontMetrics.horizontalAdvance("...");
|
||||
this->canAddMessages_ = true;
|
||||
this->isCollapsed_ = false;
|
||||
}
|
||||
|
||||
@@ -270,7 +270,7 @@ int TextLayoutElement::getMouseOverIndex(const QPoint &abs) const
|
||||
for (auto i = 0; i < this->getText().size(); i++)
|
||||
{
|
||||
auto &&text = this->getText();
|
||||
auto width = metrics.width(this->getText()[i]);
|
||||
auto width = metrics.horizontalAdvance(this->getText()[i]);
|
||||
|
||||
if (x + width > abs.x())
|
||||
{
|
||||
@@ -309,7 +309,7 @@ int TextLayoutElement::getXFromIndex(int index)
|
||||
int x = 0;
|
||||
for (int i = 0; i < index; i++)
|
||||
{
|
||||
x += metrics.width(this->getText()[i]);
|
||||
x += metrics.horizontalAdvance(this->getText()[i]);
|
||||
}
|
||||
return x + this->getRect().left();
|
||||
}
|
||||
@@ -429,7 +429,7 @@ void MultiColorTextLayoutElement::paint(QPainter &painter)
|
||||
this->getRect().y(), 10000, 10000),
|
||||
segment.text,
|
||||
QTextOption(Qt::AlignLeft | Qt::AlignTop));
|
||||
xOffset += metrics.width(segment.text);
|
||||
xOffset += metrics.horizontalAdvance(segment.text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user