summaryrefslogtreecommitdiffstats
path: root/kpdf/ui
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-14 08:57:48 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-12-14 08:57:48 +0000
commit9116c29739aa3e15eb5e052d335b1f76700f6b32 (patch)
treec7301ec627341f5207fba729b3e2ad4e6cb9dfb0 /kpdf/ui
parent47d455dd55be855e4cc691c32f687f723d9247ee (diff)
downloadtdegraphics-9116c29739aa3e15eb5e052d335b1f76700f6b32.tar.gz
tdegraphics-9116c29739aa3e15eb5e052d335b1f76700f6b32.zip
* 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
Diffstat (limited to 'kpdf/ui')
-rw-r--r--kpdf/ui/pageview.cpp62
-rw-r--r--kpdf/ui/pageview.h2
2 files changed, 61 insertions, 3 deletions
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<KPDFPage*>((*iIt)->page())->rotation();
+ r = ( r + 90 ) % 360;
+
+ const_cast<KPDFPage*>((*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<KPDFPage*>((*iIt)->page())->rotation();
+ r -= 90;
+ if ( r < 0 ) r += 360;
+
+ const_cast<KPDFPage*>((*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();