Show headwords from dictionaries setup dialog in modal mode

This commit is contained in:
Abs62 2015-03-23 18:58:49 +03:00
parent d401e57913
commit 9d82ae4622
4 changed files with 54 additions and 19 deletions

View file

@ -14,7 +14,7 @@
#define AUTO_APPLY_LIMIT 150000
DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
Dictionary::Class * dict_ ) :
Dictionary::Class * dict_ ) :
QDialog(parent)
, cfg( cfg_ )
, dict( dict_ )
@ -25,7 +25,11 @@ DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
if( cfg.headwordsDialog.headwordsDialogGeometry.size() > 0 )
restoreGeometry( cfg.headwordsDialog.headwordsDialogGeometry );
setAttribute( Qt::WA_DeleteOnClose, false );
bool fromMainWindow = parent->objectName() == "MainWindow";
if( fromMainWindow )
setAttribute( Qt::WA_DeleteOnClose, false );
setWindowFlags( windowFlags() & ~Qt::WindowContextHelpButtonHint );
ui.searchModeCombo->addItem( tr( "Text" ), QRegExp::FixedString );
@ -65,6 +69,25 @@ DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
connect( this, SIGNAL( finished( int ) ), this, SLOT( savePos() ) );
if( !fromMainWindow )
{
ui.helpButton->hide();
connect( this, SIGNAL( closeDialog() ), this, SLOT( accept() ) );
}
else
{
connect( ui.helpButton, SIGNAL( clicked() ),
this, SLOT( helpRequested() ) );
helpAction.setShortcut( QKeySequence( "F1" ) );
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
connect( &helpAction, SIGNAL( triggered() ),
this, SLOT( helpRequested() ) );
addAction( &helpAction );
}
connect( ui.OKButton, SIGNAL( clicked( bool ) ), this, SLOT( okButtonClicked() ) );
connect( ui.exportButton, SIGNAL( clicked( bool ) ), this, SLOT( exportButtonClicked() ) );
connect( ui.applyButton, SIGNAL( clicked( bool ) ), this, SLOT( filterChanged() ) );
@ -85,17 +108,6 @@ DictHeadwords::DictHeadwords( QWidget *parent, Config::Class & cfg_,
connect( proxy, SIGNAL( dataChanged( QModelIndex, QModelIndex ) ),
this, SLOT( showHeadwordsNumber() ) );
connect( ui.helpButton, SIGNAL( clicked() ),
this, SLOT( helpRequested() ) );
helpAction.setShortcut( QKeySequence( "F1" ) );
helpAction.setShortcutContext( Qt::WidgetWithChildrenShortcut );
connect( &helpAction, SIGNAL( triggered() ),
this, SLOT( helpRequested() ) );
addAction( &helpAction );
ui.headersListView->installEventFilter( this );
setup( dict_ );

View file

@ -21,7 +21,7 @@ class DictHeadwords : public QDialog
public:
explicit DictHeadwords( QWidget * parent, Config::Class & cfg_,
Dictionary::Class * dict_ );
Dictionary::Class * dict_ );
virtual ~DictHeadwords();
void setup( Dictionary::Class * dict_ );

View file

@ -3738,6 +3738,14 @@ void MainWindow::foundDictsPaneClicked( QListWidgetItem * item )
void MainWindow::showDictionaryInfo( const QString & id )
{
QWidget * owner = 0;
if( sender()->objectName().compare( "EditDictionaries" ) == 0 )
owner = qobject_cast< QWidget * >( sender() );
if( owner == 0 )
owner = this;
for( unsigned x = 0; x < dictionaries.size(); x++ )
{
if( dictionaries[ x ]->getId() == id.toUtf8().data() )
@ -3756,7 +3764,7 @@ void MainWindow::showDictionaryInfo( const QString & id )
}
else if( result == DictInfo::SHOW_HEADWORDS )
{
showDictionaryHeadwords( dictionaries[x].get() );
showDictionaryHeadwords( owner, dictionaries[x].get() );
}
break;
@ -3766,18 +3774,33 @@ void MainWindow::showDictionaryInfo( const QString & id )
void MainWindow::showDictionaryHeadwords( const QString & id )
{
QWidget * owner = 0;
if( sender()->objectName().compare( "EditDictionaries" ) == 0 )
owner = qobject_cast< QWidget * >( sender() );
if( owner == 0 )
owner = this;
for( unsigned x = 0; x < dictionaries.size(); x++ )
{
if( dictionaries[ x ]->getId() == id.toUtf8().data() )
{
showDictionaryHeadwords( dictionaries[ x ].get() );
showDictionaryHeadwords( owner, dictionaries[ x ].get() );
break;
}
}
}
void MainWindow::showDictionaryHeadwords( Dictionary::Class * dict )
void MainWindow::showDictionaryHeadwords( QWidget * owner, Dictionary::Class * dict )
{
if( owner && owner != this )
{
DictHeadwords headwords( owner, cfg, dict );
headwords.exec();
return;
}
if( headwordsDlg == 0 )
{
headwordsDlg = new DictHeadwords( this, cfg, dict );
@ -3951,7 +3974,7 @@ void MainWindow::foundDictsContextMenuRequested( const QPoint &pos )
{
if ( scanPopup )
scanPopup.get()->blockSignals( true );
showDictionaryHeadwords( pDict );
showDictionaryHeadwords( this, pDict );
if ( scanPopup )
scanPopup.get()->blockSignals( false );
}

View file

@ -237,7 +237,7 @@ private:
void fillWordListFromHistory();
void showDictionaryHeadwords( Dictionary::Class * dict );
void showDictionaryHeadwords( QWidget * owner, Dictionary::Class * dict );
private slots: