diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1279,6 +1279,21 @@ + + + + + Edit + Select Current Page + + + + Selects all the text (if the document provides it) of the current page. This works only in + Text Selection mode. + + + + 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 @@ -278,6 +278,8 @@ void slotProcessMovieAction( const Okular::MovieAction *action ); void slotProcessRenditionAction( const Okular::RenditionAction *action ); void slotFitWindowToPage(); + + void slotSelectPage(); }; #endif diff --git a/ui/pageview.cpp b/ui/pageview.cpp --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -734,6 +734,17 @@ connect(d->document, &Okular::Document::canRedoChanged, kredo, &QAction::setEnabled); kundo->setEnabled(false); kredo->setEnabled(false); + + // Setup select all action for the current page + QAction *selectCurrentPage = new QAction( i18n("Select All Text On Current Page"), this ); + ac->addAction( QStringLiteral("edit_select_all_current_page"), selectCurrentPage ); + connect( selectCurrentPage, &QAction::triggered, this, &PageView::slotSelectPage ); + addAction( selectCurrentPage ); + + if ( !d->document->isOpened() ) + { + selectCurrentPage->setEnabled( false ); + } } bool PageView::canFitPageWidth() const @@ -5570,6 +5581,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();