mirror of https://github.com/PCSX2/pcsx2.git
Qt: Fix relative directories not being canonicalized
This commit is contained in:
parent
a3d02b8702
commit
9f461253a8
|
@ -974,15 +974,15 @@ namespace SettingWidgetBinder
|
||||||
|
|
||||||
template <typename WidgetType>
|
template <typename WidgetType>
|
||||||
static void BindWidgetToFolderSetting(SettingsInterface* sif, WidgetType* widget, QAbstractButton* browse_button, QAbstractButton* open_button,
|
static void BindWidgetToFolderSetting(SettingsInterface* sif, WidgetType* widget, QAbstractButton* browse_button, QAbstractButton* open_button,
|
||||||
QAbstractButton* reset_button, std::string section, std::string key, std::string default_value)
|
QAbstractButton* reset_button, std::string section, std::string key, std::string default_value, bool use_relative = true)
|
||||||
{
|
{
|
||||||
using Accessor = SettingAccessor<WidgetType>;
|
using Accessor = SettingAccessor<WidgetType>;
|
||||||
|
|
||||||
std::string current_path(Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value.c_str()));
|
std::string current_path(Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value.c_str()));
|
||||||
if (current_path.empty())
|
if (current_path.empty())
|
||||||
current_path = default_value;
|
current_path = default_value;
|
||||||
else if (!Path::IsAbsolute(current_path))
|
else if (use_relative && !Path::IsAbsolute(current_path))
|
||||||
current_path = Path::Combine(EmuFolders::DataRoot, current_path);
|
current_path = Path::Canonicalize(Path::Combine(EmuFolders::DataRoot, current_path));
|
||||||
|
|
||||||
const QString value(QString::fromStdString(current_path));
|
const QString value(QString::fromStdString(current_path));
|
||||||
Accessor::setStringValue(widget, value);
|
Accessor::setStringValue(widget, value);
|
||||||
|
@ -998,14 +998,21 @@ namespace SettingWidgetBinder
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Accessor::connectValueChanged(widget, [widget, section = std::move(section), key = std::move(key)]() {
|
Accessor::connectValueChanged(widget, [widget, section = std::move(section), key = std::move(key), use_relative]() {
|
||||||
const std::string new_value(Accessor::getStringValue(widget).toStdString());
|
const std::string new_value(Accessor::getStringValue(widget).toStdString());
|
||||||
if (!new_value.empty())
|
if (!new_value.empty())
|
||||||
{
|
{
|
||||||
std::string relative_path(Path::MakeRelative(new_value, EmuFolders::DataRoot));
|
if (use_relative)
|
||||||
|
{
|
||||||
|
const std::string relative_path(Path::MakeRelative(new_value, EmuFolders::DataRoot));
|
||||||
Host::SetBaseStringSettingValue(section.c_str(), key.c_str(), relative_path.c_str());
|
Host::SetBaseStringSettingValue(section.c_str(), key.c_str(), relative_path.c_str());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
Host::SetBaseStringSettingValue(section.c_str(), key.c_str(), new_value.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
Host::RemoveBaseSettingValue(section.c_str(), key.c_str());
|
Host::RemoveBaseSettingValue(section.c_str(), key.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,9 +42,9 @@ DebugSettingsWidget::DebugSettingsWidget(SettingsDialog* dialog, QWidget* parent
|
||||||
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.startDraw, "EmuCore/GS", "saven", 0);
|
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.startDraw, "EmuCore/GS", "saven", 0);
|
||||||
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.dumpCount, "EmuCore/GS", "savel", 5000);
|
SettingWidgetBinder::BindWidgetToIntSetting(sif, m_ui.dumpCount, "EmuCore/GS", "savel", 5000);
|
||||||
SettingWidgetBinder::BindWidgetToFolderSetting(
|
SettingWidgetBinder::BindWidgetToFolderSetting(
|
||||||
sif, m_ui.hwDumpDirectory, m_ui.hwDumpBrowse, m_ui.hwDumpOpen, nullptr, "EmuCore/GS", "HWDumpDirectory", std::string());
|
sif, m_ui.hwDumpDirectory, m_ui.hwDumpBrowse, m_ui.hwDumpOpen, nullptr, "EmuCore/GS", "HWDumpDirectory", std::string(), false);
|
||||||
SettingWidgetBinder::BindWidgetToFolderSetting(
|
SettingWidgetBinder::BindWidgetToFolderSetting(
|
||||||
sif, m_ui.swDumpDirectory, m_ui.swDumpBrowse, m_ui.swDumpOpen, nullptr, "EmuCore/GS", "SWDumpDirectory", std::string());
|
sif, m_ui.swDumpDirectory, m_ui.swDumpBrowse, m_ui.swDumpOpen, nullptr, "EmuCore/GS", "SWDumpDirectory", std::string(), false);
|
||||||
|
|
||||||
connect(m_ui.dumpGSDraws, &QCheckBox::stateChanged, this, &DebugSettingsWidget::onDrawDumpingChanged);
|
connect(m_ui.dumpGSDraws, &QCheckBox::stateChanged, this, &DebugSettingsWidget::onDrawDumpingChanged);
|
||||||
onDrawDumpingChanged();
|
onDrawDumpingChanged();
|
||||||
|
|
Loading…
Reference in New Issue