mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-23 10:35:03 +00:00
added theme
This commit is contained in:
parent
23446ff286
commit
bd150558c9
@ -81,7 +81,6 @@ static std::vector<GameInstallDir> settings_install_dirs = {};
|
||||
std::vector<bool> install_dirs_enabled = {};
|
||||
std::filesystem::path settings_addon_install_dir = {};
|
||||
std::filesystem::path save_data_path = {};
|
||||
u32 mw_themes = 0;
|
||||
static bool isFullscreen = false;
|
||||
static std::string fullscreenMode = "Windowed";
|
||||
static bool isHDRAllowed = false;
|
||||
@ -481,10 +480,6 @@ void setAddonInstallDir(const std::filesystem::path& dir) {
|
||||
settings_addon_install_dir = dir;
|
||||
}
|
||||
|
||||
void setMainWindowTheme(u32 theme) {
|
||||
mw_themes = theme;
|
||||
}
|
||||
|
||||
void setGameInstallDirs(const std::vector<std::filesystem::path>& dirs_config) {
|
||||
settings_install_dirs.clear();
|
||||
for (const auto& dir : dirs_config) {
|
||||
@ -526,10 +521,6 @@ std::filesystem::path getAddonInstallDir() {
|
||||
return settings_addon_install_dir;
|
||||
}
|
||||
|
||||
u32 getMainWindowTheme() {
|
||||
return mw_themes;
|
||||
}
|
||||
|
||||
u32 GetLanguage() {
|
||||
return m_language;
|
||||
}
|
||||
@ -639,7 +630,6 @@ void load(const std::filesystem::path& path) {
|
||||
const toml::value& gui = data.at("GUI");
|
||||
|
||||
load_game_size = toml::find_or<bool>(gui, "loadGameSizeEnabled", true);
|
||||
mw_themes = toml::find_or<int>(gui, "theme", 0);
|
||||
|
||||
const auto install_dir_array =
|
||||
toml::find_or<std::vector<std::u8string>>(gui, "installDirs", {});
|
||||
@ -818,40 +808,6 @@ void save(const std::filesystem::path& path) {
|
||||
std::ofstream file(path, std::ios::binary);
|
||||
file << data;
|
||||
file.close();
|
||||
|
||||
saveMainWindow(path);
|
||||
}
|
||||
|
||||
void saveMainWindow(const std::filesystem::path& path) {
|
||||
toml::ordered_value data;
|
||||
|
||||
std::error_code error;
|
||||
if (std::filesystem::exists(path, error)) {
|
||||
try {
|
||||
std::ifstream ifs;
|
||||
ifs.exceptions(std::ifstream::failbit | std::ifstream::badbit);
|
||||
ifs.open(path, std::ios_base::binary);
|
||||
data = toml::parse<toml::ordered_type_config>(
|
||||
ifs, std::string{fmt::UTF(path.filename().u8string()).data});
|
||||
} catch (const std::exception& ex) {
|
||||
fmt::print("Exception trying to parse config file. Exception: {}\n", ex.what());
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if (error) {
|
||||
fmt::print("Filesystem error: {}\n", error.message());
|
||||
}
|
||||
fmt::print("Saving new configuration file {}\n", fmt::UTF(path.u8string()));
|
||||
}
|
||||
|
||||
data["GUI"]["theme"] = mw_themes;
|
||||
|
||||
// Sorting of TOML sections
|
||||
sortTomlSections(data);
|
||||
|
||||
std::ofstream file(path, std::ios::binary);
|
||||
file << data;
|
||||
file.close();
|
||||
}
|
||||
|
||||
void setDefaultValues() {
|
||||
|
@ -18,7 +18,6 @@ enum HideCursorState : int { Never, Idle, Always };
|
||||
|
||||
void load(const std::filesystem::path& path);
|
||||
void save(const std::filesystem::path& path);
|
||||
void saveMainWindow(const std::filesystem::path& path);
|
||||
|
||||
std::string getTrophyKey();
|
||||
void setTrophyKey(std::string key);
|
||||
@ -123,13 +122,10 @@ bool addGameInstallDir(const std::filesystem::path& dir, bool enabled = true);
|
||||
void removeGameInstallDir(const std::filesystem::path& dir);
|
||||
void setGameInstallDirEnabled(const std::filesystem::path& dir, bool enabled);
|
||||
void setAddonInstallDir(const std::filesystem::path& dir);
|
||||
void setMainWindowTheme(u32 theme);
|
||||
void setElfViewer(const std::vector<std::string>& elfList);
|
||||
|
||||
const std::vector<std::filesystem::path> getGameInstallDirs();
|
||||
const std::vector<bool> getGameInstallDirsEnabled();
|
||||
std::filesystem::path getAddonInstallDir();
|
||||
u32 getMainWindowTheme();
|
||||
|
||||
void setDefaultValues();
|
||||
|
||||
|
@ -58,10 +58,7 @@ Emulator::Emulator() {
|
||||
#endif
|
||||
}
|
||||
|
||||
Emulator::~Emulator() {
|
||||
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
Config::saveMainWindow(config_dir / "config.toml");
|
||||
}
|
||||
Emulator::~Emulator() {}
|
||||
|
||||
void Emulator::Run(std::filesystem::path file, const std::vector<std::string> args) {
|
||||
if (std::filesystem::is_directory(file)) {
|
||||
|
@ -12,7 +12,8 @@
|
||||
#include "main_window_themes.h"
|
||||
#include "ui_about_dialog.h"
|
||||
|
||||
AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog) {
|
||||
AboutDialog::AboutDialog(std::shared_ptr<gui_settings> gui_settings, QWidget* parent)
|
||||
: QDialog(parent), ui(new Ui::AboutDialog), m_gui_settings(std::move(gui_settings)) {
|
||||
ui->setupUi(this);
|
||||
preloadImages();
|
||||
|
||||
@ -57,7 +58,7 @@ void AboutDialog::preloadImages() {
|
||||
}
|
||||
|
||||
void AboutDialog::updateImagesForCurrentTheme() {
|
||||
Theme currentTheme = static_cast<Theme>(Config::getMainWindowTheme());
|
||||
Theme currentTheme = static_cast<Theme>(m_gui_settings->GetValue(gui::gen_theme).toInt());
|
||||
bool isDarkTheme = (currentTheme == Theme::Dark || currentTheme == Theme::Green ||
|
||||
currentTheme == Theme::Blue || currentTheme == Theme::Violet);
|
||||
if (isDarkTheme) {
|
||||
@ -188,7 +189,7 @@ void AboutDialog::removeHoverEffect(QLabel* label) {
|
||||
}
|
||||
|
||||
bool AboutDialog::isDarkTheme() const {
|
||||
Theme currentTheme = static_cast<Theme>(Config::getMainWindowTheme());
|
||||
Theme currentTheme = static_cast<Theme>(m_gui_settings->GetValue(gui::gen_theme).toInt());
|
||||
return currentTheme == Theme::Dark || currentTheme == Theme::Green ||
|
||||
currentTheme == Theme::Blue || currentTheme == Theme::Violet;
|
||||
}
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <QLabel>
|
||||
#include <QPixmap>
|
||||
#include <QUrl>
|
||||
#include "gui_settings.h"
|
||||
|
||||
namespace Ui {
|
||||
class AboutDialog;
|
||||
@ -17,7 +18,7 @@ class AboutDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit AboutDialog(QWidget* parent = nullptr);
|
||||
explicit AboutDialog(std::shared_ptr<gui_settings> gui_settings, QWidget* parent = nullptr);
|
||||
~AboutDialog();
|
||||
bool eventFilter(QObject* obj, QEvent* event);
|
||||
|
||||
@ -33,4 +34,5 @@ private:
|
||||
|
||||
QPixmap originalImages[5];
|
||||
QPixmap invertedImages[5];
|
||||
std::shared_ptr<gui_settings> m_gui_settings;
|
||||
};
|
||||
|
@ -22,6 +22,7 @@ const gui_value gen_recentFiles =
|
||||
const gui_value gen_guiLanguage = gui_value(general_settings, "guiLanguage", "en_US");
|
||||
const gui_value gen_elfDirs =
|
||||
gui_value(main_window, "elfDirs", QVariant::fromValue(QList<QString>()));
|
||||
const gui_value gen_theme = gui_value(general_settings, "theme", 0);
|
||||
|
||||
// main window settings
|
||||
const gui_value mw_geometry = gui_value(main_window, "geometry", QByteArray());
|
||||
|
@ -39,8 +39,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
|
||||
MainWindow::~MainWindow() {
|
||||
SaveWindowState();
|
||||
const auto config_dir = Common::FS::GetUserPath(Common::FS::PathType::UserDir);
|
||||
Config::saveMainWindow(config_dir / "config.toml");
|
||||
}
|
||||
|
||||
bool MainWindow::Init() {
|
||||
@ -492,7 +490,7 @@ void MainWindow::CreateConnects() {
|
||||
#endif
|
||||
|
||||
connect(ui->aboutAct, &QAction::triggered, this, [this]() {
|
||||
auto aboutDialog = new AboutDialog(this);
|
||||
auto aboutDialog = new AboutDialog(m_gui_settings, this);
|
||||
aboutDialog->exec();
|
||||
});
|
||||
|
||||
@ -778,7 +776,7 @@ void MainWindow::CreateConnects() {
|
||||
// Themes
|
||||
connect(ui->setThemeDark, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Dark, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Dark));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Dark));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -786,7 +784,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeLight, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Light, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Light));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Light));
|
||||
if (!isIconBlack) {
|
||||
SetUiIcons(true);
|
||||
isIconBlack = true;
|
||||
@ -794,7 +792,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeGreen, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Green, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Green));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Green));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -802,7 +800,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeBlue, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Blue, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Blue));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Blue));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -810,7 +808,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeViolet, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Violet, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Violet));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Violet));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -818,7 +816,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeGruvbox, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Gruvbox, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Gruvbox));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Gruvbox));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -826,7 +824,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeTokyoNight, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::TokyoNight, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::TokyoNight));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::TokyoNight));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -834,7 +832,7 @@ void MainWindow::CreateConnects() {
|
||||
});
|
||||
connect(ui->setThemeOled, &QAction::triggered, &m_window_themes, [this]() {
|
||||
m_window_themes.SetWindowTheme(Theme::Oled, ui->mw_searchbar);
|
||||
Config::setMainWindowTheme(static_cast<int>(Theme::Oled));
|
||||
m_gui_settings->SetValue(gui::gen_theme, static_cast<int>(Theme::Oled));
|
||||
if (isIconBlack) {
|
||||
SetUiIcons(false);
|
||||
isIconBlack = false;
|
||||
@ -981,7 +979,7 @@ void MainWindow::InstallDirectory() {
|
||||
}
|
||||
|
||||
void MainWindow::SetLastUsedTheme() {
|
||||
Theme lastTheme = static_cast<Theme>(Config::getMainWindowTheme());
|
||||
Theme lastTheme = static_cast<Theme>(m_gui_settings->GetValue(gui::gen_theme).toInt());
|
||||
m_window_themes.SetWindowTheme(lastTheme, ui->mw_searchbar);
|
||||
|
||||
switch (lastTheme) {
|
||||
|
@ -465,7 +465,7 @@ void TrophyViewer::SetTableItem(QTableWidget* parent, int row, int column, QStri
|
||||
item->setTextAlignment(Qt::AlignCenter);
|
||||
item->setFont(QFont("Arial", 12, QFont::Bold));
|
||||
|
||||
Theme theme = static_cast<Theme>(Config::getMainWindowTheme());
|
||||
Theme theme = static_cast<Theme>(m_gui_settings->GetValue(gui::gen_theme).toInt());
|
||||
|
||||
if (theme == Theme::Light) {
|
||||
item->setForeground(QBrush(Qt::black));
|
||||
|
Loading…
Reference in New Issue
Block a user