Give a tooltip in the page view for every kind of lnk we support.

Also improve a bit the one in the presentation mode, and give a message when the link is a "go to the page x" link.
Implements KPDF wish #131361.

svn path=/trunk/playground/graphics/okular/; revision=588899
remotes/origin/KDE/4.0
Pino Toscano 20 years ago
parent a9a27a9894
commit 853d6c70a7
  1. 2
      core/link.cpp
  2. 35
      ui/pageview.cpp
  3. 2
      ui/pageview.h
  4. 5
      ui/presentationwidget.cpp

@ -27,7 +27,7 @@ QString Link::linkTip() const
// Link Tips
QString LinkGoto::linkTip() const
{
return m_extFileName.isEmpty() ? "" : i18n("Open external file");
return m_extFileName.isEmpty() ? ( m_vp.pageNumber != -1 ? i18n( "Go to page %1", m_vp.pageNumber ) : "" ) : i18n("Open external file");
}
QString LinkExecute::linkTip() const

@ -28,6 +28,7 @@
#include <qdatetime.h>
#include <qpushbutton.h>
#include <qset.h>
#include <qtooltip.h>
#include <qapplication.h>
#include <qclipboard.h>
#include <QX11Info>
@ -602,6 +603,40 @@ bool PageView::canUnloadPixmap( int pageNumber )
//END DocumentObserver inherited methods
//BEGIN widget events
bool PageView::event( QEvent* e )
{
if ( e->type() == QEvent::ToolTip )
{
QHelpEvent * he = (QHelpEvent*)e;
PageViewItem * pageItem = pickItemOnPoint( he->x() + contentsX(), he->y() + contentsY() );
const Okular::ObjectRect * rect = 0;
const Okular::Link * link = 0;
if ( pageItem )
{
double nX = (double)( he->x() + contentsX() - pageItem->geometry().left() ) / (double)pageItem->width(),
nY = (double)( he->y() + contentsY() - pageItem->geometry().top() ) / (double)pageItem->height();
rect = pageItem->page()->getObjectRect( Okular::ObjectRect::Link, nX, nY, pageItem->width(), pageItem->height() );
if ( rect )
link = static_cast< const Okular::Link * >( rect->pointer() );
}
if ( link )
{
// TODO make the rect for the object work
QRect r = rect->boundingRect( pageItem->width(), pageItem->height() );
r.translate( pageItem->geometry().left(), pageItem->geometry().top() );
QString tip = link->linkTip();
if ( !tip.isEmpty() )
QToolTip::showText( he->globalPos(), tip, this, r );
}
e->accept();
return true;
}
else
// do not stop the event
return Q3ScrollView::event( e );
}
void PageView::viewportPaintEvent( QPaintEvent * pe )
{

@ -93,6 +93,8 @@ class PageView : public Q3ScrollView, public Okular::DocumentObserver
void rightClick( const Okular::Page *, const QPoint & );
protected:
bool event( QEvent* );
// viewport events
void viewportPaintEvent( QPaintEvent * pe );
void viewportResizeEvent( QResizeEvent* );

@ -191,13 +191,14 @@ bool PresentationWidget::event( QEvent * e )
{
QHelpEvent * he = (QHelpEvent*)e;
const Okular::Link * link = getLink( he->x(), he->y(), 0 );
QRect r;
const Okular::Link * link = getLink( he->x(), he->y(), &r );
if ( link )
{
QString tip = link->linkTip();
if ( !tip.isEmpty() )
QToolTip::showText( he->globalPos(), tip, this );
QToolTip::showText( he->globalPos(), tip, this, r );
}
e->accept();
return true;

Loading…
Cancel
Save