[rkward-cvs] SF.net SVN: rkward:[2438] trunk/rkward

tfry at users.sourceforge.net tfry at users.sourceforge.net
Fri Apr 3 12:41:39 UTC 2009


Revision: 2438
          http://rkward.svn.sourceforge.net/rkward/?rev=2438&view=rev
Author:   tfry
Date:     2009-04-03 12:41:38 +0000 (Fri, 03 Apr 2009)

Log Message:
-----------
Make argument hints react to focus and position changes

Modified Paths:
--------------
    trunk/rkward/ChangeLog
    trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
    trunk/rkward/rkward/windows/rkcommandeditorwindow.h

Modified: trunk/rkward/ChangeLog
===================================================================
--- trunk/rkward/ChangeLog	2009-03-31 19:52:39 UTC (rev 2437)
+++ trunk/rkward/ChangeLog	2009-04-03 12:41:38 UTC (rev 2438)
@@ -1,3 +1,4 @@
+- Fixed: Argument hints would always stay on top regardless of focus
 - Fix crash when reaching bottom of command history in context sensitive search
 		TODO: Backport needed?
 - Fix crash while inserting rows in a data.frame with string variables

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2009-03-31 19:52:39 UTC (rev 2437)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.cpp	2009-04-03 12:41:38 UTC (rev 2438)
@@ -2,7 +2,7 @@
                           rkcommandeditorwindow  -  description
                              -------------------
     begin                : Mon Aug 30 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -601,6 +601,9 @@
 	arghints_popup_text = new QLabel (arghints_popup);
 	layout->addWidget (arghints_popup_text);
 	arghints_popup->hide ();
+	active = false;
+
+	connect (&updater, SIGNAL (timeout()), this, SLOT (updateArgHintWindow()));
 }
 
 RKFunctionArgHinter::~RKFunctionArgHinter () {
@@ -693,13 +696,26 @@
 	// initialize and show popup
 	arghints_popup_text->setText (effective_symbol + " (" + static_cast<RFunctionObject*> (object)->printArgs () + ')');
 	arghints_popup->resize (arghints_popup_text->sizeHint () + QSize (2, 2));
+	active = true;
+	updater.start (50);
+	updateArgHintWindow ();
+}
+
+void RKFunctionArgHinter::updateArgHintWindow () {
+	RK_TRACE (COMMANDEDITOR);
+
+	if (!active) return;
+
 	arghints_popup->move (view->mapToGlobal (view->cursorPositionCoordinates () + QPoint (0, arghints_popup->height ())));
-	arghints_popup->show ();
+	if (view->hasFocus ()) arghints_popup->show ();
+	else arghints_popup->hide ();
 }
 
 void RKFunctionArgHinter::hideArgHint () {
 	RK_TRACE (COMMANDEDITOR);
 	arghints_popup->hide ();
+	active = false;
+	updater.stop ();
 }
 
 bool RKFunctionArgHinter::eventFilter (QObject *, QEvent *e) {

Modified: trunk/rkward/rkward/windows/rkcommandeditorwindow.h
===================================================================
--- trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2009-03-31 19:52:39 UTC (rev 2437)
+++ trunk/rkward/rkward/windows/rkcommandeditorwindow.h	2009-04-03 12:41:38 UTC (rev 2438)
@@ -2,7 +2,7 @@
                           rkcommandeditorwindow  -  description
                              -------------------
     begin                : Mon Aug 30 2004
-    copyright            : (C) 2004, 2006, 2007 by Thomas Friedrichsmeier
+    copyright            : (C) 2004, 2006, 2007, 2009 by Thomas Friedrichsmeier
     email                : tfry at users.sourceforge.net
  ***************************************************************************/
 
@@ -19,7 +19,8 @@
 
 #include <QWidget>
 #include <QVector>
-#include <qstring.h>
+#include <QTimer>
+#include <QString>
 
 #include <ktexteditor/view.h>
 #include <ktexteditor/document.h>
@@ -79,6 +80,8 @@
 public slots:
 	/** Internal worker function for tryArgHint () */
 	void tryArgHintNow ();
+
+	void updateArgHintWindow ();
 protected:
 	/** The (keypress) events of the view are filtered to determine, when to show / hide an argument hint */
 	bool eventFilter (QObject *, QEvent *e);
@@ -86,6 +89,9 @@
 	RKScriptContextProvider *provider;
 	KTextEditor::View *view;
 
+	/** A timer to refresh the hint window periodically. This is a bit sorry, but it's really hard to find out, when the view has been moved, or gains/loses focus. While possible, this approach uses much less code. */
+	QTimer updater;
+	bool active;
 	QFrame *arghints_popup;
 	QLabel *arghints_popup_text;
 };


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the rkward-tracker mailing list