diff --git a/data/widgets/options.xml b/data/widgets/options.xml
index 2a7f396f8..5f5fa10a4 100644
--- a/data/widgets/options.xml
+++ b/data/widgets/options.xml
@@ -11,6 +11,7 @@
+
@@ -134,6 +135,18 @@
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/app/commands/cmd_options.cpp b/src/app/commands/cmd_options.cpp
index 7701eee59..22b6dea94 100644
--- a/src/app/commands/cmd_options.cpp
+++ b/src/app/commands/cmd_options.cpp
@@ -22,6 +22,7 @@
#include "app/ui/color_button.h"
#include "base/bind.h"
#include "base/convert_to.h"
+#include "base/fs.h"
#include "base/path.h"
#include "doc/image.h"
#include "render/render.h"
@@ -33,6 +34,8 @@
namespace app {
+static const char* kSectionThemeId = "section_theme";
+
using namespace ui;
class OptionsWindow : public app::gen::Options {
@@ -151,6 +154,9 @@ public:
undoGotoModified()->setSelected(m_preferences.undo.gotoModified());
undoAllowNonlinearHistory()->setSelected(m_preferences.undo.allowNonlinearHistory());
+ // Theme buttons
+ selectTheme()->Click.connect(Bind(&OptionsWindow::onSelectTheme, this));
+
onChangeGridScope();
sectionListbox()->selectIndex(m_curSection);
}
@@ -249,6 +255,10 @@ private:
panel()->showChild(findChild(item->getValue().c_str()));
m_curSection = sectionListbox()->getSelectedIndex();
+
+ // Load themes
+ if (item->getValue() == kSectionThemeId)
+ loadThemes();
}
void onChangeGridScope() {
@@ -318,6 +328,43 @@ private:
app::launcher::open_folder(app::main_config_filename());
}
+ void loadThemes() {
+ // Themes already loaded
+ if (themeList()->getItemsCount() > 0)
+ return;
+
+ ResourceFinder rf;
+ rf.includeDataDir("skins");
+ std::string path = rf.defaultFilename();
+ for (auto& fn : base::list_files(path)) {
+ if (!base::is_directory(base::join_path(path, fn)))
+ continue;
+
+ ListItem* item = new ListItem(fn);
+ item->setValue(fn);
+ themeList()->addChild(item);
+
+ // Selected theme
+ if (fn == m_preferences.theme.selected())
+ themeList()->selectChild(item);
+ }
+
+ themeList()->sortItems();
+ themeList()->layout();
+ }
+
+ void onSelectTheme() {
+ ListItem* item = dynamic_cast(themeList()->getSelectedChild());
+ if (item &&
+ item->getValue() != m_preferences.theme.selected()) {
+ m_preferences.theme.selected(item->getValue());
+
+ ui::Alert::show(PACKAGE
+ "<