1
0
mirror of https://github.com/RPCS3/rpcs3.git synced 2024-11-22 10:42:36 +01:00

Qt: Add std::string GetSettingOptions

This has the potential for some minor optimizations
This commit is contained in:
Megamouse 2024-11-15 01:55:01 +01:00
parent d78c39b3ab
commit 1211acd59c
8 changed files with 82 additions and 72 deletions

View File

@ -48,14 +48,9 @@ namespace cfg_adapter
return get_node(node, location.cbegin(), location.cend()); return get_node(node, location.cbegin(), location.cend());
} }
QStringList get_options(const cfg_location& location) std::vector<std::string> get_options(const cfg_location& location)
{ {
QStringList values; return cfg_adapter::get_cfg(g_cfg, location.cbegin(), location.cend()).to_list();
for (const std::string& value : cfg_adapter::get_cfg(g_cfg, location.cbegin(), location.cend()).to_list())
{
values.append(QString::fromStdString(value));
}
return values;
} }
static bool get_is_dynamic(const cfg_location& location) static bool get_is_dynamic(const cfg_location& location)

View File

@ -1,7 +1,5 @@
#pragma once #pragma once
#include <QStringList>
#include "emu_settings_type.h" #include "emu_settings_type.h"
#include "util/yaml.hpp" #include "util/yaml.hpp"
@ -14,7 +12,7 @@ namespace cfg_adapter
YAML::Node get_node(const YAML::Node& node, const cfg_location& location); YAML::Node get_node(const YAML::Node& node, const cfg_location& location);
/** Returns possible options for values for some particular setting.*/ /** Returns possible options for values for some particular setting.*/
QStringList get_options(const cfg_location& location); std::vector<std::string> get_options(const cfg_location& location);
/** Returns dynamic property for some particular setting.*/ /** Returns dynamic property for some particular setting.*/
bool get_is_dynamic(emu_settings_type type); bool get_is_dynamic(emu_settings_type type);

View File

