Author: mir3x
Date: Sun Jan 29 21:22:28 2017
New Revision: 34903

URL: http://svn.gna.org/viewcvs/freeciv?rev=34903&view=rev
Log:
Qt client - show tooltip in research diagram with 500msecs delay

See patch #8092


Modified:
    branches/S3_0/client/gui-qt/repodlgs.cpp
    branches/S3_0/client/gui-qt/repodlgs.h

Modified: branches/S3_0/client/gui-qt/repodlgs.cpp
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-qt/repodlgs.cpp?rev=34903&r1=34902&r2=34903&view=diff
==============================================================================
--- branches/S3_0/client/gui-qt/repodlgs.cpp    (original)
+++ branches/S3_0/client/gui-qt/repodlgs.cpp    Sun Jan 29 21:22:28 2017
@@ -245,6 +245,7 @@
 ****************************************************************************/
 void research_diagram::reset()
 {
+  timer_active = false;
   if (req != NULL) {
     destroy_reqtree(req);
   }
@@ -350,11 +351,29 @@
       }
       tt_text = split_text(tt_text, true);
       tt_text = def_str + tt_text;
-      tt_text = tt_text.trimmed();
-      if (QToolTip::text() == "") {
-        QToolTip::showText(event->globalPos(), tt_text, this, rttp->rect);
+      tooltip_text = tt_text.trimmed();
+      tooltip_rect = rttp->rect;
+      tooltip_pos = event->globalPos();
+      if (QToolTip::isVisible() == false && timer_active == false) {
+        timer_active = true;
+        QTimer::singleShot(500, this, SLOT(show_tooltip()));
       }
     }
+  }
+}
+
+/****************************************************************************
+  Slot for timer used to show tooltip
+****************************************************************************/
+void research_diagram::show_tooltip()
+{
+  QPoint cp;
+
+  timer_active = false;
+  cp = QCursor::pos();
+  if (qAbs(cp.x() - tooltip_pos.x()) < 4
+      && qAbs(cp.y() - tooltip_pos.y()) < 4) {
+    QToolTip::showText(cp, tooltip_text, this, tooltip_rect);
   }
 }
 

Modified: branches/S3_0/client/gui-qt/repodlgs.h
URL: 
http://svn.gna.org/viewcvs/freeciv/branches/S3_0/client/gui-qt/repodlgs.h?rev=34903&r1=34902&r2=34903&view=diff
==============================================================================
--- branches/S3_0/client/gui-qt/repodlgs.h      (original)
+++ branches/S3_0/client/gui-qt/repodlgs.h      Sun Jan 29 21:22:28 2017
@@ -79,7 +79,8 @@
   void update_reqtree();
   void reset();
   QSize size();
-
+private slots:
+  void show_tooltip();
 private:
   void mousePressEvent(QMouseEvent *event);
   void mouseMoveEvent(QMouseEvent *event);
@@ -87,9 +88,14 @@
   void create_tooltip_help();
   struct canvas *pcanvas;
   struct reqtree *req;
+  bool timer_active;
   int width;
   int height;
   QList<req_tooltip_help*> tt_help;
+  QPoint tooltip_pos;
+  QString tooltip_text;
+  QRect tooltip_rect;
+  
 };
 
 /****************************************************************************


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

Reply via email to