Author: mir3x
Date: Thu Oct 27 21:24:37 2016
New Revision: 34264

URL: http://svn.gna.org/viewcvs/freeciv?rev=34264&view=rev
Log:
Qt client - under windows doesnt find themes

See bug #25228

Modified:
    trunk/client/gui-qt/fc_client.cpp
    trunk/client/gui-qt/gui_main.cpp
    trunk/client/gui-qt/themes.cpp

Modified: trunk/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/fc_client.cpp?rev=34264&r1=34263&r2=34264&view=diff
==============================================================================
--- trunk/client/gui-qt/fc_client.cpp   (original)
+++ trunk/client/gui-qt/fc_client.cpp   Thu Oct 27 21:24:37 2016
@@ -831,15 +831,19 @@
 QIcon fc_icons::get_icon(const QString &id)
 {
   QIcon icon;
+  QString str;
+
+  str = QString("themes") + DIR_SEPARATOR + "gui-qt" + DIR_SEPARATOR;
   /* Try custom icon from theme */
   icon.addFile(fileinfoname(get_data_dirs(),
-                            QString("themes/gui-qt/" + current_theme
-                                    + QDir::separator()
+                            QString(str.toLocal8Bit().data() + current_theme
+                                    + DIR_SEPARATOR
                                     + id + ".png").toLocal8Bit().data()));
+  str = str + "icons" + DIR_SEPARATOR;
   /* Try icon from icons dir */
   if (icon.isNull()) {
   icon.addFile(fileinfoname(get_data_dirs(),
-                            QString("themes/gui-qt/icons/"
+                            QString(str.toLocal8Bit().data()
                                     + id + ".png").toLocal8Bit().data()));
   }
   return QIcon(icon);
@@ -852,15 +856,19 @@
 {
   QPixmap *pm;
   bool status;
+  QString str;
+
   pm = new QPixmap;
+  str = QString("themes") + DIR_SEPARATOR + "gui-qt" + DIR_SEPARATOR;
   status = pm->load(fileinfoname(get_data_dirs(),
-                                 QString("themes/gui-qt/" + current_theme
-                                 + QDir::separator()
+                                 QString(str + current_theme
+                                 + DIR_SEPARATOR
                                  + id + ".png").toLocal8Bit().data()));
 
   if (status == false) {
-  pm->load(fileinfoname(get_data_dirs(), QString("themes/gui-qt/icons/"
-                        + id + ".png").toLocal8Bit().data()));
+    str = str + "icons" + DIR_SEPARATOR;
+    pm->load(fileinfoname(get_data_dirs(), QString(str
+                          + id + ".png").toLocal8Bit().data()));
   }
   return pm;
 }
@@ -870,9 +878,12 @@
 ****************************************************************************/
 QString fc_icons::get_path(const QString &id)
 {
+  QString str;
+  
+  str = QString("themes") + DIR_SEPARATOR + "gui-qt"
+        + DIR_SEPARATOR + "icons" + DIR_SEPARATOR;
   return fileinfoname(get_data_dirs(),
-                      QString("themes/gui-qt/icons/"
-                              + id + ".png").toLocal8Bit().data());
+                      QString(str + id + ".png").toLocal8Bit().data());
 }
 
 /****************************************************************************

Modified: trunk/client/gui-qt/gui_main.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/gui_main.cpp?rev=34264&r1=34263&r2=34264&view=diff
==============================================================================
--- trunk/client/gui-qt/gui_main.cpp    (original)
+++ trunk/client/gui-qt/gui_main.cpp    Thu Oct 27 21:24:37 2016
@@ -186,7 +186,9 @@
     if (!gui_options.gui_qt_migrated_from_2_5) {
       migrate_options_from_2_5();
     }
-    qtg_gui_load_theme(fileinfoname(get_data_dirs(), "themes/gui-qt"),
+    qtg_gui_load_theme(fileinfoname(get_data_dirs(), QString(
+                      QString("themes") + DIR_SEPARATOR
+                      + "gui-qt" ).toLocal8Bit().data()),
                        gui_options.gui_qt_default_theme_name);
     freeciv_qt = new fc_client();
     freeciv_qt->main(qapp);

Modified: trunk/client/gui-qt/themes.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/themes.cpp?rev=34264&r1=34263&r2=34264&view=diff
==============================================================================
--- trunk/client/gui-qt/themes.cpp      (original)
+++ trunk/client/gui-qt/themes.cpp      Thu Oct 27 21:24:37 2016
@@ -46,6 +46,7 @@
   QString name;
   QString res_name;
   QString path;
+  QString fake_dir;
   QDir dir;
   QFile f;
   QString lnb = "LittleFinger";
@@ -59,8 +60,7 @@
     real_data_dir = QString(directory);
   }
   
-  path = real_data_dir
-         + QDir::separator() + theme_name + QDir::separator();
+  path = real_data_dir + DIR_SEPARATOR + theme_name + DIR_SEPARATOR;
   name = dir.absolutePath() + QDir::separator() + real_data_dir;
   name = path + "resource.qss";
   f.setFileName(name);
@@ -71,12 +71,12 @@
     }
     return;
   }
-
+  /* Stylesheet uses UNIX separators */
+  fake_dir = real_data_dir;
+  fake_dir.replace(QString(DIR_SEPARATOR), "/");
   QTextStream in(&f);
   stylestring = in.readAll();
-  stylestring.replace(lnb, real_data_dir
-                      + QDir::separator() + theme_name
-                      + QDir::separator());
+  stylestring.replace(lnb, fake_dir + "/" + theme_name + "/");
 
   if (QString(theme_name) == QString("System")) {
     QApplication::setStyle(QStyleFactory::create(def_app_style));
@@ -99,9 +99,10 @@
 *****************************************************************************/
 void qtg_gui_clear_theme()
 {
-  QString name;
+  QString name, str;
 
-  name = fileinfoname(get_data_dirs(), "themes/gui-qt/");
+  str = QString("themes") + DIR_SEPARATOR + "gui-qt" + DIR_SEPARATOR;
+  name = fileinfoname(get_data_dirs(), str.toLocal8Bit().data());
   qtg_gui_load_theme(name.toLocal8Bit().data(), "NightStalker");
 }
 
@@ -113,10 +114,13 @@
 *****************************************************************************/
 char **qtg_get_gui_specific_themes_directories(int *count)
 {
+  char **array;
+  char *persistent = static_cast<char*>(fc_malloc(256));
+
   *count = 1;
-  char **array;
   array = new char *[*count];
-  array[0] = const_cast<char*>(fileinfoname(get_data_dirs(),""));
+  strncpy(persistent, fileinfoname(get_data_dirs(),""), 256);
+  array[0] = persistent;
   return array;
 }
 
@@ -135,16 +139,16 @@
   QString name;
   QDir dir;
   QFile f;
-  
-  name = fileinfoname(get_data_dirs(),
-                      QString("themes/gui-qt/").toLocal8Bit().data());
-  
+
+  str = QString("themes") + DIR_SEPARATOR + "gui-qt" + DIR_SEPARATOR;
+  name = fileinfoname(get_data_dirs(), str.toLocal8Bit().data());
+
   dir.setPath(name);
   sl << dir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot);
   name = name;
 
   foreach(str, sl) {
-    f.setFileName(name + str + QDir::separator() + "resource.qss");
+    f.setFileName(name + str + DIR_SEPARATOR + "resource.qss");
     if (f.exists() == false) {
       continue;
     }


_______________________________________________
Freeciv-commits mailing list
Freeciv-commits@gna.org
https://mail.gna.org/listinfo/freeciv-commits

Reply via email to