Commit a6dba243 authored by Stephen Anthony's avatar Stephen Anthony Committed by Albert Astals Cid
Browse files

Improve facing pages (center first page) mode when document contains only 1 or 2 pages

REVIEW: 103424
parent ee684dc5
...@@ -3639,11 +3639,14 @@ void PageView::slotRelayoutPages() ...@@ -3639,11 +3639,14 @@ void PageView::slotRelayoutPages()
QRect viewportRect( horizontalScrollBar()->value(), verticalScrollBar()->value(), viewportWidth, viewportHeight ); QRect viewportRect( horizontalScrollBar()->value(), verticalScrollBar()->value(), viewportWidth, viewportHeight );
// handle the 'center first page in row' stuff // handle the 'center first page in row' stuff
int nCols = viewColumns(); const bool facing = Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::Facing;
const bool centerFirstPage = Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::FacingFirstCentered; const bool facingCentered = Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::FacingFirstCentered;
const bool centerLastPage = centerFirstPage && d->items.count() % 2 == 0; const bool overrideCentering = facingCentered && pageCount < 3;
const bool centerFirstPage = facingCentered && !overrideCentering;
const bool facingPages = facing || centerFirstPage;
const bool centerLastPage = centerFirstPage && pageCount % 2 == 0;
const bool continuousView = Okular::Settings::viewContinuous(); const bool continuousView = Okular::Settings::viewContinuous();
const bool facingPages = centerFirstPage || Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::Facing; int nCols = overrideCentering ? 1 : viewColumns();
// set all items geometry and resize contents. handle 'continuous' and 'single' modes separately // set all items geometry and resize contents. handle 'continuous' and 'single' modes separately
...@@ -3725,7 +3728,7 @@ void PageView::slotRelayoutPages() ...@@ -3725,7 +3728,7 @@ void PageView::slotRelayoutPages()
if ( continuousView || rIdx == pageRowIdx ) if ( continuousView || rIdx == pageRowIdx )
{ {
const bool reallyDoCenterFirst = item->pageNumber() == 0 && centerFirstPage; const bool reallyDoCenterFirst = item->pageNumber() == 0 && centerFirstPage;
const bool reallyDoCenterLast = item->pageNumber() == d->items.count() - 1 && centerLastPage; const bool reallyDoCenterLast = item->pageNumber() == pageCount - 1 && centerLastPage;
int actualX = 0; int actualX = 0;
if ( reallyDoCenterFirst || reallyDoCenterLast ) if ( reallyDoCenterFirst || reallyDoCenterLast )
{ {
......
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