Skip to content

Commit

Permalink
DolphinQt: Use QFontMetrics::boundingRect instead of QFontMetrics::width
Browse files Browse the repository at this point in the history
  • Loading branch information
JosJuice committed Jun 8, 2020
1 parent d89162c commit 87330ae
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 29 deletions.
1 change: 0 additions & 1 deletion Source/Core/DolphinQt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions Source/Core/DolphinQt/Debugger/CodeViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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.
Expand All @@ -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();
}
Expand Down
3 changes: 1 addition & 2 deletions Source/Core/DolphinQt/Debugger/ThreadWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion Source/Core/DolphinQt/DolphinQt.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -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" />
Expand Down
20 changes: 0 additions & 20 deletions Source/Core/DolphinQt/QtUtils/FontMetricsHelper.h

This file was deleted.

0 comments on commit 87330ae

Please sign in to comment.