Commit 13481bdf authored by David Hurka's avatar David Hurka 🐬
Browse files

Add RTL layout KToggleAction

This adds a KToggleAction to PageView, which toggles RTL layout, which was previously only accessible from Configure Okular -> General.

The action is not in any toolbar, just in the action collection. Called "rtl_page_layout" and reads "Use Right to Left Reading Direction".

FEATURE: 424103
parent cac97208
......@@ -217,6 +217,7 @@ public:
QAction *aRotateOriginal;
KActionMenu *aTrimMode;
KToggleAction *aTrimMargins;
KToggleAction *aReadingDirection;
QAction *aMouseNormal;
QAction *aMouseSelect;
QAction *aMouseTextSelect;
......@@ -348,6 +349,7 @@ PageView::PageView(QWidget *parent, Okular::Document *document)
d->aTrimMode = nullptr;
d->aTrimMargins = nullptr;
d->aTrimToSelection = nullptr;
d->aReadingDirection = nullptr;
d->aMouseNormal = nullptr;
d->aMouseSelect = nullptr;
d->aMouseTextSelect = nullptr;
......@@ -607,6 +609,13 @@ void PageView::setupViewerActions(KActionCollection *ac)
connect(d->aViewContinuous, &QAction::toggled, this, &PageView::slotContinuousToggled);
d->aViewContinuous->setChecked(Okular::Settings::viewContinuous());
// Reading direction toggle action. (Checked means RTL, unchecked means LTR.)
d->aReadingDirection = new KToggleAction(QIcon::fromTheme(QStringLiteral("format-text-direction-rtl")), i18nc("@action page layout", "Use Right to Left Reading Direction"), this);
d->aReadingDirection->setChecked(Okular::Settings::rtlReadingDirection());
ac->addAction(QStringLiteral("rtl_page_layout"), d->aReadingDirection);
connect(d->aReadingDirection, &QAction::toggled, this, &PageView::slotReadingDirectionToggled);
connect(Okular::SettingsCore::self(), &Okular::SettingsCore::configChanged, this, &PageView::slotUpdateReadingDirectionAction);
// Mouse mode actions for viewer mode
d->mouseModeActionGroup = new QActionGroup(this);
d->mouseModeActionGroup->setExclusive(true);
......@@ -1149,6 +1158,10 @@ void PageView::updateActionState(bool haspages, bool hasformwidgets)
if (d->aZoomActual)
d->aZoomActual->setEnabled(haspages && d->zoomFactor != 1.0);
if (d->aReadingDirection) {
d->aReadingDirection->setEnabled(haspages);
}
if (d->mouseModeActionGroup)
d->mouseModeActionGroup->setEnabled(haspages);
if (d->aMouseModeMenu)
......@@ -4617,6 +4630,17 @@ void PageView::slotContinuousToggled(bool on)
}
}
void PageView::slotReadingDirectionToggled(bool leftToRight)
{
Okular::Settings::setRtlReadingDirection(leftToRight);
Okular::Settings::self()->save();
}
void PageView::slotUpdateReadingDirectionAction()
{
d->aReadingDirection->setChecked(Okular::Settings::rtlReadingDirection());
}
void PageView::slotMouseNormalToggled(bool checked)
{
if (checked) {
......
......@@ -254,6 +254,8 @@ private Q_SLOTS:
void slotAutoFitToggled(bool);
void slotViewMode(QAction *action);
void slotContinuousToggled(bool);
void slotReadingDirectionToggled(bool leftToRight);
void slotUpdateReadingDirectionAction();
void slotMouseNormalToggled(bool);
void slotSetMouseZoom();
void slotSetMouseMagnifier();
......
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