File Metadata

Author
yurchor
Created
Feb 27 2019, 10:16 AM

D18744-my.diff

diff --git a/doc/index.docbook b/doc/index.docbook
index 995514f77..1771b21f2 100644
--- a/doc/index.docbook
+++ b/doc/index.docbook
@@ -1284,6 +1284,21 @@ Context menu actions like Rename Bookmarks etc.)
</varlistentry>
</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. This works only in
+ <guibutton>Text Selection</guibutton> mode.</para>
+ </listitem>
+ </varlistentry>
+ </variablelist>
+
<variablelist>
<varlistentry>
<term>
diff --git a/part.cpp b/part.cpp
index 1e02780e4..a978a9af3 100644
--- a/part.cpp
+++ b/part.cpp
@@ -719,6 +719,7 @@ void Part::setupViewerActions()
m_copy = nullptr;
m_selectAll = nullptr;
+ m_selectCurrentPage = nullptr;
// Find and other actions
m_find = KStandardAction::find( this, SLOT(slotShowFindBar()), ac );
@@ -842,6 +843,12 @@ void Part::setupActions()
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->setEnabled( false );
@@ -2145,6 +2152,7 @@ void Part::updateViewActions()
m_reload->setEnabled( true );
if (m_copy) m_copy->setEnabled( true );
if (m_selectAll) m_selectAll->setEnabled( true );
+ if (m_selectCurrentPage) m_selectCurrentPage->setEnabled( true );
}
else
{
@@ -2158,6 +2166,7 @@ void Part::updateViewActions()
m_reload->setEnabled( false );
if (m_copy) m_copy->setEnabled( false );
if (m_selectAll) m_selectAll->setEnabled( false );
+ if (m_selectCurrentPage) m_selectCurrentPage->setEnabled( false );
}
if ( factory() )
diff --git a/part.h b/part.h
index 2954e45d6..3cfc5a31d 100644
--- a/part.h
+++ b/part.h
@@ -360,6 +360,7 @@ class OKULARPART_EXPORT Part : public KParts::ReadWritePart, public Okular::Docu
QAction *m_nextBookmark;
QAction *m_copy;
QAction *m_selectAll;
+ QAction *m_selectCurrentPage;
QAction *m_find;
QAction *m_findNext;
QAction *m_findPrev;
diff --git a/part.rc b/part.rc
index c8dc309a0..bf15cac50 100644
--- a/part.rc
+++ b/part.rc
@@ -1,5 +1,5 @@
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="okular_part" version="39">
+<kpartgui name="okular_part" version="40">
<MenuBar>
<Menu name="file"><text>&amp;File</text>
<Action name="get_new_stuff" group="file_open"/>
@@ -21,6 +21,7 @@
<Action name="edit_copy"/>
<Separator/>
<Action name="edit_select_all"/>
+ <Action name="edit_select_all_current_page"/>
<Separator/>
<Action name="edit_find"/>
<Action name="edit_find_next"/>
diff --git a/ui/pageview.cpp b/ui/pageview.cpp
index b81aa2f3a..74588b7e6 100644
--- a/ui/pageview.cpp
+++ b/ui/pageview.cpp
@@ -5570,6 +5570,37 @@ void PageView::slotFitWindowToPage()
emit fitWindowToPage( viewportSize, pageSize );
}
+void PageView::slotSelectPage()
+{
+ // The code below selects the entire page and copies the text to a clipboard
+ 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 ) );
+
+ if ( d->document->isAllowed( Okular::AllowCopy ) )
+ {
+ if ( !text.isEmpty() )
+ {
+ QClipboard *cb = QApplication::clipboard();
+ if ( cb->supportsSelection() )
+ {
+ cb->setText( text, QClipboard::Selection );
+ }
+
+ }
+ return;
+ }
+ delete area;
+ }
+}
+
void PageView::highlightSignatureFormWidget( const Okular::FormFieldSignature *form )
{
QVector< PageViewItem * >::const_iterator dIt = d->items.constBegin(), dEnd = d->items.constEnd();
diff --git a/ui/pageview.h b/ui/pageview.h
index be2b2e208..0778cbf82 100644
--- a/ui/pageview.h
+++ b/ui/pageview.h
@@ -129,6 +129,8 @@ Q_OBJECT
void slotToggleChangeColors();
void slotSetChangeColors(bool active);
+
+ void slotSelectPage();
Q_SIGNALS:
void rightClick( const Okular::Page *, const QPoint & );