Mercurial > minori
annotate src/gui/translate/config.cc @ 187:9613d72b097e
*: multiple performance improvements
like marking `static const` when it makes sense...
date: change old stupid heap-based method to a structure which should
make copying the thing actually make a copy.
also many performance-based changes, like removing the std::tie
dependency and forward-declaring nlohmann json
*: replace every instance of QString::fromUtf8 to Strings::ToQString.
the main difference is that our function will always convert exactly
what is in the string, while some other times it would only convert
up to the nearest NUL byte
author | Paper <mrpapersonic@gmail.com> |
---|---|
date | Wed, 06 Dec 2023 13:43:54 -0500 |
parents | 29e2840d9b7b |
children | 71832ffe425a |
rev | line source |
---|---|
91 | 1 #include "core/config.h" |
2 #include "gui/translate/config.h" | |
3 | |
4 namespace Translate { | |
5 | |
6 Themes ToTheme(const std::string& theme) { | |
7 const std::unordered_map<std::string, Themes> map = { | |
8 {"Default", Themes::OS }, | |
9 {"Light", Themes::LIGHT}, | |
10 {"Dark", Themes::DARK } | |
11 }; | |
12 | |
13 if (map.find(theme) == map.end()) | |
14 return Themes::OS; | |
15 return map.at(theme); | |
16 } | |
17 | |
18 std::string ToString(const Themes& theme) { | |
19 switch (theme) { | |
20 default: | |
21 case Themes::OS: return "Default"; | |
22 case Themes::LIGHT: return "Light"; | |
23 case Themes::DARK: return "Dark"; | |
24 } | |
25 } | |
26 | |
27 } |