mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Port from QFontMetrics::width() to boundingRect().width()
Summary: In all the cases that were changed, the bounding rect is needed. A few places were not ported, since they need more careful investigation. This reduces deprecation warnings. Reviewers: #konsole, hindenburg Reviewed By: #konsole, hindenburg Subscribers: hindenburg, konsole-devel Tags: #konsole Differential Revision: https://phabricator.kde.org/D23144
This commit is contained in:
committed by
Kurt Hindenburg
parent
5f141c16ab
commit
6a06431962
@@ -87,7 +87,7 @@ ColorSchemeEditor::ColorSchemeEditor(QWidget *parent) :
|
||||
|
||||
// transparency slider
|
||||
QFontMetrics metrics(font());
|
||||
_ui->transparencyPercentLabel->setMinimumWidth(metrics.width(QStringLiteral("100%")));
|
||||
_ui->transparencyPercentLabel->setMinimumWidth(metrics.boundingRect(QStringLiteral("100%")).width());
|
||||
|
||||
connect(_ui->transparencySlider, &QSlider::valueChanged, this,
|
||||
&Konsole::ColorSchemeEditor::setTransparencyPercentLabel);
|
||||
|
||||
@@ -962,7 +962,7 @@ bool EditProfileDialog::eventFilter(QObject *watched, QEvent *event)
|
||||
QSize EditProfileDialog::sizeHint() const
|
||||
{
|
||||
QFontMetrics fm(font());
|
||||
const int ch = fm.width(QLatin1Char('0'));
|
||||
const int ch = fm.boundingRect(QLatin1Char('0')).width();
|
||||
|
||||
// By default minimum size is used. Increase it to make text inputs
|
||||
// on "tabs" page wider and to add some whitespace on right side
|
||||
@@ -1736,10 +1736,10 @@ int EditProfileDialog::maxSpinBoxWidth(const KPluralHandlingSpinBox *spinBox, co
|
||||
const QString singular = suffix.subs(1).toString();
|
||||
const QString min = QString::number(spinBox->minimum());
|
||||
const QString max = QString::number(spinBox->maximum());
|
||||
const int pluralWidth = fm.width(plural);
|
||||
const int singularWidth = fm.width(singular);
|
||||
const int minWidth = fm.width(min);
|
||||
const int maxWidth = fm.width(max);
|
||||
const int pluralWidth = fm.boundingRect(plural).width();
|
||||
const int singularWidth = fm.boundingRect(singular).width();
|
||||
const int minWidth = fm.boundingRect(min).width();
|
||||
const int maxWidth = fm.boundingRect(max).width();
|
||||
const int width = qMax(pluralWidth, singularWidth) + qMax(minWidth, maxWidth) + cursorWidth;
|
||||
|
||||
// Based on QAbstractSpinBox::initStyleOption() from Qt
|
||||
@@ -1905,7 +1905,7 @@ void ColorSchemeViewDelegate::paint(QPainter *painter, const QStyleOptionViewIte
|
||||
// Determine width of sample text using profile's font
|
||||
const QString sampleText = i18n("AaZz09...");
|
||||
QFontMetrics profileFontMetrics(profileFont);
|
||||
const int sampleTextWidth = profileFontMetrics.width(sampleText);
|
||||
const int sampleTextWidth = profileFontMetrics.boundingRect(sampleText).width();
|
||||
|
||||
painter->drawText(option.rect.adjusted(sampleTextWidth + 15, 0, 0, 0),
|
||||
Qt::AlignLeft | Qt::AlignVCenter,
|
||||
|
||||
@@ -1251,7 +1251,7 @@ void TerminalDisplay::showResizeNotification()
|
||||
if (_showTerminalSizeHint && isVisible()) {
|
||||
if (_resizeWidget == nullptr) {
|
||||
_resizeWidget = new QLabel(i18n("Size: XXX x XXX"), this);
|
||||
_resizeWidget->setMinimumWidth(_resizeWidget->fontMetrics().width(i18n("Size: XXX x XXX")));
|
||||
_resizeWidget->setMinimumWidth(_resizeWidget->fontMetrics().boundingRect(i18n("Size: XXX x XXX")).width());
|
||||
_resizeWidget->setMinimumHeight(_resizeWidget->sizeHint().height());
|
||||
_resizeWidget->setAlignment(Qt::AlignCenter);
|
||||
|
||||
|
||||
@@ -509,7 +509,7 @@ QSize Konsole::ShortcutItemDelegate::sizeHint(const QStyleOptionViewItem &option
|
||||
QFontMetrics fm = option.fontMetrics;
|
||||
|
||||
static const int editorMargins = 16; // chosen empirically
|
||||
const int width = fm.width(shortcutString + QStringLiteral(", ..."))
|
||||
const int width = fm.boundingRect(shortcutString + QStringLiteral(", ...")).width()
|
||||
+ editorMargins;
|
||||
|
||||
return {width, QStyledItemDelegate::sizeHint(option, index).height()};
|
||||
|
||||
Reference in New Issue
Block a user