mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-12-18 03:14:06 +00:00
Update history when clicking links on page (issue #120)
This commit is contained in:
parent
02dfa9f36a
commit
259efae81c
|
@ -689,6 +689,7 @@ void ArticleView::openLink( QUrl const & url, QUrl const & ref,
|
||||||
{
|
{
|
||||||
showDefinition( url.path(),
|
showDefinition( url.path(),
|
||||||
getGroup( ref ), scrollTo, contexts );
|
getGroup( ref ), scrollTo, contexts );
|
||||||
|
emit sendWordToHistory( url.path() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if ( url.scheme() == "gdlookup" ) // Plain html links inherit gdlookup scheme
|
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() ) ) );
|
QString( "window.location = \"%1\"" ).arg( QString::fromUtf8( url.toEncoded() ) ) );
|
||||||
}
|
}
|
||||||
else
|
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
|
else
|
||||||
if ( url.scheme() == "bres" || url.scheme() == "gdau" ||
|
if ( url.scheme() == "bres" || url.scheme() == "gdau" ||
|
||||||
|
@ -1460,6 +1464,7 @@ void ArticleView::doubleClicked()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
showDefinition( selectedText, getGroup( ui.definition->url() ), getCurrentArticle() );
|
showDefinition( selectedText, getGroup( ui.definition->url() ), getCurrentArticle() );
|
||||||
|
emit sendWordToHistory( selectedText );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -169,15 +169,18 @@ signals:
|
||||||
|
|
||||||
void pageLoaded( ArticleView * );
|
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,
|
void openLinkInNewTab( QUrl const &, QUrl const & referrer,
|
||||||
QString const & fromArticle,
|
QString const & fromArticle,
|
||||||
ArticleView::Contexts const & contexts );
|
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,
|
void showDefinitionInNewTab( QString const & word, unsigned group,
|
||||||
QString const & fromArticle,
|
QString const & fromArticle,
|
||||||
ArticleView::Contexts const & contexts );
|
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
|
/// Emitted when user types a text key. This should typically be used to
|
||||||
/// switch focus to word input.
|
/// switch focus to word input.
|
||||||
void typingEvent( QString const & text );
|
void typingEvent( QString const & text );
|
||||||
|
|
|
@ -897,6 +897,9 @@ void MainWindow::makeScanPopup()
|
||||||
connect( scanPopup.get(), SIGNAL( showDictionaryInfo( const QString & ) ),
|
connect( scanPopup.get(), SIGNAL( showDictionaryInfo( const QString & ) ),
|
||||||
this, SLOT( showDictionaryInfo( const QString & ) ) );
|
this, SLOT( showDictionaryInfo( const QString & ) ) );
|
||||||
|
|
||||||
|
connect( scanPopup.get(), SIGNAL( sendWordToHistory( QString ) ),
|
||||||
|
this, SLOT( addWordToHistory( QString ) ) );
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
connect( scanPopup.get(), SIGNAL( isGoldenDictWindow( HWND ) ),
|
connect( scanPopup.get(), SIGNAL( isGoldenDictWindow( HWND ) ),
|
||||||
this, SLOT( 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( setExpandMode( bool ) ), this, SLOT( setExpandMode( bool ) ) );
|
||||||
|
|
||||||
|
connect( view, SIGNAL( sendWordToHistory( QString ) ),
|
||||||
|
this, SLOT( addWordToHistory( QString ) ) );
|
||||||
|
|
||||||
view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick );
|
view->setSelectionBySingleClick( cfg.preferences.selectWordBySingleClick );
|
||||||
|
|
||||||
int index = cfg.preferences.newTabsOpenAfterCurrentOne ?
|
int index = cfg.preferences.newTabsOpenAfterCurrentOne ?
|
||||||
|
@ -1992,11 +1998,7 @@ void MainWindow::showTranslationFor( QString const & inWord,
|
||||||
|
|
||||||
// Add to history
|
// Add to history
|
||||||
|
|
||||||
if( !showHistory )
|
addWordToHistory( inWord );
|
||||||
{
|
|
||||||
history.addItem( History::Item( group, inWord.trimmed() ) );
|
|
||||||
// history.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
updateBackForwardButtons();
|
updateBackForwardButtons();
|
||||||
|
|
||||||
|
@ -2943,6 +2945,14 @@ void MainWindow::focusWordList()
|
||||||
ui.wordList->setFocus();
|
ui.wordList->setFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::addWordToHistory( const QString & word )
|
||||||
|
{
|
||||||
|
if( !showHistory )
|
||||||
|
{
|
||||||
|
history.addItem( History::Item( 1, word.trimmed() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::forceAddWordToHistory( const QString & word )
|
void MainWindow::forceAddWordToHistory( const QString & word )
|
||||||
{
|
{
|
||||||
history.enableAdd( true );
|
history.enableAdd( true );
|
||||||
|
|
|
@ -341,6 +341,8 @@ private slots:
|
||||||
void on_importHistory_activated();
|
void on_importHistory_activated();
|
||||||
void focusWordList();
|
void focusWordList();
|
||||||
|
|
||||||
|
/// Add word to history
|
||||||
|
void addWordToHistory( const QString & word );
|
||||||
/// 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);
|
||||||
|
|
||||||
|
|
|
@ -68,6 +68,8 @@ ScanPopup::ScanPopup( QWidget * parent,
|
||||||
this, SIGNAL( forceAddWordToHistory( QString ) ) );
|
this, SIGNAL( forceAddWordToHistory( QString ) ) );
|
||||||
connect( this, SIGNAL( closeMenu() ),
|
connect( this, SIGNAL( closeMenu() ),
|
||||||
definition, SIGNAL( closePopupMenu() ) );
|
definition, SIGNAL( closePopupMenu() ) );
|
||||||
|
connect( definition, SIGNAL( sendWordToHistory( QString ) ),
|
||||||
|
this, SIGNAL( sendWordToHistory( QString ) ) );
|
||||||
|
|
||||||
applyZoomFactor();
|
applyZoomFactor();
|
||||||
|
|
||||||
|
@ -477,9 +479,7 @@ void ScanPopup::initiateTranslation()
|
||||||
definition->showDefinition( inputWord, ui.groupList->getCurrentGroup() );
|
definition->showDefinition( inputWord, ui.groupList->getCurrentGroup() );
|
||||||
wordFinder.prefixMatch( inputWord, getActiveDicts() );
|
wordFinder.prefixMatch( inputWord, getActiveDicts() );
|
||||||
|
|
||||||
history.addItem( History::Item( ui.groupList->getCurrentGroup(),
|
emit sendWordToHistory( inputWord.trimmed() );
|
||||||
inputWord.trimmed() ) );
|
|
||||||
// history.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vector< sptr< Dictionary::Class > > const & ScanPopup::getActiveDicts()
|
vector< sptr< Dictionary::Class > > const & ScanPopup::getActiveDicts()
|
||||||
|
|
|
@ -62,6 +62,8 @@ signals:
|
||||||
void forceAddWordToHistory( const QString & word);
|
void forceAddWordToHistory( const QString & word);
|
||||||
/// Retranslate signal from dictionary bar
|
/// Retranslate signal from dictionary bar
|
||||||
void showDictionaryInfo( QString const & id );
|
void showDictionaryInfo( QString const & id );
|
||||||
|
/// Put translated word into history
|
||||||
|
void sendWordToHistory( QString const & word );
|
||||||
|
|
||||||
#ifdef Q_OS_WIN32
|
#ifdef Q_OS_WIN32
|
||||||
/// Ask for source window is current translate tab
|
/// Ask for source window is current translate tab
|
||||||
|
|
Loading…
Reference in a new issue