-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.cpp | 167 | ||||
-rw-r--r-- | kaddressbook/kcmconfigs/kabconfigwidget.h | 48 |
2 files changed, 164 insertions, 51 deletions
diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.cpp b/kaddressbook/kcmconfigs/kabconfigwidget.cpp index 38c7946..1bac26f 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.cpp +++ b/kaddressbook/kcmconfigs/kabconfigwidget.cpp @@ -1,24 +1,24 @@ -/* - This file is part of KAddressBook. +/* + This file is part of KAddressBook. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - 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, + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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. -*/ +*/ #include <qcheckbox.h> @@ -28,4 +28,8 @@ #include <qpushbutton.h> #include <qtabwidget.h> +#include <qcombobox.h> +#include <qlineedit.h> +#include <qlabel.h> +#include <qfile.h> #include <kconfig.h> @@ -76,7 +80,7 @@ class ExtensionItem : public QCheckListItem QString mName; QString mComment; - + #endif //KAB_EMBEDDED - + }; @@ -94,5 +98,5 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) 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() ); @@ -110,4 +114,7 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) layout->addWidget( groupBox ); + + //extensions groupbox + groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Extensions" ), generalPage ); boxLayout = new QVBoxLayout( groupBox->layout() ); @@ -122,5 +129,5 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) mExtensionView->addColumn( i18n( "Description" ) ); mExtensionView->setMaximumHeight(80); - + boxLayout->addWidget( mExtensionView ); @@ -146,6 +153,94 @@ KABConfigWidget::KABConfigWidget( QWidget *parent, const char *name ) tabWidget->addTab( mAddresseeWidget, i18n( "Contact" ) ); connect( mAddresseeWidget, SIGNAL( modified() ), SLOT( modified() ) ); + + // mailclient page + QWidget *mailclientPage = new QWidget( this ); + layout = new QVBoxLayout( mailclientPage, KDialog::marginHintSmall(), + KDialog::spacingHintSmall() ); + + groupBox = new QGroupBox( 0, Qt::Vertical, i18n( "Used Mail Client" ), mailclientPage ); + 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() ); + + mEmailClient = new QComboBox( groupBox ); + mEmailClient->insertItem( i18n("OM/Pi"), KABPrefs::OMPI ); + mEmailClient->insertItem( i18n("Qtopia mail"), KABPrefs::QTOPIA ); + mEmailClient->insertItem( i18n("Opie mail"), KABPrefs::OPIE ); + mEmailClient->insertItem( i18n("Other"), KABPrefs::OTHER ); + boxLayout->addWidget( mEmailClient ); + + connect( mEmailClient, SIGNAL( activated( int ) ), + this, SLOT (emailclient_changed( int ) ) ); + + QLabel* lab = new QLabel( i18n("Channel:"), groupBox); + boxLayout->addWidget( lab ); + mEmailChannel = new QLineEdit(groupBox); + mEmailChannel->setReadOnly(true); + boxLayout->addWidget( mEmailChannel ); + + layout->addWidget( groupBox ); + tabWidget->addTab( mailclientPage, i18n( "Mail" ) ); + + + } + + +void KABConfigWidget::emailclient_changed( int newClient ) +{ + if (newClient == KABPrefs::OTHER) + mEmailChannel->setReadOnly(false); + else + mEmailChannel->setReadOnly(true); + + QString opiepath = QString::fromLatin1( getenv("OPIEDIR") ); + QString qtopiapath = QString::fromLatin1( getenv("QPEDIR") ); + + if (opiepath.isEmpty()) + opiepath = qtopiapath; + + QString text = mEmailChannel->text(); + + if (newClient == KABPrefs::OPIE) + { + if ( QFile::exists( opiepath + "/bin/opiemail" )) + text = "QPE/Application/opiemail"; + else + text = "FILENOTFOUND: " + opiepath + "/bin/opiemail"; + } + else if (newClient == KABPrefs::QTOPIA) + { + if ( QFile::exists( qtopiapath + "/bin/qtmail" )) + text = "QPE/Application/qtmail"; + else + text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail"; + + } + else if (newClient == KABPrefs::OMPI) + { + if ( QFile::exists( qtopiapath + "/bin/ompi" )) + text = "QPE/Application/ompi"; + else if ( QFile::exists( opiepath + "/bin/ompi" )) + text = "QPE/Application/ompi"; + else + text = "FILENOTFOUND: " + qtopiapath + "/bin/ompi"; + + } + else + { + //do nothing if we choosed other + } + + mEmailChannel->setText( text ); + + +} + + void KABConfigWidget::restoreSettings() { @@ -155,4 +250,8 @@ void KABConfigWidget::restoreSettings() mNameParsing->setChecked( KABPrefs::instance()->mAutomaticNameParsing ); mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick ); + + mEmailChannel->setText( KABPrefs::instance()->mEmailChannel ); + mEmailClient->setCurrentItem(KABPrefs::instance()->mEmailClient); + mAddresseeWidget->restoreSettings(); @@ -168,4 +267,8 @@ void KABConfigWidget::saveSettings() KABPrefs::instance()->mAutomaticNameParsing = mNameParsing->isChecked(); KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked(); + + KABPrefs::instance()->mEmailClient = mEmailClient->currentItem(); + KABPrefs::instance()->mEmailChannel = mEmailChannel->text(); + mAddresseeWidget->saveSettings(); @@ -181,4 +284,8 @@ void KABConfigWidget::defaults() mViewsSingleClickBox->setChecked( false ); + mEmailClient->setCurrentItem(KABPrefs::OMPI); + emailclient_changed( KABPrefs::OMPI ); + + emit changed( true ); } @@ -211,22 +318,22 @@ void KABConfigWidget::restoreExtensionSettings() ExtensionItem *item = new ExtensionItem( mExtensionView, "Merge", "Merge", "Merge contacts"); - + item->setFactory( extensionFactory ); if ( activeExtensions.contains( extensionFactory->identifier() ) ) item->setOn( true ); - - + + extensionFactory = new DistributionListFactory(); item = new ExtensionItem( mExtensionView, "Distribution List", "Distribution List", "Manage Distribution Lists"); - + item->setFactory( extensionFactory ); if ( activeExtensions.contains( extensionFactory->identifier() ) ) item->setOn( true ); - - + + #endif //KAB_EMBEDDED - + } @@ -318,5 +425,5 @@ bool ExtensionItem::configWidgetAvailable() const if ( !extensionFactory ) return false; - + return extensionFactory->configureWidgetAvailable(); #else //KAB_EMBEDDED diff --git a/kaddressbook/kcmconfigs/kabconfigwidget.h b/kaddressbook/kcmconfigs/kabconfigwidget.h index 0f36d9e..9d1363b 100644 --- a/kaddressbook/kcmconfigs/kabconfigwidget.h +++ b/kaddressbook/kcmconfigs/kabconfigwidget.h @@ -1,24 +1,24 @@ -/* - This file is part of KAddressBook. +/* + This file is part of KAddressBook. Copyright (c) 2003 Tobias Koenig <tokoe@kde.org> - + This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - 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, + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + 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 @@ -30,5 +30,6 @@ class QCheckBox; class QListViewItem; class QPushButton; - +class QComboBox; +class QLineEdit; class KListView; @@ -38,8 +39,8 @@ class KABConfigWidget : public QWidget { Q_OBJECT - + public: KABConfigWidget( QWidget *parent, const char *name = 0 ); - + void restoreSettings(); void saveSettings(); @@ -52,8 +53,11 @@ class KABConfigWidget : public QWidget void modified(); + + private slots: void configureExtension(); void selectionChanged( QListViewItem* ); void itemClicked( QListViewItem* ); + void emailclient_changed( int newClient ); private: @@ -66,4 +70,6 @@ class KABConfigWidget : public QWidget QCheckBox *mViewsSingleClickBox; QPushButton *mConfigureButton; + QComboBox* mEmailClient; + QLineEdit* mEmailChannel; AddresseeWidget *mAddresseeWidget; |