author | ulf69 <ulf69> | 2004-09-21 19:54:39 (UTC) |
---|---|---|
committer | ulf69 <ulf69> | 2004-09-21 19:54:39 (UTC) |
commit | 618dec7bf4371c2085048cc1f95a93220bc8a233 (patch) (side-by-side diff) | |
tree | df5e3e47a417400fa9f6871912eda6558294d9b4 /kaddressbook | |
parent | 186ee062d9169860fbab1613ca21b956c69296a6 (diff) | |
download | kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.zip kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.tar.gz kdepimpi-618dec7bf4371c2085048cc1f95a93220bc8a233.tar.bz2 |
modified configdialog to work properly with global configwidget from (libkdepim)
-rw-r--r-- | kaddressbook/kabcore.cpp | 9 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 32 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 20 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.cpp | 16 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.h | 2 |
5 files changed, 26 insertions, 53 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4ebd6a8..1b40d71 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -1274,35 +1274,30 @@ QString KABCore::getNameByPhone( const QString &phone ) } return ownerName; #else //KAB_EMBEDDED qDebug("KABCore::getNameByPhone finsih method"); return ""; #endif //KAB_EMBEDDED } void KABCore::openConfigDialog() { - KABPrefs* kab_prefs = KABPrefs::instance(); - KPimGlobalPrefs* kpim_prefs = KPimGlobalPrefs::instance(); - KCMultiDialog* ConfigureDialog = new KCMultiDialog( "PIM", this ,"kabconfigdialog", true ); - KCMKabConfig* kabcfg = new KCMKabConfig( kab_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); + KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); ConfigureDialog->addModule(kabcfg ); - KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); + KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); ConfigureDialog->addModule(kdelibcfg ); - - connect( ConfigureDialog, SIGNAL( applyClicked() ), this, SLOT( configurationChanged() ) ); connect( ConfigureDialog, SIGNAL( okClicked() ), this, SLOT( configurationChanged() ) ); saveSettings(); #ifndef DESKTOP_VERSION ConfigureDialog->showMaximized(); #endif if ( ConfigureDialog->exec() ) KMessageBox::information( this, i18n("Some changes are only\neffective after a restart!\n") ); delete ConfigureDialog; } diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 0c3a199..e970c3d 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp @@ -76,26 +76,26 @@ class ExtensionItem : public QCheckListItem private: #ifndef KAB_EMBEDDED KService::Ptr mPtr; #else //KAB_EMBEDDED ExtensionFactory* mFactory; QString mName; QString mComment; #endif //KAB_EMBEDDED }; -KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) - : QWidget( parent, name ) +KABConfigWidget::KABConfigWidget( KABPrefs* prefs, QWidget *parent, const char *name ) + : KPrefsWidget( prefs, parent, name ) { QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); QTabWidget *tabWidget = new QTabWidget( this ); topLayout->addWidget( tabWidget ); // General page QWidget *generalPage = new QWidget( this ); QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), KDialog::spacingHintSmall() ); //general groupbox @@ -164,77 +164,59 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) connect( mConfigureButton, SIGNAL( clicked() ), SLOT( configureExtension() ) ); tabWidget->addTab( extensionPage, i18n( "Extensions" ) ); // Addressee page mAddresseeWidget = new AddresseeWidget( this ); tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); } - -void KABConfigWidget::restoreSettings(KABPrefs* prefs) +void KABConfigWidget::usrReadConfig() { -//US prefs was KABPrefs::instance() before + KABPrefs* prefs = KABPrefs::instance(); bool blocked = signalsBlocked(); blockSignals( true ); mNameParsing->setChecked( prefs->mAutomaticNameParsing ); mViewsSingleClickBox->setChecked( prefs->mHonorSingleClick ); mSearchReturnBox->setChecked( prefs->mSearchWithReturn ); mMultipleViewsAtOnce->setChecked( prefs->mMultipleViewsAtOnce ); mAskForQuit->setChecked( prefs->mAskForQuit ); mAddresseeWidget->restoreSettings(); restoreExtensionSettings(); blockSignals( blocked ); - emit changed( false ); } -void KABConfigWidget::saveSettings(KABPrefs* prefs) +void KABConfigWidget::usrWriteConfig() { + KABPrefs* prefs = KABPrefs::instance(); + prefs->mAutomaticNameParsing = mNameParsing->isChecked(); prefs->mHonorSingleClick = mViewsSingleClickBox->isChecked(); prefs->mSearchWithReturn = mSearchReturnBox->isChecked(); prefs->mMultipleViewsAtOnce = mMultipleViewsAtOnce->isChecked(); prefs->mAskForQuit = mAskForQuit->isChecked(); mAddresseeWidget->saveSettings(); saveExtensionSettings(); - KABPrefs::instance()->writeConfig(); - emit changed( false ); -} - -void KABConfigWidget::defaults(KABPrefs* prefs) -{ - mNameParsing->setChecked( true ); - mViewsSingleClickBox->setChecked( false ); - mMultipleViewsAtOnce->setChecked( true ); - mSearchReturnBox->setChecked( true ); - mAskForQuit->setChecked (true); - - emit changed( true ); -} - -void KABConfigWidget::modified() -{ - emit changed( true ); } void KABConfigWidget::restoreExtensionSettings() { QStringList activeExtensions = KABPrefs::instance()->mActiveExtensions; mExtensionView->clear(); #ifndef KAB_EMBEDDED KTrader::OfferList plugins = KTrader::self()->query( "KAddressBook/Extension" ); KTrader::OfferList::ConstIterator it; for ( it = plugins.begin(); it != plugins.end(); ++it ) { diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h index 6cd4223..1e71fd1 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.h +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h @@ -15,52 +15,48 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #ifndef KABCONFIGWIDGET_H #define KABCONFIGWIDGET_H -#include <qwidget.h> +#include <kprefswidget.h> class QCheckBox; class QListViewItem; class QPushButton; class QComboBox; class QLineEdit; class KListView; class KABPrefs; class AddresseeWidget; -class KABConfigWidget : public QWidget +class KABConfigWidget : public KPrefsWidget { Q_OBJECT public: - KABConfigWidget( QWidget *parent, const char *name = 0 ); + KABConfigWidget(KABPrefs *prefs, QWidget *parent, const char *name = 0 ); - void restoreSettings(KABPrefs* prefs); - void saveSettings(KABPrefs* prefs); - void defaults(KABPrefs* prefs); - - signals: - void changed( bool ); - - public slots: - void modified(); + protected: + /** Implement this to read custom configuration widgets. */ + virtual void usrReadConfig(); + /** Implement this to write custom configuration widgets. */ + virtual void usrWriteConfig(); private slots: void configureExtension(); void selectionChanged( QListViewItem* ); void itemClicked( QListViewItem* ); private: void restoreExtensionSettings(); void saveExtensionSettings(); diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.cpp b/kaddressbook/kcmconfigs/kcmkabconfig.cpp index b460a81..cbfedbd 100644 --- a/kaddressbook/kcmconfigs/kcmkabconfig.cpp +++ b/kaddressbook/kcmconfigs/kcmkabconfig.cpp @@ -30,55 +30,55 @@ //#include <klocale.h> //#include <stdlib.h> #include "kabconfigwidget.h" #include "kcmkabconfig.h" #include "kabprefs.h" #include "kprefs.h" extern "C" { - KCModule *create_kabconfig( KABPrefs* prefs, QWidget *parent, const char * ) { - return new KCMKabConfig( prefs, parent, "kcmkabconfig" ); + KCModule *create_kabconfig( QWidget *parent, const char * ) { + return new KCMKabConfig( parent, "kcmkabconfig" ); } } -KCMKabConfig::KCMKabConfig( KABPrefs* prefs, QWidget *parent, const char *name ) - : KCModule( prefs, parent, name ) +KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) + : KCModule( KABPrefs::instance(), parent, name ) { //abort(); QVBoxLayout *layout = new QVBoxLayout( this ); - mConfigWidget = new KABConfigWidget( this, "mConfigWidget" ); + mConfigWidget = new KABConfigWidget( (KABPrefs*)getPreferences(), this, "KABConfigWidget" ); layout->addWidget( mConfigWidget ); layout->setSpacing( 0 ); layout->setMargin( 0 ); connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); } void KCMKabConfig::load() { - mConfigWidget->restoreSettings((KABPrefs*)getPreferences()); + mConfigWidget->readConfig(); } void KCMKabConfig::save() { - mConfigWidget->saveSettings((KABPrefs*)getPreferences()); + mConfigWidget->writeConfig(); } void KCMKabConfig::defaults() { - mConfigWidget->defaults((KABPrefs*)getPreferences()); + mConfigWidget->setDefaults(); } #ifndef KAB_EMBEDDED const KAboutData* KCMKabConfig::aboutData() const { KAboutData *about = new KAboutData( I18N_NOOP( "kcmkabconfig" ), I18N_NOOP( "KAddressBook Configure Dialog" ), 0, 0, KAboutData::License_GPL, I18N_NOOP( "(c), 2003 Tobias Koenig" ) ); about->addAuthor( "Tobias Koenig", 0, "tokoe@kde.org" ); diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.h b/kaddressbook/kcmconfigs/kcmkabconfig.h index 1cb6ad3..2ecbfef 100644 --- a/kaddressbook/kcmconfigs/kcmkabconfig.h +++ b/kaddressbook/kcmconfigs/kcmkabconfig.h @@ -25,23 +25,23 @@ #define KCMKABCONFIG_H #include <kcmodule.h> class KABConfigWidget; class KABPrefs; class KCMKabConfig : public KCModule { Q_OBJECT public: - KCMKabConfig( KABPrefs* prefs, QWidget *parent = 0, const char *name = 0 ); + KCMKabConfig( QWidget *parent = 0, const char *name = 0 ); virtual void load(); virtual void save(); virtual void defaults(); private: KABConfigWidget *mConfigWidget; }; #endif |