| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | // Copyright 2015 Dolphin Emulator Project
 | 
					
						
							|  |  |  | // Licensed under GPLv2+
 | 
					
						
							|  |  |  | // Refer to the license.txt file included.
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 00:40:15 +02:00
										 |  |  | #include "DolphinQt/Settings.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-28 03:48:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-06 18:25:37 +02:00
										 |  |  | #include <QApplication>
 | 
					
						
							| 
									
										
										
										
											2017-05-09 18:49:10 +02:00
										 |  |  | #include <QDir>
 | 
					
						
							| 
									
										
										
										
											2018-05-06 18:25:37 +02:00
										 |  |  | #include <QFile>
 | 
					
						
							| 
									
										
										
										
											2017-07-05 17:35:47 -07:00
										 |  |  | #include <QSettings>
 | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | #include <QSize>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-21 10:26:06 +02:00
										 |  |  | #include "AudioCommon/AudioCommon.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-28 03:48:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-20 09:29:32 -07:00
										 |  |  | #include "Common/Config/Config.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | #include "Common/FileUtil.h"
 | 
					
						
							| 
									
										
										
										
											2017-05-20 17:53:17 +02:00
										 |  |  | #include "Common/StringUtil.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-28 03:48:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 18:29:46 -07:00
										 |  |  | #include "Core/Config/MainSettings.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | #include "Core/ConfigManager.h"
 | 
					
						
							| 
									
										
										
										
											2017-09-04 11:12:13 -07:00
										 |  |  | #include "Core/Core.h"
 | 
					
						
							| 
									
										
										
										
											2018-07-09 00:45:27 -04:00
										 |  |  | #include "Core/NetPlayClient.h"
 | 
					
						
							|  |  |  | #include "Core/NetPlayServer.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-28 03:48:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-07 00:40:15 +02:00
										 |  |  | #include "DolphinQt/GameList/GameListModel.h"
 | 
					
						
							|  |  |  | #include "DolphinQt/QtUtils/QueueOnObject.h"
 | 
					
						
							| 
									
										
										
										
											2018-05-28 03:48:04 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-05 14:17:07 -07:00
										 |  |  | #include "InputCommon/ControllerInterface/ControllerInterface.h"
 | 
					
						
							| 
									
										
										
										
											2017-05-20 17:53:17 +02:00
										 |  |  | #include "InputCommon/InputConfig.h"
 | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-09-04 11:12:13 -07:00
										 |  |  | Settings::Settings() | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-09-15 10:33:22 -07:00
										 |  |  |   qRegisterMetaType<Core::State>(); | 
					
						
							| 
									
										
										
										
											2018-04-22 12:49:07 +02:00
										 |  |  |   Core::SetOnStateChangedCallback([this](Core::State new_state) { | 
					
						
							|  |  |  |     QueueOnObject(this, [this, new_state] { emit EmulationStateChanged(new_state); }); | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2017-09-20 09:29:32 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   Config::AddConfigChangedCallback( | 
					
						
							|  |  |  |       [this] { QueueOnObject(this, [this] { emit ConfigChanged(); }); }); | 
					
						
							| 
									
										
										
										
											2018-05-06 18:25:37 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-05 14:17:07 -07:00
										 |  |  |   g_controller_interface.RegisterDevicesChangedCallback( | 
					
						
							|  |  |  |       [this] { QueueOnObject(this, [this] { emit DevicesChanged(); }); }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-06 18:25:37 +02:00
										 |  |  |   SetCurrentUserStyle(GetCurrentUserStyle()); | 
					
						
							| 
									
										
										
										
											2017-09-04 11:12:13 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-09 00:45:27 -04:00
										 |  |  | Settings::~Settings() = default; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-31 00:17:39 -07:00
										 |  |  | Settings& Settings::Instance() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   static Settings settings; | 
					
						
							|  |  |  |   return settings; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  | QSettings& Settings::GetQSettings() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   static QSettings settings( | 
					
						
							|  |  |  |       QStringLiteral("%1/Qt.ini").arg(QString::fromStdString(File::GetUserPath(D_CONFIG_IDX))), | 
					
						
							|  |  |  |       QSettings::IniFormat); | 
					
						
							|  |  |  |   return settings; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-31 16:15:48 -07:00
										 |  |  | void Settings::SetThemeName(const QString& theme_name) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   SConfig::GetInstance().theme_name = theme_name.toStdString(); | 
					
						
							|  |  |  |   emit ThemeChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-05-06 18:25:37 +02:00
										 |  |  | QString Settings::GetCurrentUserStyle() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return GetQSettings().value(QStringLiteral("userstyle/path"), false).toString(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetCurrentUserStyle(const QString& stylesheet_path) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   QString stylesheet_contents; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   if (!stylesheet_path.isEmpty() && AreUserStylesEnabled()) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     // Load custom user stylesheet
 | 
					
						
							|  |  |  |     QFile stylesheet(stylesheet_path); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     if (stylesheet.open(QFile::ReadOnly)) | 
					
						
							|  |  |  |       stylesheet_contents = QString::fromUtf8(stylesheet.readAll().data()); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   qApp->setStyleSheet(stylesheet_contents); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GetQSettings().setValue(QStringLiteral("userstyle/path"), stylesheet_path); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::AreUserStylesEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return GetQSettings().value(QStringLiteral("userstyle/enabled"), false).toBool(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetUserStylesEnabled(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   GetQSettings().setValue(QStringLiteral("userstyle/enabled"), enabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | QStringList Settings::GetPaths() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   QStringList list; | 
					
						
							|  |  |  |   for (const auto& path : SConfig::GetInstance().m_ISOFolder) | 
					
						
							|  |  |  |     list << QString::fromStdString(path); | 
					
						
							|  |  |  |   return list; | 
					
						
							| 
									
										
										
										
											2017-05-31 00:42:15 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  | void Settings::AddPath(const QString& qpath) | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   std::string path = qpath.toStdString(); | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   std::vector<std::string>& paths = SConfig::GetInstance().m_ISOFolder; | 
					
						
							|  |  |  |   if (std::find(paths.begin(), paths.end(), path) != paths.end()) | 
					
						
							| 
									
										
										
										
											2017-05-31 00:42:15 -07:00
										 |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   paths.emplace_back(path); | 
					
						
							|  |  |  |   emit PathAdded(qpath); | 
					
						
							| 
									
										
										
										
											2017-05-03 21:19:51 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  | void Settings::RemovePath(const QString& qpath) | 
					
						
							| 
									
										
										
										
											2017-05-03 21:19:51 -07:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   std::string path = qpath.toStdString(); | 
					
						
							|  |  |  |   std::vector<std::string>& paths = SConfig::GetInstance().m_ISOFolder; | 
					
						
							| 
									
										
										
										
											2017-05-03 21:19:51 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   auto new_end = std::remove(paths.begin(), paths.end(), path); | 
					
						
							|  |  |  |   if (new_end == paths.end()) | 
					
						
							|  |  |  |     return; | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-22 15:11:53 -07:00
										 |  |  |   paths.erase(new_end, paths.end()); | 
					
						
							|  |  |  |   emit PathRemoved(qpath); | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 20:27:07 +02:00
										 |  |  | void Settings::RefreshGameList() | 
					
						
							| 
									
										
										
										
											2018-04-19 23:07:36 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-06 20:27:07 +02:00
										 |  |  |   emit GameListRefreshRequested(); | 
					
						
							| 
									
										
										
										
											2018-04-19 23:07:36 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-30 03:16:37 +02:00
										 |  |  | void Settings::RefreshMetadata() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit MetadataRefreshRequested(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::NotifyMetadataRefreshComplete() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit MetadataRefreshCompleted(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-04 21:44:46 +02:00
										 |  |  | void Settings::ReloadTitleDB() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit TitleDBReloadRequested(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-06-06 10:52:27 +02:00
										 |  |  | bool Settings::IsAutoRefreshEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return GetQSettings().value(QStringLiteral("gamelist/autorefresh"), true).toBool(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetAutoRefreshEnabled(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsAutoRefreshEnabled() == enabled) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GetQSettings().setValue(QStringLiteral("gamelist/autorefresh"), enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit AutoRefreshToggled(enabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-01-31 19:58:02 +01:00
										 |  |  | QString Settings::GetDefaultGame() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-06 18:29:46 -07:00
										 |  |  |   return QString::fromStdString(Config::Get(Config::MAIN_DEFAULT_ISO)); | 
					
						
							| 
									
										
										
										
											2018-01-31 19:58:02 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetDefaultGame(QString path) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (GetDefaultGame() != path) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-07-06 18:29:46 -07:00
										 |  |  |     Config::SetBase(Config::MAIN_DEFAULT_ISO, path.toStdString()); | 
					
						
							| 
									
										
										
										
											2018-01-31 19:58:02 +01:00
										 |  |  |     emit DefaultGameChanged(path); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-01 02:29:39 -08:00
										 |  |  | bool Settings::GetPreferredView() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("PreferredView"), true).toBool(); | 
					
						
							| 
									
										
										
										
											2016-01-01 02:29:39 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-08-05 10:28:53 +02:00
										 |  |  | void Settings::SetPreferredView(bool list) | 
					
						
							| 
									
										
										
										
											2016-01-01 02:29:39 -08:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   GetQSettings().setValue(QStringLiteral("PreferredView"), list); | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-02-15 12:56:40 +11:00
										 |  |  | int Settings::GetStateSlot() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("Emulation/StateSlot"), 1).toInt(); | 
					
						
							| 
									
										
										
										
											2016-02-15 12:56:40 +11:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetStateSlot(int slot) | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   GetQSettings().setValue(QStringLiteral("Emulation/StateSlot"), slot); | 
					
						
							| 
									
										
										
										
											2015-12-20 15:36:39 -08:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-05-08 19:03:59 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-31 23:49:06 -07:00
										 |  |  | void Settings::SetHideCursor(bool hide_cursor) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   SConfig::GetInstance().bHideCursor = hide_cursor; | 
					
						
							|  |  |  |   emit HideCursorChanged(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::GetHideCursor() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().bHideCursor; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-22 10:56:15 +02:00
										 |  |  | void Settings::SetKeepWindowOnTop(bool top) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsKeepWindowOnTopEnabled() == top) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   SConfig::GetInstance().bKeepWindowOnTop = top; | 
					
						
							|  |  |  |   emit KeepWindowOnTopChanged(top); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsKeepWindowOnTopEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().bKeepWindowOnTop; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-06-21 10:26:06 +02:00
										 |  |  | int Settings::GetVolume() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().m_Volume; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetVolume(int volume) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (GetVolume() != volume) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     SConfig::GetInstance().m_Volume = volume; | 
					
						
							|  |  |  |     emit VolumeChanged(volume); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::IncreaseVolume(int volume) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AudioCommon::IncreaseVolume(volume); | 
					
						
							|  |  |  |   emit VolumeChanged(GetVolume()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::DecreaseVolume(int volume) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   AudioCommon::DecreaseVolume(volume); | 
					
						
							|  |  |  |   emit VolumeChanged(GetVolume()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-07-04 15:21:33 +02:00
										 |  |  | bool Settings::IsLogVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("logging/logvisible")).toBool(); | 
					
						
							| 
									
										
										
										
											2017-07-04 15:21:33 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetLogVisible(bool visible) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsLogVisible() != visible) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("logging/logvisible"), visible); | 
					
						
							| 
									
										
										
										
											2017-07-04 15:21:33 +02:00
										 |  |  |     emit LogVisibilityChanged(visible); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsLogConfigVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("logging/logconfigvisible")).toBool(); | 
					
						
							| 
									
										
										
										
											2017-07-04 15:21:33 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetLogConfigVisible(bool visible) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsLogConfigVisible() != visible) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("logging/logconfigvisible"), visible); | 
					
						
							| 
									
										
										
										
											2017-07-04 15:21:33 +02:00
										 |  |  |     emit LogConfigVisibilityChanged(visible); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | GameListModel* Settings::GetGameListModel() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   static GameListModel* model = new GameListModel; | 
					
						
							|  |  |  |   return model; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-12 20:37:12 -04:00
										 |  |  | std::shared_ptr<NetPlay::NetPlayClient> Settings::GetNetPlayClient() | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-12 20:37:12 -04:00
										 |  |  |   return m_client; | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 19:39:42 -04:00
										 |  |  | void Settings::ResetNetPlayClient(NetPlay::NetPlayClient* client) | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   m_client.reset(client); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-12 20:37:12 -04:00
										 |  |  | std::shared_ptr<NetPlay::NetPlayServer> Settings::GetNetPlayServer() | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | { | 
					
						
							| 
									
										
										
										
											2018-07-12 20:37:12 -04:00
										 |  |  |   return m_server; | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-07-06 19:39:42 -04:00
										 |  |  | void Settings::ResetNetPlayServer(NetPlay::NetPlayServer* server) | 
					
						
							| 
									
										
										
										
											2017-08-01 12:55:21 +02:00
										 |  |  | { | 
					
						
							|  |  |  |   m_server.reset(server); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-08-30 21:00:59 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool Settings::GetCheatsEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().bEnableCheats; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetCheatsEnabled(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (SConfig::GetInstance().bEnableCheats != enabled) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     SConfig::GetInstance().bEnableCheats = enabled; | 
					
						
							|  |  |  |     emit EnableCheatsChanged(enabled); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-09-19 14:14:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetDebugModeEnabled(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsDebugModeEnabled() != enabled) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     SConfig::GetInstance().bEnableDebugging = enabled; | 
					
						
							|  |  |  |     emit DebugModeToggled(enabled); | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2018-03-24 17:50:47 +01:00
										 |  |  |   if (enabled) | 
					
						
							|  |  |  |     SetCodeVisible(true); | 
					
						
							| 
									
										
										
										
											2017-09-19 14:14:45 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsDebugModeEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().bEnableDebugging; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2017-09-13 19:33:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetRegistersVisible(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsRegistersVisible() != enabled) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("debugger/showregisters"), enabled); | 
					
						
							| 
									
										
										
										
											2017-09-13 19:33:45 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit RegistersVisibilityChanged(enabled); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsRegistersVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("debugger/showregisters")).toBool(); | 
					
						
							| 
									
										
										
										
											2017-09-13 19:33:45 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-09-27 08:53:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetWatchVisible(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsWatchVisible() != enabled) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("debugger/showwatch"), enabled); | 
					
						
							| 
									
										
										
										
											2017-09-27 08:53:05 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit WatchVisibilityChanged(enabled); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsWatchVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("debugger/showwatch")).toBool(); | 
					
						
							| 
									
										
										
										
											2017-09-27 08:53:05 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2017-10-03 18:43:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetBreakpointsVisible(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsBreakpointsVisible() != enabled) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("debugger/showbreakpoints"), enabled); | 
					
						
							| 
									
										
										
										
											2017-10-03 18:43:44 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit BreakpointsVisibilityChanged(enabled); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsBreakpointsVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("debugger/showbreakpoints")).toBool(); | 
					
						
							| 
									
										
										
										
											2017-10-03 18:43:44 +02:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-06 23:12:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsControllerStateNeeded() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return m_controller_state_needed; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetControllerStateNeeded(bool needed) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_controller_state_needed = needed; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-02-14 23:25:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetCodeVisible(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsCodeVisible() != enabled) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("debugger/showcode"), enabled); | 
					
						
							| 
									
										
										
										
											2018-02-14 23:25:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit CodeVisibilityChanged(enabled); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsCodeVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("debugger/showcode")).toBool(); | 
					
						
							| 
									
										
										
										
											2018-02-14 23:25:01 +01:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-16 12:39:53 +01:00
										 |  |  | void Settings::SetMemoryVisible(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsMemoryVisible() == enabled) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   QSettings().setValue(QStringLiteral("debugger/showmemory"), enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit MemoryVisibilityChanged(enabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsMemoryVisible() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return QSettings().value(QStringLiteral("debugger/showmemory")).toBool(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-04-09 15:31:20 +02:00
										 |  |  | void Settings::SetJITVisible(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsJITVisible() == enabled) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  |   QSettings().setValue(QStringLiteral("debugger/showjit"), enabled); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit JITVisibilityChanged(enabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsJITVisible() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return QSettings().value(QStringLiteral("debugger/showjit")).toBool(); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-08-20 00:39:57 +02:00
										 |  |  | void Settings::RefreshWidgetVisibility() | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   emit DebugModeToggled(IsDebugModeEnabled()); | 
					
						
							|  |  |  |   emit LogVisibilityChanged(IsLogVisible()); | 
					
						
							|  |  |  |   emit LogConfigVisibilityChanged(IsLogConfigVisible()); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-02-14 23:25:01 +01:00
										 |  |  | void Settings::SetDebugFont(QFont font) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (GetDebugFont() != font) | 
					
						
							|  |  |  |   { | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |     GetQSettings().setValue(QStringLiteral("debugger/font"), font); | 
					
						
							| 
									
										
										
										
											2018-02-14 23:25:01 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |     emit DebugFontChanged(font); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QFont Settings::GetDebugFont() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   QFont default_font = QFont(QStringLiteral("Monospace")); | 
					
						
							|  |  |  |   default_font.setStyleHint(QFont::TypeWriter); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2018-03-23 12:10:53 +01:00
										 |  |  |   return GetQSettings().value(QStringLiteral("debugger/font"), default_font).value<QFont>(); | 
					
						
							| 
									
										
										
										
											2018-02-14 23:25:01 +01:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-22 12:20:15 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetAutoUpdateTrack(const QString& mode) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (mode == GetAutoUpdateTrack()) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   SConfig::GetInstance().m_auto_update_track = mode.toStdString(); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit AutoUpdateTrackChanged(mode); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | QString Settings::GetAutoUpdateTrack() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return QString::fromStdString(SConfig::GetInstance().m_auto_update_track); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-03-23 23:25:17 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetAnalyticsEnabled(bool enabled) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (enabled == IsAnalyticsEnabled()) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   SConfig::GetInstance().m_analytics_enabled = enabled; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit AnalyticsToggled(enabled); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsAnalyticsEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().m_analytics_enabled; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-19 11:32:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetToolBarVisible(bool visible) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsToolBarVisible() == visible) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GetQSettings().setValue(QStringLiteral("toolbar/visible"), visible); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit ToolBarVisibilityChanged(visible); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsToolBarVisible() const | 
					
						
							|  |  |  | { | 
					
						
							| 
									
										
										
										
											2018-04-28 21:27:29 +02:00
										 |  |  |   return GetQSettings().value(QStringLiteral("toolbar/visible"), true).toBool(); | 
					
						
							| 
									
										
										
										
											2018-04-19 11:32:00 +02:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetWidgetsLocked(bool locked) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (AreWidgetsLocked() == locked) | 
					
						
							|  |  |  |     return; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   GetQSettings().setValue(QStringLiteral("widgets/locked"), locked); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   emit WidgetLockChanged(locked); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | bool Settings::AreWidgetsLocked() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return GetQSettings().value(QStringLiteral("widgets/locked"), true).toBool(); | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-04-29 19:13:40 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsBatchModeEnabled() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return m_batch; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | void Settings::SetBatchModeEnabled(bool batch) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   m_batch = batch; | 
					
						
							|  |  |  | } | 
					
						
							| 
									
										
										
										
											2018-08-02 12:55:30 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | bool Settings::IsUSBKeyboardConnected() const | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   return SConfig::GetInstance().m_WiiKeyboard; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | void Settings::SetUSBKeyboardConnected(bool connected) | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   if (IsUSBKeyboardConnected() != connected) | 
					
						
							|  |  |  |   { | 
					
						
							|  |  |  |     SConfig::GetInstance().m_WiiKeyboard = connected; | 
					
						
							|  |  |  |     emit USBKeyboardConnectionChanged(connected); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } |