Commit f788b5a3 authored by Shubham  .'s avatar Shubham . Committed by Albert Astals Cid

Add action in Edit menu to select the text on current page

BUG: 358868

Test Plan: Click on "Select All Text on Current Page" entry in Edit menu to select the entire page. The selected text can then be copied via Edit menu item "Copy"

Reviewers: aacid, #vdg, ngraham

Reviewed By: #vdg, ngraham

Subscribers: yurchor, michaelweghorn, kde-doc-english, davidhurka, abetts, loh.tar, alexde, ngraham, okular-devel

Tags: #okular, #documentation

Differential Revision: https://phabricator.kde.org/D18744
parent 6556b549
...@@ -1284,6 +1284,21 @@ Context menu actions like Rename Bookmarks etc.) ...@@ -1284,6 +1284,21 @@ Context menu actions like Rename Bookmarks etc.)
</varlistentry> </varlistentry>
</variablelist> </variablelist>
<variablelist>
<varlistentry>
<term>
<menuchoice>
<guimenu>Edit</guimenu>
<guimenuitem>Select All Text on Current Page</guimenuitem>
</menuchoice>
</term>
<listitem>
<para><action>Selects</action> all the text (if the document provides it) of the current page.
</para>
</listitem>
</varlistentry>
</variablelist>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
......
...@@ -720,6 +720,7 @@ void Part::setupViewerActions() ...@@ -720,6 +720,7 @@ void Part::setupViewerActions()
m_copy = nullptr; m_copy = nullptr;
m_selectAll = nullptr; m_selectAll = nullptr;
m_selectCurrentPage = nullptr;
// Find and other actions // Find and other actions
m_find = KStandardAction::find( this, SLOT(slotShowFindBar()), ac ); m_find = KStandardAction::find( this, SLOT(slotShowFindBar()), ac );
...@@ -843,6 +844,12 @@ void Part::setupActions() ...@@ -843,6 +844,12 @@ void Part::setupActions()
m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac ); m_selectAll = KStandardAction::selectAll( m_pageView, SLOT(selectAll()), ac );
// Setup select all action for the current page
m_selectCurrentPage = ac->addAction(QStringLiteral("edit_select_all_current_page"));
m_selectCurrentPage->setText(i18n("Select All Text on Current Page"));
connect( m_selectCurrentPage, &QAction::triggered, m_pageView, &PageView::slotSelectPage );
m_selectCurrentPage->setEnabled( false );
m_save = KStandardAction::save( this, [this] { saveFile(); }, ac ); m_save = KStandardAction::save( this, [this] { saveFile(); }, ac );
m_save->setEnabled( false ); m_save->setEnabled( false );
...@@ -2146,6 +2153,7 @@ void Part::updateViewActions() ...@@ -2146,6 +2153,7 @@ void Part::updateViewActions()
m_reload->setEnabled( true ); m_reload->setEnabled( true );
if (m_copy) m_copy->setEnabled( true ); if (m_copy) m_copy->setEnabled( true );
if (m_selectAll) m_selectAll->setEnabled( true ); if (m_selectAll) m_selectAll->setEnabled( true );
if (m_selectCurrentPage) m_selectCurrentPage->setEnabled( true );
} }
else else
{ {
...@@ -2159,6 +2167,7 @@ void Part::updateViewActions() ...@@ -2159,6 +2167,7 @@ void Part::updateViewActions()
m_reload->setEnabled( false ); m_reload->setEnabled( false );
if (m_copy) m_copy->setEnabled( false ); if (m_copy) m_copy->setEnabled( false );
if (m_selectAll) m_selectAll->setEnabled( false ); if (m_selectAll) m_selectAll->setEnabled( false );
if (m_selectCurrentPage) m_selectCurrentPage->setEnabled( false );
} }
if ( factory() ) if ( factory() )
......
...@@ -360,6 +360,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu ...@@ -360,6 +360,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
QAction *m_nextBookmark; QAction *m_nextBookmark;
QAction *m_copy; QAction *m_copy;
QAction *m_selectAll; QAction *m_selectAll;
QAction *m_selectCurrentPage;
QAction *m_find; QAction *m_find;
QAction *m_findNext; QAction *m_findNext;
QAction *m_findPrev; QAction *m_findPrev;
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd"> <!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="okular_part" version="39"> <kpartgui name="okular_part" version="40">
<MenuBar> <MenuBar>
<Menu name="file"><text>&amp;File</text> <Menu name="file"><text>&amp;File</text>
<Action name="get_new_stuff" group="file_open"/> <Action name="get_new_stuff" group="file_open"/>
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
<Action name="edit_copy"/> <Action name="edit_copy"/>
<Separator/> <Separator/>
<Action name="edit_select_all"/> <Action name="edit_select_all"/>
<Action name="edit_select_all_current_page"/>
<Separator/> <Separator/>
<Action name="edit_find"/> <Action name="edit_find"/>
<Action name="edit_find_next"/> <Action name="edit_find_next"/>
......
...@@ -5538,6 +5538,21 @@ void PageView::slotFitWindowToPage() ...@@ -5538,6 +5538,21 @@ void PageView::slotFitWindowToPage()
emit fitWindowToPage( viewportSize, pageSize ); emit fitWindowToPage( viewportSize, pageSize );
} }
void PageView::slotSelectPage()
{
textSelectionClear();
const int currentPage = d->document->viewport().pageNumber;
PageViewItem *item = d->items.at( currentPage );
if ( item )
{
Okular::RegularAreaRect * area = textSelectionForItem( item );
const QString text = item->page()->text( area );
d->pagesWithTextSelection.insert( currentPage );
d->document->setPageTextSelection( currentPage, area, palette().color( QPalette::Active, QPalette::Highlight ) );
}
}
void PageView::highlightSignatureFormWidget( const Okular::FormFieldSignature *form ) void PageView::highlightSignatureFormWidget( const Okular::FormFieldSignature *form )
{ {
QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd(); QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd();
......
...@@ -130,6 +130,8 @@ Q_OBJECT ...@@ -130,6 +130,8 @@ Q_OBJECT
void slotToggleChangeColors(); void slotToggleChangeColors();
void slotSetChangeColors(bool active); void slotSetChangeColors(bool active);
void slotSelectPage();
Q_SIGNALS: Q_SIGNALS:
void rightClick( const Okular::Page *, const QPoint & ); void rightClick( const Okular::Page *, const QPoint & );
void mouseBackButtonClick(); void mouseBackButtonClick();
......
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