diff --git a/doc/index.docbook b/doc/index.docbook --- a/doc/index.docbook +++ b/doc/index.docbook @@ -1278,6 +1278,22 @@ + + + + + + &Ctrl;P + 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/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,14 @@ 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( this ); + selectCurrentPage->setIcon( QIcon::fromTheme( QStringLiteral( "edit-select-all" ) ) ); + ac->addAction( QStringLiteral("Select Current Page"), selectCurrentPage ); + connect( selectCurrentPage, &QAction::triggered, this, &PageView::slotSelectPage ); + ac->setDefaultShortcut(selectCurrentPage, QKeySequence(Qt::CTRL + Qt::Key_P)); + addAction( selectCurrentPage ); } bool PageView::canFitPageWidth() const @@ -3263,6 +3271,7 @@ if ( e->button() == Qt::LeftButton ) { + // Below code selects the word on mouse double click event const QPoint eventPos = contentAreaPoint( e->pos() ); PageViewItem * pageItem = pickItemOnPoint( eventPos.x(), eventPos.y() ); if ( pageItem ) @@ -5570,6 +5579,42 @@ emit fitWindowToPage( viewportSize, pageSize ); } +void PageView::slotSelectPage() +{ + // The code below selects the entire page and copies the text to a clipboard if mode is Text Select + if (d->mouseMode == Okular::Settings::EnumMouseMode::TextSelect) + { + 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 ) ); + //d->pagesWithTextSelection << currentPage; + + if ( d->document->isAllowed( Okular::AllowCopy ) ) + { + //const QString text = d->selectedText(); + 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();