summaryrefslogtreecommitdiff
path: root/src/gui/setup_theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2012-12-29 00:16:54 +0300
committerAndrei Karas <akaras@inbox.ru>2012-12-29 00:16:54 +0300
commit0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118 (patch)
tree5dedc441dcf535f8ac4b43f8b8ea0bb27c8ba6ac /src/gui/setup_theme.cpp
parent7c51eee345d27e680a26a915ffccb2d0abf063ea (diff)
downloadmv-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.tar.gz
mv-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.tar.bz2
mv-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.tar.xz
mv-0cd049b5b56b34b0b7ab3e3eac93dcb255c4e118.zip
Show flags icons in language selection list
Also add support for extended listboxes in popuplist control.
Diffstat (limited to 'src/gui/setup_theme.cpp')
-rw-r--r--src/gui/setup_theme.cpp70
1 files changed, 49 insertions, 21 deletions
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index 277ddadae..2a8836bcb 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -29,6 +29,7 @@
#include "gui/widgets/button.h"
#include "gui/widgets/checkbox.h"
#include "gui/widgets/dropdown.h"
+#include "gui/widgets/extendedlistmodel.h"
#include "gui/widgets/label.h"
#include "gui/widgets/layouthelper.h"
#include "gui/widgets/namesmodel.h"
@@ -116,46 +117,73 @@ struct Language final
{
std::string name;
std::string value;
+ std::string icon;
};
const int langs_count = 16;
const Language LANG_NAME[langs_count] =
{
- {N_("(default)"), ""},
- {N_("Chinese (China)"), "zh_CN"},
- {N_("Czech"), "cs_CZ"},
- {N_("English"), "C"},
- {N_("Finnish"), "fi_FI"},
- {N_("French"), "fr_FR"},
- {N_("German"), "de_DE"},
- {N_("Indonesian"), "id_ID"},
- {N_("Italian"), "it_IT"},
- {N_("Polish"), "pl_PL"},
- {N_("Japanese"), "ja_JP.utf8"},
- {N_("Dutch (Belgium/Flemish)"), "nl_BE"},
- {N_("Portuguese"), "pt_PT"},
- {N_("Portuguese (Brazilian)"), "pt_BR"},
- {N_("Russian"), "ru_RU"},
- {N_("Spanish (Castilian)"), "es_ES"}
+ {N_("(default)"), "", ""},
+ {N_("Chinese (China)"), "zh_CN", "cn.png"},
+ {N_("Czech"), "cs_CZ", "cz.png"},
+ {N_("English"), "C", "en.png"},
+ {N_("Finnish"), "fi_FI", "fi.png"},
+ {N_("French"), "fr_FR", "fr.png"},
+ {N_("German"), "de_DE", "de.png"},
+ {N_("Indonesian"), "id_ID", "id.png"},
+ {N_("Italian"), "it_IT", "it.png"},
+ {N_("Polish"), "pl_PL", "pl.png"},
+ {N_("Japanese"), "ja_JP", "jp.png"},
+ {N_("Dutch (Belgium/Flemish)"), "nl_BE", ""},
+ {N_("Portuguese"), "pt_PT", "pt.png"},
+ {N_("Portuguese (Brazilian)"), "pt_BR", "pt_BR.png"},
+ {N_("Russian"), "ru_RU", "ru.png"},
+ {N_("Spanish (Castilian)"), "es_ES", "es.png"}
};
-class LangListModel final : public gcn::ListModel
+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);
+ }
+ }
+
virtual ~LangListModel()
- { }
+ {
+ for (int f = 0; f < langs_count; f ++)
+ {
+ Image *const img = mIcons[f];
+ if (img)
+ img->decRef();
+ }
+ }
- virtual int getNumberOfElements() override
+ int getNumberOfElements() override A_WARN_UNUSED
{ return langs_count; }
- virtual std::string getElementAt(int i) override
+ std::string getElementAt(int i) override A_WARN_UNUSED
{
if (i >= getNumberOfElements() || i < 0)
return _("???");
return gettext(LANG_NAME[i].name.c_str());
}
+
+ const Image *getImageAt(int i) override 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) :
@@ -170,7 +198,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) :
mFont(config.getStringValue("font")),
mLangListModel(new LangListModel),
mLangLabel(new Label(this, _("Language"))),
- mLangDropDown(new DropDown(this, mLangListModel)),
+ mLangDropDown(new DropDown(this, mLangListModel, true)),
mLang(config.getStringValue("lang")),
mBoldFontLabel(new Label(this, _("Bold font"))),
mBoldFontDropDown(new DropDown(this, mFontsModel)),