Fixes changing continuous mode while on tabs issue

Toggling the Continuous mode while opening multiple tabs caused an issue
in Okular, in which it considered it a global setting. So, toggling it
for one document, then toggling it again for the other documents may not
take effect. This should fix it by considering this setting a per
document setting, and therefore toggling the mode for one document
shouldn't have any effect for other documents.

BUGS: 422080
remotes/origin/work/spdx
Mahmoud Khalil 5 years ago committed by Albert Astals Cid
parent 00b60aec24
commit aa0d1b459b
  1. 2
      conf/okular.kcfg
  2. 5
      part/dlggeneral.cpp
  3. 44
      part/pageview.cpp
  4. 9
      part/pageview.h

@ -7,6 +7,7 @@
<kcfgfile arg="true" />
<signal name="builtinAnnotationToolsChanged" />
<signal name="quickAnnotationToolsChanged" />
<signal name="viewContinuousChanged" />
<group name="Dlg Performance" >
<entry key="EnableCompositing" type="Bool" >
<default>true</default>
@ -309,6 +310,7 @@
</entry>
<entry key="ViewContinuous" type="Bool" >
<default>true</default>
<emit signal="viewContinuousChanged" />
</entry>
<entry key="ViewMode" type="Enum" >
<default>Single</default>

@ -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:

@ -152,7 +152,7 @@ public:
QLinkedList<PageViewItem *> 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<QAction *> 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 {

@ -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);

Loading…
Cancel
Save