Qt: Get rid of duplicate base setting query helpers

This commit is contained in:
Connor McLaughlin 2022-05-24 22:37:44 +10:00 committed by refractionpcsx2
parent 9481bbd2ef
commit 2a32864856
16 changed files with 108 additions and 128 deletions

View File

@ -20,6 +20,7 @@
#include "QtHost.h"
#include "QtUtils.h"
#include "pcsx2/HostSettings.h"
#include "pcsx2/SysForwardDefs.h"
#include "svnrev.h"
@ -424,7 +425,7 @@ void AutoUpdaterDialog::downloadUpdateClicked()
void AutoUpdaterDialog::checkIfUpdateNeeded()
{
const QString last_checked_version(
QString::fromStdString(QtHost::GetBaseStringSettingValue("AutoUpdater", "LastVersion")));
QString::fromStdString(Host::GetBaseStringSettingValue("AutoUpdater", "LastVersion")));
Console.WriteLn(Color_StrongGreen, "Current version: %s", GIT_TAG);
Console.WriteLn(Color_StrongYellow, "Latest SHA: %s", m_latest_version.toUtf8().constData());

View File

@ -33,6 +33,7 @@
#include "pcsx2/GS/GS.h"
#include "pcsx2/GSDumpReplayer.h"
#include "pcsx2/HostDisplay.h"
#include "pcsx2/HostSettings.h"
#include "pcsx2/PAD/Host/PAD.h"
#include "pcsx2/PerformanceMetrics.h"
#include "pcsx2/Recording/InputRecordingControls.h"
@ -106,8 +107,8 @@ void EmuThread::startVM(std::shared_ptr<VMBootParameters> boot_params)
emit onVMStarting();
// create the display, this may take a while...
m_is_fullscreen = boot_params->fullscreen.value_or(QtHost::GetBaseBoolSettingValue("UI", "StartFullscreen", false));
m_is_rendering_to_main = QtHost::GetBaseBoolSettingValue("UI", "RenderToMainWindow", true);
m_is_fullscreen = boot_params->fullscreen.value_or(Host::GetBaseBoolSettingValue("UI", "StartFullscreen", false));
m_is_rendering_to_main = Host::GetBaseBoolSettingValue("UI", "RenderToMainWindow", true);
m_is_surfaceless = false;
m_save_state_on_shutdown = false;
if (!VMManager::Initialize(*boot_params))
@ -409,14 +410,14 @@ void EmuThread::reloadGameSettings()
void EmuThread::loadOurSettings()
{
m_verbose_status = QtHost::GetBaseBoolSettingValue("UI", "VerboseStatusBar", false);
m_verbose_status = Host::GetBaseBoolSettingValue("UI", "VerboseStatusBar", false);
}
void EmuThread::checkForSettingChanges()
{
if (VMManager::HasValidVM())
{
const bool render_to_main = QtHost::GetBaseBoolSettingValue("UI", "RenderToMainWindow", true);
const bool render_to_main = Host::GetBaseBoolSettingValue("UI", "RenderToMainWindow", true);
if (!m_is_fullscreen && m_is_rendering_to_main != render_to_main)
{
m_is_rendering_to_main = render_to_main;

View File

@ -19,6 +19,7 @@
#include "common/StringUtil.h"
#include "pcsx2/Frontend/GameList.h"
#include "pcsx2/HostSettings.h"
#include <QtCore/QSortFilterProxyModel>
#include <QtGui/QPixmap>
@ -73,8 +74,8 @@ GameListWidget::~GameListWidget() = default;
void GameListWidget::initialize()
{
m_model = new GameListModel(this);
m_model->setCoverScale(QtHost::GetBaseFloatSettingValue("UI", "GameListCoverArtScale", 0.45f));
m_model->setShowCoverTitles(QtHost::GetBaseBoolSettingValue("UI", "GameListShowCoverTitles", true));
m_model->setCoverScale(Host::GetBaseFloatSettingValue("UI", "GameListCoverArtScale", 0.45f));
m_model->setShowCoverTitles(Host::GetBaseBoolSettingValue("UI", "GameListShowCoverTitles", true));
m_sort_model = new GameListSortModel(m_model);
m_sort_model->setSourceModel(m_model);
@ -136,7 +137,7 @@ void GameListWidget::initialize()
connect(m_empty_ui.scanForNewGames, &QPushButton::clicked, this, [this]() { refresh(false); });
insertWidget(2, m_empty_widget);
if (QtHost::GetBaseBoolSettingValue("UI", "GameListGridView", false))
if (Host::GetBaseBoolSettingValue("UI", "GameListGridView", false))
setCurrentIndex(1);
else
setCurrentIndex(0);
@ -186,7 +187,7 @@ void GameListWidget::onRefreshProgress(const QString& status, int current, int t
{
// switch away from the placeholder while we scan, in case we find anything
if (currentIndex() == 2)
setCurrentIndex(QtHost::GetBaseBoolSettingValue("UI", "GameListGridView", false) ? 1 : 0);
setCurrentIndex(Host::GetBaseBoolSettingValue("UI", "GameListGridView", false) ? 1 : 0);
m_model->refresh();
emit refreshProgress(status, current, total);
@ -377,7 +378,7 @@ void GameListWidget::loadTableViewColumnVisibilitySettings()
for (int column = 0; column < GameListModel::Column_Count; column++)
{
const bool visible = QtHost::GetBaseBoolSettingValue(
const bool visible = Host::GetBaseBoolSettingValue(
"GameListTableView", getColumnVisibilitySettingsKeyName(column).c_str(), DEFAULT_VISIBILITY[column]);
m_table_view->setColumnHidden(column, !visible);
}
@ -404,10 +405,10 @@ void GameListWidget::loadTableViewColumnSortSettings()
const bool DEFAULT_SORT_DESCENDING = false;
const GameListModel::Column sort_column =
GameListModel::getColumnIdForName(QtHost::GetBaseStringSettingValue("GameListTableView", "SortColumn"))
GameListModel::getColumnIdForName(Host::GetBaseStringSettingValue("GameListTableView", "SortColumn"))
.value_or(DEFAULT_SORT_COLUMN);
const bool sort_descending =
QtHost::GetBaseBoolSettingValue("GameListTableView", "SortDescending", DEFAULT_SORT_DESCENDING);
Host::GetBaseBoolSettingValue("GameListTableView", "SortDescending", DEFAULT_SORT_DESCENDING);
m_table_view->sortByColumn(sort_column, sort_descending ? Qt::DescendingOrder : Qt::AscendingOrder);
}

View File

@ -30,6 +30,7 @@
#include "pcsx2/Frontend/GameList.h"
#include "pcsx2/GSDumpReplayer.h"
#include "pcsx2/HostDisplay.h"
#include "pcsx2/HostSettings.h"
#include "pcsx2/PerformanceMetrics.h"
#include "pcsx2/Recording/InputRecording.h"
@ -98,16 +99,16 @@ void MainWindow::initialize()
void MainWindow::setupAdditionalUi()
{
const bool toolbar_visible = QtHost::GetBaseBoolSettingValue("UI", "ShowToolbar", false);
const bool toolbar_visible = Host::GetBaseBoolSettingValue("UI", "ShowToolbar", false);
m_ui.actionViewToolbar->setChecked(toolbar_visible);
m_ui.toolBar->setVisible(toolbar_visible);
const bool toolbars_locked = QtHost::GetBaseBoolSettingValue("UI", "LockToolbar", false);
const bool toolbars_locked = Host::GetBaseBoolSettingValue("UI", "LockToolbar", false);
m_ui.actionViewLockToolbar->setChecked(toolbars_locked);
m_ui.toolBar->setMovable(!toolbars_locked);
m_ui.toolBar->setContextMenuPolicy(Qt::PreventContextMenu);
const bool status_bar_visible = QtHost::GetBaseBoolSettingValue("UI", "ShowStatusBar", true);
const bool status_bar_visible = Host::GetBaseBoolSettingValue("UI", "ShowStatusBar", true);
m_ui.actionViewStatusBar->setChecked(status_bar_visible);
m_ui.statusBar->setVisible(status_bar_visible);
@ -293,7 +294,7 @@ void MainWindow::recreate()
void MainWindow::setStyleFromSettings()
{
const std::string theme(QtHost::GetBaseStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
const std::string theme(Host::GetBaseStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
if (theme == "fusion")
{
@ -522,7 +523,7 @@ void MainWindow::setStyleFromSettings()
void MainWindow::setIconThemeFromSettings()
{
const std::string theme(QtHost::GetBaseStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
const std::string theme(Host::GetBaseStringSettingValue("UI", "Theme", DEFAULT_THEME_NAME));
QString icon_theme;
if (theme == "darkfusion" || theme == "darkfusionblue" || theme == "dualtoneOrangeBlue" || theme == "ScarletDevilRed")
@ -571,7 +572,7 @@ void MainWindow::saveStateToConfig()
{
const QByteArray geometry = saveGeometry();
const QByteArray geometry_b64 = geometry.toBase64();
const std::string old_geometry_b64 = QtHost::GetBaseStringSettingValue("UI", "MainWindowGeometry");
const std::string old_geometry_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowGeometry");
if (old_geometry_b64 != geometry_b64.constData())
QtHost::SetBaseStringSettingValue("UI", "MainWindowGeometry", geometry_b64.constData());
}
@ -579,7 +580,7 @@ void MainWindow::saveStateToConfig()
{
const QByteArray state = saveState();
const QByteArray state_b64 = state.toBase64();
const std::string old_state_b64 = QtHost::GetBaseStringSettingValue("UI", "MainWindowState");
const std::string old_state_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowState");
if (old_state_b64 != state_b64.constData())
QtHost::SetBaseStringSettingValue("UI", "MainWindowState", state_b64.constData());
}
@ -588,14 +589,14 @@ void MainWindow::saveStateToConfig()
void MainWindow::restoreStateFromConfig()
{
{
const std::string geometry_b64 = QtHost::GetBaseStringSettingValue("UI", "MainWindowGeometry");
const std::string geometry_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowGeometry");
const QByteArray geometry = QByteArray::fromBase64(QByteArray::fromStdString(geometry_b64));
if (!geometry.isEmpty())
restoreGeometry(geometry);
}
{
const std::string state_b64 = QtHost::GetBaseStringSettingValue("UI", "MainWindowState");
const std::string state_b64 = Host::GetBaseStringSettingValue("UI", "MainWindowState");
const QByteArray state = QByteArray::fromBase64(QByteArray::fromStdString(state_b64));
if (!state.isEmpty())
restoreState(state);
@ -810,7 +811,7 @@ bool MainWindow::requestShutdown(bool allow_confirm /* = true */, bool allow_sav
bool save_state = allow_save_to_state && EmuConfig.SaveStateOnShutdown;
// only confirm on UI thread because we need to display a msgbox
if (allow_confirm && !GSDumpReplayer::IsReplayingDump() && QtHost::GetBaseBoolSettingValue("UI", "ConfirmShutdown", true))
if (allow_confirm && !GSDumpReplayer::IsReplayingDump() && Host::GetBaseBoolSettingValue("UI", "ConfirmShutdown", true))
{
VMLock lock(pauseAndLockVM());
@ -1189,7 +1190,7 @@ void MainWindow::onUpdateCheckComplete()
void MainWindow::startupUpdateCheck()
{
if (!QtHost::GetBaseBoolSettingValue("AutoUpdater", "CheckAtStartup", true))
if (!Host::GetBaseBoolSettingValue("AutoUpdater", "CheckAtStartup", true))
return;
checkForUpdates(false);
@ -1397,7 +1398,7 @@ DisplayWidget* MainWindow::createDisplay(bool fullscreen, bool render_to_main)
if (!host_display)
return nullptr;
const std::string fullscreen_mode(QtHost::GetBaseStringSettingValue("EmuCore/GS", "FullscreenMode", ""));
const std::string fullscreen_mode(Host::GetBaseStringSettingValue("EmuCore/GS", "FullscreenMode", ""));
const bool is_exclusive_fullscreen = (fullscreen && !fullscreen_mode.empty() && host_display->SupportsFullscreen());
QWidget* container;
@ -1479,7 +1480,7 @@ DisplayWidget* MainWindow::updateDisplay(bool fullscreen, bool render_to_main, b
QWidget* container = m_display_container ? static_cast<QWidget*>(m_display_container) : static_cast<QWidget*>(m_display_widget);
const bool is_fullscreen = isRenderingFullscreen();
const bool is_rendering_to_main = isRenderingToMain();
const std::string fullscreen_mode(QtHost::GetBaseStringSettingValue("EmuCore/GS", "FullscreenMode", ""));
const std::string fullscreen_mode(Host::GetBaseStringSettingValue("EmuCore/GS", "FullscreenMode", ""));
const bool is_exclusive_fullscreen = (fullscreen && !fullscreen_mode.empty() && host_display->SupportsFullscreen());
const bool changing_surfaceless = (!m_display_widget != surfaceless);
if (fullscreen == is_fullscreen && is_rendering_to_main == render_to_main && !changing_surfaceless)
@ -1654,14 +1655,14 @@ void MainWindow::saveDisplayWindowGeometryToConfig()
const QByteArray geometry = getDisplayContainer()->saveGeometry();
const QByteArray geometry_b64 = geometry.toBase64();
const std::string old_geometry_b64 = QtHost::GetBaseStringSettingValue("UI", "DisplayWindowGeometry");
const std::string old_geometry_b64 = Host::GetBaseStringSettingValue("UI", "DisplayWindowGeometry");
if (old_geometry_b64 != geometry_b64.constData())
QtHost::SetBaseStringSettingValue("UI", "DisplayWindowGeometry", geometry_b64.constData());
}
void MainWindow::restoreDisplayWindowGeometryFromConfig()
{
const std::string geometry_b64 = QtHost::GetBaseStringSettingValue("UI", "DisplayWindowGeometry");
const std::string geometry_b64 = Host::GetBaseStringSettingValue("UI", "DisplayWindowGeometry");
const QByteArray geometry = QByteArray::fromBase64(QByteArray::fromStdString(geometry_b64));
QWidget* container = getDisplayContainer();
if (!geometry.isEmpty())

View File

@ -265,41 +265,6 @@ void QtHost::SetDefaultConfig()
PAD::SetDefaultConfig(si);
}
SettingsInterface* QtHost::GetBaseSettingsInterface()
{
return s_base_settings_interface.get();
}
std::string QtHost::GetBaseStringSettingValue(const char* section, const char* key, const char* default_value /*= ""*/)
{
auto lock = Host::GetSettingsLock();
return s_base_settings_interface->GetStringValue(section, key, default_value);
}
bool QtHost::GetBaseBoolSettingValue(const char* section, const char* key, bool default_value /*= false*/)
{
auto lock = Host::GetSettingsLock();
return s_base_settings_interface->GetBoolValue(section, key, default_value);
}
int QtHost::GetBaseIntSettingValue(const char* section, const char* key, int default_value /*= 0*/)
{
auto lock = Host::GetSettingsLock();
return s_base_settings_interface->GetIntValue(section, key, default_value);
}
float QtHost::GetBaseFloatSettingValue(const char* section, const char* key, float default_value /*= 0.0f*/)
{
auto lock = Host::GetSettingsLock();
return s_base_settings_interface->GetFloatValue(section, key, default_value);
}
std::vector<std::string> QtHost::GetBaseStringListSetting(const char* section, const char* key)
{
auto lock = Host::GetSettingsLock();
return s_base_settings_interface->GetStringList(section, key);
}
void QtHost::SetBaseBoolSettingValue(const char* section, const char* key, bool value)
{
auto lock = Host::GetSettingsLock();
@ -820,17 +785,17 @@ void QtHost::InitializeEarlyConsole()
void QtHost::UpdateLogging()
{
const bool system_console_enabled = QtHost::GetBaseBoolSettingValue("Logging", "EnableSystemConsole", false);
const bool file_logging_enabled = QtHost::GetBaseBoolSettingValue("Logging", "EnableFileLogging", false);
const bool system_console_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableSystemConsole", false);
const bool file_logging_enabled = Host::GetBaseBoolSettingValue("Logging", "EnableFileLogging", false);
const bool any_logging_sinks = system_console_enabled || file_logging_enabled;
DevConWriterEnabled = any_logging_sinks && (IsDevBuild || QtHost::GetBaseBoolSettingValue("Logging", "EnableVerbose", false));
SysConsole.eeConsole.Enabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableEEConsole", false);
SysConsole.iopConsole.Enabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableIOPConsole", false);
DevConWriterEnabled = any_logging_sinks && (IsDevBuild || Host::GetBaseBoolSettingValue("Logging", "EnableVerbose", false));
SysConsole.eeConsole.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableEEConsole", false);
SysConsole.iopConsole.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableIOPConsole", false);
// Input Recording Logs
SysConsole.recordingConsole.Enabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableInputRecordingLogs", true);
SysConsole.controlInfo.Enabled = any_logging_sinks && QtHost::GetBaseBoolSettingValue("Logging", "EnableControllerLogs", false);
SysConsole.recordingConsole.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableInputRecordingLogs", true);
SysConsole.controlInfo.Enabled = any_logging_sinks && Host::GetBaseBoolSettingValue("Logging", "EnableControllerLogs", false);
UpdateLoggingSinks(system_console_enabled, file_logging_enabled);
}

View File

@ -60,12 +60,6 @@ namespace QtHost
QString GetAppConfigSuffix();
/// Thread-safe settings access.
SettingsInterface* GetBaseSettingsInterface();
std::string GetBaseStringSettingValue(const char* section, const char* key, const char* default_value = "");
bool GetBaseBoolSettingValue(const char* section, const char* key, bool default_value = false);
int GetBaseIntSettingValue(const char* section, const char* key, int default_value = 0);
float GetBaseFloatSettingValue(const char* section, const char* key, float default_value = 0.0f);
std::vector<std::string> GetBaseStringListSetting(const char* section, const char* key);
void SetBaseBoolSettingValue(const char* section, const char* key, bool value);
void SetBaseIntSettingValue(const char* section, const char* key, int value);
void SetBaseFloatSettingValue(const char* section, const char* key, float value);

View File

@ -27,6 +27,8 @@
#include <QtWidgets/QSlider>
#include <QtWidgets/QSpinBox>
#include "pcsx2/HostSettings.h"
#include "EmuThread.h"
#include "QtHost.h"
#include "Settings/SettingsDialog.h"
@ -387,7 +389,7 @@ namespace SettingWidgetBinder
{
using Accessor = SettingAccessor<WidgetType>;
const bool value = QtHost::GetBaseBoolSettingValue(section.c_str(), key.c_str(), default_value);
const bool value = Host::GetBaseBoolSettingValue(section.c_str(), key.c_str(), default_value);
if (sif)
{
@ -427,7 +429,7 @@ namespace SettingWidgetBinder
{
using Accessor = SettingAccessor<WidgetType>;
const s32 value = QtHost::GetBaseIntSettingValue(section.c_str(), key.c_str(), static_cast<s32>(default_value)) - option_offset;
const s32 value = Host::GetBaseIntSettingValue(section.c_str(), key.c_str(), static_cast<s32>(default_value)) - option_offset;
if (sif)
{
@ -466,7 +468,7 @@ namespace SettingWidgetBinder
{
using Accessor = SettingAccessor<WidgetType>;
const float value = QtHost::GetBaseFloatSettingValue(section.c_str(), key.c_str(), default_value);
const float value = Host::GetBaseFloatSettingValue(section.c_str(), key.c_str(), default_value);
if (sif)
{
@ -506,7 +508,7 @@ namespace SettingWidgetBinder
{
using Accessor = SettingAccessor<WidgetType>;
const float value = QtHost::GetBaseFloatSettingValue(section.c_str(), key.c_str(), default_value);
const float value = Host::GetBaseFloatSettingValue(section.c_str(), key.c_str(), default_value);
if (sif)
{
@ -546,7 +548,7 @@ namespace SettingWidgetBinder
{
using Accessor = SettingAccessor<WidgetType>;
const QString value(QString::fromStdString(QtHost::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value.c_str())));
const QString value(QString::fromStdString(Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value.c_str())));
if (sif)
{
@ -591,7 +593,7 @@ namespace SettingWidgetBinder
using Accessor = SettingAccessor<WidgetType>;
using UnderlyingType = std::underlying_type_t<DataType>;
const std::string value(QtHost::GetBaseStringSettingValue(section.c_str(), key.c_str(), to_string_function(default_value)));
const std::string value(Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), to_string_function(default_value)));
const std::optional<DataType> typed_value = from_string_function(value.c_str());
if (sif)
@ -651,7 +653,7 @@ namespace SettingWidgetBinder
using UnderlyingType = std::underlying_type_t<DataType>;
const std::string value(
QtHost::GetBaseStringSettingValue(section.c_str(), key.c_str(), enum_names[static_cast<UnderlyingType>(default_value)]));
Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), enum_names[static_cast<UnderlyingType>(default_value)]));
UnderlyingType enum_index = static_cast<UnderlyingType>(default_value);
for (UnderlyingType i = 0; enum_names[i] != nullptr; i++)
@ -710,7 +712,7 @@ namespace SettingWidgetBinder
{
using Accessor = SettingAccessor<WidgetType>;
const std::string value = QtHost::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value);
const std::string value = Host::GetBaseStringSettingValue(section.c_str(), key.c_str(), default_value);
for (int i = 0; enum_names[i] != nullptr; i++)
widget->addItem(QString::fromUtf8(enum_names[i]));

View File

@ -19,6 +19,7 @@
#include <QtWidgets/QFileDialog>
#include <algorithm>
#include "pcsx2/HostSettings.h"
#include "pcsx2/ps2/BiosTools.h"
#include "BIOSSettingsWidget.h"
@ -110,7 +111,7 @@ void BIOSSettingsWidget::updateSearchDirectory()
void BIOSSettingsWidget::listRefreshed(const QVector<BIOSInfo>& items)
{
const std::string selected_bios(QtHost::GetBaseStringSettingValue("Filenames", "BIOS"));
const std::string selected_bios(Host::GetBaseStringSettingValue("Filenames", "BIOS"));
QSignalBlocker sb(m_ui.fileList);
for (const BIOSInfo& bi : items)

View File

@ -27,6 +27,7 @@
#include "SettingsDialog.h"
#include "common/StringUtil.h"
#include "pcsx2/HostSettings.h"
#include "pcsx2/PAD/Host/PAD.h"
#include "SettingWidgetBinder.h"
@ -64,7 +65,7 @@ void ControllerBindingWidget::onTypeChanged()
m_current_widget = nullptr;
}
m_controller_type = QtHost::GetBaseStringSettingValue(m_config_section.c_str(), "Type");
m_controller_type = Host::GetBaseStringSettingValue(m_config_section.c_str(), "Type");
const int index = m_ui.controllerType->findData(QString::fromStdString(m_controller_type));
if (index >= 0 && index != m_ui.controllerType->currentIndex())
@ -119,7 +120,7 @@ void ControllerBindingWidget::doDeviceAutomaticBinding(const QString& device)
bool result;
{
auto lock = Host::GetSettingsLock();
result = PAD::MapController(*QtHost::GetBaseSettingsInterface(), m_port_number, mapping);
result = PAD::MapController(*Host::Internal::GetBaseSettingsLayer(), m_port_number, mapping);
}
if (result)

View File

@ -20,6 +20,9 @@
#include <algorithm>
#include "common/StringUtil.h"
#include "pcsx2/HostSettings.h"
#include "DEV9SettingsWidget.h"
#include "EmuThread.h"
#include "QtUtils.h"
@ -166,7 +169,7 @@ DEV9SettingsWidget::DEV9SettingsWidget(SettingsDialog* dialog, QWidget* parent)
//We replace the blank entry with one for global settings
if (m_dialog->isPerGameSettings())
{
const std::string valueAPI = QtHost::GetBaseStringSettingValue("DEV9/Eth", "EthApi", Pcsx2Config::DEV9Options::NetApiNames[static_cast<int>(Pcsx2Config::DEV9Options::NetApi::Unset)]);
const std::string valueAPI = Host::GetBaseStringSettingValue("DEV9/Eth", "EthApi", Pcsx2Config::DEV9Options::NetApiNames[static_cast<int>(Pcsx2Config::DEV9Options::NetApi::Unset)]);
for (int i = 0; Pcsx2Config::DEV9Options::NetApiNames[i] != nullptr; i++)
{
if (valueAPI == Pcsx2Config::DEV9Options::NetApiNames[i])
@ -179,7 +182,7 @@ DEV9SettingsWidget::DEV9SettingsWidget(SettingsDialog* dialog, QWidget* parent)
std::vector<AdapterEntry> baseList = m_adapter_list[static_cast<u32>(m_global_api)];
std::string baseAdapter = " ";
const std::string valueGUID = QtHost::GetBaseStringSettingValue("DEV9/Eth", "EthDevice", "");
const std::string valueGUID = Host::GetBaseStringSettingValue("DEV9/Eth", "EthDevice", "");
for (size_t i = 0; i < baseList.size(); i++)
{
if (baseList[i].guid == valueGUID)
@ -239,11 +242,11 @@ DEV9SettingsWidget::DEV9SettingsWidget(SettingsDialog* dialog, QWidget* parent)
m_ui.ethDNS1Addr ->setText(QString::fromUtf8(m_dialog->getStringValue("DEV9/Eth", "DNS1", "").value().c_str()));
m_ui.ethDNS2Addr ->setText(QString::fromUtf8(m_dialog->getStringValue("DEV9/Eth", "DNS2", "").value().c_str()));
m_ui.ethPS2Addr ->setPlaceholderText(QString::fromUtf8(QtHost::GetBaseStringSettingValue("DEV9/Eth", "PS2IP", "0.0.0.0").c_str()));
m_ui.ethNetMask ->setPlaceholderText(QString::fromUtf8(QtHost::GetBaseStringSettingValue("DEV9/Eth", "Mask", "0.0.0.0").c_str()));
m_ui.ethGatewayAddr->setPlaceholderText(QString::fromUtf8(QtHost::GetBaseStringSettingValue("DEV9/Eth", "Gateway", "0.0.0.0").c_str()));
m_ui.ethDNS1Addr ->setPlaceholderText(QString::fromUtf8(QtHost::GetBaseStringSettingValue("DEV9/Eth", "DNS1", "0.0.0.0").c_str()));
m_ui.ethDNS2Addr ->setPlaceholderText(QString::fromUtf8(QtHost::GetBaseStringSettingValue("DEV9/Eth", "DNS2", "0.0.0.0").c_str()));
m_ui.ethPS2Addr ->setPlaceholderText(QString::fromUtf8(Host::GetBaseStringSettingValue("DEV9/Eth", "PS2IP", "0.0.0.0").c_str()));
m_ui.ethNetMask ->setPlaceholderText(QString::fromUtf8(Host::GetBaseStringSettingValue("DEV9/Eth", "Mask", "0.0.0.0").c_str()));
m_ui.ethGatewayAddr->setPlaceholderText(QString::fromUtf8(Host::GetBaseStringSettingValue("DEV9/Eth", "Gateway", "0.0.0.0").c_str()));
m_ui.ethDNS1Addr ->setPlaceholderText(QString::fromUtf8(Host::GetBaseStringSettingValue("DEV9/Eth", "DNS1", "0.0.0.0").c_str()));
m_ui.ethDNS2Addr ->setPlaceholderText(QString::fromUtf8(Host::GetBaseStringSettingValue("DEV9/Eth", "DNS2", "0.0.0.0").c_str()));
}
else
{
@ -319,7 +322,7 @@ DEV9SettingsWidget::DEV9SettingsWidget(SettingsDialog* dialog, QWidget* parent)
connect(m_ui.hddFile, &QLineEdit::editingFinished, this, &DEV9SettingsWidget::onHddFileEdit);
SettingWidgetBinder::BindWidgetToStringSetting(sif, m_ui.hddFile, "DEV9/Hdd", "HddFile", "DEV9hdd.raw");
if (m_dialog->isPerGameSettings())
m_ui.hddFile->setPlaceholderText(QString::fromUtf8(QtHost::GetBaseStringSettingValue("DEV9/Hdd", "HddFile", "DEV9hdd.raw")));
m_ui.hddFile->setPlaceholderText(QString::fromUtf8(Host::GetBaseStringSettingValue("DEV9/Hdd", "HddFile", "DEV9hdd.raw")));
connect(m_ui.hddBrowseFile, &QPushButton::clicked, this, &DEV9SettingsWidget::onHddBrowseFileClicked);
//TODO: need a getUintValue for if 48bit support occurs
@ -327,7 +330,7 @@ DEV9SettingsWidget::DEV9SettingsWidget(SettingsDialog* dialog, QWidget* parent)
if (m_dialog->isPerGameSettings())
{
const int sizeGlobal = (u64)QtHost::GetBaseIntSettingValue("DEV9/Hdd", "HddSizeSectors", 0) * 512 / (1024 * 1024 * 1024);
const int sizeGlobal = (u64)Host::GetBaseIntSettingValue("DEV9/Hdd", "HddSizeSectors", 0) * 512 / (1024 * 1024 * 1024);
m_ui.hddSizeSpinBox->setMinimum(39);
m_ui.hddSizeSpinBox->setSpecialValueText(tr("Global [%1]").arg(sizeGlobal));
}
@ -345,7 +348,7 @@ DEV9SettingsWidget::DEV9SettingsWidget(SettingsDialog* dialog, QWidget* parent)
void DEV9SettingsWidget::onEthEnabledChanged(int state)
{
const bool enabled = state == Qt::CheckState::PartiallyChecked ? QtHost::GetBaseBoolSettingValue("DEV9/Eth", "EthEnable", false) : state;
const bool enabled = state == Qt::CheckState::PartiallyChecked ? Host::GetBaseBoolSettingValue("DEV9/Eth", "EthEnable", false) : state;
m_ui.ethDevType->setEnabled(enabled);
m_ui.ethDevTypeLabel->setEnabled(enabled);
@ -434,7 +437,7 @@ void DEV9SettingsWidget::onEthDeviceChanged(int index)
void DEV9SettingsWidget::onEthDHCPInterceptChanged(int state)
{
const bool enabled = (state == Qt::CheckState::PartiallyChecked ? QtHost::GetBaseBoolSettingValue("DEV9/Eth", "InterceptDHCP", false) : state) ||
const bool enabled = (state == Qt::CheckState::PartiallyChecked ? Host::GetBaseBoolSettingValue("DEV9/Eth", "InterceptDHCP", false) : state) ||
((m_adapter_options & AdapterOptions::DHCP_ForcedOn) == AdapterOptions::DHCP_ForcedOn);
// clang-format off
@ -491,7 +494,7 @@ void DEV9SettingsWidget::onEthAutoChanged(QCheckBox* sender, int state, QLineEdi
{
if (sender->isEnabled())
{
const bool manual = !(state == Qt::CheckState::PartiallyChecked ? QtHost::GetBaseBoolSettingValue(section, key, true) : state);
const bool manual = !(state == Qt::CheckState::PartiallyChecked ? Host::GetBaseBoolSettingValue(section, key, true) : state);
input->setEnabled(manual);
}
else
@ -506,7 +509,7 @@ void DEV9SettingsWidget::onEthDNSModeChanged(QComboBox* sender, int index, QLine
{
if (index == 0)
{
const std::string value = QtHost::GetBaseStringSettingValue(section, key, Pcsx2Config::DEV9Options::DnsModeNames[static_cast<int>(Pcsx2Config::DEV9Options::DnsMode::Auto)]);
const std::string value = Host::GetBaseStringSettingValue(section, key, Pcsx2Config::DEV9Options::DnsModeNames[static_cast<int>(Pcsx2Config::DEV9Options::DnsMode::Auto)]);
for (int i = 0; Pcsx2Config::DEV9Options::DnsModeNames[i] != nullptr; i++)
{
if (value == Pcsx2Config::DEV9Options::DnsModeNames[i])

View File

@ -19,6 +19,8 @@
#include <QtWidgets/QMessageBox>
#include <limits>
#include "pcsx2/HostSettings.h"
#include "EmulationSettingsWidget.h"
#include "QtUtils.h"
#include "SettingWidgetBinder.h"
@ -82,7 +84,7 @@ EmulationSettingsWidget::~EmulationSettingsWidget() = default;
void EmulationSettingsWidget::initializeSpeedCombo(QComboBox* cb, const char* section, const char* key, float default_value)
{
float value = QtHost::GetBaseFloatSettingValue(section, key, default_value);
float value = Host::GetBaseFloatSettingValue(section, key, default_value);
if (m_dialog->isPerGameSettings())
{
cb->addItem(tr("Use Global Setting [%1%]").arg(value * 100.0f, 0, 'f', 0));

View File

@ -77,7 +77,7 @@ void GameListSettingsWidget::refreshExclusionList()
{
m_ui.excludedPaths->clear();
const std::vector<std::string> paths(QtHost::GetBaseStringListSetting("GameList", "ExcludedPaths"));
const std::vector<std::string> paths(Host::GetBaseStringListSetting("GameList", "ExcludedPaths"));
for (const std::string& path : paths)
m_ui.excludedPaths->addItem(QString::fromStdString(path));
}
@ -124,11 +124,11 @@ void GameListSettingsWidget::refreshDirectoryList()
while (m_ui.searchDirectoryList->rowCount() > 0)
m_ui.searchDirectoryList->removeRow(0);
std::vector<std::string> path_list = QtHost::GetBaseStringListSetting("GameList", "Paths");
std::vector<std::string> path_list = Host::GetBaseStringListSetting("GameList", "Paths");
for (const std::string& entry : path_list)
addPathToTable(entry, false);
path_list = QtHost::GetBaseStringListSetting("GameList", "RecursivePaths");
path_list = Host::GetBaseStringListSetting("GameList", "RecursivePaths");
for (const std::string& entry : path_list)
addPathToTable(entry, true);

View File

@ -21,6 +21,7 @@
#include "SettingsDialog.h"
#include <QtWidgets/QMessageBox>
#include "pcsx2/HostSettings.h"
#include "pcsx2/GS/GS.h"
#include "pcsx2/GS/GSUtil.h"
@ -235,7 +236,7 @@ GraphicsSettingsWidget::GraphicsSettingsWidget(SettingsDialog* dialog, QWidget*
// per-game override for renderer is slightly annoying, since we need to populate the global setting field
if (sif)
{
const int global_renderer = QtHost::GetBaseIntSettingValue("EmuCore/GS", "Renderer", static_cast<int>(GSRendererType::Auto));
const int global_renderer = Host::GetBaseIntSettingValue("EmuCore/GS", "Renderer", static_cast<int>(GSRendererType::Auto));
QString global_renderer_name;
for (const RendererInfo& ri : s_renderer_info)
{
@ -336,7 +337,7 @@ void GraphicsSettingsWidget::onShadeBoostChanged()
void GraphicsSettingsWidget::onGpuPaletteConversionChanged(int state)
{
const bool enabled = state == Qt::CheckState::PartiallyChecked ? QtHost::GetBaseBoolSettingValue("EmuCore/GS", "paltex", false) : state;
const bool enabled = state == Qt::CheckState::PartiallyChecked ? Host::GetBaseBoolSettingValue("EmuCore/GS", "paltex", false) : state;
m_ui.anisotropicFiltering->setEnabled(!enabled);
}
@ -458,7 +459,7 @@ void GraphicsSettingsWidget::updateRendererDependentOptions()
{
QSignalBlocker sb(m_ui.adapter);
std::string current_adapter = QtHost::GetBaseStringSettingValue("EmuCore/GS", "Adapter", "");
std::string current_adapter = Host::GetBaseStringSettingValue("EmuCore/GS", "Adapter", "");
m_ui.adapter->clear();
m_ui.adapter->setEnabled(!modes.adapter_names.empty());
m_ui.adapter->addItem(tr("(Default)"));
@ -488,7 +489,7 @@ void GraphicsSettingsWidget::updateRendererDependentOptions()
{
QSignalBlocker sb(m_ui.fullscreenModes);
std::string current_mode(QtHost::GetBaseStringSettingValue("EmuCore/GS", "FullscreenMode", ""));
std::string current_mode(Host::GetBaseStringSettingValue("EmuCore/GS", "FullscreenMode", ""));
m_ui.fullscreenModes->clear();
m_ui.fullscreenModes->addItem(tr("Borderless Fullscreen"));
m_ui.fullscreenModes->setCurrentIndex(0);

View File

@ -15,12 +15,6 @@
#include "PrecompiledHeader.h"
#include "EmuThread.h"
#include "QtHost.h"
#include "QtUtils.h"
#include "Settings/ControllerSettingsDialog.h"
#include "Settings/InputBindingDialog.h"
#include "Settings/InputBindingWidget.h"
#include <QtCore/QTimer>
#include <QtGui/QKeyEvent>
#include <QtGui/QMouseEvent>
@ -28,8 +22,17 @@
#include <cmath>
#include <sstream>
#include "pcsx2/HostSettings.h"
#include "pcsx2/GS/GSIntrin.h" // _BitScanForward
#include "EmuThread.h"
#include "QtHost.h"
#include "QtUtils.h"
#include "Settings/ControllerSettingsDialog.h"
#include "Settings/InputBindingDialog.h"
#include "Settings/InputBindingWidget.h"
InputBindingWidget::InputBindingWidget(QWidget* parent)
: QPushButton(parent)
{
@ -56,7 +59,7 @@ void InputBindingWidget::setKey(std::string section_name, std::string key_name)
{
m_section_name = std::move(section_name);
m_key_name = std::move(key_name);
m_bindings = QtHost::GetBaseStringListSetting(m_section_name.c_str(), m_key_name.c_str());
m_bindings = Host::GetBaseStringListSetting(m_section_name.c_str(), m_key_name.c_str());
updateText();
}
@ -183,7 +186,7 @@ void InputBindingWidget::clearBinding()
void InputBindingWidget::reloadBinding()
{
m_bindings = QtHost::GetBaseStringListSetting(m_section_name.c_str(), m_key_name.c_str());
m_bindings = Host::GetBaseStringListSetting(m_section_name.c_str(), m_key_name.c_str());
updateText();
}
@ -319,7 +322,7 @@ void InputVibrationBindingWidget::setKey(ControllerSettingsDialog* dialog, std::
m_dialog = dialog;
m_section_name = std::move(section_name);
m_key_name = std::move(key_name);
m_binding = QtHost::GetBaseStringSettingValue(m_section_name.c_str(), m_key_name.c_str());
m_binding = Host::GetBaseStringSettingValue(m_section_name.c_str(), m_key_name.c_str());
setText(QString::fromStdString(m_binding));
}

View File

@ -18,6 +18,8 @@
#include "common/FileSystem.h"
#include "common/Path.h"
#include "common/StringUtil.h"
#include "pcsx2/HostSettings.h"
#include "pcsx2/Frontend/GameList.h"
#include "pcsx2/Frontend/INISettingsInterface.h"
@ -249,7 +251,7 @@ bool SettingsDialog::getEffectiveBoolValue(const char* section, const char* key,
if (m_sif && m_sif->GetBoolValue(section, key, &value))
return value;
else
return QtHost::GetBaseBoolSettingValue(section, key, default_value);
return Host::GetBaseBoolSettingValue(section, key, default_value);
}
int SettingsDialog::getEffectiveIntValue(const char* section, const char* key, int default_value) const
@ -258,7 +260,7 @@ int SettingsDialog::getEffectiveIntValue(const char* section, const char* key, i
if (m_sif && m_sif->GetIntValue(section, key, &value))
return value;
else
return QtHost::GetBaseIntSettingValue(section, key, default_value);
return Host::GetBaseIntSettingValue(section, key, default_value);
}
float SettingsDialog::getEffectiveFloatValue(const char* section, const char* key, float default_value) const
@ -267,14 +269,14 @@ float SettingsDialog::getEffectiveFloatValue(const char* section, const char* ke
if (m_sif && m_sif->GetFloatValue(section, key, &value))
return value;
else
return QtHost::GetBaseFloatSettingValue(section, key, default_value);
return Host::GetBaseFloatSettingValue(section, key, default_value);
}
std::string SettingsDialog::getEffectiveStringValue(const char* section, const char* key, const char* default_value) const
{
std::string value;
if (!m_sif || !m_sif->GetStringValue(section, key, &value))
value = QtHost::GetBaseStringSettingValue(section, key, default_value);
value = Host::GetBaseStringSettingValue(section, key, default_value);
return value;
}
@ -291,7 +293,7 @@ std::optional<bool> SettingsDialog::getBoolValue(const char* section, const char
}
else
{
value = QtHost::GetBaseBoolSettingValue(section, key, default_value.value_or(false));
value = Host::GetBaseBoolSettingValue(section, key, default_value.value_or(false));
}
return value;
@ -310,7 +312,7 @@ std::optional<int> SettingsDialog::getIntValue(const char* section, const char*
}
else
{
value = QtHost::GetBaseIntSettingValue(section, key, default_value.value_or(0));
value = Host::GetBaseIntSettingValue(section, key, default_value.value_or(0));
}
return value;
@ -329,7 +331,7 @@ std::optional<float> SettingsDialog::getFloatValue(const char* section, const ch
}
else
{
value = QtHost::GetBaseFloatSettingValue(section, key, default_value.value_or(0.0f));
value = Host::GetBaseFloatSettingValue(section, key, default_value.value_or(0.0f));
}
return value;
@ -348,7 +350,7 @@ std::optional<std::string> SettingsDialog::getStringValue(const char* section, c
}
else
{
value = QtHost::GetBaseStringSettingValue(section, key, default_value.value_or(""));
value = Host::GetBaseStringSettingValue(section, key, default_value.value_or(""));
}
return value;

View File

@ -18,6 +18,8 @@
#include <QtWidgets/QMessageBox>
#include <algorithm>
#include "pcsx2/HostSettings.h"
#include "EmuThread.h"
#include "QtUtils.h"
#include "SettingWidgetBinder.h"
@ -50,7 +52,7 @@ SystemSettingsWidget::SystemSettingsWidget(SettingsDialog* dialog, QWidget* pare
m_ui.eeCycleRate->insertItem(
0, tr("Use Global Setting [%1]")
.arg(m_ui.eeCycleRate->itemText(
std::clamp(QtHost::GetBaseIntSettingValue("EmuCore/Speedhacks", "EECycleRate", DEFAULT_EE_CYCLE_RATE) - MINIMUM_EE_CYCLE_RATE,
std::clamp(Host::GetBaseIntSettingValue("EmuCore/Speedhacks", "EECycleRate", DEFAULT_EE_CYCLE_RATE) - MINIMUM_EE_CYCLE_RATE,
0, MAXIMUM_EE_CYCLE_RATE - MINIMUM_EE_CYCLE_RATE))));
m_ui.eeClampMode->insertItem(0, tr("Use Global Setting [%1]").arg(m_ui.eeClampMode->itemText(getGlobalClampingModeIndex(false))));
m_ui.vuClampMode->insertItem(0, tr("Use Global Setting [%1]").arg(m_ui.vuClampMode->itemText(getGlobalClampingModeIndex(true))));
@ -86,13 +88,13 @@ void SystemSettingsWidget::updateVU1InstantState()
int SystemSettingsWidget::getGlobalClampingModeIndex(bool vu) const
{
if (QtHost::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuSignOverflow" : "fpuFullMode", false))
if (Host::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuSignOverflow" : "fpuFullMode", false))
return 3;
if (QtHost::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuExtraOverflow" : "fpuExtraOverflow", false))
if (Host::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuExtraOverflow" : "fpuExtraOverflow", false))
return 2;
if (QtHost::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuOverflow" : "fpuOverflow", true))
if (Host::GetBaseBoolSettingValue("EmuCore/CPU/Recompiler", vu ? "vuOverflow" : "fpuOverflow", true))
return 1;
return 0;