Commit 9ae96a86 authored by Enrico Ros's avatar Enrico Ros

mainly fixes. (starting rmb on page and bookmarking)

svn path=/branches/kpdf_experiments/kdegraphics/kpdf/; revision=349991
parent 4175f135
...@@ -15,15 +15,15 @@ More items ...@@ -15,15 +15,15 @@ More items
-> wrong zoom buttons order (BR74248) (check consistancy with kdvi/kghostview/.. (not konq)) -> wrong zoom buttons order (BR74248) (check consistancy with kdvi/kghostview/.. (not konq))
Porting / In progress on the branch (first item comes first): Porting / In progress on the branch (first item comes first):
-> restore single page mdoe (broke up) -> restore single page mode (broke up)
-> zoom buttons in sync with text (BR69092) -> zoom buttons in sync with text (BR69092)
-> porting Albert's link following -> porting Albert's link following
-> implementing async document generator using Albert's thread as the generation thread -> implementing async document generator using Albert's thread as the generation thread
-> reading aids (accessibility): mode: normal, invert, contrast, recolor bg/text -> reading aids (accessibility): mode: normal, invert, contrast, recolor bg/text
Done (sorted by inv.time) Done (sorted by inv.time)
-> continous mode -> added continous mode
-> multiple pages per view -> added multiple pages per view (gui selects 1 or 2 ppv)
-> added the option to open password protected files (from head) -> added the option to open password protected files (from head)
-> added the TOC from head (missing click and go functionality because it needs link following) -> added the TOC from head (missing click and go functionality because it needs link following)
-> added a 'search bar' with prune-as-you-type feature -> added a 'search bar' with prune-as-you-type feature
......
...@@ -84,6 +84,14 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -84,6 +84,14 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
document = new KPDFDocument(); document = new KPDFDocument();
connect( document, SIGNAL( pageChanged() ), this, SLOT( updateActions() ) ); connect( document, SIGNAL( pageChanged() ), this, SLOT( updateActions() ) );
// widgets: ^searchbar (toolbar containing label and SearchWidget)
// m_searchToolBar = new KToolBar( parentWidget, "searchBar" );
// m_searchToolBar->boxLayout()->setSpacing( KDialog::spacingHint() );
// QLabel * sLabel = new QLabel( i18n( "&Search:" ), m_searchToolBar, "kde toolbar widget" );
// m_searchWidget = new SearchWidget( m_searchToolBar, document );
// sLabel->setBuddy( m_searchWidget );
// m_searchToolBar->setStretchableWidget( m_searchWidget );
// widgets: [] splitter [] // widgets: [] splitter []
m_splitter = new QSplitter( parentWidget, widgetName ); m_splitter = new QSplitter( parentWidget, widgetName );
m_splitter->setOpaqueResize( true ); m_splitter->setOpaqueResize( true );
...@@ -99,6 +107,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -99,6 +107,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
TOC * tocFrame = new TOC( m_toolBox, document ); TOC * tocFrame = new TOC( m_toolBox, document );
m_toolBox->addItem( tocFrame, QIconSet(SmallIcon("text_left")), i18n("Contents") ); m_toolBox->addItem( tocFrame, QIconSet(SmallIcon("text_left")), i18n("Contents") );
connect(tocFrame, SIGNAL(hasTOC(bool)), this, SLOT(enableTOC(bool))); connect(tocFrame, SIGNAL(hasTOC(bool)), this, SLOT(enableTOC(bool)));
enableTOC( false );
QVBox * thumbsBox = new ThumbnailsBox( m_toolBox ); QVBox * thumbsBox = new ThumbnailsBox( m_toolBox );
m_thumbnailList = new ThumbnailList( thumbsBox, document ); m_thumbnailList = new ThumbnailList( thumbsBox, document );
...@@ -108,13 +117,16 @@ Part::Part(QWidget *parentWidget, const char *widgetName, ...@@ -108,13 +117,16 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_toolBox->setCurrentItem( thumbsBox ); m_toolBox->setCurrentItem( thumbsBox );
QFrame * bookmarksFrame = new QFrame( m_toolBox ); QFrame * bookmarksFrame = new QFrame( m_toolBox );
m_toolBox->addItem( bookmarksFrame, QIconSet(SmallIcon("bookmark")), i18n("Bookmarks") ); int iIdx = m_toolBox->addItem( bookmarksFrame, QIconSet(SmallIcon("bookmark")), i18n("Bookmarks") );
m_toolBox->setItemEnabled( iIdx, false );
QFrame * editFrame = new QFrame( m_toolBox ); QFrame * editFrame = new QFrame( m_toolBox );
m_toolBox->addItem( editFrame, QIconSet(SmallIcon("pencil")), i18n("Annotations") ); iIdx = m_toolBox->addItem( editFrame, QIconSet(SmallIcon("pencil")), i18n("Annotations") );
m_toolBox->setItemEnabled( iIdx, false );
QFrame * moreFrame = new QFrame( m_toolBox ); QFrame * moreFrame = new QFrame( m_toolBox );
m_toolBox->addItem( moreFrame, QIconSet(SmallIcon("fork")), i18n("More stuff..") ); iIdx = m_toolBox->addItem( moreFrame, QIconSet(SmallIcon("fork")), i18n("More stuff..") );
m_toolBox->setItemEnabled( iIdx, false );
// widgets: [] | [right 'pageView'] // widgets: [] | [right 'pageView']
m_pageView = new PageView( m_splitter, document ); m_pageView = new PageView( m_splitter, document );
......
...@@ -16,6 +16,9 @@ ...@@ -16,6 +16,9 @@
<Action name="zoom_out"/> <Action name="zoom_out"/>
<Action name="zoom_fit_width"/> <Action name="zoom_fit_width"/>
<Action name="zoom_fit_page"/> <Action name="zoom_fit_page"/>
<Separator/>
<Action name="view_twopages"/>
<Action name="view_continous"/>
</Menu> </Menu>
<Menu name="go"><text>&amp;Go</text> <Menu name="go"><text>&amp;Go</text>
<Action name="first_page"/> <Action name="first_page"/>
...@@ -41,6 +44,7 @@ ...@@ -41,6 +44,7 @@
<Action name="zoom_out"/> <Action name="zoom_out"/>
<!--Action name="zoom_fit_width"/--> <!--Action name="zoom_fit_width"/-->
<!--Action name="zoom_fit_page"/--> <!--Action name="zoom_fit_page"/-->
<Merge/>
<Separator/> <Separator/>
<Action name="view_twopages"/> <Action name="view_twopages"/>
<Action name="view_continous"/> <Action name="view_continous"/>
......
...@@ -24,8 +24,8 @@ ...@@ -24,8 +24,8 @@
KPDFPage::KPDFPage( int page, float w, float h, int r ) KPDFPage::KPDFPage( int page, float w, float h, int r )
: m_number( page ), m_rotation( r ), m_width( w ), m_height( h ), : m_number( page ), m_rotation( r ), m_width( w ), m_height( h ),
m_hilighting( false ), m_sLeft( 0 ), m_sTop( 0 ), m_sRight( 0 ), m_hilighting( false ), m_bookmarking( false ), m_sLeft( 0 ),
m_sBottom( 0 ), m_text( 0 ) m_sTop( 0 ), m_sRight( 0 ), m_sBottom( 0 ), m_text( 0 )
{ {
} }
...@@ -148,6 +148,11 @@ void KPDFPage::hilightLastSearch( bool on ) ...@@ -148,6 +148,11 @@ void KPDFPage::hilightLastSearch( bool on )
m_hilighting = on; m_hilighting = on;
//if ( !on ) -> invalidate search rect? //if ( !on ) -> invalidate search rect?
} }
void KPDFPage::bookmark( bool on )
{
m_bookmarking = on;
}
// END commands (paint / search) // END commands (paint / search)
......
...@@ -40,6 +40,7 @@ public: ...@@ -40,6 +40,7 @@ public:
float ratio() const { return m_height / m_width; } float ratio() const { return m_height / m_width; }
float rotation() const { return m_rotation; } float rotation() const { return m_rotation; }
bool isHilighted() const { return m_hilighting; } bool isHilighted() const { return m_hilighting; }
bool isBookmarked() const { return m_bookmarking; }
bool hasPixmap( int id, int width, int height ) const; bool hasPixmap( int id, int width, int height ) const;
bool hasSearchPage() const; bool hasSearchPage() const;
bool hasLink( int mouseX, int mouseY ) const; bool hasLink( int mouseX, int mouseY ) const;
...@@ -48,6 +49,7 @@ public: ...@@ -48,6 +49,7 @@ public:
void drawPixmap( int id, QPainter * p, const QRect & rect, int width, int height ) const; void drawPixmap( int id, QPainter * p, const QRect & rect, int width, int height ) const;
bool hasText( const QString & text, bool strictCase, bool fromTop ); bool hasText( const QString & text, bool strictCase, bool fromTop );
void hilightLastSearch( bool enabled ); void hilightLastSearch( bool enabled );
void bookmark( bool enabled );
// set page contents // set page contents
void setPixmap( int id, QPixmap * pixmap ); void setPixmap( int id, QPixmap * pixmap );
...@@ -58,7 +60,7 @@ public: ...@@ -58,7 +60,7 @@ public:
private: private:
int m_number, m_rotation; int m_number, m_rotation;
float m_width, m_height; float m_width, m_height;
bool m_hilighting; bool m_hilighting, m_bookmarking;
double m_sLeft, m_sTop, m_sRight, m_sBottom; double m_sLeft, m_sTop, m_sRight, m_sBottom;
QMap<int,QPixmap *> m_pixmaps; QMap<int,QPixmap *> m_pixmaps;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <kurldrag.h> #include <kurldrag.h>
#include <kaction.h> #include <kaction.h>
#include <kactioncollection.h> #include <kactioncollection.h>
#include <kpopupmenu.h>
#include <klocale.h> #include <klocale.h>
#include <kconfigbase.h> #include <kconfigbase.h>
...@@ -52,6 +53,7 @@ public: ...@@ -52,6 +53,7 @@ public:
float zoomFactor; float zoomFactor;
PageView::MouseMode mouseMode; PageView::MouseMode mouseMode;
QPoint mouseGrabPos; QPoint mouseGrabPos;
QPoint mouseStartPos;
bool mouseOnLink; bool mouseOnLink;
// other stuff // other stuff
...@@ -260,6 +262,7 @@ void PageView::contentsMousePressEvent( QMouseEvent * e ) ...@@ -260,6 +262,7 @@ void PageView::contentsMousePressEvent( QMouseEvent * e )
if ( e->button() & LeftButton ) if ( e->button() & LeftButton )
{ {
d->mouseGrabPos = e->globalPos(); d->mouseGrabPos = e->globalPos();
d->mouseStartPos = d->mouseGrabPos;
setCursor( sizeAllCursor ); setCursor( sizeAllCursor );
} }
else if ( e->button() & RightButton ) else if ( e->button() & RightButton )
...@@ -282,13 +285,47 @@ void PageView::contentsMousePressEvent( QMouseEvent * e ) ...@@ -282,13 +285,47 @@ void PageView::contentsMousePressEvent( QMouseEvent * e )
} }
} }
void PageView::contentsMouseReleaseEvent( QMouseEvent * ) void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
{ {
PageWidget * page = pickPageOnPoint( e->x(), e->y() );
switch ( d->mouseMode ) switch ( d->mouseMode )
{ {
case MouseNormal: // end drag / follow link case MouseNormal: // end drag / follow link
setCursor( arrowCursor ); if ( e->button() & LeftButton )
{
setCursor( arrowCursor );
// check if it was a click, in that case select the page
if ( e->globalPos() == d->mouseStartPos && page )
d->document->slotSetCurrentPage( page->pageNumber() );
}
else if ( e->button() == Qt::RightButton && page )
{
// If over a page display a popup menu
//FIXME ADD BOOKMARKING STUFF IN DOCUMENT !!!!!!!!!
KPDFPage * kpdfPage = (KPDFPage *)d->document->page( page->pageNumber() );
KPopupMenu * m_popup = new KPopupMenu( this, "rmb popup" );
m_popup->insertTitle( i18n( "Page %1" ).arg( page->pageNumber() ) );
if ( kpdfPage->isBookmarked() )
m_popup->insertItem( SmallIcon("bookmark"), i18n("Remove Bookmark"), 1 );
else
m_popup->insertItem( SmallIcon("bookmark"), i18n("Add Bookmark"), 1 );
m_popup->insertItem( SmallIcon("viewmagfit"), i18n("Fit Page"), 2 );
m_popup->insertItem( SmallIcon("pencil"), i18n("Edit"), 3 );
switch ( m_popup->exec(QCursor::pos()) )
{
case 1:
kpdfPage->bookmark( !kpdfPage->isBookmarked() );
break;
case 2:
slotTwoPagesToggled( false );
slotFitToWidthToggled( true );
d->document->slotSetCurrentPage( page->pageNumber() );
break;
case 3:
//TODO switch to edit
break;
}
}
/* TODO Albert /* TODO Albert
PageLink * link = *PAGE* ->findLink(e->x()/m_ppp, e->y()/m_ppp); PageLink * link = *PAGE* ->findLink(e->x()/m_ppp, e->y()/m_ppp);
if ( link == d->pressedLink ) if ( link == d->pressedLink )
...@@ -489,28 +526,43 @@ void PageView::slotFitToWidthToggled( bool on ) ...@@ -489,28 +526,43 @@ void PageView::slotFitToWidthToggled( bool on )
void PageView::slotFitToPageToggled( bool on ) void PageView::slotFitToPageToggled( bool on )
{ {
d->zoomMode = on ? ZoomFitPage : ZoomFixed; ZoomMode newZoomMode = on ? ZoomFitText : ZoomFixed;
slotUpdateView(); if ( newZoomMode != d->zoomMode )
d->aZoomFitWidth->setChecked( false ); {
d->zoomMode = newZoomMode;
slotUpdateView();
d->aZoomFitWidth->setChecked( false );
}
} }
void PageView::slotFitToTextToggled( bool on ) void PageView::slotFitToTextToggled( bool on )
{ {
d->zoomMode = on ? ZoomFitText : ZoomFixed; ZoomMode newZoomMode = on ? ZoomFitText : ZoomFixed;
slotUpdateView(); if ( newZoomMode != d->zoomMode )
d->aZoomFitWidth->setChecked( false ); {
d->zoomMode = newZoomMode;
slotUpdateView();
d->aZoomFitWidth->setChecked( false );
}
} }
void PageView::slotTwoPagesToggled( bool on ) void PageView::slotTwoPagesToggled( bool on )
{ {
d->viewColumns = on ? 2 : 1; int newColumns = on ? 2 : 1;
reLayoutPages(); if ( d->viewColumns != newColumns )
{
d->viewColumns = newColumns;
reLayoutPages();
}
} }
void PageView::slotContinousToggled( bool on ) void PageView::slotContinousToggled( bool on )
{ {
d->viewContinous = on; if ( d->viewContinous != on )
reLayoutPages(); {
d->viewContinous = on;
reLayoutPages();
}
} }
void PageView::slotSetMouseNormal() void PageView::slotSetMouseNormal()
...@@ -681,6 +733,28 @@ void PageView::reLayoutPages() ...@@ -681,6 +733,28 @@ void PageView::reLayoutPages()
d->dirty = false; d->dirty = false;
} }
PageWidget * PageView::pickPageOnPoint( int x, int y )
{
PageWidget * page = 0;
QValueVector< PageWidget * >::iterator pIt = d->pages.begin(), pEnd = d->pages.end();
for ( ; pIt != pEnd; ++pIt )
{
PageWidget * p = *pIt;
int pLeft = childX( p ),
pRight = pLeft + p->widthHint(),
pTop = childY( p ),
pBottom = pTop + p->heightHint();
// little optimized, stops if found or probably quits on the next row
if ( x > pLeft && x < pRight && y < pBottom )
{
if ( y > pTop )
page = p;
break;
}
}
return page;
}
bool PageView::atTop() const bool PageView::atTop() const
{ {
return verticalScrollBar()->value() == verticalScrollBar()->minValue(); return verticalScrollBar()->value() == verticalScrollBar()->minValue();
......
...@@ -28,6 +28,7 @@ class KURL; ...@@ -28,6 +28,7 @@ class KURL;
class KActionCollection; class KActionCollection;
class KConfigGroup; class KConfigGroup;
class PageWidget;
class PageViewPrivate; class PageViewPrivate;
/** /**
...@@ -94,6 +95,7 @@ signals: ...@@ -94,6 +95,7 @@ signals:
private: private:
void reLayoutPages(); void reLayoutPages();
PageWidget * pickPageOnPoint( int x, int y );
// FIXME REMOVE ME what does atTop() means if I see 4 tiled pages on screen ? // FIXME REMOVE ME what does atTop() means if I see 4 tiled pages on screen ?
bool atTop() const; bool atTop() const;
......
...@@ -161,8 +161,21 @@ void PageWidget::paintEvent( QPaintEvent * e ) ...@@ -161,8 +161,21 @@ void PageWidget::paintEvent( QPaintEvent * e )
// draw page (inside pageClip rectangle) // draw page (inside pageClip rectangle)
p.translate( m_marginLeft, m_marginTop ); p.translate( m_marginLeft, m_marginTop );
pageClip.moveBy( -m_marginLeft, -m_marginTop ); pageClip.moveBy( -m_marginLeft, -m_marginTop );
// TODO: accessibility settings: p.setRasterOp( Qt::NotCopyROP ); #if 0
// TODO: accessibility settings
p.setRasterOp( Qt::NotCopyROP );
#endif
m_page->drawPixmap( PAGEVIEW_ID, &p, pageClip, m_pixmapWidth, m_pixmapHeight ); m_page->drawPixmap( PAGEVIEW_ID, &p, pageClip, m_pixmapWidth, m_pixmapHeight );
#if 0
// TODO: overlays <ONLY FOR FUN> :-)
#include <qpixmap.h>
#include <kstandarddirs.h>
if ( m_pixmapWidth > 64 && m_pixmapHeight > 64 )
{
QPixmap page( locate("data","kpdf/bookmark_corner.png") );
p.drawPixmap( m_pixmapWidth - page.width(), 0, page );
}
#endif
p.translate( -m_marginLeft, -m_marginTop ); p.translate( -m_marginLeft, -m_marginTop );
p.end(); p.end();
......
...@@ -59,7 +59,7 @@ void SearchWidget::setupActions( KActionCollection * ac, KConfigGroup * config ) ...@@ -59,7 +59,7 @@ void SearchWidget::setupActions( KActionCollection * ac, KConfigGroup * config )
ss->setCheckedState(i18n("Hide Search Bar")); ss->setCheckedState(i18n("Hide Search Bar"));
connect( ss, SIGNAL( toggled( bool ) ), SLOT( slotToggleSearchBar( bool ) ) ); connect( ss, SIGNAL( toggled( bool ) ), SLOT( slotToggleSearchBar( bool ) ) );
ss->setChecked( config->readBoolEntry( "ShowSearchBar", false ) ); ss->setChecked( config->readBoolEntry( "ShowSearchBar", true ) );
slotToggleSearchBar( ss->isChecked() ); slotToggleSearchBar( ss->isChecked() );
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment