1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-25 04:02:42 +01:00

Qt: Simplify some string conversion bloat

This commit is contained in:
Megamouse 2024-09-24 02:37:34 +02:00
parent 82f97d33d1
commit c4282e63fb
10 changed files with 16 additions and 37 deletions

View File

@ -13,8 +13,6 @@
LOG_CHANNEL(autopause_log, "AutoPause");
constexpr auto qstr = QString::fromStdString;
auto_pause_settings_dialog::auto_pause_settings_dialog(QWidget *parent) : QDialog(parent)
{
QLabel *description = new QLabel(tr("To use auto pause: enter the ID(s) of a function or a system call.\nRestart of the game is required to apply. You can enable/disable this in the settings."), this);
@ -127,7 +125,7 @@ void auto_pause_settings_dialog::UpdateList()
typeItem->setFlags(typeItem->flags() & ~Qt::ItemIsEditable);
if (m_entries[i] != 0xFFFFFFFF)
{
callItem->setData(Qt::DisplayRole, qstr(fmt::format("%08x", m_entries[i])));
callItem->setData(Qt::DisplayRole, QString::fromStdString(fmt::format("%08x", m_entries[i])));
}
else
{
@ -230,7 +228,7 @@ AutoPauseConfigDialog::AutoPauseConfigDialog(QWidget* parent, auto_pause_setting
m_current_converted->setWordWrap(true);
m_id = new QLineEdit(this);
m_id->setText(qstr(fmt::format("%08x", m_entry)));
m_id->setText(QString::fromStdString(fmt::format("%08x", m_entry)));
m_id->setPlaceholderText("ffffffff");
m_id->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
m_id->setMaxLength(8);

View File

@ -9,8 +9,6 @@
#include <QMessageBox>
#include <QMouseEvent>
constexpr auto qstr = QString::fromStdString;
extern bool is_using_interpreter(thread_class t_class);
breakpoint_list::breakpoint_list(QWidget* parent, breakpoint_handler* handler) : QListWidget(parent), m_ppu_breakpoint_handler(handler)
@ -83,7 +81,7 @@ bool breakpoint_list::AddBreakpoint(u32 pc)
m_disasm->disasm(pc);
QString text = qstr(m_disasm->last_opcode);
QString text = QString::fromStdString(m_disasm->last_opcode);
text.remove(10, 13);
QListWidgetItem* breakpoint_item = new QListWidgetItem(text);

View File

@ -5,8 +5,6 @@
#include <QKeyEvent>
#include <QMouseEvent>
constexpr auto qstr = QString::fromStdString;
call_stack_list::call_stack_list(QWidget* parent) : QListWidget(parent)
{
setEditTriggers(QAbstractItemView::NoEditTriggers);
@ -37,7 +35,7 @@ void call_stack_list::HandleUpdate(const std::vector<std::pair<u32, u32>>& call_
for (const auto& addr : call_stack)
{
const QString text = qstr(fmt::format("0x%08llx (sp=0x%08llx)", addr.first, addr.second));
const QString text = QString::fromStdString(fmt::format("0x%08llx (sp=0x%08llx)", addr.first, addr.second));
QListWidgetItem* call_stack_item = new QListWidgetItem(text);
call_stack_item->setData(Qt::UserRole, { addr.first });
addItem(call_stack_item);

View File

@ -8,8 +8,6 @@
#include <QValidator>
#include <QLabel>
constexpr auto qstr = QString::fromStdString;
input_dialog::input_dialog(int max_length, const QString& text, const QString& title, const QString& label, const QString& placeholder, QWidget *parent, Qt::WindowFlags f)
: QDialog(parent, f)
{
@ -50,7 +48,7 @@ void input_dialog::set_input_font(const QFont& font, bool fix_width, char sample
{
if (const int max = m_input->maxLength(); max > 0 && fix_width && std::isprint(static_cast<uchar>(sample)))
{
const QString str = qstr(std::string(static_cast<usz>(max), sample));
const QString str = QString(max, sample);
m_input->setFixedWidth(gui::utils::get_label_width(str, &font));
}

View File

@ -24,8 +24,6 @@ extern std::array<std::deque<std::string>, 16> g_tty_input;
extern std::mutex g_tty_mutex;
extern bool g_log_all_errors;
constexpr auto qstr = QString::fromStdString;
struct gui_listener : logs::listener
{
atomic_t<logs::level> enabled{logs::level{0xff}};
@ -891,7 +889,7 @@ void log_frame::UpdateUI()
}
// Print UTF-8 text.
m_log_text += escaped(qstr(packet->msg), QString{});
m_log_text += escaped(QString::fromStdString(packet->msg), QString{});
if (m_stack_log)
{

View File

@ -2157,7 +2157,7 @@ QAction* main_window::CreateRecentAction(const q_string_pair& entry, const uint&
{
if (m_rg_entries.contains(entry))
{
gui_log.warning("Recent Game not valid, removing from Boot Recent list: %s", sstr(entry.first));
gui_log.warning("Recent Game not valid, removing from Boot Recent list: %s", entry.first);
const int idx = m_rg_entries.indexOf(entry);
m_rg_entries.removeAt(idx);

View File

@ -12,8 +12,6 @@
#include <QFormLayout>
#include <QRegularExpressionValidator>
constexpr auto qstr = QString::fromStdString;
osk_dialog_frame::~osk_dialog_frame()
{
if (m_dialog)
@ -38,7 +36,7 @@ void osk_dialog_frame::Create(const osk_params& params)
m_dialog->setModal(true);
// Title
m_dialog->setWindowTitle(qstr(params.title));
m_dialog->setWindowTitle(QString::fromStdString(params.title));
// Message
QLabel* message_label = new QLabel(QString::fromStdU16String(params.message));

View File

@ -16,8 +16,6 @@
LOG_CHANNEL(patch_log, "PAT");
constexpr auto qstr = QString::fromStdString;
Q_DECLARE_METATYPE(patch_type)
enum patch_column : int
@ -96,7 +94,7 @@ void patch_creator_dialog::init_patch_type_bombo_box(QComboBox* combo_box, patch
{
if (const patch_type t = patch_engine::get_patch_type(type); t != patch_type::invalid)
{
types << qstr(type);
types << QString::fromStdString(type);
combo_box->addItem(types.last(), QVariant::fromValue<patch_type>(t));
@ -459,7 +457,7 @@ void patch_creator_dialog::export_patch()
return;
}
const QString file_path = QFileDialog::getSaveFileName(this, tr("Select Patch File"), qstr(patch_engine::get_patches_path()), tr("patch.yml files (*.yml);;All files (*.*)"));
const QString file_path = QFileDialog::getSaveFileName(this, tr("Select Patch File"), QString::fromStdString(patch_engine::get_patches_path()), tr("patch.yml files (*.yml);;All files (*.*)"));
if (file_path.isEmpty())
{
return;

View File

@ -5,8 +5,6 @@
#include <QHeaderView>
#include "Emu/System.h"
constexpr auto qstr = QString::fromStdString;
save_data_info_dialog::save_data_info_dialog(SaveDataEntry save, QWidget* parent)
: QDialog(parent)
, m_entry(std::move(save))
@ -62,16 +60,16 @@ void save_data_info_dialog::UpdateData()
//Maybe there should be more details of save data.
m_list->setItem(0, 0, new QTableWidgetItem(tr("User ID")));
m_list->setItem(0, 1, new QTableWidgetItem(qstr(Emu.GetUsr())));
m_list->setItem(0, 1, new QTableWidgetItem(QString::fromStdString(Emu.GetUsr())));
m_list->setItem(1, 0, new QTableWidgetItem(tr("Title")));
m_list->setItem(1, 1, new QTableWidgetItem(qstr(m_entry.title)));
m_list->setItem(1, 1, new QTableWidgetItem(QString::fromStdString(m_entry.title)));
m_list->setItem(2, 0, new QTableWidgetItem(tr("Subtitle")));
m_list->setItem(2, 1, new QTableWidgetItem(qstr(m_entry.subtitle)));
m_list->setItem(2, 1, new QTableWidgetItem(QString::fromStdString(m_entry.subtitle)));
m_list->setItem(3, 0, new QTableWidgetItem(tr("Detail")));
m_list->setItem(3, 1, new QTableWidgetItem(qstr(m_entry.details)));
m_list->setItem(3, 1, new QTableWidgetItem(QString::fromStdString(m_entry.details)));
QImage img;
if (!m_entry.iconBuf.empty() && img.loadFromData(m_entry.iconBuf.data(), static_cast<int>(m_entry.iconBuf.size()), "PNG"))

View File

@ -36,11 +36,6 @@
LOG_CHANNEL(gui_log, "GUI");
namespace
{
inline std::string sstr(const QString& _in) { return _in.toUtf8().toStdString(); }
}
enum GameUserRole
{
GameIndex = Qt::UserRole,
@ -705,7 +700,7 @@ void trophy_manager_dialog::ResizeTrophyIcons()
}
else
{
gui_log.error("Failed to load trophy icon for trophy %d (icon='%s')", trophy_id, sstr(path));
gui_log.error("Failed to load trophy icon for trophy %d (icon='%s')", trophy_id, path);
}
}
}
@ -1027,7 +1022,7 @@ void trophy_manager_dialog::StartTrophyLoadThreads()
atomic_t<usz> error_count{};
futureWatcher.setFuture(QtConcurrent::map(indices, [this, &error_count, &folder_list](const int& i)
{
const std::string dir_name = sstr(folder_list.value(i));
const std::string dir_name = folder_list.value(i).toStdString();
gui_log.trace("Loading trophy dir: %s", dir_name);
if (!LoadTrophyFolderToDB(dir_name))