mirror of
https://invent.kde.org/graphics/okular
synced 2024-10-13 03:12:22 +00:00
fixes flickering in the statusbar
svn path=/trunk/kdegraphics/kdvi/; revision=196948
This commit is contained in:
parent
eadd5d85e6
commit
23b4c9a248
40
dviwin.cpp
40
dviwin.cpp
|
@ -82,6 +82,8 @@ dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
|||
setFocusPolicy(QWidget::StrongFocus);
|
||||
setFocus();
|
||||
|
||||
connect( &clearStatusBarTimer, SIGNAL(timeout()), this, SLOT(clearStatusBar()) );
|
||||
|
||||
// initialize the dvi machinery
|
||||
dviFile = 0;
|
||||
|
||||
|
@ -747,36 +749,44 @@ void dviWindow::paintEvent(QPaintEvent *e)
|
|||
}
|
||||
}
|
||||
|
||||
void dviWindow::clearStatusBar(void)
|
||||
{
|
||||
emit setStatusBarText( QString::null );
|
||||
}
|
||||
|
||||
void dviWindow::mouseMoveEvent ( QMouseEvent * e )
|
||||
{
|
||||
// If no mouse button pressed
|
||||
if ( e->state() == 0 ) {
|
||||
QString statusbarMessage;
|
||||
|
||||
// go through hyperlinks
|
||||
for(unsigned int i=0; i<hyperLinkList.size(); i++) {
|
||||
if (hyperLinkList[i].box.contains(e->pos())) {
|
||||
statusbarMessage = hyperLinkList[i].linkText;
|
||||
break;
|
||||
clearStatusBarTimer.stop();
|
||||
setCursor(pointingHandCursor);
|
||||
QString link = hyperLinkList[i].linkText;
|
||||
if ( link.startsWith("#") )
|
||||
link = link.remove(0,1);
|
||||
emit setStatusBarText( i18n("Link to %1").arg(link) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ( statusbarMessage == QString::null)
|
||||
setCursor(arrowCursor);
|
||||
else
|
||||
setCursor(pointingHandCursor);
|
||||
|
||||
// go through sourceHyperlinks
|
||||
// Cursor not over hyperlink? Then let the cursor be the usual arrow
|
||||
setCursor(arrowCursor);
|
||||
|
||||
// But maybe the cursor hovers over a sourceHyperlink?
|
||||
for(unsigned int i=0; i<sourceHyperLinkList.size(); i++) {
|
||||
if (sourceHyperLinkList[i].box.contains(e->pos())) {
|
||||
if ( statusbarMessage != QString::null)
|
||||
statusbarMessage += " | ";
|
||||
clearStatusBarTimer.stop();
|
||||
KStringHandler kstr;
|
||||
statusbarMessage += i18n("Line %1 of %2").arg(kstr.word(sourceHyperLinkList[i].linkText, "0")).arg(kstr.word(sourceHyperLinkList[i].linkText, "1:"));
|
||||
break;
|
||||
QString line = kstr.word(sourceHyperLinkList[i].linkText, "0");
|
||||
QString file = kstr.word(sourceHyperLinkList[i].linkText, "1:");
|
||||
emit setStatusBarText( i18n("Link to line %1 of %2").arg(line).arg(file) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
emit setStatusBarText( statusbarMessage );
|
||||
if (!clearStatusBarTimer.isActive())
|
||||
clearStatusBarTimer.start( 200, TRUE ); // clear the statusbar after 200 msec.
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
10
dviwin.h
10
dviwin.h
|
@ -143,6 +143,10 @@ public slots:
|
|||
void abortExternalProgramm(void);
|
||||
bool setFile(QString fname, QString ref = QString::null, bool sourceMarker=true);
|
||||
|
||||
/** simply emits "setStatusBarText( QString::null )". This is used
|
||||
in dviWindow::mouseMoveEvent(), see the explanation there. */;
|
||||
void clearStatusBar(void);
|
||||
|
||||
/** Displays the page of the first argument */
|
||||
void gotoPage(unsigned int page);
|
||||
|
||||
|
@ -196,6 +200,12 @@ private:
|
|||
void header_special(QString cp);
|
||||
void source_special(QString cp);
|
||||
|
||||
/* This timer is used to delay clearing of the statusbar. Clearing
|
||||
the statusbar is delayed to avoid awful flickering when the mouse
|
||||
moves over a block of text that contains source hyperlinks. The
|
||||
signal timeout() is connected to the method clearStatusBar() of
|
||||
*this. */
|
||||
QTimer clearStatusBarTimer;
|
||||
|
||||
QValueVector<DVI_Hyperlink> sourceHyperLinkList; // List of source-hyperlinks, for source-specials
|
||||
QString *source_href; // If not NULL, the text currently
|
||||
|
|
Loading…
Reference in a new issue