Author: mir3x Date: Wed Jul 20 21:42:57 2016 New Revision: 33285 URL: http://svn.gna.org/viewcvs/freeciv?rev=33285&view=rev Log: Qt client - added option to change themes (only system ones).
See patch #7471 Modified: branches/S2_6/client/gui-qt/gui_main.cpp branches/S2_6/client/gui-qt/themes.cpp branches/S2_6/client/options.c branches/S2_6/client/options.h Modified: branches/S2_6/client/gui-qt/gui_main.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/gui_main.cpp?rev=33285&r1=33284&r2=33285&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/gui_main.cpp (original) +++ branches/S2_6/client/gui-qt/gui_main.cpp Wed Jul 20 21:42:57 2016 @@ -38,6 +38,7 @@ #include <QApplication> #include <QMessageBox> #include <QScrollBar> +#include <QStyleFactory> // utility #include "fc_cmdline.h" @@ -174,7 +175,7 @@ qpm = get_icon_sprite(tileset, ICON_FREECIV)->pm; app_icon = ::QIcon(*qpm); qapp->setWindowIcon(app_icon); - + qapp->setStyle(QStyleFactory::create(gui_options.gui_qt_default_theme_name)); if (!gui_options.gui_qt_migrated_from_2_5) { migrate_options_from_2_5(); } Modified: branches/S2_6/client/gui-qt/themes.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/themes.cpp?rev=33285&r1=33284&r2=33285&view=diff ============================================================================== --- branches/S2_6/client/gui-qt/themes.cpp (original) +++ branches/S2_6/client/gui-qt/themes.cpp Wed Jul 20 21:42:57 2016 @@ -14,6 +14,10 @@ #include <fc_config.h> #endif +// Qt +#include <QApplication> +#include <QStyleFactory> + /* utility */ #include "mem.h" @@ -26,12 +30,14 @@ /* client/include */ #include "themes_g.h" +extern QApplication *qapp; + /***************************************************************************** - Loads a gtk theme directory/theme_name + Loads a qt theme directory/theme_name *****************************************************************************/ void qtg_gui_load_theme(const char *directory, const char *theme_name) { - /* Nothing */ + qapp->setStyle(QStyleFactory::create(theme_name)); } /***************************************************************************** @@ -39,7 +45,7 @@ *****************************************************************************/ void qtg_gui_clear_theme() { - /* Nothing */ + qapp->setStyle(QStyleFactory::create("Fusion")); } /***************************************************************************** @@ -50,9 +56,10 @@ *****************************************************************************/ char **qtg_get_gui_specific_themes_directories(int *count) { - *count = 0; - - return (char **) fc_malloc(sizeof(char*) * 0); + const char **array = new const char *[1]; + *count = 1; + array[0] = "qt"; + return const_cast<char**>(array); } /***************************************************************************** @@ -62,6 +69,22 @@ *****************************************************************************/ char **qtg_get_useable_themes_in_directory(const char *directory, int *count) { - *count = 0; - return (char **) fc_malloc(sizeof(char*) * 0); + QStringList sl; + char **array; + char *data; + QByteArray qba;; + QString str; + + sl = QStyleFactory::keys(); + array = new char *[sl.count()]; + *count = sl.count(); + + for (int i = 0; i < *count; i++) { + qba = sl[i].toLocal8Bit(); + data = new char[sl[i].toLocal8Bit().count() + 1]; + strcpy(data, sl[i].toLocal8Bit().data()); + array[i] = data; + } + + return array; } Modified: branches/S2_6/client/options.c URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.c?rev=33285&r1=33284&r2=33285&view=diff ============================================================================== --- branches/S2_6/client/options.c (original) +++ branches/S2_6/client/options.c Wed Jul 20 21:42:57 2016 @@ -273,6 +273,7 @@ /* gui-qt client specific options. */ .gui_qt_fullscreen = FALSE, + .gui_qt_default_theme_name = "Fusion", .gui_qt_font_city_label = "Monospace,8,-1,5,50,0,0,0,0,0", .gui_qt_font_default = "Sans Serif,10,-1,5,75,0,0,0,0,0", .gui_qt_font_notify_label = "Monospace,8,-1,5,75,0,0,0,0,0", @@ -1863,6 +1864,11 @@ N_("By changing this option you change the " "active theme."), COC_GRAPHICS, GUI_SDL2, FC_SDL2_DEFAULT_THEME_NAME, + get_themes_list, theme_reread_callback, 0), + GEN_STR_LIST_OPTION(gui_qt_default_theme_name, N_("Theme"), + N_("By changing this option you change the " + "active theme."), + COC_GRAPHICS, GUI_QT, NULL, get_themes_list, theme_reread_callback, 0), /* It's important to give empty string instead of NULL as as default Modified: branches/S2_6/client/options.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/options.h?rev=33285&r1=33284&r2=33285&view=diff ============================================================================== --- branches/S2_6/client/options.h (original) +++ branches/S2_6/client/options.h Wed Jul 20 21:42:57 2016 @@ -289,6 +289,7 @@ /* gui-qt client specific options. */ bool gui_qt_fullscreen; bool gui_qt_allied_chat_only; + char gui_qt_default_theme_name[512]; char gui_qt_font_city_label[512]; char gui_qt_font_default[512]; char gui_qt_font_notify_label[512]; _______________________________________________ Freeciv-commits mailing list Freeciv-commits@gna.org https://mail.gna.org/listinfo/freeciv-commits