From 46298a842cead991e271535105db546f80f88eba Mon Sep 17 00:00:00 2001 From: Abs62 Date: Mon, 17 Nov 2014 17:37:19 +0300 Subject: [PATCH] Jump to dictionary when show word from dictionary headwords dialog --- dictheadwords.cc | 4 +++- dictheadwords.hh | 3 ++- mainwindow.cc | 20 ++++++++++++++------ mainwindow.hh | 6 ++++-- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/dictheadwords.cc b/dictheadwords.cc index dc5d3831..f8b96f90 100644 --- a/dictheadwords.cc +++ b/dictheadwords.cc @@ -140,6 +140,8 @@ void DictHeadwords::setup( Dictionary::Class *dict_ ) setWindowIcon( dict->getIcon() ); + dictId = QString( dict->getId().c_str() ); + QApplication::restoreOverrideCursor(); } @@ -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 ); } } diff --git a/dictheadwords.hh b/dictheadwords.hh index 28c7de3f..ae06fdd2 100644 --- a/dictheadwords.hh +++ b/dictheadwords.hh @@ -33,6 +33,7 @@ protected: QStringListModel * model; QSortFilterProxyModel * proxy; WordListItemDelegate * delegate; + QString dictId; QAction helpAction; @@ -54,7 +55,7 @@ private slots: void helpRequested(); signals: - void headwordSelected( QString const & ); + void headwordSelected( QString const &, QString const & ); void closeDialog(); }; diff --git a/mainwindow.cc b/mainwindow.cc index 0d2c4c1f..f5d6c103 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -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() ); @@ -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 ) { @@ -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(); @@ -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(); @@ -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() ) @@ -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() ) ); } diff --git a/mainwindow.hh b/mainwindow.hh index c803d471..e2c32b98 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -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: @@ -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(); @@ -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 );