r16474 by craig -

scribus-commit scribus-commit at lists.scribus.net
Tue Mar 22 13:38:07 CET 2011


Author: craig
Date: Tue Mar 22 12:38:07 2011
New Revision: 16474

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16474
Log:
#9863: Improve cursor visibilty - visible while moving, and cursor stays visible longer after home/end/page up/down, fwd port

Modified:
    trunk/Scribus/scribus/canvasmode_edit.cpp
    trunk/Scribus/scribus/canvasmode_edit.h
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribusview.h

Modified: trunk/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16474&path=/trunk/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.cpp (original)
+++ trunk/Scribus/scribus/canvasmode_edit.cpp Tue Mar 22 12:38:07 2011
@@ -70,6 +70,7 @@
 	connect(m_blinker, SIGNAL(timeout()), this, SLOT(blinkTextCursor()));
 	connect(view->horizRuler, SIGNAL(MarkerMoved(double, double)), this, SLOT(rulerPreview(double, double)));
 	mRulerGuide = -1;
+	m_longCursorTime=false;
 }
 
 inline bool CanvasMode_Edit::GetItem(PageItem** pi)
@@ -89,6 +90,36 @@
 		m_canvas->update(QRectF(m_canvas->canvasToLocal(brect.topLeft()), QSizeF(brect.width(),brect.height())*m_canvas->scale()).toRect());
 	}
 }
+
+void CanvasMode_Edit::keyPressEvent(QKeyEvent *e)
+{
+	PageItem* currItem;
+	if (GetItem(&currItem))
+	{
+		PageItem_TextFrame* textframe = currItem->asTextFrame();
+		if (textframe)
+		{
+			m_cursorVisible=true;
+			int kk = e->key();
+			switch (kk)
+			{
+				case Qt::Key_PageUp:
+				case Qt::Key_PageDown:
+				case Qt::Key_Up:
+				case Qt::Key_Down:
+				case Qt::Key_Home:
+				case Qt::Key_End:
+					m_longCursorTime=true;
+					break;
+				default:
+					m_longCursorTime=false;
+					break;
+			}
+			blinkTextCursor();
+		}
+	}
+}
+
 
 
 void CanvasMode_Edit::rulerPreview(double base, double xp)
@@ -174,12 +205,16 @@
 
 void CanvasMode_Edit::drawTextCursor ( QPainter *p, PageItem_TextFrame* textframe )
 {
-	if(textframe->lastInFrame() < 0)
-		return;
-	if ( m_blinkTime.elapsed() > qApp->cursorFlashTime() / 2 )
+//	CB: If we have this test in we get no initial cursor placed for a new text frame
+//	if(textframe->lastInFrame() < 0)
+//		return;
+	if ((!m_longCursorTime && m_blinkTime.elapsed() > qApp->cursorFlashTime() / 2 ) ||
+		(m_longCursorTime && m_blinkTime.elapsed() > qApp->cursorFlashTime() )
+		)
 	{
 		m_cursorVisible = !m_cursorVisible;
 		m_blinkTime.restart();
+		m_longCursorTime=false;
 	}
 	if ( m_cursorVisible )
 	{
@@ -369,12 +404,6 @@
 	oldCp = Cp = -1;
 	frameResizeHandle = -1;
 	setModeCursor();
-	if (m_doc->appMode == modeEdit)
-	{
-		m_blinker->start(500);
-		m_blinkTime.start();
-		m_cursorVisible = true;
-	}
 	if (fromGesture)
 	{
 		m_view->update();
@@ -384,7 +413,16 @@
 	if(GetItem(&it))
 	{
 		if (it->asTextFrame())
+		{
 			m_canvas->setupEditHRuler(it, true);
+			if (m_doc->appMode == modeEdit)
+			{
+				m_blinker->start(200);
+				m_blinkTime.start();
+				m_cursorVisible = true;
+				blinkTextCursor();
+			}
+		}
 	}
 }
 

Modified: trunk/Scribus/scribus/canvasmode_edit.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16474&path=/trunk/Scribus/scribus/canvasmode_edit.h
==============================================================================
--- trunk/Scribus/scribus/canvasmode_edit.h (original)
+++ trunk/Scribus/scribus/canvasmode_edit.h Tue Mar 22 12:38:07 2011
@@ -44,10 +44,14 @@
 	
 	virtual void activate(bool);
 	virtual void deactivate(bool);
+
 	virtual void mouseDoubleClickEvent(QMouseEvent *m);
 	virtual void mouseReleaseEvent(QMouseEvent *m);
 	virtual void mouseMoveEvent(QMouseEvent *m);
 	virtual void mousePressEvent(QMouseEvent *m);
+
+	virtual void keyPressEvent(QKeyEvent *e);
+
 	virtual void drawControls(QPainter* p);
 
 // protected:
@@ -70,6 +74,7 @@
 	QTimer* m_blinker;
 	bool m_lastPosWasOverGuide;
 	double mRulerGuide;
+	bool m_longCursorTime;
 
 private slots:
 	void blinkTextCursor();

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16474&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Tue Mar 22 12:38:07 2011
@@ -1515,6 +1515,7 @@
 				if (currItem->itemType() == PageItem::TextFrame)
 				{
 					bool kr=keyrep;
+					view->canvasMode()->keyPressEvent(k); //Hack for 1.4.x for stopping the cursor blinking while moving about
 					currItem->handleModeEditKey(k, keyrep);
 					keyrep=kr;
 				}
@@ -7892,7 +7893,7 @@
 		msg2 += tr("Until this is remedied, you cannot import EPS images or use PostScript Print Preview. ")+"\n";
 #endif
 		//msg2 += tr("Please read our <a href=\"http://wiki.scribus.net/index.php/Ghostscript\">help and installation instructions</a>.") + "</qt>";
-		msg2 += tr("Click the Help button read Scribus-related Ghostscript help and installation instructions.") + "</qt>";
+		msg2 += tr("Click the Help button to read Scribus-related Ghostscript help and installation instructions.") + "</qt>";
 		QMessageBox msgBox;
 		msgBox.addButton(QMessageBox::Ok);
 		msgBox.addButton(QMessageBox::Help);

Modified: trunk/Scribus/scribus/scribusview.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16474&path=/trunk/Scribus/scribus/scribusview.h
==============================================================================
--- trunk/Scribus/scribus/scribusview.h (original)
+++ trunk/Scribus/scribus/scribusview.h Tue Mar 22 12:38:07 2011
@@ -141,7 +141,8 @@
   /** Dokument zu dem die Seite gehoert */
 	ScribusDoc * const Doc;
 	Canvas * const m_canvas;
-	CanvasMode* m_canvasMode; // might be a CanvasGesture
+	CanvasMode* m_canvasMode; // might be a CanvasGesture FIXME make private
+	CanvasMode* canvasMode();
 	QMap<int,CanvasMode*> modeInstances;
 	ApplicationPrefs * const Prefs;
 	UndoManager * const undoManager;
@@ -476,4 +477,9 @@
 	return m_dragTimerFired;
 }
 
+inline CanvasMode* ScribusView::canvasMode()
+{
+	return m_canvasMode;
+}
+
 #endif




More information about the scribus-commit mailing list