Author: mir3x
Date: Thu Dec 17 20:55:23 2015
New Revision: 31045

URL: http://svn.gna.org/viewcvs/freeciv?rev=31045&view=rev
Log:
Made text "no research target"  blinking  when 
current technology is not set and goal technology is not set too.
Also clicking on that text will bring research dialog up. 

See patch #6681


Modified:
    trunk/client/gui-qt/mapview.cpp
    trunk/client/gui-qt/mapview.h

Modified: trunk/client/gui-qt/mapview.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapview.cpp?rev=31045&r1=31044&r2=31045&view=diff
==============================================================================
--- trunk/client/gui-qt/mapview.cpp     (original)
+++ trunk/client/gui-qt/mapview.cpp     Thu Dec 17 20:55:23 2015
@@ -30,6 +30,7 @@
 #include "calendar.h"
 #include "game.h"
 #include "map.h"
+#include "research.h"
 
 // client
 #include "climisc.h"
@@ -905,6 +906,8 @@
   "color: rgb(232, 255, 0); background: transparent;";
 static const char *res_label_stylesheet =
   "color: rgb(40, 138, 200); background: transparent;";
+static const char *res_blink_label_stylesheet =
+  "color: rgb(120, 220, 255); background: transparent;";
 static const char *time_label_stylesheet =
   "color: rgb(180, 0, 0); background: transparent;";
 
@@ -984,6 +987,20 @@
   }
 }
 
+/***************************************************************************
+  Constructor for clicked_label
+***************************************************************************/
+clicked_label::clicked_label(QWidget *parent) : QLabel(parent)
+{
+}
+
+/***************************************************************************
+  Mouse event for clicked_label
+***************************************************************************/
+void clicked_label::mousePressEvent(QMouseEvent *e)
+{
+  emit clicked();
+}
 
 /**************************************************************************
   Constructor for information label
@@ -1003,7 +1020,7 @@
   layout->addWidget(eco_info);
   si = new QSpacerItem(10, 0);
   layout->addSpacerItem(si);
-  res_info = new QLabel();
+  res_info = new clicked_label();
   res_info->setStyleSheet(res_label_stylesheet);
   layout->addWidget(res_info);
   si = new QSpacerItem(10, 0);
@@ -1018,7 +1035,12 @@
   layout->addWidget(time_label);
   si = new QSpacerItem(10, 0);
   layout->addSpacerItem(si);
+  timer_active = false;
+  res_timer = new QTimer;
+  res_timer->setSingleShot(true);
   setLayout(layout);
+  connect(res_timer, SIGNAL(timeout()), this, SLOT(blink()));
+  connect(res_info, SIGNAL(clicked()), this, SLOT(show_research_tab()));
 }
 
 
@@ -1027,6 +1049,14 @@
 **************************************************************************/
 info_label::~info_label()
 {
+}
+
+/***************************************************************************
+  Slot for showing research tab
+***************************************************************************/
+void info_label::show_research_tab()
+{
+  science_report_dialog_popup(true);
 }
 
 /**************************************************************************
@@ -1219,7 +1249,50 @@
   str.remove(str.indexOf('('), str.count());
   set_res_info(str);
 
+  if (nullptr != client.conn.playing) {
+    struct research *research = research_get(client_player());
+
+    if (research->researching == A_UNSET && research->tech_goal == A_UNSET
+        && !timer_active) {
+      res_timer->start(700);
+      blink_state = true;
+    }
+  }
+
   resize(sizeHint());
+}
+
+/**************************************************************************
+  Makes research text blinking ( it's slot for timeout() from res_timer)
+**************************************************************************/
+void info_label::blink()
+{
+  if (client_is_observer()) {
+    res_info->setStyleSheet(res_label_stylesheet);
+    res_timer->stop();
+    timer_active = false;
+    return;
+  }
+
+  if (blink_state) {
+    res_info->setStyleSheet(res_blink_label_stylesheet);
+  } else {
+    res_info->setStyleSheet(res_label_stylesheet);
+  }
+
+  if (nullptr != client.conn.playing) {
+    struct research *research = research_get(client_player());
+    if (timer_active && ( research->researching != A_UNSET
+        || research->tech_goal != A_UNSET)) {
+      res_timer->stop();
+      timer_active = false;
+      res_info->setStyleSheet(res_label_stylesheet);
+    } else {
+      timer_active = true;
+      res_timer->start(700);
+      blink_state = !blink_state;
+    }
+  }
 }
 
 /****************************************************************************

Modified: trunk/client/gui-qt/mapview.h
URL: 
http://svn.gna.org/viewcvs/freeciv/trunk/client/gui-qt/mapview.h?rev=31045&r1=31044&r2=31045&view=diff
==============================================================================
--- trunk/client/gui-qt/mapview.h       (original)
+++ trunk/client/gui-qt/mapview.h       Thu Dec 17 20:55:23 2015
@@ -268,6 +268,20 @@
 };
 
 /**************************************************************************
+  Label which will trigger clicked signal on mouse click
+**************************************************************************/
+class clicked_label : public QLabel
+{
+  Q_OBJECT
+public:
+  explicit clicked_label(QWidget *parent = 0);
+signals:
+  void clicked();
+protected:
+  void mousePressEvent(QMouseEvent *e);
+};
+
+/**************************************************************************
   Information label about civilization, turn, time etc
 **************************************************************************/
 class info_label : public fcwidget
@@ -277,7 +291,9 @@
   QLabel *eco_info;
   QLabel *time_label;
   QLabel *res_info;
-
+  QTimer *res_timer;
+  bool blink_state;
+  bool timer_active;
 public:
   info_label(QWidget *parent);
   virtual ~info_label();
@@ -288,8 +304,14 @@
   void set_res_info(const QString &info);
   void info_update();
   void update_menu();
-};
-
+private slots:
+  void blink();
+  void show_research_tab();
+};
+
+/**************************************************************************
+  End turn widget with government indicators and taxes
+**************************************************************************/
 class end_turn_area : public QFrame
 {
   Q_OBJECT


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

Reply via email to