mirror of
https://github.com/xiaoyifang/goldendict-ng.git
synced 2024-11-27 15:24:05 +00:00
Allow dictionaries groups combobox standard hotkeys from FTS and Headwords dialogs
This commit is contained in:
parent
85e0f43d8b
commit
05bfc353a8
|
@ -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 )
|
||||
{
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <QComboBox>
|
||||
#include <QAction>
|
||||
#include <QSize>
|
||||
#include <QList>
|
||||
#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.
|
||||
|
|
|
@ -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 ) ) );
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in a new issue