Skip to content

Commit

Permalink
Jump to dictionary when show word from dictionary headwords dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Abs62 committed Nov 17, 2014
1 parent e107975 commit 46298a8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
4 changes: 3 additions & 1 deletion dictheadwords.cc
Expand Up @@ -140,6 +140,8 @@ void DictHeadwords::setup( Dictionary::Class *dict_ )

setWindowIcon( dict->getIcon() );

dictId = QString( dict->getId().c_str() );

QApplication::restoreOverrideCursor();
}

Expand Down Expand Up @@ -219,7 +221,7 @@ void DictHeadwords::itemClicked( const QModelIndex & index )
if ( value.canConvert< QString >() )
{
QString headword = value.toString();
emit headwordSelected( headword );
emit headwordSelected( headword, dictId );
}
}

Expand Down
3 changes: 2 additions & 1 deletion dictheadwords.hh
Expand Up @@ -33,6 +33,7 @@ protected:
QStringListModel * model;
QSortFilterProxyModel * proxy;
WordListItemDelegate * delegate;
QString dictId;

QAction helpAction;

Expand All @@ -54,7 +55,7 @@ private slots:
void helpRequested();

signals:
void headwordSelected( QString const & );
void headwordSelected( QString const &, QString const & );
void closeDialog();
};

Expand Down
20 changes: 14 additions & 6 deletions mainwindow.cc
Expand Up @@ -2102,7 +2102,7 @@ void MainWindow::translateInputChanged( QString const & newValue )
wordFinder.prefixMatch( req, getActiveDicts() );
}

void MainWindow::translateInputFinished( bool checkModifiers )
void MainWindow::translateInputFinished( bool checkModifiers, QString const & dictID )
{
QString word = Folding::unescapeWildcardSymbols( translateLine->text() );

Expand All @@ -2112,7 +2112,7 @@ void MainWindow::translateInputFinished( bool checkModifiers )
if ( checkModifiers && ( mods & (Qt::ControlModifier | Qt::ShiftModifier) ) )
addNewTab();

showTranslationFor( word );
showTranslationFor( word, 0, dictID );

if ( cfg.preferences.searchInDock )
{
Expand Down Expand Up @@ -2536,7 +2536,8 @@ void MainWindow::showHistoryItem( QString const & word )
}

void MainWindow::showTranslationFor( QString const & inWord,
unsigned inGroup )
unsigned inGroup,
QString const & dictID )
{
ArticleView *view = getCurrentArticleView();

Expand All @@ -2546,7 +2547,7 @@ void MainWindow::showTranslationFor( QString const & inWord,
( groupInstances.empty() ? 0 :
groupInstances[ groupList->currentIndex() ].id );

view->showDefinition( inWord, group );
view->showDefinition( inWord, group, dictID );

updatePronounceAvailability();
updateFoundInDictsList();
Expand Down Expand Up @@ -3507,6 +3508,13 @@ void MainWindow::wordReceived( const QString & word)
translateInputFinished( false );
}

void MainWindow::headwordReceived( const QString & word, const QString & ID )
{
toggleMainWindow( true );
translateLine->setText( Folding::escapeWildcardSymbols( word ) );
translateInputFinished( false, QString( "gdfrom-" )+ ID );
}

void MainWindow::updateHistoryMenu()
{
if ( ui.historyPane->toggleViewAction()->isChecked() )
Expand Down Expand Up @@ -3766,8 +3774,8 @@ void MainWindow::showDictionaryHeadwords( Dictionary::Class * dict )
{
headwordsDlg = new DictHeadwords( this, cfg, dict );
addGlobalActionsToDialog( headwordsDlg );
connect( headwordsDlg, SIGNAL( headwordSelected( QString ) ),
this, SLOT( wordReceived( QString ) ) );
connect( headwordsDlg, SIGNAL( headwordSelected( QString, QString ) ),
this, SLOT( headwordReceived( QString, QString ) ) );
connect( headwordsDlg, SIGNAL( closeDialog() ),
this, SLOT( closeHeadwordsDialog() ) );
}
Expand Down
6 changes: 4 additions & 2 deletions mainwindow.hh
Expand Up @@ -77,6 +77,7 @@ public slots:
void messageFromAnotherInstanceReceived( QString const & );
void showStatusBarMessage ( QString const &, int, QPixmap const & );
void wordReceived( QString const & );
void headwordReceived( QString const &, QString const & );
void setExpandMode( bool expand );

private:
Expand Down Expand Up @@ -329,7 +330,7 @@ private slots:

void currentGroupChanged( QString const & );
void translateInputChanged( QString const & );
void translateInputFinished( bool checkModifiers = true );
void translateInputFinished( bool checkModifiers = true, QString const & dictID = QString() );

/// Closes any opened search in the article view, and focuses the translateLine/close main window to tray.
void handleEsc();
Expand Down Expand Up @@ -364,7 +365,8 @@ private slots:

void mutedDictionariesChanged();

void showTranslationFor( QString const &, unsigned inGroup = 0 );
void showTranslationFor( QString const &, unsigned inGroup = 0,
QString const & dictID = QString() );

void showTranslationFor( QString const &, QStringList const & dictIDs,
QRegExp const & searchRegExp );
Expand Down

0 comments on commit 46298a8

Please sign in to comment.