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

View file

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

View file

@ -1063,6 +1063,9 @@ ArticleView * MainWindow::createNewTab( bool switchToIt,
connect( view, SIGNAL( sendWordToHistory( QString ) ), connect( view, SIGNAL( sendWordToHistory( QString ) ),
this, SLOT( addWordToHistory( QString ) ) ); this, SLOT( addWordToHistory( QString ) ) );
connect( view, SIGNAL( sendWordToInputLine( QString const & ) ),
this, SLOT(sendWordToInputLine( QString const & ) ) );
view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick ); view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick );
int index = cfg.preferences.newTabsOpenAfterCurrentOne ? 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 #ifdef Q_OS_WIN32
bool MainWindow::winEvent( MSG * message, long * result ) 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 /// Add word to history even if history is disabled in options
void forceAddWordToHistory( const QString & word); void forceAddWordToHistory( const QString & word);
void sendWordToInputLine( QString const & word );
signals: signals:
/// Set optional parts expand mode for all tabs /// Set optional parts expand mode for all tabs
void setExpandOptionalParts( bool expand ); void setExpandOptionalParts( bool expand );