mirror of
https://github.com/libretro/RetroArch
synced 2025-03-03 04:14:00 +00:00
(Qt) Cleanups
This commit is contained in:
parent
81a623c2b6
commit
dd721def41
@ -824,6 +824,20 @@ int setting_generic_action_ok_default(rarch_setting_t *setting, bool wraparound)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void setting_generic_handle_change(rarch_setting_t *setting)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
settings->modified = true;
|
||||
|
||||
if (setting->change_handler)
|
||||
setting->change_handler(setting);
|
||||
|
||||
if (setting->cmd_trigger.idx && !setting->cmd_trigger.triggered)
|
||||
command_event(setting->cmd_trigger.idx, NULL);
|
||||
}
|
||||
|
||||
|
||||
static void setting_get_string_representation_int_gpu_index(rarch_setting_t *setting,
|
||||
char *s, size_t len)
|
||||
{
|
||||
|
@ -127,6 +127,8 @@ int menu_action_handle_setting(rarch_setting_t *setting,
|
||||
enum setting_type menu_setting_get_browser_selection_type(
|
||||
rarch_setting_t *setting);
|
||||
|
||||
void setting_generic_handle_change(rarch_setting_t *setting);
|
||||
|
||||
void general_write_handler(rarch_setting_t *setting);
|
||||
|
||||
void general_read_handler(rarch_setting_t *setting);
|
||||
|
@ -263,7 +263,7 @@ void PlaylistModel::onImageLoaded(const QImage image, const QModelIndex &index,
|
||||
m_pendingImages.remove(path);
|
||||
}
|
||||
|
||||
inline static bool comp_hash_name_key_lower(const QHash<QString, QString> &lhs, const QHash<QString, QString> &rhs)
|
||||
static inline bool comp_hash_name_key_lower(const QHash<QString, QString> &lhs, const QHash<QString, QString> &rhs)
|
||||
{
|
||||
return lhs.value("name").toLower() < rhs.value("name").toLower();
|
||||
}
|
||||
|
@ -23,20 +23,8 @@ extern "C" {
|
||||
|
||||
static const QRegularExpression decimalsRegex("%.(\\d)f");
|
||||
|
||||
inline void handleChange(rarch_setting_t *setting)
|
||||
{
|
||||
settings_t *settings = config_get_ptr();
|
||||
|
||||
settings->modified = true;
|
||||
|
||||
if (setting->change_handler)
|
||||
setting->change_handler(setting);
|
||||
|
||||
if (setting->cmd_trigger.idx && !setting->cmd_trigger.triggered)
|
||||
command_event(setting->cmd_trigger.idx, NULL);
|
||||
}
|
||||
|
||||
inline void addSublabelAndWhatsThis(QWidget *widget, rarch_setting_t *setting)
|
||||
static inline void add_sublabel_and_whats_this(
|
||||
QWidget *widget, rarch_setting_t *setting)
|
||||
{
|
||||
struct menu_file_list_cbs cbs = {};
|
||||
char tmp[512];
|
||||
@ -56,14 +44,14 @@ inline void addSublabelAndWhatsThis(QWidget *widget, rarch_setting_t *setting)
|
||||
widget->setWhatsThis(tmp);
|
||||
}
|
||||
|
||||
static QString sanitizeAmpersand(QString input)
|
||||
static QString sanitize_ampersand(QString input)
|
||||
{
|
||||
return input.replace("&", "&&");
|
||||
}
|
||||
|
||||
inline QString formLabel(rarch_setting_t *setting)
|
||||
static inline QString form_label(rarch_setting_t *setting)
|
||||
{
|
||||
return QString(sanitizeAmpersand(setting->short_description)) + ":";
|
||||
return QString(sanitize_ampersand(setting->short_description)) + ":";
|
||||
}
|
||||
|
||||
FormLayout::FormLayout(QWidget *parent) :
|
||||
@ -86,61 +74,61 @@ void FormLayout::addUIntRadioButtons(rarch_setting_t *setting)
|
||||
void FormLayout::addUIntComboBox(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new UIntComboBox(setting));
|
||||
addRow(form_label(setting), new UIntComboBox(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addStringComboBox(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new StringComboBox(setting));
|
||||
addRow(form_label(setting), new StringComboBox(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addStringLineEdit(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new StringLineEdit(setting));
|
||||
addRow(form_label(setting), new StringLineEdit(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addPasswordLineEdit(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new PasswordLineEdit(setting));
|
||||
addRow(form_label(setting), new PasswordLineEdit(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addUIntSpinBox(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new UIntSpinBox(setting));
|
||||
addRow(form_label(setting), new UIntSpinBox(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addSizeSpinBox(rarch_setting_t *setting, unsigned scale)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new SizeSpinBox(setting, scale));
|
||||
addRow(form_label(setting), new SizeSpinBox(setting, scale));
|
||||
}
|
||||
|
||||
void FormLayout::addFloatSpinBox(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new FloatSpinBox(setting));
|
||||
addRow(form_label(setting), new FloatSpinBox(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addDirectorySelector(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new DirectorySelector(setting));
|
||||
addRow(form_label(setting), new DirectorySelector(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addFileSelector(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new FileSelector(setting));
|
||||
addRow(form_label(setting), new FileSelector(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addFloatSliderAndSpinBox(rarch_setting_t *setting)
|
||||
{
|
||||
if (setting && setting->short_description)
|
||||
addRow(formLabel(setting), new FloatSliderAndSpinBox(setting));
|
||||
addRow(form_label(setting), new FloatSliderAndSpinBox(setting));
|
||||
}
|
||||
|
||||
void FormLayout::addUIntColorButton(const QString &title, msg_hash_enums r, msg_hash_enums g, msg_hash_enums b)
|
||||
@ -266,7 +254,7 @@ void SettingsGroup::addBindButton(rarch_setting_t *setting)
|
||||
}
|
||||
|
||||
CheckBox::CheckBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
QCheckBox(sanitizeAmpersand(setting->short_description), parent)
|
||||
QCheckBox(sanitize_ampersand(setting->short_description), parent)
|
||||
,m_setting(setting)
|
||||
,m_value(setting->value.target.boolean)
|
||||
{
|
||||
@ -276,7 +264,7 @@ CheckBox::CheckBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(onClicked(bool)));
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
CheckBox::CheckBox(const char *setting, QWidget *parent) :
|
||||
@ -293,7 +281,7 @@ void CheckBox::onClicked(bool checked)
|
||||
{
|
||||
*m_value = checked;
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void CheckBox::paintEvent(QPaintEvent *event)
|
||||
@ -325,7 +313,7 @@ CheckableSettingsGroup::CheckableSettingsGroup(rarch_setting_t *setting, QWidget
|
||||
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
}
|
||||
|
||||
@ -343,7 +331,7 @@ void CheckableSettingsGroup::onClicked(bool checked)
|
||||
{
|
||||
*m_value = checked;
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void CheckableSettingsGroup::paintEvent(QPaintEvent *event)
|
||||
@ -383,14 +371,14 @@ CheckableIcon::CheckableIcon(rarch_setting_t *setting, const QIcon &icon, QWidge
|
||||
|
||||
connect(this, SIGNAL(toggled(bool)), this, SLOT(onToggled(bool)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
void CheckableIcon::onToggled(bool checked)
|
||||
{
|
||||
*m_value = QAbstractButton::isChecked();
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
|
||||
QAbstractButton::setChecked(checked);
|
||||
}
|
||||
@ -415,7 +403,7 @@ StringLineEdit::StringLineEdit(rarch_setting_t *setting, QWidget *parent) :
|
||||
{
|
||||
connect(this, SIGNAL(editingFinished()), this, SLOT(onEditingFinished()));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
StringLineEdit::StringLineEdit(const char *setting, QWidget *parent) :
|
||||
@ -427,7 +415,7 @@ void StringLineEdit::onEditingFinished()
|
||||
{
|
||||
strlcpy(m_value, text().toUtf8().data(), m_setting->size);
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
|
||||
setModified(false);
|
||||
}
|
||||
@ -458,7 +446,7 @@ StringComboBox::StringComboBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
|
||||
connect(this, SIGNAL(currentTextChanged(const QString&)), this, SLOT(onCurrentTextChanged(const QString&)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
StringComboBox::StringComboBox(const char *setting, QWidget *parent) :
|
||||
@ -470,7 +458,7 @@ void StringComboBox::onCurrentTextChanged(const QString &text)
|
||||
{
|
||||
strlcpy(m_value, text.toUtf8().data(), sizeof(m_value));
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void StringComboBox::paintEvent(QPaintEvent *event)
|
||||
@ -491,7 +479,7 @@ UIntComboBox::UIntComboBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
UIntComboBox::UIntComboBox(rarch_setting_t *setting, double min, double max, QWidget *parent) :
|
||||
@ -503,7 +491,7 @@ UIntComboBox::UIntComboBox(rarch_setting_t *setting, double min, double max, QWi
|
||||
|
||||
connect(this, SIGNAL(currentIndexChanged(int)), this, SLOT(onCurrentIndexChanged(int)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
void UIntComboBox::populate(double min, double max)
|
||||
@ -562,7 +550,7 @@ void UIntComboBox::onCurrentIndexChanged(int index)
|
||||
|
||||
*m_value = currentData().toUInt();
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void UIntComboBox::paintEvent(QPaintEvent *event)
|
||||
@ -583,7 +571,7 @@ UIntSpinBox::UIntSpinBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
|
||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
UIntSpinBox::UIntSpinBox(msg_hash_enums enum_idx, QWidget *parent) :
|
||||
@ -594,7 +582,7 @@ UIntSpinBox::UIntSpinBox(msg_hash_enums enum_idx, QWidget *parent) :
|
||||
void UIntSpinBox::onValueChanged(int value)
|
||||
{
|
||||
*m_value = value;
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void UIntSpinBox::paintEvent(QPaintEvent *event)
|
||||
@ -626,7 +614,7 @@ SizeSpinBox::SizeSpinBox(rarch_setting_t *setting, unsigned scale, QWidget *pare
|
||||
|
||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
SizeSpinBox::SizeSpinBox(msg_hash_enums enum_idx, unsigned scale, QWidget *parent) :
|
||||
@ -637,7 +625,7 @@ SizeSpinBox::SizeSpinBox(msg_hash_enums enum_idx, unsigned scale, QWidget *paren
|
||||
void SizeSpinBox::onValueChanged(int value)
|
||||
{
|
||||
*m_value = value * m_scale;
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void SizeSpinBox::paintEvent(QPaintEvent *event)
|
||||
@ -689,7 +677,7 @@ UIntRadioButton::UIntRadioButton(const QString &text, rarch_setting_t *setting,
|
||||
void UIntRadioButton::onClicked(bool)
|
||||
{
|
||||
*m_target = m_value;
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void UIntRadioButton::paintEvent(QPaintEvent *event)
|
||||
@ -743,7 +731,7 @@ UIntRadioButtons::UIntRadioButtons(rarch_setting_t *setting, QWidget *parent) :
|
||||
|
||||
*setting->value.target.unsigned_integer = orig_value;
|
||||
}
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
connect(m_buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(onButtonClicked(int)));
|
||||
}
|
||||
|
||||
@ -761,7 +749,7 @@ void UIntRadioButtons::onButtonClicked(int id)
|
||||
{
|
||||
*m_value = id;
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
IntSpinBox::IntSpinBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
@ -776,13 +764,13 @@ IntSpinBox::IntSpinBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
|
||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
void IntSpinBox::onValueChanged(int value)
|
||||
{
|
||||
*m_value = value;
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void IntSpinBox::paintEvent(QPaintEvent *event)
|
||||
@ -826,14 +814,14 @@ FloatSpinBox::FloatSpinBox(rarch_setting_t *setting, QWidget *parent) :
|
||||
setSingleStep(setting->step);
|
||||
|
||||
connect(this, SIGNAL(valueChanged(double)), this, SLOT(onValueChanged(double)));
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
void FloatSpinBox::onValueChanged(double value)
|
||||
{
|
||||
*m_value = (float)value;
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void FloatSpinBox::paintEvent(QPaintEvent *event)
|
||||
@ -861,7 +849,7 @@ PathButton::PathButton(rarch_setting_t *setting, QWidget *parent) :
|
||||
{
|
||||
connect(this, SIGNAL(clicked(bool)), this, SLOT(onClicked(bool)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
PathButton::PathButton(const char *setting, QWidget *parent) :
|
||||
@ -888,7 +876,7 @@ void DirectoryButton::onClicked(bool)
|
||||
{
|
||||
strlcpy(m_setting->value.target.string, QDir::toNativeSeparators(dir).toUtf8().data(), m_setting->size);
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
emit changed();
|
||||
@ -906,7 +894,7 @@ void FileButton::onClicked(bool)
|
||||
{
|
||||
strlcpy(m_setting->value.target.string, QDir::toNativeSeparators(file).toUtf8().data(), m_setting->size);
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
emit changed();
|
||||
@ -967,14 +955,14 @@ FloatSlider::FloatSlider(rarch_setting_t *setting, QWidget *parent) :
|
||||
|
||||
connect(this, SIGNAL(valueChanged(int)), this, SLOT(onValueChanged(int)));
|
||||
|
||||
addSublabelAndWhatsThis(this, m_setting);
|
||||
add_sublabel_and_whats_this(this, m_setting);
|
||||
}
|
||||
|
||||
void FloatSlider::onValueChanged(int value)
|
||||
{
|
||||
*m_value = (float)value / m_precision;
|
||||
|
||||
handleChange(m_setting);
|
||||
setting_generic_handle_change(m_setting);
|
||||
}
|
||||
|
||||
void FloatSlider::paintEvent(QPaintEvent *event)
|
||||
|
Loading…
x
Reference in New Issue
Block a user