fix: use GUIUtil::TextWidth() instead deprecated width()

It fixes this warning:
```
qt/trafficgraphwidget.cpp:177:42: warning: ‘int QFontMetrics::width(const QString&, int) const’ is deprecated: Use QFontMetrics::horizontalAdvance [-Wdeprecated-declarations]
  177 |     const int nWidthBytes = fmInOut.width("1000 GB") + 2 * nPadding;
```
This commit is contained in:
Konstantin Akimov 2023-11-06 00:41:25 +07:00 committed by PastaPastaPasta
parent 66432fd04e
commit f2e8431f4a
2 changed files with 3 additions and 3 deletions

View File

@ -1305,7 +1305,7 @@ bool loadFonts()
auto supportedWeights = [](FontFamily family) -> std::vector<QFont::Weight> {
auto getTestWidth = [&](QFont::Weight weight) -> int {
QFont font = getFont(family, weight, false, defaultFontSize);
return QFontMetrics(font).width("Check the width of this text to see if the weight change has an impact!");
return TextWidth(QFontMetrics(font), ("Check the width of this text to see if the weight change has an impact!"));
};
std::vector<QFont::Weight> vecWeights{QFont::Thin, QFont::ExtraLight, QFont::Light,
QFont::Normal, QFont::Medium, QFont::DemiBold,

View File

@ -173,8 +173,8 @@ void TrafficGraphWidget::paintEvent(QPaintEvent *)
QFontMetrics fmTotal(fontTotal);
QFontMetrics fmInOut(fontInOut);
const int nSizeMark = fmInOut.height() + 2 * nPadding;
const int nWidthText = fmInOut.width(strReceived) + 2 * nPadding;
const int nWidthBytes = fmInOut.width("1000 GB") + 2 * nPadding;
const int nWidthText = GUIUtil::TextWidth(fmInOut, strReceived) + 2 * nPadding;
const int nWidthBytes = GUIUtil::TextWidth(fmInOut, "1000 GB") + 2 * nPadding;
const int nHeightTotals = fmTotal.height() + 2 * nPadding;
const int nHeightInOut = fmInOut.height() + 2 * nPadding;
const int nWidthStats = nSizeMark + nWidthText + nWidthBytes + 2 * nPadding;