r16473 by craig -
scribus-commit
scribus-commit at lists.scribus.net
Tue Mar 22 13:20:07 CET 2011
Author: craig
Date: Tue Mar 22 12:20:05 2011
New Revision: 16473
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16473
Log:
#9863: Improve cursor visibilty - visible while moving, and cursor stays visible longer after home/end/page up/down
Modified:
branches/Version135/Scribus/scribus/canvasmode_edit.cpp
branches/Version135/Scribus/scribus/canvasmode_edit.h
branches/Version135/Scribus/scribus/scribus.cpp
branches/Version135/Scribus/scribus/scribusview.h
Modified: branches/Version135/Scribus/scribus/canvasmode_edit.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16473&path=/branches/Version135/Scribus/scribus/canvasmode_edit.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/canvasmode_edit.cpp (original)
+++ branches/Version135/Scribus/scribus/canvasmode_edit.cpp Tue Mar 22 12:20:05 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)));
m_RulerGuide = -1;
+ m_longCursorTime=false;
}
inline bool CanvasMode_Edit::GetItem(PageItem** pi)
@@ -87,6 +88,35 @@
QRectF brect = currItem->getBoundingRect();
// qDebug() << "update cursor" << brect;
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();
+ }
}
}
@@ -141,12 +171,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 )
{
@@ -336,12 +370,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();
@@ -351,7 +379,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: branches/Version135/Scribus/scribus/canvasmode_edit.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16473&path=/branches/Version135/Scribus/scribus/canvasmode_edit.h
==============================================================================
--- branches/Version135/Scribus/scribus/canvasmode_edit.h (original)
+++ branches/Version135/Scribus/scribus/canvasmode_edit.h Tue Mar 22 12:20:05 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 m_RulerGuide;
+ bool m_longCursorTime;
private slots:
void blinkTextCursor();
Modified: branches/Version135/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16473&path=/branches/Version135/Scribus/scribus/scribus.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scribus.cpp (original)
+++ branches/Version135/Scribus/scribus/scribus.cpp Tue Mar 22 12:20:05 2011
@@ -1871,6 +1871,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;
}
Modified: branches/Version135/Scribus/scribus/scribusview.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16473&path=/branches/Version135/Scribus/scribus/scribusview.h
==============================================================================
--- branches/Version135/Scribus/scribus/scribusview.h (original)
+++ branches/Version135/Scribus/scribus/scribusview.h Tue Mar 22 12:20:05 2011
@@ -134,7 +134,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;
@@ -514,4 +515,9 @@
return m_dragTimerFired;
}
+inline CanvasMode* ScribusView::canvasMode()
+{
+ return m_canvasMode;
+}
+
#endif
More information about the scribus-commit
mailing list