summaryrefslogtreecommitdiff
path: root/src/gui/setup_theme.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2013-04-30 14:08:37 +0300
committerAndrei Karas <akaras@inbox.ru>2013-04-30 14:08:37 +0300
commit1cffd95a2d98736c2d0dc2f382995889ceaef86a (patch)
tree9bb16984a2cc28daf7521beb2f9125f0b0ea77da /src/gui/setup_theme.cpp
parent27a4c8b4acdf5f433f42b5dce97f95f391e36cbf (diff)
downloadmv-1cffd95a2d98736c2d0dc2f382995889ceaef86a.tar.gz
mv-1cffd95a2d98736c2d0dc2f382995889ceaef86a.tar.bz2
mv-1cffd95a2d98736c2d0dc2f382995889ceaef86a.tar.xz
mv-1cffd95a2d98736c2d0dc2f382995889ceaef86a.zip
add support for set fonts and font sizes from themes.
Changed default font size from 11 to 12 px.
Diffstat (limited to 'src/gui/setup_theme.cpp')
-rw-r--r--src/gui/setup_theme.cpp39
1 files changed, 34 insertions, 5 deletions
diff --git a/src/gui/setup_theme.cpp b/src/gui/setup_theme.cpp
index db0b7b6f9..f0cacf8af 100644
--- a/src/gui/setup_theme.cpp
+++ b/src/gui/setup_theme.cpp
@@ -195,6 +195,7 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) :
mThemesModel(new ThemesModel),
mThemeDropDown(new DropDown(this, mThemesModel)),
mTheme(config.getStringValue("theme")),
+ mInfo(Theme::loadInfo(mTheme)),
mFontsModel(new FontsModel),
mFontLabel(new Label(this, _("Main Font"))),
mFontDropDown(new DropDown(this, mFontsModel)),
@@ -318,6 +319,9 @@ Setup_Theme::Setup_Theme(const Widget2 *const widget) :
Setup_Theme::~Setup_Theme()
{
+ delete mInfo;
+ mInfo = nullptr;
+
delete mThemesModel;
mThemesModel = nullptr;
@@ -336,11 +340,11 @@ Setup_Theme::~Setup_Theme()
void Setup_Theme::updateInfo()
{
- ThemeInfo *info = Theme::loadInfo(mTheme);
- if (info)
+ mInfo = Theme::loadInfo(mTheme);
+ if (mInfo)
{
- mThemeInfo = std::string("Name: ").append(info->name)
- .append("\nCopyright:\n").append(info->copyright);
+ mThemeInfo = std::string("Name: ").append(mInfo->name)
+ .append("\nCopyright:\n").append(mInfo->copyright);
}
else
{
@@ -348,7 +352,6 @@ void Setup_Theme::updateInfo()
}
replaceAll(mThemeInfo, "\\n", "\n");
mInfoButton->setEnabled(!mThemeInfo.empty());
- delete info;
}
void Setup_Theme::action(const gcn::ActionEvent &event)
@@ -413,6 +416,9 @@ void Setup_Theme::cancel()
mJapanFont = getFileName(config.getStringValue("japanFont"));
}
+#define updateField(name1, name2) if (!mInfo->name1.empty()) \
+ name2 = mInfo->name1;
+
void Setup_Theme::apply()
{
if (config.getStringValue("theme") != mTheme)
@@ -422,6 +428,27 @@ void Setup_Theme::apply()
}
config.setValue("selectedSkin", "");
+ if (config.getStringValue("theme") != mTheme)
+ {
+ updateField(font, mFont);
+ updateField(boldFont, mBoldFont);
+ updateField(particleFont, mParticleFont);
+ updateField(helpFont, mHelpFont);
+ updateField(secureFont, mSecureFont);
+ updateField(japanFont, mJapanFont);
+ if (mInfo->fontSize)
+ {
+ const int size = mInfo->fontSize - 9;
+ if (size >= 0)
+ mFontSizeDropDown->setSelected(size);
+ }
+ if (mInfo->npcfontSize)
+ {
+ const int size = mInfo->npcfontSize - 9;
+ if (size >= 0)
+ mNpcFontSizeDropDown->setSelected(size);
+ }
+ }
config.setValue("theme", mTheme);
config.setValue("lang", mLang);
if (config.getValue("font", "dejavusans.ttf") != mFont
@@ -447,3 +474,5 @@ void Setup_Theme::apply()
gui->updateFonts();
}
}
+
+#undef updateField