Mercurial > minori
comparison src/gui/translate/config.cc @ 279:657fda1b9cac
*: clean up enums
| author | Paper <paper@paper.us.eu.org> |
|---|---|
| date | Fri, 19 Apr 2024 13:24:06 -0400 |
| parents | 862d0d8619f6 |
| children | b1f625b0227c |
comparison
equal
deleted
inserted
replaced
| 274:f6a756c19bfb | 279:657fda1b9cac |
|---|---|
| 1 #include "core/config.h" | 1 #include "core/config.h" |
| 2 #include "core/strings.h" | |
| 2 #include "gui/translate/config.h" | 3 #include "gui/translate/config.h" |
| 4 | |
| 5 #include <QCoreApplication> | |
| 3 | 6 |
| 4 #include <unordered_map> | 7 #include <unordered_map> |
| 5 | 8 |
| 6 namespace Translate { | 9 namespace Translate { |
| 7 | 10 |
| 8 Themes ToTheme(const std::string& theme) { | 11 Theme::Theme ToTheme(const std::string& theme) { |
| 9 const std::unordered_map<std::string, Themes> map = { | 12 const std::unordered_map<std::string, Theme::Theme> map = { |
| 10 {"Default", Themes::OS }, | 13 {"Default", Theme::Theme::Default }, |
| 11 {"Light", Themes::LIGHT}, | 14 {"Light", Theme::Theme::Light}, |
| 12 {"Dark", Themes::DARK } | 15 {"Dark", Theme::Theme::Dark } |
| 13 }; | 16 }; |
| 14 | 17 |
| 15 if (map.find(theme) == map.end()) | 18 if (map.find(theme) == map.end()) |
| 16 return Themes::OS; | 19 return Theme::Theme::Default; |
| 17 return map.at(theme); | 20 return map.at(theme); |
| 18 } | 21 } |
| 19 | 22 |
| 20 std::string ToString(const Themes& theme) { | 23 std::string ToString(const Theme::Theme& theme) { |
| 21 switch (theme) { | 24 switch (theme) { |
| 22 default: | 25 default: |
| 23 case Themes::OS: return "Default"; | 26 case Theme::Theme::Default: return "Default"; |
| 24 case Themes::LIGHT: return "Light"; | 27 case Theme::Theme::Light: return "Light"; |
| 25 case Themes::DARK: return "Dark"; | 28 case Theme::Theme::Dark: return "Dark"; |
| 29 } | |
| 30 } | |
| 31 | |
| 32 std::string ToLocalString(const Theme::Theme& theme) { | |
| 33 switch (theme) { | |
| 34 default: | |
| 35 case Theme::Theme::Default: return Strings::ToUtf8String(QCoreApplication::tr("Default")); | |
| 36 case Theme::Theme::Light: return Strings::ToUtf8String(QCoreApplication::tr("Light")); | |
| 37 case Theme::Theme::Dark: return Strings::ToUtf8String(QCoreApplication::tr("Dark")); | |
| 26 } | 38 } |
| 27 } | 39 } |
| 28 | 40 |
| 29 } // namespace Translate | 41 } // namespace Translate |
