Author: mir3x
Date: Sun Nov  6 22:01:11 2016
New Revision: 34408

URL: http://svn.gna.org/viewcvs/freeciv?rev=34408&view=rev
Log:
Qt client: fixed some fonts not updated when changed in the settings
Reported by Louis Moureaux <louis94>

See bug #25023

Modified:
    branches/S2_6/client/gui-qt/fc_client.cpp
    branches/S2_6/client/gui-qt/fc_client.h
    branches/S2_6/client/gui-qt/gui_main.cpp
    branches/S2_6/client/gui-qt/helpdlg.cpp
    branches/S2_6/client/gui-qt/helpdlg.h

Modified: branches/S2_6/client/gui-qt/fc_client.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.cpp?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_6/client/gui-qt/fc_client.cpp   Sun Nov  6 22:01:11 2016
@@ -276,16 +276,6 @@
     output_window->append(str);
     output_window->verticalScrollBar()->setSliderPosition(
                               output_window->verticalScrollBar()->maximum());
-  }
-}
-
-/****************************************************************************
-  Updates the application's default font when it changes
-****************************************************************************/
-void fc_client::update_font(const QString &name, const QFont &font)
-{
-  if (name == fonts::default_font) {
-    QApplication::setFont(font);
   }
 }
 

Modified: branches/S2_6/client/gui-qt/fc_client.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/fc_client.h?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/fc_client.h     (original)
+++ branches/S2_6/client/gui-qt/fc_client.h     Sun Nov  6 22:01:11 2016
@@ -307,8 +307,6 @@
 private:
   void chat_message_received(const QString &message,
                              const struct text_tag_list *tags);
-  void update_font(const QString &name, const QFont &font);
-
   void create_main_page();
   void create_network_page();
   void create_load_page();

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=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/gui_main.cpp    (original)
+++ branches/S2_6/client/gui-qt/gui_main.cpp    Sun Nov  6 22:01:11 2016
@@ -433,40 +433,22 @@
 ****************************************************************************/
 static void apply_notify_font(struct option *poption)
 {
-  QFont *f;
-  QFont *remove_old;
+  if (gui()) {
+    qtg_gui_update_font("notify_label", option_font_get(poption));
+    restart_notify_dialogs();
+  }
+}
+
+
+/****************************************************************************
+  Changes city label font
+****************************************************************************/
+void apply_city_font(option *poption)
+{
   QString s;
 
-  if (gui()) {
-    f = new QFont;
-    s = option_font_get(poption);
-    f->fromString(s);
-    s = option_name(poption);
-    remove_old = fc_font::instance()->get_font(s);
-    delete remove_old;
-    fc_font::instance()->set_font(s, f);
-    restart_notify_dialogs();
-  }
-}
-
-
-/****************************************************************************
-  Changes city label font
-****************************************************************************/
-void apply_city_font(option *poption)
-{
-  QFont *f;
-  QFont *remove_old;
-  QString s;
-
   if (gui() && qtg_get_current_client_page() == PAGE_GAME) {
-    f = new QFont;
-    s = option_font_get(poption);
-    f->fromString(s);
-    s = option_name(poption);
-    remove_old = fc_font::instance()->get_font(s);
-    delete remove_old;
-    fc_font::instance()->set_font(s, f);
+    qtg_gui_update_font("city_label", option_font_get(poption));
     city_font_update();
   }
 }

Modified: branches/S2_6/client/gui-qt/helpdlg.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/helpdlg.cpp?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/helpdlg.cpp     (original)
+++ branches/S2_6/client/gui-qt/helpdlg.cpp     Sun Nov  6 22:01:11 2016
@@ -358,9 +358,11 @@
   box_wdg->setFrameShadow(QFrame::Raised);
 
   title_label = new QLabel(box_wdg);
+  title_label->setProperty(fonts::help_title, "true");
   group_layout->addWidget(title_label);
 
   text_browser = new QTextBrowser(this);
+  text_browser->setProperty(fonts::help_text, "true");
   layout->addWidget(text_browser);
   main_widget = text_browser;
 
@@ -431,19 +433,28 @@
 **************************************************************************/
 void help_widget::update_fonts()
 {
-  QFont *help_font, *label_font, *title_font;
-  QLabel *label;
-
-  label_font = fc_font::instance()->get_font(fonts::help_label);
-  help_font = fc_font::instance()->get_font(fonts::help_text);
-  title_font = fc_font::instance()->get_font(fonts::help_title);
-  text_browser->setFont(*help_font);
-  title_label->setFont(*title_font);
-  foreach (label, label_list) {
-    label->setFont(*label_font);
-  }
-  foreach (label, title_list) {
-    label->setFont(*title_font);
+  QList<QWidget *> l;
+  QFont *f;
+
+  l = findChildren<QWidget *>();
+
+  f = fc_font::instance()->get_font(fonts::help_label);
+  for (int i = 0; i < l.size(); ++i) {
+    if (l.at(i)->property(fonts::help_label).isValid()) {
+      l.at(i)->setFont(*f);
+    }
+  }
+  f = fc_font::instance()->get_font(fonts::help_text);
+  for (int i = 0; i < l.size(); ++i) {
+    if (l.at(i)->property(fonts::help_text).isValid()) {
+      l.at(i)->setFont(*f);
+    }
+  }
+  f = fc_font::instance()->get_font(fonts::help_title);
+  for (int i = 0; i < l.size(); ++i) {
+    if (l.at(i)->property(fonts::help_title).isValid()) {
+      l.at(i)->setFont(*f);
+    }
   }
 }
 
@@ -468,8 +479,6 @@
   info_panel = NULL;
   splitter = NULL;
   info_layout = NULL;
-  label_list.clear();
-  title_list.clear();
 }
 
 /****************************************************************************
@@ -509,8 +518,7 @@
 {
   QLabel *label = new QLabel(text);
   label->setWordWrap(true);
-
-  label_list << label;
+  label->setProperty(fonts::help_label, "true");
   info_layout->addWidget(label);
 }
 
@@ -537,14 +545,14 @@
 
   label = new QLabel(text, wdg);
   layout->addWidget(label, 0, 0);
-  label_list << label;
+  label->setProperty(fonts::help_label, "true");
   label = new QLabel(wdg);
   if (value.isEmpty()) {
     label->setNum(progress);
   } else {
     label->setText(value);
   }
-  label_list << label;
+  label->setProperty(fonts::help_label, "true");
   layout->addWidget(label, 0, 1, Qt::AlignRight);
 
   bar = new QProgressBar(wdg);
@@ -582,6 +590,7 @@
       QLabel *tb;
       QString str;
       tb = new QLabel(this);
+      tb->setProperty(fonts::help_label, "true");
       tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
       tb->setTextFormat(Qt::RichText);
 
@@ -918,6 +927,7 @@
           if (VUT_ADVANCE == preq->source.kind
               && preq->source.value.advance == padvance) {
             tb = new QLabel(this);
+            tb->setProperty(fonts::help_label, "true");
             tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
             tb->setTextFormat(Qt::RichText);
             str = _("Allows");
@@ -941,6 +951,7 @@
                             is_great_wonder(pimprove) ? HELP_WONDER
                              : HELP_IMPROVEMENT);
             tb = new QLabel(this);
+            tb->setProperty(fonts::help_label, "true");
             tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
             tb->setTextFormat(Qt::RichText);
             tb->setText(str.trimmed());
@@ -959,6 +970,7 @@
                             is_great_wonder(pimprove) ? HELP_WONDER
                             : HELP_IMPROVEMENT);
             tb = new QLabel(this);
+            tb->setProperty(fonts::help_label, "true");
             tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
             tb->setTextFormat(Qt::RichText);
             tb->setText(str.trimmed());
@@ -977,6 +989,7 @@
         str = "<b>" + str + "</b> "
               + link_me(utype_name_translation(punittype), HELP_UNIT);
         tb = new QLabel(this);
+        tb->setProperty(fonts::help_label, "true");
         tb->setTextInteractionFlags(Qt::LinksAccessibleByMouse);
         tb->setTextFormat(Qt::RichText);
         tb->setText(str.trimmed());
@@ -1063,11 +1076,11 @@
 
   label = new QLabel(title);
   layout->addWidget(label, 0, 1, Qt::AlignBottom);
-  title_list << label;
+  label->setProperty(fonts::help_title, "true");
 
   label = new QLabel(legend);
   layout->addWidget(label, 1, 1, Qt::AlignTop);
-  label_list << label;
+  label->setProperty(fonts::help_label, "true");
 
   if (!tooltip.isEmpty()) {
     label->setToolTip(tooltip);

Modified: branches/S2_6/client/gui-qt/helpdlg.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/helpdlg.h?rev=34408&r1=34407&r2=34408&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/helpdlg.h       (original)
+++ branches/S2_6/client/gui-qt/helpdlg.h       Sun Nov  6 22:01:11 2016
@@ -64,8 +64,6 @@
   Q_OBJECT
   QFrame *box_wdg;
   QLabel *title_label;
-  QList<QLabel *> label_list;
-  QList<QLabel *> title_list;
 
   QWidget *main_widget;
   QTextBrowser *text_browser;


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

Reply via email to