summaryrefslogtreecommitdiffstats
path: root/kpdf
diff options
context:
space:
mode:
authorMavridis Philippe <[email protected]>2021-01-16 12:57:12 +0200
committerSlávek Banko <[email protected]>2021-01-17 18:24:08 +0100
commit370114e566d382b2c79872327d198fb4fab19406 (patch)
tree02b82be5d4be4e548faa2634ae6bb820d50d7703 /kpdf
parent9c49b19b8d62099e39cb72bc9549536e27b83b4a (diff)
downloadtdegraphics-370114e566d382b2c79872327d198fb4fab19406.tar.gz
tdegraphics-370114e566d382b2c79872327d198fb4fab19406.zip
Cover page support for KPDF
This resolves issue #26. Signed-off-by: Mavridis Philippe <[email protected]> (cherry picked from commit 3afb31110af4b60836c340d2794cc6de092b9e1d)
Diffstat (limited to 'kpdf')
-rw-r--r--kpdf/conf/kpdf.kcfg3
-rw-r--r--kpdf/part.rc1
-rw-r--r--kpdf/ui/pageview.cpp43
-rw-r--r--kpdf/ui/pageview.h1
4 files changed, 45 insertions, 3 deletions
diff --git a/kpdf/conf/kpdf.kcfg b/kpdf/conf/kpdf.kcfg
index 9f54b412..7f84081e 100644
--- a/kpdf/conf/kpdf.kcfg
+++ b/kpdf/conf/kpdf.kcfg
@@ -76,6 +76,9 @@
<entry key="ViewContinuous" type="Bool" >
<default>true</default>
</entry>
+ <entry key="ViewCoverPage" type="Bool" >
+ <default>false</default>
+ </entry>
<entry key="ViewColumns" type="UInt" >
<default>1</default>
<min>1</min>
diff --git a/kpdf/part.rc b/kpdf/part.rc
index 194e94ac..d69959d4 100644
--- a/kpdf/part.rc
+++ b/kpdf/part.rc
@@ -24,6 +24,7 @@
<Separator/>
<Action name="view_continuous"/>
<Action name="view_twopages"/>
+ <Action name="view_coverpage"/>
</Menu>
<Menu name="go"><text>&amp;Go</text>
<Action name="previous_page"/>
diff --git a/kpdf/ui/pageview.cpp b/kpdf/ui/pageview.cpp
index 88f599d6..8225bf32 100644
--- a/kpdf/ui/pageview.cpp
+++ b/kpdf/ui/pageview.cpp
@@ -114,6 +114,7 @@ public:
TDEToggleAction * aZoomFitText;
TDEToggleAction * aViewTwoPages;
TDEToggleAction * aViewContinuous;
+ TDEToggleAction * aViewCoverPage;
TDEAction * aPrevAction;
};
@@ -282,6 +283,11 @@ void PageView::setupActions( TDEActionCollection * ac )
connect( d->aViewContinuous, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( slotContinuousToggled( bool ) ) );
d->aViewContinuous->setChecked( KpdfSettings::viewContinuous() );
+ d->aViewCoverPage = new TDEToggleAction( i18n("Co&ver Page"), "contents2", 0, ac, "view_coverpage" );
+ connect( d->aViewCoverPage, TQT_SIGNAL( toggled( bool ) ), TQT_SLOT( slotCoverPageToggled( bool ) ) );
+ d->aViewCoverPage->setChecked( KpdfSettings::viewCoverPage() );
+ d->aViewCoverPage->setEnabled( KpdfSettings::viewColumns() > 1 );
+
// Mouse-Mode actions
d->aMouseNormal = new TDERadioAction( i18n("&Browse Tool"), "input-mouse", 0, TQT_TQOBJECT(this), TQT_SLOT( slotSetMouseNormal() ), ac, "mouse_drag" );
d->aMouseNormal->setExclusiveGroup( "MouseType" );
@@ -1718,11 +1724,19 @@ void PageView::slotRelayoutPages()
insertY = 4; // 2 + 4*d->zoomFactor ?
cIdx = 0;
rIdx = 0;
+
+ if( KpdfSettings::viewColumns() == 2 && KpdfSettings::viewCoverPage() )
+ ++cIdx;
+
for ( iIt = d->items.begin(); iIt != iEnd; ++iIt )
{
PageViewItem * item = *iIt;
int cWidth = colWidth[ cIdx ],
rHeight = rowHeight[ rIdx ];
+
+ if( KpdfSettings::viewColumns() == 2 && KpdfSettings::viewCoverPage() && item->pageNumber() == 0 ) // align widget right inside viewport
+ insertX+=cWidth;
+
// center widget inside 'cells'
item->moveTo( insertX + (cWidth - item->width()) / 2,
insertY + (rHeight - item->height()) / 2 );
@@ -1776,14 +1790,24 @@ void PageView::slotRelayoutPages()
// 2) hide all widgets except the displayable ones and dispose those
int insertX = 0;
cIdx = 0;
+
+ if( KpdfSettings::viewColumns() == 2 && KpdfSettings::viewCoverPage() && (int)d->document->currentPage() == 0 )
+ ++cIdx;
+
for ( iIt = d->items.begin(); iIt != iEnd; ++iIt )
{
PageViewItem * item = *iIt;
if ( item == currentItem || (cIdx > 0 && cIdx < nCols) )
{
- // center widget inside 'cells'
- item->moveTo( insertX + (colWidth[ cIdx ] - item->width()) / 2,
- (fullHeight - item->height()) / 2 );
+ if( KpdfSettings::viewCoverPage() && (int)d->document->currentPage() == 0 ) {
+ // center widget inside viewport
+ item->moveTo( insertX + (viewportWidth - item->width()) / 2,
+ (viewportHeight - item->height()) / 2 );
+ } else {
+ // center widget inside 'cells'
+ item->moveTo( insertX + (colWidth[ cIdx ] - item->width()) / 2,
+ (fullHeight - item->height()) / 2 );
+ }
// advance col index
insertX += colWidth[ cIdx ];
cIdx++;
@@ -2110,6 +2134,8 @@ void PageView::slotTwoPagesToggled( bool on )
if ( d->document->pages() > 0 )
slotRelayoutPages();
}
+
+ d->aViewCoverPage->setEnabled( on );
}
void PageView::slotContinuousToggled( bool on )
@@ -2123,6 +2149,17 @@ void PageView::slotContinuousToggled( bool on )
}
}
+void PageView::slotCoverPageToggled( bool on )
+{
+ if ( KpdfSettings::viewCoverPage() != on )
+ {
+ KpdfSettings::setViewCoverPage( on );
+ KpdfSettings::writeConfig();
+ if ( d->document->pages() > 0 )
+ slotRelayoutPages();
+ }
+}
+
void PageView::slotSetMouseNormal()
{
d->mouseMode = MouseNormal;
diff --git a/kpdf/ui/pageview.h b/kpdf/ui/pageview.h
index 901ec9e6..267c58f5 100644
--- a/kpdf/ui/pageview.h
+++ b/kpdf/ui/pageview.h
@@ -140,6 +140,7 @@ class PageView : public TQScrollView, public DocumentObserver
void slotRotateLeft();
void slotTwoPagesToggled( bool );
void slotContinuousToggled( bool );
+ void slotCoverPageToggled( bool );
void slotSetMouseNormal();
void slotSetMouseZoom();
void slotSetMouseSelect();