summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/Makefile.am1
-rw-r--r--src/gui/models/langlistmodel.h121
-rw-r--r--src/gui/widgets/tabs/setup_theme.cpp94
4 files changed, 124 insertions, 93 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c6cbcecfc..42c2ae992 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -154,6 +154,7 @@ SET(SRCS
gui/models/ignorechoiceslistmodel.h
gui/models/itemsmodel.h
gui/models/keylistmodel.h
+ gui/models/langlistmodel.h
gui/widgets/flowcontainer.cpp
gui/widgets/flowcontainer.h
gui/widgets/tabs/gmtab.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index 91a2b3bf2..217048e4f 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -245,6 +245,7 @@ manaplus_SOURCES += gui/widgets/avatarlistbox.cpp \
gui/models/ignorechoiceslistmodel.h \
gui/models/itemsmodel.h \
gui/models/keylistmodel.h \
+ gui/models/langlistmodel.h \
gui/widgets/flowcontainer.cpp \
gui/widgets/flowcontainer.h \
gui/widgets/tabs/gmtab.cpp \
diff --git a/src/gui/models/langlistmodel.h b/src/gui/models/langlistmodel.h
new file mode 100644
index 000000000..bc807fcf2
--- /dev/null
+++ b/src/gui/models/langlistmodel.h
@@ -0,0 +1,121 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2009-2010 Andrei Karas
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "gui/models/listmodel.h"
+
+#include "resources/resourcemanager.h"
+
+#include "utils/gettext.h"
+
+#include "localconsts.h"
+
+struct Language final
+{
+ std::string name;
+ std::string value;
+ std::string icon;
+};
+
+const int langs_count = 17;
+
+const Language LANG_NAME[langs_count] =
+{
+ // TRANSLATORS: language
+ {N_("(default)"), "", ""},
+ // TRANSLATORS: language
+ {N_("Chinese (China)"), "zh_CN", "cn.png"},
+ // TRANSLATORS: language
+ {N_("Czech"), "cs_CZ", "cz.png"},
+ // TRANSLATORS: language
+ {N_("English"), "C", "en.png"},
+ // TRANSLATORS: language
+ {N_("Finnish"), "fi_FI", "fi.png"},
+ // TRANSLATORS: language
+ {N_("French"), "fr_FR", "fr.png"},
+ // TRANSLATORS: language
+ {N_("German"), "de_DE", "de.png"},
+ // TRANSLATORS: language
+ {N_("Indonesian"), "id_ID", "id.png"},
+ // TRANSLATORS: language
+ {N_("Italian"), "it_IT", "it.png"},
+ // TRANSLATORS: language
+ {N_("Polish"), "pl_PL", "pl.png"},
+ // TRANSLATORS: language
+ {N_("Japanese"), "ja_JP", "jp.png"},
+ // TRANSLATORS: language
+ {N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"},
+ // TRANSLATORS: language
+ {N_("Portuguese"), "pt_PT", "pt.png"},
+ // TRANSLATORS: language
+ {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"},
+ // TRANSLATORS: language
+ {N_("Russian"), "ru_RU", "ru.png"},
+ // TRANSLATORS: language
+ {N_("Spanish (Castilian)"), "es_ES", "es.png"},
+ // TRANSLATORS: language
+ {N_("Turkish"), "tr_TR", "tr.png"}
+};
+
+class LangListModel final : public ExtendedListModel
+{
+public:
+ LangListModel()
+ {
+ ResourceManager *const resman = ResourceManager::getInstance();
+ for (int f = 0; f < langs_count; f ++)
+ {
+ mIcons[f] = resman->getImage("graphics/flags/"
+ + LANG_NAME[f].icon);
+ }
+ }
+
+ A_DELETE_COPY(LangListModel)
+
+ ~LangListModel()
+ {
+ for (int f = 0; f < langs_count; f ++)
+ {
+ Image *const img = mIcons[f];
+ if (img)
+ img->decRef();
+ }
+ }
+
+ int getNumberOfElements() override final A_WARN_UNUSED
+ { return langs_count; }
+
+ std::string getElementAt(int i) override final A_WARN_UNUSED
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return "???";
+
+ return gettext(LANG_NAME[i].name.c_str());
+ }
+
+ const Image *getImageAt(int i) override final A_WARN_UNUSED
+ {
+ if (i >= getNumberOfElements() || i < 0)
+ return nullptr;
+ return mIcons[i];
+ }
+
+ Image *mIcons[langs_count];
+};
diff --git a/src/gui/widgets/tabs/setup_theme.cpp b/src/gui/widgets/tabs/setup_theme.cpp
index 7d818f477..6ba74449d 100644
--- a/src/gui/widgets/tabs/setup_theme.cpp
+++ b/src/gui/widgets/tabs/setup_theme.cpp
@@ -30,6 +30,7 @@
#include "gui/models/extendedlistmodel.h"
#include "gui/models/fontsizechoicelistmodel.h"
#include "gui/models/fontsmodel.h"
+#include "gui/models/langlistmodel.h"
#include "gui/models/themesmodel.h"
#include "gui/widgets/button.h"
@@ -59,99 +60,6 @@ const char* ACTION_JAPAN_FONT = "japanese font";
const char* ACTION_CHINA_FONT = "chinese font";
const char* ACTION_INFO = "info";
-struct Language final
-{
- std::string name;
- std::string value;
- std::string icon;
-};
-
-const int langs_count = 17;
-
-const Language LANG_NAME[langs_count] =
-{
- // TRANSLATORS: language
- {N_("(default)"), "", ""},
- // TRANSLATORS: language
- {N_("Chinese (China)"), "zh_CN", "cn.png"},
- // TRANSLATORS: language
- {N_("Czech"), "cs_CZ", "cz.png"},
- // TRANSLATORS: language
- {N_("English"), "C", "en.png"},
- // TRANSLATORS: language
- {N_("Finnish"), "fi_FI", "fi.png"},
- // TRANSLATORS: language
- {N_("French"), "fr_FR", "fr.png"},
- // TRANSLATORS: language
- {N_("German"), "de_DE", "de.png"},
- // TRANSLATORS: language
- {N_("Indonesian"), "id_ID", "id.png"},
- // TRANSLATORS: language
- {N_("Italian"), "it_IT", "it.png"},
- // TRANSLATORS: language
- {N_("Polish"), "pl_PL", "pl.png"},
- // TRANSLATORS: language
- {N_("Japanese"), "ja_JP", "jp.png"},
- // TRANSLATORS: language
- {N_("Dutch (Belgium/Flemish)"), "nl_BE", "nl_BE.png"},
- // TRANSLATORS: language
- {N_("Portuguese"), "pt_PT", "pt.png"},
- // TRANSLATORS: language
- {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"},
- // TRANSLATORS: language
- {N_("Russian"), "ru_RU", "ru.png"},
- // TRANSLATORS: language
- {N_("Spanish (Castilian)"), "es_ES", "es.png"},
- // TRANSLATORS: language
- {N_("Turkish"), "tr_TR", "tr.png"}
-};
-
-class LangListModel final : public ExtendedListModel
-{
-public:
- LangListModel()
- {
- ResourceManager *const resman = ResourceManager::getInstance();
- for (int f = 0; f < langs_count; f ++)
- {
- mIcons[f] = resman->getImage("graphics/flags/"
- + LANG_NAME[f].icon);
- }
- }
-
- A_DELETE_COPY(LangListModel)
-
- ~LangListModel()
- {
- for (int f = 0; f < langs_count; f ++)
- {
- Image *const img = mIcons[f];
- if (img)
- img->decRef();
- }
- }
-
- int getNumberOfElements() override final A_WARN_UNUSED
- { return langs_count; }
-
- std::string getElementAt(int i) override final A_WARN_UNUSED
- {
- if (i >= getNumberOfElements() || i < 0)
- return "???";
-
- return gettext(LANG_NAME[i].name.c_str());
- }
-
- const Image *getImageAt(int i) override final A_WARN_UNUSED
- {
- if (i >= getNumberOfElements() || i < 0)
- return nullptr;
- return mIcons[i];
- }
-
- Image *mIcons[langs_count];
-};
-
Setup_Theme::Setup_Theme(const Widget2 *const widget) :
SetupTab(widget),
// TRANSLATORS: theme settings label