Do not copy to the selection the text when selecting "Copy text" in the RMB menu, but after releasing the LMB when "visually" selecting text.

BUG: 157364

svn path=/trunk/KDE/kdegraphics/okular/; revision=779710
remotes/origin/KDE/4.1
Pino Toscano 18 years ago
parent cea186978f
commit 39c2d29ac2
  1. 32
      ui/pageview.cpp

@ -82,6 +82,7 @@ public:
PageViewPrivate( PageView *qq ); PageViewPrivate( PageView *qq );
FormWidgetsController* formWidgetsController(); FormWidgetsController* formWidgetsController();
QString selectedText() const;
// the document, pageviewItems and the 'visible cache' // the document, pageviewItems and the 'visible cache'
PageView *q; PageView *q;
@ -620,39 +621,43 @@ KAction *PageView::toggleFormsAction() const
return d->aToggleForms; return d->aToggleForms;
} }
void PageView::copyTextSelection() const QString PageViewPrivate::selectedText() const
{ {
if ( d->pagesWithTextSelection.isEmpty() ) if ( pagesWithTextSelection.isEmpty() )
return; return QString();
QString text; QString text;
QList< int > selpages = d->pagesWithTextSelection.toList(); QList< int > selpages = pagesWithTextSelection.toList();
qSort( selpages ); qSort( selpages );
const Okular::Page * pg = 0; const Okular::Page * pg = 0;
if ( selpages.count() == 1 ) if ( selpages.count() == 1 )
{ {
pg = d->document->page( selpages.first() ); pg = document->page( selpages.first() );
text.append( pg->text( pg->textSelection() ) ); text.append( pg->text( pg->textSelection() ) );
} }
else else
{ {
pg = d->document->page( selpages.first() ); pg = document->page( selpages.first() );
text.append( pg->text( pg->textSelection() ) ); text.append( pg->text( pg->textSelection() ) );
int end = selpages.count() - 1; int end = selpages.count() - 1;
for( int i = 1; i < end; ++i ) for( int i = 1; i < end; ++i )
{ {
pg = d->document->page( selpages.at( i ) ); pg = document->page( selpages.at( i ) );
text.append( pg->text() ); text.append( pg->text() );
} }
pg = d->document->page( selpages.last() ); pg = document->page( selpages.last() );
text.append( pg->text( pg->textSelection() ) ); text.append( pg->text( pg->textSelection() ) );
} }
return text;
}
void PageView::copyTextSelection() const
{
const QString text = d->selectedText();
if ( !text.isEmpty() ) if ( !text.isEmpty() )
{ {
QClipboard *cb = QApplication::clipboard(); QClipboard *cb = QApplication::clipboard();
cb->setText( text, QClipboard::Clipboard ); cb->setText( text, QClipboard::Clipboard );
if ( cb->supportsSelection() )
cb->setText( text, QClipboard::Selection );
} }
} }
@ -1913,6 +1918,13 @@ void PageView::contentsMouseReleaseEvent( QMouseEvent * e )
{ {
d->mouseTextSelecting = false; d->mouseTextSelecting = false;
// textSelectionClear(); // textSelectionClear();
const QString text = d->selectedText();
if ( !text.isEmpty() )
{
QClipboard *cb = QApplication::clipboard();
if ( cb->supportsSelection() )
cb->setText( text, QClipboard::Selection );
}
} }
else if ( !d->mousePressPos.isNull() && rightButton ) else if ( !d->mousePressPos.isNull() && rightButton )
{ {

Loading…
Cancel
Save