diff --git a/ui/pageview.cpp b/ui/pageview.cpp --- a/ui/pageview.cpp +++ b/ui/pageview.cpp @@ -3263,6 +3263,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 ) @@ -3304,6 +3305,40 @@ openAnnotationWindow( ann, pageItem->pageNumber() ); } } + + // The code below selects the entire page and copies the text to a clipboard if position of double mouse click event is empty portion and mode is Text Select + if (d->mouseMode == Okular::Settings::EnumMouseMode::TextSelect) + { + textSelectionClear(); + //add block to select (visually) the current page + 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; + } + } } }