Send word to input line via context menu

This commit is contained in:
Abs62 2012-11-26 17:13:13 +04:00
parent 1bbcc29523
commit 0dcbfd849f
4 changed files with 22 additions and 0 deletions

View file

@ -999,6 +999,7 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
QAction * maxDictionaryRefsAction = 0;
QAction * addWordToHistoryAction = 0;
QAction * addHeaderToHistoryAction = 0;
QAction * sendWordToInputLineAction = 0;
QUrl targetUrl( r.linkUrl() );
Contexts contexts;
@ -1047,6 +1048,11 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
arg( ui.definition->selectedText() ),
&menu );
menu.addAction( lookupSelectionNewTab );
sendWordToInputLineAction = new QAction( tr( "Send \"%1\" to input line" ).
arg( ui.definition->selectedText() ),
&menu );
menu.addAction( sendWordToInputLineAction );
}
addWordToHistoryAction = new QAction( tr( "&Add \"%1\" to history" ).
@ -1165,6 +1171,9 @@ void ArticleView::contextMenuRequested( QPoint const & pos )
if ( result == addHeaderToHistoryAction )
emit forceAddWordToHistory( ui.definition->title() );
else
if( result == sendWordToInputLineAction )
emit sendWordToInputLine( selectedText );
else
if ( !popupView && result == followLinkNewTab )
emit openLinkInNewTab( targetUrl, ui.definition->url(), getCurrentArticle(), contexts );
else

View file

@ -205,6 +205,8 @@ signals:
/// Signal to set optional parts expand mode
void setExpandMode ( bool expand );
void sendWordToInputLine( QString const & word );
public slots:
void on_searchPrevious_clicked();

View file

@ -1063,6 +1063,9 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
connect( view, SIGNAL( sendWordToHistory( QString ) ),
this, SLOT( addWordToHistory( QString ) ) );
connect( view, SIGNAL( sendWordToInputLine( QString const & ) ),
this, SLOT(sendWordToInputLine( QString const & ) ) );
view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick );
int index = cfg.preferences.newTabsOpenAfterCurrentOne ?
@ -3052,6 +3055,12 @@ void MainWindow::foundDictsContextMenuRequested( const QPoint &pos )
}
}
void MainWindow::sendWordToInputLine( const QString & word )
{
ui.translateLine->clear();
ui.translateLine->setText( word );
}
#ifdef Q_OS_WIN32
bool MainWindow::winEvent( MSG * message, long * result )

View file

@ -348,6 +348,8 @@ private slots:
/// Add word to history even if history is disabled in options
void forceAddWordToHistory( const QString & word);
void sendWordToInputLine( QString const & word );
signals:
/// Set optional parts expand mode for all tabs
void setExpandOptionalParts( bool expand );