Author: mir3x Date: Thu Dec 17 20:55:32 2015 New Revision: 31046 URL: http://svn.gna.org/viewcvs/freeciv?rev=31046&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: branches/S2_5/client/gui-qt/mapview.cpp branches/S2_5/client/gui-qt/mapview.h Modified: branches/S2_5/client/gui-qt/mapview.cpp URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/mapview.cpp?rev=31046&r1=31045&r2=31046&view=diff ============================================================================== --- branches/S2_5/client/gui-qt/mapview.cpp (original) +++ branches/S2_5/client/gui-qt/mapview.cpp Thu Dec 17 20:55:32 2015 @@ -29,6 +29,7 @@ // common #include "game.h" #include "map.h" +#include "research.h" // client #include "climisc.h" @@ -900,6 +901,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;"; @@ -979,6 +982,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 @@ -998,7 +1015,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); @@ -1013,7 +1030,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())); } @@ -1022,6 +1044,14 @@ **************************************************************************/ info_label::~info_label() { +} + +/*************************************************************************** + Slot for showing research tab +***************************************************************************/ +void info_label::show_research_tab() +{ + science_report_dialog_popup(true); } /************************************************************************** @@ -1214,7 +1244,50 @@ str.remove(str.indexOf('('), str.count()); set_res_info(str); + if (nullptr != client.conn.playing) { + struct player_research *research = player_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 player_research *research = player_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: branches/S2_5/client/gui-qt/mapview.h URL: http://svn.gna.org/viewcvs/freeciv/branches/S2_5/client/gui-qt/mapview.h?rev=31046&r1=31045&r2=31046&view=diff ============================================================================== --- branches/S2_5/client/gui-qt/mapview.h (original) +++ branches/S2_5/client/gui-qt/mapview.h Thu Dec 17 20:55:32 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