@ -21,9 +21,6 @@ LOG_CHANNEL(cfg_log, "CFG");
extern std::string g_cfg_defaults; //! Default settings grabbed from Utilities/Config.h extern std::string g_cfg_defaults; //! Default settings grabbed from Utilities/Config.h
inline std::string sstr(const QString& _in) { return _in.toStdString(); }
inline std::string sstr(const QVariant& _in) { return sstr(_in.toString()); }
// Emit sorted YAML // Emit sorted YAML
namespace namespace
{ {
@ -82,7 +79,7 @@ bool emu_settings::Init()
// Make Vulkan default setting if it is supported // Make Vulkan default setting if it is supported
if (m_render_creator->Vulkan.supported && !m_render_creator->Vulkan.adapters.empty()) if (m_render_creator->Vulkan.supported && !m_render_creator->Vulkan.adapters.empty())
{ {
const std::string adapter = sstr(::at32(m_render_creator->Vulkan.adapters, 0)); const std::string adapter = ::at32(m_render_creator->Vulkan.adapters, 0).toStdString();
cfg_log.notice("Setting the default renderer to Vulkan. Default GPU: '%s'", adapter); cfg_log.notice("Setting the default renderer to Vulkan. Default GPU: '%s'", adapter);
Emu.SetDefaultRenderer(video_renderer::vulkan); Emu.SetDefaultRenderer(video_renderer::vulkan);
Emu.SetDefaultGraphicsAdapter(adapter); Emu.SetDefaultGraphicsAdapter(adapter);
@ -297,7 +294,8 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
cfg_log.warning("EnhanceCombobox '%s': ignoring sorting request on ranged combo box", cfg_adapter::get_setting_name(type)); cfg_log.warning("EnhanceCombobox '%s': ignoring sorting request on ranged combo box", cfg_adapter::get_setting_name(type));
} }
const QStringList range = GetSettingOptions(type); const QStringList range = GetQStringSettingOptions(type);
ensure(!range.empty());
const int max_item = use_max ? max : range.last().toInt(); const int max_item = use_max ? max : range.last().toInt();
@ -308,7 +306,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
} }
else else
{ {
const QStringList settings = GetSettingOptions(type); const QStringList settings = GetQStringSettingOptions(type);
for (int i = 0; i < settings.count(); i++) for (int i = 0; i < settings.count(); i++)
{ {
@ -348,7 +346,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
const std::string def = GetSettingDefault(type); const std::string def = GetSettingDefault(type);
const std::string selected = GetSetting(type); const std::string selected = GetSetting(type);
const QString selected_q = qstr(selected); const QString selected_q = QString::fromStdString(selected);
int index; int index;
if (is_ranged) if (is_ranged)
@ -366,11 +364,11 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
if (is_ranged) if (is_ranged)
{ {
index = combobox->findData(qstr(def)); index = combobox->findData(QString::fromStdString(def));
} }
else else
{ {
index = find_index(combobox, qstr(def)); index = find_index(combobox, QString::fromStdString(def));
} }
m_broken_types.insert(type); m_broken_types.insert(type);
@ -384,7 +382,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
if (is_ranged) if (is_ranged)
{ {
SetSetting(type, sstr(combobox->itemData(index))); SetSetting(type, combobox->itemData(index).toString().toStdString());
} }
else else
{ {
@ -393,7 +391,7 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
{ {
fmt::throw_exception("Invalid data found in combobox entry %d (text='%s', listsize=%d, itemcount=%d)", index, combobox->itemText(index), var_list.size(), combobox->count()); fmt::throw_exception("Invalid data found in combobox entry %d (text='%s', listsize=%d, itemcount=%d)", index, combobox->itemText(index), var_list.size(), combobox->count());
} }
SetSetting(type, sstr(var_list[0])); SetSetting(type, var_list[0].toString().toStdString());
} }
}); });
@ -401,11 +399,11 @@ void emu_settings::EnhanceComboBox(QComboBox* combobox, emu_settings_type type,
{ {
if (is_ranged) if (is_ranged)
{ {
combobox->setCurrentIndex(combobox->findData(qstr(def))); combobox->setCurrentIndex(combobox->findData(QString::fromStdString(def)));
} }
else else
{ {
combobox->setCurrentIndex(find_index(combobox, qstr(def))); combobox->setCurrentIndex(find_index(combobox, QString::fromStdString(def)));
} }
}); });
} }
@ -469,9 +467,11 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
// If using offset from now, then we disable the keyboard tracking to reduce the numebr of events that occur (since for each event we will lose focus) // If using offset from now, then we disable the keyboard tracking to reduce the numebr of events that occur (since for each event we will lose focus)
date_time_edit->setKeyboardTracking(false); date_time_edit->setKeyboardTracking(false);
const QStringList range = GetQStringSettingOptions(type);
ensure(!range.empty());
bool ok_def = false, ok_min = false, ok_max = false; bool ok_def = false, ok_min = false, ok_max = false;
const QStringList range = GetSettingOptions(type); const s64 def = QString::fromStdString(GetSettingDefault(type)).toLongLong(&ok_def);
const s64 def = qstr(GetSettingDefault(type)).toLongLong(&ok_def);
const s64 min = range.first().toLongLong(&ok_min); const s64 min = range.first().toLongLong(&ok_min);
const s64 max = range.last().toLongLong(&ok_max); const s64 max = range.last().toLongLong(&ok_max);
if (!ok_def || !ok_min || !ok_max) if (!ok_def || !ok_min || !ok_max)
@ -481,7 +481,7 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
} }
bool ok_sel = false; bool ok_sel = false;
s64 val = qstr(GetSetting(type)).toLongLong(&ok_sel); s64 val = QString::fromStdString(GetSetting(type)).toLongLong(&ok_sel);
if (!ok_sel || val < min || val > max) if (!ok_sel || val < min || val > max)
{ {
cfg_log.error("EnhanceDateTimeEdit '%s' tried to set an invalid value: %d. Setting to default: %d. Allowed range: [%d, %d]", cfg_adapter::get_setting_name(type), val, def, min, max); cfg_log.error("EnhanceDateTimeEdit '%s' tried to set an invalid value: %d. Setting to default: %d. Allowed range: [%d, %d]", cfg_adapter::get_setting_name(type), val, def, min, max);
@ -509,7 +509,7 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
if (!date_time_edit->hasFocus() && (!date_time_edit->calendarPopup() || !date_time_edit->calendarWidget()->hasFocus())) if (!date_time_edit->hasFocus() && (!date_time_edit->calendarPopup() || !date_time_edit->calendarWidget()->hasFocus()))
{ {
const QDateTime now = QDateTime::currentDateTime(); const QDateTime now = QDateTime::currentDateTime();
const s64 offset = qstr(GetSetting(emu_settings_type::ConsoleTimeOffset)).toLongLong(); const s64 offset = QString::fromStdString(GetSetting(emu_settings_type::ConsoleTimeOffset)).toLongLong();
date_time_edit->setDateTime(now.addSecs(offset)); date_time_edit->setDateTime(now.addSecs(offset));
date_time_edit->setDateTimeRange(now.addSecs(min), now.addSecs(max)); date_time_edit->setDateTimeRange(now.addSecs(min), now.addSecs(max));
} }
@ -525,8 +525,10 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
} }
else else
{ {
QString str = qstr(GetSettingDefault(type)); const QStringList range = GetQStringSettingOptions(type);
const QStringList range = GetSettingOptions(type); ensure(!range.empty());
QString str = QString::fromStdString(GetSettingDefault(type));
const QDateTime def = QDateTime::fromString(str, Qt::ISODate); const QDateTime def = QDateTime::fromString(str, Qt::ISODate);
const QDateTime min = QDateTime::fromString(range.first(), Qt::ISODate); const QDateTime min = QDateTime::fromString(range.first(), Qt::ISODate);
const QDateTime max = QDateTime::fromString(range.last(), Qt::ISODate); const QDateTime max = QDateTime::fromString(range.last(), Qt::ISODate);
@ -536,7 +538,7 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
return; return;
} }
str = qstr(GetSetting(type)); str = QString::fromStdString(GetSetting(type));
QDateTime val = QDateTime::fromString(str, Qt::ISODate); QDateTime val = QDateTime::fromString(str, Qt::ISODate);
if (!val.isValid() || val < min || val > max) if (!val.isValid() || val < min || val > max)
{ {
@ -544,7 +546,7 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
cfg_adapter::get_setting_name(type), val.toString(Qt::ISODate), def.toString(Qt::ISODate), min.toString(Qt::ISODate), max.toString(Qt::ISODate)); cfg_adapter::get_setting_name(type), val.toString(Qt::ISODate), def.toString(Qt::ISODate), min.toString(Qt::ISODate), max.toString(Qt::ISODate));
val = def; val = def;
m_broken_types.insert(type); m_broken_types.insert(type);
SetSetting(type, sstr(def.toString(Qt::ISODate))); SetSetting(type, def.toString(Qt::ISODate).toStdString());
} }
// we set the allowed limits // we set the allowed limits
@ -577,7 +579,7 @@ void emu_settings::EnhanceDateTimeEdit(QDateTimeEdit* date_time_edit, emu_settin
else else
{ {
// date time will be written straight into settings // date time will be written straight into settings
SetSetting(type, sstr(datetime.toString(Qt::ISODate))); SetSetting(type, datetime.toString(Qt::ISODate).toStdString());
} }
}); });
} }
@ -590,10 +592,12 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type)
return; return;
} }
const QStringList range = GetSettingOptions(type); const QStringList range = GetQStringSettingOptions(type);
ensure(!range.empty());
bool ok_def, ok_sel, ok_min, ok_max; bool ok_def, ok_sel, ok_min, ok_max;
const int def = qstr(GetSettingDefault(type)).toInt(&ok_def); const int def = QString::fromStdString(GetSettingDefault(type)).toInt(&ok_def);
const int min = range.first().toInt(&ok_min); const int min = range.first().toInt(&ok_min);
const int max = range.last().toInt(&ok_max); const int max = range.last().toInt(&ok_max);
@ -603,7 +607,7 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type)
return; return;
} }
const QString selected = qstr(GetSetting(type)); const QString selected = QString::fromStdString(GetSetting(type));
int val = selected.toInt(&ok_sel); int val = selected.toInt(&ok_sel);
if (!ok_sel || val < min || val > max) if (!ok_sel || val < min || val > max)
@ -618,7 +622,7 @@ void emu_settings::EnhanceSlider(QSlider* slider, emu_settings_type type)
connect(slider, &QSlider::valueChanged, this, [type, this](int value) connect(slider, &QSlider::valueChanged, this, [type, this](int value)
{ {
SetSetting(type, sstr(value)); SetSetting(type, QString::number(value).toStdString());
}); });
connect(this, &emu_settings::RestoreDefaultsSignal, slider, [def, slider]() connect(this, &emu_settings::RestoreDefaultsSignal, slider, [def, slider]()
@ -635,10 +639,12 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, con
return; return;
} }
const QStringList range = GetSettingOptions(type); const QStringList range = GetQStringSettingOptions(type);
ensure(!range.empty());
bool ok_def, ok_sel, ok_min, ok_max; bool ok_def, ok_sel, ok_min, ok_max;
const int def = qstr(GetSettingDefault(type)).toInt(&ok_def); const int def = QString::fromStdString(GetSettingDefault(type)).toInt(&ok_def);
const int min = range.first().toInt(&ok_min); const int min = range.first().toInt(&ok_min);
const int max = range.last().toInt(&ok_max); const int max = range.last().toInt(&ok_max);
@ -649,7 +655,7 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, con
} }
const std::string selected = GetSetting(type); const std::string selected = GetSetting(type);
int val = qstr(selected).toInt(&ok_sel); int val = QString::fromStdString(selected).toInt(&ok_sel);
if (!ok_sel || val < min || val > max) if (!ok_sel || val < min || val > max)
{ {
@ -666,7 +672,7 @@ void emu_settings::EnhanceSpinBox(QSpinBox* spinbox, emu_settings_type type, con
connect(spinbox, &QSpinBox::textChanged, this, [type, spinbox, this](const QString& /* text*/) connect(spinbox, &QSpinBox::textChanged, this, [type, spinbox, this](const QString& /* text*/)
{ {
if (!spinbox) return; if (!spinbox) return;
SetSetting(type, sstr(spinbox->cleanText())); SetSetting(type, spinbox->cleanText().toStdString());
}); });
connect(this, &emu_settings::RestoreDefaultsSignal, spinbox, [def, spinbox]() connect(this, &emu_settings::RestoreDefaultsSignal, spinbox, [def, spinbox]()
@ -683,11 +689,13 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_ty
return; return;
} }
const QStringList range = GetSettingOptions(type); const std::vector<std::string> range = GetSettingOptions(type);
ensure(!range.empty());
const std::string def_s = GetSettingDefault(type); const std::string def_s = GetSettingDefault(type);
const std::string val_s = GetSetting(type); const std::string val_s = GetSetting(type);
const std::string min_s = sstr(range.first()); const std::string& min_s = range.front();
const std::string max_s = sstr(range.last()); const std::string& max_s = range.back();
// cfg::_float range is in s32 // cfg::_float range is in s32
constexpr s32 min_value = ::std::numeric_limits<s32>::min(); constexpr s32 min_value = ::std::numeric_limits<s32>::min();
@ -720,7 +728,7 @@ void emu_settings::EnhanceDoubleSpinBox(QDoubleSpinBox* spinbox, emu_settings_ty
connect(spinbox, &QDoubleSpinBox::textChanged, this, [type, spinbox, this](const QString& /* text*/) connect(spinbox, &QDoubleSpinBox::textChanged, this, [type, spinbox, this](const QString& /* text*/)
{ {
if (!spinbox) return; if (!spinbox) return;
SetSetting(type, sstr(spinbox->cleanText())); SetSetting(type, spinbox->cleanText().toStdString());
}); });
connect(this, &emu_settings::RestoreDefaultsSignal, spinbox, [def, spinbox]() connect(this, &emu_settings::RestoreDefaultsSignal, spinbox, [def, spinbox]()
@ -738,7 +746,7 @@ void emu_settings::EnhanceLineEdit(QLineEdit* edit, emu_settings_type type)
} }
const std::string set_text = GetSetting(type); const std::string set_text = GetSetting(type);
edit->setText(qstr(set_text)); edit->setText(QString::fromStdString(set_text));
connect(edit, &QLineEdit::textChanged, this, [type, this](const QString &text) connect(edit, &QLineEdit::textChanged, this, [type, this](const QString &text)
{ {
@ -747,12 +755,12 @@ void emu_settings::EnhanceLineEdit(QLineEdit* edit, emu_settings_type type)
{ {
cfg_log.warning("EnhanceLineEdit '%s' input was trimmed", cfg_adapter::get_setting_name(type)); cfg_log.warning("EnhanceLineEdit '%s' input was trimmed", cfg_adapter::get_setting_name(type));
} }
SetSetting(type, sstr(trimmed)); SetSetting(type, trimmed.toStdString());
}); });
connect(this, &emu_settings::RestoreDefaultsSignal, edit, [this, edit, type]() connect(this, &emu_settings::RestoreDefaultsSignal, edit, [this, edit, type]()
{ {
edit->setText(qstr(GetSettingDefault(type))); edit->setText(QString::fromStdString(GetSettingDefault(type)));
}); });
} }
@ -764,9 +772,9 @@ void emu_settings::EnhanceRadioButton(QButtonGroup* button_group, emu_settings_t
return; return;
} }
const QString selected = qstr(GetSetting(type)); const QString selected = QString::fromStdString(GetSetting(type));
const QString def = qstr(GetSettingDefault(type)); const QString def = QString::fromStdString(GetSettingDefault(type));
const QStringList options = GetSettingOptions(type); const QStringList options = GetQStringSettingOptions(type);
if (button_group->buttons().count() < options.size()) if (button_group->buttons().count() < options.size())
{ {
@ -796,7 +804,7 @@ void emu_settings::EnhanceRadioButton(QButtonGroup* button_group, emu_settings_t
def_pos = i; def_pos = i;
} }
connect(button, &QAbstractButton::toggled, this, [this, type, val = sstr(option)](bool checked) connect(button, &QAbstractButton::toggled, this, [this, type, val = option.toStdString()](bool checked)
{ {
if (checked) if (checked)
{ {
@ -835,11 +843,21 @@ void emu_settings::SaveSelectedLibraries(const std::vector<std::string>& libs)
m_current_settings["Core"]["Libraries Control"] = libs; m_current_settings["Core"]["Libraries Control"] = libs;
} }
QStringList emu_settings::GetSettingOptions(emu_settings_type type) std::vector<std::string> emu_settings::GetSettingOptions(emu_settings_type type)
{ {
return cfg_adapter::get_options(::at32(settings_location, type)); return cfg_adapter::get_options(::at32(settings_location, type));
} }
QStringList emu_settings::GetQStringSettingOptions(emu_settings_type type)
{
QStringList values;
for (const std::string& value : cfg_adapter::get_options(::at32(settings_location, type)))
{
values.append(QString::fromStdString(value));
}
return values;
}
std::string emu_settings::GetSettingDefault(emu_settings_type type) const std::string emu_settings::GetSettingDefault(emu_settings_type type) const
{ {
if (const auto node = cfg_adapter::get_node(m_default_settings, ::at32(settings_location, type)); node && node.IsScalar()) if (const auto node = cfg_adapter::get_node(m_default_settings, ::at32(settings_location, type)); node && node.IsScalar())

View File

@ -18,8 +18,6 @@
#include <string> #include <string>
#include <vector> #include <vector>
constexpr auto qstr = QString::fromStdString;
class emu_settings : public QObject class emu_settings : public QObject
{ {
/** A settings class for Emulator specific settings. This class is a refactored version of the wx version. It is much nicer /** A settings class for Emulator specific settings. This class is a refactored version of the wx version. It is much nicer
@ -64,7 +62,10 @@ public:
void SaveSelectedLibraries(const std::vector<std::string>& libs); void SaveSelectedLibraries(const std::vector<std::string>& libs);
/** Returns the valid options for a given setting.*/ /** Returns the valid options for a given setting.*/
static QStringList GetSettingOptions(emu_settings_type type); static std::vector<std::string> GetSettingOptions(emu_settings_type type);
/** Returns the valid options for a given setting.*/
static QStringList GetQStringSettingOptions(emu_settings_type type);
/** Returns the default value of the setting type.*/ /** Returns the default value of the setting type.*/
std::string GetSettingDefault(emu_settings_type type) const; std::string GetSettingDefault(emu_settings_type type) const;

View File

@ -67,8 +67,6 @@ bool is_input_allowed()
return g_game_window_focused || g_cfg.io.background_input_enabled; return g_game_window_focused || g_cfg.io.background_input_enabled;
} }
constexpr auto qstr = QString::fromStdString;
gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen) gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon, std::shared_ptr<gui_settings> gui_settings, bool force_fullscreen)
: QWindow() : QWindow()
, m_initial_geometry(geometry) , m_initial_geometry(geometry)
@ -118,7 +116,7 @@ gs_frame::gs_frame(QScreen* screen, const QRect& geometry, const QIcon& appIcon,
setMinimumHeight(90); setMinimumHeight(90);
setScreen(screen); setScreen(screen);
setGeometry(geometry); setGeometry(geometry);
setTitle(qstr(m_window_title)); setTitle(QString::fromStdString(m_window_title));
if (g_cfg.video.renderer != video_renderer::opengl) if (g_cfg.video.renderer != video_renderer::opengl)
{ {
@ -752,7 +750,7 @@ void gs_frame::flip(draw_context_t, bool /*skip_frame*/)
Emu.CallFromMainThread([this, title = std::move(new_title)]() Emu.CallFromMainThread([this, title = std::move(new_title)]()
{ {
setTitle(qstr(title)); setTitle(QString::fromStdString(title));
}); });
} }
@ -941,7 +939,7 @@ void gs_frame::take_screenshot(std::vector<u8> data, u32 sshot_width, u32 sshot_
QImage overlay_img; QImage overlay_img;
if (!overlay_img.load(qstr(cell_sshot_overlay_path))) if (!overlay_img.load(QString::fromStdString(cell_sshot_overlay_path)))
{ {
screenshot_log.error("Failed to read cell screenshot overlay '%s' : %s", cell_sshot_overlay_path, fs::g_tls_error); screenshot_log.error("Failed to read cell screenshot overlay '%s' : %s", cell_sshot_overlay_path, fs::g_tls_error);
return; return;

View File

@ -111,9 +111,9 @@ bool gui_application::Init()
} }
} }
m_emu_settings.reset(new emu_settings()); m_emu_settings = std::make_shared<emu_settings>();
m_gui_settings.reset(new gui_settings()); m_gui_settings = std::make_shared<gui_settings>();
m_persistent_settings.reset(new persistent_settings()); m_persistent_settings = std::make_shared<persistent_settings>();
if (!m_emu_settings->Init()) if (!m_emu_settings->Init())
{ {
@ -620,7 +620,7 @@ void gui_application::InitializeCallbacks()
// Create a new sound effect. Re-using the same object seems to be broken for some users starting with Qt 6.6.3. // Create a new sound effect. Re-using the same object seems to be broken for some users starting with Qt 6.6.3.
std::unique_ptr<QSoundEffect> sound_effect = std::make_unique<QSoundEffect>(); std::unique_ptr<QSoundEffect> sound_effect = std::make_unique<QSoundEffect>();
sound_effect->setSource(QUrl::fromLocalFile(qstr(path))); sound_effect->setSource(QUrl::fromLocalFile(QString::fromStdString(path)));
sound_effect->setVolume(g_cfg.audio.volume * 0.01f); sound_effect->setVolume(g_cfg.audio.volume * 0.01f);
sound_effect->play(); sound_effect->play();
@ -783,7 +783,7 @@ void gui_application::InitializeCallbacks()
old_written = bytes_written; old_written = bytes_written;
pdlg->setLabelText(text_base.arg(gui::utils::format_byte_size(bytes_written)).arg(*half_seconds / 2).arg(qstr(verbose_message))); pdlg->setLabelText(text_base.arg(gui::utils::format_byte_size(bytes_written)).arg(*half_seconds / 2).arg(QString::fromStdString(verbose_message)));
// 300MB -> 50%, 600MB -> 75%, 1200MB -> 87.5% etc // 300MB -> 50%, 600MB -> 75%, 1200MB -> 87.5% etc
const int percent = std::clamp(static_cast<int>(100. - 100. / std::pow(2., std::fmax(0.01, bytes_written * 1. / (300 * 1024 * 1024)))), 2, 100); const int percent = std::clamp(static_cast<int>(100. - 100. / std::pow(2., std::fmax(0.01, bytes_written * 1. / (300 * 1024 * 1024)))), 2, 100);
@ -820,7 +820,7 @@ void gui_application::StartPlaytime(bool start_playtime = true)
return; return;
} }
const QString serial = qstr(Emu.GetTitleID()); const QString serial = QString::fromStdString(Emu.GetTitleID());
if (serial.isEmpty()) if (serial.isEmpty())
{ {
return; return;
@ -839,7 +839,7 @@ void gui_application::UpdatePlaytime()
return; return;
} }
const QString serial = qstr(Emu.GetTitleID()); const QString serial = QString::fromStdString(Emu.GetTitleID());
if (serial.isEmpty()) if (serial.isEmpty())
{ {
m_timer_playtime.invalidate(); m_timer_playtime.invalidate();
@ -858,7 +858,7 @@ void gui_application::StopPlaytime()
if (!m_timer_playtime.isValid()) if (!m_timer_playtime.isValid())
return; return;
const QString serial = qstr(Emu.GetTitleID()); const QString serial = QString::fromStdString(Emu.GetTitleID());
if (serial.isEmpty()) if (serial.isEmpty())
{ {
m_timer_playtime.invalidate(); m_timer_playtime.invalidate();
@ -1004,10 +1004,10 @@ void gui_application::OnChangeStyleSheetRequest()
if (QFile file(stylesheet_path); !stylesheet_path.isEmpty() && file.open(QIODevice::ReadOnly | QIODevice::Text)) if (QFile file(stylesheet_path); !stylesheet_path.isEmpty() && file.open(QIODevice::ReadOnly | QIODevice::Text))
{ {
const QString config_dir = qstr(fs::get_config_dir()); const QString config_dir = QString::fromStdString(fs::get_config_dir());
// Add PS3 fonts // Add PS3 fonts
QDirIterator ps3_font_it(qstr(g_cfg_vfs.get_dev_flash() + "data/font/"), QStringList() << "*.ttf", QDir::Files, QDirIterator::Subdirectories); QDirIterator ps3_font_it(QString::fromStdString(g_cfg_vfs.get_dev_flash() + "data/font/"), QStringList() << "*.ttf", QDir::Files, QDirIterator::Subdirectories);
while (ps3_font_it.hasNext()) while (ps3_font_it.hasNext())
QFontDatabase::addApplicationFont(ps3_font_it.next()); QFontDatabase::addApplicationFont(ps3_font_it.next());

View File

@ -108,7 +108,7 @@ namespace gui
gui_settings::gui_settings(QObject* parent) : settings(parent) gui_settings::gui_settings(QObject* parent) : settings(parent)
{ {
m_settings.reset(new QSettings(ComputeSettingsDir() + gui::Settings + ".ini", QSettings::Format::IniFormat, parent)); m_settings = std::make_unique<QSettings>(ComputeSettingsDir() + gui::Settings + ".ini", QSettings::Format::IniFormat, parent);
} }
QStringList gui_settings::GetGameListCategoryFilters(bool is_list_mode) const QStringList gui_settings::GetGameListCategoryFilters(bool is_list_mode) const

View File

@ -8,7 +8,7 @@ LOG_CHANNEL(cfg_log, "CFG");
persistent_settings::persistent_settings(QObject* parent) : settings(parent) persistent_settings::persistent_settings(QObject* parent) : settings(parent)
{ {
// Don't use the .ini file ending for now, as it will be confused for a regular gui_settings file. // Don't use the .ini file ending for now, as it will be confused for a regular gui_settings file.
m_settings.reset(new QSettings(ComputeSettingsDir() + gui::persistent::persistent_file_name + ".dat", QSettings::Format::IniFormat, parent)); m_settings = std::make_unique<QSettings>(ComputeSettingsDir() + gui::persistent::persistent_file_name + ".dat", QSettings::Format::IniFormat, parent);
} }
void persistent_settings::SetPlaytime(const QString& serial, quint64 playtime, bool sync) void persistent_settings::SetPlaytime(const QString& serial, quint64 playtime, bool sync)