mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-14 21:37:52 -07:00
DolphinQt: Use QFontMetrics::boundingRect instead of QFontMetrics::width
See https://kdepepo.wordpress.com/2019/08/05/about-deprecation-of-qfontmetricswidth/
This commit is contained in:
parent
d89162c8ad
commit
87330ae524
@ -230,7 +230,6 @@ add_executable(dolphin-emu
|
||||
QtUtils/FileOpenEventFilter.h
|
||||
QtUtils/FlowLayout.cpp
|
||||
QtUtils/FlowLayout.h
|
||||
QtUtils/FontMetricsHelper.h
|
||||
QtUtils/ModalMessageBox.cpp
|
||||
QtUtils/ModalMessageBox.h
|
||||
QtUtils/ParallelProgressDialog.h
|
||||
|
@ -31,7 +31,6 @@
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "DolphinQt/Debugger/PatchInstructionDialog.h"
|
||||
#include "DolphinQt/Host.h"
|
||||
#include "DolphinQt/QtUtils/FontMetricsHelper.h"
|
||||
#include "DolphinQt/Resources.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
@ -201,7 +200,7 @@ void CodeViewWidget::FontBasedSizing()
|
||||
horizontalHeader()->setMinimumSectionSize(rowh + 5);
|
||||
setColumnWidth(CODE_VIEW_COLUMN_BREAKPOINT, rowh + 5);
|
||||
setColumnWidth(CODE_VIEW_COLUMN_ADDRESS,
|
||||
FontMetricsWidth(fm, QStringLiteral("80000000")) + extra_text_width);
|
||||
fm.boundingRect(QStringLiteral("80000000")).width() + extra_text_width);
|
||||
|
||||
// The longest instruction is technically 'ps_merge00' (0x10000420u), but those instructions are
|
||||
// very rare and would needlessly increase the column size, so let's go with 'rlwinm.' instead.
|
||||
@ -213,11 +212,11 @@ void CodeViewWidget::FontBasedSizing()
|
||||
const std::string ins = (split == std::string::npos ? disas : disas.substr(0, split));
|
||||
const std::string param = (split == std::string::npos ? "" : disas.substr(split + 1));
|
||||
setColumnWidth(CODE_VIEW_COLUMN_INSTRUCTION,
|
||||
FontMetricsWidth(fm, QString::fromStdString(ins)) + extra_text_width);
|
||||
fm.boundingRect(QString::fromStdString(ins)).width() + extra_text_width);
|
||||
setColumnWidth(CODE_VIEW_COLUMN_PARAMETERS,
|
||||
FontMetricsWidth(fm, QString::fromStdString(param)) + extra_text_width);
|
||||
fm.boundingRect(QString::fromStdString(param)).width() + extra_text_width);
|
||||
setColumnWidth(CODE_VIEW_COLUMN_DESCRIPTION,
|
||||
FontMetricsWidth(fm, QStringLiteral("0")) * 25 + extra_text_width);
|
||||
fm.boundingRect(QChar(u'0')).width() * 25 + extra_text_width);
|
||||
|
||||
Update();
|
||||
}
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "Core/PowerPC/MMU.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "DolphinQt/Host.h"
|
||||
#include "DolphinQt/QtUtils/FontMetricsHelper.h"
|
||||
#include "DolphinQt/Settings.h"
|
||||
|
||||
ThreadWidget::ThreadWidget(QWidget* parent) : QDockWidget(parent)
|
||||
@ -135,7 +134,7 @@ QLineEdit* ThreadWidget::CreateLineEdit() const
|
||||
QLineEdit* line_edit = new QLineEdit(QLatin1Literal("00000000"));
|
||||
line_edit->setReadOnly(true);
|
||||
line_edit->setFixedWidth(
|
||||
FontMetricsWidth(line_edit->fontMetrics(), QLatin1Literal(" 00000000 ")));
|
||||
line_edit->fontMetrics().boundingRect(QLatin1Literal(" 00000000 ")).width());
|
||||
return line_edit;
|
||||
}
|
||||
|
||||
|
@ -457,7 +457,6 @@
|
||||
<ClInclude Include="Config\Mapping\MappingCommon.h" />
|
||||
<ClInclude Include="Debugger\RegisterColumn.h" />
|
||||
<ClInclude Include="QtUtils\ActionHelper.h" />
|
||||
<ClInclude Include="QtUtils\FontMetricsHelper.h" />
|
||||
<ClInclude Include="QtUtils\ImageConverter.h" />
|
||||
<ClInclude Include="QtUtils\QueueOnObject.h" />
|
||||
<ClInclude Include="QtUtils\RunOnObject.h" />
|
||||
|
@ -1,20 +0,0 @@
|
||||
// Copyright 2020 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <utility>
|
||||
|
||||
#include <QFontMetrics>
|
||||
|
||||
// This exists purely to get rid of deprecation warnings while still supporting older Qt versions
|
||||
template <typename... Args>
|
||||
int FontMetricsWidth(const QFontMetrics& fm, Args&&... args)
|
||||
{
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)
|
||||
return fm.horizontalAdvance(std::forward<Args>(args)...);
|
||||
#else
|
||||
return fm.width(std::forward<Args>(args)...);
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user