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
-> wrong zoom buttons order (BR74248) (check consistancy with kdvi/kghostview/.. (not konq))
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)
-> porting Albert's link following
-> implementing async document generator using Albert's thread as the generation thread
-> reading aids (accessibility): mode: normal, invert, contrast, recolor bg/text
Done (sorted by inv.time)
-> continous mode
-> multiple pages per view
-> added continous mode
-> added multiple pages per view (gui selects 1 or 2 ppv)
-> 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 a 'search bar' with prune-as-you-type feature
......
......@@ -84,6 +84,14 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
document = new KPDFDocument();
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 []
m_splitter = new QSplitter( parentWidget, widgetName );
m_splitter->setOpaqueResize( true );
......@@ -99,6 +107,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
TOC * tocFrame = new TOC( m_toolBox, document );
m_toolBox->addItem( tocFrame, QIconSet(SmallIcon("text_left")), i18n("Contents") );
connect(tocFrame, SIGNAL(hasTOC(bool)), this, SLOT(enableTOC(bool)));
enableTOC( false );
QVBox * thumbsBox = new ThumbnailsBox( m_toolBox );
m_thumbnailList = new ThumbnailList( thumbsBox, document );
......@@ -108,13 +117,16 @@ Part::Part(QWidget *parentWidget, const char *widgetName,
m_toolBox->setCurrentItem( thumbsBox );
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 );
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 );
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']
m_pageView = new PageView( m_splitter, document );
......
......@@ -16,6 +16,9 @@
<Action name="zoom_out"/>
<Action name="zoom_fit_width"/>
<Action name="zoom_fit_page"/>
<Separator/>
<Action name="view_twopages"/>
<Action name="view_continous"/>
</Menu>
<Menu name="go"><text>&amp;Go</text>
<Action name="first_page"/>
......@@ -41,6 +44,7 @@
<Action name="zoom_out"/>
<!--Action name="zoom_fit_width"/-->
<!--Action name="zoom_fit_page"/-->
<Merge/>
<Separator/>
<Action name="view_twopages"/>
<Action name="view_continous"/>
......
......@@ -24,8 +24,8 @@
KPDFPage::KPDFPage( int page, float w, float h, int r )
: 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_sBottom( 0 ), m_text( 0 )
m_hilighting( false ), m_bookmarking( false ), m_sLeft( 0 ),
m_sTop( 0 ), m_sRight( 0 ), m_sBottom( 0 ), m_text( 0 )
{
}
......@@ -148,6 +148,11 @@ void KPDFPage::hilightLastSearch( bool on )
m_hilighting = on;
//if ( !on ) -> invalidate search rect?
}
void KPDFPage::bookmark( bool on )
{
m_bookmarking = on;
}
// END commands (paint / search)
......
......@@ -40,6 +40,7 @@ public:
float ratio() const { return m_height / m_width; }
float rotation() const { return m_rotation; }
bool isHilighted() const { return m_hilighting; }
bool isBookmarked() const { return m_bookmarking; }
bool hasPixmap( int id, int width, int height ) const;
bool hasSearchPage() const;
bool hasLink( int mouseX, int mouseY ) const;
......@@ -48,6 +49,7 @@ public:
void drawPixmap( int id, QPainter * p, const QRect & rect, int width, int height ) const;
bool hasText( const QString & text, bool strictCase, bool fromTop );
void hilightLastSearch( bool enabled );
void bookmark( bool enabled );
// set page contents
void setPixmap( int id, QPixmap * pixmap );
......@@ -58,7 +60,7 @@ public:
private:
int m_number, m_rotation;
float m_width, m_height;
bool m_hilighting;
bool m_hilighting, m_bookmarking;
double m_sLeft, m_sTop, m_sRight, m_sBottom;
QMap<int,QPixmap *> m_pixmaps;
......
......@@ -25,6 +25,7 @@
#include <kurldrag.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kpopupmenu.h>
#include <klocale.h>
#include <kconfigbase.h>
......@@ -52,6 +53,7 @@ public:
float zoomFactor;
PageView::MouseMode mouseMode;
QPoint mouseGrabPos;
QPoint mouseStartPos;
bool mouseOnLink;
// other stuff
......@@ -260,6 +262,7 @@ void PageView::contentsMousePressEvent( QMouseEvent * e )
if ( e->button() & LeftButton )
{
d->mouseGrabPos = e->globalPos();
d->mouseStartPos = d->mouseGrabPos;
setCursor( sizeAllCursor );
}
else if ( e->button() & RightButton )
......@@ -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 )
{
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
PageLink * link = *PAGE* ->findLink(e->x()/m_ppp, e->y()/m_ppp);
if ( link == d->pressedLink )
......@@ -489,28 +526,43 @@ void PageView::slotFitToWidthToggled( bool on )
void PageView::slotFitToPageToggled( bool on )
{
d->zoomMode = on ? ZoomFitPage : ZoomFixed;
slotUpdateView();
d->aZoomFitWidth->setChecked( false );
ZoomMode newZoomMode = on ? ZoomFitText : ZoomFixed;
if ( newZoomMode != d->zoomMode )
{
d->zoomMode = newZoomMode;
slotUpdateView();
d->aZoomFitWidth->setChecked( false );
}
}
void PageView::slotFitToTextToggled( bool on )
{
d->zoomMode = on ? ZoomFitText : ZoomFixed;
slotUpdateView();
d->aZoomFitWidth->setChecked( false );
ZoomMode newZoomMode = on ? ZoomFitText : ZoomFixed;
if ( newZoomMode != d->zoomMode )
{
d->zoomMode = newZoomMode;
slotUpdateView();
d->aZoomFitWidth->setChecked( false );
}
}
void PageView::slotTwoPagesToggled( bool on )
{
d->viewColumns = on ? 2 : 1;
reLayoutPages();
int newColumns = on ? 2 : 1;
if ( d->viewColumns != newColumns )
{
d->viewColumns = newColumns;
reLayoutPages();
}
}
void PageView::slotContinousToggled( bool on )
{
d->viewContinous = on;
reLayoutPages();
if ( d->viewContinous != on )
{
d->viewContinous = on;
reLayoutPages();
}
}
void PageView::slotSetMouseNormal()
......@@ -681,6 +733,28 @@ void PageView::reLayoutPages()
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
{
return verticalScrollBar()->value() == verticalScrollBar()->minValue();
......
......@@ -28,6 +28,7 @@ class KURL;
class KActionCollection;
class KConfigGroup;
class PageWidget;
class PageViewPrivate;
/**
......@@ -94,6 +95,7 @@ signals:
private:
void reLayoutPages();
PageWidget * pickPageOnPoint( int x, int y );
// FIXME REMOVE ME what does atTop() means if I see 4 tiled pages on screen ?
bool atTop() const;
......
......@@ -161,8 +161,21 @@ void PageWidget::paintEvent( QPaintEvent * e )
// draw page (inside pageClip rectangle)
p.translate( 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 );
#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.end();
......
......@@ -59,7 +59,7 @@ void SearchWidget::setupActions( KActionCollection * ac, KConfigGroup * config )
ss->setCheckedState(i18n("Hide Search Bar"));
connect( ss, SIGNAL( toggled( bool ) ), SLOT( slotToggleSearchBar( bool ) ) );
ss->setChecked( config->readBoolEntry( "ShowSearchBar", false ) );
ss->setChecked( config->readBoolEntry( "ShowSearchBar", true ) );
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