Author: mir3x
Date: Sun Dec 20 19:48:57 2015
New Revision: 31111

URL: http://svn.gna.org/viewcvs/freeciv?rev=31111&view=rev
Log:
Changed updating info_label behaviour, it waits about 100 msecs,
and if no new updates comes, then calls update_info_label().

See bug #24153


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/mapview.cpp

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=31111&r1=31110&r2=31111&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/fc_client.cpp   (original)
+++ branches/S2_6/client/gui-qt/fc_client.cpp   Sun Dec 20 19:48:57 2015
@@ -97,6 +97,7 @@
   pre_vote = NULL;
   x_vote = NULL;
   gtd = NULL;
+  update_info_timer = nullptr;
   for (int i = 0; i <= PAGE_GAME; i++) {
     pages_layout[i] = NULL;
     pages[i] = NULL;

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=31111&r1=31110&r2=31111&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/fc_client.h     (original)
+++ branches/S2_6/client/gui-qt/fc_client.h     Sun Dec 20 19:48:57 2015
@@ -172,6 +172,7 @@
 
   QTimer* meta_scan_timer;
   QTimer* lan_scan_timer;
+  QTimer *update_info_timer;
 
   QStatusBar *status_bar;
   QSignalMapper *switch_page_mapper;
@@ -262,6 +263,7 @@
 public slots:
   void switch_page(int i);
   void popup_client_options();
+  void update_info_label();
 
 protected slots:
 

Modified: branches/S2_6/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S2_6/client/gui-qt/mapview.cpp?rev=31111&r1=31110&r2=31111&view=diff
==============================================================================
--- branches/S2_6/client/gui-qt/mapview.cpp     (original)
+++ branches/S2_6/client/gui-qt/mapview.cpp     Sun Dec 20 19:48:57 2015
@@ -1302,14 +1302,35 @@
 ****************************************************************************/
 void update_info_label(void)
 {
+  gui()->update_info_label();
+}
+
+/****************************************************************************
+  Real update, updates only once per 100 ms.
+****************************************************************************/
+void fc_client::update_info_label(void)
+{
   QString s, eco_info;
 
-  if (gui()->current_page() != PAGE_GAME) {
+  if (current_page() != PAGE_GAME) {
     return;
   }
+  if (update_info_timer == nullptr) {
+    update_info_timer = new QTimer();
+    update_info_timer->setSingleShot(true);
+    connect(update_info_timer, SIGNAL(timeout()),
+            this, SLOT(update_info_label()));
+    update_info_timer->start(100);
+    return;
+  }
+
+  if (update_info_timer->remainingTime() > 0) {
+    return;
+  }
+
   s = QString(_("%1 (Turn:%2)")).arg(calendar_text(),
-                                             QString::number(game.info.turn));
-  gui()->game_info_label->set_turn_info(s);
+                                            QString::number(game.info.turn));
+  game_info_label->set_turn_info(s);
   set_indicator_icons(client_research_sprite(),
                       client_warming_sprite(),
                       client_cooling_sprite(), client_government_sprite());
@@ -1323,11 +1344,14 @@
            .arg(QString::number(client.conn.playing->economic.gold),
            QString::number(player_get_expected_income(client.conn.playing)));
     }
-    gui()->game_info_label->set_eco_info(eco_info);
-  }
-  gui()->game_info_label->info_update();
-  gui()->end_turn_rect->end_turn_update();
-}
+    game_info_label->set_eco_info(eco_info);
+  }
+  game_info_label->info_update();
+  end_turn_rect->end_turn_update();
+  delete update_info_timer;
+  update_info_timer = nullptr;
+}
+
 
 /****************************************************************************
   Update the information label which gives info on the current unit


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

Reply via email to