summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier CHURLAUD <olivier@churlaud.com>2016-07-25 23:37:54 (GMT)
committerOlivier CHURLAUD <olivier@churlaud.com>2016-07-25 23:37:54 (GMT)
commit04908dba2f93842a0008ef1ba8c966621c615f9e (patch)
tree27f45ccaa1d234c05406bc790277076fc4c1c78d
parentea607664d21328046be33eeb568d45010970f3bd (diff)
Adding RTL reading mode feature to okular
Commited on behalf of Fahad Al-Saidi REVIEW: 125397 BUG: 325650
-rw-r--r--conf/dlggeneral.cpp1
-rwxr-xr-xconf/dlggeneralbase.ui86
-rw-r--r--conf/okular.kcfg3
-rw-r--r--ui/pageview.cpp31
4 files changed, 102 insertions, 19 deletions
diff --git a/conf/dlggeneral.cpp b/conf/dlggeneral.cpp
index ad389f3..52abd43 100644
--- a/conf/dlggeneral.cpp
+++ b/conf/dlggeneral.cpp
@@ -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 );
}
diff --git a/conf/dlggeneralbase.ui b/conf/dlggeneralbase.ui
index 1cf6ea9..6486747 100755
--- a/conf/dlggeneralbase.ui
+++ b/conf/dlggeneralbase.ui
@@ -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>
diff --git a/conf/okular.kcfg b/conf/okular.kcfg
index e75861e..3d60b04 100644
--- a/conf/okular.kcfg
+++ b/conf/okular.kcfg
@@ -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>
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 3ebf7dc..bb540cb 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -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 );