Select an enire text of the current article (Ctrl+Shift+A).

Plus a context menu for that as well.
This commit is contained in:
Tvangeste 2013-01-18 15:37:24 +01:00
parent 3784ac18d7
commit 0ee62530c2
3 changed files with 22 additions and 1 deletions

View file

@ -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 ) } }"

View file

@ -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 ) );
}

View file

@ -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 );