Update history when clicking links on page (issue #120)

This commit is contained in:
Abs62 2012-11-12 17:52:54 +04:00
parent 02dfa9f36a
commit 259efae81c
6 changed files with 34 additions and 12 deletions

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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