/* This file is part of KdePim/Pi. Copyright (c) 2004 Ulf Schenk 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, 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 #include #include #include #include #include #include #include #include #include /*US #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef KAB_EMBEDDED #include #else // KAB_EMBEDDED #include #include #endif // KAB_EMBEDDED #include "addresseewidget.h" #include "extensionconfigdialog.h" #include "extensionwidget.h" */ #include "kpimprefs.h" #include "kdepimconfigwidget.h" KDEPIMConfigWidget::KDEPIMConfigWidget( QWidget *parent, const char *name ) : QWidget( parent, name ) { 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(), 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() ); 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 ); 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 KDEPIMConfigWidget::emailclient_changed( int newClient ) { if (newClient == KPimPrefs::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 == KPimPrefs::OPIE) { if ( QFile::exists( opiepath + "/bin/opiemail" )) text = "QPE/Application/opiemail"; else text = "FILENOTFOUND: " + opiepath + "/bin/opiemail"; } else if (newClient == KPimPrefs::QTOPIA) { if ( QFile::exists( qtopiapath + "/bin/qtmail" )) text = "QPE/Application/qtmail"; else text = "FILENOTFOUND: " + qtopiapath + "/bin/qtmail"; } else if (newClient == KPimPrefs::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 KDEPIMConfigWidget::restoreSettings(KPimPrefs* prefs) { bool blocked = signalsBlocked(); blockSignals( true ); mEmailChannel->setText( prefs->mEmailChannel ); mEmailClient->setCurrentItem(prefs->mEmailClient); blockSignals( blocked ); emit changed( false ); } void KDEPIMConfigWidget::saveSettings(KPimPrefs* prefs) { prefs->mEmailClient = mEmailClient->currentItem(); prefs->mEmailChannel = mEmailChannel->text(); prefs->writeConfig(); emit changed( false ); } void KDEPIMConfigWidget::defaults(KPimPrefs* prefs) { mEmailClient->setCurrentItem(KPimPrefs::OMPI); emailclient_changed( KPimPrefs::OMPI ); emit changed( true ); } void KDEPIMConfigWidget::modified() { emit changed( true ); }