Added Apply button to the Dictionaries configuration dialog.

This commit is contained in:
Tvangeste 2011-06-13 14:30:49 +02:00
parent f12a8e6761
commit a30a13323b
3 changed files with 23 additions and 2 deletions

View file

@ -42,6 +42,9 @@ EditDictionaries::EditDictionaries( QWidget * parent, Config::Class & cfg_,
ui.tabs->addTab( orderAndProps.get(), QIcon(":/icons/book.png"), tr( "&Dictionaries" ) ); ui.tabs->addTab( orderAndProps.get(), QIcon(":/icons/book.png"), tr( "&Dictionaries" ) );
ui.tabs->addTab( groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) ); ui.tabs->addTab( groups.get(), QIcon(":/icons/bookcase.png"), tr( "&Groups" ) );
connect( ui.buttons, SIGNAL( clicked( QAbstractButton * ) ),
this, SLOT( buttonBoxClicked( QAbstractButton * ) ) );
connect( &sources, SIGNAL( rescan() ), this, SLOT( rescanSources() ) ); connect( &sources, SIGNAL( rescan() ), this, SLOT( rescanSources() ) );
} }
@ -56,7 +59,7 @@ void EditDictionaries::editGroup( unsigned id )
} }
} }
void EditDictionaries::accept() void EditDictionaries::save()
{ {
Config::Groups newGroups = groups->getGroups(); Config::Groups newGroups = groups->getGroups();
Config::Group newOrder = orderAndProps->getCurrentDictionaryOrder(); Config::Group newOrder = orderAndProps->getCurrentDictionaryOrder();
@ -73,7 +76,11 @@ void EditDictionaries::accept()
cfg.dictionaryOrder = newOrder; cfg.dictionaryOrder = newOrder;
cfg.inactiveDictionaries = newInactive; cfg.inactiveDictionaries = newInactive;
} }
}
void EditDictionaries::accept()
{
save();
QDialog::accept(); QDialog::accept();
} }
@ -132,6 +139,16 @@ void EditDictionaries::rescanSources()
acceptChangedSources( true ); acceptChangedSources( true );
} }
void EditDictionaries::buttonBoxClicked( QAbstractButton * button )
{
if (ui.buttons->buttonRole(button) == QDialogButtonBox::ApplyRole) {
if ( isSourcesChanged() ) {
acceptChangedSources( true );
}
save();
}
}
bool EditDictionaries::isSourcesChanged() const bool EditDictionaries::isSourcesChanged() const
{ {
return sources.getPaths() != cfg.paths || return sources.getPaths() != cfg.paths ||

View file

@ -43,6 +43,8 @@ private slots:
void on_tabs_currentChanged( int index ); void on_tabs_currentChanged( int index );
void buttonBoxClicked( QAbstractButton * button );
void rescanSources(); void rescanSources();
private: private:
@ -50,6 +52,8 @@ private:
bool isSourcesChanged() const; bool isSourcesChanged() const;
void acceptChangedSources( bool rebuildGroups ); void acceptChangedSources( bool rebuildGroups );
void save();
private: private:

View file

@ -32,7 +32,7 @@
<enum>Qt::Horizontal</enum> <enum>Qt::Horizontal</enum>
</property> </property>
<property name="standardButtons"> <property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set> <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property> </property>
</widget> </widget>
</item> </item>