diff --git a/articleview.cc b/articleview.cc index 65d8f6c0..bc6e3bb7 100644 --- a/articleview.cc +++ b/articleview.cc @@ -689,6 +689,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, { showDefinition( url.path(), getGroup( ref ), scrollTo, contexts ); + emit sendWordToHistory( url.path() ); } else if ( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme @@ -699,8 +700,11 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref, QString( "window.location = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) ); } else - showDefinition( url.path().mid( 1 ), - getGroup( ref ), scrollTo, contexts ); + { + showDefinition( url.path().mid( 1 ), + getGroup( ref ), scrollTo, contexts ); + emit sendWordToHistory( url.path().mid( 1 ) ); + } } else if ( url.scheme() == "bres" || url.scheme() == "gdau" || @@ -1460,6 +1464,7 @@ void ArticleView::doubleClicked() } else showDefinition( selectedText, getGroup( ui.definition->url() ), getCurrentArticle() ); + emit sendWordToHistory( selectedText ); } } } diff --git a/articleview.hh b/articleview.hh index 11ad64e0..4355c989 100644 --- a/articleview.hh +++ b/articleview.hh @@ -169,15 +169,18 @@ signals: void pageLoaded( ArticleView * ); - /// Singals that the following link was requested to be opened in new tab + /// Signals that the following link was requested to be opened in new tab void openLinkInNewTab( QUrl const &, QUrl const & referrer, QString const & fromArticle, ArticleView::Contexts const & contexts ); - /// Singals that the following definition was requested to be showed in new tab + /// Signals that the following definition was requested to be showed in new tab void showDefinitionInNewTab( QString const & word, unsigned group, QString const & fromArticle, ArticleView::Contexts const & contexts ); + /// Put translated word into history + void sendWordToHistory( QString const & word ); + /// Emitted when user types a text key. This should typically be used to /// switch focus to word input. void typingEvent( QString const & text ); diff --git a/mainwindow.cc b/mainwindow.cc index c6326262..4386ee2f 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -897,6 +897,9 @@ void MainWindow::makeScanPopup() connect( scanPopup.get(), SIGNAL( showDictionaryInfo( const QString & ) ), this, SLOT( showDictionaryInfo( const QString & ) ) ); + connect( scanPopup.get(), SIGNAL( sendWordToHistory( QString ) ), + this, SLOT( addWordToHistory( QString ) ) ); + #ifdef Q_OS_WIN32 connect( scanPopup.get(), SIGNAL( isGoldenDictWindow( HWND ) ), this, SLOT( isGoldenDictWindow( HWND ) ) ); @@ -1052,6 +1055,9 @@ ArticleView * MainWindow::createNewTab( bool switchToIt, connect( view, SIGNAL( setExpandMode( bool ) ), this, SLOT( setExpandMode( bool ) ) ); + connect( view, SIGNAL( sendWordToHistory( QString ) ), + this, SLOT( addWordToHistory( QString ) ) ); + view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick ); int index = cfg.preferences.newTabsOpenAfterCurrentOne ? @@ -1992,11 +1998,7 @@ void MainWindow::showTranslationFor( QString const & inWord, // Add to history - if( !showHistory ) - { - history.addItem( History::Item( group, inWord.trimmed() ) ); -// history.save(); - } + addWordToHistory( inWord ); updateBackForwardButtons(); @@ -2943,6 +2945,14 @@ void MainWindow::focusWordList() ui.wordList->setFocus(); } +void MainWindow::addWordToHistory( const QString & word ) +{ + if( !showHistory ) + { + history.addItem( History::Item( 1, word.trimmed() ) ); + } +} + void MainWindow::forceAddWordToHistory( const QString & word ) { history.enableAdd( true ); diff --git a/mainwindow.hh b/mainwindow.hh index fcf6a5f8..b6c7c0d4 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -341,6 +341,8 @@ private slots: void on_importHistory_activated(); void focusWordList(); + /// Add word to history + void addWordToHistory( const QString & word ); /// Add word to history even if history is disabled in options void forceAddWordToHistory( const QString & word); diff --git a/scanpopup.cc b/scanpopup.cc index 41d70359..6d010437 100644 --- a/scanpopup.cc +++ b/scanpopup.cc @@ -68,6 +68,8 @@ ScanPopup::ScanPopup( QWidget * parent, this, SIGNAL( forceAddWordToHistory( QString ) ) ); connect( this, SIGNAL( closeMenu() ), definition, SIGNAL( closePopupMenu() ) ); + connect( definition, SIGNAL( sendWordToHistory( QString ) ), + this, SIGNAL( sendWordToHistory( QString ) ) ); applyZoomFactor(); @@ -477,9 +479,7 @@ void ScanPopup::initiateTranslation() definition->showDefinition( inputWord, ui.groupList->getCurrentGroup() ); wordFinder.prefixMatch( inputWord, getActiveDicts() ); - history.addItem( History::Item( ui.groupList->getCurrentGroup(), - inputWord.trimmed() ) ); -// history.save(); + emit sendWordToHistory( inputWord.trimmed() ); } vector< sptr< Dictionary::Class > > const & ScanPopup::getActiveDicts() diff --git a/scanpopup.hh b/scanpopup.hh index b6bc96e3..689b513b 100644 --- a/scanpopup.hh +++ b/scanpopup.hh @@ -62,6 +62,8 @@ signals: void forceAddWordToHistory( const QString & word); /// Retranslate signal from dictionary bar void showDictionaryInfo( QString const & id ); + /// Put translated word into history + void sendWordToHistory( QString const & word ); #ifdef Q_OS_WIN32 /// Ask for source window is current translate tab