diff --git a/conf/okular.kcfg b/conf/okular.kcfg
index 482ca3478..af46cbec0 100644
--- a/conf/okular.kcfg
+++ b/conf/okular.kcfg
@@ -7,6 +7,7 @@
+
true
@@ -309,6 +310,7 @@
true
+
Single
diff --git a/part/dlggeneral.cpp b/part/dlggeneral.cpp
index b66cc4d28..7da63be71 100644
--- a/part/dlggeneral.cpp
+++ b/part/dlggeneral.cpp
@@ -157,6 +157,11 @@ DlgGeneral::DlgGeneral(QWidget *parent, Okular::EmbedMode embedMode)
useRtl->setObjectName(QStringLiteral("kcfg_rtlReadingDirection"));
layout->addRow(programFeaturesLabel(), useRtl);
}
+
+ QCheckBox *openInContinuousModeByDefault = new QCheckBox(this);
+ openInContinuousModeByDefault->setText(i18nc("@option:check Config dialog, general page", "Open in continuous mode by default"));
+ openInContinuousModeByDefault->setObjectName(QStringLiteral("kcfg_ViewContinuous"));
+ layout->addRow(programFeaturesLabel(), openInContinuousModeByDefault);
// END Program features section
// If no Program features section, don’t add a second spacer:
diff --git a/part/pageview.cpp b/part/pageview.cpp
index d079172c0..5819cc06e 100644
--- a/part/pageview.cpp
+++ b/part/pageview.cpp
@@ -152,7 +152,7 @@ public:
QLinkedList visibleItems;
MagnifierView *magnifierView;
- // view layout (columns and continuous in Settings), zoom and mouse
+ // view layout (columns in Settings), zoom and mouse
PageView::ZoomMode zoomMode;
float zoomFactor;
QPoint mouseGrabOffset;
@@ -410,6 +410,11 @@ PageView::PageView(QWidget *parent, Okular::Document *document)
}
}
+ connect(Okular::Settings::self(), &Okular::Settings::viewContinuousChanged, this, [=]() {
+ if (d->aViewContinuous && !d->document->isOpened())
+ d->aViewContinuous->setChecked(Okular::Settings::viewContinuous());
+ });
+
d->delayResizeEventTimer = new QTimer(this);
d->delayResizeEventTimer->setSingleShot(true);
d->delayResizeEventTimer->setObjectName(QStringLiteral("delayResizeEventTimer"));
@@ -1315,7 +1320,7 @@ void PageView::updateActionState(bool haspages, bool hasformwidgets)
if (d->aMouseMagnifier)
d->aMouseMagnifier->setEnabled(d->document->supportsTiles());
if (d->aFitWindowToPage)
- d->aFitWindowToPage->setEnabled(haspages && !Okular::Settings::viewContinuous());
+ d->aFitWindowToPage->setEnabled(haspages && !getContinuousMode());
}
void PageView::setupActionsPostGUIActivated()
@@ -1390,7 +1395,7 @@ void PageView::slotRealNotifyViewportChanged(bool smoothMove)
#endif
// relayout in "Single Pages" mode or if a relayout is pending
d->blockPixmapsRequest = true;
- if (!Okular::Settings::viewContinuous() || d->dirtyLayout)
+ if (!getContinuousMode() || d->dirtyLayout)
slotRelayoutPages();
// restore viewport center or use default {x-center,v-top} alignment
@@ -1553,7 +1558,7 @@ void PageView::notifyCurrentPageChanged(int previous, int current)
// if the view is paged (or not continuous) and there is a selected annotation,
// we call reset to avoid creating an artifact in the next page.
- if (!Okular::Settings::viewContinuous()) {
+ if (!getContinuousMode()) {
if (d->mouseAnnotation && d->mouseAnnotation->isFocused()) {
d->mouseAnnotation->reset();
}
@@ -1597,7 +1602,7 @@ QVariant PageView::capability(ViewCapability capability) const
case ZoomModality:
return d->zoomMode;
case Continuous:
- return d->aViewContinuous ? d->aViewContinuous->isChecked() : true;
+ return getContinuousMode();
case ViewModeModality: {
if (d->viewModeActionGroup) {
const QList actions = d->viewModeActionGroup->actions();
@@ -1648,7 +1653,6 @@ void PageView::setCapability(ViewCapability capability, const QVariant &option)
case Continuous: {
bool mode = option.toBool();
d->aViewContinuous->setChecked(mode);
- slotContinuousToggled(mode);
break;
}
case TrimMargins: {
@@ -3135,7 +3139,7 @@ void PageView::wheelEvent(QWheelEvent *e)
} else {
d->controlWheelAccumulatedDelta = 0;
- if (delta <= -QWheelEvent::DefaultDeltasPerStep && !Okular::Settings::viewContinuous() && vScroll == verticalScrollBar()->maximum()) {
+ if (delta <= -QWheelEvent::DefaultDeltasPerStep && !getContinuousMode() && vScroll == verticalScrollBar()->maximum()) {
// go to next page
if ((int)d->document->currentPage() < d->items.count() - 1) {
// more optimized than document->setNextPage and then move view to top
@@ -3148,7 +3152,7 @@ void PageView::wheelEvent(QWheelEvent *e)
d->document->setViewport(newViewport);
d->scroller->scrollTo(QPoint(horizontalScrollBar()->value(), verticalScrollBar()->value()), 0); // sync scroller with scrollbar
}
- } else if (delta >= QWheelEvent::DefaultDeltasPerStep && !Okular::Settings::viewContinuous() && vScroll == verticalScrollBar()->minimum()) {
+ } else if (delta >= QWheelEvent::DefaultDeltasPerStep && !getContinuousMode() && vScroll == verticalScrollBar()->minimum()) {
// go to prev page
if (d->document->currentPage() > 0) {
// more optimized than document->setPrevPage and then move view to bottom
@@ -3479,8 +3483,7 @@ void PageView::updateItemSize(PageViewItem *item, int colWidth, int rowHeight)
const double pageAspect = (double)height / (double)width;
const double rel = uiAspect / pageAspect;
- const bool isContinuous = Okular::Settings::viewContinuous();
- if (!isContinuous && rel > aspectRatioRelation) {
+ if (!getContinuousMode() && rel > aspectRatioRelation) {
// UI space is relatively much higher than the page
zoom = (double)rowHeight / (double)height;
} else if (rel < 1.0 / aspectRatioRelation) {
@@ -4234,6 +4237,11 @@ void PageView::updateSmoothScrollAnimationSpeed()
d->currentLongScrollDuration = d->baseLongScrollDuration * globalAnimationScale;
}
+bool PageView::getContinuousMode() const
+{
+ return d->aViewContinuous ? d->aViewContinuous->isChecked() : Okular::Settings::viewContinuous();
+}
+
// BEGIN private SLOTS
void PageView::slotRelayoutPages()
// called by: notifySetup, viewportResizeEvent, slotViewMode, slotContinuousToggled, updateZoom
@@ -4253,7 +4261,7 @@ void PageView::slotRelayoutPages()
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 = getContinuousMode();
const int nCols = overrideCentering ? 1 : viewColumns();
const bool singlePageViewMode = Okular::Settings::viewMode() == Okular::Settings::EnumViewMode::Single;
@@ -4700,14 +4708,10 @@ void PageView::slotViewMode(QAction *action)
}
}
-void PageView::slotContinuousToggled(bool on)
+void PageView::slotContinuousToggled()
{
- if (Okular::Settings::viewContinuous() != on) {
- Okular::Settings::setViewContinuous(on);
- Okular::Settings::self()->save();
- if (d->document->pages() > 0)
- slotRelayoutPages();
- }
+ if (d->document->pages() > 0)
+ slotRelayoutPages();
}
void PageView::slotReadingDirectionToggled(bool leftToRight)
@@ -4828,7 +4832,7 @@ void PageView::slotAutoScrollDown()
void PageView::slotScrollUp(int nSteps)
{
// if in single page mode and at the top of the screen, go to \ page
- if (Okular::Settings::viewContinuous() || verticalScrollBar()->value() > verticalScrollBar()->minimum()) {
+ if (getContinuousMode() || verticalScrollBar()->value() > verticalScrollBar()->minimum()) {
if (nSteps) {
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, -100 * nSteps), d->currentShortScrollDuration);
} else {
@@ -4850,7 +4854,7 @@ void PageView::slotScrollUp(int nSteps)
void PageView::slotScrollDown(int nSteps)
{
// if in single page mode and at the bottom of the screen, go to next page
- if (Okular::Settings::viewContinuous() || verticalScrollBar()->value() < verticalScrollBar()->maximum()) {
+ if (getContinuousMode() || verticalScrollBar()->value() < verticalScrollBar()->maximum()) {
if (nSteps) {
d->scroller->scrollTo(d->scroller->finalPosition() + QPoint(0, 100 * nSteps), d->currentShortScrollDuration);
} else {
diff --git a/part/pageview.h b/part/pageview.h
index 29faa26a1..c3fac3b7f 100644
--- a/part/pageview.h
+++ b/part/pageview.h
@@ -226,6 +226,13 @@ private:
// Update speed of animated smooth scroll transitions
void updateSmoothScrollAnimationSpeed();
+ /*
+ * returns the continuous mode value of the current document, by either:
+ * - if the continuous mode action is initialized, then we return its associated value
+ * - if not, then we will fallback to the default settings
+ */
+ bool getContinuousMode() const;
+
// don't want to expose classes in here
class PageViewPrivate *d;
@@ -259,7 +266,7 @@ private Q_SLOTS:
void slotFitToPageToggled(bool);
void slotAutoFitToggled(bool);
void slotViewMode(QAction *action);
- void slotContinuousToggled(bool);
+ void slotContinuousToggled();
void slotReadingDirectionToggled(bool leftToRight);
void slotUpdateReadingDirectionAction();
void slotMouseNormalToggled(bool);