diff --git a/article_maker.cc b/article_maker.cc index 27f21582..4938472e 100644 --- a/article_maker.cc +++ b/article_maker.cc @@ -125,6 +125,10 @@ std::string ArticleMaker::makeHtmlHeader( QString const & word, "gdCurrentArticle = 'gdfrom-' + newId; articleview.onJsActiveArticleChanged(gdCurrentArticle);" "eval( 'gdActivateAudioLink_' + newId + '();' ); } }" "var overIframeId = null;" + "function gdSelectArticle( id ) {" + "var selection = window.getSelection(); var range = document.createRange();" + "range.selectNodeContents(document.getElementById('gdfrom-' + id));" + "selection.removeAllRanges(); selection.addRange(range); }" "function processIframeMouseOut() { overIframeId = null; top.focus(); }" "function processIframeMouseOver( newId ) { overIframeId = newId; }" "function processIframeClick() { if( overIframeId != null ) { overIframeId = overIframeId.replace( 'gdexpandframe-', '' ); gdMakeArticleActive( overIframeId ) } }" diff --git a/articleview.cc b/articleview.cc index b08fb7b5..96b00b63 100644 --- a/articleview.cc +++ b/articleview.cc @@ -87,6 +87,7 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, goBackAction( this ), goForwardAction( this ), openSearchAction( this ), + selectCurrentArticleAction( this ), searchIsOpened( false ), dictionaryBarToggled( dictionaryBarToggled_ ), groupComboBox( groupComboBox_ ) @@ -157,6 +158,12 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, ui.definition->addAction( &openSearchAction ); connect( &openSearchAction, SIGNAL( triggered() ), this, SLOT( openSearch() ) ); + selectCurrentArticleAction.setShortcut( QKeySequence( "Ctrl+Shift+A" )); + selectCurrentArticleAction.setText( tr( "Select Current Article" ) ); + ui.definition->addAction( &selectCurrentArticleAction ); + connect( &selectCurrentArticleAction, SIGNAL( triggered() ), + this, SLOT( selectCurrentArticle() ) ); + ui.definition->installEventFilter( this ); // Load the default blank page instantly, so there would be no flicker. @@ -448,6 +455,12 @@ void ArticleView::setCurrentArticle( QString const & id, bool moveToIt ) } } +void ArticleView::selectCurrentArticle() +{ + ui.definition->page()->mainFrame()->evaluateJavaScript( + QString( "gdSelectArticle( '%1' );" ).arg( getActiveArticleId() ) ); +} + bool ArticleView::isFramedArticle( QString const & ca ) { if ( ca.isEmpty() ) @@ -1128,6 +1141,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos ) } else { + menu.addAction( &selectCurrentArticleAction ); menu.addAction( ui.definition->pageAction( QWebPage::SelectAll ) ); } diff --git a/articleview.hh b/articleview.hh index da7cf395..5b933545 100644 --- a/articleview.hh +++ b/articleview.hh @@ -28,7 +28,7 @@ class ArticleView: public QFrame Ui::ArticleView ui; QAction pasteAction, articleUpAction, articleDownAction, - goBackAction, goForwardAction, openSearchAction; + goBackAction, goForwardAction, openSearchAction, selectCurrentArticleAction; bool searchIsOpened; bool expandOptionalParts; QString articleToJump; @@ -219,6 +219,9 @@ public slots: void receiveExpandOptionalParts( bool expand ); void switchExpandOptionalParts(); + /// Selects an entire text of the current article + void selectCurrentArticle(); + private slots: void loadFinished( bool ok );