From 9116c29739aa3e15eb5e052d335b1f76700f6b32 Mon Sep 17 00:00:00 2001 From: tpearson Date: Mon, 14 Dec 2009 08:57:48 +0000 Subject: * kpdf page rotate options * kdvi options dialog enhancements * djvu plugin for kviewshell git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdegraphics@1062216 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kpdf/ui/pageview.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++++++--- kpdf/ui/pageview.h | 2 ++ 2 files changed, 61 insertions(+), 3 deletions(-) (limited to 'kpdf/ui') diff --git a/kpdf/ui/pageview.cpp b/kpdf/ui/pageview.cpp index 247f1b1b..866b8d66 100644 --- a/kpdf/ui/pageview.cpp +++ b/kpdf/ui/pageview.cpp @@ -71,6 +71,7 @@ public: // view layout (columns and continuous in Settings), zoom and mouse PageView::ZoomMode zoomMode; float zoomFactor; + int rotation; PageView::MouseMode mouseMode; QPoint mouseGrabPos; QPoint mousePressPos; @@ -185,6 +186,7 @@ PageView::PageView( QWidget *parent, KPDFDocument *document ) d->document = document; d->zoomMode = (PageView::ZoomMode)KpdfSettings::zoomMode(); d->zoomFactor = KpdfSettings::zoomFactor(); + d->rotation = 0; d->mouseMode = MouseNormal; d->mouseMidStartY = -1; d->mouseOnRect = false; @@ -263,6 +265,14 @@ void PageView::setupActions( KActionCollection * ac ) d->aZoomFitText = new KToggleAction( i18n("Fit to &Text"), "viewmagfit", 0, ac, "zoom_fit_text" ); connect( d->aZoomFitText, SIGNAL( toggled( bool ) ), SLOT( slotFitToTextToggled( bool ) ) ); + // rotate actions + KAction *action; + action = new KAction( i18n("Rotate Right"), "rotate_cw", KShortcut( "Ctrl+Shift++" ), + this, SLOT( slotRotateRight() ), ac, "rotate_right" ); + + action = new KAction( i18n("Rotate Left"), "rotate_ccw", KShortcut( "Ctrl+Shift+-" ), + this, SLOT( slotRotateLeft() ), ac, "rotate_left" ); + // View-Layout actions d->aViewTwoPages = new KToggleAction( i18n("&Two Pages"), "view_left_right", 0, ac, "view_twopages" ); connect( d->aViewTwoPages, SIGNAL( toggled( bool ) ), SLOT( slotTwoPagesToggled( bool ) ) ); @@ -1867,7 +1877,7 @@ void PageView::slotRequestVisiblePixmaps( int newLeft, int newTop ) if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) ) { PixmapRequest * p = new PixmapRequest( - PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRIO, true ); + PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRIO, true, d->rotation ); requestedPixmaps.push_back( p ); } @@ -1907,7 +1917,7 @@ void PageView::slotRequestVisiblePixmaps( int newLeft, int newTop ) // request the pixmap if not already present if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) && i->width() > 0 ) requestedPixmaps.push_back( new PixmapRequest( - PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRELOAD_PRIO, true ) ); + PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRELOAD_PRIO, true, d->rotation ) ); } // add the page before the 'visible series' in preload @@ -1918,7 +1928,7 @@ void PageView::slotRequestVisiblePixmaps( int newLeft, int newTop ) // request the pixmap if not already present if ( !i->page()->hasPixmap( PAGEVIEW_ID, i->width(), i->height() ) && i->width() > 0 ) requestedPixmaps.push_back( new PixmapRequest( - PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRELOAD_PRIO, true ) ); + PAGEVIEW_ID, i->pageNumber(), i->width(), i->height(), PAGEVIEW_PRELOAD_PRIO, true, d->rotation ) ); } } @@ -2044,6 +2054,52 @@ void PageView::slotFitToTextToggled( bool on ) if ( on ) updateZoom( ZoomFitText ); } +void PageView::slotRotateRight() +{ + d->rotation = ( d->rotation + 90 ) % 360; + + QValueVector< PageViewItem * >::iterator iIt = d->items.begin(), iEnd = d->items.end(); + for ( ; iIt != iEnd; ++iIt ) + { + int r = const_cast((*iIt)->page())->rotation(); + r = ( r + 90 ) % 360; + + const_cast((*iIt)->page())->rotate90degrees(); + } + + // be sure to block updates to document's viewport + bool prevState = d->blockViewport; + d->blockViewport = true; + slotRelayoutPages(); + d->blockViewport = prevState; + // request pixmaps + slotRequestVisiblePixmaps(); +} + +void PageView::slotRotateLeft() +{ + d->rotation -= 90; + if ( d->rotation < 0 ) d->rotation += 360; + + QValueVector< PageViewItem * >::iterator iIt = d->items.begin(), iEnd = d->items.end(); + for ( ; iIt != iEnd; ++iIt ) + { + int r = const_cast((*iIt)->page())->rotation(); + r -= 90; + if ( r < 0 ) r += 360; + + const_cast((*iIt)->page())->rotate90degrees(); + } + + // be sure to block updates to document's viewport + bool prevState = d->blockViewport; + d->blockViewport = true; + slotRelayoutPages(); + d->blockViewport = prevState; + // request pixmaps + slotRequestVisiblePixmaps(); +} + void PageView::slotTwoPagesToggled( bool on ) { uint newColumns = on ? 2 : 1; diff --git a/kpdf/ui/pageview.h b/kpdf/ui/pageview.h index f6e40991..be082bd4 100644 --- a/kpdf/ui/pageview.h +++ b/kpdf/ui/pageview.h @@ -135,6 +135,8 @@ class PageView : public QScrollView, public DocumentObserver void slotFitToWidthToggled( bool ); void slotFitToPageToggled( bool ); void slotFitToTextToggled( bool ); + void slotRotateRight(); + void slotRotateLeft(); void slotTwoPagesToggled( bool ); void slotContinuousToggled( bool ); void slotSetMouseNormal(); -- cgit v1.2.1