mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-09 23:59:27 +01:00
Use a separate INI file for UI settings.
This commit is contained in:
parent
2842897d55
commit
3a4a60f937
@ -10,6 +10,7 @@ set(SRCS
|
||||
MenuBar.cpp
|
||||
RenderWidget.cpp
|
||||
Resources.cpp
|
||||
Settings.cpp
|
||||
ToolBar.cpp
|
||||
GameList/GameFile.cpp
|
||||
GameList/GameList.cpp
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DiscIO/VolumeCreator.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameFile.h"
|
||||
|
||||
static const int CACHE_VERSION = 13; // Last changed in PR #3261
|
||||
@ -50,12 +51,6 @@ GameFile::GameFile(QString path) : m_path(path)
|
||||
m_valid = true;
|
||||
}
|
||||
|
||||
DiscIO::IVolume::ELanguage GameFile::GetDefaultLanguage() const
|
||||
{
|
||||
bool wii = m_platform != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
return SConfig::GetInstance().GetCurrentLanguage(wii);
|
||||
}
|
||||
|
||||
QString GameFile::GetCacheFileName() const
|
||||
{
|
||||
QString folder = QString::fromStdString(File::GetUserPath(D_CACHE_IDX));
|
||||
@ -194,7 +189,14 @@ QString GameFile::GetLanguageString(QMap<DiscIO::IVolume::ELanguage, QString> m)
|
||||
// Try the settings language, then English, then just pick one.
|
||||
if (m.isEmpty())
|
||||
return QString();
|
||||
DiscIO::IVolume::ELanguage current_lang = GetDefaultLanguage();
|
||||
|
||||
bool wii = m_platform != DiscIO::IVolume::GAMECUBE_DISC;
|
||||
DiscIO::IVolume::ELanguage current_lang;
|
||||
if (wii)
|
||||
current_lang = Settings().GetWiiSystemLanguage();
|
||||
else
|
||||
current_lang = Settings().GetGCSystemLanguage();
|
||||
|
||||
if (m.contains(current_lang))
|
||||
return m[current_lang];
|
||||
if (m.contains(DiscIO::IVolume::LANGUAGE_ENGLISH))
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include <QHeaderView>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt2/GameList/GameList.h"
|
||||
#include "DolphinQt2/GameList/ListProxyModel.h"
|
||||
#include "DolphinQt2/GameList/TableProxyModel.h"
|
||||
|
@ -6,9 +6,20 @@
|
||||
#include <QDirIterator>
|
||||
#include <QFile>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameTracker.h"
|
||||
|
||||
static const QStringList game_filters{
|
||||
QStringLiteral("*.gcm"),
|
||||
QStringLiteral("*.iso"),
|
||||
QStringLiteral("*.ciso"),
|
||||
QStringLiteral("*.gcz"),
|
||||
QStringLiteral("*.wbfs"),
|
||||
QStringLiteral("*.wad"),
|
||||
QStringLiteral("*.elf"),
|
||||
QStringLiteral("*.dol")
|
||||
};
|
||||
|
||||
GameTracker::GameTracker(QObject* parent)
|
||||
: QFileSystemWatcher(parent)
|
||||
{
|
||||
@ -22,12 +33,10 @@ GameTracker::GameTracker(QObject* parent)
|
||||
connect(this, &GameTracker::PathChanged, m_loader, &GameLoader::LoadGame);
|
||||
connect(m_loader, &GameLoader::GameLoaded, this, &GameTracker::GameLoaded);
|
||||
|
||||
GenerateFilters();
|
||||
|
||||
m_loader_thread.start();
|
||||
|
||||
for (const std::string& dir : SConfig::GetInstance().m_ISOFolder)
|
||||
AddDirectory(QString::fromStdString(dir));
|
||||
for (QString dir : Settings().GetPaths())
|
||||
AddDirectory(dir);
|
||||
}
|
||||
|
||||
GameTracker::~GameTracker()
|
||||
@ -44,7 +53,7 @@ void GameTracker::AddDirectory(QString dir)
|
||||
|
||||
void GameTracker::UpdateDirectory(QString dir)
|
||||
{
|
||||
QDirIterator it(dir, m_filters);
|
||||
QDirIterator it(dir, game_filters);
|
||||
while (it.hasNext())
|
||||
{
|
||||
QString path = QFileInfo(it.next()).canonicalFilePath();
|
||||
@ -69,16 +78,3 @@ void GameTracker::UpdateFile(QString file)
|
||||
emit GameRemoved(file);
|
||||
}
|
||||
}
|
||||
|
||||
void GameTracker::GenerateFilters()
|
||||
{
|
||||
m_filters.clear();
|
||||
if (SConfig::GetInstance().m_ListGC)
|
||||
m_filters << tr("*.gcm");
|
||||
if (SConfig::GetInstance().m_ListWii || SConfig::GetInstance().m_ListGC)
|
||||
m_filters << tr("*.iso") << tr("*.ciso") << tr("*.gcz") << tr("*.wbfs");
|
||||
if (SConfig::GetInstance().m_ListWad)
|
||||
m_filters << tr("*.wad");
|
||||
if (SConfig::GetInstance().m_ListElfDol)
|
||||
m_filters << tr("*.elf") << tr("*.dol");
|
||||
}
|
||||
|
@ -39,10 +39,8 @@ signals:
|
||||
private:
|
||||
void UpdateDirectory(QString dir);
|
||||
void UpdateFile(QString path);
|
||||
void GenerateFilters();
|
||||
|
||||
QSet<QString> m_tracked_files;
|
||||
QStringList m_filters;
|
||||
QThread m_loader_thread;
|
||||
GameLoader* m_loader;
|
||||
};
|
||||
|
@ -11,13 +11,12 @@
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/BootManager.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/Core.h"
|
||||
#include "DolphinQt2/Host.h"
|
||||
#include "DolphinQt2/MainWindow.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/GameList/GameListModel.h"
|
||||
|
||||
MainWindow::MainWindow() : QMainWindow(nullptr)
|
||||
@ -107,12 +106,12 @@ void MainWindow::Browse()
|
||||
QDir::currentPath());
|
||||
if (!dir.isEmpty())
|
||||
{
|
||||
std::vector<std::string>& iso_folders = SConfig::GetInstance().m_ISOFolder;
|
||||
auto found = std::find(iso_folders.begin(), iso_folders.end(), dir.toStdString());
|
||||
if (found == iso_folders.end())
|
||||
Settings settings;
|
||||
QStringList iso_folders = settings.GetPaths();
|
||||
if (!iso_folders.contains(dir))
|
||||
{
|
||||
iso_folders.push_back(dir.toStdString());
|
||||
SConfig::GetInstance().SaveSettings();
|
||||
iso_folders << dir;
|
||||
settings.SetPaths(iso_folders);
|
||||
emit m_game_list->DirectoryAdded(dir);
|
||||
}
|
||||
}
|
||||
@ -138,8 +137,8 @@ void MainWindow::Play()
|
||||
}
|
||||
else
|
||||
{
|
||||
QString path = QString::fromStdString(SConfig::GetInstance().m_LastFilename);
|
||||
if (QFile::exists(path))
|
||||
QString path = Settings().GetLastGame();
|
||||
if (!path.isEmpty() && QFile::exists(path))
|
||||
StartGame(path);
|
||||
else
|
||||
Open();
|
||||
@ -156,7 +155,7 @@ void MainWindow::Pause()
|
||||
bool MainWindow::Stop()
|
||||
{
|
||||
bool stop = true;
|
||||
if (SConfig::GetInstance().bConfirmStop)
|
||||
if (Settings().GetConfirmStop())
|
||||
{
|
||||
// We could pause the game here and resume it if they say no.
|
||||
QMessageBox::StandardButton confirm;
|
||||
@ -180,7 +179,7 @@ void MainWindow::ForceStop()
|
||||
void MainWindow::FullScreen()
|
||||
{
|
||||
// If the render widget is fullscreen we want to reset it to whatever is in
|
||||
// SConfig. If it's set to be fullscreen then it just remakes the window,
|
||||
// settings. If it's set to be fullscreen then it just remakes the window,
|
||||
// which probably isn't ideal.
|
||||
bool was_fullscreen = m_render_widget->isFullScreen();
|
||||
HideRenderWidget();
|
||||
@ -209,13 +208,15 @@ void MainWindow::StartGame(QString path)
|
||||
QMessageBox::critical(this, tr("Error"), tr("Failed to init core"), QMessageBox::Ok);
|
||||
return;
|
||||
}
|
||||
Settings().SetLastGame(path);
|
||||
ShowRenderWidget();
|
||||
emit EmulationStarted();
|
||||
}
|
||||
|
||||
void MainWindow::ShowRenderWidget()
|
||||
{
|
||||
if (SConfig::GetInstance().bRenderToMain)
|
||||
Settings settings;
|
||||
if (settings.GetRenderToMain())
|
||||
{
|
||||
// If we're rendering to main, add it to the stack and update our title when necessary.
|
||||
m_rendering_to_main = true;
|
||||
@ -226,15 +227,13 @@ void MainWindow::ShowRenderWidget()
|
||||
{
|
||||
// Otherwise, just show it.
|
||||
m_rendering_to_main = false;
|
||||
if (SConfig::GetInstance().bFullscreen)
|
||||
if (settings.GetFullScreen())
|
||||
{
|
||||
m_render_widget->showFullScreen();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_render_widget->setFixedSize(
|
||||
SConfig::GetInstance().iRenderWindowWidth,
|
||||
SConfig::GetInstance().iRenderWindowHeight);
|
||||
m_render_widget->setFixedSize(settings.GetRenderWindowSize());
|
||||
m_render_widget->showNormal();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <QAction>
|
||||
#include <QActionGroup>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt2/MenuBar.h"
|
||||
|
||||
MenuBar::MenuBar(QWidget* parent)
|
||||
@ -54,7 +53,7 @@ void MenuBar::AddGameListTypeSection(QMenu* view_menu)
|
||||
connect(list_view, &QAction::triggered, this, &MenuBar::ShowList);
|
||||
}
|
||||
|
||||
// TODO implement this after we stop using SConfig.
|
||||
// TODO implement this
|
||||
void MenuBar::AddTableColumnsMenu(QMenu* view_menu)
|
||||
{
|
||||
QActionGroup* column_group = new QActionGroup(this);
|
||||
|
@ -6,7 +6,6 @@
|
||||
|
||||
#include "Common/CommonPaths.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt2/Resources.h"
|
||||
|
||||
QList<QPixmap> Resources::m_platforms;
|
||||
|
75
Source/Core/DolphinQt2/Settings.cpp
Normal file
75
Source/Core/DolphinQt2/Settings.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <QSize>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
|
||||
static QString GetSettingsPath()
|
||||
{
|
||||
return QString::fromStdString(File::GetUserPath(D_CONFIG_IDX)) + QStringLiteral("/UI.ini");
|
||||
}
|
||||
|
||||
Settings::Settings(QObject* parent)
|
||||
: QSettings(GetSettingsPath(), QSettings::IniFormat, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QString Settings::GetThemeDir() const
|
||||
{
|
||||
QString theme_name = value(QStringLiteral("Theme"), QStringLiteral("Clean")).toString();
|
||||
return QString::fromStdString(File::GetThemeDir(theme_name.toStdString()));
|
||||
}
|
||||
|
||||
QString Settings::GetLastGame() const
|
||||
{
|
||||
return value(QStringLiteral("GameList/LastGame")).toString();
|
||||
}
|
||||
|
||||
void Settings::SetLastGame(QString path)
|
||||
{
|
||||
setValue(QStringLiteral("GameList/LastGame"), path);
|
||||
}
|
||||
|
||||
QStringList Settings::GetPaths() const
|
||||
{
|
||||
return value(QStringLiteral("GameList/Paths")).toStringList();
|
||||
}
|
||||
|
||||
void Settings::SetPaths(QStringList paths)
|
||||
{
|
||||
setValue(QStringLiteral("GameList/Paths"), paths);
|
||||
}
|
||||
|
||||
DiscIO::IVolume::ELanguage Settings::GetWiiSystemLanguage() const
|
||||
{
|
||||
return SConfig::GetInstance().GetCurrentLanguage(true);
|
||||
}
|
||||
|
||||
DiscIO::IVolume::ELanguage Settings::GetGCSystemLanguage() const
|
||||
{
|
||||
return SConfig::GetInstance().GetCurrentLanguage(false);
|
||||
}
|
||||
|
||||
bool Settings::GetConfirmStop() const
|
||||
{
|
||||
return value(QStringLiteral("Emulation/ConfirmStop"), true).toBool();
|
||||
}
|
||||
|
||||
bool Settings::GetRenderToMain() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/RenderToMain"), false).toBool();
|
||||
}
|
||||
|
||||
bool Settings::GetFullScreen() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/FullScreen"), false).toBool();
|
||||
}
|
||||
|
||||
QSize Settings::GetRenderWindowSize() const
|
||||
{
|
||||
return value(QStringLiteral("Graphics/RenderWindowSize"), QSize(640, 480)).toSize();
|
||||
}
|
36
Source/Core/DolphinQt2/Settings.h
Normal file
36
Source/Core/DolphinQt2/Settings.h
Normal file
@ -0,0 +1,36 @@
|
||||
// Copyright 2015 Dolphin Emulator Project
|
||||
// Licensed under GPLv2+
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QSettings>
|
||||
|
||||
#include "DiscIO/Volume.h"
|
||||
|
||||
class Settings final : public QSettings
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Settings(QObject* parent = nullptr);
|
||||
|
||||
// UI
|
||||
QString GetThemeDir() const;
|
||||
|
||||
// GameList
|
||||
QString GetLastGame() const;
|
||||
void SetLastGame(QString path);
|
||||
QStringList GetPaths() const;
|
||||
void SetPaths(QStringList paths);
|
||||
DiscIO::IVolume::ELanguage GetWiiSystemLanguage() const;
|
||||
DiscIO::IVolume::ELanguage GetGCSystemLanguage() const;
|
||||
|
||||
// Emulation
|
||||
bool GetConfirmStop() const;
|
||||
|
||||
// Graphics
|
||||
bool GetRenderToMain() const;
|
||||
bool GetFullScreen() const;
|
||||
QSize GetRenderWindowSize() const;
|
||||
};
|
@ -4,8 +4,7 @@
|
||||
|
||||
#include <QIcon>
|
||||
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "DolphinQt2/Settings.h"
|
||||
#include "DolphinQt2/ToolBar.h"
|
||||
|
||||
static constexpr QSize ICON_SIZE(32, 32);
|
||||
@ -82,7 +81,7 @@ void ToolBar::MakeActions()
|
||||
|
||||
void ToolBar::UpdateIcons()
|
||||
{
|
||||
QString dir = QString::fromStdString(File::GetThemeDir(SConfig::GetInstance().theme_name));
|
||||
QString dir = Settings().GetThemeDir();
|
||||
|
||||
m_open_action->setIcon(QIcon(QStringLiteral("open.png").prepend(dir)));
|
||||
m_paths_action->setIcon(QIcon(QStringLiteral("browse.png").prepend(dir)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user