From a30a13323ba3ff5b36f9cf555bcd6eb3acb006b1 Mon Sep 17 00:00:00 2001 From: Tvangeste Date: Mon, 13 Jun 2011 14:30:49 +0200 Subject: [PATCH] Added Apply button to the Dictionaries configuration dialog. --- editdictionaries.cc | 19 ++++++++++++++++++- editdictionaries.hh | 4 ++++ editdictionaries.ui | 2 +- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/editdictionaries.cc b/editdictionaries.cc index 43dc3ba1..056435e0 100644 --- a/editdictionaries.cc +++ b/editdictionaries.cc @@ -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( 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() ) ); } @@ -56,7 +59,7 @@ void EditDictionaries::editGroup( unsigned id ) } } -void EditDictionaries::accept() +void EditDictionaries::save() { Config::Groups newGroups = groups->getGroups(); Config::Group newOrder = orderAndProps->getCurrentDictionaryOrder(); @@ -73,7 +76,11 @@ void EditDictionaries::accept() cfg.dictionaryOrder = newOrder; cfg.inactiveDictionaries = newInactive; } +} +void EditDictionaries::accept() +{ + save(); QDialog::accept(); } @@ -132,6 +139,16 @@ void EditDictionaries::rescanSources() acceptChangedSources( true ); } +void EditDictionaries::buttonBoxClicked( QAbstractButton * button ) +{ + if (ui.buttons->buttonRole(button) == QDialogButtonBox::ApplyRole) { + if ( isSourcesChanged() ) { + acceptChangedSources( true ); + } + save(); + } +} + bool EditDictionaries::isSourcesChanged() const { return sources.getPaths() != cfg.paths || diff --git a/editdictionaries.hh b/editdictionaries.hh index 2665dde4..80d1ecd1 100644 --- a/editdictionaries.hh +++ b/editdictionaries.hh @@ -43,6 +43,8 @@ private slots: void on_tabs_currentChanged( int index ); + void buttonBoxClicked( QAbstractButton * button ); + void rescanSources(); private: @@ -50,6 +52,8 @@ private: bool isSourcesChanged() const; void acceptChangedSources( bool rebuildGroups ); + + void save(); private: diff --git a/editdictionaries.ui b/editdictionaries.ui index f39b158d..3e40ded8 100644 --- a/editdictionaries.ui +++ b/editdictionaries.ui @@ -32,7 +32,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok