Commit 04908dba authored by Olivier CHURLAUD's avatar Olivier CHURLAUD

Adding RTL reading mode feature to okular

Commited on behalf of Fahad Al-Saidi

REVIEW: 125397
BUG: 325650
parent ea607664
......@@ -26,6 +26,7 @@ DlgGeneral::DlgGeneral( QWidget * parent, Okular::EmbedMode embedMode )
m_dlg->kcfg_SyncThumbnailsViewport->setVisible( false );
m_dlg->kcfg_DisplayDocumentTitle->setVisible( false );
m_dlg->kcfg_WatchFile->setVisible( false );
m_dlg->kcfg_rtlReadingDirection->setVisible(false);
}
m_dlg->kcfg_ShellOpenFileInTabs->setVisible( embedMode == Okular::NativeShellMode );
}
......
......@@ -11,7 +11,16 @@
</rect>
</property>
<layout class="QVBoxLayout">
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -23,7 +32,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
......@@ -31,7 +49,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -133,7 +160,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -176,7 +212,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>9</number>
</property>
<property name="topMargin">
<number>9</number>
</property>
<property name="rightMargin">
<number>9</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<item>
......@@ -184,7 +229,16 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
......@@ -222,16 +276,22 @@
<property name="spacing">
<number>6</number>
</property>
<property name="margin">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QLabel" name="pixmapLabel1_2_2">
<property name="sizePolicy">
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
<widget class="QCheckBox" name="kcfg_rtlReadingDirection">
<property name="text">
<string>Right to left reading direction</string>
</property>
</widget>
</item>
......
......@@ -96,6 +96,9 @@
<entry key="DisplayDocumentTitle" type="Bool" >
<default>true</default>
</entry>
<entry key="rtlReadingDirection" type="Bool" >
<default>false</default>
</entry>
<entry key="DisplayDocumentNameOrPath" type="Enum" >
<default>Name</default>
<choices>
......
......@@ -223,7 +223,7 @@ public:
KAction * aFitWindowToPage;
int setting_viewCols;
bool rtl_Mode;
// Keep track of whether tablet pen is currently pressed down
bool penDown;
};
......@@ -335,6 +335,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->actionCollection = 0;
d->aPageSizes=0;
d->setting_viewCols = Okular::Settings::viewColumns();
d->rtl_Mode = Okular::Settings::rtlReadingDirection();
d->mouseModeActionGroup = 0;
d->penDown = false;
d->aMouseMagnifier = 0;
......@@ -803,6 +804,12 @@ void PageView::reparseConfig()
slotRelayoutPages();
}
if (Okular::Settings::rtlReadingDirection() != d->rtl_Mode )
{
d->rtl_Mode = Okular::Settings::rtlReadingDirection();
slotRelayoutPages();
}
updatePageStep();
if ( d->annotator )
......@@ -4332,15 +4339,27 @@ void PageView::slotRelayoutPages()
}
else if ( facingPages )
{
// page edges 'touch' the center of the viewport
actualX = ( (centerFirstPage && item->pageNumber() % 2 == 1) ||
(!centerFirstPage && item->pageNumber() % 2 == 0) ) ?
(fullWidth / 2) - item->croppedWidth() - 1 : (fullWidth / 2) + 1;
if (Okular::Settings::rtlReadingDirection()){
// RTL reading mode
actualX = ( (centerFirstPage && item->pageNumber() % 2 == 0) ||
(!centerFirstPage && item->pageNumber() % 2 == 1) ) ?
(fullWidth / 2) - item->croppedWidth() - 1 : (fullWidth / 2) + 1;
} else {
// page edges 'touch' the center of the viewport
actualX = ( (centerFirstPage && item->pageNumber() % 2 == 1) ||
(!centerFirstPage && item->pageNumber() % 2 == 0) ) ?
(fullWidth / 2) - item->croppedWidth() - 1 : (fullWidth / 2) + 1;
}
}
else
{
// page is centered within its virtual column
actualX = insertX + (cWidth - item->croppedWidth()) / 2;
//actualX = insertX + (cWidth - item->croppedWidth()) / 2;
if (Okular::Settings::rtlReadingDirection()){
actualX = fullWidth - insertX - cWidth +( (cWidth - item->croppedWidth()) / 2);
} else {
actualX = insertX + (cWidth - item->croppedWidth()) / 2;
}
}
item->moveTo( actualX,
(continuousView ? insertY : origInsertY) + (rHeight - item->croppedHeight()) / 2 );
......
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