diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1284,6 +1284,21 @@ + + + + + Edit + Select All Text on Current Page + + + + Selects all the text (if the document provides it) of the current page. + + + + + diff --git a/part.h b/part.h --- a/part.h +++ b/part.h @@ -360,6 +360,7 @@ 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.cpp b/part.cpp --- a/part.cpp +++ b/part.cpp @@ -719,6 +719,7 @@ 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 @@ 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 @@ 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 @@ 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.rc b/part.rc --- a/part.rc +++ b/part.rc @@ -1,5 +1,5 @@ - + &File @@ -21,6 +21,7 @@ + diff --git a/ui/pageview.h b/ui/pageview.h --- a/ui/pageview.h +++ b/ui/pageview.h @@ -130,6 +130,8 @@ void slotToggleChangeColors(); void slotSetChangeColors(bool active); + void slotSelectPage(); + Q_SIGNALS: void rightClick( const Okular::Page *, const QPoint & ); void mouseBackButtonClick(); diff --git a/ui/pageview.cpp b/ui/pageview.cpp --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -5570,6 +5570,37 @@ 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();