From 05bfc353a814ff15bfdd44119d1af8d6f92b65a8 Mon Sep 17 00:00:00 2001 From: Abs62 Date: Tue, 9 Jul 2019 18:00:23 +0300 Subject: [PATCH] Allow dictionaries groups combobox standard hotkeys from FTS and Headwords dialogs --- groupcombobox.cc | 9 ++++++++- groupcombobox.hh | 4 ++++ mainwindow.cc | 24 ++++++++++++++++++++++++ mainwindow.hh | 2 ++ 4 files changed, 38 insertions(+), 1 deletion(-) diff --git a/groupcombobox.cc b/groupcombobox.cc index 7739b35c..ed305e76 100644 --- a/groupcombobox.cc +++ b/groupcombobox.cc @@ -83,9 +83,16 @@ bool GroupComboBox::event( QEvent * event ) } return QComboBox::event( event ); - } +QList< QAction * > GroupComboBox::getExternActions() +{ + QList< QAction * > list; + list.append( &popupAction ); + list.append( &selectNextAction ); + list.append( &selectPreviousAction ); + return list; +} void GroupComboBox::setCurrentGroup( unsigned id ) { diff --git a/groupcombobox.hh b/groupcombobox.hh index a7e92174..cfce87c4 100644 --- a/groupcombobox.hh +++ b/groupcombobox.hh @@ -7,6 +7,7 @@ #include #include #include +#include #include "instances.hh" /// This is a combo box which is for choosing the dictionary group @@ -29,6 +30,9 @@ public: /// Returns current group. unsigned getCurrentGroup() const; + /// Return actions which should be accessible from FTS and Headwords dialogs + QList< QAction * > getExternActions(); + protected: /// We handle shortcut events here. diff --git a/mainwindow.cc b/mainwindow.cc index fcf1a0b6..0c57929b 100644 --- a/mainwindow.cc +++ b/mainwindow.cc @@ -887,6 +887,11 @@ void MainWindow::updateSearchPaneAndBar( bool searchInDock ) { QString text = translateLine->text(); + if( ftsDlg ) + removeGroupComboBoxActionsFromDialog( ftsDlg, groupList ); + if( headwordsDlg ) + removeGroupComboBoxActionsFromDialog( headwordsDlg, groupList ); + if ( searchInDock ) { cfg.preferences.searchInDock = true; @@ -925,6 +930,11 @@ void MainWindow::updateSearchPaneAndBar( bool searchInDock ) translateBoxToolBarAction->setVisible( true ); } + if( ftsDlg ) + addGroupComboBoxActionsToDialog( ftsDlg, groupList ); + if( headwordsDlg ) + addGroupComboBoxActionsToDialog( headwordsDlg, groupList ); + translateLine->setToolTip( tr( "String to search in dictionaries. The wildcards '*', '?' and sets of symbols '[...]' are allowed.\nTo find '*', '?', '[', ']' symbols use '\\*', '\\?', '\\[', '\\]' respectively" ) ); // reset the flag when switching UI modes @@ -1029,6 +1039,18 @@ void MainWindow::addGlobalActionsToDialog( QDialog * dialog ) dialog->addAction( ui.fullTextSearchAction ); } +void MainWindow::addGroupComboBoxActionsToDialog( QDialog * dialog, GroupComboBox * pGroupComboBox ) +{ + dialog->addActions( pGroupComboBox->getExternActions() ); +} + +void MainWindow::removeGroupComboBoxActionsFromDialog( QDialog * dialog, GroupComboBox * pGroupComboBox ) +{ + QList< QAction * > actions = pGroupComboBox->getExternActions(); + for( QList< QAction * >::iterator it = actions.begin(); it != actions.end(); ++it ) + dialog->removeAction( *it ); +} + void MainWindow::commitData( QSessionManager & ) { commitData(); @@ -4255,6 +4277,7 @@ void MainWindow::showDictionaryHeadwords( QWidget * owner, Dictionary::Class * d { headwordsDlg = new DictHeadwords( this, cfg, dict ); addGlobalActionsToDialog( headwordsDlg ); + addGroupComboBoxActionsToDialog( headwordsDlg, groupList ); connect( headwordsDlg, SIGNAL( headwordSelected( QString, QString ) ), this, SLOT( headwordReceived( QString, QString ) ) ); connect( headwordsDlg, SIGNAL( closeDialog() ), @@ -4515,6 +4538,7 @@ void MainWindow::showFullTextSearchDialog() { ftsDlg = new FTS::FullTextSearchDialog( this, cfg, dictionaries, groupInstances, ftsIndexing ); addGlobalActionsToDialog( ftsDlg ); + addGroupComboBoxActionsToDialog( ftsDlg, groupList ); connect( ftsDlg, SIGNAL( showTranslationFor( QString, QStringList, QRegExp, bool ) ), this, SLOT( showTranslationFor( QString, QStringList, QRegExp, bool ) ) ); diff --git a/mainwindow.hh b/mainwindow.hh index 473b7ecd..820df6c1 100644 --- a/mainwindow.hh +++ b/mainwindow.hh @@ -91,6 +91,8 @@ public slots: private: void addGlobalAction( QAction * action, const char * slot ); void addGlobalActionsToDialog( QDialog * dialog ); + void addGroupComboBoxActionsToDialog( QDialog * dialog, GroupComboBox * pGroupComboBox ); + void removeGroupComboBoxActionsFromDialog( QDialog * dialog, GroupComboBox * pGroupComboBox ); void commitData();