annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
1 #include "core/config.h"
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
2 #include "core/strings.h"
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
3 #include "gui/translate/config.h"
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
4
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
5 #include <QCoreApplication>
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
6
202
71832ffe425a animia: re-add kvm fd source
Paper <paper@paper.us.eu.org>
parents: 91
diff changeset
7 #include <unordered_map>
71832ffe425a animia: re-add kvm fd source
Paper <paper@paper.us.eu.org>
parents: 91
diff changeset
8
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
9 namespace Translate {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
10
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
11 Theme::Theme ToTheme(const std::string& theme) {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
12 const std::unordered_map<std::string, Theme::Theme> map = {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
13 {"Default", Theme::Theme::Default },
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
14 {"Light", Theme::Theme::Light},
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
15 {"Dark", Theme::Theme::Dark }
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 202
diff changeset
16 };
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
17
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
18 if (map.find(theme) == map.end())
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
19 return Theme::Theme::Default;
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
20 return map.at(theme);
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
21 }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
22
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
23 std::string ToString(const Theme::Theme& theme) {
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
24 switch (theme) {
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
25 default:
279
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
26 case Theme::Theme::Default: return "Default";
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
27 case Theme::Theme::Light: return "Light";
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
28 case Theme::Theme::Dark: return "Dark";
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
29 }
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
30 }
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
31
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
32 std::string ToLocalString(const Theme::Theme& theme) {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
33 switch (theme) {
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
34 default:
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
35 case Theme::Theme::Default: return Strings::ToUtf8String(QCoreApplication::tr("Default"));
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
36 case Theme::Theme::Light: return Strings::ToUtf8String(QCoreApplication::tr("Light"));
657fda1b9cac *: clean up enums
Paper <paper@paper.us.eu.org>
parents: 258
diff changeset
37 case Theme::Theme::Dark: return Strings::ToUtf8String(QCoreApplication::tr("Dark"));
91
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
38 }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
39 }
29e2840d9b7b *: oops
Paper <mrpapersonic@gmail.com>
parents:
diff changeset
40
258
862d0d8619f6 *: HUUUGE changes
Paper <paper@paper.us.eu.org>
parents: 202
diff changeset
41 } // namespace Translate