[okular] /: Move Continuous option to View Mode submenu
Albert Astals Cid
null at kde.org
Thu Mar 12 21:03:48 GMT 2020
Git commit 493ba07e22dacfe53ced42903371ad1ae25bcc8d by Albert Astals Cid, on behalf of David Hurka.
Committed on 12/03/2020 at 21:03.
Pushed by aacid into branch 'master'.
Move Continuous option to View Mode submenu
Summary:
This moves the Continuous option from the View menu to the
View Mode submenu. This makes the View Mode menu (a KActionMenu)
more useful in the main toolbar. Additionally, “Continuous” is explained by the context “View Mode”.
The primary intention was to give this View Mode a similar usage pattern like
the Change Colors menu (D21195), if both are added to the toolbar. See my
suggestion in Bugs 407217 and 407326.
FEATURE: 407326
Screenshot before:
{F6821917}
Screenshot now:
{F6821920}
and in the toolbar:
{F6821921}
Test Plan:
* Look into View menu and test entries
* Add View Mode menu to toolbar and test entries
Reviewers: #okular, #vdg, aacid
Spies: aacid, ngraham, okular-devel, kde-doc-english
Tags: #okular, #documentation
Differential Revision: https://phabricator.kde.org/D21196
M +4 -16 doc/index.docbook
M +1 -2 part-viewermode.rc
M +1 -2 part.rc
M +52 -36 ui/pageview.cpp
https://invent.kde.org/kde/okular/commit/493ba07e22dacfe53ced42903371ad1ae25bcc8d
diff --git a/doc/index.docbook b/doc/index.docbook
index 353baddfc..4c3a733b7 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1508,22 +1508,6 @@ Context menu actions like Rename Bookmarks etc.)
to a value that, depending on the size relation between the page and the view area, automatically either makes the pages' width equal to the document view's width (like fit-width), the pages' height equal to the document view's height (like fit-height), or the whole page visible (like fit-page).</para>
</listitem>
</varlistentry>
- <varlistentry>
- <term>
- <menuchoice>
- <guimenu>View</guimenu>
- <guimenuitem>Continuous</guimenuitem>
- </menuchoice>
- </term>
- <listitem>
- <para><action>Enable the continuous page mode</action>. In continuous mode,
- all pages of the document are shown, and you can scroll through
- them without having to use the <menuchoice><guimenu>Go</guimenu>
- <guimenuitem>Previous Page</guimenuitem></menuchoice> and
- <menuchoice><guimenu>Go</guimenu><guimenuitem>Next Page</guimenuitem>
- </menuchoice> options.</para>
- </listitem>
- </varlistentry>
<varlistentry>
<term>
<menuchoice>
@@ -1538,6 +1522,10 @@ Context menu actions like Rename Bookmarks etc.)
<guimenuitem>Facing Pages (Center First Page)</guimenuitem> and
<guimenuitem>Overview</guimenuitem> (the number of columns is the one
specified in the <link linkend="configure">&okular; settings</link>).</para>
+ <para>Additionally, you can enable the <guimenuitem>Continuous</guimenuitem> mode.
+ In continuous mode, all pages of the document are shown, and you can smoothly
+ scroll through them. Otherwise, only one page (or one row of pages) is shown
+ at a time.</para>
</listitem>
</varlistentry>
<varlistentry>
diff --git a/part-viewermode.rc b/part-viewermode.rc
index e443c3331..f281baa4e 100644
--- a/part-viewermode.rc
+++ b/part-viewermode.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="okular_part_viewermode" version="4">
+<kpartgui name="okular_part_viewermode" version="5">
<MenuBar>
<Menu name="file"><text>&File</text>
@@ -26,7 +26,6 @@
<Action name="view_fit_to_width" group="viewer_menu_merge"/>
<Action name="view_fit_to_page" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
- <Action name="view_continuous" group="viewer_menu_merge"/>
<Action name="view_render_mode" group="viewer_menu_merge"/>
<Separator group="viewer_menu_merge"/>
<Menu name="view_orientation" group="viewer_menu_merge"><text>&Orientation</text>
diff --git a/part.rc b/part.rc
index 353db202b..48649b522 100644
--- a/part.rc
+++ b/part.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="okular_part" version="42">
+<kpartgui name="okular_part" version="43">
<MenuBar>
<Menu name="file"><text>&File</text>
<Action name="get_new_stuff" group="file_open"/>
@@ -38,7 +38,6 @@
<Action name="view_fit_to_page"/>
<Action name="view_auto_fit"/>
<Separator/>
- <Action name="view_continuous"/>
<Action name="view_render_mode"/>
<Separator/>
<Menu name="view_orientation"><text>&Orientation</text>
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index 28e222bf7..4ebf7374f 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -232,7 +232,8 @@ public:
KToggleAction * aZoomFitWidth;
KToggleAction * aZoomFitPage;
KToggleAction * aZoomAutoFit;
- KActionMenu * aViewMode;
+ KActionMenu * aViewModeMenu;
+ QActionGroup * viewModeActionGroup;
KToggleAction * aViewContinuous;
QAction * aPrevAction;
QAction * aToggleForms;
@@ -338,7 +339,7 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->aRotateClockwise = nullptr;
d->aRotateCounterClockwise = nullptr;
d->aRotateOriginal = nullptr;
- d->aViewMode = nullptr;
+ d->aViewModeMenu = nullptr;
d->zoomMode = PageView::ZoomFitWidth;
d->zoomFactor = 1.0;
d->mouseSelecting = false;
@@ -378,8 +379,9 @@ PageView::PageView( QWidget *parent, Okular::Document *document )
d->aZoomFitWidth = nullptr;
d->aZoomFitPage = nullptr;
d->aZoomAutoFit = nullptr;
- d->aViewMode = nullptr;
+ d->aViewModeMenu = nullptr;
d->aViewContinuous = nullptr;
+ d->viewModeActionGroup = nullptr;
d->aPrevAction = nullptr;
d->aToggleForms = nullptr;
d->aSpeakDoc = nullptr;
@@ -608,36 +610,46 @@ void PageView::setupViewerActions( KActionCollection * ac )
ac->addAction( QStringLiteral("fit_window_to_page"), d->aFitWindowToPage );
connect( d->aFitWindowToPage, &QAction::triggered, this, &PageView::slotFitWindowToPage );
- // View-Layout actions
- d->aViewMode = new KActionMenu( QIcon::fromTheme( QStringLiteral("view-split-left-right") ), i18n( "&View Mode" ), this );
- d->aViewMode->setDelayed( false );
-#define ADD_VIEWMODE_ACTION( text, name, id ) \
-do { \
- QAction *vm = new QAction( text, this ); \
- vm->setCheckable( true ); \
- vm->setData( QVariant::fromValue( id ) ); \
- d->aViewMode->addAction( vm ); \
- ac->addAction( QStringLiteral(name), vm ); \
- vmGroup->addAction( vm ); \
-} while( 0 )
- ac->addAction(QStringLiteral("view_render_mode"), d->aViewMode );
- QActionGroup *vmGroup = new QActionGroup( this ); //d->aViewMode->menu() );
- ADD_VIEWMODE_ACTION( i18n( "Single Page" ), "view_render_mode_single", (int)Okular::Settings::EnumViewMode::Single );
- ADD_VIEWMODE_ACTION( i18n( "Facing Pages" ), "view_render_mode_facing", (int)Okular::Settings::EnumViewMode::Facing );
- ADD_VIEWMODE_ACTION( i18n( "Facing Pages (Center First Page)" ), "view_render_mode_facing_center_first", (int)Okular::Settings::EnumViewMode::FacingFirstCentered );
- ADD_VIEWMODE_ACTION( i18n( "Overview" ), "view_render_mode_overview", (int)Okular::Settings::EnumViewMode::Summary );
- const QList<QAction *> viewModeActions = d->aViewMode->menu()->actions();
- for (QAction *viewModeAction : viewModeActions)
- {
- if (viewModeAction->data().toInt() == Okular::Settings::viewMode())
+ // View Mode action menu (Single Page, Facing Pages,...(choose), and Continuous (on/off))
+ d->aViewModeMenu = new KActionMenu( QIcon::fromTheme( QStringLiteral("view-split-left-right") ), i18n( "&View Mode" ), this );
+ d->aViewModeMenu->setDelayed( false );
+ ac->addAction( QStringLiteral( "view_render_mode" ), d->aViewModeMenu );
+
+ d->viewModeActionGroup = new QActionGroup( this );
+ auto addViewMode = [=] ( QAction * a, const QString &name, Okular::Settings::EnumViewMode::type id ) {
+ a->setCheckable( true );
+ a->setData( int( id ) );
+ d->aViewModeMenu->addAction( a );
+ ac->addAction( name, a );
+ d->viewModeActionGroup->addAction( a );
+ };
+ addViewMode( new QAction( i18nc( "@item:inmenu", "&Single Page" ), this ),
+ QStringLiteral("view_render_mode_single"),
+ Okular::Settings::EnumViewMode::Single );
+ addViewMode( new QAction( i18nc( "@item:inmenu", "&Facing Pages" ), this ),
+ QStringLiteral("view_render_mode_single"),
+ Okular::Settings::EnumViewMode::Facing );
+ addViewMode( new QAction( i18nc( "@item:inmenu", "Facing Pages (&Center First Page)" ), this ),
+ QStringLiteral("view_render_mode_single"),
+ Okular::Settings::EnumViewMode::FacingFirstCentered );
+ addViewMode( new QAction( i18nc( "@item:inmenu", "&Overview" ), this ),
+ QStringLiteral("view_render_mode_single"),
+ Okular::Settings::EnumViewMode::Summary );
+ const QList< QAction* > viewModeActions = d->viewModeActionGroup->actions();
+ for ( QAction * viewModeAction : viewModeActions )
+ {
+ if ( viewModeAction->data().toInt() == Okular::Settings::viewMode() )
{
viewModeAction->setChecked( true );
+ break;
}
}
- connect( vmGroup, &QActionGroup::triggered, this, &PageView::slotViewMode );
-#undef ADD_VIEWMODE_ACTION
+ connect( d->viewModeActionGroup, &QActionGroup::triggered, this, &PageView::slotViewMode );
+ // Continuous view action, add to view mode action menu.
+ d->aViewModeMenu->addSeparator();
d->aViewContinuous = new KToggleAction(QIcon::fromTheme( QStringLiteral("view-list-text") ), i18n("&Continuous"), this);
+ d->aViewModeMenu->addAction(d->aViewContinuous);
ac->addAction(QStringLiteral("view_continuous"), d->aViewContinuous );
connect( d->aViewContinuous, &QAction::toggled, this, &PageView::slotContinuousToggled );
d->aViewContinuous->setChecked( Okular::Settings::viewContinuous() );
@@ -806,7 +818,7 @@ void PageView::fitPageWidth( int page )
d->aZoomFitWidth->setChecked( true );
d->aZoomFitPage->setChecked( false );
d->aZoomAutoFit->setChecked( false );
- d->aViewMode->menu()->actions().at( 0 )->setChecked( true );
+ updateViewMode( 0 );
viewport()->setUpdatesEnabled( false );
slotRelayoutPages();
viewport()->setUpdatesEnabled( true );
@@ -1241,8 +1253,8 @@ void PageView::updateActionState( bool haspages, bool documentChanged, bool hasf
if ( d->aTrimToSelection )
d->aTrimToSelection->setEnabled( haspages );
- if ( d->aViewMode )
- d->aViewMode->setEnabled( haspages );
+ if ( d->aViewModeMenu )
+ d->aViewModeMenu->setEnabled( haspages );
if ( d->aViewContinuous )
d->aViewContinuous->setEnabled( haspages );
@@ -1610,12 +1622,16 @@ QVariant PageView::capability( ViewCapability capability ) const
return d->aViewContinuous ? d->aViewContinuous->isChecked() : true;
case ViewModeModality:
{
- const int nActions = d->aViewMode ? d->aViewMode->menu()->actions().size() : 0;
- for (int i=0; i < nActions; ++i)
+ if ( d->viewModeActionGroup )
{
- const QAction* action = d->aViewMode->menu()->actions().at(i);
- if ( action->isChecked() )
- return action->data();
+ const QList<QAction*> actions = d->viewModeActionGroup->actions();
+ for ( const QAction* action : actions )
+ {
+ if (action->isChecked())
+ {
+ return action->data();
+ }
+ }
}
return QVariant();
}
@@ -4272,7 +4288,7 @@ void PageView::updateZoomText()
void PageView::updateViewMode(const int nr)
{
- const QList<QAction*> actions = d->aViewMode->menu()->actions();
+ const QList<QAction*> actions = d->viewModeActionGroup->actions();
for ( QAction* action : actions ) {
QVariant mode_id = action->data();
if (mode_id.toInt() == nr) {
More information about the kde-doc-english
mailing list