mirror of
https://github.com/wheremyfoodat/Panda3DS.git
synced 2025-04-06 06:05:40 +12:00
* Qt: Add config window controls * Fix Windows build * Fix audio slider * Qt configs: Make thread-safe, properly update audio enable & renderdoc settings * Qt configs: Add `connectCheckbox` function * Qt configs: Add `connectCheckbox` function * Rename spuLayout * Add Discord RPC reloading * Allow configuring the app icon * Qt: Serialize icon & theme, properly set them * Add rnap and rcow icons * Qt: Fix forceShadergen config --------- Co-authored-by: wheremyfoodat <44909372+wheremyfoodat@users.noreply.github.com>
64 lines
No EOL
1.9 KiB
C++
64 lines
No EOL
1.9 KiB
C++
#include "frontend_settings.hpp"
|
|
|
|
#include <algorithm>
|
|
#include <cctype>
|
|
#include <unordered_map>
|
|
|
|
// Frontend setting serialization/deserialization functions
|
|
|
|
FrontendSettings::Theme FrontendSettings::themeFromString(std::string inString) {
|
|
// Transform to lower-case to make the setting case-insensitive
|
|
std::transform(inString.begin(), inString.end(), inString.begin(), [](unsigned char c) { return std::tolower(c); });
|
|
|
|
static const std::unordered_map<std::string, Theme> map = {
|
|
{"system", Theme::System}, {"light", Theme::Light}, {"dark", Theme::Dark}, {"greetingscat", Theme::GreetingsCat}, {"cream", Theme::Cream},
|
|
};
|
|
|
|
if (auto search = map.find(inString); search != map.end()) {
|
|
return search->second;
|
|
}
|
|
|
|
// Default to dark theme
|
|
return Theme::Dark;
|
|
}
|
|
|
|
const char* FrontendSettings::themeToString(Theme theme) {
|
|
switch (theme) {
|
|
case Theme::System: return "system";
|
|
case Theme::Light: return "light";
|
|
case Theme::GreetingsCat: return "greetingscat";
|
|
case Theme::Cream: return "cream";
|
|
|
|
case Theme::Dark:
|
|
default: return "dark";
|
|
}
|
|
}
|
|
|
|
FrontendSettings::WindowIcon FrontendSettings::iconFromString(std::string inString) { // Transform to lower-case to make the setting case-insensitive
|
|
std::transform(inString.begin(), inString.end(), inString.begin(), [](unsigned char c) { return std::tolower(c); });
|
|
|
|
static const std::unordered_map<std::string, WindowIcon> map = {
|
|
{"rpog", WindowIcon::Rpog},
|
|
{"rsyn", WindowIcon::Rsyn},
|
|
{"rcow", WindowIcon::Rcow},
|
|
{"rnap", WindowIcon::Rnap},
|
|
};
|
|
|
|
if (auto search = map.find(inString); search != map.end()) {
|
|
return search->second;
|
|
}
|
|
|
|
// Default to the icon rpog icon
|
|
return WindowIcon::Rpog;
|
|
}
|
|
|
|
const char* FrontendSettings::iconToString(WindowIcon icon) {
|
|
switch (icon) {
|
|
case WindowIcon::Rsyn: return "rsyn";
|
|
case WindowIcon::Rcow: return "rcow";
|
|
case WindowIcon::Rnap: return "rnap";
|
|
|
|
case WindowIcon::Rpog:
|
|
default: return "rpog";
|
|
}
|
|
} |