From 0dcbfd849fb1210a740bb46510fb2bf3c8d509a2 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Mon, 26 Nov 2012 17:13:13 +0400 Subject: [PATCH] Send word to input line via context menu --- articleview.cc | 9 +++++++++ articleview.hh | 2 ++ mainwindow.cc | 9 +++++++++ mainwindow.hh | 2 ++ 4 files changed, 22 insertions(+) diff --git a/articleview.cc b/articleview.cc index c8d67b7f..b9ce5a90 100644 --- a/articleview.cc +++ b/articleview.cc @@ -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 diff --git a/articleview.hh b/articleview.hh index 4355c989..519bf112 100644 --- a/articleview.hh +++ b/articleview.hh @@ -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(); diff --git a/mainwindow.cc b/mainwindow.cc index 5093a153..f9efc428 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -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 ) diff --git a/mainwindow.hh b/mainwindow.hh index 3156d010..a4392f3a 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -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 );