| 
91
 | 
     1 #include "core/config.h"
 | 
| 
279
 | 
     2 #include "core/strings.h"
 | 
| 
91
 | 
     3 #include "gui/translate/config.h"
 | 
| 
 | 
     4 
 | 
| 
279
 | 
     5 #include <QCoreApplication>
 | 
| 
 | 
     6 
 | 
| 
202
 | 
     7 #include <unordered_map>
 | 
| 
 | 
     8 
 | 
| 
91
 | 
     9 namespace Translate {
 | 
| 
 | 
    10 
 | 
| 
279
 | 
    11 Theme::Theme ToTheme(const std::string& theme) {
 | 
| 
 | 
    12 	const std::unordered_map<std::string, Theme::Theme> map = {
 | 
| 
 | 
    13 	    {"Default", Theme::Theme::Default   },
 | 
| 
 | 
    14         {"Light",   Theme::Theme::Light},
 | 
| 
 | 
    15         {"Dark",    Theme::Theme::Dark }
 | 
| 
258
 | 
    16     };
 | 
| 
91
 | 
    17 
 | 
| 
 | 
    18 	if (map.find(theme) == map.end())
 | 
| 
279
 | 
    19 		return Theme::Theme::Default;
 | 
| 
91
 | 
    20 	return map.at(theme);
 | 
| 
 | 
    21 }
 | 
| 
 | 
    22 
 | 
| 
279
 | 
    23 std::string ToString(const Theme::Theme& theme) {
 | 
| 
91
 | 
    24 	switch (theme) {
 | 
| 
 | 
    25 		default:
 | 
| 
279
 | 
    26 		case Theme::Theme::Default: return "Default";
 | 
| 
 | 
    27 		case Theme::Theme::Light: return "Light";
 | 
| 
 | 
    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"));
 | 
| 
91
 | 
    38 	}
 | 
| 
 | 
    39 }
 | 
| 
 | 
    40 
 | 
| 
258
 | 
    41 } // namespace Translate
 |