-rw-r--r-- | kaddressbook/kabcore.cpp | 53 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.cpp | 20 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kcmkabconfig.h | 10 | ||||
-rw-r--r-- | libkdepim/addresseeview.cpp | 1 | ||||
-rw-r--r-- | libkdepim/kcmconfigs/kcmkdepimconfig.cpp | 24 | ||||
-rw-r--r-- | libkdepim/kcmconfigs/kcmkdepimconfig.h | 10 | ||||
-rw-r--r-- | libkdepim/kcmconfigs/kdepimconfigwidget.cpp | 530 | ||||
-rw-r--r-- | libkdepim/kcmconfigs/kdepimconfigwidget.h | 68 | ||||
-rw-r--r-- | libkdepim/kpimprefs.cpp | 11 | ||||
-rw-r--r-- | libkdepim/kpimprefs.h | 19 | ||||
-rw-r--r-- | libkdepim/libkdepim.pro | 4 | ||||
-rw-r--r-- | libkdepim/libkdepimE.pro | 4 | ||||
-rw-r--r-- | microkde/kdeui/kcmodule.cpp | 10 | ||||
-rw-r--r-- | microkde/kdeui/kcmodule.h | 11 | ||||
-rw-r--r-- | microkde/kutils/kcmultidialog.cpp | 13 | ||||
-rw-r--r-- | microkde/kutils/kcmultidialog.h | 5 |
16 files changed, 560 insertions, 233 deletions
diff --git a/kaddressbook/kabcore.cpp b/kaddressbook/kabcore.cpp index 4303cab..fe4841a 100644 --- a/kaddressbook/kabcore.cpp +++ b/kaddressbook/kabcore.cpp @@ -84,16 +84,18 @@ #include <qtopia/services.h> #include <qtopia/qcopenvelope_qws.h> #include <qpe/ir.h> #endif #endif // KAB_EMBEDDED #include "kcmconfigs/kcmkabconfig.h" #include "kcmconfigs/kcmkdepimconfig.h" +#include "kpimglobalprefs.h" +#include "externalapphandler.h" #include <kresources/selectdialog.h> #include <kmessagebox.h> #include <picture.h> #include <resource.h> @@ -462,39 +464,17 @@ void KABCore::setContactSelected( const QString &uid ) void KABCore::sendMail() { sendMail( mViewManager->selectedEmails().join( ", " ) ); } void KABCore::sendMail( const QString& email ) { -//US original kde implementation : kapp->invokeMailer( email, "" ); - -/*US original qtopia implementation - PimContact c = abList->currentEntry(); - QString name = c.fileAs(); - QString email = c.defaultEmail(); -#ifndef QT_NO_COP - QCopEnvelope e(Service::channel("Email"), "writeMail(QString,QString)"); - e << name << email; -#else -*/ - - -#ifndef QT_NO_COP - QCString channel = KABPrefs::instance()->mEmailChannel.latin1(); - qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")"); - - QCopEnvelope e(channel, "writeMail(QString,QString)"); - //US we need no names in the To field. The emailadresses are enough - e << "" << email; -#else - KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); -#endif + bool result = ExternalAppHandler::instance()->mailToContacts(email); } void KABCore::mailVCard() { QStringList uids = mViewManager->selectedUids(); if ( !uids.isEmpty() ) @@ -545,36 +525,27 @@ void KABCore::mailVCard( const QStringList& uids ) t.setEncoding( QTextStream::UnicodeUTF8 ); t << vcard; outFile.close(); urls.append( fileName ); } } + + bool result = ExternalAppHandler::instance()->mailAttachments(urls.join(", ")); + + /*US kapp->invokeMailer( QString::null, QString::null, QString::null, QString::null, // subject QString::null, // body QString::null, urls ); // attachments */ -#ifndef QT_NO_COP - QCString channel = KABPrefs::instance()->mEmailChannel.latin1(); - qDebug("Using QCopEnvelope e(\"" + channel + "\", \"writeMail(QMap(QString,QString))\")"); - - QMap<QString, QString> parameterMap; - parameterMap.insert("ATTACHMENT<n>", urls.join(", ")); - - QCopEnvelope e(channel, "writeMail(QMap(QString,QString))"); - e << parameterMap; -#else - KMessageBox::sorry( this, i18n( "This version does not support sending emails." ) ); -#endif - } /** Beams the "WhoAmI contact. */ void KABCore::beamMySelf() { @@ -1192,21 +1163,23 @@ QString KABCore::getNameByPhone( const QString &phone ) qDebug("KABCore::getNameByPhone finsih method"); return ""; #endif //KAB_EMBEDDED } void KABCore::openConfigDialog() { - KABPrefs* prefs = KABPrefs::instance(); - KCMultiDialog* ConfigureDialog = new KCMultiDialog( prefs, "PIM", this ,"kabconfigdialog", true ); - KCMKabConfig* kabcfg = new KCMKabConfig( ConfigureDialog->getNewVBoxPage(i18n( "Addressbook")) , "KCMKabConfig" ); + 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" ); ConfigureDialog->addModule(kabcfg ); - KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( ConfigureDialog->getNewVBoxPage(i18n( "Pim")) , "KCMKdeLibConfig" ); + KCMKdePimConfig* kdelibcfg = new KCMKdePimConfig( kpim_prefs, ConfigureDialog->getNewVBoxPage(i18n( "Global")) , "KCMKdeLibConfig" ); ConfigureDialog->addModule(kdelibcfg ); connect( ConfigureDialog, SIGNAL( applyClicked() ), this, SLOT( configurationChanged() ) ); connect( ConfigureDialog, SIGNAL( okClicked() ), this, SLOT( configurationChanged() ) ); diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.cpp b/kaddressbook/kcmconfigs/kcmkabconfig.cpp index 26398f8..b460a81 100644 --- a/kaddressbook/kcmconfigs/kcmkabconfig.cpp +++ b/kaddressbook/kcmconfigs/kcmkabconfig.cpp @@ -34,47 +34,47 @@ #include "kcmkabconfig.h" #include "kabprefs.h" #include "kprefs.h" extern "C" { - KCModule *create_kabconfig( QWidget *parent, const char * ) { - return new KCMKabConfig( parent, "kcmkabconfig" ); + KCModule *create_kabconfig( KABPrefs* prefs, QWidget *parent, const char * ) { + return new KCMKabConfig( prefs, parent, "kcmkabconfig" ); } } -KCMKabConfig::KCMKabConfig( QWidget *parent, const char *name ) - : KCModule( parent, name ) +KCMKabConfig::KCMKabConfig( KABPrefs* prefs, QWidget *parent, const char *name ) + : KCModule( prefs, parent, name ) { //abort(); QVBoxLayout *layout = new QVBoxLayout( this ); mConfigWidget = new KABConfigWidget( this, "mConfigWidget" ); layout->addWidget( mConfigWidget ); layout->setSpacing( 0 ); layout->setMargin( 0 ); connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); } -void KCMKabConfig::load(KPrefs* prefs) +void KCMKabConfig::load() { - mConfigWidget->restoreSettings((KABPrefs*)prefs); + mConfigWidget->restoreSettings((KABPrefs*)getPreferences()); } -void KCMKabConfig::save(KPrefs* prefs) +void KCMKabConfig::save() { - mConfigWidget->saveSettings((KABPrefs*)prefs); + mConfigWidget->saveSettings((KABPrefs*)getPreferences()); } -void KCMKabConfig::defaults(KPrefs* prefs) +void KCMKabConfig::defaults() { - mConfigWidget->defaults((KABPrefs*)prefs); + mConfigWidget->defaults((KABPrefs*)getPreferences()); } #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, diff --git a/kaddressbook/kcmconfigs/kcmkabconfig.h b/kaddressbook/kcmconfigs/kcmkabconfig.h index b4858c1..1cb6ad3 100644 --- a/kaddressbook/kcmconfigs/kcmkabconfig.h +++ b/kaddressbook/kcmconfigs/kcmkabconfig.h @@ -22,26 +22,26 @@ */ #ifndef KCMKABCONFIG_H #define KCMKABCONFIG_H #include <kcmodule.h> class KABConfigWidget; -class KPrefs; +class KABPrefs; class KCMKabConfig : public KCModule { Q_OBJECT public: - KCMKabConfig( QWidget *parent = 0, const char *name = 0 ); + KCMKabConfig( KABPrefs* prefs, QWidget *parent = 0, const char *name = 0 ); - virtual void load(KPrefs* prefs); - virtual void save(KPrefs* prefs); - virtual void defaults(KPrefs* prefs); + virtual void load(); + virtual void save(); + virtual void defaults(); private: KABConfigWidget *mConfigWidget; }; #endif diff --git a/libkdepim/addresseeview.cpp b/libkdepim/addresseeview.cpp index 547441c..83aba48 100644 --- a/libkdepim/addresseeview.cpp +++ b/libkdepim/addresseeview.cpp @@ -302,16 +302,17 @@ mText = "<table width=\"100%\">\n"; mText += dynamicPart; mText += notes; mText += "</table>"; } // at last display it... setText( mText ); + } KABC::Addressee AddresseeView::addressee() const { return mAddressee; } void AddresseeView::addTag(const QString & tag,const QString & text) { diff --git a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp index 830d5d2..f26efe0 100644 --- a/libkdepim/kcmconfigs/kcmkdepimconfig.cpp +++ b/libkdepim/kcmconfigs/kcmkdepimconfig.cpp @@ -34,44 +34,46 @@ $Id$ #include <kdebug.h> //#include <klocale.h> //#include <stdlib.h> #include "kdepimconfigwidget.h" #include "kcmkdepimconfig.h" #include "kprefs.h" -#include "kpimprefs.h" +#include "kpimglobalprefs.h" + #ifndef _WIN32_ extern "C" { - KCModule *create_kabconfig( QWidget *parent, const char * ) { - return new KCMKdePimConfig( parent, "kcmkdepimconfig" ); + KCModule *create_kabconfig( KPimGlobalPrefs* prefs, QWidget *parent, const char * ) { + return new KCMKdePimConfig( prefs, parent, "kcmkdepimconfig" ); } } #endif -KCMKdePimConfig::KCMKdePimConfig( QWidget *parent, const char *name ) - : KCModule( parent, name ) + +KCMKdePimConfig::KCMKdePimConfig( KPimGlobalPrefs* prefs, QWidget *parent, const char *name ) + : KCModule( prefs, parent, name ) { //abort(); QVBoxLayout *layout = new QVBoxLayout( this ); mConfigWidget = new KDEPIMConfigWidget( this, "mConfigWidget" ); layout->addWidget( mConfigWidget ); layout->setSpacing( 0 ); layout->setMargin( 0 ); connect( mConfigWidget, SIGNAL( changed( bool ) ), SIGNAL( changed( bool ) ) ); } -void KCMKdePimConfig::load(KPrefs* prefs) +void KCMKdePimConfig::load() { - mConfigWidget->restoreSettings((KPimPrefs*)prefs); + mConfigWidget->restoreSettings((KPimGlobalPrefs*)getPreferences()); } -void KCMKdePimConfig::save(KPrefs* prefs) +void KCMKdePimConfig::save() { - mConfigWidget->saveSettings((KPimPrefs*)prefs); + mConfigWidget->saveSettings((KPimGlobalPrefs*)getPreferences()); } -void KCMKdePimConfig::defaults(KPrefs* prefs) +void KCMKdePimConfig::defaults() { - mConfigWidget->defaults((KPimPrefs*)prefs); + mConfigWidget->defaults((KPimGlobalPrefs*)getPreferences()); } diff --git a/libkdepim/kcmconfigs/kcmkdepimconfig.h b/libkdepim/kcmconfigs/kcmkdepimconfig.h index 8cb74f4..fa96eda 100644 --- a/libkdepim/kcmconfigs/kcmkdepimconfig.h +++ b/libkdepim/kcmconfigs/kcmkdepimconfig.h @@ -29,26 +29,26 @@ $Id$ */ #ifndef KCMKDEPIMCONFIG_H #define KCMKDEPIMCONFIG_H #include <kcmodule.h> class KDEPIMConfigWidget; -class KPrefs; +class KPimGlobalPrefs; class KCMKdePimConfig : public KCModule { Q_OBJECT public: - KCMKdePimConfig( QWidget *parent = 0, const char *name = 0 ); + KCMKdePimConfig( KPimGlobalPrefs* prefs, QWidget *parent = 0, const char *name = 0 ); - virtual void load(KPrefs* prefs); - virtual void save(KPrefs* prefs); - virtual void defaults(KPrefs* prefs); + virtual void load(); + virtual void save(); + virtual void defaults(); private: KDEPIMConfigWidget *mConfigWidget; }; #endif diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp index 477267c..9964eeb 100644 --- a/libkdepim/kcmconfigs/kdepimconfigwidget.cpp +++ b/libkdepim/kcmconfigs/kdepimconfigwidget.cpp @@ -66,208 +66,492 @@ $Id$ #include <distributionlistwidget.h> #endif // KAB_EMBEDDED #include "addresseewidget.h" #include "extensionconfigdialog.h" #include "extensionwidget.h" */ -#include "kpimprefs.h" +#include "kpimglobalprefs.h" #include "kdepimconfigwidget.h" KDEPIMConfigWidget::KDEPIMConfigWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { + mExternalAppsMap.insert(ExternalAppHandler::EMAIL, i18n("Email")); + mExternalAppsMap.insert(ExternalAppHandler::PHONE, i18n("Phone")); + mExternalAppsMap.insert(ExternalAppHandler::SMS, i18n("SMS")); + mExternalAppsMap.insert(ExternalAppHandler::FAX, i18n("Fax")); + mExternalAppsMap.insert(ExternalAppHandler::PAGER, i18n("Pager")); + + QVBoxLayout *topLayout = new QVBoxLayout( this, 0, KDialog::spacingHint() ); QTabWidget *tabWidget = new QTabWidget( this ); topLayout->addWidget( tabWidget ); -/*US - // General page - QWidget *generalPage = new QWidget( this ); - QVBoxLayout *layout = new QVBoxLayout( generalPage, KDialog::marginHintSmall(), - KDialog::spacingHintSmall() ); - //general groupbox - QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "General" ), generalPage ); - QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); - boxLayout->setAlignment( Qt::AlignTop ); - boxLayout->setMargin(KDialog::marginHintSmall() ); - groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; - groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); - boxLayout->setSpacing( KDialog::spacingHintSmall() ); - mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), groupBox, "msingle" ); - boxLayout->addWidget( mViewsSingleClickBox ); - - mNameParsing = new QCheckBox( i18n( "Automatic name parsing for new addressees" ), groupBox, "mparse" ); - boxLayout->addWidget( mNameParsing ); - - layout->addWidget( groupBox ); - - - //extensions groupbox - - QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); - QVBoxLayout *boxLayout = new QVBoxLayout( groupBox->layout() ); - boxLayout->setAlignment( Qt::AlignTop ); - boxLayout->setMargin(KDialog::marginHintSmall()); - boxLayout->setSpacing(KDialog::spacingHintSmall()); - groupBox->layout()->setMargin(1) ; - groupBox->layout()->setSpacing(0); - mExtensionView = new KListView( groupBox ); - mExtensionView->setAllColumnsShowFocus( true ); - mExtensionView->addColumn( i18n( "Name" ) ); - mExtensionView->addColumn( i18n( "Description" ) ); - mExtensionView->setMaximumHeight(80); - - boxLayout->addWidget( mExtensionView ); - - mConfigureButton = new QPushButton( i18n( "Configure..." ), groupBox ); - mConfigureButton->setEnabled( false ); - boxLayout->addWidget( mConfigureButton ); - - layout->addWidget( groupBox ); - - connect( mNameParsing, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); - connect( mViewsSingleClickBox, SIGNAL( toggled( bool ) ), this, SLOT( modified() ) ); - connect( mExtensionView, SIGNAL( selectionChanged( QListViewItem* ) ), - SLOT( selectionChanged( QListViewItem* ) ) ); - connect( mExtensionView, SIGNAL( clicked( QListViewItem* ) ), - SLOT( itemClicked( QListViewItem* ) ) ); - connect( mConfigureButton, SIGNAL( clicked() ), - SLOT( configureExtension() ) ); - - tabWidget->addTab( generalPage, i18n( "General" ) ); - - // Addressee page - mAddresseeWidget = new AddresseeWidget( this ); - tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); - connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); -*/ + + // mailclient page - QWidget *mailclientPage = new QWidget( this ); - QVBoxLayout* layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(), + QWidget *externalAppsPage = new QWidget( this ); + QVBoxLayout* layout = new QVBoxLayout( externalAppsPage, KDialog::marginHintSmall(), KDialog::spacingHintSmall() ); - QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage ); - QVBoxLayout* boxLayout = new QVBoxLayout( groupBox->layout() ); - boxLayout->setAlignment( Qt::AlignTop ); -// boxLayout->setMargin(KDialog::marginHintSmall() ); -// groupBox->layout()->setMargin(KDialog::marginHintSmall()) ; -// groupBox->layout()->setSpacing(KDialog::spacingHintSmall()); -// boxLayout->setSpacing( KDialog::spacingHintSmall() ); + mExternalApps = new QComboBox( externalAppsPage ); + + QMap<ExternalAppHandler::Types, QString>::Iterator it; + for( it = mExternalAppsMap.begin(); it != mExternalAppsMap.end(); ++it ) + mExternalApps->insertItem( it.data(), it.key() ); + + layout->addWidget( mExternalApps ); + + connect( mExternalApps, SIGNAL( activated( int ) ), + this, SLOT (externalapp_changed( int ) ) ); + + + + + mExternalAppGroupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), externalAppsPage ); + QGridLayout *boxLayout = new QGridLayout( mExternalAppGroupBox->layout(), 4, 2, -1, "gridlayout" ); + - mEmailClient = new QComboBox( groupBox ); - mEmailClient->insertItem( i18n("OM/Pi"), KPimPrefs::OMPI ); - mEmailClient->insertItem( i18n("Qtopia mail"), KPimPrefs::QTOPIA ); - mEmailClient->insertItem( i18n("Opie mail"), KPimPrefs::OPIE ); - mEmailClient->insertItem( i18n("Other"), KPimPrefs::OTHER ); - boxLayout->addWidget( mEmailClient ); + mClient = new QComboBox( mExternalAppGroupBox ); + boxLayout->addMultiCellWidget( mClient, 0, 0, 0, 1 ); - connect( mEmailClient, SIGNAL( activated( int ) ), - this, SLOT (emailclient_changed( int ) ) ); + connect( mClient, SIGNAL( activated( int ) ), + this, SLOT (client_changed( int ) ) ); - QLabel* lab = new QLabel( i18n("Channel:"), groupBox); - boxLayout->addWidget( lab ); - mEmailChannel = new QLineEdit(groupBox); - mEmailChannel->setReadOnly(true); - boxLayout->addWidget( mEmailChannel ); + QLabel* lab = new QLabel( i18n("Channel:"), mExternalAppGroupBox); + boxLayout->addWidget( lab, 1, 0 ); + mChannel = new QLineEdit(mExternalAppGroupBox); + mChannel->setReadOnly(true); + boxLayout->addMultiCellWidget( mChannel, 2 , 2, 0, 1 ); - layout->addWidget( groupBox ); - tabWidget->addTab( mailclientPage, i18n( "Mail" ) ); + lab = new QLabel( i18n("Message:"), mExternalAppGroupBox); + boxLayout->addWidget( lab, 3, 0 ); + mMessage = new QLineEdit(mExternalAppGroupBox); + mMessage->setReadOnly(true); + boxLayout->addWidget( mMessage , 4, 0); + lab = new QLabel( i18n("Parameters:"), mExternalAppGroupBox); + boxLayout->addWidget( lab, 3, 1 ); + mParameters = new QLineEdit(mExternalAppGroupBox); + mParameters->setReadOnly(true); + boxLayout->addWidget( mParameters, 4, 1 ); + lab = new QLabel( i18n("extra Message:"), mExternalAppGroupBox); + boxLayout->addWidget( lab, 5, 0 ); + mMessage2 = new QLineEdit(mExternalAppGroupBox); + mMessage2->setReadOnly(true); + boxLayout->addWidget( mMessage2 , 6, 0); + + lab = new QLabel( i18n("extra Parameters:"), mExternalAppGroupBox); + boxLayout->addWidget( lab, 5, 1 ); + mParameters2 = new QLineEdit(mExternalAppGroupBox); + mParameters2->setReadOnly(true); + boxLayout->addWidget( mParameters2, 6, 1 ); + + lab = new QLabel( i18n("HINT: Delimiter=; Data=%1 "), mExternalAppGroupBox); + boxLayout->addMultiCellWidget( lab, 7, 7, 0, 1 ); + + + connect( mChannel, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); + connect( mMessage, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); + connect( mParameters, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); + connect( mMessage2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); + connect( mParameters2, SIGNAL( textChanged ( const QString & )), this, SLOT( textChanged ( const QString & )) ); + + + + layout->addWidget( mExternalAppGroupBox ); + tabWidget->addTab( externalAppsPage, i18n( "External Apps." ) ); } +void KDEPIMConfigWidget::externalapp_changed( int newApp ) +{ + // first store the current data + saveEditFieldSettings(); + // set mCurrentApp + mCurrentApp = (ExternalAppHandler::Types)newApp; -void KDEPIMConfigWidget::emailclient_changed( int newClient ) + // set mCurrentClient + switch(mCurrentApp) { - if (newClient == KPimPrefs::OTHER) - mEmailChannel->setReadOnly(false); - else - mEmailChannel->setReadOnly(true); + case(ExternalAppHandler::EMAIL): + mCurrentClient = mEmailClient; + break; + case(ExternalAppHandler::PHONE): + mCurrentClient = mPhoneClient; + break; + case(ExternalAppHandler::SMS): + mCurrentClient = mSMSClient; + break; + case(ExternalAppHandler::FAX): + mCurrentClient = mFaxClient; + break; + case(ExternalAppHandler::PAGER): + mCurrentClient = mPagerClient; + break; + default: + return; + } - QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); - QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); + // and at last update the widgets + updateClientWidgets(); +} - if (opiepath.isEmpty()) - opiepath = qtopiapath; - QString text = mEmailChannel->text(); - if (newClient == KPimPrefs::OPIE) +void KDEPIMConfigWidget::client_changed( int newClient ) { - if ( QFile::exists( opiepath + "/bin/opiemail" )) - text = "QPE/Application/opiemail"; - else - text = "FILENOTFOUND: " + opiepath + "/bin/opiemail"; + if (newClient == mCurrentClient) + return; + + // first store the current data + saveEditFieldSettings(); + + + //then reset the clientvariable + mCurrentClient = newClient; + + // and at last update the widgets + updateClientWidgets(); + + modified(); } - else if (newClient == KPimPrefs::QTOPIA) + +void KDEPIMConfigWidget::saveEditFieldSettings() { - if ( QFile::exists( qtopiapath + "/bin/qtmail" )) - text = "QPE/Application/qtmail"; - else - text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail"; + + switch(mCurrentApp) + { + case(ExternalAppHandler::EMAIL): + mEmailClient = mClient->currentItem(); + break; + case(ExternalAppHandler::PHONE): + mPhoneClient= mClient->currentItem(); + break; + case(ExternalAppHandler::SMS): + mSMSClient = mClient->currentItem(); + break; + case(ExternalAppHandler::FAX): + mFaxClient = mClient->currentItem(); + break; + case(ExternalAppHandler::PAGER): + mPagerClient = mClient->currentItem(); + break; + default: + return; + } + + //store the current data back to the apropriate membervariables if we had set it to "other" + if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) + { + mEmailOtherChannel = mChannel->text(); + mEmailOtherMessage = mMessage->text(); + mEmailOtherMessageParameters = mParameters->text(); + mEmailOtherMessage2 = mMessage2->text(); + mEmailOtherMessageParameters2 = mParameters2->text(); + } + else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) + { + mPhoneOtherChannel = mChannel->text(); + mPhoneOtherMessage = mMessage->text(); + mPhoneOtherMessageParameters = mParameters->text(); + } + else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) + { + mSMSOtherChannel = mChannel->text(); + mSMSOtherMessage = mMessage->text(); + mSMSOtherMessageParameters = mParameters->text(); + } + else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) + { + mFaxOtherChannel = mChannel->text(); + mFaxOtherMessage = mMessage->text(); + mFaxOtherMessageParameters = mParameters->text(); + } + else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) + { + mPagerOtherChannel = mChannel->text(); + mPagerOtherMessage = mMessage->text(); + mPagerOtherMessageParameters = mParameters->text(); + } } - else if (newClient == KPimPrefs::OMPI) + +void KDEPIMConfigWidget::updateClientWidgets() { - if ( QFile::exists( qtopiapath + "/bin/ompi" )) - text = "QPE/Application/ompi"; - else if ( QFile::exists( opiepath + "/bin/ompi" )) - text = "QPE/Application/ompi"; + bool blocked = signalsBlocked(); + blockSignals( true ); + + // at this point we assume, that mCurrentApp and mCurrentClient are set to the values that we want to display + QMap<ExternalAppHandler::Types, QString>::Iterator it = mExternalAppsMap.find ( mCurrentApp ); + if (it == mExternalAppsMap.end()) + return; + + // update group box + mExternalAppGroupBox->setTitle(i18n( "Used %1 Client" ).arg(it.data())); + + //update the entries in the client combobox + mClient->clear(); + + QList<DefaultAppItem> items = ExternalAppHandler::instance()->getAvailableDefaultItems(mCurrentApp); + DefaultAppItem* dai; + for ( dai=items.first(); dai != 0; dai=items.next() ) + { + mClient->insertItem( i18n(dai->_label), dai->_id ); + + if (dai->_id == mCurrentClient) + { + //restore the edit fields with the data of the local membervariables if we had set it to "other". + //Otherwise take the default data from externalapphandler. + mChannel->setText(dai->_channel); + mMessage->setText(dai->_message); + mParameters->setText(dai->_parameters); + mMessage2->setText(dai->_message2); + mParameters2->setText(dai->_parameters2); + + + if ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) + { + mChannel->setText(mEmailOtherChannel); + mMessage->setText(mEmailOtherMessage); + mParameters->setText(mEmailOtherMessageParameters); + mMessage2->setText(mEmailOtherMessage2); + mParameters2->setText(mEmailOtherMessageParameters2); + } + else if ((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) + { + mChannel->setText(mPhoneOtherChannel); + mMessage->setText(mPhoneOtherMessage); + mParameters->setText(mPhoneOtherMessageParameters); + } + else if ((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) + { + mChannel->setText(mSMSOtherChannel); + mMessage->setText(mSMSOtherMessage); + mParameters->setText(mSMSOtherMessageParameters); + } + else if ((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) + { + mChannel->setText(mFaxOtherChannel); + mMessage->setText(mFaxOtherMessage); + mParameters->setText(mFaxOtherMessageParameters); + } + else if ((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC)) + { + mChannel->setText(mPagerOtherChannel); + mMessage->setText(mPagerOtherMessage); + mParameters->setText(mPagerOtherMessageParameters); + } + } + + } + + bool readonly; + bool enabled; + if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::OTHER_EMC)) + ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::OTHER_PHC)) + ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::OTHER_SMC)) + ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::OTHER_FAC)) + ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::OTHER_PAC))) + { + readonly = false; + } else - text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi"; + { + readonly = true; + } + if ( ((mCurrentApp == ExternalAppHandler::EMAIL) && (mCurrentClient == KPimGlobalPrefs::NONE_EMC)) + ||((mCurrentApp == ExternalAppHandler::PHONE) && (mCurrentClient == KPimGlobalPrefs::NONE_PHC)) + ||((mCurrentApp == ExternalAppHandler::SMS) && (mCurrentClient == KPimGlobalPrefs::NONE_SMC)) + ||((mCurrentApp == ExternalAppHandler::FAX) && (mCurrentClient == KPimGlobalPrefs::NONE_FAC)) + ||((mCurrentApp == ExternalAppHandler::PAGER) && (mCurrentClient == KPimGlobalPrefs::NONE_PAC))) + { + enabled = false; } else { - //do nothing if we choosed other + enabled = true; } - mEmailChannel->setText( text ); + mChannel->setReadOnly(readonly); + mMessage->setReadOnly(readonly); + mParameters->setReadOnly(readonly); + mMessage2->setReadOnly(readonly); + mParameters2->setReadOnly(readonly); + + mChannel->setEnabled(enabled); + mMessage->setEnabled(enabled); + mParameters->setEnabled(enabled); + mMessage2->setEnabled(enabled); + mParameters2->setEnabled(enabled); + + + + mClient->setCurrentItem(mCurrentClient); + + + // enable/disable the extra message/parameter field + if (mCurrentApp == ExternalAppHandler::EMAIL) + { + } + else + { + mMessage2->setText( "" ); + mParameters2->setText( "" ); + } + if (enabled == true) { + mMessage2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); + mParameters2->setEnabled(mCurrentApp == ExternalAppHandler::EMAIL); } -void KDEPIMConfigWidget::restoreSettings(KPimPrefs* prefs) + blockSignals( blocked ); + +} + + + + +void KDEPIMConfigWidget::restoreSettings(KPimGlobalPrefs* prefs) { bool blocked = signalsBlocked(); blockSignals( true ); - mEmailChannel->setText( prefs->mEmailChannel ); - mEmailClient->setCurrentItem(prefs->mEmailClient); + mEmailClient = prefs->mEmailClient; + mEmailOtherChannel = prefs->mEmailOtherChannel; + mEmailOtherMessage = prefs->mEmailOtherMessage; + mEmailOtherMessageParameters = prefs->mEmailOtherMessageParameters; + mEmailOtherMessage2 = prefs->mEmailOtherMessage2; + mEmailOtherMessageParameters2 = prefs->mEmailOtherMessageParameters2; + + mPhoneClient = prefs->mPhoneClient; + mPhoneOtherChannel = prefs->mPhoneOtherChannel; + mPhoneOtherMessage = prefs->mPhoneOtherMessage; + mPhoneOtherMessageParameters = prefs->mPhoneOtherMessageParameters; + + mFaxClient = prefs->mFaxClient; + mFaxOtherChannel = prefs->mFaxOtherChannel; + mFaxOtherMessage = prefs->mFaxOtherMessage; + mFaxOtherMessageParameters = prefs->mFaxOtherMessageParameters; + + mSMSClient = prefs->mSMSClient; + mSMSOtherChannel = prefs->mSMSOtherChannel; + mSMSOtherMessage = prefs->mSMSOtherMessage; + mSMSOtherMessageParameters = prefs->mSMSOtherMessageParameters; + + mPagerClient = prefs->mPagerClient; + mPagerOtherChannel = prefs->mPagerOtherChannel; + mPagerOtherMessage = prefs->mPagerOtherMessage; + mPagerOtherMessageParameters = prefs->mPagerOtherMessageParameters; + + mCurrentApp = ExternalAppHandler::EMAIL; + mCurrentClient = mEmailClient; + + updateClientWidgets(); blockSignals( blocked ); emit changed( false ); + } -void KDEPIMConfigWidget::saveSettings(KPimPrefs* prefs) +void KDEPIMConfigWidget::saveSettings(KPimGlobalPrefs* prefs) { - prefs->mEmailClient = mEmailClient->currentItem(); - prefs->mEmailChannel = mEmailChannel->text(); + saveEditFieldSettings(); + + prefs->mEmailClient = mEmailClient; + prefs->mEmailOtherChannel = mEmailOtherChannel; + prefs->mEmailOtherMessage = mEmailOtherMessage; + prefs->mEmailOtherMessageParameters = mEmailOtherMessageParameters; + prefs->mEmailOtherMessage2 = mEmailOtherMessage2; + prefs->mEmailOtherMessageParameters2 = mEmailOtherMessageParameters2; + + prefs->mPhoneClient = mPhoneClient; + prefs->mPhoneOtherChannel = mPhoneOtherChannel; + prefs->mPhoneOtherMessage = mPhoneOtherMessage; + prefs->mPhoneOtherMessageParameters = mPhoneOtherMessageParameters; + + prefs->mFaxClient = mFaxClient; + prefs->mFaxOtherChannel = mFaxOtherChannel; + prefs->mFaxOtherMessage = mFaxOtherMessage; + prefs->mFaxOtherMessageParameters = mFaxOtherMessageParameters; + + prefs->mSMSClient = mSMSClient; + prefs->mSMSOtherChannel = mSMSOtherChannel; + prefs->mSMSOtherMessage = mSMSOtherMessage; + prefs->mSMSOtherMessageParameters = mSMSOtherMessageParameters; + + prefs->mPagerClient = mPagerClient; + prefs->mPagerOtherChannel = mPagerOtherChannel; + prefs->mPagerOtherMessage = mPagerOtherMessage; + prefs->mPagerOtherMessageParameters = mPagerOtherMessageParameters; prefs->writeConfig(); emit changed( false ); } -void KDEPIMConfigWidget::defaults(KPimPrefs* prefs) +void KDEPIMConfigWidget::defaults(KPimGlobalPrefs* prefs) { - mEmailClient->setCurrentItem(KPimPrefs::OMPI); - emailclient_changed( KPimPrefs::OMPI ); + + DefaultAppItem* dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::EMAIL, KPimGlobalPrefs::NONE_EMC); + + mEmailClient = dai->_id; + mEmailOtherChannel = dai->_channel; + mEmailOtherMessage = dai->_message; + mEmailOtherMessageParameters = dai->_parameters; + mEmailOtherMessage2 = dai->_message2; + mEmailOtherMessageParameters2 = dai->_parameters2; + + + dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::PHONE, KPimGlobalPrefs::NONE_PHC); + + mPhoneClient = dai->_id; + mPhoneOtherChannel = dai->_channel; + mPhoneOtherMessage = dai->_message; + mPhoneOtherMessageParameters = dai->_parameters; + + dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::FAX, KPimGlobalPrefs::NONE_FAC); + + mFaxClient = dai->_id; + mFaxOtherChannel = dai->_channel; + mFaxOtherMessage = dai->_message; + mFaxOtherMessageParameters = dai->_parameters; + + dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::SMS, KPimGlobalPrefs::NONE_SMC); + + mSMSClient = dai->_id; + mSMSOtherChannel = dai->_channel; + mSMSOtherMessage = dai->_message; + mSMSOtherMessageParameters = dai->_parameters; + + dai = ExternalAppHandler::instance()->getDefaultItem(ExternalAppHandler::PAGER, KPimGlobalPrefs::NONE_PAC); + + mPagerClient = dai->_id; + mPagerOtherChannel = dai->_channel; + mPagerOtherMessage = dai->_message; + mPagerOtherMessageParameters = dai->_parameters; emit changed( true ); } void KDEPIMConfigWidget::modified() { emit changed( true ); } + +void KDEPIMConfigWidget::textChanged( const QString& text ) +{ + emit changed( true ); +} diff --git a/libkdepim/kcmconfigs/kdepimconfigwidget.h b/libkdepim/kcmconfigs/kdepimconfigwidget.h index 109a847..6e02544 100644 --- a/libkdepim/kcmconfigs/kdepimconfigwidget.h +++ b/libkdepim/kcmconfigs/kdepimconfigwidget.h @@ -27,60 +27,114 @@ Copyright (c) 2004 Ulf Schenk $Id$ */ #ifndef KDEPIMCONFIGWIDGET_H #define KDEPIMCONFIGWIDGET_H #include <qwidget.h> +#include <qmap.h> + +#include "externalapphandler.h" + /* class QCheckBox; class QListViewItem; class QPushButton; class KListView; */ class QComboBox; class QLineEdit; -class KPimPrefs; +class KPimGlobalPrefs; +class QGroupBox; class KDEPIMConfigWidget : public QWidget { Q_OBJECT public: KDEPIMConfigWidget( QWidget *parent, const char *name = 0 ); - void restoreSettings(KPimPrefs* prefs); - void saveSettings(KPimPrefs* prefs); - void defaults(KPimPrefs* prefs); + void restoreSettings(KPimGlobalPrefs* prefs); + void saveSettings(KPimGlobalPrefs* prefs); + void defaults(KPimGlobalPrefs* prefs); signals: void changed( bool ); + public slots: void modified(); + void textChanged( const QString& text ); private slots: // void configureExtension(); // void selectionChanged( QListViewItem* ); // void itemClicked( QListViewItem* ); - void emailclient_changed( int newClient ); + void client_changed( int newClient ); + void externalapp_changed( int newApp ); private: + void saveEditFieldSettings(); + void updateClientWidgets(); + // void restoreExtensionSettings(); // void saveExtensionSettings(); // KListView *mExtensionView; // QCheckBox *mNameParsing; // QCheckBox *mViewsSingleClickBox; // QPushButton *mConfigureButton; - QComboBox* mEmailClient; - QLineEdit* mEmailChannel; + QComboBox* mExternalApps; + QGroupBox* mExternalAppGroupBox; + + + QComboBox* mClient; + QLineEdit* mChannel; + QLineEdit* mMessage; + QLineEdit* mParameters; + QLineEdit* mMessage2; + QLineEdit* mParameters2; + + ExternalAppHandler::Types mCurrentApp; + int mCurrentClient; + + + int mEmailClient; + QString mEmailOtherChannel; + QString mEmailOtherMessage; + QString mEmailOtherMessageParameters; + QString mEmailOtherMessage2; + QString mEmailOtherMessageParameters2; + + int mPhoneClient; + QString mPhoneOtherChannel; + QString mPhoneOtherMessage; + QString mPhoneOtherMessageParameters; + + int mFaxClient; + QString mFaxOtherChannel; + QString mFaxOtherMessage; + QString mFaxOtherMessageParameters; + + int mSMSClient; + QString mSMSOtherChannel; + QString mSMSOtherMessage; + QString mSMSOtherMessageParameters; + + int mPagerClient; + QString mPagerOtherChannel; + QString mPagerOtherMessage; + QString mPagerOtherMessageParameters; + + + + QMap<ExternalAppHandler::Types, QString> mExternalAppsMap; // AddresseeWidget *mAddresseeWidget; }; #endif diff --git a/libkdepim/kpimprefs.cpp b/libkdepim/kpimprefs.cpp index 15531c7..140a286 100644 --- a/libkdepim/kpimprefs.cpp +++ b/libkdepim/kpimprefs.cpp @@ -16,30 +16,33 @@ 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. */ +/* +Enhanced Version of the file for platform independent KDE tools. +Copyright (c) 2004 Ulf Schenk + +$Id$ +*/ + #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include "kpimprefs.h" KPimPrefs::KPimPrefs( const QString &name ) : KPrefs( name ) { - KPrefs::setCurrentGroup( "ExternalApplications" ); - addItemInt( "EmailChannelType", &mEmailClient, OMPI ); - addItemString( "EmailChannelOther", &mEmailChannel, "" ); - } KPimPrefs::~KPimPrefs() { } void KPimPrefs::usrSetDefaults() { diff --git a/libkdepim/kpimprefs.h b/libkdepim/kpimprefs.h index 5186315..9bd9466 100644 --- a/libkdepim/kpimprefs.h +++ b/libkdepim/kpimprefs.h @@ -15,16 +15,24 @@ 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. */ + +/* +Enhanced Version of the file for platform independent KDE tools. +Copyright (c) 2004 Ulf Schenk + +$Id$ +*/ + #ifndef KPIMPREFS_H #define KPIMPREFS_H #include <qstringlist.h> #include "kprefs.h" class KPimPrefs : public KPrefs @@ -39,29 +47,18 @@ class KPimPrefs : public KPrefs void usrSetDefaults(); /** Read preferences from config file */ void usrReadConfig(); /** Write preferences to config file */ void usrWriteConfig(); - enum EMailClients { - OMPI = 0, - QTOPIA = 1, - OPIE = 2, - OTHER = 3 - }; - public: QStringList mCustomCategories; - int mEmailClient; - QString mEmailChannel; - - protected: virtual void setCategoryDefaults() = 0; }; #endif diff --git a/libkdepim/libkdepim.pro b/libkdepim/libkdepim.pro index 902f049..e05e681 100644 --- a/libkdepim/libkdepim.pro +++ b/libkdepim/libkdepim.pro @@ -18,38 +18,42 @@ MOC_DIR = moc/win } INTERFACES = \ HEADERS = \ categoryeditdialog.h \ categoryeditdialog_base.h \ categoryselectdialog.h \ categoryselectdialog_base.h \ + externalapphandler.h \ kdateedit.h \ kdatepicker.h \ kinputdialog.h \ kincidenceformatter.h \ kpimprefs.h \ + kpimglobalprefs.h \ kprefsdialog.h \ addresseeview.h \ ksyncprofile.h \ ksyncprefsdialog.h \ kcmconfigs/kcmkdepimconfig.h \ kcmconfigs/kdepimconfigwidget.h SOURCES = \ categoryeditdialog.cpp \ categoryeditdialog_base.cpp \ categoryselectdialog.cpp \ categoryselectdialog_base.cpp \ + externalapphandler.cpp \ kdateedit.cpp \ kdatepicker.cpp \ kinputdialog.cpp \ kincidenceformatter.cpp \ kpimprefs.cpp \ + kpimglobalprefs.cpp \ kprefsdialog.cpp \ addresseeview.cpp \ ksyncprofile.cpp \ ksyncprefsdialog.cpp \ kcmconfigs/kcmkdepimconfig.cpp \ kcmconfigs/kdepimconfigwidget.cpp diff --git a/libkdepim/libkdepimE.pro b/libkdepim/libkdepimE.pro index fc8abe1..b322bce 100644 --- a/libkdepim/libkdepimE.pro +++ b/libkdepim/libkdepimE.pro @@ -12,38 +12,42 @@ DESTDIR=$(QPEDIR)/lib INTERFACES = \ HEADERS = \ categoryeditdialog.h \ categoryeditdialog_base.h \ categoryselectdialog.h \ categoryselectdialog_base.h \ + externalapphandler.h \ kdateedit.h \ kdatepicker.h \ kinputdialog.h \ kincidenceformatter.h \ kpimprefs.h \ + kpimglobalprefs.h \ kprefsdialog.h \ addresseeview.h \ ksyncprofile.h \ ksyncprefsdialog.h \ kcmconfigs/kcmkdepimconfig.h \ kcmconfigs/kdepimconfigwidget.h SOURCES = \ categoryeditdialog.cpp \ categoryeditdialog_base.cpp \ categoryselectdialog.cpp \ categoryselectdialog_base.cpp \ + externalapphandler.cpp \ kdateedit.cpp \ kinputdialog.cpp \ kdatepicker.cpp \ kincidenceformatter.cpp \ kpimprefs.cpp \ + kpimglobalprefs.cpp \ kprefsdialog.cpp \ addresseeview.cpp \ ksyncprofile.cpp \ ksyncprefsdialog.cpp \ kcmconfigs/kcmkdepimconfig.cpp \ kcmconfigs/kdepimconfigwidget.cpp diff --git a/microkde/kdeui/kcmodule.cpp b/microkde/kdeui/kcmodule.cpp index 915cd0f..f646db3 100644 --- a/microkde/kdeui/kcmodule.cpp +++ b/microkde/kdeui/kcmodule.cpp @@ -28,24 +28,26 @@ class KCModulePrivate { public: //US KInstance *_instance; QString _rootOnlyMsg; bool _useRootOnlyMsg; bool _hasOwnInstance; + KPrefs* _prefs; }; -KCModule::KCModule(QWidget *parent, const char *name, const QStringList &) +KCModule::KCModule(KPrefs* prefs, QWidget *parent, const char *name, const QStringList &) : QWidget(parent, name), _btn(Help|Default|Apply) { kdDebug() << "KCModule " << name << endl; d = new KCModulePrivate; d->_useRootOnlyMsg = true; + d->_prefs = prefs; /*US d->_instance = new KInstance(name); if (name && strlen(name)) { d->_instance = new KInstance(name); KGlobal::locale()->insertCatalogue(name); } else d->_instance = new KInstance("kcmunnamed"); */ @@ -89,16 +91,22 @@ void KCModule::setUseRootOnlyMsg(bool on) { d->_useRootOnlyMsg = on; } bool KCModule::useRootOnlyMsg() const { return d->_useRootOnlyMsg; } + +KPrefs* KCModule::getPreferences() +{ + return d->_prefs; +} + /*US KInstance *KCModule::instance() const { return d->_instance; } */ void KCModule::virtual_hook( int, void* ) { /*BASE::virtual_hook( id, data );*/ } diff --git a/microkde/kdeui/kcmodule.h b/microkde/kdeui/kcmodule.h index bc020bc..874958c 100644 --- a/microkde/kdeui/kcmodule.h +++ b/microkde/kdeui/kcmodule.h @@ -78,17 +78,17 @@ public: Ok=32, /* obsolete, do not use! */ SysDefault=64 /* obsolete, do not use! */ }; /* * Base class for all KControlModules. * Make sure you have a QStringList argument in your * implementation. */ - KCModule(QWidget *parent=0, const char *name=0, const QStringList &args=QStringList() ); + KCModule(KPrefs* prefs, QWidget *parent=0, const char *name=0, const QStringList &args=QStringList() ); //US KCModule(KInstance *instance, QWidget *parent=0, const QStringList &args=QStringList() ); /* * Destroys the module. */ ~KCModule(); @@ -101,48 +101,48 @@ public: * * This method is invoked whenever the module should read its configuration * (most of the times from a config file) and update the user interface. * This happens when the user clicks the "Reset" button in the control * center, to undo all of his changes and restore the currently valid * settings. NOTE that this is not called after the modules is loaded, * so you probably want to call this method in the constructor. */ - virtual void load(KPrefs* prefs) {}; + virtual void load() {}; /** * Save the configuration data. * * The save method stores the config information as shown * in the user interface in the config files. * * If necessary, this method also updates the running system, * e.g. by restarting applications. * * save is called when the user clicks "Apply" or "Ok". */ - virtual void save(KPrefs* prefs) {}; + virtual void save() {}; /** * Sets the configuration to sensible default values. * * This method is called when the user clicks the "Default" * button. It should set the display to useful values. */ - virtual void defaults(KPrefs* prefs) {}; + virtual void defaults() {}; /** * Set the configuration to system default values. * * This method is called when the user clicks the "System-Default" * button. It should set the display to the system default values. * * NOTE: The default behaviour is to call defaults(). */ - virtual void sysdefaults(KPrefs* prefs) { defaults(prefs); }; + virtual void sysdefaults() { defaults(); }; /** * Return a quick-help text. * * This method is called when the module is docked. * The quick-help text should contain a short description of the module and * links to the module's help files. You can use QML formating tags in the text. * @@ -188,16 +188,17 @@ public: * In some cases, the module don't want a RootOnly message to * appear (for example if it has already one). This function * tells KControl if a RootOnly message should be shown * * @see KCModule::setUseRootOnlyMsg */ bool useRootOnlyMsg() const; + KPrefs* getPreferences(); //US KInstance *instance() const; signals: /** * Indicate that the state of the modules contents has changed. * diff --git a/microkde/kutils/kcmultidialog.cpp b/microkde/kutils/kcmultidialog.cpp index c2378fb..6c82e4f 100644 --- a/microkde/kutils/kcmultidialog.cpp +++ b/microkde/kutils/kcmultidialog.cpp @@ -29,23 +29,22 @@ #include <kdebug.h> #include <kiconloader.h> #include <kmessagebox.h> //US #include <klibloader.h> #include <krun.h> #include <kprocess.h> #include "kcmultidialog.h" -#include "kprefs.h" //US #include "kcmultidialog.moc" //US #include "kcmoduleloader.h" -KCMultiDialog::KCMultiDialog(KPrefs* prefs, const QString& baseGroup, QWidget *parent, const char *name, bool modal) +KCMultiDialog::KCMultiDialog(const QString& baseGroup, QWidget *parent, const char *name, bool modal) : KDialogBase(IconList, i18n("Configure"), Default |Cancel | Apply | Ok, Ok, - parent, name, modal, true), mPrefs(prefs), d(0L) + parent, name, modal, true), d(0L) { enableButton(Apply, false); //connect(this, SIGNAL(aboutToShowPage(QWidget *)), this, SLOT(slotAboutToShow(QWidget *))); connect( this, SIGNAL( defaultClicked() ), SLOT( slotDefault() ) ); _baseGroup = baseGroup; mMainWidget = new KJanusWidget( this, "JanusWidget", KJanusWidget::Tabbed ); @@ -70,45 +69,45 @@ void KCMultiDialog::slotDefault() int curPageIndex = mMainWidget->activePageIndex(); QPtrListIterator<KCModule> it(modules); for (; it.current(); ++it) { if (pageIndex((QWidget *)(*it)->parent()) == curPageIndex) { - (*it)->defaults(mPrefs); + (*it)->defaults(); clientChanged(true); return; } } } void KCMultiDialog::slotApply() { qDebug("KCMultiDialog::slotApply clicked"); QPtrListIterator<KCModule> it(modules); for (; it.current(); ++it) - (*it)->save(mPrefs); + (*it)->save(); clientChanged(false); emit applyClicked(); } void KCMultiDialog::slotOk() { qDebug("KCMultiDialog::slotOk clicked"); QPtrListIterator<KCModule> it(modules); for (; it.current(); ++it) - (*it)->save(mPrefs); + (*it)->save(); accept(); emit okClicked(); } void KCMultiDialog::slotHelp() { /*US @@ -157,17 +156,17 @@ QVBox * KCMultiDialog::getNewVBoxPage( const QString & modulename ) } //US special method for microkde. We dop noty want to load everything dynamically. void KCMultiDialog::addModule(KCModule* module ) //, const QString& modulename, const QString& iconname) { modules.append(module); connect(module, SIGNAL(changed(bool)), this, SLOT(clientChanged(bool))); //US - module->load(mPrefs); + module->load(); } void KCMultiDialog::slotAboutToShow(QWidget *page) { /*US LoadInfo *loadInfo = moduleDict[page]; diff --git a/microkde/kutils/kcmultidialog.h b/microkde/kutils/kcmultidialog.h index a42555f..1aa66b2 100644 --- a/microkde/kutils/kcmultidialog.h +++ b/microkde/kutils/kcmultidialog.h @@ -24,18 +24,16 @@ #include <qptrlist.h> #include <qptrdict.h> #include <kdialogbase.h> #include <kjanuswidget.h> #include <kcmodule.h> -class KPrefs; - /** * A class that offers a @ref KDialogBase containing arbitrary KControl Modules * * @short A method that offers a @ref KDialogBase containing arbitrary * KControl Modules. * * @author Matthias Elter <elter@kde.org>, Daniel Molkentin <molkentin@kde.org> * @since 3.2 @@ -49,17 +47,17 @@ public: * Constructs a new KCMultiDialog * * @param parent The parent Widget * @param name The widget name * @param baseGroup The baseGroup, if you want to call a module out of * kcontrol, just keep "settings" * @param modal If you pass true here, the dialog will be modal **/ - KCMultiDialog(KPrefs* prefs, const QString& baseGroup = QString::fromLatin1("settings"), + KCMultiDialog(const QString& baseGroup = QString::fromLatin1("settings"), QWidget *parent=0, const char *name=0, bool modal=false); /** * Destructor **/ virtual ~KCMultiDialog(); @@ -134,16 +132,15 @@ private: /* QPtrDict<LoadInfo> moduleDict; QString _docPath; */ QString _baseGroup; //US KJanusWidget* mMainWidget; - KPrefs* mPrefs; // For future use class KCMultiDialogPrivate; KCMultiDialogPrivate *d; }; #endif //KCMULTIDIALOG_H |