00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #include <config.h>
00025
00026
00027 #include "configuredialog.h"
00028 #include "configuredialog_p.h"
00029
00030 #include "globalsettings.h"
00031 #include "replyphrases.h"
00032 #include "templatesconfiguration_kfg.h"
00033
00034
00035 #include "kmkernel.h"
00036 #include "simplestringlisteditor.h"
00037 #include "accountdialog.h"
00038 using KMail::AccountDialog;
00039 #include "colorlistbox.h"
00040 #include "kmacctseldlg.h"
00041 #include "messagesender.h"
00042 #include "kmtransport.h"
00043 #include "kmfoldermgr.h"
00044 #include <libkpimidentities/identitymanager.h>
00045 #include "identitylistview.h"
00046 using KMail::IdentityListView;
00047 using KMail::IdentityListViewItem;
00048 #include "kcursorsaver.h"
00049 #include "accountmanager.h"
00050 #include <composercryptoconfiguration.h>
00051 #include <warningconfiguration.h>
00052 #include <smimeconfiguration.h>
00053 #include "templatesconfiguration.h"
00054 #include "customtemplates.h"
00055 #include "folderrequester.h"
00056 using KMail::FolderRequester;
00057 #include "accountcombobox.h"
00058 #include "imapaccountbase.h"
00059 using KMail::ImapAccountBase;
00060 #include "folderstorage.h"
00061 #include "kmfolder.h"
00062 #include "kmmainwidget.h"
00063 #include "recentaddresses.h"
00064 using KRecentAddress::RecentAddresses;
00065 #include "completionordereditor.h"
00066 #include "ldapclient.h"
00067 #include "index.h"
00068
00069 using KMail::IdentityListView;
00070 using KMail::IdentityListViewItem;
00071 #include "identitydialog.h"
00072 using KMail::IdentityDialog;
00073
00074
00075 #include <libkpimidentities/identity.h>
00076 #include <kmime_util.h>
00077 using KMime::DateFormatter;
00078 #include <kleo/cryptoconfig.h>
00079 #include <kleo/cryptobackendfactory.h>
00080 #include <ui/backendconfigwidget.h>
00081 #include <ui/keyrequester.h>
00082 #include <ui/keyselectiondialog.h>
00083
00084
00085 #include <klocale.h>
00086 #include <kapplication.h>
00087 #include <kcharsets.h>
00088 #include <kasciistringtools.h>
00089 #include <kdebug.h>
00090 #include <knuminput.h>
00091 #include <kfontdialog.h>
00092 #include <kmessagebox.h>
00093 #include <kurlrequester.h>
00094 #include <kseparator.h>
00095 #include <kiconloader.h>
00096 #include <kstandarddirs.h>
00097 #include <kwin.h>
00098 #include <knotifydialog.h>
00099 #include <kconfig.h>
00100 #include <kactivelabel.h>
00101 #include <kcmultidialog.h>
00102
00103
00104 #include <qvalidator.h>
00105 #include <qwhatsthis.h>
00106 #include <qvgroupbox.h>
00107 #include <qvbox.h>
00108 #include <qvbuttongroup.h>
00109 #include <qhbuttongroup.h>
00110 #include <qtooltip.h>
00111 #include <qlabel.h>
00112 #include <qtextcodec.h>
00113 #include <qheader.h>
00114 #include <qpopupmenu.h>
00115 #include <qradiobutton.h>
00116 #include <qlayout.h>
00117 #include <qcheckbox.h>
00118 #include <qwidgetstack.h>
00119
00120
00121 #include <assert.h>
00122 #include <stdlib.h>
00123
00124 #ifndef _PATH_SENDMAIL
00125 #define _PATH_SENDMAIL "/usr/sbin/sendmail"
00126 #endif
00127
00128 #ifdef DIM
00129 #undef DIM
00130 #endif
00131 #define DIM(x) sizeof(x) / sizeof(*x)
00132
00133 namespace {
00134
00135 struct EnumConfigEntryItem {
00136 const char * key;
00137 const char * desc;
00138 };
00139 struct EnumConfigEntry {
00140 const char * group;
00141 const char * key;
00142 const char * desc;
00143 const EnumConfigEntryItem * items;
00144 int numItems;
00145 int defaultItem;
00146 };
00147 struct BoolConfigEntry {
00148 const char * group;
00149 const char * key;
00150 const char * desc;
00151 bool defaultValue;
00152 };
00153
00154 static const char * lockedDownWarning =
00155 I18N_NOOP("<qt><p>This setting has been fixed by your administrator.</p>"
00156 "<p>If you think this is an error, please contact him.</p></qt>");
00157
00158 void checkLockDown( QWidget * w, const KConfigBase & c, const char * key ) {
00159 if ( c.entryIsImmutable( key ) ) {
00160 w->setEnabled( false );
00161 QToolTip::add( w, i18n( lockedDownWarning ) );
00162 } else {
00163 QToolTip::remove( w );
00164 }
00165 }
00166
00167 void populateButtonGroup( QButtonGroup * g, const EnumConfigEntry & e ) {
00168 g->setTitle( i18n( e.desc ) );
00169 g->layout()->setSpacing( KDialog::spacingHint() );
00170 for ( int i = 0 ; i < e.numItems ; ++i )
00171 g->insert( new QRadioButton( i18n( e.items[i].desc ), g ), i );
00172 }
00173
00174 void populateCheckBox( QCheckBox * b, const BoolConfigEntry & e ) {
00175 b->setText( i18n( e.desc ) );
00176 }
00177
00178 void loadWidget( QCheckBox * b, const KConfigBase & c, const BoolConfigEntry & e ) {
00179 Q_ASSERT( c.group() == e.group );
00180 checkLockDown( b, c, e.key );
00181 b->setChecked( c.readBoolEntry( e.key, e.defaultValue ) );
00182 }
00183
00184 void loadWidget( QButtonGroup * g, const KConfigBase & c, const EnumConfigEntry & e ) {
00185 Q_ASSERT( c.group() == e.group );
00186 Q_ASSERT( g->count() == e.numItems );
00187 checkLockDown( g, c, e.key );
00188 const QString s = c.readEntry( e.key, e.items[e.defaultItem].key );
00189 for ( int i = 0 ; i < e.numItems ; ++i )
00190 if ( s == e.items[i].key ) {
00191 g->setButton( i );
00192 return;
00193 }
00194 g->setButton( e.defaultItem );
00195 }
00196
00197 void saveCheckBox( QCheckBox * b, KConfigBase & c, const BoolConfigEntry & e ) {
00198 Q_ASSERT( c.group() == e.group );
00199 c.writeEntry( e.key, b->isChecked() );
00200 }
00201
00202 void saveButtonGroup( QButtonGroup * g, KConfigBase & c, const EnumConfigEntry & e ) {
00203 Q_ASSERT( c.group() == e.group );
00204 Q_ASSERT( g->count() == e.numItems );
00205 c.writeEntry( e.key, e.items[ g->id( g->selected() ) ].key );
00206 }
00207
00208 template <typename T_Widget, typename T_Entry>
00209 inline void loadProfile( T_Widget * g, const KConfigBase & c, const T_Entry & e ) {
00210 if ( c.hasKey( e.key ) )
00211 loadWidget( g, c, e );
00212 }
00213 }
00214
00215
00216 ConfigureDialog::ConfigureDialog( QWidget *parent, const char *name, bool modal )
00217 : KCMultiDialog( KDialogBase::IconList, KGuiItem( i18n( "&Load Profile..." ) ),
00218 KGuiItem(), User2, i18n( "Configure" ), parent, name, modal )
00219 , mProfileDialog( 0 )
00220 {
00221 KWin::setIcons( winId(), kapp->icon(), kapp->miniIcon() );
00222 showButton( User1, true );
00223
00224 addModule ( "kmail_config_identity", false );
00225 addModule ( "kmail_config_accounts", false );
00226 addModule ( "kmail_config_appearance", false );
00227 addModule ( "kmail_config_composer", false );
00228 addModule ( "kmail_config_security", false );
00229 addModule ( "kmail_config_misc", false );
00230
00231
00232
00233
00234
00235 KConfigGroup geometry( KMKernel::config(), "Geometry" );
00236 int width = geometry.readNumEntry( "ConfigureDialogWidth" );
00237 int height = geometry.readNumEntry( "ConfigureDialogHeight" );
00238 if ( width != 0 && height != 0 ) {
00239 setMinimumSize( width, height );
00240 }
00241
00242 }
00243
00244 void ConfigureDialog::hideEvent( QHideEvent *ev ) {
00245 KConfigGroup geometry( KMKernel::config(), "Geometry" );
00246 geometry.writeEntry( "ConfigureDialogWidth", width() );
00247 geometry.writeEntry( "ConfigureDialogHeight",height() );
00248 KDialogBase::hideEvent( ev );
00249 }
00250
00251 ConfigureDialog::~ConfigureDialog() {
00252 }
00253
00254 void ConfigureDialog::slotApply() {
00255 GlobalSettings::self()->writeConfig();
00256 KCMultiDialog::slotApply();
00257 }
00258
00259 void ConfigureDialog::slotOk() {
00260 GlobalSettings::self()->writeConfig();
00261 KCMultiDialog::slotOk();
00262 }
00263
00264 void ConfigureDialog::slotUser2() {
00265 if ( mProfileDialog ) {
00266 mProfileDialog->raise();
00267 return;
00268 }
00269 mProfileDialog = new ProfileDialog( this, "mProfileDialog" );
00270 connect( mProfileDialog, SIGNAL(profileSelected(KConfig*)),
00271 this, SIGNAL(installProfile(KConfig*)) );
00272 mProfileDialog->show();
00273 }
00274
00275
00276
00277
00278
00279
00280 QString IdentityPage::helpAnchor() const {
00281 return QString::fromLatin1("configure-identity");
00282 }
00283
00284 IdentityPage::IdentityPage( QWidget * parent, const char * name )
00285 : ConfigModule( parent, name ),
00286 mIdentityDialog( 0 )
00287 {
00288 QHBoxLayout * hlay = new QHBoxLayout( this, 0, KDialog::spacingHint() );
00289
00290 mIdentityList = new IdentityListView( this );
00291 connect( mIdentityList, SIGNAL(selectionChanged()),
00292 SLOT(slotIdentitySelectionChanged()) );
00293 connect( mIdentityList, SIGNAL(itemRenamed(QListViewItem*,const QString&,int)),
00294 SLOT(slotRenameIdentity(QListViewItem*,const QString&,int)) );
00295 connect( mIdentityList, SIGNAL(doubleClicked(QListViewItem*,const QPoint&,int)),
00296 SLOT(slotModifyIdentity()) );
00297 connect( mIdentityList, SIGNAL(contextMenu(KListView*,QListViewItem*,const QPoint&)),
00298 SLOT(slotContextMenu(KListView*,QListViewItem*,const QPoint&)) );
00299
00300
00301 hlay->addWidget( mIdentityList, 1 );
00302
00303 QVBoxLayout * vlay = new QVBoxLayout( hlay );
00304
00305 QPushButton * button = new QPushButton( i18n("&Add..."), this );
00306 mModifyButton = new QPushButton( i18n("&Modify..."), this );
00307 mRenameButton = new QPushButton( i18n("&Rename"), this );
00308 mRemoveButton = new QPushButton( i18n("Remo&ve"), this );
00309 mSetAsDefaultButton = new QPushButton( i18n("Set as &Default"), this );
00310 button->setAutoDefault( false );
00311 mModifyButton->setAutoDefault( false );
00312 mModifyButton->setEnabled( false );
00313 mRenameButton->setAutoDefault( false );
00314 mRenameButton->setEnabled( false );
00315 mRemoveButton->setAutoDefault( false );
00316 mRemoveButton->setEnabled( false );
00317 mSetAsDefaultButton->setAutoDefault( false );
00318 mSetAsDefaultButton->setEnabled( false );
00319 connect( button, SIGNAL(clicked()),
00320 this, SLOT(slotNewIdentity()) );
00321 connect( mModifyButton, SIGNAL(clicked()),
00322 this, SLOT(slotModifyIdentity()) );
00323 connect( mRenameButton, SIGNAL(clicked()),
00324 this, SLOT(slotRenameIdentity()) );
00325 connect( mRemoveButton, SIGNAL(clicked()),
00326 this, SLOT(slotRemoveIdentity()) );
00327 connect( mSetAsDefaultButton, SIGNAL(clicked()),
00328 this, SLOT(slotSetAsDefault()) );
00329 vlay->addWidget( button );
00330 vlay->addWidget( mModifyButton );
00331 vlay->addWidget( mRenameButton );
00332 vlay->addWidget( mRemoveButton );
00333 vlay->addWidget( mSetAsDefaultButton );
00334 vlay->addStretch( 1 );
00335 load();
00336 }
00337
00338 void IdentityPage::load()
00339 {
00340 KPIM::IdentityManager * im = kmkernel->identityManager();
00341 mOldNumberOfIdentities = im->shadowIdentities().count();
00342
00343 mIdentityList->clear();
00344 QListViewItem * item = 0;
00345 for ( KPIM::IdentityManager::Iterator it = im->modifyBegin() ; it != im->modifyEnd() ; ++it )
00346 item = new IdentityListViewItem( mIdentityList, item, *it );
00347 mIdentityList->setSelected( mIdentityList->currentItem(), true );
00348 }
00349
00350 void IdentityPage::save() {
00351 assert( !mIdentityDialog );
00352
00353 kmkernel->identityManager()->sort();
00354 kmkernel->identityManager()->commit();
00355
00356 if( mOldNumberOfIdentities < 2 && mIdentityList->childCount() > 1 ) {
00357
00358
00359 KConfigGroup composer( KMKernel::config(), "Composer" );
00360 int showHeaders = composer.readNumEntry( "headers", HDR_STANDARD );
00361 showHeaders |= HDR_IDENTITY;
00362 composer.writeEntry( "headers", showHeaders );
00363 }
00364
00365 if( mOldNumberOfIdentities > 1 && mIdentityList->childCount() < 2 ) {
00366
00367 KConfigGroup composer( KMKernel::config(), "Composer" );
00368 int showHeaders = composer.readNumEntry( "headers", HDR_STANDARD );
00369 showHeaders &= ~HDR_IDENTITY;
00370 composer.writeEntry( "headers", showHeaders );
00371 }
00372 }
00373
00374 void IdentityPage::slotNewIdentity()
00375 {
00376 assert( !mIdentityDialog );
00377
00378 KPIM::IdentityManager * im = kmkernel->identityManager();
00379 NewIdentityDialog dialog( im->shadowIdentities(), this, "new", true );
00380
00381 if( dialog.exec() == QDialog::Accepted ) {
00382 QString identityName = dialog.identityName().stripWhiteSpace();
00383 assert( !identityName.isEmpty() );
00384
00385
00386
00387
00388 switch ( dialog.duplicateMode() ) {
00389 case NewIdentityDialog::ExistingEntry:
00390 {
00391 KPIM::Identity & dupThis = im->modifyIdentityForName( dialog.duplicateIdentity() );
00392 im->newFromExisting( dupThis, identityName );
00393 break;
00394 }
00395 case NewIdentityDialog::ControlCenter:
00396 im->newFromControlCenter( identityName );
00397 break;
00398 case NewIdentityDialog::Empty:
00399 im->newFromScratch( identityName );
00400 default: ;
00401 }
00402
00403
00404
00405
00406 KPIM::Identity & newIdent = im->modifyIdentityForName( identityName );
00407 QListViewItem * item = mIdentityList->selectedItem();
00408 if ( item )
00409 item = item->itemAbove();
00410 mIdentityList->setSelected( new IdentityListViewItem( mIdentityList,
00411 item,
00412 newIdent ), true );
00413 slotModifyIdentity();
00414 }
00415 }
00416
00417 void IdentityPage::slotModifyIdentity() {
00418 assert( !mIdentityDialog );
00419
00420 IdentityListViewItem * item =
00421 dynamic_cast<IdentityListViewItem*>( mIdentityList->selectedItem() );
00422 if ( !item ) return;
00423
00424 mIdentityDialog = new IdentityDialog( this );
00425 mIdentityDialog->setIdentity( item->identity() );
00426
00427
00428 if ( mIdentityDialog->exec() == QDialog::Accepted ) {
00429 mIdentityDialog->updateIdentity( item->identity() );
00430 item->redisplay();
00431 emit changed(true);
00432 }
00433
00434 delete mIdentityDialog;
00435 mIdentityDialog = 0;
00436 }
00437
00438 void IdentityPage::slotRemoveIdentity()
00439 {
00440 assert( !mIdentityDialog );
00441
00442 KPIM::IdentityManager * im = kmkernel->identityManager();
00443 kdFatal( im->shadowIdentities().count() < 2 )
00444 << "Attempted to remove the last identity!" << endl;
00445
00446 IdentityListViewItem * item =
00447 dynamic_cast<IdentityListViewItem*>( mIdentityList->selectedItem() );
00448 if ( !item ) return;
00449
00450 QString msg = i18n("<qt>Do you really want to remove the identity named "
00451 "<b>%1</b>?</qt>").arg( item->identity().identityName() );
00452 if( KMessageBox::warningContinueCancel( this, msg, i18n("Remove Identity"),
00453 KGuiItem(i18n("&Remove"),"editdelete") ) == KMessageBox::Continue )
00454 if ( im->removeIdentity( item->identity().identityName() ) ) {
00455 delete item;
00456 mIdentityList->setSelected( mIdentityList->currentItem(), true );
00457 refreshList();
00458 }
00459 }
00460
00461 void IdentityPage::slotRenameIdentity() {
00462 assert( !mIdentityDialog );
00463
00464 QListViewItem * item = mIdentityList->selectedItem();
00465 if ( !item ) return;
00466
00467 mIdentityList->rename( item, 0 );
00468 }
00469
00470 void IdentityPage::slotRenameIdentity( QListViewItem * i,
00471 const QString & s, int col ) {
00472 assert( col == 0 );
00473 Q_UNUSED( col );
00474
00475 IdentityListViewItem * item = dynamic_cast<IdentityListViewItem*>( i );
00476 if ( !item ) return;
00477
00478 QString newName = s.stripWhiteSpace();
00479 if ( !newName.isEmpty() &&
00480 !kmkernel->identityManager()->shadowIdentities().contains( newName ) ) {
00481 KPIM::Identity & ident = item->identity();
00482 ident.setIdentityName( newName );
00483 emit changed(true);
00484 }
00485 item->redisplay();
00486 }
00487
00488 void IdentityPage::slotContextMenu( KListView *, QListViewItem * i,
00489 const QPoint & pos ) {
00490 IdentityListViewItem * item = dynamic_cast<IdentityListViewItem*>( i );
00491
00492 QPopupMenu * menu = new QPopupMenu( this );
00493 menu->insertItem( i18n("Add..."), this, SLOT(slotNewIdentity()) );
00494 if ( item ) {
00495 menu->insertItem( i18n("Modify..."), this, SLOT(slotModifyIdentity()) );
00496 if ( mIdentityList->childCount() > 1 )
00497 menu->insertItem( i18n("Remove"), this, SLOT(slotRemoveIdentity()) );
00498 if ( !item->identity().isDefault() )
00499 menu->insertItem( i18n("Set as Default"), this, SLOT(slotSetAsDefault()) );
00500 }
00501 menu->exec( pos );
00502 delete menu;
00503 }
00504
00505
00506 void IdentityPage::slotSetAsDefault() {
00507 assert( !mIdentityDialog );
00508
00509 IdentityListViewItem * item =
00510 dynamic_cast<IdentityListViewItem*>( mIdentityList->selectedItem() );
00511 if ( !item ) return;
00512
00513 KPIM::IdentityManager * im = kmkernel->identityManager();
00514 im->setAsDefault( item->identity().identityName() );
00515 refreshList();
00516 }
00517
00518 void IdentityPage::refreshList() {
00519 for ( QListViewItemIterator it( mIdentityList ) ; it.current() ; ++it ) {
00520 IdentityListViewItem * item =
00521 dynamic_cast<IdentityListViewItem*>(it.current());
00522 if ( item )
00523 item->redisplay();
00524 }
00525 emit changed(true);
00526 }
00527
00528 void IdentityPage::slotIdentitySelectionChanged()
00529 {
00530 IdentityListViewItem *item =
00531 dynamic_cast<IdentityListViewItem*>( mIdentityList->selectedItem() );
00532
00533 mRemoveButton->setEnabled( item && mIdentityList->childCount() > 1 );
00534 mModifyButton->setEnabled( item );
00535 mRenameButton->setEnabled( item );
00536 mSetAsDefaultButton->setEnabled( item && !item->identity().isDefault() );
00537 }
00538
00539 void IdentityPage::slotUpdateTransportCombo( const QStringList & sl )
00540 {
00541 if ( mIdentityDialog ) mIdentityDialog->slotUpdateTransportCombo( sl );
00542 }
00543
00544
00545
00546
00547
00548
00549
00550
00551 QString AccountsPage::helpAnchor() const {
00552 return QString::fromLatin1("configure-accounts");
00553 }
00554
00555 AccountsPage::AccountsPage( QWidget * parent, const char * name )
00556 : ConfigModuleWithTabs( parent, name )
00557 {
00558
00559
00560
00561 mReceivingTab = new ReceivingTab();
00562 addTab( mReceivingTab, i18n( "&Receiving" ) );
00563 connect( mReceivingTab, SIGNAL(accountListChanged(const QStringList &)),
00564 this, SIGNAL(accountListChanged(const QStringList &)) );
00565
00566
00567
00568
00569 mSendingTab = new SendingTab();
00570 addTab( mSendingTab, i18n( "&Sending" ) );
00571 connect( mSendingTab, SIGNAL(transportListChanged(const QStringList&)),
00572 this, SIGNAL(transportListChanged(const QStringList&)) );
00573
00574 load();
00575 }
00576
00577 QString AccountsPage::SendingTab::helpAnchor() const {
00578 return QString::fromLatin1("configure-accounts-sending");
00579 }
00580
00581 AccountsPageSendingTab::AccountsPageSendingTab( QWidget * parent, const char * name )
00582 : ConfigModuleTab( parent, name )
00583 {
00584 mTransportInfoList.setAutoDelete( true );
00585
00586 QVBoxLayout *vlay;
00587 QVBoxLayout *btn_vlay;
00588 QHBoxLayout *hlay;
00589 QGridLayout *glay;
00590 QPushButton *button;
00591 QGroupBox *group;
00592
00593 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
00594
00595 vlay->addWidget( new QLabel( i18n("Outgoing accounts (add at least one):"), this ) );
00596
00597
00598 hlay = new QHBoxLayout();
00599 vlay->addLayout( hlay, 10 );
00600
00601
00602
00603 mTransportList = new ListView( this, "transportList", 5 );
00604 mTransportList->addColumn( i18n("Name") );
00605 mTransportList->addColumn( i18n("Type") );
00606 mTransportList->setAllColumnsShowFocus( true );
00607 mTransportList->setSorting( -1 );
00608 connect( mTransportList, SIGNAL(selectionChanged()),
00609 this, SLOT(slotTransportSelected()) );
00610 connect( mTransportList, SIGNAL(doubleClicked( QListViewItem *)),
00611 this, SLOT(slotModifySelectedTransport()) );
00612 hlay->addWidget( mTransportList, 1 );
00613
00614
00615 btn_vlay = new QVBoxLayout( hlay );
00616
00617
00618 button = new QPushButton( i18n("A&dd..."), this );
00619 button->setAutoDefault( false );
00620 connect( button, SIGNAL(clicked()),
00621 this, SLOT(slotAddTransport()) );
00622 btn_vlay->addWidget( button );
00623
00624
00625 mModifyTransportButton = new QPushButton( i18n("&Modify..."), this );
00626 mModifyTransportButton->setAutoDefault( false );
00627 mModifyTransportButton->setEnabled( false );
00628 connect( mModifyTransportButton, SIGNAL(clicked()),
00629 this, SLOT(slotModifySelectedTransport()) );
00630 btn_vlay->addWidget( mModifyTransportButton );
00631
00632
00633 mRemoveTransportButton = new QPushButton( i18n("R&emove"), this );
00634 mRemoveTransportButton->setAutoDefault( false );
00635 mRemoveTransportButton->setEnabled( false );
00636 connect( mRemoveTransportButton, SIGNAL(clicked()),
00637 this, SLOT(slotRemoveSelectedTransport()) );
00638 btn_vlay->addWidget( mRemoveTransportButton );
00639
00640 mSetDefaultTransportButton = new QPushButton( i18n("Set Default"), this );
00641 mSetDefaultTransportButton->setAutoDefault( false );
00642 mSetDefaultTransportButton->setEnabled( false );
00643 connect ( mSetDefaultTransportButton, SIGNAL(clicked()),
00644 this, SLOT(slotSetDefaultTransport()) );
00645 btn_vlay->addWidget( mSetDefaultTransportButton );
00646 btn_vlay->addStretch( 1 );
00647
00648
00649 group = new QGroupBox( 0, Qt::Vertical,
00650 i18n("Common Options"), this );
00651 vlay->addWidget(group);
00652
00653
00654 glay = new QGridLayout( group->layout(), 5, 3, KDialog::spacingHint() );
00655 glay->setColStretch( 2, 10 );
00656
00657
00658 mConfirmSendCheck = new QCheckBox( i18n("Confirm &before send"), group );
00659 glay->addMultiCellWidget( mConfirmSendCheck, 0, 0, 0, 1 );
00660 connect( mConfirmSendCheck, SIGNAL( stateChanged( int ) ),
00661 this, SLOT( slotEmitChanged( void ) ) );
00662
00663
00664 mSendOnCheckCombo = new QComboBox( false, group );
00665 mSendOnCheckCombo->insertStringList( QStringList()
00666 << i18n("Never Automatically")
00667 << i18n("On Manual Mail Checks")
00668 << i18n("On All Mail Checks") );
00669 glay->addWidget( mSendOnCheckCombo, 1, 1 );
00670 connect( mSendOnCheckCombo, SIGNAL( activated( int ) ),
00671 this, SLOT( slotEmitChanged( void ) ) );
00672
00673
00674 mSendMethodCombo = new QComboBox( false, group );
00675 mSendMethodCombo->insertStringList( QStringList()
00676 << i18n("Send Now")
00677 << i18n("Send Later") );
00678 glay->addWidget( mSendMethodCombo, 2, 1 );
00679 connect( mSendMethodCombo, SIGNAL( activated( int ) ),
00680 this, SLOT( slotEmitChanged( void ) ) );
00681
00682
00683
00684
00685 mMessagePropertyCombo = new QComboBox( false, group );
00686 mMessagePropertyCombo->insertStringList( QStringList()
00687 << i18n("Allow 8-bit")
00688 << i18n("MIME Compliant (Quoted Printable)") );
00689 glay->addWidget( mMessagePropertyCombo, 3, 1 );
00690 connect( mMessagePropertyCombo, SIGNAL( activated( int ) ),
00691 this, SLOT( slotEmitChanged( void ) ) );
00692
00693
00694 mDefaultDomainEdit = new KLineEdit( group );
00695 glay->addMultiCellWidget( mDefaultDomainEdit, 4, 4, 1, 2 );
00696 connect( mDefaultDomainEdit, SIGNAL( textChanged( const QString& ) ),
00697 this, SLOT( slotEmitChanged( void ) ) );
00698
00699
00700 QLabel *l = new QLabel( mSendOnCheckCombo,
00701 i18n("Send &messages in outbox folder:"), group );
00702 glay->addWidget( l, 1, 0 );
00703
00704 QString msg = i18n( GlobalSettings::self()->sendOnCheckItem()->whatsThis().utf8() );
00705 QWhatsThis::add( l, msg );
00706 QWhatsThis::add( mSendOnCheckCombo, msg );
00707
00708 glay->addWidget( new QLabel( mSendMethodCombo,
00709 i18n("Defa&ult send method:"), group ), 2, 0 );
00710 glay->addWidget( new QLabel( mMessagePropertyCombo,
00711 i18n("Message &property:"), group ), 3, 0 );
00712 l = new QLabel( mDefaultDomainEdit,
00713 i18n("Defaul&t domain:"), group );
00714 glay->addWidget( l, 4, 0 );
00715
00716
00717 msg = i18n( "<qt><p>The default domain is used to complete email "
00718 "addresses that only consist of the user's name."
00719 "</p></qt>" );
00720 QWhatsThis::add( l, msg );
00721 QWhatsThis::add( mDefaultDomainEdit, msg );
00722 }
00723
00724
00725 void AccountsPage::SendingTab::slotTransportSelected()
00726 {
00727 QListViewItem *cur = mTransportList->selectedItem();
00728 mModifyTransportButton->setEnabled( cur );
00729 mRemoveTransportButton->setEnabled( cur );
00730 mSetDefaultTransportButton->setEnabled( cur );
00731 }
00732
00733
00734 static inline QString uniqueName( const QStringList & list,
00735 const QString & name )
00736 {
00737 int suffix = 1;
00738 QString result = name;
00739 while ( list.find( result ) != list.end() ) {
00740 result = i18n("%1: name; %2: number appended to it to make it unique "
00741 "among a list of names", "%1 %2")
00742 .arg( name ).arg( suffix );
00743 suffix++;
00744 }
00745 return result;
00746 }
00747
00748 void AccountsPage::SendingTab::slotSetDefaultTransport()
00749 {
00750 QListViewItem *item = mTransportList->selectedItem();
00751 if ( !item ) return;
00752
00753 KMTransportInfo ti;
00754
00755 QListViewItemIterator it( mTransportList );
00756 for ( ; it.current(); ++it ) {
00757 ti.readConfig( KMTransportInfo::findTransport( it.current()->text(0) ));
00758 if ( ti.type != "sendmail" ) {
00759 it.current()->setText( 1, "smtp" );
00760 } else {
00761 it.current()->setText( 1, "sendmail" );
00762 }
00763 }
00764
00765 if ( item->text(1) != "sendmail" ) {
00766 item->setText( 1, i18n( "smtp (Default)" ));
00767 } else {
00768 item->setText( 1, i18n( "sendmail (Default)" ));
00769 }
00770
00771 GlobalSettings::self()->setDefaultTransport( item->text(0) );
00772
00773 }
00774
00775 void AccountsPage::SendingTab::slotAddTransport()
00776 {
00777 int transportType;
00778
00779 {
00780 KMTransportSelDlg selDialog( this );
00781 if ( selDialog.exec() != QDialog::Accepted ) return;
00782 transportType = selDialog.selected();
00783 }
00784
00785 KMTransportInfo *transportInfo = new KMTransportInfo();
00786 switch ( transportType ) {
00787 case 0:
00788 transportInfo->type = QString::fromLatin1("smtp");
00789 break;
00790 case 1:
00791 transportInfo->type = QString::fromLatin1("sendmail");
00792 transportInfo->name = i18n("Sendmail");
00793 transportInfo->host = _PATH_SENDMAIL;
00794 break;
00795 default:
00796 assert( 0 );
00797 }
00798
00799 KMTransportDialog dialog( i18n("Add Transport"), transportInfo, this );
00800
00801
00802
00803 QStringList transportNames;
00804 QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
00805 for ( it.toFirst() ; it.current() ; ++it )
00806 transportNames << (*it)->name;
00807
00808 if( dialog.exec() != QDialog::Accepted ) {
00809 delete transportInfo;
00810 return;
00811 }
00812
00813
00814
00815 transportInfo->name = uniqueName( transportNames, transportInfo->name );
00816
00817 transportNames << transportInfo->name;
00818 mTransportInfoList.append( transportInfo );
00819
00820
00821
00822 QListViewItem *lastItem = mTransportList->firstChild();
00823 QString typeDisplayName;
00824 if ( lastItem ) {
00825 typeDisplayName = transportInfo->type;
00826 } else {
00827 typeDisplayName = i18n("%1: type of transport. Result used in "
00828 "Configure->Accounts->Sending listview, \"type\" "
00829 "column, first row, to indicate that this is the "
00830 "default transport", "%1 (Default)")
00831 .arg( transportInfo->type );
00832 GlobalSettings::self()->setDefaultTransport( transportInfo->name );
00833 }
00834 (void) new QListViewItem( mTransportList, lastItem, transportInfo->name,
00835 typeDisplayName );
00836
00837
00838 emit transportListChanged( transportNames );
00839 emit changed( true );
00840 }
00841
00842 void AccountsPage::SendingTab::slotModifySelectedTransport()
00843 {
00844 QListViewItem *item = mTransportList->selectedItem();
00845 if ( !item ) return;
00846
00847 const QString& originalTransport = item->text(0);
00848
00849 QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
00850 for ( it.toFirst() ; it.current() ; ++it )
00851 if ( (*it)->name == item->text(0) ) break;
00852 if ( !it.current() ) return;
00853
00854 KMTransportDialog dialog( i18n("Modify Transport"), (*it), this );
00855
00856 if ( dialog.exec() != QDialog::Accepted ) return;
00857
00858
00859
00860 QStringList transportNames;
00861 QPtrListIterator<KMTransportInfo> jt( mTransportInfoList );
00862 int entryLocation = -1;
00863 for ( jt.toFirst() ; jt.current() ; ++jt )
00864 if ( jt != it )
00865 transportNames << (*jt)->name;
00866 else
00867 entryLocation = transportNames.count();
00868 assert( entryLocation >= 0 );
00869
00870
00871 (*it)->name = uniqueName( transportNames, (*it)->name );
00872
00873 item->setText( 0, (*it)->name );
00874
00875
00876 transportNames.insert( transportNames.at( entryLocation ), (*it)->name );
00877 const QString& newTransportName = (*it)->name;
00878
00879 QStringList changedIdents;
00880 KPIM::IdentityManager * im = kmkernel->identityManager();
00881 for ( KPIM::IdentityManager::Iterator it = im->modifyBegin(); it != im->modifyEnd(); ++it ) {
00882 if ( originalTransport == (*it).transport() ) {
00883 (*it).setTransport( newTransportName );
00884 changedIdents += (*it).identityName();
00885 }
00886 }
00887
00888 if ( !changedIdents.isEmpty() ) {
00889 QString information = i18n( "This identity has been changed to use the modified transport:",
00890 "These %n identities have been changed to use the modified transport:",
00891 changedIdents.count() );
00892 KMessageBox::informationList( this, information, changedIdents );
00893 }
00894
00895 emit transportListChanged( transportNames );
00896 emit changed( true );
00897 }
00898
00899 void AccountsPage::SendingTab::slotRemoveSelectedTransport()
00900 {
00901 QListViewItem *item = mTransportList->selectedItem();
00902 if ( !item ) return;
00903
00904 QStringList changedIdents;
00905 KPIM::IdentityManager * im = kmkernel->identityManager();
00906 for ( KPIM::IdentityManager::Iterator it = im->modifyBegin(); it != im->modifyEnd(); ++it ) {
00907 if ( item->text( 0 ) == (*it).transport() ) {
00908 (*it).setTransport( QString::null );
00909 changedIdents += (*it).identityName();
00910 }
00911 }
00912
00913
00914 const QString& currentTransport = GlobalSettings::self()->currentTransport();
00915 if ( item->text( 0 ) == currentTransport ) {
00916 GlobalSettings::self()->setCurrentTransport( QString::null );
00917 }
00918
00919 if ( !changedIdents.isEmpty() ) {
00920 QString information = i18n( "This identity has been changed to use the default transport:",
00921 "These %n identities have been changed to use the default transport:",
00922 changedIdents.count() );
00923 KMessageBox::informationList( this, information, changedIdents );
00924 }
00925
00926 QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
00927 for ( it.toFirst() ; it.current() ; ++it )
00928 if ( (*it)->name == item->text(0) ) break;
00929 if ( !it.current() ) return;
00930
00931 KMTransportInfo ti;
00932
00933 QListViewItem *newCurrent = item->itemBelow();
00934 if ( !newCurrent ) newCurrent = item->itemAbove();
00935
00936 if ( newCurrent ) {
00937 mTransportList->setCurrentItem( newCurrent );
00938 mTransportList->setSelected( newCurrent, true );
00939 GlobalSettings::self()->setDefaultTransport( newCurrent->text(0) );
00940 ti.readConfig( KMTransportInfo::findTransport( newCurrent->text(0) ));
00941 if ( item->text( 0 ) == GlobalSettings::self()->defaultTransport() ) {
00942 if ( ti.type != "sendmail" ) {
00943 newCurrent->setText( 1, i18n("smtp (Default)") );
00944 } else {
00945 newCurrent->setText( 1, i18n("sendmail (Default)" ));
00946 }
00947 }
00948 } else {
00949 GlobalSettings::self()->setDefaultTransport( QString::null );
00950 }
00951
00952 delete item;
00953 mTransportInfoList.remove( it );
00954
00955 QStringList transportNames;
00956 for ( it.toFirst() ; it.current() ; ++it )
00957 transportNames << (*it)->name;
00958 emit transportListChanged( transportNames );
00959 emit changed( true );
00960 }
00961
00962 void AccountsPage::SendingTab::doLoadFromGlobalSettings() {
00963 mSendOnCheckCombo->setCurrentItem( GlobalSettings::self()->sendOnCheck() );
00964 }
00965
00966 void AccountsPage::SendingTab::doLoadOther() {
00967 KConfigGroup general( KMKernel::config(), "General");
00968 KConfigGroup composer( KMKernel::config(), "Composer");
00969
00970 int numTransports = general.readNumEntry("transports", 0);
00971
00972 QListViewItem *top = 0;
00973 mTransportInfoList.clear();
00974 mTransportList->clear();
00975 QStringList transportNames;
00976 for ( int i = 1 ; i <= numTransports ; i++ ) {
00977 KMTransportInfo *ti = new KMTransportInfo();
00978 ti->readConfig(i);
00979 mTransportInfoList.append( ti );
00980 transportNames << ti->name;
00981 top = new QListViewItem( mTransportList, top, ti->name, ti->type );
00982 }
00983 emit transportListChanged( transportNames );
00984
00985 const QString &defaultTransport = GlobalSettings::self()->defaultTransport();
00986
00987 QListViewItemIterator it( mTransportList );
00988 for ( ; it.current(); ++it ) {
00989 if ( it.current()->text(0) == defaultTransport ) {
00990 if ( it.current()->text(1) != "sendmail" ) {
00991 it.current()->setText( 1, i18n( "smtp (Default)" ));
00992 } else {
00993 it.current()->setText( 1, i18n( "sendmail (Default)" ));
00994 }
00995 } else {
00996 if ( it.current()->text(1) != "sendmail" ) {
00997 it.current()->setText( 1, "smtp" );
00998 } else {
00999 it.current()->setText( 1, "sendmail" );
01000 }
01001 }
01002 }
01003
01004 mSendMethodCombo->setCurrentItem(
01005 kmkernel->msgSender()->sendImmediate() ? 0 : 1 );
01006 mMessagePropertyCombo->setCurrentItem(
01007 kmkernel->msgSender()->sendQuotedPrintable() ? 1 : 0 );
01008
01009 mConfirmSendCheck->setChecked( composer.readBoolEntry( "confirm-before-send",
01010 false ) );
01011 QString str = general.readEntry( "Default domain" );
01012 if( str.isEmpty() )
01013 {
01014
01015
01016
01017 char buffer[256];
01018 if ( !gethostname( buffer, 255 ) )
01019
01020 buffer[255] = 0;
01021 else
01022 buffer[0] = 0;
01023 str = QString::fromLatin1( *buffer ? buffer : "localhost" );
01024 }
01025 mDefaultDomainEdit->setText( str );
01026 }
01027
01028 void AccountsPage::SendingTab::save() {
01029 KConfigGroup general( KMKernel::config(), "General" );
01030 KConfigGroup composer( KMKernel::config(), "Composer" );
01031
01032
01033 general.writeEntry( "transports", mTransportInfoList.count() );
01034 QPtrListIterator<KMTransportInfo> it( mTransportInfoList );
01035 for ( int i = 1 ; it.current() ; ++it, ++i )
01036 (*it)->writeConfig(i);
01037
01038
01039 GlobalSettings::self()->setSendOnCheck( mSendOnCheckCombo->currentItem() );
01040 kmkernel->msgSender()->setSendImmediate(
01041 mSendMethodCombo->currentItem() == 0 );
01042 kmkernel->msgSender()->setSendQuotedPrintable(
01043 mMessagePropertyCombo->currentItem() == 1 );
01044 kmkernel->msgSender()->writeConfig( false );
01045 composer.writeEntry("confirm-before-send", mConfirmSendCheck->isChecked() );
01046 general.writeEntry( "Default domain", mDefaultDomainEdit->text() );
01047 }
01048
01049 QString AccountsPage::ReceivingTab::helpAnchor() const {
01050 return QString::fromLatin1("configure-accounts-receiving");
01051 }
01052
01053 AccountsPageReceivingTab::AccountsPageReceivingTab( QWidget * parent, const char * name )
01054 : ConfigModuleTab ( parent, name )
01055 {
01056
01057 QVBoxLayout *vlay;
01058 QVBoxLayout *btn_vlay;
01059 QHBoxLayout *hlay;
01060 QPushButton *button;
01061 QGroupBox *group;
01062
01063 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
01064
01065
01066 vlay->addWidget( new QLabel( i18n("Incoming accounts (add at least one):"), this ) );
01067
01068
01069 hlay = new QHBoxLayout();
01070 vlay->addLayout( hlay, 10 );
01071
01072
01073 mAccountList = new ListView( this, "accountList", 5 );
01074 mAccountList->addColumn( i18n("Name") );
01075 mAccountList->addColumn( i18n("Type") );
01076 mAccountList->addColumn( i18n("Folder") );
01077 mAccountList->setAllColumnsShowFocus( true );
01078 mAccountList->setSorting( -1 );
01079 connect( mAccountList, SIGNAL(selectionChanged()),
01080 this, SLOT(slotAccountSelected()) );
01081 connect( mAccountList, SIGNAL(doubleClicked( QListViewItem *)),
01082 this, SLOT(slotModifySelectedAccount()) );
01083 hlay->addWidget( mAccountList, 1 );
01084
01085
01086 btn_vlay = new QVBoxLayout( hlay );
01087
01088
01089 button = new QPushButton( i18n("A&dd..."), this );
01090 button->setAutoDefault( false );
01091 connect( button, SIGNAL(clicked()),
01092 this, SLOT(slotAddAccount()) );
01093 btn_vlay->addWidget( button );
01094
01095
01096 mModifyAccountButton = new QPushButton( i18n("&Modify..."), this );
01097 mModifyAccountButton->setAutoDefault( false );
01098 mModifyAccountButton->setEnabled( false );
01099 connect( mModifyAccountButton, SIGNAL(clicked()),
01100 this, SLOT(slotModifySelectedAccount()) );
01101 btn_vlay->addWidget( mModifyAccountButton );
01102
01103
01104 mRemoveAccountButton = new QPushButton( i18n("R&emove"), this );
01105 mRemoveAccountButton->setAutoDefault( false );
01106 mRemoveAccountButton->setEnabled( false );
01107 connect( mRemoveAccountButton, SIGNAL(clicked()),
01108 this, SLOT(slotRemoveSelectedAccount()) );
01109 btn_vlay->addWidget( mRemoveAccountButton );
01110 btn_vlay->addStretch( 1 );
01111
01112 mCheckmailStartupCheck = new QCheckBox( i18n("Chec&k mail on startup"), this );
01113 vlay->addWidget( mCheckmailStartupCheck );
01114 connect( mCheckmailStartupCheck, SIGNAL( stateChanged( int ) ),
01115 this, SLOT( slotEmitChanged( void ) ) );
01116
01117
01118 group = new QVGroupBox( i18n("New Mail Notification"), this );
01119 vlay->addWidget( group );
01120 group->layout()->setSpacing( KDialog::spacingHint() );
01121
01122
01123 mBeepNewMailCheck = new QCheckBox(i18n("&Beep"), group );
01124 mBeepNewMailCheck->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding,
01125 QSizePolicy::Fixed ) );
01126 connect( mBeepNewMailCheck, SIGNAL( stateChanged( int ) ),
01127 this, SLOT( slotEmitChanged( void ) ) );
01128
01129
01130 mVerboseNotificationCheck =
01131 new QCheckBox( i18n( "Deta&iled new mail notification" ), group );
01132 mVerboseNotificationCheck->setSizePolicy( QSizePolicy( QSizePolicy::MinimumExpanding,
01133 QSizePolicy::Fixed ) );
01134 QToolTip::add( mVerboseNotificationCheck,
01135 i18n( "Show for each folder the number of newly arrived "
01136 "messages" ) );
01137 QWhatsThis::add( mVerboseNotificationCheck,
01138 GlobalSettings::self()->verboseNewMailNotificationItem()->whatsThis() );
01139 connect( mVerboseNotificationCheck, SIGNAL( stateChanged( int ) ),
01140 this, SLOT( slotEmitChanged() ) );
01141
01142
01143 mOtherNewMailActionsButton = new QPushButton( i18n("Other Actio&ns"), group );
01144 mOtherNewMailActionsButton->setSizePolicy( QSizePolicy( QSizePolicy::Fixed,
01145 QSizePolicy::Fixed ) );
01146 connect( mOtherNewMailActionsButton, SIGNAL(clicked()),
01147 this, SLOT(slotEditNotifications()) );
01148 }
01149
01150
01151 void AccountsPage::ReceivingTab::slotAccountSelected()
01152 {
01153 QListViewItem * item = mAccountList->selectedItem();
01154 mModifyAccountButton->setEnabled( item );
01155 mRemoveAccountButton->setEnabled( item );
01156 }
01157
01158 QStringList AccountsPage::ReceivingTab::occupiedNames()
01159 {
01160 QStringList accountNames = kmkernel->acctMgr()->getAccounts();
01161
01162 QValueList<ModifiedAccountsType*>::Iterator k;
01163 for (k = mModifiedAccounts.begin(); k != mModifiedAccounts.end(); ++k )
01164 if ((*k)->oldAccount)
01165 accountNames.remove( (*k)->oldAccount->name() );
01166
01167 QValueList< QGuardedPtr<KMAccount> >::Iterator l;
01168 for (l = mAccountsToDelete.begin(); l != mAccountsToDelete.end(); ++l )
01169 if (*l)
01170 accountNames.remove( (*l)->name() );
01171
01172 QValueList< QGuardedPtr<KMAccount> >::Iterator it;
01173 for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it )
01174 if (*it)
01175 accountNames += (*it)->name();
01176
01177 QValueList<ModifiedAccountsType*>::Iterator j;
01178 for (j = mModifiedAccounts.begin(); j != mModifiedAccounts.end(); ++j )
01179 accountNames += (*j)->newAccount->name();
01180
01181 return accountNames;
01182 }
01183
01184 void AccountsPage::ReceivingTab::slotAddAccount() {
01185 KMAcctSelDlg accountSelectorDialog( this );
01186 if( accountSelectorDialog.exec() != QDialog::Accepted ) return;
01187
01188 const char *accountType = 0;
01189 switch ( accountSelectorDialog.selected() ) {
01190 case 0: accountType = "local"; break;
01191 case 1: accountType = "pop"; break;
01192 case 2: accountType = "imap"; break;
01193 case 3: accountType = "cachedimap"; break;
01194 case 4: accountType = "maildir"; break;
01195
01196 default:
01197
01198
01199 KMessageBox::sorry( this, i18n("Unknown account type selected") );
01200 return;
01201 }
01202
01203 KMAccount *account
01204 = kmkernel->acctMgr()->create( QString::fromLatin1( accountType ) );
01205 if ( !account ) {
01206
01207
01208 KMessageBox::sorry( this, i18n("Unable to create account") );
01209 return;
01210 }
01211
01212 account->init();
01213
01214 AccountDialog dialog( i18n("Add Account"), account, this );
01215
01216 QStringList accountNames = occupiedNames();
01217
01218 if( dialog.exec() != QDialog::Accepted ) {
01219 delete account;
01220 return;
01221 }
01222
01223 account->deinstallTimer();
01224 account->setName( uniqueName( accountNames, account->name() ) );
01225
01226 QListViewItem *after = mAccountList->firstChild();
01227 while ( after && after->nextSibling() )
01228 after = after->nextSibling();
01229
01230 QListViewItem *listItem =
01231 new QListViewItem( mAccountList, after, account->name(), account->type() );
01232 if( account->folder() )
01233 listItem->setText( 2, account->folder()->label() );
01234
01235 mNewAccounts.append( account );
01236 emit changed( true );
01237 }
01238
01239
01240
01241 void AccountsPage::ReceivingTab::slotModifySelectedAccount()
01242 {
01243 QListViewItem *listItem = mAccountList->selectedItem();
01244 if( !listItem ) return;
01245
01246 KMAccount *account = 0;
01247 QValueList<ModifiedAccountsType*>::Iterator j;
01248 for (j = mModifiedAccounts.begin(); j != mModifiedAccounts.end(); ++j )
01249 if ( (*j)->newAccount->name() == listItem->text(0) ) {
01250 account = (*j)->newAccount;
01251 break;
01252 }
01253
01254 if ( !account ) {
01255 QValueList< QGuardedPtr<KMAccount> >::Iterator it;
01256 for ( it = mNewAccounts.begin() ; it != mNewAccounts.end() ; ++it )
01257 if ( (*it)->name() == listItem->text(0) ) {
01258 account = *it;
01259 break;
01260 }
01261
01262 if ( !account ) {
01263 account = kmkernel->acctMgr()->findByName( listItem->text(0) );
01264 if( !account ) {
01265
01266 KMessageBox::sorry( this, i18n("Unable to locate account") );
01267 return;
01268 }
01269 if ( account->type() == "imap" || account->type() == "cachedimap" )
01270 {
01271 ImapAccountBase* ai = static_cast<ImapAccountBase*>( account );
01272 if ( ai->namespaces().isEmpty() || ai->namespaceToDelimiter().isEmpty() )
01273 {
01274
01275 kdDebug(5006) << "slotModifySelectedAccount - connect" << endl;
01276 ai->makeConnection();
01277 }
01278 }
01279
01280 ModifiedAccountsType *mod = new ModifiedAccountsType;
01281 mod->oldAccount = account;
01282 mod->newAccount = kmkernel->acctMgr()->create( account->type(),
01283 account->name() );
01284 mod->newAccount->pseudoAssign( account );
01285 mModifiedAccounts.append( mod );
01286 account = mod->newAccount;
01287 }
01288 }
01289
01290 QStringList accountNames = occupiedNames();
01291 accountNames.remove( account->name() );
01292
01293 AccountDialog dialog( i18n("Modify Account"), account, this );
01294
01295 if( dialog.exec() != QDialog::Accepted ) return;
01296
01297 account->setName( uniqueName( accountNames, account->name() ) );
01298
01299 listItem->setText( 0, account->name() );
01300 listItem->setText( 1, account->type() );
01301 if( account->folder() )
01302 listItem->setText( 2, account->folder()->label() );
01303
01304 emit changed( true );
01305 }
01306
01307
01308
01309 void AccountsPage::ReceivingTab::slotRemoveSelectedAccount() {
01310 QListViewItem *listItem = mAccountList->selectedItem();
01311 if( !listItem ) return;
01312
01313 KMAccount *acct = 0;
01314 QValueList<ModifiedAccountsType*>::Iterator j;
01315 for ( j = mModifiedAccounts.begin() ; j != mModifiedAccounts.end() ; ++j )
01316 if ( (*j)->newAccount->name() == listItem->text(0) ) {
01317 acct = (*j)->oldAccount;
01318 mAccountsToDelete.append( acct );
01319 mModifiedAccounts.remove( j );
01320 break;
01321 }
01322 if ( !acct ) {
01323 QValueList< QGuardedPtr<KMAccount> >::Iterator it;
01324 for ( it = mNewAccounts.begin() ; it != mNewAccounts.end() ; ++it )
01325 if ( (*it)->name() == listItem->text(0) ) {
01326 acct = *it;
01327 mNewAccounts.remove( it );
01328 break;
01329 }
01330 }
01331 if ( !acct ) {
01332 acct = kmkernel->acctMgr()->findByName( listItem->text(0) );
01333 if ( acct )
01334 mAccountsToDelete.append( acct );
01335 }
01336 if ( !acct ) {
01337
01338 KMessageBox::sorry( this, i18n("<qt>Unable to locate account <b>%1</b>.</qt>")
01339 .arg(listItem->text(0)) );
01340 return;
01341 }
01342
01343 QListViewItem * item = listItem->itemBelow();
01344 if ( !item ) item = listItem->itemAbove();
01345 delete listItem;
01346
01347 if ( item )
01348 mAccountList->setSelected( item, true );
01349
01350 emit changed( true );
01351 }
01352
01353 void AccountsPage::ReceivingTab::slotEditNotifications()
01354 {
01355 if(kmkernel->xmlGuiInstance())
01356 KNotifyDialog::configure(this, 0, kmkernel->xmlGuiInstance()->aboutData());
01357 else
01358 KNotifyDialog::configure(this);
01359 }
01360
01361 void AccountsPage::ReceivingTab::doLoadFromGlobalSettings() {
01362 mVerboseNotificationCheck->setChecked( GlobalSettings::self()->verboseNewMailNotification() );
01363 }
01364
01365 void AccountsPage::ReceivingTab::doLoadOther() {
01366 KConfigGroup general( KMKernel::config(), "General" );
01367
01368 mAccountList->clear();
01369 QListViewItem *top = 0;
01370
01371 for( KMAccount *a = kmkernel->acctMgr()->first(); a!=0;
01372 a = kmkernel->acctMgr()->next() ) {
01373 QListViewItem *listItem =
01374 new QListViewItem( mAccountList, top, a->name(), a->type() );
01375 if( a->folder() )
01376 listItem->setText( 2, a->folder()->label() );
01377 top = listItem;
01378 }
01379 QListViewItem *listItem = mAccountList->firstChild();
01380 if ( listItem ) {
01381 mAccountList->setCurrentItem( listItem );
01382 mAccountList->setSelected( listItem, true );
01383 }
01384
01385 mBeepNewMailCheck->setChecked( general.readBoolEntry("beep-on-mail", false ) );
01386 mCheckmailStartupCheck->setChecked( general.readBoolEntry("checkmail-startup", false) );
01387 QTimer::singleShot( 0, this, SLOT( slotTweakAccountList() ) );
01388 }
01389
01390 void AccountsPage::ReceivingTab::slotTweakAccountList()
01391 {
01392
01393
01394 mAccountList->resizeContents( mAccountList->visibleWidth(), mAccountList->contentsHeight() );
01395 }
01396
01397 void AccountsPage::ReceivingTab::save() {
01398
01399 QValueList< QGuardedPtr<KMAccount> >::Iterator it;
01400 for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) {
01401 kmkernel->acctMgr()->add( *it );
01402 (*it)->installTimer();
01403 }
01404
01405
01406 QValueList<ModifiedAccountsType*>::Iterator j;
01407 for ( j = mModifiedAccounts.begin() ; j != mModifiedAccounts.end() ; ++j ) {
01408 (*j)->oldAccount->pseudoAssign( (*j)->newAccount );
01409 delete (*j)->newAccount;
01410 delete (*j);
01411 }
01412 mModifiedAccounts.clear();
01413
01414
01415 for ( it = mAccountsToDelete.begin() ;
01416 it != mAccountsToDelete.end() ; ++it ) {
01417 kmkernel->acctMgr()->writeConfig( true );
01418 if ( (*it) && !kmkernel->acctMgr()->remove(*it) )
01419 KMessageBox::sorry( this, i18n("<qt>Unable to locate account <b>%1</b>.</qt>")
01420 .arg( (*it)->name() ) );
01421 }
01422 mAccountsToDelete.clear();
01423
01424
01425 kmkernel->acctMgr()->writeConfig( false );
01426 kmkernel->cleanupImapFolders();
01427
01428
01429 KConfigGroup general( KMKernel::config(), "General" );
01430 general.writeEntry( "beep-on-mail", mBeepNewMailCheck->isChecked() );
01431 GlobalSettings::self()->setVerboseNewMailNotification( mVerboseNotificationCheck->isChecked() );
01432
01433 general.writeEntry( "checkmail-startup", mCheckmailStartupCheck->isChecked() );
01434
01435
01436 for (it = mNewAccounts.begin(); it != mNewAccounts.end(); ++it ) {
01437 KMAccount *macc = (*it);
01438 ImapAccountBase *acc = dynamic_cast<ImapAccountBase*> (macc);
01439 if ( acc ) {
01440 AccountUpdater *au = new AccountUpdater( acc );
01441 au->update();
01442 }
01443 }
01444 mNewAccounts.clear();
01445
01446 }
01447
01448
01449
01450
01451
01452
01453 QString AppearancePage::helpAnchor() const {
01454 return QString::fromLatin1("configure-appearance");
01455 }
01456
01457 AppearancePage::AppearancePage( QWidget * parent, const char * name )
01458 : ConfigModuleWithTabs( parent, name )
01459 {
01460
01461
01462
01463 mFontsTab = new FontsTab();
01464 addTab( mFontsTab, i18n("&Fonts") );
01465
01466
01467
01468
01469 mColorsTab = new ColorsTab();
01470 addTab( mColorsTab, i18n("Color&s") );
01471
01472
01473
01474
01475 mLayoutTab = new LayoutTab();
01476 addTab( mLayoutTab, i18n("La&yout") );
01477
01478
01479
01480
01481 mHeadersTab = new HeadersTab();
01482 addTab( mHeadersTab, i18n("M&essage List") );
01483
01484
01485
01486
01487 mReaderTab = new ReaderTab();
01488 addTab( mReaderTab, i18n("Message W&indow") );
01489
01490
01491
01492
01493 mSystemTrayTab = new SystemTrayTab();
01494 addTab( mSystemTrayTab, i18n("System &Tray") );
01495
01496 load();
01497 }
01498
01499
01500 QString AppearancePage::FontsTab::helpAnchor() const {
01501 return QString::fromLatin1("configure-appearance-fonts");
01502 }
01503
01504 static const struct {
01505 const char * configName;
01506 const char * displayName;
01507 bool enableFamilyAndSize;
01508 bool onlyFixed;
01509 } fontNames[] = {
01510 { "body-font", I18N_NOOP("Message Body"), true, false },
01511 { "list-font", I18N_NOOP("Message List"), true, false },
01512 { "list-new-font", I18N_NOOP("Message List - New Messages"), true, false },
01513 { "list-unread-font", I18N_NOOP("Message List - Unread Messages"), true, false },
01514 { "list-important-font", I18N_NOOP("Message List - Important Messages"), true, false },
01515 { "list-todo-font", I18N_NOOP("Message List - Todo Messages"), true, false },
01516 { "list-date-font", I18N_NOOP("Message List - Date Field"), true, false },
01517 { "folder-font", I18N_NOOP("Folder List"), true, false },
01518 { "quote1-font", I18N_NOOP("Quoted Text - First Level"), false, false },
01519 { "quote2-font", I18N_NOOP("Quoted Text - Second Level"), false, false },
01520 { "quote3-font", I18N_NOOP("Quoted Text - Third Level"), false, false },
01521 { "fixed-font", I18N_NOOP("Fixed Width Font"), true, true },
01522 { "composer-font", I18N_NOOP("Composer"), true, false },
01523 { "print-font", I18N_NOOP("Printing Output"), true, false },
01524 };
01525 static const int numFontNames = sizeof fontNames / sizeof *fontNames;
01526
01527 AppearancePageFontsTab::AppearancePageFontsTab( QWidget * parent, const char * name )
01528 : ConfigModuleTab( parent, name ), mActiveFontIndex( -1 )
01529 {
01530 assert( numFontNames == sizeof mFont / sizeof *mFont );
01531
01532 QVBoxLayout *vlay;
01533 QHBoxLayout *hlay;
01534 QLabel *label;
01535
01536
01537 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
01538 mCustomFontCheck = new QCheckBox( i18n("&Use custom fonts"), this );
01539 vlay->addWidget( mCustomFontCheck );
01540 vlay->addWidget( new KSeparator( KSeparator::HLine, this ) );
01541 connect ( mCustomFontCheck, SIGNAL( stateChanged( int ) ),
01542 this, SLOT( slotEmitChanged( void ) ) );
01543
01544
01545 hlay = new QHBoxLayout( vlay );
01546 mFontLocationCombo = new QComboBox( false, this );
01547 mFontLocationCombo->setEnabled( false );
01548
01549 QStringList fontDescriptions;
01550 for ( int i = 0 ; i < numFontNames ; i++ )
01551 fontDescriptions << i18n( fontNames[i].displayName );
01552 mFontLocationCombo->insertStringList( fontDescriptions );
01553
01554 label = new QLabel( mFontLocationCombo, i18n("Apply &to:"), this );
01555 label->setEnabled( false );
01556 hlay->addWidget( label );
01557
01558 hlay->addWidget( mFontLocationCombo );
01559 hlay->addStretch( 10 );
01560 vlay->addSpacing( KDialog::spacingHint() );
01561 mFontChooser = new KFontChooser( this, "font", false, QStringList(),
01562 false, 4 );
01563 mFontChooser->setEnabled( false );
01564 vlay->addWidget( mFontChooser );
01565 connect ( mFontChooser, SIGNAL( fontSelected( const QFont& ) ),
01566 this, SLOT( slotEmitChanged( void ) ) );
01567
01568
01569
01570 connect( mCustomFontCheck, SIGNAL(toggled(bool)),
01571 label, SLOT(setEnabled(bool)) );
01572 connect( mCustomFontCheck, SIGNAL(toggled(bool)),
01573 mFontLocationCombo, SLOT(setEnabled(bool)) );
01574 connect( mCustomFontCheck, SIGNAL(toggled(bool)),
01575 mFontChooser, SLOT(setEnabled(bool)) );
01576
01577 connect( mFontLocationCombo, SIGNAL(activated(int) ),
01578 this, SLOT(slotFontSelectorChanged(int)) );
01579 }
01580
01581
01582 void AppearancePage::FontsTab::slotFontSelectorChanged( int index )
01583 {
01584 kdDebug(5006) << "slotFontSelectorChanged() called" << endl;
01585 if( index < 0 || index >= mFontLocationCombo->count() )
01586 return;
01587
01588
01589 if( mActiveFontIndex == 0 ) {
01590 mFont[0] = mFontChooser->font();
01591
01592 for ( int i = 0 ; i < numFontNames ; i++ )
01593 if ( !fontNames[i].enableFamilyAndSize ) {
01594
01595
01596
01597 mFont[i].setFamily( mFont[0].family() );
01598 mFont[i].setPointSize( mFont[0].pointSize() );
01599 }
01600 } else if ( mActiveFontIndex > 0 )
01601 mFont[ mActiveFontIndex ] = mFontChooser->font();
01602 mActiveFontIndex = index;
01603
01604
01605 disconnect ( mFontChooser, SIGNAL( fontSelected( const QFont& ) ),
01606 this, SLOT( slotEmitChanged( void ) ) );
01607
01608
01609 mFontChooser->setFont( mFont[index], fontNames[index].onlyFixed );
01610
01611 connect ( mFontChooser, SIGNAL( fontSelected( const QFont& ) ),
01612 this, SLOT( slotEmitChanged( void ) ) );
01613
01614
01615 mFontChooser->enableColumn( KFontChooser::FamilyList|KFontChooser::SizeList,
01616 fontNames[ index ].enableFamilyAndSize );
01617 }
01618
01619 void AppearancePage::FontsTab::doLoadOther() {
01620 KConfigGroup fonts( KMKernel::config(), "Fonts" );
01621
01622 mFont[0] = KGlobalSettings::generalFont();
01623 QFont fixedFont = KGlobalSettings::fixedFont();
01624 for ( int i = 0 ; i < numFontNames ; i++ )
01625 mFont[i] = fonts.readFontEntry( fontNames[i].configName,
01626 (fontNames[i].onlyFixed) ? &fixedFont : &mFont[0] );
01627
01628 mCustomFontCheck->setChecked( !fonts.readBoolEntry( "defaultFonts", true ) );
01629 mFontLocationCombo->setCurrentItem( 0 );
01630 slotFontSelectorChanged( 0 );
01631 }
01632
01633 void AppearancePage::FontsTab::installProfile( KConfig * profile ) {
01634 KConfigGroup fonts( profile, "Fonts" );
01635
01636
01637 bool needChange = false;
01638 for ( int i = 0 ; i < numFontNames ; i++ )
01639 if ( fonts.hasKey( fontNames[i].configName ) ) {
01640 needChange = true;
01641 mFont[i] = fonts.readFontEntry( fontNames[i].configName );
01642 kdDebug(5006) << "got font \"" << fontNames[i].configName
01643 << "\" thusly: \"" << mFont[i].toString() << "\"" << endl;
01644 }
01645 if ( needChange && mFontLocationCombo->currentItem() > 0 )
01646 mFontChooser->setFont( mFont[ mFontLocationCombo->currentItem() ],
01647 fontNames[ mFontLocationCombo->currentItem() ].onlyFixed );
01648
01649 if ( fonts.hasKey( "defaultFonts" ) )
01650 mCustomFontCheck->setChecked( !fonts.readBoolEntry( "defaultFonts" ) );
01651 }
01652
01653 void AppearancePage::FontsTab::save() {
01654 KConfigGroup fonts( KMKernel::config(), "Fonts" );
01655
01656
01657 if ( mActiveFontIndex >= 0 )
01658 mFont[ mActiveFontIndex ] = mFontChooser->font();
01659
01660 bool customFonts = mCustomFontCheck->isChecked();
01661 fonts.writeEntry( "defaultFonts", !customFonts );
01662 for ( int i = 0 ; i < numFontNames ; i++ )
01663 if ( customFonts || fonts.hasKey( fontNames[i].configName ) )
01664
01665
01666 fonts.writeEntry( fontNames[i].configName, mFont[i] );
01667 }
01668
01669 QString AppearancePage::ColorsTab::helpAnchor() const {
01670 return QString::fromLatin1("configure-appearance-colors");
01671 }
01672
01673
01674 static const struct {
01675 const char * configName;
01676 const char * displayName;
01677 } colorNames[] = {
01678 { "BackgroundColor", I18N_NOOP("Composer Background") },
01679 { "AltBackgroundColor", I18N_NOOP("Alternative Background Color") },
01680 { "ForegroundColor", I18N_NOOP("Normal Text") },
01681 { "QuotedText1", I18N_NOOP("Quoted Text - First Level") },
01682 { "QuotedText2", I18N_NOOP("Quoted Text - Second Level") },
01683 { "QuotedText3", I18N_NOOP("Quoted Text - Third Level") },
01684 { "LinkColor", I18N_NOOP("Link") },
01685 { "FollowedColor", I18N_NOOP("Followed Link") },
01686 { "MisspelledColor", I18N_NOOP("Misspelled Words") },
01687 { "NewMessage", I18N_NOOP("New Message") },
01688 { "UnreadMessage", I18N_NOOP("Unread Message") },
01689 { "FlagMessage", I18N_NOOP("Important Message") },
01690 { "TodoMessage", I18N_NOOP("Todo Message") },
01691 { "PGPMessageEncr", I18N_NOOP("OpenPGP Message - Encrypted") },
01692 { "PGPMessageOkKeyOk", I18N_NOOP("OpenPGP Message - Valid Signature with Trusted Key") },
01693 { "PGPMessageOkKeyBad", I18N_NOOP("OpenPGP Message - Valid Signature with Untrusted Key") },
01694 { "PGPMessageWarn", I18N_NOOP("OpenPGP Message - Unchecked Signature") },
01695 { "PGPMessageErr", I18N_NOOP("OpenPGP Message - Bad Signature") },
01696 { "HTMLWarningColor", I18N_NOOP("Border Around Warning Prepending HTML Messages") },
01697 { "ColorbarBackgroundPlain", I18N_NOOP("HTML Status Bar Background - No HTML Message") },
01698 { "ColorbarForegroundPlain", I18N_NOOP("HTML Status Bar Foreground - No HTML Message") },
01699 { "ColorbarBackgroundHTML", I18N_NOOP("HTML Status Bar Background - HTML Message") },
01700 { "ColorbarForegroundHTML", I18N_NOOP("HTML Status Bar Foreground - HTML Message") },
01701 };
01702 static const int numColorNames = sizeof colorNames / sizeof *colorNames;
01703
01704 AppearancePageColorsTab::AppearancePageColorsTab( QWidget * parent, const char * name )
01705 : ConfigModuleTab( parent, name )
01706 {
01707
01708 QVBoxLayout *vlay;
01709
01710
01711 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
01712 mCustomColorCheck = new QCheckBox( i18n("&Use custom colors"), this );
01713 vlay->addWidget( mCustomColorCheck );
01714 connect( mCustomColorCheck, SIGNAL( stateChanged( int ) ),
01715 this, SLOT( slotEmitChanged( void ) ) );
01716
01717
01718 mColorList = new ColorListBox( this );
01719 mColorList->setEnabled( false );
01720 QStringList modeList;
01721 for ( int i = 0 ; i < numColorNames ; i++ )
01722 mColorList->insertItem( new ColorListItem( i18n( colorNames[i].displayName ) ) );
01723 vlay->addWidget( mColorList, 1 );
01724
01725
01726 mRecycleColorCheck =
01727 new QCheckBox( i18n("Recycle colors on deep "ing"), this );
01728 mRecycleColorCheck->setEnabled( false );
01729 vlay->addWidget( mRecycleColorCheck );
01730 connect( mRecycleColorCheck, SIGNAL( stateChanged( int ) ),
01731 this, SLOT( slotEmitChanged( void ) ) );
01732
01733
01734 connect( mCustomColorCheck, SIGNAL(toggled(bool)),
01735 mColorList, SLOT(setEnabled(bool)) );
01736 connect( mCustomColorCheck, SIGNAL(toggled(bool)),
01737 mRecycleColorCheck, SLOT(setEnabled(bool)) );
01738 connect( mCustomColorCheck, SIGNAL( stateChanged( int ) ),
01739 this, SLOT( slotEmitChanged( void ) ) );
01740 }
01741
01742 void AppearancePage::ColorsTab::doLoadOther() {
01743 KConfigGroup reader( KMKernel::config(), "Reader" );
01744
01745 mCustomColorCheck->setChecked( !reader.readBoolEntry( "defaultColors", true ) );
01746 mRecycleColorCheck->setChecked( reader.readBoolEntry( "RecycleQuoteColors", false ) );
01747
01748 static const QColor defaultColor[ numColorNames ] = {
01749 kapp->palette().active().base(),
01750 KGlobalSettings::alternateBackgroundColor(),
01751 kapp->palette().active().text(),
01752 QColor( 0x00, 0x80, 0x00 ),
01753 QColor( 0x00, 0x70, 0x00 ),
01754 QColor( 0x00, 0x60, 0x00 ),
01755 KGlobalSettings::linkColor(),
01756 KGlobalSettings::visitedLinkColor(),
01757 Qt::red,
01758 Qt::red,
01759 Qt::blue,
01760 QColor( 0x00, 0x7F, 0x00 ),
01761 QColor( 0x00, 0x80, 0xFF ),
01762 QColor( 0x40, 0xFF, 0x40 ),
01763 QColor( 0xFF, 0xFF, 0x40 ),
01764 QColor( 0xFF, 0xFF, 0x40 ),
01765 Qt::red,
01766 QColor( 0xFF, 0x40, 0x40 ),
01767 Qt::lightGray,
01768 Qt::black,
01769 Qt::black,
01770 Qt::white,
01771 };
01772
01773 for ( int i = 0 ; i < numColorNames ; i++ )
01774 mColorList->setColor( i,
01775 reader.readColorEntry( colorNames[i].configName, &defaultColor[i] ) );
01776 connect( mColorList, SIGNAL( changed( ) ),
01777 this, SLOT( slotEmitChanged( void ) ) );
01778 }
01779
01780 void AppearancePage::ColorsTab::installProfile( KConfig * profile ) {
01781 KConfigGroup reader( profile, "Reader" );
01782
01783 if ( reader.hasKey( "defaultColors" ) )
01784 mCustomColorCheck->setChecked( !reader.readBoolEntry( "defaultColors" ) );
01785 if ( reader.hasKey( "RecycleQuoteColors" ) )
01786 mRecycleColorCheck->setChecked( reader.readBoolEntry( "RecycleQuoteColors" ) );
01787
01788 for ( int i = 0 ; i < numColorNames ; i++ )
01789 if ( reader.hasKey( colorNames[i].configName ) )
01790 mColorList->setColor( i, reader.readColorEntry( colorNames[i].configName ) );
01791 }
01792
01793 void AppearancePage::ColorsTab::save() {
01794 KConfigGroup reader( KMKernel::config(), "Reader" );
01795
01796 bool customColors = mCustomColorCheck->isChecked();
01797 reader.writeEntry( "defaultColors", !customColors );
01798
01799 for ( int i = 0 ; i < numColorNames ; i++ )
01800
01801
01802 if ( customColors || reader.hasKey( colorNames[i].configName ) )
01803 reader.writeEntry( colorNames[i].configName, mColorList->color(i) );
01804
01805 reader.writeEntry( "RecycleQuoteColors", mRecycleColorCheck->isChecked() );
01806 }
01807
01808 QString AppearancePage::LayoutTab::helpAnchor() const {
01809 return QString::fromLatin1("configure-appearance-layout");
01810 }
01811
01812 static const EnumConfigEntryItem folderListModes[] = {
01813 { "long", I18N_NOOP("Lon&g folder list") },
01814 { "short", I18N_NOOP("Shor&t folder list" ) }
01815 };
01816 static const EnumConfigEntry folderListMode = {
01817 "Geometry", "FolderList", I18N_NOOP("Folder List"),
01818 folderListModes, DIM(folderListModes), 0
01819 };
01820
01821
01822 static const EnumConfigEntryItem mimeTreeLocations[] = {
01823 { "top", I18N_NOOP("Abo&ve the message pane") },
01824 { "bottom", I18N_NOOP("&Below the message pane") }
01825 };
01826 static const EnumConfigEntry mimeTreeLocation = {
01827 "Reader", "MimeTreeLocation", I18N_NOOP("Message Structure Viewer Placement"),
01828 mimeTreeLocations, DIM(mimeTreeLocations), 1
01829 };
01830
01831 static const EnumConfigEntryItem mimeTreeModes[] = {
01832 { "never", I18N_NOOP("Show &never") },
01833 { "smart", I18N_NOOP("Show only for non-plaintext &messages") },
01834 { "always", I18N_NOOP("Show alway&s") }
01835 };
01836 static const EnumConfigEntry mimeTreeMode = {
01837 "Reader", "MimeTreeMode", I18N_NOOP("Message Structure Viewer"),
01838 mimeTreeModes, DIM(mimeTreeModes), 1
01839 };
01840
01841
01842 static const EnumConfigEntryItem readerWindowModes[] = {
01843 { "hide", I18N_NOOP("&Do not show a message preview pane") },
01844 { "below", I18N_NOOP("Show the message preview pane belo&w the message list") },
01845 { "right", I18N_NOOP("Show the message preview pane ne&xt to the message list") }
01846 };
01847 static const EnumConfigEntry readerWindowMode = {
01848 "Geometry", "readerWindowMode", I18N_NOOP("Message Preview Pane"),
01849 readerWindowModes, DIM(readerWindowModes), 1
01850 };
01851
01852 AppearancePageLayoutTab::AppearancePageLayoutTab( QWidget * parent, const char * name )
01853 : ConfigModuleTab( parent, name )
01854 {
01855
01856 QVBoxLayout * vlay;
01857
01858 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
01859
01860
01861 populateButtonGroup( mFolderListGroup = new QHButtonGroup( this ), folderListMode );
01862 vlay->addWidget( mFolderListGroup );
01863 connect( mFolderListGroup, SIGNAL ( clicked( int ) ),
01864 this, SLOT( slotEmitChanged() ) );
01865
01866
01867 populateButtonGroup( mReaderWindowModeGroup = new QVButtonGroup( this ), readerWindowMode );
01868 vlay->addWidget( mReaderWindowModeGroup );
01869 connect( mReaderWindowModeGroup, SIGNAL ( clicked( int ) ),
01870 this, SLOT( slotEmitChanged() ) );
01871
01872
01873 populateButtonGroup( mMIMETreeModeGroup = new QVButtonGroup( this ), mimeTreeMode );
01874 vlay->addWidget( mMIMETreeModeGroup );
01875 connect( mMIMETreeModeGroup, SIGNAL ( clicked( int ) ),
01876 this, SLOT( slotEmitChanged() ) );
01877
01878
01879 populateButtonGroup( mMIMETreeLocationGroup = new QHButtonGroup( this ), mimeTreeLocation );
01880 vlay->addWidget( mMIMETreeLocationGroup );
01881 connect( mMIMETreeLocationGroup, SIGNAL ( clicked( int ) ),
01882 this, SLOT( slotEmitChanged() ) );
01883
01884 vlay->addStretch( 10 );
01885 }
01886
01887 void AppearancePage::LayoutTab::doLoadOther() {
01888 const KConfigGroup reader( KMKernel::config(), "Reader" );
01889 const KConfigGroup geometry( KMKernel::config(), "Geometry" );
01890
01891 loadWidget( mFolderListGroup, geometry, folderListMode );
01892 loadWidget( mMIMETreeLocationGroup, reader, mimeTreeLocation );
01893 loadWidget( mMIMETreeModeGroup, reader, mimeTreeMode );
01894 loadWidget( mReaderWindowModeGroup, geometry, readerWindowMode );
01895 }
01896
01897 void AppearancePage::LayoutTab::installProfile( KConfig * profile ) {
01898 const KConfigGroup reader( profile, "Reader" );
01899 const KConfigGroup geometry( profile, "Geometry" );
01900
01901 loadProfile( mFolderListGroup, geometry, folderListMode );
01902 loadProfile( mMIMETreeLocationGroup, reader, mimeTreeLocation );
01903 loadProfile( mMIMETreeModeGroup, reader, mimeTreeMode );
01904 loadProfile( mReaderWindowModeGroup, geometry, readerWindowMode );
01905 }
01906
01907 void AppearancePage::LayoutTab::save() {
01908 KConfigGroup reader( KMKernel::config(), "Reader" );
01909 KConfigGroup geometry( KMKernel::config(), "Geometry" );
01910
01911 saveButtonGroup( mFolderListGroup, geometry, folderListMode );
01912 saveButtonGroup( mMIMETreeLocationGroup, reader, mimeTreeLocation );
01913 saveButtonGroup( mMIMETreeModeGroup, reader, mimeTreeMode );
01914 saveButtonGroup( mReaderWindowModeGroup, geometry, readerWindowMode );
01915 }
01916
01917
01918
01919
01920
01921 QString AppearancePage::HeadersTab::helpAnchor() const {
01922 return QString::fromLatin1("configure-appearance-headers");
01923 }
01924
01925 static const struct {
01926 const char * displayName;
01927 DateFormatter::FormatType dateDisplay;
01928 } dateDisplayConfig[] = {
01929 { I18N_NOOP("Sta&ndard format (%1)"), KMime::DateFormatter::CTime },
01930 { I18N_NOOP("Locali&zed format (%1)"), KMime::DateFormatter::Localized },
01931 { I18N_NOOP("Fancy for&mat (%1)"), KMime::DateFormatter::Fancy },
01932 { I18N_NOOP("C&ustom format (Shift+F1 for help):"),
01933 KMime::DateFormatter::Custom }
01934 };
01935 static const int numDateDisplayConfig =
01936 sizeof dateDisplayConfig / sizeof *dateDisplayConfig;
01937
01938 AppearancePageHeadersTab::AppearancePageHeadersTab( QWidget * parent, const char * name )
01939 : ConfigModuleTab( parent, name ),
01940 mCustomDateFormatEdit( 0 )
01941 {
01942
01943 QButtonGroup * group;
01944 QRadioButton * radio;
01945
01946 QVBoxLayout * vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
01947
01948
01949 group = new QVButtonGroup( i18n( "General Options" ), this );
01950 group->layout()->setSpacing( KDialog::spacingHint() );
01951
01952 mMessageSizeCheck = new QCheckBox( i18n("Display messa&ge sizes"), group );
01953
01954 mCryptoIconsCheck = new QCheckBox( i18n( "Show crypto &icons" ), group );
01955
01956 mAttachmentCheck = new QCheckBox( i18n("Show attachment icon"), group );
01957
01958 mNestedMessagesCheck =
01959 new QCheckBox( i18n("&Threaded message list"), group );
01960
01961 connect( mMessageSizeCheck, SIGNAL( stateChanged( int ) ),
01962 this, SLOT( slotEmitChanged( void ) ) );
01963 connect( mAttachmentCheck, SIGNAL( stateChanged( int ) ),
01964 this, SLOT( slotEmitChanged( void ) ) );
01965 connect( mCryptoIconsCheck, SIGNAL( stateChanged( int ) ),
01966 this, SLOT( slotEmitChanged( void ) ) );
01967 connect( mNestedMessagesCheck, SIGNAL( stateChanged( int ) ),
01968 this, SLOT( slotEmitChanged( void ) ) );
01969
01970
01971 vlay->addWidget( group );
01972
01973
01974 mNestingPolicy =
01975 new QVButtonGroup( i18n("Threaded Message List Options"), this );
01976 mNestingPolicy->layout()->setSpacing( KDialog::spacingHint() );
01977
01978 mNestingPolicy->insert(
01979 new QRadioButton( i18n("Always &keep threads open"),
01980 mNestingPolicy ), 0 );
01981 mNestingPolicy->insert(
01982 new QRadioButton( i18n("Threads default to o&pen"),
01983 mNestingPolicy ), 1 );
01984 mNestingPolicy->insert(
01985 new QRadioButton( i18n("Threads default to closed"),
01986 mNestingPolicy ), 2 );
01987 mNestingPolicy->insert(
01988 new QRadioButton( i18n("Open threads that contain ne&w, unread "
01989 "or important messages and open watched threads."),
01990 mNestingPolicy ), 3 );
01991
01992 vlay->addWidget( mNestingPolicy );
01993
01994 connect( mNestingPolicy, SIGNAL( clicked( int ) ),
01995 this, SLOT( slotEmitChanged( void ) ) );
01996
01997
01998 mDateDisplay = new QVButtonGroup( i18n("Date Display"), this );
01999 mDateDisplay->layout()->setSpacing( KDialog::spacingHint() );
02000
02001 for ( int i = 0 ; i < numDateDisplayConfig ; i++ ) {
02002 QString buttonLabel = i18n(dateDisplayConfig[i].displayName);
02003 if ( buttonLabel.contains("%1") )
02004 buttonLabel = buttonLabel.arg( DateFormatter::formatCurrentDate( dateDisplayConfig[i].dateDisplay ) );
02005 radio = new QRadioButton( buttonLabel, mDateDisplay );
02006 mDateDisplay->insert( radio, i );
02007 if ( dateDisplayConfig[i].dateDisplay == DateFormatter::Custom ) {
02008 mCustomDateFormatEdit = new KLineEdit( mDateDisplay );
02009 mCustomDateFormatEdit->setEnabled( false );
02010 connect( radio, SIGNAL(toggled(bool)),
02011 mCustomDateFormatEdit, SLOT(setEnabled(bool)) );
02012 connect( mCustomDateFormatEdit, SIGNAL(textChanged(const QString&)),
02013 this, SLOT(slotEmitChanged(void)) );
02014 QString customDateWhatsThis =
02015 i18n("<qt><p><strong>These expressions may be used for the date:"
02016 "</strong></p>"
02017 "<ul>"
02018 "<li>d - the day as a number without a leading zero (1-31)</li>"
02019 "<li>dd - the day as a number with a leading zero (01-31)</li>"
02020 "<li>ddd - the abbreviated day name (Mon - Sun)</li>"
02021 "<li>dddd - the long day name (Monday - Sunday)</li>"
02022 "<li>M - the month as a number without a leading zero (1-12)</li>"
02023 "<li>MM - the month as a number with a leading zero (01-12)</li>"
02024 "<li>MMM - the abbreviated month name (Jan - Dec)</li>"
02025 "<li>MMMM - the long month name (January - December)</li>"
02026 "<li>yy - the year as a two digit number (00-99)</li>"
02027 "<li>yyyy - the year as a four digit number (0000-9999)</li>"
02028 "</ul>"
02029 "<p><strong>These expressions may be used for the time:"
02030 "</string></p> "
02031 "<ul>"
02032 "<li>h - the hour without a leading zero (0-23 or 1-12 if AM/PM display)</li>"
02033 "<li>hh - the hour with a leading zero (00-23 or 01-12 if AM/PM display)</li>"
02034 "<li>m - the minutes without a leading zero (0-59)</li>"
02035 "<li>mm - the minutes with a leading zero (00-59)</li>"
02036 "<li>s - the seconds without a leading zero (0-59)</li>"
02037 "<li>ss - the seconds with a leading zero (00-59)</li>"
02038 "<li>z - the milliseconds without leading zeroes (0-999)</li>"
02039 "<li>zzz - the milliseconds with leading zeroes (000-999)</li>"
02040 "<li>AP - switch to AM/PM display. AP will be replaced by either \"AM\" or \"PM\".</li>"
02041 "<li>ap - switch to AM/PM display. ap will be replaced by either \"am\" or \"pm\".</li>"
02042 "<li>Z - time zone in numeric form (-0500)</li>"
02043 "</ul>"
02044 "<p><strong>All other input characters will be ignored."
02045 "</strong></p></qt>");
02046 QWhatsThis::add( mCustomDateFormatEdit, customDateWhatsThis );
02047 QWhatsThis::add( radio, customDateWhatsThis );
02048 }
02049 }
02050
02051 vlay->addWidget( mDateDisplay );
02052 connect( mDateDisplay, SIGNAL( clicked( int ) ),
02053 this, SLOT( slotEmitChanged( void ) ) );
02054
02055
02056 vlay->addStretch( 10 );
02057 }
02058
02059 void AppearancePage::HeadersTab::doLoadOther() {
02060 KConfigGroup general( KMKernel::config(), "General" );
02061 KConfigGroup geometry( KMKernel::config(), "Geometry" );
02062
02063
02064 mNestedMessagesCheck->setChecked( geometry.readBoolEntry( "nestedMessages", false ) );
02065 mMessageSizeCheck->setChecked( general.readBoolEntry( "showMessageSize", false ) );
02066 mCryptoIconsCheck->setChecked( general.readBoolEntry( "showCryptoIcons", false ) );
02067 mAttachmentCheck->setChecked( general.readBoolEntry( "showAttachmentIcon", true ) );
02068
02069
02070 int num = geometry.readNumEntry( "nestingPolicy", 3 );
02071 if ( num < 0 || num > 3 ) num = 3;
02072 mNestingPolicy->setButton( num );
02073
02074
02075 setDateDisplay( general.readNumEntry( "dateFormat", DateFormatter::Fancy ),
02076 general.readEntry( "customDateFormat" ) );
02077 }
02078
02079 void AppearancePage::HeadersTab::setDateDisplay( int num, const QString & format ) {
02080 DateFormatter::FormatType dateDisplay =
02081 static_cast<DateFormatter::FormatType>( num );
02082
02083
02084 if ( dateDisplay == DateFormatter::Custom )
02085 mCustomDateFormatEdit->setText( format );
02086
02087 for ( int i = 0 ; i < numDateDisplayConfig ; i++ )
02088 if ( dateDisplay == dateDisplayConfig[i].dateDisplay ) {
02089 mDateDisplay->setButton( i );
02090 return;
02091 }
02092
02093 mDateDisplay->setButton( numDateDisplayConfig - 2 );
02094 }
02095
02096 void AppearancePage::HeadersTab::installProfile( KConfig * profile ) {
02097 KConfigGroup general( profile, "General" );
02098 KConfigGroup geometry( profile, "Geometry" );
02099
02100 if ( geometry.hasKey( "nestedMessages" ) )
02101 mNestedMessagesCheck->setChecked( geometry.readBoolEntry( "nestedMessages" ) );
02102 if ( general.hasKey( "showMessageSize" ) )
02103 mMessageSizeCheck->setChecked( general.readBoolEntry( "showMessageSize" ) );
02104
02105 if( general.hasKey( "showCryptoIcons" ) )
02106 mCryptoIconsCheck->setChecked( general.readBoolEntry( "showCryptoIcons" ) );
02107 if ( general.hasKey( "showAttachmentIcon" ) )
02108 mAttachmentCheck->setChecked( general.readBoolEntry( "showAttachmentIcon" ) );
02109
02110 if ( geometry.hasKey( "nestingPolicy" ) ) {
02111 int num = geometry.readNumEntry( "nestingPolicy" );
02112 if ( num < 0 || num > 3 ) num = 3;
02113 mNestingPolicy->setButton( num );
02114 }
02115
02116 if ( general.hasKey( "dateFormat" ) )
02117 setDateDisplay( general.readNumEntry( "dateFormat" ),
02118 general.readEntry( "customDateFormat" ) );
02119 }
02120
02121 void AppearancePage::HeadersTab::save() {
02122 KConfigGroup general( KMKernel::config(), "General" );
02123 KConfigGroup geometry( KMKernel::config(), "Geometry" );
02124
02125 if ( geometry.readBoolEntry( "nestedMessages", false )
02126 != mNestedMessagesCheck->isChecked() ) {
02127 int result = KMessageBox::warningContinueCancel( this,
02128 i18n("Changing the global threading setting will override "
02129 "all folder specific values."),
02130 QString::null, KStdGuiItem::cont(), "threadOverride" );
02131 if ( result == KMessageBox::Continue ) {
02132 geometry.writeEntry( "nestedMessages", mNestedMessagesCheck->isChecked() );
02133
02134 QStringList groups = KMKernel::config()->groupList().grep( QRegExp("^Folder-") );
02135 kdDebug(5006) << "groups.count() == " << groups.count() << endl;
02136 for ( QStringList::const_iterator it = groups.begin() ; it != groups.end() ; ++it ) {
02137 KConfigGroup group( KMKernel::config(), *it );
02138 group.deleteEntry( "threadMessagesOverride" );
02139 }
02140 }
02141 }
02142
02143 geometry.writeEntry( "nestingPolicy",
02144 mNestingPolicy->id( mNestingPolicy->selected() ) );
02145 general.writeEntry( "showMessageSize", mMessageSizeCheck->isChecked() );
02146 general.writeEntry( "showCryptoIcons", mCryptoIconsCheck->isChecked() );
02147 general.writeEntry( "showAttachmentIcon", mAttachmentCheck->isChecked() );
02148
02149 int dateDisplayID = mDateDisplay->id( mDateDisplay->selected() );
02150
02151 assert( dateDisplayID >= 0 ); assert( dateDisplayID < numDateDisplayConfig );
02152 general.writeEntry( "dateFormat",
02153 dateDisplayConfig[ dateDisplayID ].dateDisplay );
02154 general.writeEntry( "customDateFormat", mCustomDateFormatEdit->text() );
02155 }
02156
02157
02158
02159
02160
02161
02162
02163 static const BoolConfigEntry showColorbarMode = {
02164 "Reader", "showColorbar", I18N_NOOP("Show HTML stat&us bar"), false
02165 };
02166
02167 static const BoolConfigEntry showSpamStatusMode = {
02168 "Reader", "showSpamStatus", I18N_NOOP("Show s&pam status in fancy headers"), true
02169 };
02170
02171 static const BoolConfigEntry showEmoticons = {
02172 "Reader", "ShowEmoticons", I18N_NOOP("Replace smileys by emoticons"), true
02173 };
02174
02175 static const BoolConfigEntry shrinkQuotes = {
02176 "Reader", "ShrinkQuotes", I18N_NOOP("Use smaller font for quoted text"), false
02177 };
02178
02179 static const BoolConfigEntry showExpandQuotesMark= {
02180 "Reader", "ShowExpandQuotesMark", I18N_NOOP("Show expand/collapse quote marks"), false
02181 };
02182
02183
02184 QString AppearancePage::ReaderTab::helpAnchor() const {
02185 return QString::fromLatin1("configure-appearance-reader");
02186 }
02187
02188 AppearancePageReaderTab::AppearancePageReaderTab( QWidget * parent,
02189 const char * name )
02190 : ConfigModuleTab( parent, name )
02191 {
02192 QVBoxLayout *vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
02193
02194
02195 populateCheckBox( mShowColorbarCheck = new QCheckBox( this ), showColorbarMode );
02196 vlay->addWidget( mShowColorbarCheck );
02197 connect( mShowColorbarCheck, SIGNAL ( stateChanged( int ) ),
02198 this, SLOT( slotEmitChanged() ) );
02199
02200
02201 populateCheckBox( mShowSpamStatusCheck = new QCheckBox( this ), showSpamStatusMode );
02202 vlay->addWidget( mShowSpamStatusCheck );
02203 connect( mShowSpamStatusCheck, SIGNAL ( stateChanged( int ) ),
02204 this, SLOT( slotEmitChanged() ) );
02205
02206
02207 populateCheckBox( mShowEmoticonsCheck = new QCheckBox( this ), showEmoticons );
02208 vlay->addWidget( mShowEmoticonsCheck );
02209 connect( mShowEmoticonsCheck, SIGNAL ( stateChanged( int ) ),
02210 this, SLOT( slotEmitChanged() ) );
02211
02212
02213 mShrinkQuotesCheck = new QCheckBox( i18n( shrinkQuotes.desc ), this,
02214 "kcfg_ShrinkQuotes" );
02215 vlay->addWidget( mShrinkQuotesCheck );
02216 connect( mShrinkQuotesCheck, SIGNAL( stateChanged( int ) ),
02217 this, SLOT( slotEmitChanged() ) );
02218
02219
02220 QHBoxLayout *hlay= new QHBoxLayout( vlay );
02221 populateCheckBox( mShowExpandQuotesMark= new QCheckBox( this ), showExpandQuotesMark);
02222 hlay->addWidget( mShowExpandQuotesMark);
02223 connect( mShowExpandQuotesMark, SIGNAL ( stateChanged( int ) ),
02224 this, SLOT( slotEmitChanged() ) );
02225
02226 hlay->addStretch( 1 );
02227 mCollapseQuoteLevelSpin = new KIntSpinBox( 0,10,1,
02228 3,10,this );
02229
02230 QLabel *label = new QLabel( mCollapseQuoteLevelSpin,
02231 GlobalSettings::self()->collapseQuoteLevelSpinItem()->label(), this );
02232
02233 hlay->addWidget( label );
02234
02235 mCollapseQuoteLevelSpin->setEnabled( false );
02236 connect( mCollapseQuoteLevelSpin, SIGNAL( valueChanged( int ) ),
02237 this, SLOT( slotEmitChanged( void ) ) );
02238 hlay->addWidget( mCollapseQuoteLevelSpin);
02239
02240 connect( mShowExpandQuotesMark, SIGNAL( toggled( bool ) ),
02241 mCollapseQuoteLevelSpin, SLOT( setEnabled( bool ) ) );
02242
02243
02244 hlay = new QHBoxLayout( vlay );
02245 mCharsetCombo = new QComboBox( this );
02246 mCharsetCombo->insertStringList( KMMsgBase::supportedEncodings( false ) );
02247
02248 connect( mCharsetCombo, SIGNAL( activated( int ) ),
02249 this, SLOT( slotEmitChanged( void ) ) );
02250
02251 QString fallbackCharsetWhatsThis =
02252 i18n( GlobalSettings::self()->fallbackCharacterEncodingItem()->whatsThis().utf8() );
02253 QWhatsThis::add( mCharsetCombo, fallbackCharsetWhatsThis );
02254
02255 label = new QLabel( i18n("Fallback ch&aracter encoding:"), this );
02256 label->setBuddy( mCharsetCombo );
02257
02258 hlay->addWidget( label );
02259 hlay->addWidget( mCharsetCombo );
02260
02261
02262 QHBoxLayout *hlay2 = new QHBoxLayout( vlay );
02263 mOverrideCharsetCombo = new QComboBox( this );
02264 QStringList encodings = KMMsgBase::supportedEncodings( false );
02265 encodings.prepend( i18n( "Auto" ) );
02266 mOverrideCharsetCombo->insertStringList( encodings );
02267 mOverrideCharsetCombo->setCurrentItem(0);
02268
02269 connect( mOverrideCharsetCombo, SIGNAL( activated( int ) ),
02270 this, SLOT( slotEmitChanged( void ) ) );
02271
02272 QString overrideCharsetWhatsThis =
02273 i18n( GlobalSettings::self()->overrideCharacterEncodingItem()->whatsThis().utf8() );
02274 QWhatsThis::add( mOverrideCharsetCombo, overrideCharsetWhatsThis );
02275
02276 label = new QLabel( i18n("&Override character encoding:"), this );
02277 label->setBuddy( mOverrideCharsetCombo );
02278
02279 hlay2->addWidget( label );
02280 hlay2->addWidget( mOverrideCharsetCombo );
02281
02282 vlay->addStretch( 100 );
02283 }
02284
02285
02286 void AppearancePage::ReaderTab::readCurrentFallbackCodec()
02287 {
02288 QStringList encodings = KMMsgBase::supportedEncodings( false );
02289 QStringList::ConstIterator it( encodings.begin() );
02290 QStringList::ConstIterator end( encodings.end() );
02291 QString currentEncoding = GlobalSettings::self()->fallbackCharacterEncoding();
02292 currentEncoding = currentEncoding.replace( "iso ", "iso-", false );
02294 int i = 0;
02295 int indexOfLatin9 = 0;
02296 bool found = false;
02297 for( ; it != end; ++it)
02298 {
02299 const QString encoding = KGlobal::charsets()->encodingForName(*it);
02300 if ( encoding == "iso-8859-15" )
02301 indexOfLatin9 = i;
02302 if( encoding == currentEncoding )
02303 {
02304 mCharsetCombo->setCurrentItem( i );
02305 found = true;
02306 break;
02307 }
02308 i++;
02309 }
02310 if ( !found )
02311 mCharsetCombo->setCurrentItem( indexOfLatin9 );
02312 }
02313
02314 void AppearancePage::ReaderTab::readCurrentOverrideCodec()
02315 {
02316 const QString ¤tOverrideEncoding = GlobalSettings::self()->overrideCharacterEncoding();
02317 if ( currentOverrideEncoding.isEmpty() ) {
02318 mOverrideCharsetCombo->setCurrentItem( 0 );
02319 return;
02320 }
02321 QStringList encodings = KMMsgBase::supportedEncodings( false );
02322 encodings.prepend( i18n( "Auto" ) );
02323 QStringList::Iterator it( encodings.begin() );
02324 QStringList::Iterator end( encodings.end() );
02325 uint i = 0;
02326 for( ; it != end; ++it)
02327 {
02328 if( KGlobal::charsets()->encodingForName(*it) == currentOverrideEncoding )
02329 {
02330 mOverrideCharsetCombo->setCurrentItem( i );
02331 break;
02332 }
02333 i++;
02334 }
02335 if ( i == encodings.size() ) {
02336
02337 kdWarning(5006) << "Unknown override character encoding \"" << currentOverrideEncoding
02338 << "\". Resetting to Auto." << endl;
02339 mOverrideCharsetCombo->setCurrentItem( 0 );
02340 GlobalSettings::self()->setOverrideCharacterEncoding( QString::null );
02341 }
02342 }
02343
02344 void AppearancePage::ReaderTab::doLoadFromGlobalSettings()
02345 {
02346 mShowEmoticonsCheck->setChecked( GlobalSettings::self()->showEmoticons() );
02347 mShrinkQuotesCheck->setChecked( GlobalSettings::self()->shrinkQuotes() );
02348 mShowExpandQuotesMark->setChecked( GlobalSettings::self()->showExpandQuotesMark() );
02349 mCollapseQuoteLevelSpin->setValue( GlobalSettings::self()->collapseQuoteLevelSpin() );
02350 readCurrentFallbackCodec();
02351 readCurrentOverrideCodec();
02352 }
02353
02354 void AppearancePage::ReaderTab::doLoadOther()
02355 {
02356 const KConfigGroup reader( KMKernel::config(), "Reader" );
02357 loadWidget( mShowColorbarCheck, reader, showColorbarMode );
02358 loadWidget( mShowSpamStatusCheck, reader, showSpamStatusMode );
02359 }
02360
02361
02362 void AppearancePage::ReaderTab::save() {
02363 KConfigGroup reader( KMKernel::config(), "Reader" );
02364 saveCheckBox( mShowColorbarCheck, reader, showColorbarMode );
02365 saveCheckBox( mShowSpamStatusCheck, reader, showSpamStatusMode );
02366 GlobalSettings::self()->setShowEmoticons( mShowEmoticonsCheck->isChecked() );
02367 GlobalSettings::self()->setShrinkQuotes( mShrinkQuotesCheck->isChecked() );
02368 GlobalSettings::self()->setShowExpandQuotesMark( mShowExpandQuotesMark->isChecked() );
02369
02370 GlobalSettings::self()->setCollapseQuoteLevelSpin( mCollapseQuoteLevelSpin->value() );
02371 GlobalSettings::self()->setFallbackCharacterEncoding(
02372 KGlobal::charsets()->encodingForName( mCharsetCombo->currentText() ) );
02373 GlobalSettings::self()->setOverrideCharacterEncoding(
02374 mOverrideCharsetCombo->currentItem() == 0 ?
02375 QString() :
02376 KGlobal::charsets()->encodingForName( mOverrideCharsetCombo->currentText() ) );
02377 }
02378
02379
02380 void AppearancePage::ReaderTab::installProfile( KConfig * ) {
02381 const KConfigGroup reader( KMKernel::config(), "Reader" );
02382 loadProfile( mShowColorbarCheck, reader, showColorbarMode );
02383 loadProfile( mShowSpamStatusCheck, reader, showSpamStatusMode );
02384 loadProfile( mShowEmoticonsCheck, reader, showEmoticons );
02385 loadProfile( mShrinkQuotesCheck, reader, shrinkQuotes );
02386 loadProfile( mShowExpandQuotesMark, reader, showExpandQuotesMark);
02387 }
02388
02389
02390 QString AppearancePage::SystemTrayTab::helpAnchor() const {
02391 return QString::fromLatin1("configure-appearance-systemtray");
02392 }
02393
02394 AppearancePageSystemTrayTab::AppearancePageSystemTrayTab( QWidget * parent,
02395 const char * name )
02396 : ConfigModuleTab( parent, name )
02397 {
02398 QVBoxLayout * vlay = new QVBoxLayout( this, KDialog::marginHint(),
02399 KDialog::spacingHint() );
02400
02401
02402 mSystemTrayCheck = new QCheckBox( i18n("Enable system tray icon"), this );
02403 vlay->addWidget( mSystemTrayCheck );
02404 connect( mSystemTrayCheck, SIGNAL( stateChanged( int ) ),
02405 this, SLOT( slotEmitChanged( void ) ) );
02406
02407
02408 mSystemTrayGroup = new QVButtonGroup( i18n("System Tray Mode"), this );
02409 mSystemTrayGroup->layout()->setSpacing( KDialog::spacingHint() );
02410 vlay->addWidget( mSystemTrayGroup );
02411 connect( mSystemTrayGroup, SIGNAL( clicked( int ) ),
02412 this, SLOT( slotEmitChanged( void ) ) );
02413 connect( mSystemTrayCheck, SIGNAL( toggled( bool ) ),
02414 mSystemTrayGroup, SLOT( setEnabled( bool ) ) );
02415
02416 mSystemTrayGroup->insert( new QRadioButton( i18n("Always show KMail in system tray"), mSystemTrayGroup ),
02417 GlobalSettings::EnumSystemTrayPolicy::ShowAlways );
02418
02419 mSystemTrayGroup->insert( new QRadioButton( i18n("Only show KMail in system tray if there are unread messages"), mSystemTrayGroup ),
02420 GlobalSettings::EnumSystemTrayPolicy::ShowOnUnread );
02421
02422 vlay->addStretch( 10 );
02423 }
02424
02425 void AppearancePage::SystemTrayTab::doLoadFromGlobalSettings() {
02426 mSystemTrayCheck->setChecked( GlobalSettings::self()->systemTrayEnabled() );
02427 mSystemTrayGroup->setButton( GlobalSettings::self()->systemTrayPolicy() );
02428 mSystemTrayGroup->setEnabled( mSystemTrayCheck->isChecked() );
02429 }
02430
02431 void AppearancePage::SystemTrayTab::installProfile( KConfig * profile ) {
02432 KConfigGroup general( profile, "General" );
02433
02434 if ( general.hasKey( "SystemTrayEnabled" ) ) {
02435 mSystemTrayCheck->setChecked( general.readBoolEntry( "SystemTrayEnabled" ) );
02436 }
02437 if ( general.hasKey( "SystemTrayPolicy" ) ) {
02438 mSystemTrayGroup->setButton( general.readNumEntry( "SystemTrayPolicy" ) );
02439 }
02440 mSystemTrayGroup->setEnabled( mSystemTrayCheck->isChecked() );
02441 }
02442
02443 void AppearancePage::SystemTrayTab::save() {
02444 GlobalSettings::self()->setSystemTrayEnabled( mSystemTrayCheck->isChecked() );
02445 GlobalSettings::self()->setSystemTrayPolicy( mSystemTrayGroup->id( mSystemTrayGroup->selected() ) );
02446 }
02447
02448
02449
02450
02451
02452
02453
02454
02455 QString ComposerPage::helpAnchor() const {
02456 return QString::fromLatin1("configure-composer");
02457 }
02458
02459 ComposerPage::ComposerPage( QWidget * parent, const char * name )
02460 : ConfigModuleWithTabs( parent, name )
02461 {
02462
02463
02464
02465 mGeneralTab = new GeneralTab();
02466 addTab( mGeneralTab, i18n("&General") );
02467 addConfig( GlobalSettings::self(), mGeneralTab );
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478 mTemplatesTab = new TemplatesTab();
02479 addTab( mTemplatesTab, i18n("&Templates") );
02480
02481
02482
02483
02484 mCustomTemplatesTab = new CustomTemplatesTab();
02485 addTab( mCustomTemplatesTab, i18n("&Custom Templates") );
02486
02487
02488
02489
02490 mSubjectTab = new SubjectTab();
02491 addTab( mSubjectTab, i18n("&Subject") );
02492 addConfig( GlobalSettings::self(), mSubjectTab );
02493
02494
02495
02496
02497 mCharsetTab = new CharsetTab();
02498 addTab( mCharsetTab, i18n("Cha&rset") );
02499
02500
02501
02502
02503 mHeadersTab = new HeadersTab();
02504 addTab( mHeadersTab, i18n("H&eaders") );
02505
02506
02507
02508
02509 mAttachmentsTab = new AttachmentsTab();
02510 addTab( mAttachmentsTab, i18n("Config->Composer->Attachments", "A&ttachments") );
02511 load();
02512 }
02513
02514 QString ComposerPage::GeneralTab::helpAnchor() const {
02515 return QString::fromLatin1("configure-composer-general");
02516 }
02517
02518 ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent, const char * name )
02519 : ConfigModuleTab( parent, name )
02520 {
02521
02522 QVBoxLayout *vlay;
02523 QHBoxLayout *hlay;
02524 QGroupBox *group;
02525 QLabel *label;
02526 QHBox *hbox;
02527 QString msg;
02528
02529 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
02530
02531
02532 mAutoAppSignFileCheck = new QCheckBox(
02533 GlobalSettings::self()->autoTextSignatureItem()->label(),
02534 this );
02535 vlay->addWidget( mAutoAppSignFileCheck );
02536 connect( mAutoAppSignFileCheck, SIGNAL( stateChanged(int) ),
02537 this, SLOT( slotEmitChanged( void ) ) );
02538
02539 mSmartQuoteCheck = new QCheckBox(
02540 GlobalSettings::self()->smartQuoteItem()->label(),
02541 this, "kcfg_SmartQuote" );
02542 vlay->addWidget( mSmartQuoteCheck );
02543 connect( mSmartQuoteCheck, SIGNAL( stateChanged(int) ),
02544 this, SLOT( slotEmitChanged( void ) ) );
02545
02546 mAutoRequestMDNCheck = new QCheckBox(
02547 GlobalSettings::self()->requestMDNItem()->label(),
02548 this, "kcfg_RequestMDN" );
02549 vlay->addWidget( mAutoRequestMDNCheck );
02550 connect( mAutoRequestMDNCheck, SIGNAL( stateChanged(int) ),
02551 this, SLOT( slotEmitChanged( void ) ) );
02552
02553 mShowRecentAddressesInComposer = new QCheckBox(
02554 GlobalSettings::self()->showRecentAddressesInComposerItem()->label(),
02555 this, "kcfg_ShowRecentAddressesInComposer" );
02556 vlay->addWidget( mShowRecentAddressesInComposer );
02557 connect( mShowRecentAddressesInComposer, SIGNAL( stateChanged(int) ),
02558 this, SLOT( slotEmitChanged( void ) ) );
02559
02560
02561
02562 hlay = new QHBoxLayout( vlay );
02563 mWordWrapCheck = new QCheckBox(
02564 GlobalSettings::self()->wordWrapItem()->label(),
02565 this, "kcfg_WordWrap" );
02566 hlay->addWidget( mWordWrapCheck );
02567 connect( mWordWrapCheck, SIGNAL( stateChanged(int) ),
02568 this, SLOT( slotEmitChanged( void ) ) );
02569
02570 mWrapColumnSpin = new KIntSpinBox( 30, 78, 1,
02571 78, 10 , this, "kcfg_LineWrapWidth" );
02572 mWrapColumnSpin->setEnabled( false );
02573 connect( mWrapColumnSpin, SIGNAL( valueChanged(int) ),
02574 this, SLOT( slotEmitChanged( void ) ) );
02575
02576 hlay->addWidget( mWrapColumnSpin );
02577 hlay->addStretch( 1 );
02578
02579 connect( mWordWrapCheck, SIGNAL(toggled(bool)),
02580 mWrapColumnSpin, SLOT(setEnabled(bool)) );
02581
02582 hlay = new QHBoxLayout( vlay );
02583 mAutoSave = new KIntSpinBox( 0, 60, 1, 1, 10, this, "kcfg_AutosaveInterval" );
02584 label = new QLabel( mAutoSave,
02585 GlobalSettings::self()->autosaveIntervalItem()->label(), this );
02586 hlay->addWidget( label );
02587 hlay->addWidget( mAutoSave );
02588 mAutoSave->setSpecialValueText( i18n("No autosave") );
02589 mAutoSave->setSuffix( i18n(" min") );
02590 hlay->addStretch( 1 );
02591 connect( mAutoSave, SIGNAL( valueChanged(int) ),
02592 this, SLOT( slotEmitChanged( void ) ) );
02593
02594 hlay = new QHBoxLayout( vlay );
02595 QPushButton *completionOrderBtn = new QPushButton( i18n( "Configure Completion Order" ), this );
02596 connect( completionOrderBtn, SIGNAL( clicked() ),
02597 this, SLOT( slotConfigureCompletionOrder() ) );
02598 hlay->addWidget( completionOrderBtn );
02599 hlay->addItem( new QSpacerItem(0, 0) );
02600
02601
02602 hlay = new QHBoxLayout( vlay );
02603 QPushButton *recentAddressesBtn = new QPushButton( i18n( "Edit Recent Addresses" ), this );
02604 connect( recentAddressesBtn, SIGNAL( clicked() ),
02605 this, SLOT( slotConfigureRecentAddresses() ) );
02606 hlay->addWidget( recentAddressesBtn );
02607 hlay->addItem( new QSpacerItem(0, 0) );
02608
02609
02610 group = new QVGroupBox( i18n("External Editor"), this );
02611 group->layout()->setSpacing( KDialog::spacingHint() );
02612
02613 mExternalEditorCheck = new QCheckBox(
02614 GlobalSettings::self()->useExternalEditorItem()->label(),
02615 group, "kcfg_UseExternalEditor" );
02616 connect( mExternalEditorCheck, SIGNAL( toggled( bool ) ),
02617 this, SLOT( slotEmitChanged( void ) ) );
02618
02619 hbox = new QHBox( group );
02620 label = new QLabel( GlobalSettings::self()->externalEditorItem()->label(),
02621 hbox );
02622 mEditorRequester = new KURLRequester( hbox, "kcfg_ExternalEditor" );
02623 connect( mEditorRequester, SIGNAL( urlSelected(const QString&) ),
02624 this, SLOT( slotEmitChanged( void ) ) );
02625 connect( mEditorRequester, SIGNAL( textChanged(const QString&) ),
02626 this, SLOT( slotEmitChanged( void ) ) );
02627
02628 hbox->setStretchFactor( mEditorRequester, 1 );
02629 label->setBuddy( mEditorRequester );
02630 label->setEnabled( false );
02631
02632 mEditorRequester->setFilter( "application/x-executable "
02633 "application/x-shellscript "
02634 "application/x-desktop" );
02635 mEditorRequester->setEnabled( false );
02636 connect( mExternalEditorCheck, SIGNAL(toggled(bool)),
02637 label, SLOT(setEnabled(bool)) );
02638 connect( mExternalEditorCheck, SIGNAL(toggled(bool)),
02639 mEditorRequester, SLOT(setEnabled(bool)) );
02640
02641 label = new QLabel( i18n("<b>%f</b> will be replaced with the "
02642 "filename to edit."), group );
02643 label->setEnabled( false );
02644 connect( mExternalEditorCheck, SIGNAL(toggled(bool)),
02645 label, SLOT(setEnabled(bool)) );
02646
02647 vlay->addWidget( group );
02648 vlay->addStretch( 100 );
02649 }
02650
02651 void ComposerPage::GeneralTab::doLoadFromGlobalSettings() {
02652
02653
02654 mAutoAppSignFileCheck->setChecked(
02655 GlobalSettings::self()->autoTextSignature()=="auto" );
02656 mSmartQuoteCheck->setChecked( GlobalSettings::self()->smartQuote() );
02657 mAutoRequestMDNCheck->setChecked( GlobalSettings::self()->requestMDN() );
02658 mWordWrapCheck->setChecked( GlobalSettings::self()->wordWrap() );
02659
02660 mWrapColumnSpin->setValue( GlobalSettings::self()->lineWrapWidth() );
02661 mAutoSave->setValue( GlobalSettings::self()->autosaveInterval() );
02662
02663
02664 mExternalEditorCheck->setChecked( GlobalSettings::self()->useExternalEditor() );
02665 mEditorRequester->setURL( GlobalSettings::self()->externalEditor() );
02666 }
02667
02668 void ComposerPage::GeneralTab::installProfile( KConfig * profile ) {
02669 KConfigGroup composer( profile, "Composer" );
02670 KConfigGroup general( profile, "General" );
02671
02672 if ( composer.hasKey( "signature" ) ) {
02673 bool state = composer.readBoolEntry("signature");
02674 mAutoAppSignFileCheck->setChecked( state );
02675 }
02676 if ( composer.hasKey( "smart-quote" ) )
02677 mSmartQuoteCheck->setChecked( composer.readBoolEntry( "smart-quote" ) );
02678 if ( composer.hasKey( "request-mdn" ) )
02679 mAutoRequestMDNCheck->setChecked( composer.readBoolEntry( "request-mdn" ) );
02680 if ( composer.hasKey( "word-wrap" ) )
02681 mWordWrapCheck->setChecked( composer.readBoolEntry( "word-wrap" ) );
02682 if ( composer.hasKey( "break-at" ) )
02683 mWrapColumnSpin->setValue( composer.readNumEntry( "break-at" ) );
02684 if ( composer.hasKey( "autosave" ) )
02685 mAutoSave->setValue( composer.readNumEntry( "autosave" ) );
02686
02687 if ( general.hasKey( "use-external-editor" )
02688 && general.hasKey( "external-editor" ) ) {
02689 mExternalEditorCheck->setChecked( general.readBoolEntry( "use-external-editor" ) );
02690 mEditorRequester->setURL( general.readPathEntry( "external-editor" ) );
02691 }
02692 }
02693
02694 void ComposerPage::GeneralTab::save() {
02695 GlobalSettings::self()->setAutoTextSignature(
02696 mAutoAppSignFileCheck->isChecked() ? "auto" : "manual" );
02697 GlobalSettings::self()->setSmartQuote( mSmartQuoteCheck->isChecked() );
02698 GlobalSettings::self()->setRequestMDN( mAutoRequestMDNCheck->isChecked() );
02699 GlobalSettings::self()->setWordWrap( mWordWrapCheck->isChecked() );
02700
02701 GlobalSettings::self()->setLineWrapWidth( mWrapColumnSpin->value() );
02702 GlobalSettings::self()->setAutosaveInterval( mAutoSave->value() );
02703
02704
02705 GlobalSettings::self()->setUseExternalEditor( mExternalEditorCheck->isChecked() );
02706 GlobalSettings::self()->setExternalEditor( mEditorRequester->url() );
02707 }
02708
02709 void ComposerPage::GeneralTab::slotConfigureRecentAddresses( )
02710 {
02711 KRecentAddress::RecentAddressDialog dlg( this );
02712 dlg.setAddresses( RecentAddresses::self( KMKernel::config() )->addresses() );
02713 if ( dlg.exec() ) {
02714 RecentAddresses::self( KMKernel::config() )->clear();
02715 const QStringList &addrList = dlg.addresses();
02716 QStringList::ConstIterator it;
02717 for ( it = addrList.constBegin(); it != addrList.constEnd(); ++it )
02718 RecentAddresses::self( KMKernel::config() )->add( *it );
02719 }
02720 }
02721
02722 void ComposerPage::GeneralTab::slotConfigureCompletionOrder( )
02723 {
02724 KPIM::LdapSearch search;
02725 KPIM::CompletionOrderEditor editor( &search, this );
02726 editor.exec();
02727 }
02728
02729 QString ComposerPage::PhrasesTab::helpAnchor() const {
02730 return QString::fromLatin1("configure-composer-phrases");
02731 }
02732
02733 ComposerPagePhrasesTab::ComposerPagePhrasesTab( QWidget * parent, const char * name )
02734 : ConfigModuleTab( parent, name )
02735 {
02736
02737 QGridLayout *glay;
02738 QPushButton *button;
02739
02740 glay = new QGridLayout( this, 7, 3, KDialog::spacingHint() );
02741 glay->setMargin( KDialog::marginHint() );
02742 glay->setColStretch( 1, 1 );
02743 glay->setColStretch( 2, 1 );
02744 glay->setRowStretch( 7, 1 );
02745
02746
02747 glay->addMultiCellWidget( new QLabel( i18n("<qt>The following placeholders are "
02748 "supported in the reply phrases:<br>"
02749 "<b>%D</b>: date, <b>%S</b>: subject,<br>"
02750 "<b>%e</b>: sender's address, <b>%F</b>: sender's name, <b>%f</b>: sender's initials,<br>"
02751 "<b>%T</b>: recipient's name, <b>%t</b>: recipient's name and address,<br>"
02752 "<b>%C</b>: carbon copy names, <b>%c</b>: carbon copy names and addresses,<br>"
02753 "<b>%%</b>: percent sign, <b>%_</b>: space, "
02754 "<b>%L</b>: linebreak</qt>"), this ),
02755 0, 0, 0, 2 );
02756
02757
02758 mPhraseLanguageCombo = new LanguageComboBox( false, this );
02759 glay->addWidget( new QLabel( mPhraseLanguageCombo,
02760 i18n("Lang&uage:"), this ), 1, 0 );
02761 glay->addMultiCellWidget( mPhraseLanguageCombo, 1, 1, 1, 2 );
02762 connect( mPhraseLanguageCombo, SIGNAL(activated(const QString&)),
02763 this, SLOT(slotLanguageChanged(const QString&)) );
02764
02765
02766 button = new QPushButton( i18n("A&dd..."), this );
02767 button->setAutoDefault( false );
02768 glay->addWidget( button, 2, 1 );
02769 mRemoveButton = new QPushButton( i18n("Re&move"), this );
02770 mRemoveButton->setAutoDefault( false );
02771 mRemoveButton->setEnabled( false );
02772 glay->addWidget( mRemoveButton, 2, 2 );
02773 connect( button, SIGNAL(clicked()),
02774 this, SLOT(slotNewLanguage()) );
02775 connect( mRemoveButton, SIGNAL(clicked()),
02776 this, SLOT(slotRemoveLanguage()) );
02777
02778
02779 mPhraseReplyEdit = new KLineEdit( this );
02780 connect( mPhraseReplyEdit, SIGNAL( textChanged( const QString& ) ),
02781 this, SLOT( slotEmitChanged( void ) ) );
02782 glay->addWidget( new QLabel( mPhraseReplyEdit,
02783 i18n("Reply to se&nder:"), this ), 3, 0 );
02784 glay->addMultiCellWidget( mPhraseReplyEdit, 3, 3, 1, 2 );
02785
02786
02787 mPhraseReplyAllEdit = new KLineEdit( this );
02788 connect( mPhraseReplyAllEdit, SIGNAL( textChanged( const QString& ) ),
02789 this, SLOT( slotEmitChanged( void ) ) );
02790 glay->addWidget( new QLabel( mPhraseReplyAllEdit,
02791 i18n("Repl&y to all:"), this ), 4, 0 );
02792 glay->addMultiCellWidget( mPhraseReplyAllEdit, 4, 4, 1, 2 );
02793
02794
02795 mPhraseForwardEdit = new KLineEdit( this );
02796 connect( mPhraseForwardEdit, SIGNAL( textChanged( const QString& ) ),
02797 this, SLOT( slotEmitChanged( void ) ) );
02798 glay->addWidget( new QLabel( mPhraseForwardEdit,
02799 i18n("&Forward:"), this ), 5, 0 );
02800 glay->addMultiCellWidget( mPhraseForwardEdit, 5, 5, 1, 2 );
02801
02802
02803 mPhraseIndentPrefixEdit = new KLineEdit( this );
02804 connect( mPhraseIndentPrefixEdit, SIGNAL( textChanged( const QString& ) ),
02805 this, SLOT( slotEmitChanged( void ) ) );
02806 glay->addWidget( new QLabel( mPhraseIndentPrefixEdit,
02807 i18n("&Quote indicator:"), this ), 6, 0 );
02808 glay->addMultiCellWidget( mPhraseIndentPrefixEdit, 6, 6, 1, 2 );
02809
02810
02811 }
02812
02813
02814 void ComposerPage::PhrasesTab::setLanguageItemInformation( int index ) {
02815 assert( 0 <= index && index < (int)mLanguageList.count() );
02816
02817 LanguageItem &l = *mLanguageList.at( index );
02818
02819 mPhraseReplyEdit->setText( l.mReply );
02820 mPhraseReplyAllEdit->setText( l.mReplyAll );
02821 mPhraseForwardEdit->setText( l.mForward );
02822 mPhraseIndentPrefixEdit->setText( l.mIndentPrefix );
02823 }
02824
02825 void ComposerPage::PhrasesTab::saveActiveLanguageItem() {
02826 int index = mActiveLanguageItem;
02827 if (index == -1) return;
02828 assert( 0 <= index && index < (int)mLanguageList.count() );
02829
02830 LanguageItem &l = *mLanguageList.at( index );
02831
02832 l.mReply = mPhraseReplyEdit->text();
02833 l.mReplyAll = mPhraseReplyAllEdit->text();
02834 l.mForward = mPhraseForwardEdit->text();
02835 l.mIndentPrefix = mPhraseIndentPrefixEdit->text();
02836 }
02837
02838 void ComposerPage::PhrasesTab::slotNewLanguage()
02839 {
02840 NewLanguageDialog dialog( mLanguageList, parentWidget(), "New", true );
02841 if ( dialog.exec() == QDialog::Accepted ) slotAddNewLanguage( dialog.language() );
02842 }
02843
02844 void ComposerPage::PhrasesTab::slotAddNewLanguage( const QString& lang )
02845 {
02846 mPhraseLanguageCombo->setCurrentItem(
02847 mPhraseLanguageCombo->insertLanguage( lang ) );
02848 KLocale locale("kmail");
02849 locale.setLanguage( lang );
02850 mLanguageList.append(
02851 LanguageItem( lang,
02852 locale.translate("On %D, you wrote:"),
02853 locale.translate("On %D, %F wrote:"),
02854 locale.translate("Forwarded Message"),
02855 locale.translate(">%_") ) );
02856 mRemoveButton->setEnabled( true );
02857 slotLanguageChanged( QString::null );
02858 }
02859
02860 void ComposerPage::PhrasesTab::slotRemoveLanguage()
02861 {
02862 assert( mPhraseLanguageCombo->count() > 1 );
02863 int index = mPhraseLanguageCombo->currentItem();
02864 assert( 0 <= index && index < (int)mLanguageList.count() );
02865
02866
02867 mLanguageList.remove( mLanguageList.at( index ) );
02868 mPhraseLanguageCombo->removeItem( index );
02869
02870 if ( index >= (int)mLanguageList.count() ) index--;
02871
02872 mActiveLanguageItem = index;
02873 setLanguageItemInformation( index );
02874 mRemoveButton->setEnabled( mLanguageList.count() > 1 );
02875 emit changed( true );
02876 }
02877
02878 void ComposerPage::PhrasesTab::slotLanguageChanged( const QString& )
02879 {
02880 int index = mPhraseLanguageCombo->currentItem();
02881 assert( index < (int)mLanguageList.count() );
02882 saveActiveLanguageItem();
02883 mActiveLanguageItem = index;
02884 setLanguageItemInformation( index );
02885 emit changed( true );
02886 }
02887
02888
02889 void ComposerPage::PhrasesTab::doLoadFromGlobalSettings() {
02890 mLanguageList.clear();
02891 mPhraseLanguageCombo->clear();
02892 mActiveLanguageItem = -1;
02893
02894 int numLang = GlobalSettings::self()->replyLanguagesCount();
02895 int currentNr = GlobalSettings::self()->replyCurrentLanguage();
02896
02897
02898 for ( int i = 0 ; i < numLang ; i++ ) {
02899 ReplyPhrases replyPhrases( QString::number(i) );
02900 replyPhrases.readConfig();
02901 QString lang = replyPhrases.language();
02902 mLanguageList.append(
02903 LanguageItem( lang,
02904 replyPhrases.phraseReplySender(),
02905 replyPhrases.phraseReplyAll(),
02906 replyPhrases.phraseForward(),
02907 replyPhrases.indentPrefix() ) );
02908 mPhraseLanguageCombo->insertLanguage( lang );
02909 }
02910
02911 if ( currentNr >= numLang || currentNr < 0 )
02912 currentNr = 0;
02913
02914 if ( numLang == 0 ) {
02915 slotAddNewLanguage( KGlobal::locale()->language() );
02916 }
02917
02918 mPhraseLanguageCombo->setCurrentItem( currentNr );
02919 mActiveLanguageItem = currentNr;
02920 setLanguageItemInformation( currentNr );
02921 mRemoveButton->setEnabled( mLanguageList.count() > 1 );
02922 }
02923
02924 void ComposerPage::PhrasesTab::save() {
02925 GlobalSettings::self()->setReplyLanguagesCount( mLanguageList.count() );
02926 GlobalSettings::self()->setReplyCurrentLanguage( mPhraseLanguageCombo->currentItem() );
02927
02928 saveActiveLanguageItem();
02929 LanguageItemList::Iterator it = mLanguageList.begin();
02930 for ( int i = 0 ; it != mLanguageList.end() ; ++it, ++i ) {
02931 ReplyPhrases replyPhrases( QString::number(i) );
02932 replyPhrases.setLanguage( (*it).mLanguage );
02933 replyPhrases.setPhraseReplySender( (*it).mReply );
02934 replyPhrases.setPhraseReplyAll( (*it).mReplyAll );
02935 replyPhrases.setPhraseForward( (*it).mForward );
02936 replyPhrases.setIndentPrefix( (*it).mIndentPrefix );
02937 replyPhrases.writeConfig();
02938 }
02939 }
02940
02941 QString ComposerPage::TemplatesTab::helpAnchor() const {
02942 return QString::fromLatin1("configure-composer-templates");
02943 }
02944
02945 ComposerPageTemplatesTab::ComposerPageTemplatesTab( QWidget * parent, const char * name )
02946 : ConfigModuleTab ( parent, name )
02947 {
02948 QVBoxLayout* vlay = new QVBoxLayout( this, 0, KDialog::spacingHint() );
02949
02950 mWidget = new TemplatesConfiguration( this );
02951 vlay->addWidget( mWidget );
02952
02953 connect( mWidget, SIGNAL( changed() ),
02954 this, SLOT( slotEmitChanged( void ) ) );
02955 }
02956
02957 void ComposerPage::TemplatesTab::doLoadFromGlobalSettings() {
02958 mWidget->loadFromGlobal();
02959 }
02960
02961 void ComposerPage::TemplatesTab::save() {
02962 mWidget->saveToGlobal();
02963 }
02964
02965 QString ComposerPage::CustomTemplatesTab::helpAnchor() const {
02966 return QString::fromLatin1("configure-composer-custom-templates");
02967 }
02968
02969 ComposerPageCustomTemplatesTab::ComposerPageCustomTemplatesTab( QWidget * parent, const char * name )
02970 : ConfigModuleTab ( parent, name )
02971 {
02972 QVBoxLayout* vlay = new QVBoxLayout( this, 0, KDialog::spacingHint() );
02973
02974 mWidget = new CustomTemplates( this );
02975 vlay->addWidget( mWidget );
02976
02977 connect( mWidget, SIGNAL( changed() ),
02978 this, SLOT( slotEmitChanged( void ) ) );
02979 }
02980
02981 void ComposerPage::CustomTemplatesTab::doLoadFromGlobalSettings() {
02982 mWidget->load();
02983 }
02984
02985 void ComposerPage::CustomTemplatesTab::save() {
02986 mWidget->save();
02987 }
02988
02989 QString ComposerPage::SubjectTab::helpAnchor() const {
02990 return QString::fromLatin1("configure-composer-subject");
02991 }
02992
02993 ComposerPageSubjectTab::ComposerPageSubjectTab( QWidget * parent, const char * name )
02994 : ConfigModuleTab( parent, name )
02995 {
02996
02997 QVBoxLayout *vlay;
02998 QGroupBox *group;
02999 QLabel *label;
03000
03001
03002 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
03003
03004 group = new QVGroupBox( i18n("Repl&y Subject Prefixes"), this );
03005 group->layout()->setSpacing( KDialog::spacingHint() );
03006
03007
03008 label = new QLabel( i18n("Recognize any sequence of the following prefixes\n"
03009 "(entries are case-insensitive regular expressions):"), group );
03010 label->setAlignment( AlignLeft|WordBreak );
03011
03012
03013 SimpleStringListEditor::ButtonCode buttonCode =
03014 static_cast<SimpleStringListEditor::ButtonCode>( SimpleStringListEditor::Add | SimpleStringListEditor::Remove | SimpleStringListEditor::Modify );
03015 mReplyListEditor =
03016 new SimpleStringListEditor( group, 0, buttonCode,
03017 i18n("A&dd..."), i18n("Re&move"),
03018 i18n("Mod&ify..."),
03019 i18n("Enter new reply prefix:") );
03020 connect( mReplyListEditor, SIGNAL( changed( void ) ),
03021 this, SLOT( slotEmitChanged( void ) ) );
03022
03023
03024 mReplaceReplyPrefixCheck = new QCheckBox(
03025 GlobalSettings::self()->replaceReplyPrefixItem()->label(),
03026 group, "kcfg_ReplaceReplyPrefix" );
03027 connect( mReplaceReplyPrefixCheck, SIGNAL( stateChanged( int ) ),
03028 this, SLOT( slotEmitChanged( void ) ) );
03029
03030 vlay->addWidget( group );
03031
03032
03033 group = new QVGroupBox( i18n("For&ward Subject Prefixes"), this );
03034 group->layout()->setSpacing( KDialog::marginHint() );
03035
03036
03037 label= new QLabel( i18n("Recognize any sequence of the following prefixes\n"
03038 "(entries are case-insensitive regular expressions):"), group );
03039 label->setAlignment( AlignLeft|WordBreak );
03040
03041
03042 mForwardListEditor =
03043 new SimpleStringListEditor( group, 0, buttonCode,
03044 i18n("Add..."),
03045 i18n("Remo&ve"),
03046 i18n("Modify..."),
03047 i18n("Enter new forward prefix:") );
03048 connect( mForwardListEditor, SIGNAL( changed( void ) ),
03049 this, SLOT( slotEmitChanged( void ) ) );
03050
03051
03052 mReplaceForwardPrefixCheck = new QCheckBox(
03053 GlobalSettings::self()->replaceForwardPrefixItem()->label(),
03054 group, "kcfg_ReplaceForwardPrefix" );
03055 connect( mReplaceForwardPrefixCheck, SIGNAL( stateChanged( int ) ),
03056 this, SLOT( slotEmitChanged( void ) ) );
03057
03058 vlay->addWidget( group );
03059 }
03060
03061 void ComposerPage::SubjectTab::doLoadFromGlobalSettings() {
03062 mReplyListEditor->setStringList( GlobalSettings::self()->replyPrefixes() );
03063 mReplaceReplyPrefixCheck->setChecked( GlobalSettings::self()->replaceReplyPrefix() );
03064 mForwardListEditor->setStringList( GlobalSettings::self()->forwardPrefixes() );
03065 mReplaceForwardPrefixCheck->setChecked( GlobalSettings::self()->replaceForwardPrefix() );
03066 }
03067
03068 void ComposerPage::SubjectTab::save() {
03069 GlobalSettings::self()->setReplyPrefixes( mReplyListEditor->stringList() );
03070 GlobalSettings::self()->setForwardPrefixes( mForwardListEditor->stringList() );
03071 }
03072
03073 QString ComposerPage::CharsetTab::helpAnchor() const {
03074 return QString::fromLatin1("configure-composer-charset");
03075 }
03076
03077 ComposerPageCharsetTab::ComposerPageCharsetTab( QWidget * parent, const char * name )
03078 : ConfigModuleTab( parent, name )
03079 {
03080
03081 QVBoxLayout *vlay;
03082 QLabel *label;
03083
03084 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
03085
03086 label = new QLabel( i18n("This list is checked for every outgoing message "
03087 "from the top to the bottom for a charset that "
03088 "contains all required characters."), this );
03089 label->setAlignment( WordBreak);
03090 vlay->addWidget( label );
03091
03092 mCharsetListEditor =
03093 new SimpleStringListEditor( this, 0, SimpleStringListEditor::All,
03094 i18n("A&dd..."), i18n("Remo&ve"),
03095 i18n("&Modify..."), i18n("Enter charset:") );
03096 connect( mCharsetListEditor, SIGNAL( changed( void ) ),
03097 this, SLOT( slotEmitChanged( void ) ) );
03098
03099 vlay->addWidget( mCharsetListEditor, 1 );
03100
03101 mKeepReplyCharsetCheck = new QCheckBox( i18n("&Keep original charset when "
03102 "replying or forwarding (if "
03103 "possible)"), this );
03104 connect( mKeepReplyCharsetCheck, SIGNAL ( stateChanged( int ) ),
03105 this, SLOT( slotEmitChanged( void ) ) );
03106 vlay->addWidget( mKeepReplyCharsetCheck );
03107
03108 connect( mCharsetListEditor, SIGNAL(aboutToAdd(QString&)),
03109 this, SLOT(slotVerifyCharset(QString&)) );
03110 }
03111
03112 void ComposerPage::CharsetTab::slotVerifyCharset( QString & charset ) {
03113 if ( charset.isEmpty() ) return;
03114
03115
03116
03117 if ( charset.lower() == QString::fromLatin1("us-ascii") ) {
03118 charset = QString::fromLatin1("us-ascii");
03119 return;
03120 }
03121
03122 if ( charset.lower() == QString::fromLatin1("locale") ) {
03123 charset = QString::fromLatin1("%1 (locale)")
03124 .arg( QCString( kmkernel->networkCodec()->mimeName() ).lower() );
03125 return;
03126 }
03127
03128 bool ok = false;
03129 QTextCodec *codec = KGlobal::charsets()->codecForName( charset, ok );
03130 if ( ok && codec ) {
03131 charset = QString::fromLatin1( codec->mimeName() ).lower();
03132 return;
03133 }
03134
03135 KMessageBox::sorry( this, i18n("This charset is not supported.") );
03136 charset = QString::null;
03137 }
03138
03139 void ComposerPage::CharsetTab::doLoadOther() {
03140 KConfigGroup composer( KMKernel::config(), "Composer" );
03141
03142 QStringList charsets = composer.readListEntry( "pref-charsets" );
03143 for ( QStringList::Iterator it = charsets.begin() ;
03144 it != charsets.end() ; ++it )
03145 if ( (*it) == QString::fromLatin1("locale") ) {
03146 QCString cset = kmkernel->networkCodec()->mimeName();
03147 KPIM::kAsciiToLower( cset.data() );
03148 (*it) = QString("%1 (locale)").arg( cset );
03149 }
03150
03151 mCharsetListEditor->setStringList( charsets );
03152 mKeepReplyCharsetCheck->setChecked( !composer.readBoolEntry( "force-reply-charset", false ) );
03153 }
03154
03155 void ComposerPage::CharsetTab::save() {
03156 KConfigGroup composer( KMKernel::config(), "Composer" );
03157
03158 QStringList charsetList = mCharsetListEditor->stringList();
03159 QStringList::Iterator it = charsetList.begin();
03160 for ( ; it != charsetList.end() ; ++it )
03161 if ( (*it).endsWith("(locale)") )
03162 (*it) = "locale";
03163 composer.writeEntry( "pref-charsets", charsetList );
03164 composer.writeEntry( "force-reply-charset",
03165 !mKeepReplyCharsetCheck->isChecked() );
03166 }
03167
03168 QString ComposerPage::HeadersTab::helpAnchor() const {
03169 return QString::fromLatin1("configure-composer-headers");
03170 }
03171
03172 ComposerPageHeadersTab::ComposerPageHeadersTab( QWidget * parent, const char * name )
03173 : ConfigModuleTab( parent, name )
03174 {
03175
03176 QVBoxLayout *vlay;
03177 QHBoxLayout *hlay;
03178 QGridLayout *glay;
03179 QLabel *label;
03180 QPushButton *button;
03181
03182 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
03183
03184
03185 mCreateOwnMessageIdCheck =
03186 new QCheckBox( i18n("&Use custom message-id suffix"), this );
03187 connect( mCreateOwnMessageIdCheck, SIGNAL ( stateChanged( int ) ),
03188 this, SLOT( slotEmitChanged( void ) ) );
03189 vlay->addWidget( mCreateOwnMessageIdCheck );
03190
03191
03192 hlay = new QHBoxLayout( vlay );
03193 mMessageIdSuffixEdit = new KLineEdit( this );
03194
03195 mMessageIdSuffixValidator =
03196 new QRegExpValidator( QRegExp( "[a-zA-Z0-9+-]+(?:\\.[a-zA-Z0-9+-]+)*" ), this );
03197 mMessageIdSuffixEdit->setValidator( mMessageIdSuffixValidator );
03198 label = new QLabel( mMessageIdSuffixEdit,
03199 i18n("Custom message-&id suffix:"), this );
03200 label->setEnabled( false );
03201 mMessageIdSuffixEdit->setEnabled( false );
03202 hlay->addWidget( label );
03203 hlay->addWidget( mMessageIdSuffixEdit, 1 );
03204 connect( mCreateOwnMessageIdCheck, SIGNAL(toggled(bool) ),
03205 label, SLOT(setEnabled(bool)) );
03206 connect( mCreateOwnMessageIdCheck, SIGNAL(toggled(bool) ),
03207 mMessageIdSuffixEdit, SLOT(setEnabled(bool)) );
03208 connect( mMessageIdSuffixEdit, SIGNAL( textChanged( const QString& ) ),
03209 this, SLOT( slotEmitChanged( void ) ) );
03210
03211
03212 vlay->addWidget( new KSeparator( KSeparator::HLine, this ) );
03213 vlay->addWidget( new QLabel( i18n("Define custom mime header fields:"), this) );
03214
03215
03216 glay = new QGridLayout( vlay, 5, 3 );
03217 glay->setRowStretch( 2, 1 );
03218 glay->setColStretch( 1, 1 );
03219 mTagList = new ListView( this, "tagList" );
03220 mTagList->addColumn( i18n("Name") );
03221 mTagList->addColumn( i18n("Value") );
03222 mTagList->setAllColumnsShowFocus( true );
03223 mTagList->setSorting( -1 );
03224 connect( mTagList, SIGNAL(selectionChanged()),
03225 this, SLOT(slotMimeHeaderSelectionChanged()) );
03226 glay->addMultiCellWidget( mTagList, 0, 2, 0, 1 );
03227
03228
03229 button = new QPushButton( i18n("Ne&w"), this );
03230 connect( button, SIGNAL(clicked()), this, SLOT(slotNewMimeHeader()) );
03231 button->setAutoDefault( false );
03232 glay->addWidget( button, 0, 2 );
03233 mRemoveHeaderButton = new QPushButton( i18n("Re&move"), this );
03234 connect( mRemoveHeaderButton, SIGNAL(clicked()),
03235 this, SLOT(slotRemoveMimeHeader()) );
03236 button->setAutoDefault( false );
03237 glay->addWidget( mRemoveHeaderButton, 1, 2 );
03238
03239
03240 mTagNameEdit = new KLineEdit( this );
03241 mTagNameEdit->setEnabled( false );
03242 mTagNameLabel = new QLabel( mTagNameEdit, i18n("&Name:"), this );
03243 mTagNameLabel->setEnabled( false );
03244 glay->addWidget( mTagNameLabel, 3, 0 );
03245 glay->addWidget( mTagNameEdit, 3, 1 );
03246 connect( mTagNameEdit, SIGNAL(textChanged(const QString&)),
03247 this, SLOT(slotMimeHeaderNameChanged(const QString&)) );
03248
03249 mTagValueEdit = new KLineEdit( this );
03250 mTagValueEdit->setEnabled( false );
03251 mTagValueLabel = new QLabel( mTagValueEdit, i18n("&Value:"), this );
03252 mTagValueLabel->setEnabled( false );
03253 glay->addWidget( mTagValueLabel, 4, 0 );
03254 glay->addWidget( mTagValueEdit, 4, 1 );
03255 connect( mTagValueEdit, SIGNAL(textChanged(const QString&)),
03256 this, SLOT(slotMimeHeaderValueChanged(const QString&)) );
03257 }
03258
03259 void ComposerPage::HeadersTab::slotMimeHeaderSelectionChanged()
03260 {
03261 QListViewItem * item = mTagList->selectedItem();
03262
03263 if ( item ) {
03264 mTagNameEdit->setText( item->text( 0 ) );
03265 mTagValueEdit->setText( item->text( 1 ) );
03266 } else {
03267 mTagNameEdit->clear();
03268 mTagValueEdit->clear();
03269 }
03270 mRemoveHeaderButton->setEnabled( item );
03271 mTagNameEdit->setEnabled( item );
03272 mTagValueEdit->setEnabled( item );
03273 mTagNameLabel->setEnabled( item );
03274 mTagValueLabel->setEnabled( item );
03275 }
03276
03277
03278 void ComposerPage::HeadersTab::slotMimeHeaderNameChanged( const QString & text ) {
03279
03280
03281 QListViewItem * item = mTagList->selectedItem();
03282 if ( item )
03283 item->setText( 0, text );
03284 emit changed( true );
03285 }
03286
03287
03288 void ComposerPage::HeadersTab::slotMimeHeaderValueChanged( const QString & text ) {
03289
03290
03291 QListViewItem * item = mTagList->selectedItem();
03292 if ( item )
03293 item->setText( 1, text );
03294 emit changed( true );
03295 }
03296
03297
03298 void ComposerPage::HeadersTab::slotNewMimeHeader()
03299 {
03300 QListViewItem *listItem = new QListViewItem( mTagList );
03301 mTagList->setCurrentItem( listItem );
03302 mTagList->setSelected( listItem, true );
03303 emit changed( true );
03304 }
03305
03306
03307 void ComposerPage::HeadersTab::slotRemoveMimeHeader()
03308 {
03309
03310 QListViewItem * item = mTagList->selectedItem();
03311 if ( !item ) {
03312 kdDebug(5006) << "==================================================\n"
03313 << "Error: Remove button was pressed although no custom header was selected\n"
03314 << "==================================================\n";
03315 return;
03316 }
03317
03318 QListViewItem * below = item->nextSibling();
03319 delete item;
03320
03321 if ( below )
03322 mTagList->setSelected( below, true );
03323 else if ( mTagList->lastItem() )
03324 mTagList->setSelected( mTagList->lastItem(), true );
03325 emit changed( true );
03326 }
03327
03328 void ComposerPage::HeadersTab::doLoadOther() {
03329 KConfigGroup general( KMKernel::config(), "General" );
03330
03331 QString suffix = general.readEntry( "myMessageIdSuffix" );
03332 mMessageIdSuffixEdit->setText( suffix );
03333 bool state = ( !suffix.isEmpty() &&
03334 general.readBoolEntry( "useCustomMessageIdSuffix", false ) );
03335 mCreateOwnMessageIdCheck->setChecked( state );
03336
03337 mTagList->clear();
03338 mTagNameEdit->clear();
03339 mTagValueEdit->clear();
03340
03341 QListViewItem * item = 0;
03342
03343 int count = general.readNumEntry( "mime-header-count", 0 );
03344 for( int i = 0 ; i < count ; i++ ) {
03345 KConfigGroup config( KMKernel::config(),
03346 QCString("Mime #") + QCString().setNum(i) );
03347 QString name = config.readEntry( "name" );
03348 QString value = config.readEntry( "value" );
03349 if( !name.isEmpty() )
03350 item = new QListViewItem( mTagList, item, name, value );
03351 }
03352 if ( mTagList->childCount() ) {
03353 mTagList->setCurrentItem( mTagList->firstChild() );
03354 mTagList->setSelected( mTagList->firstChild(), true );
03355 }
03356 else {
03357
03358 mRemoveHeaderButton->setEnabled( false );
03359 }
03360 }
03361
03362 void ComposerPage::HeadersTab::save() {
03363 KConfigGroup general( KMKernel::config(), "General" );
03364
03365 general.writeEntry( "useCustomMessageIdSuffix",
03366 mCreateOwnMessageIdCheck->isChecked() );
03367 general.writeEntry( "myMessageIdSuffix",
03368 mMessageIdSuffixEdit->text() );
03369
03370 int numValidEntries = 0;
03371 QListViewItem * item = mTagList->firstChild();
03372 for ( ; item ; item = item->itemBelow() )
03373 if( !item->text(0).isEmpty() ) {
03374 KConfigGroup config( KMKernel::config(), QCString("Mime #")
03375 + QCString().setNum( numValidEntries ) );
03376 config.writeEntry( "name", item->text( 0 ) );
03377 config.writeEntry( "value", item->text( 1 ) );
03378 numValidEntries++;
03379 }
03380 general.writeEntry( "mime-header-count", numValidEntries );
03381 }
03382
03383 QString ComposerPage::AttachmentsTab::helpAnchor() const {
03384 return QString::fromLatin1("configure-composer-attachments");
03385 }
03386
03387 ComposerPageAttachmentsTab::ComposerPageAttachmentsTab( QWidget * parent,
03388 const char * name )
03389 : ConfigModuleTab( parent, name ) {
03390
03391 QVBoxLayout *vlay;
03392 QLabel *label;
03393
03394 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
03395
03396
03397 mOutlookCompatibleCheck =
03398 new QCheckBox( i18n( "Outlook-compatible attachment naming" ), this );
03399 mOutlookCompatibleCheck->setChecked( false );
03400 QToolTip::add( mOutlookCompatibleCheck, i18n(
03401 "Turn this option on to make Outlook(tm) understand attachment names "
03402 "containing non-English characters" ) );
03403 connect( mOutlookCompatibleCheck, SIGNAL( stateChanged( int ) ),
03404 this, SLOT( slotEmitChanged( void ) ) );
03405 connect( mOutlookCompatibleCheck, SIGNAL( clicked() ),
03406 this, SLOT( slotOutlookCompatibleClicked() ) );
03407 vlay->addWidget( mOutlookCompatibleCheck );
03408 vlay->addSpacing( 5 );
03409
03410
03411 mMissingAttachmentDetectionCheck =
03412 new QCheckBox( i18n("E&nable detection of missing attachments"), this );
03413 mMissingAttachmentDetectionCheck->setChecked( true );
03414 connect( mMissingAttachmentDetectionCheck, SIGNAL( stateChanged( int ) ),
03415 this, SLOT( slotEmitChanged( void ) ) );
03416 vlay->addWidget( mMissingAttachmentDetectionCheck );
03417
03418
03419 label = new QLabel( i18n("Recognize any of the following key words as "
03420 "intention to attach a file:"), this );
03421 label->setAlignment( AlignLeft|WordBreak );
03422 vlay->addWidget( label );
03423
03424 SimpleStringListEditor::ButtonCode buttonCode =
03425 static_cast<SimpleStringListEditor::ButtonCode>( SimpleStringListEditor::Add | SimpleStringListEditor::Remove | SimpleStringListEditor::Modify );
03426 mAttachWordsListEditor =
03427 new SimpleStringListEditor( this, 0, buttonCode,
03428 i18n("A&dd..."), i18n("Re&move"),
03429 i18n("Mod&ify..."),
03430 i18n("Enter new key word:") );
03431 connect( mAttachWordsListEditor, SIGNAL( changed( void ) ),
03432 this, SLOT( slotEmitChanged( void ) ) );
03433 vlay->addWidget( mAttachWordsListEditor );
03434
03435 connect( mMissingAttachmentDetectionCheck, SIGNAL(toggled(bool) ),
03436 label, SLOT(setEnabled(bool)) );
03437 connect( mMissingAttachmentDetectionCheck, SIGNAL(toggled(bool) ),
03438 mAttachWordsListEditor, SLOT(setEnabled(bool)) );
03439 }
03440
03441 void ComposerPage::AttachmentsTab::doLoadFromGlobalSettings() {
03442 mOutlookCompatibleCheck->setChecked(
03443 GlobalSettings::self()->outlookCompatibleAttachments() );
03444 mMissingAttachmentDetectionCheck->setChecked(
03445 GlobalSettings::self()->showForgottenAttachmentWarning() );
03446 QStringList attachWordsList = GlobalSettings::self()->attachmentKeywords();
03447 if ( attachWordsList.isEmpty() ) {
03448
03449 attachWordsList << QString::fromLatin1("attachment")
03450 << QString::fromLatin1("attached");
03451 if ( QString::fromLatin1("attachment") != i18n("attachment") )
03452 attachWordsList << i18n("attachment");
03453 if ( QString::fromLatin1("attached") != i18n("attached") )
03454 attachWordsList << i18n("attached");
03455 }
03456
03457 mAttachWordsListEditor->setStringList( attachWordsList );
03458 }
03459
03460 void ComposerPage::AttachmentsTab::save() {
03461 GlobalSettings::self()->setOutlookCompatibleAttachments(
03462 mOutlookCompatibleCheck->isChecked() );
03463 GlobalSettings::self()->setShowForgottenAttachmentWarning(
03464 mMissingAttachmentDetectionCheck->isChecked() );
03465 GlobalSettings::self()->setAttachmentKeywords(
03466 mAttachWordsListEditor->stringList() );
03467 }
03468
03469 void ComposerPageAttachmentsTab::slotOutlookCompatibleClicked()
03470 {
03471 if (mOutlookCompatibleCheck->isChecked()) {
03472 KMessageBox::information(0,i18n("You have chosen to "
03473 "encode attachment names containing non-English characters in a way that "
03474 "is understood by Outlook(tm) and other mail clients that do not "
03475 "support standard-compliant encoded attachment names.\n"
03476 "Note that KMail may create non-standard compliant messages, "
03477 "and consequently it is possible that your messages will not be "
03478 "understood by standard-compliant mail clients; so, unless you have no "
03479 "other choice, you should not enable this option." ) );
03480 }
03481 }
03482
03483
03484
03485
03486
03487
03488 QString SecurityPage::helpAnchor() const {
03489 return QString::fromLatin1("configure-security");
03490 }
03491
03492 SecurityPage::SecurityPage( QWidget * parent, const char * name )
03493 : ConfigModuleWithTabs( parent, name )
03494 {
03495
03496
03497
03498 mGeneralTab = new GeneralTab();
03499 addTab( mGeneralTab, i18n("&Reading") );
03500
03501
03502
03503
03504 mComposerCryptoTab = new ComposerCryptoTab();
03505 addTab( mComposerCryptoTab, i18n("Composing") );
03506
03507
03508
03509
03510 mWarningTab = new WarningTab();
03511 addTab( mWarningTab, i18n("Warnings") );
03512
03513
03514
03515
03516 mSMimeTab = new SMimeTab();
03517 addTab( mSMimeTab, i18n("S/MIME &Validation") );
03518
03519
03520
03521
03522 mCryptPlugTab = new CryptPlugTab();
03523 addTab( mCryptPlugTab, i18n("Crypto Backe&nds") );
03524 load();
03525 }
03526
03527
03528 void SecurityPage::installProfile( KConfig * profile ) {
03529 mGeneralTab->installProfile( profile );
03530 mComposerCryptoTab->installProfile( profile );
03531 mWarningTab->installProfile( profile );
03532 mSMimeTab->installProfile( profile );
03533 }
03534
03535 QString SecurityPage::GeneralTab::helpAnchor() const {
03536 return QString::fromLatin1("configure-security-reading");
03537 }
03538
03539 SecurityPageGeneralTab::SecurityPageGeneralTab( QWidget * parent, const char * name )
03540 : ConfigModuleTab ( parent, name )
03541 {
03542
03543 QVBoxLayout *vlay;
03544 QHBox *hbox;
03545 QGroupBox *group;
03546 QRadioButton *radio;
03547 KActiveLabel *label;
03548 QWidget *w;
03549 QString msg;
03550
03551 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
03552
03553
03554 QString htmlWhatsThis = i18n( "<qt><p>Messages sometimes come in both formats. "
03555 "This option controls whether you want the HTML part or the plain "
03556 "text part to be displayed.</p>"
03557 "<p>Displaying the HTML part makes the message look better, "
03558 "but at the same time increases the risk of security holes "
03559 "being exploited.</p>"
03560 "<p>Displaying the plain text part loses much of the message's "
03561 "formatting, but makes it almost <em>impossible</em> "
03562 "to exploit security holes in the HTML renderer (Konqueror).</p>"
03563 "<p>The option below guards against one common misuse of HTML "
03564 "messages, but it cannot guard against security issues that were "
03565 "not known at the time this version of KMail was written.</p>"
03566 "<p>It is therefore advisable to <em>not</em> prefer HTML to "
03567 "plain text.</p>"
03568 "<p><b>Note:</b> You can set this option on a per-folder basis "
03569 "from the <i>Folder</i> menu of KMail's main window.</p></qt>" );
03570
03571 QString externalWhatsThis = i18n( "<qt><p>Some mail advertisements are in HTML "
03572 "and contain references to, for example, images that the advertisers"
03573 " employ to find out that you have read their message "
03574 "("web bugs").</p>"
03575 "<p>There is no valid reason to load images off the Internet like "
03576 "this, since the sender can always attach the required images "
03577 "directly to the message.</p>"
03578 "<p>To guard from such a misuse of the HTML displaying feature "
03579 "of KMail, this option is <em>disabled</em> by default.</p>"
03580 "<p>However, if you wish to, for example, view images in HTML "
03581 "messages that were not attached to it, you can enable this "
03582 "option, but you should be aware of the possible problem.</p></qt>" );
03583
03584 QString receiptWhatsThis = i18n( "<qt><h3>Message Disposition "
03585 "Notification Policy</h3>"
03586 "<p>MDNs are a generalization of what is commonly called <b>read "
03587 "receipt</b>. The message author requests a disposition "
03588 "notification to be sent and the receiver's mail program "
03589 "generates a reply from which the author can learn what "
03590 "happened to his message. Common disposition types include "
03591 "<b>displayed</b> (i.e. read), <b>deleted</b> and <b>dispatched</b> "
03592 "(e.g. forwarded).</p>"
03593 "<p>The following options are available to control KMail's "
03594 "sending of MDNs:</p>"
03595 "<ul>"
03596 "<li><em>Ignore</em>: Ignores any request for disposition "
03597 "notifications. No MDN will ever be sent automatically "
03598 "(recommended).</li>"
03599 "<li><em>Ask</em>: Answers requests only after asking the user "
03600 "for permission. This way, you can send MDNs for selected "
03601 "messages while denying or ignoring them for others.</li>"
03602 "<li><em>Deny</em>: Always sends a <b>denied</b> notification. This "
03603 "is only <em>slightly</em> better than always sending MDNs. "
03604 "The author will still know that the messages has been acted "
03605 "upon, he just cannot tell whether it was deleted or read etc.</li>"
03606 "<li><em>Always send</em>: Always sends the requested "
03607 "disposition notification. That means that the author of the "
03608 "message gets to know when the message was acted upon and, "
03609 "in addition, what happened to it (displayed, deleted, "
03610 "etc.). This option is strongly discouraged, but since it "
03611 "makes much sense e.g. for customer relationship management, "
03612 "it has been made available.</li>"
03613 "</ul></qt>" );
03614
03615
03616
03617 group = new QVGroupBox( i18n( "HTML Messages" ), this );
03618 group->layout()->setSpacing( KDialog::spacingHint() );
03619
03620 mHtmlMailCheck = new QCheckBox( i18n("Prefer H&TML to plain text"), group );
03621 QWhatsThis::add( mHtmlMailCheck, htmlWhatsThis );
03622 connect( mHtmlMailCheck, SIGNAL( stateChanged( int ) ),
03623 this, SLOT( slotEmitChanged( void ) ) );
03624 mExternalReferences = new QCheckBox( i18n("Allow messages to load e&xternal "
03625 "references from the Internet" ), group );
03626 QWhatsThis::add( mExternalReferences, externalWhatsThis );
03627 connect( mExternalReferences, SIGNAL( stateChanged( int ) ),
03628 this, SLOT( slotEmitChanged( void ) ) );
03629 label = new KActiveLabel( i18n("<b>WARNING:</b> Allowing HTML in email may "
03630 "increase the risk that your system will be "
03631 "compromised by present and anticipated security "
03632 "exploits. <a href=\"whatsthis:%1\">More about "
03633 "HTML mails...</a> <a href=\"whatsthis:%2\">More "
03634 "about external references...</a>")
03635 .arg(htmlWhatsThis).arg(externalWhatsThis),
03636 group );
03637
03638 vlay->addWidget( group );
03639
03640
03641 group = new QVGroupBox( i18n("Message Disposition Notifications"), this );
03642 group->layout()->setSpacing( KDialog::spacingHint() );
03643
03644
03645
03646 mMDNGroup = new QButtonGroup( group );
03647 mMDNGroup->hide();
03648 connect( mMDNGroup, SIGNAL( clicked( int ) ),
03649 this, SLOT( slotEmitChanged( void ) ) );
03650 hbox = new QHBox( group );
03651 hbox->setSpacing( KDialog::spacingHint() );
03652
03653 (void)new QLabel( i18n("Send policy:"), hbox );
03654
03655 radio = new QRadioButton( i18n("&Ignore"), hbox );
03656 mMDNGroup->insert( radio );
03657
03658 radio = new QRadioButton( i18n("As&k"), hbox );
03659 mMDNGroup->insert( radio );
03660
03661 radio = new QRadioButton( i18n("&Deny"), hbox );
03662 mMDNGroup->insert( radio );
03663
03664 radio = new QRadioButton( i18n("Al&ways send"), hbox );
03665 mMDNGroup->insert( radio );
03666
03667 for ( int i = 0 ; i < mMDNGroup->count() ; ++i )
03668 QWhatsThis::add( mMDNGroup->find( i ), receiptWhatsThis );
03669
03670 w = new QWidget( hbox );
03671 hbox->setStretchFactor( w, 1 );
03672
03673
03674 mOrigQuoteGroup = new QButtonGroup( group );
03675 mOrigQuoteGroup->hide();
03676 connect( mOrigQuoteGroup, SIGNAL( clicked( int ) ),
03677 this, SLOT( slotEmitChanged( void ) ) );
03678
03679 hbox = new QHBox( group );
03680 hbox->setSpacing( KDialog::spacingHint() );
03681
03682 (void)new QLabel( i18n("Quote original message:"), hbox );
03683
03684 radio = new QRadioButton( i18n("Nothin&g"), hbox );
03685 mOrigQuoteGroup->insert( radio );
03686
03687 radio = new QRadioButton( i18n("&Full message"), hbox );
03688 mOrigQuoteGroup->insert( radio );
03689
03690 radio = new QRadioButton( i18n("Onl&y headers"), hbox );
03691 mOrigQuoteGroup->insert( radio );
03692
03693 w = new QWidget( hbox );
03694 hbox->setStretchFactor( w, 1 );
03695
03696 mNoMDNsWhenEncryptedCheck = new QCheckBox( i18n("Do not send MDNs in response to encrypted messages"), group );
03697 connect( mNoMDNsWhenEncryptedCheck, SIGNAL(toggled(bool)), SLOT(slotEmitChanged()) );
03698
03699
03700 label = new KActiveLabel( i18n("<b>WARNING:</b> Unconditionally returning "
03701 "confirmations undermines your privacy. "
03702 "<a href=\"whatsthis:%1\">More...</a>")
03703 .arg(receiptWhatsThis),
03704 group );
03705
03706 vlay->addWidget( group );
03707
03708
03709 group = new QVGroupBox( i18n( "Certificate && Key Bundle Attachments" ), this );
03710 group->layout()->setSpacing( KDialog::spacingHint() );
03711
03712 mAutomaticallyImportAttachedKeysCheck = new QCheckBox( i18n("Automatically import keys and certificates"), group );
03713 connect( mAutomaticallyImportAttachedKeysCheck, SIGNAL(toggled(bool)), SLOT(slotEmitChanged()) );
03714
03715 vlay->addWidget( group );
03716
03717
03718
03719 vlay->addStretch( 10 );
03720 }
03721
03722 void SecurityPage::GeneralTab::doLoadOther() {
03723 const KConfigGroup reader( KMKernel::config(), "Reader" );
03724
03725 mHtmlMailCheck->setChecked( reader.readBoolEntry( "htmlMail", false ) );
03726 mExternalReferences->setChecked( reader.readBoolEntry( "htmlLoadExternal", false ) );
03727 mAutomaticallyImportAttachedKeysCheck->setChecked( reader.readBoolEntry( "AutoImportKeys", false ) );
03728
03729 const KConfigGroup mdn( KMKernel::config(), "MDN" );
03730
03731 int num = mdn.readNumEntry( "default-policy", 0 );
03732 if ( num < 0 || num >= mMDNGroup->count() ) num = 0;
03733 mMDNGroup->setButton( num );
03734 num = mdn.readNumEntry( "quote-message", 0 );
03735 if ( num < 0 || num >= mOrigQuoteGroup->count() ) num = 0;
03736 mOrigQuoteGroup->setButton( num );
03737 mNoMDNsWhenEncryptedCheck->setChecked(mdn.readBoolEntry( "not-send-when-encrypted", true ));
03738 }
03739
03740 void SecurityPage::GeneralTab::installProfile( KConfig * profile ) {
03741 const KConfigGroup reader( profile, "Reader" );
03742 const KConfigGroup mdn( profile, "MDN" );
03743
03744 if ( reader.hasKey( "htmlMail" ) )
03745 mHtmlMailCheck->setChecked( reader.readBoolEntry( "htmlMail" ) );
03746 if ( reader.hasKey( "htmlLoadExternal" ) )
03747 mExternalReferences->setChecked( reader.readBoolEntry( "htmlLoadExternal" ) );
03748 if ( reader.hasKey( "AutoImportKeys" ) )
03749 mAutomaticallyImportAttachedKeysCheck->setChecked( reader.readBoolEntry( "AutoImportKeys" ) );
03750
03751 if ( mdn.hasKey( "default-policy" ) ) {
03752 int num = mdn.readNumEntry( "default-policy" );
03753 if ( num < 0 || num >= mMDNGroup->count() ) num = 0;
03754 mMDNGroup->setButton( num );
03755 }
03756 if ( mdn.hasKey( "quote-message" ) ) {
03757 int num = mdn.readNumEntry( "quote-message" );
03758 if ( num < 0 || num >= mOrigQuoteGroup->count() ) num = 0;
03759 mOrigQuoteGroup->setButton( num );
03760 }
03761 if ( mdn.hasKey( "not-send-when-encrypted" ) )
03762 mNoMDNsWhenEncryptedCheck->setChecked(mdn.readBoolEntry( "not-send-when-encrypted" ));
03763 }
03764
03765 void SecurityPage::GeneralTab::save() {
03766 KConfigGroup reader( KMKernel::config(), "Reader" );
03767 KConfigGroup mdn( KMKernel::config(), "MDN" );
03768
03769 if (reader.readBoolEntry( "htmlMail", false ) != mHtmlMailCheck->isChecked())
03770 {
03771 if (KMessageBox::warningContinueCancel(this, i18n("Changing the global "
03772 "HTML setting will override all folder specific values."), QString::null,
03773 KStdGuiItem::cont(), "htmlMailOverride") == KMessageBox::Continue)
03774 {
03775 reader.writeEntry( "htmlMail", mHtmlMailCheck->isChecked() );
03776 QStringList names;
03777 QValueList<QGuardedPtr<KMFolder> > folders;
03778 kmkernel->folderMgr()->createFolderList(&names, &folders);
03779 kmkernel->imapFolderMgr()->createFolderList(&names, &folders);
03780 kmkernel->dimapFolderMgr()->createFolderList(&names, &folders);
03781 kmkernel->searchFolderMgr()->createFolderList(&names, &folders);
03782 for (QValueList<QGuardedPtr<KMFolder> >::iterator it = folders.begin();
03783 it != folders.end(); ++it)
03784 {
03785 if (*it)
03786 {
03787 KConfigGroupSaver saver(KMKernel::config(),
03788 "Folder-" + (*it)->idString());
03789 KMKernel::config()->writeEntry("htmlMailOverride", false);
03790 }
03791 }
03792 }
03793 }
03794 reader.writeEntry( "htmlLoadExternal", mExternalReferences->isChecked() );
03795 reader.writeEntry( "AutoImportKeys", mAutomaticallyImportAttachedKeysCheck->isChecked() );
03796 mdn.writeEntry( "default-policy", mMDNGroup->id( mMDNGroup->selected() ) );
03797 mdn.writeEntry( "quote-message", mOrigQuoteGroup->id( mOrigQuoteGroup->selected() ) );
03798 mdn.writeEntry( "not-send-when-encrypted", mNoMDNsWhenEncryptedCheck->isChecked() );
03799 }
03800
03801
03802 QString SecurityPage::ComposerCryptoTab::helpAnchor() const {
03803 return QString::fromLatin1("configure-security-composing");
03804 }
03805
03806 SecurityPageComposerCryptoTab::SecurityPageComposerCryptoTab( QWidget * parent, const char * name )
03807 : ConfigModuleTab ( parent, name )
03808 {
03809
03810 QVBoxLayout* vlay = new QVBoxLayout( this, 0, 0 );
03811
03812 mWidget = new ComposerCryptoConfiguration( this );
03813 connect( mWidget->mAutoSignature, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03814 connect( mWidget->mEncToSelf, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03815 connect( mWidget->mShowEncryptionResult, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03816 connect( mWidget->mShowKeyApprovalDlg, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03817 connect( mWidget->mAutoEncrypt, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03818 connect( mWidget->mNeverEncryptWhenSavingInDrafts, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03819 connect( mWidget->mStoreEncrypted, SIGNAL( toggled(bool) ), this, SLOT( slotEmitChanged() ) );
03820 vlay->addWidget( mWidget );
03821 }
03822
03823 void SecurityPage::ComposerCryptoTab::doLoadOther() {
03824 const KConfigGroup composer( KMKernel::config(), "Composer" );
03825
03826
03827
03828 mWidget->mAutoSignature->setChecked( composer.readBoolEntry( "pgp-auto-sign", false ) );
03829
03830 mWidget->mEncToSelf->setChecked( composer.readBoolEntry( "crypto-encrypt-to-self", true ) );
03831 mWidget->mShowEncryptionResult->setChecked( false );
03832 mWidget->mShowEncryptionResult->hide();
03833 mWidget->mShowKeyApprovalDlg->setChecked( composer.readBoolEntry( "crypto-show-keys-for-approval", true ) );
03834
03835 mWidget->mAutoEncrypt->setChecked( composer.readBoolEntry( "pgp-auto-encrypt", false ) );
03836 mWidget->mNeverEncryptWhenSavingInDrafts->setChecked( composer.readBoolEntry( "never-encrypt-drafts", true ) );
03837
03838 mWidget->mStoreEncrypted->setChecked( composer.readBoolEntry( "crypto-store-encrypted", true ) );
03839 }
03840
03841 void SecurityPage::ComposerCryptoTab::installProfile( KConfig * profile ) {
03842 const KConfigGroup composer( profile, "Composer" );
03843
03844 if ( composer.hasKey( "pgp-auto-sign" ) )
03845 mWidget->mAutoSignature->setChecked( composer.readBoolEntry( "pgp-auto-sign" ) );
03846
03847 if ( composer.hasKey( "crypto-encrypt-to-self" ) )
03848 mWidget->mEncToSelf->setChecked( composer.readBoolEntry( "crypto-encrypt-to-self" ) );
03849 if ( composer.hasKey( "crypto-show-encryption-result" ) )
03850 mWidget->mShowEncryptionResult->setChecked( composer.readBoolEntry( "crypto-show-encryption-result" ) );
03851 if ( composer.hasKey( "crypto-show-keys-for-approval" ) )
03852 mWidget->mShowKeyApprovalDlg->setChecked( composer.readBoolEntry( "crypto-show-keys-for-approval" ) );
03853 if ( composer.hasKey( "pgp-auto-encrypt" ) )
03854 mWidget->mAutoEncrypt->setChecked( composer.readBoolEntry( "pgp-auto-encrypt" ) );
03855 if ( composer.hasKey( "never-encrypt-drafts" ) )
03856 mWidget->mNeverEncryptWhenSavingInDrafts->setChecked( composer.readBoolEntry( "never-encrypt-drafts" ) );
03857
03858 if ( composer.hasKey( "crypto-store-encrypted" ) )
03859 mWidget->mStoreEncrypted->setChecked( composer.readBoolEntry( "crypto-store-encrypted" ) );
03860 }
03861
03862 void SecurityPage::ComposerCryptoTab::save() {
03863 KConfigGroup composer( KMKernel::config(), "Composer" );
03864
03865 composer.writeEntry( "pgp-auto-sign", mWidget->mAutoSignature->isChecked() );
03866
03867 composer.writeEntry( "crypto-encrypt-to-self", mWidget->mEncToSelf->isChecked() );
03868 composer.writeEntry( "crypto-show-encryption-result", mWidget->mShowEncryptionResult->isChecked() );
03869 composer.writeEntry( "crypto-show-keys-for-approval", mWidget->mShowKeyApprovalDlg->isChecked() );
03870
03871 composer.writeEntry( "pgp-auto-encrypt", mWidget->mAutoEncrypt->isChecked() );
03872 composer.writeEntry( "never-encrypt-drafts", mWidget->mNeverEncryptWhenSavingInDrafts->isChecked() );
03873
03874 composer.writeEntry( "crypto-store-encrypted", mWidget->mStoreEncrypted->isChecked() );
03875 }
03876
03877 QString SecurityPage::WarningTab::helpAnchor() const {
03878 return QString::fromLatin1("configure-security-warnings");
03879 }
03880
03881 SecurityPageWarningTab::SecurityPageWarningTab( QWidget * parent, const char * name )
03882 : ConfigModuleTab( parent, name )
03883 {
03884
03885 QVBoxLayout* vlay = new QVBoxLayout( this, 0, 0 );
03886
03887 mWidget = new WarningConfiguration( this );
03888 vlay->addWidget( mWidget );
03889
03890 connect( mWidget->warnGroupBox, SIGNAL(toggled(bool)), SLOT(slotEmitChanged()) );
03891 connect( mWidget->mWarnUnsigned, SIGNAL(toggled(bool)), SLOT(slotEmitChanged()) );
03892 connect( mWidget->warnUnencryptedCB, SIGNAL(toggled(bool)), SLOT(slotEmitChanged()) );
03893 connect( mWidget->warnReceiverNotInCertificateCB, SIGNAL(toggled(bool)), SLOT(slotEmitChanged()) );
03894 connect( mWidget->mWarnSignKeyExpiresSB, SIGNAL( valueChanged( int ) ), SLOT( slotEmitChanged() ) );
03895 connect( mWidget->mWarnSignChainCertExpiresSB, SIGNAL( valueChanged( int ) ), SLOT( slotEmitChanged() ) );
03896 connect( mWidget->mWarnSignRootCertExpiresSB, SIGNAL( valueChanged( int ) ), SLOT( slotEmitChanged() ) );
03897
03898 connect( mWidget->mWarnEncrKeyExpiresSB, SIGNAL( valueChanged( int ) ), SLOT( slotEmitChanged() ) );
03899 connect( mWidget->mWarnEncrChainCertExpiresSB, SIGNAL( valueChanged( int ) ), SLOT( slotEmitChanged() ) );
03900 connect( mWidget->mWarnEncrRootCertExpiresSB, SIGNAL( valueChanged( int ) ), SLOT( slotEmitChanged() ) );
03901
03902 connect( mWidget->enableAllWarningsPB, SIGNAL(clicked()),
03903 SLOT(slotReenableAllWarningsClicked()) );
03904 }
03905
03906 void SecurityPage::WarningTab::doLoadOther() {
03907 const KConfigGroup composer( KMKernel::config(), "Composer" );
03908
03909 mWidget->warnUnencryptedCB->setChecked( composer.readBoolEntry( "crypto-warning-unencrypted", false ) );
03910 mWidget->mWarnUnsigned->setChecked( composer.readBoolEntry( "crypto-warning-unsigned", false ) );
03911 mWidget->warnReceiverNotInCertificateCB->setChecked( composer.readBoolEntry( "crypto-warn-recv-not-in-cert", true ) );
03912
03913
03914
03915 mWidget->warnGroupBox->setChecked( composer.readBoolEntry( "crypto-warn-when-near-expire", true ) );
03916
03917 mWidget->mWarnSignKeyExpiresSB->setValue( composer.readNumEntry( "crypto-warn-sign-key-near-expire-int", 14 ) );
03918 mWidget->mWarnSignChainCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-sign-chaincert-near-expire-int", 14 ) );
03919 mWidget->mWarnSignRootCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-sign-root-near-expire-int", 14 ) );
03920
03921 mWidget->mWarnEncrKeyExpiresSB->setValue( composer.readNumEntry( "crypto-warn-encr-key-near-expire-int", 14 ) );
03922 mWidget->mWarnEncrChainCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-encr-chaincert-near-expire-int", 14 ) );
03923 mWidget->mWarnEncrRootCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-encr-root-near-expire-int", 14 ) );
03924
03925 mWidget->enableAllWarningsPB->setEnabled( true );
03926 }
03927
03928 void SecurityPage::WarningTab::installProfile( KConfig * profile ) {
03929 const KConfigGroup composer( profile, "Composer" );
03930
03931 if ( composer.hasKey( "crypto-warning-unencrypted" ) )
03932 mWidget->warnUnencryptedCB->setChecked( composer.readBoolEntry( "crypto-warning-unencrypted" ) );
03933 if ( composer.hasKey( "crypto-warning-unsigned" ) )
03934 mWidget->mWarnUnsigned->setChecked( composer.readBoolEntry( "crypto-warning-unsigned" ) );
03935 if ( composer.hasKey( "crypto-warn-recv-not-in-cert" ) )
03936 mWidget->warnReceiverNotInCertificateCB->setChecked( composer.readBoolEntry( "crypto-warn-recv-not-in-cert" ) );
03937
03938 if ( composer.hasKey( "crypto-warn-when-near-expire" ) )
03939 mWidget->warnGroupBox->setChecked( composer.readBoolEntry( "crypto-warn-when-near-expire" ) );
03940
03941 if ( composer.hasKey( "crypto-warn-sign-key-near-expire-int" ) )
03942 mWidget->mWarnSignKeyExpiresSB->setValue( composer.readNumEntry( "crypto-warn-sign-key-near-expire-int" ) );
03943 if ( composer.hasKey( "crypto-warn-sign-chaincert-near-expire-int" ) )
03944 mWidget->mWarnSignChainCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-sign-chaincert-near-expire-int" ) );
03945 if ( composer.hasKey( "crypto-warn-sign-root-near-expire-int" ) )
03946 mWidget->mWarnSignRootCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-sign-root-near-expire-int" ) );
03947
03948 if ( composer.hasKey( "crypto-warn-encr-key-near-expire-int" ) )
03949 mWidget->mWarnEncrKeyExpiresSB->setValue( composer.readNumEntry( "crypto-warn-encr-key-near-expire-int" ) );
03950 if ( composer.hasKey( "crypto-warn-encr-chaincert-near-expire-int" ) )
03951 mWidget->mWarnEncrChainCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-encr-chaincert-near-expire-int" ) );
03952 if ( composer.hasKey( "crypto-warn-encr-root-near-expire-int" ) )
03953 mWidget->mWarnEncrRootCertExpiresSB->setValue( composer.readNumEntry( "crypto-warn-encr-root-near-expire-int" ) );
03954 }
03955
03956 void SecurityPage::WarningTab::save() {
03957 KConfigGroup composer( KMKernel::config(), "Composer" );
03958
03959 composer.writeEntry( "crypto-warn-recv-not-in-cert", mWidget->warnReceiverNotInCertificateCB->isChecked() );
03960 composer.writeEntry( "crypto-warning-unencrypted", mWidget->warnUnencryptedCB->isChecked() );
03961 composer.writeEntry( "crypto-warning-unsigned", mWidget->mWarnUnsigned->isChecked() );
03962
03963 composer.writeEntry( "crypto-warn-when-near-expire", mWidget->warnGroupBox->isChecked() );
03964 composer.writeEntry( "crypto-warn-sign-key-near-expire-int",
03965 mWidget->mWarnSignKeyExpiresSB->value() );
03966 composer.writeEntry( "crypto-warn-sign-chaincert-near-expire-int",
03967 mWidget->mWarnSignChainCertExpiresSB->value() );
03968 composer.writeEntry( "crypto-warn-sign-root-near-expire-int",
03969 mWidget->mWarnSignRootCertExpiresSB->value() );
03970
03971 composer.writeEntry( "crypto-warn-encr-key-near-expire-int",
03972 mWidget->mWarnEncrKeyExpiresSB->value() );
03973 composer.writeEntry( "crypto-warn-encr-chaincert-near-expire-int",
03974 mWidget->mWarnEncrChainCertExpiresSB->value() );
03975 composer.writeEntry( "crypto-warn-encr-root-near-expire-int",
03976 mWidget->mWarnEncrRootCertExpiresSB->value() );
03977 }
03978
03979 void SecurityPage::WarningTab::slotReenableAllWarningsClicked() {
03980 KMessageBox::enableAllMessages();
03981 mWidget->enableAllWarningsPB->setEnabled( false );
03982 }
03983
03985
03986 QString SecurityPage::SMimeTab::helpAnchor() const {
03987 return QString::fromLatin1("configure-security-smime-validation");
03988 }
03989
03990 SecurityPageSMimeTab::SecurityPageSMimeTab( QWidget * parent, const char * name )
03991 : ConfigModuleTab( parent, name )
03992 {
03993
03994 QVBoxLayout* vlay = new QVBoxLayout( this, 0, 0 );
03995
03996 mWidget = new SMimeConfiguration( this );
03997 vlay->addWidget( mWidget );
03998
03999
04000 QButtonGroup* bg = new QButtonGroup( mWidget );
04001 bg->hide();
04002 bg->insert( mWidget->CRLRB );
04003 bg->insert( mWidget->OCSPRB );
04004
04005
04006 mWidget->OCSPResponderSignature->setAllowedKeys(
04007 Kleo::KeySelectionDialog::SMIMEKeys
04008 | Kleo::KeySelectionDialog::TrustedKeys
04009 | Kleo::KeySelectionDialog::ValidKeys
04010 | Kleo::KeySelectionDialog::SigningKeys
04011 | Kleo::KeySelectionDialog::PublicKeys );
04012 mWidget->OCSPResponderSignature->setMultipleKeysEnabled( false );
04013
04014 mConfig = Kleo::CryptoBackendFactory::instance()->config();
04015
04016 connect( mWidget->CRLRB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04017 connect( mWidget->OCSPRB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04018 connect( mWidget->OCSPResponderURL, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotEmitChanged() ) );
04019 connect( mWidget->OCSPResponderSignature, SIGNAL( changed() ), this, SLOT( slotEmitChanged() ) );
04020 connect( mWidget->doNotCheckCertPolicyCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04021 connect( mWidget->neverConsultCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04022 connect( mWidget->fetchMissingCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04023
04024 connect( mWidget->ignoreServiceURLCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04025 connect( mWidget->ignoreHTTPDPCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04026 connect( mWidget->disableHTTPCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04027 connect( mWidget->honorHTTPProxyRB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04028 connect( mWidget->useCustomHTTPProxyRB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04029 connect( mWidget->customHTTPProxy, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotEmitChanged() ) );
04030 connect( mWidget->ignoreLDAPDPCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04031 connect( mWidget->disableLDAPCB, SIGNAL( toggled( bool ) ), this, SLOT( slotEmitChanged() ) );
04032 connect( mWidget->customLDAPProxy, SIGNAL( textChanged( const QString& ) ), this, SLOT( slotEmitChanged() ) );
04033
04034 connect( mWidget->disableHTTPCB, SIGNAL( toggled( bool ) ),
04035 this, SLOT( slotUpdateHTTPActions() ) );
04036 connect( mWidget->ignoreHTTPDPCB, SIGNAL( toggled( bool ) ),
04037 this, SLOT( slotUpdateHTTPActions() ) );
04038
04039
04040 QButtonGroup* bgHTTPProxy = new QButtonGroup( mWidget );
04041 bgHTTPProxy->hide();
04042 bgHTTPProxy->insert( mWidget->honorHTTPProxyRB );
04043 bgHTTPProxy->insert( mWidget->useCustomHTTPProxyRB );
04044
04045 if ( !connectDCOPSignal( 0, "KPIM::CryptoConfig", "changed()",
04046 "load()", false ) )
04047 kdError(5650) << "SecurityPageSMimeTab: connection to CryptoConfig's changed() failed" << endl;
04048
04049 }
04050
04051 SecurityPageSMimeTab::~SecurityPageSMimeTab()
04052 {
04053 }
04054
04055 static void disableDirmngrWidget( QWidget* w ) {
04056 w->setEnabled( false );
04057 QWhatsThis::remove( w );
04058 QWhatsThis::add( w, i18n( "This option requires dirmngr >= 0.9.0" ) );
04059 }
04060
04061 static void initializeDirmngrCheckbox( QCheckBox* cb, Kleo::CryptoConfigEntry* entry ) {
04062 if ( entry )
04063 cb->setChecked( entry->boolValue() );
04064 else
04065 disableDirmngrWidget( cb );
04066 }
04067
04068 struct SMIMECryptoConfigEntries {
04069 SMIMECryptoConfigEntries( Kleo::CryptoConfig* config )
04070 : mConfig( config ) {
04071
04072
04073 mCheckUsingOCSPConfigEntry = configEntry( "gpgsm", "Security", "enable-ocsp", Kleo::CryptoConfigEntry::ArgType_None, false );
04074 mEnableOCSPsendingConfigEntry = configEntry( "dirmngr", "OCSP", "allow-ocsp", Kleo::CryptoConfigEntry::ArgType_None, false );
04075 mDoNotCheckCertPolicyConfigEntry = configEntry( "gpgsm", "Security", "disable-policy-checks", Kleo::CryptoConfigEntry::ArgType_None, false );
04076 mNeverConsultConfigEntry = configEntry( "gpgsm", "Security", "disable-crl-checks", Kleo::CryptoConfigEntry::ArgType_None, false );
04077 mFetchMissingConfigEntry = configEntry( "gpgsm", "Security", "auto-issuer-key-retrieve", Kleo::CryptoConfigEntry::ArgType_None, false );
04078
04079 mIgnoreServiceURLEntry = configEntry( "dirmngr", "OCSP", "ignore-ocsp-service-url", Kleo::CryptoConfigEntry::ArgType_None, false );
04080 mIgnoreHTTPDPEntry = configEntry( "dirmngr", "HTTP", "ignore-http-dp", Kleo::CryptoConfigEntry::ArgType_None, false );
04081 mDisableHTTPEntry = configEntry( "dirmngr", "HTTP", "disable-http", Kleo::CryptoConfigEntry::ArgType_None, false );
04082 mHonorHTTPProxy = configEntry( "dirmngr", "HTTP", "honor-http-proxy", Kleo::CryptoConfigEntry::ArgType_None, false );
04083
04084 mIgnoreLDAPDPEntry = configEntry( "dirmngr", "LDAP", "ignore-ldap-dp", Kleo::CryptoConfigEntry::ArgType_None, false );
04085 mDisableLDAPEntry = configEntry( "dirmngr", "LDAP", "disable-ldap", Kleo::CryptoConfigEntry::ArgType_None, false );
04086
04087 mOCSPResponderURLConfigEntry = configEntry( "dirmngr", "OCSP", "ocsp-responder", Kleo::CryptoConfigEntry::ArgType_String, false );
04088 mOCSPResponderSignature = configEntry( "dirmngr", "OCSP", "ocsp-signer", Kleo::CryptoConfigEntry::ArgType_String, false );
04089 mCustomHTTPProxy = configEntry( "dirmngr", "HTTP", "http-proxy", Kleo::CryptoConfigEntry::ArgType_String, false );
04090 mCustomLDAPProxy = configEntry( "dirmngr", "LDAP", "ldap-proxy", Kleo::CryptoConfigEntry::ArgType_String, false );
04091 }
04092
04093 Kleo::CryptoConfigEntry* configEntry( const char* componentName,
04094 const char* groupName,
04095 const char* entryName,
04096 int argType,
04097 bool isList );
04098
04099
04100 Kleo::CryptoConfigEntry* mCheckUsingOCSPConfigEntry;
04101 Kleo::CryptoConfigEntry* mEnableOCSPsendingConfigEntry;
04102 Kleo::CryptoConfigEntry* mDoNotCheckCertPolicyConfigEntry;
04103 Kleo::CryptoConfigEntry* mNeverConsultConfigEntry;
04104 Kleo::CryptoConfigEntry* mFetchMissingConfigEntry;
04105 Kleo::CryptoConfigEntry* mIgnoreServiceURLEntry;
04106 Kleo::CryptoConfigEntry* mIgnoreHTTPDPEntry;
04107 Kleo::CryptoConfigEntry* mDisableHTTPEntry;
04108 Kleo::CryptoConfigEntry* mHonorHTTPProxy;
04109 Kleo::CryptoConfigEntry* mIgnoreLDAPDPEntry;
04110 Kleo::CryptoConfigEntry* mDisableLDAPEntry;
04111
04112 Kleo::CryptoConfigEntry* mOCSPResponderURLConfigEntry;
04113 Kleo::CryptoConfigEntry* mOCSPResponderSignature;
04114 Kleo::CryptoConfigEntry* mCustomHTTPProxy;
04115 Kleo::CryptoConfigEntry* mCustomLDAPProxy;
04116
04117 Kleo::CryptoConfig* mConfig;
04118 };
04119
04120 void SecurityPage::SMimeTab::doLoadOther() {
04121 if ( !mConfig ) {
04122 setEnabled( false );
04123 return;
04124 }
04125
04126
04127
04128 mConfig->clear();
04129
04130
04131
04132
04133 SMIMECryptoConfigEntries e( mConfig );
04134
04135
04136
04137 if ( e.mCheckUsingOCSPConfigEntry ) {
04138 bool b = e.mCheckUsingOCSPConfigEntry->boolValue();
04139 mWidget->OCSPRB->setChecked( b );
04140 mWidget->CRLRB->setChecked( !b );
04141 mWidget->OCSPGroupBox->setEnabled( b );
04142 } else {
04143 mWidget->OCSPGroupBox->setEnabled( false );
04144 }
04145 if ( e.mDoNotCheckCertPolicyConfigEntry )
04146 mWidget->doNotCheckCertPolicyCB->setChecked( e.mDoNotCheckCertPolicyConfigEntry->boolValue() );
04147 if ( e.mNeverConsultConfigEntry )
04148 mWidget->neverConsultCB->setChecked( e.mNeverConsultConfigEntry->boolValue() );
04149 if ( e.mFetchMissingConfigEntry )
04150 mWidget->fetchMissingCB->setChecked( e.mFetchMissingConfigEntry->boolValue() );
04151
04152 if ( e.mOCSPResponderURLConfigEntry )
04153 mWidget->OCSPResponderURL->setText( e.mOCSPResponderURLConfigEntry->stringValue() );
04154 if ( e.mOCSPResponderSignature ) {
04155 mWidget->OCSPResponderSignature->setFingerprint( e.mOCSPResponderSignature->stringValue() );
04156 }
04157
04158
04159 initializeDirmngrCheckbox( mWidget->ignoreServiceURLCB, e.mIgnoreServiceURLEntry );
04160 initializeDirmngrCheckbox( mWidget->ignoreHTTPDPCB, e.mIgnoreHTTPDPEntry );
04161 initializeDirmngrCheckbox( mWidget->disableHTTPCB, e.mDisableHTTPEntry );
04162 initializeDirmngrCheckbox( mWidget->ignoreLDAPDPCB, e.mIgnoreLDAPDPEntry );
04163 initializeDirmngrCheckbox( mWidget->disableLDAPCB, e.mDisableLDAPEntry );
04164 if ( e.mCustomHTTPProxy ) {
04165 QString systemProxy = QString::fromLocal8Bit( getenv( "http_proxy" ) );
04166 if ( systemProxy.isEmpty() )
04167 systemProxy = i18n( "no proxy" );
04168 mWidget->systemHTTPProxy->setText( i18n( "(Current system setting: %1)" ).arg( systemProxy ) );
04169 bool honor = e.mHonorHTTPProxy && e.mHonorHTTPProxy->boolValue();
04170 mWidget->honorHTTPProxyRB->setChecked( honor );
04171 mWidget->useCustomHTTPProxyRB->setChecked( !honor );
04172 mWidget->customHTTPProxy->setText( e.mCustomHTTPProxy->stringValue() );
04173 } else {
04174 disableDirmngrWidget( mWidget->honorHTTPProxyRB );
04175 disableDirmngrWidget( mWidget->useCustomHTTPProxyRB );
04176 disableDirmngrWidget( mWidget->systemHTTPProxy );
04177 disableDirmngrWidget( mWidget->customHTTPProxy );
04178 }
04179 if ( e.mCustomLDAPProxy )
04180 mWidget->customLDAPProxy->setText( e.mCustomLDAPProxy->stringValue() );
04181 else {
04182 disableDirmngrWidget( mWidget->customLDAPProxy );
04183 disableDirmngrWidget( mWidget->customLDAPLabel );
04184 }
04185 slotUpdateHTTPActions();
04186 }
04187
04188 void SecurityPage::SMimeTab::slotUpdateHTTPActions() {
04189 mWidget->ignoreHTTPDPCB->setEnabled( !mWidget->disableHTTPCB->isChecked() );
04190
04191
04192 bool enableProxySettings = !mWidget->disableHTTPCB->isChecked()
04193 && mWidget->ignoreHTTPDPCB->isChecked();
04194 mWidget->systemHTTPProxy->setEnabled( enableProxySettings );
04195 mWidget->useCustomHTTPProxyRB->setEnabled( enableProxySettings );
04196 mWidget->honorHTTPProxyRB->setEnabled( enableProxySettings );
04197 mWidget->customHTTPProxy->setEnabled( enableProxySettings );
04198 }
04199
04200 void SecurityPage::SMimeTab::installProfile( KConfig * ) {
04201 }
04202
04203 static void saveCheckBoxToKleoEntry( QCheckBox* cb, Kleo::CryptoConfigEntry* entry ) {
04204 const bool b = cb->isChecked();
04205 if ( entry && entry->boolValue() != b )
04206 entry->setBoolValue( b );
04207 }
04208
04209 void SecurityPage::SMimeTab::save() {
04210 if ( !mConfig ) {
04211 return;
04212 }
04213
04214
04215
04216 SMIMECryptoConfigEntries e( mConfig );
04217
04218 bool b = mWidget->OCSPRB->isChecked();
04219 if ( e.mCheckUsingOCSPConfigEntry && e.mCheckUsingOCSPConfigEntry->boolValue() != b )
04220 e.mCheckUsingOCSPConfigEntry->setBoolValue( b );
04221
04222 if ( e.mEnableOCSPsendingConfigEntry && e.mEnableOCSPsendingConfigEntry->boolValue() != b )
04223 e.mEnableOCSPsendingConfigEntry->setBoolValue( b );
04224
04225 saveCheckBoxToKleoEntry( mWidget->doNotCheckCertPolicyCB, e.mDoNotCheckCertPolicyConfigEntry );
04226 saveCheckBoxToKleoEntry( mWidget->neverConsultCB, e.mNeverConsultConfigEntry );
04227 saveCheckBoxToKleoEntry( mWidget->fetchMissingCB, e.mFetchMissingConfigEntry );
04228
04229 QString txt = mWidget->OCSPResponderURL->text();
04230 if ( e.mOCSPResponderURLConfigEntry && e.mOCSPResponderURLConfigEntry->stringValue() != txt )
04231 e.mOCSPResponderURLConfigEntry->setStringValue( txt );
04232
04233 txt = mWidget->OCSPResponderSignature->fingerprint();
04234 if ( e.mOCSPResponderSignature && e.mOCSPResponderSignature->stringValue() != txt ) {
04235 e.mOCSPResponderSignature->setStringValue( txt );
04236 }
04237
04238
04239 saveCheckBoxToKleoEntry( mWidget->ignoreServiceURLCB, e.mIgnoreServiceURLEntry );
04240 saveCheckBoxToKleoEntry( mWidget->ignoreHTTPDPCB, e.mIgnoreHTTPDPEntry );
04241 saveCheckBoxToKleoEntry( mWidget->disableHTTPCB, e.mDisableHTTPEntry );
04242 saveCheckBoxToKleoEntry( mWidget->ignoreLDAPDPCB, e.mIgnoreLDAPDPEntry );
04243 saveCheckBoxToKleoEntry( mWidget->disableLDAPCB, e.mDisableLDAPEntry );
04244 if ( e.mCustomHTTPProxy ) {
04245 const bool honor = mWidget->honorHTTPProxyRB->isChecked();
04246 if ( e.mHonorHTTPProxy && e.mHonorHTTPProxy->boolValue() != honor )
04247 e.mHonorHTTPProxy->setBoolValue( honor );
04248
04249 QString chosenProxy = mWidget->customHTTPProxy->text();
04250 if ( chosenProxy != e.mCustomHTTPProxy->stringValue() )
04251 e.mCustomHTTPProxy->setStringValue( chosenProxy );
04252 }
04253 txt = mWidget->customLDAPProxy->text();
04254 if ( e.mCustomLDAPProxy && e.mCustomLDAPProxy->stringValue() != txt )
04255 e.mCustomLDAPProxy->setStringValue( mWidget->customLDAPProxy->text() );
04256
04257 mConfig->sync( true );
04258 }
04259
04260 bool SecurityPageSMimeTab::process(const QCString &fun, const QByteArray &data, QCString& replyType, QByteArray &replyData)
04261 {
04262 if ( fun == "load()" ) {
04263 replyType = "void";
04264 load();
04265 } else {
04266 return DCOPObject::process( fun, data, replyType, replyData );
04267 }
04268 return true;
04269 }
04270
04271 QCStringList SecurityPageSMimeTab::interfaces()
04272 {
04273 QCStringList ifaces = DCOPObject::interfaces();
04274 ifaces += "SecurityPageSMimeTab";
04275 return ifaces;
04276 }
04277
04278 QCStringList SecurityPageSMimeTab::functions()
04279 {
04280
04281 return DCOPObject::functions();
04282 }
04283
04284 Kleo::CryptoConfigEntry* SMIMECryptoConfigEntries::configEntry( const char* componentName,
04285 const char* groupName,
04286 const char* entryName,
04287 int argType,
04288 bool isList )
04289 {
04290 Kleo::CryptoConfigEntry* entry = mConfig->entry( componentName, groupName, entryName );
04291 if ( !entry ) {
04292 kdWarning(5006) << QString( "Backend error: gpgconf doesn't seem to know the entry for %1/%2/%3" ).arg( componentName, groupName, entryName ) << endl;
04293 return 0;
04294 }
04295 if( entry->argType() != argType || entry->isList() != isList ) {
04296 kdWarning(5006) << QString( "Backend error: gpgconf has wrong type for %1/%2/%3: %4 %5" ).arg( componentName, groupName, entryName ).arg( entry->argType() ).arg( entry->isList() ) << endl;
04297 return 0;
04298 }
04299 return entry;
04300 }
04301
04303
04304 QString SecurityPage::CryptPlugTab::helpAnchor() const {
04305 return QString::fromLatin1("configure-security-crypto-backends");
04306 }
04307
04308 SecurityPageCryptPlugTab::SecurityPageCryptPlugTab( QWidget * parent, const char * name )
04309 : ConfigModuleTab( parent, name )
04310 {
04311 QVBoxLayout * vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
04312
04313 mBackendConfig = Kleo::CryptoBackendFactory::instance()->configWidget( this, "mBackendConfig" );
04314 connect( mBackendConfig, SIGNAL( changed( bool ) ), this, SIGNAL( changed( bool ) ) );
04315
04316 vlay->addWidget( mBackendConfig );
04317 }
04318
04319 SecurityPageCryptPlugTab::~SecurityPageCryptPlugTab()
04320 {
04321
04322 }
04323
04324 void SecurityPage::CryptPlugTab::doLoadOther() {
04325 mBackendConfig->load();
04326 }
04327
04328 void SecurityPage::CryptPlugTab::save() {
04329 mBackendConfig->save();
04330 }
04331
04332
04333
04334
04335
04336
04337 QString MiscPage::helpAnchor() const {
04338 return QString::fromLatin1("configure-misc");
04339 }
04340
04341 MiscPage::MiscPage( QWidget * parent, const char * name )
04342 : ConfigModuleWithTabs( parent, name )
04343 {
04344 mFolderTab = new FolderTab();
04345 addTab( mFolderTab, i18n("&Folders") );
04346
04347 mGroupwareTab = new GroupwareTab();
04348 addTab( mGroupwareTab, i18n("&Groupware") );
04349 load();
04350 }
04351
04352 QString MiscPage::FolderTab::helpAnchor() const {
04353 return QString::fromLatin1("configure-misc-folders");
04354 }
04355
04356 MiscPageFolderTab::MiscPageFolderTab( QWidget * parent, const char * name )
04357 : ConfigModuleTab( parent, name )
04358 {
04359
04360 QVBoxLayout *vlay;
04361 QHBoxLayout *hlay;
04362 QLabel *label;
04363
04364 vlay = new QVBoxLayout( this, KDialog::marginHint(), KDialog::spacingHint() );
04365
04366
04367 mEmptyFolderConfirmCheck =
04368 new QCheckBox( i18n("Corresponds to Folder->Move All Messages to Trash",
04369 "Ask for co&nfirmation before moving all messages to "
04370 "trash"),
04371 this );
04372 vlay->addWidget( mEmptyFolderConfirmCheck );
04373 connect( mEmptyFolderConfirmCheck, SIGNAL( stateChanged( int ) ),
04374 this, SLOT( slotEmitChanged( void ) ) );
04375 mExcludeImportantFromExpiry =
04376 new QCheckBox( i18n("E&xclude important messages from expiry"), this );
04377 vlay->addWidget( mExcludeImportantFromExpiry );
04378 connect( mExcludeImportantFromExpiry, SIGNAL( stateChanged( int ) ),
04379 this, SLOT( slotEmitChanged( void ) ) );
04380
04381
04382 hlay = new QHBoxLayout( vlay );
04383 mLoopOnGotoUnread = new QComboBox( false, this );
04384 label = new QLabel( mLoopOnGotoUnread,
04385 i18n("to be continued with \"do not loop\", \"loop in current folder\", "
04386 "and \"loop in all folders\".",
04387 "When trying to find unread messages:"), this );
04388 mLoopOnGotoUnread->insertStringList( QStringList()
04389 << i18n("continuation of \"When trying to find unread messages:\"",
04390 "Do not Loop")
04391 << i18n("continuation of \"When trying to find unread messages:\"",
04392 "Loop in Current Folder")
04393 << i18n("continuation of \"When trying to find unread messages:\"",
04394 "Loop in All Folders"));
04395 hlay->addWidget( label );
04396 hlay->addWidget( mLoopOnGotoUnread, 1 );
04397 connect( mLoopOnGotoUnread, SIGNAL( activated( int ) ),
04398 this, SLOT( slotEmitChanged( void ) ) );
04399
04400
04401 hlay = new QHBoxLayout( vlay );
04402 mActionEnterFolder = new QComboBox( false, this );
04403 label = new QLabel( mActionEnterFolder,
04404 i18n("to be continued with \"jump to first new message\", "
04405 "\"jump to first unread or new message\","
04406 "and \"jump to last selected message\".",
04407 "When entering a folder:"), this );
04408 mActionEnterFolder->insertStringList( QStringList()
04409 << i18n("continuation of \"When entering a folder:\"",
04410 "Jump to First New Message")
04411 << i18n("continuation of \"When entering a folder:\"",
04412 "Jump to First Unread or New Message")
04413 << i18n("continuation of \"When entering a folder:\"",
04414 "Jump to Last Selected Message"));
04415 hlay->addWidget( label );
04416 hlay->addWidget( mActionEnterFolder, 1 );
04417 connect( mActionEnterFolder, SIGNAL( activated( int ) ),
04418 this, SLOT( slotEmitChanged( void ) ) );
04419
04420 hlay = new QHBoxLayout( vlay );
04421 mDelayedMarkAsRead = new QCheckBox( i18n("Mar&k selected message as read after"), this );
04422 hlay->addWidget( mDelayedMarkAsRead );
04423 mDelayedMarkTime = new KIntSpinBox( 0 , 60 , 1,
04424 0 , 10 , this);
04425 mDelayedMarkTime->setSuffix( i18n(" sec") );
04426 mDelayedMarkTime->setEnabled( false );
04427 hlay->addWidget( mDelayedMarkTime );
04428 hlay->addStretch( 1 );
04429 connect( mDelayedMarkTime, SIGNAL( valueChanged( int ) ),
04430 this, SLOT( slotEmitChanged( void ) ) );
04431 connect( mDelayedMarkAsRead, SIGNAL(toggled(bool)),
04432 mDelayedMarkTime, SLOT(setEnabled(bool)));
04433 connect( mDelayedMarkAsRead, SIGNAL(toggled(bool)),
04434 this , SLOT(slotEmitChanged( void )));
04435
04436
04437 mShowPopupAfterDnD =
04438 new QCheckBox( i18n("Ask for action after &dragging messages to another folder"), this );
04439 vlay->addWidget( mShowPopupAfterDnD );
04440 connect( mShowPopupAfterDnD, SIGNAL( stateChanged( int ) ),
04441 this, SLOT( slotEmitChanged( void ) ) );
04442
04443
04444 hlay = new QHBoxLayout( vlay );
04445 mMailboxPrefCombo = new QComboBox( false, this );
04446 label = new QLabel( mMailboxPrefCombo,
04447 i18n("to be continued with \"flat files\" and "
04448 "\"directories\", resp.",
04449 "By default, &message folders on disk are:"), this );
04450 mMailboxPrefCombo->insertStringList( QStringList()
04451 << i18n("continuation of \"By default, &message folders on disk are\"",
04452 "Flat Files (\"mbox\" format)")
04453 << i18n("continuation of \"By default, &message folders on disk are\"",
04454 "Directories (\"maildir\" format)") );
04455 hlay->addWidget( label );
04456 hlay->addWidget( mMailboxPrefCombo, 1 );
04457 connect( mMailboxPrefCombo, SIGNAL( activated( int ) ),
04458 this, SLOT( slotEmitChanged( void ) ) );
04459
04460
04461 hlay = new QHBoxLayout( vlay );
04462 mOnStartupOpenFolder = new FolderRequester( this,
04463 kmkernel->getKMMainWidget()->folderTree() );
04464 label = new QLabel( mOnStartupOpenFolder,
04465 i18n("Open this folder on startup:"), this );
04466 hlay->addWidget( label );
04467 hlay->addWidget( mOnStartupOpenFolder, 1 );
04468 connect( mOnStartupOpenFolder, SIGNAL( folderChanged( KMFolder* ) ),
04469 this, SLOT( slotEmitChanged( void ) ) );
04470
04471
04472 mEmptyTrashCheck = new QCheckBox( i18n("Empty local &trash folder on program exit"),
04473 this );
04474 vlay->addWidget( mEmptyTrashCheck );
04475 connect( mEmptyTrashCheck, SIGNAL( stateChanged( int ) ),
04476 this, SLOT( slotEmitChanged( void ) ) );
04477
04478 #ifdef HAVE_INDEXLIB
04479
04480 mIndexingEnabled = new QCheckBox( i18n("Enable full text &indexing"), this );
04481 vlay->addWidget( mIndexingEnabled );
04482 connect( mIndexingEnabled, SIGNAL( stateChanged( int ) ),
04483 this, SLOT( slotEmitChanged( void ) ) );
04484 #endif
04485
04486
04487
04488 vlay->addStretch( 1 );
04489
04490
04491 QString msg = i18n( "what's this help",
04492 "<qt><p>This selects which mailbox format will be "
04493 "the default for local folders:</p>"
04494 "<p><b>mbox:</b> KMail's mail "
04495 "folders are represented by a single file each. "
04496 "Individual messages are separated from each other by a "
04497 "line starting with \"From \". This saves space on "
04498 "disk, but may be less robust, e.g. when moving messages "
04499 "between folders.</p>"
04500 "<p><b>maildir:</b> KMail's mail folders are "
04501 "represented by real folders on disk. Individual messages "
04502 "are separate files. This may waste a bit of space on "
04503 "disk, but should be more robust, e.g. when moving "
04504 "messages between folders.</p></qt>");
04505 QWhatsThis::add( mMailboxPrefCombo, msg );
04506 QWhatsThis::add( label, msg );
04507
04508 msg = i18n( "what's this help",
04509 "<qt><p>When jumping to the next unread message, it may occur "
04510 "that no more unread messages are below the current message.</p>"
04511 "<p><b>Do not loop:</b> The search will stop at the last message in "
04512 "the current folder.</p>"
04513 "<p><b>Loop in current folder:</b> The search will continue at the "
04514 "top of the message list, but not go to another folder.</p>"
04515 "<p><b>Loop in all folders:</b> The search will continue at the top of "
04516 "the message list. If no unread messages are found it will then continue "
04517 "to the next folder.</p>"
04518 "<p>Similarly, when searching for the previous unread message, "
04519 "the search will start from the bottom of the message list and continue to "
04520 "the previous folder depending on which option is selected.</p></qt>" );
04521 QWhatsThis::add( mLoopOnGotoUnread, msg );
04522
04523 #ifdef HAVE_INDEXLIB
04524
04525 msg = i18n( "what's this help",
04526 "<qt><p>Full text indexing allows very fast searches on the content "
04527 "of your messages. When enabled, the search dialog will work very fast. "
04528 "Also, the search tool bar will select messages based on content.</p>"
04529 "<p>It takes up a certain amount of disk space "
04530 "(about half the disk space for the messages).</p>"
04531 "<p>After enabling, the index will need to be built, but you can continue to use KMail "
04532 "while this operation is running.</p>"
04533 "</qt>"
04534 );
04535
04536 QWhatsThis::add( mIndexingEnabled, msg );
04537 #endif
04538 }
04539
04540 void MiscPage::FolderTab::doLoadFromGlobalSettings() {
04541 mExcludeImportantFromExpiry->setChecked( GlobalSettings::self()->excludeImportantMailFromExpiry() );
04542
04543 mLoopOnGotoUnread->setCurrentItem( GlobalSettings::self()->loopOnGotoUnread() );
04544 mActionEnterFolder->setCurrentItem( GlobalSettings::self()->actionEnterFolder() );
04545 mDelayedMarkAsRead->setChecked( GlobalSettings::self()->delayedMarkAsRead() );
04546 mDelayedMarkTime->setValue( GlobalSettings::self()->delayedMarkTime() );
04547 mShowPopupAfterDnD->setChecked( GlobalSettings::self()->showPopupAfterDnD() );
04548 }
04549
04550 void MiscPage::FolderTab::doLoadOther() {
04551 KConfigGroup general( KMKernel::config(), "General" );
04552
04553 mEmptyTrashCheck->setChecked( general.readBoolEntry( "empty-trash-on-exit", true ) );
04554 mOnStartupOpenFolder->setFolder( general.readEntry( "startupFolder",
04555 kmkernel->inboxFolder()->idString() ) );
04556 mEmptyFolderConfirmCheck->setChecked( general.readBoolEntry( "confirm-before-empty", true ) );
04557
04558 int num = general.readNumEntry("default-mailbox-format", 1 );
04559 if ( num < 0 || num > 1 ) num = 1;
04560 mMailboxPrefCombo->setCurrentItem( num );
04561
04562 #ifdef HAVE_INDEXLIB
04563 mIndexingEnabled->setChecked( kmkernel->msgIndex() && kmkernel->msgIndex()->isEnabled() );
04564 #endif
04565 }
04566
04567 void MiscPage::FolderTab::save() {
04568 KConfigGroup general( KMKernel::config(), "General" );
04569
04570 general.writeEntry( "empty-trash-on-exit", mEmptyTrashCheck->isChecked() );
04571 general.writeEntry( "confirm-before-empty", mEmptyFolderConfirmCheck->isChecked() );
04572 general.writeEntry( "default-mailbox-format", mMailboxPrefCombo->currentItem() );
04573 general.writeEntry( "startupFolder", mOnStartupOpenFolder->folder() ?
04574 mOnStartupOpenFolder->folder()->idString() : QString::null );
04575
04576 GlobalSettings::self()->setDelayedMarkAsRead( mDelayedMarkAsRead->isChecked() );
04577 GlobalSettings::self()->setDelayedMarkTime( mDelayedMarkTime->value() );
04578 GlobalSettings::self()->setActionEnterFolder( mActionEnterFolder->currentItem() );
04579 GlobalSettings::self()->setLoopOnGotoUnread( mLoopOnGotoUnread->currentItem() );
04580 GlobalSettings::self()->setShowPopupAfterDnD( mShowPopupAfterDnD->isChecked() );
04581 GlobalSettings::self()->setExcludeImportantMailFromExpiry(
04582 mExcludeImportantFromExpiry->isChecked() );
04583 #ifdef HAVE_INDEXLIB
04584 if ( kmkernel->msgIndex() ) kmkernel->msgIndex()->setEnabled( mIndexingEnabled->isChecked() );
04585 #endif
04586 }
04587
04588 QString MiscPage::GroupwareTab::helpAnchor() const {
04589 return QString::fromLatin1("configure-misc-groupware");
04590 }
04591
04592 MiscPageGroupwareTab::MiscPageGroupwareTab( QWidget* parent, const char* name )
04593 : ConfigModuleTab( parent, name )
04594 {
04595 QBoxLayout* vlay = new QVBoxLayout( this, KDialog::marginHint(),
04596 KDialog::spacingHint() );
04597 vlay->setAutoAdd( true );
04598
04599
04600 QVGroupBox* b1 = new QVGroupBox( i18n("&IMAP Resource Folder Options"),
04601 this );
04602
04603 mEnableImapResCB =
04604 new QCheckBox( i18n("&Enable IMAP resource functionality"), b1 );
04605 QToolTip::add( mEnableImapResCB, i18n( "This enables the IMAP storage for "
04606 "the Kontact applications" ) );
04607 QWhatsThis::add( mEnableImapResCB,
04608 i18n( GlobalSettings::self()->theIMAPResourceEnabledItem()->whatsThis().utf8() ) );
04609 connect( mEnableImapResCB, SIGNAL( stateChanged( int ) ),
04610 this, SLOT( slotEmitChanged( void ) ) );
04611
04612 mBox = new QWidget( b1 );
04613 QGridLayout* grid = new QGridLayout( mBox, 4, 2, 0, KDialog::spacingHint() );
04614 grid->setColStretch( 1, 1 );
04615 connect( mEnableImapResCB, SIGNAL( toggled(bool) ),
04616 mBox, SLOT( setEnabled(bool) ) );
04617
04618 QLabel* storageFormatLA = new QLabel( i18n("&Format used for the groupware folders:"),
04619 mBox );
04620 QString toolTip = i18n( "Choose the format to use to store the contents of the groupware folders." );
04621 QString whatsThis = i18n( GlobalSettings::self()
04622 ->theIMAPResourceStorageFormatItem()->whatsThis().utf8() );
04623 grid->addWidget( storageFormatLA, 0, 0 );
04624 QToolTip::add( storageFormatLA, toolTip );
04625 QWhatsThis::add( storageFormatLA, whatsThis );
04626 mStorageFormatCombo = new QComboBox( false, mBox );
04627 storageFormatLA->setBuddy( mStorageFormatCombo );
04628 QStringList formatLst;
04629 formatLst << i18n("Standard (Ical / Vcard)") << i18n("Kolab (XML)");
04630 mStorageFormatCombo->insertStringList( formatLst );
04631 grid->addWidget( mStorageFormatCombo, 0, 1 );
04632 QToolTip::add( mStorageFormatCombo, toolTip );
04633 QWhatsThis::add( mStorageFormatCombo, whatsThis );
04634 connect( mStorageFormatCombo, SIGNAL( activated( int ) ),
04635 this, SLOT( slotStorageFormatChanged( int ) ) );
04636
04637 QLabel* languageLA = new QLabel( i18n("&Language of the groupware folders:"),
04638 mBox );
04639
04640 toolTip = i18n( "Set the language of the folder names" );
04641 whatsThis = i18n( GlobalSettings::self()
04642 ->theIMAPResourceFolderLanguageItem()->whatsThis().utf8() );
04643 grid->addWidget( languageLA, 1, 0 );
04644 QToolTip::add( languageLA, toolTip );
04645 QWhatsThis::add( languageLA, whatsThis );
04646 mLanguageCombo = new QComboBox( false, mBox );
04647 languageLA->setBuddy( mLanguageCombo );
04648 QStringList lst;
04649 lst << i18n("English") << i18n("German") << i18n("French") << i18n("Dutch");
04650 mLanguageCombo->insertStringList( lst );
04651 grid->addWidget( mLanguageCombo, 1, 1 );
04652 QToolTip::add( mLanguageCombo, toolTip );
04653 QWhatsThis::add( mLanguageCombo, whatsThis );
04654 connect( mLanguageCombo, SIGNAL( activated( int ) ),
04655 this, SLOT( slotEmitChanged( void ) ) );
04656
04657 mFolderComboLabel = new QLabel( mBox );
04658 toolTip = i18n( "Set the parent of the resource folders" );
04659 whatsThis = i18n( GlobalSettings::self()->theIMAPResourceFolderParentItem()->whatsThis().utf8() );
04660 QToolTip::add( mFolderComboLabel, toolTip );
04661 QWhatsThis::add( mFolderComboLabel, whatsThis );
04662 grid->addWidget( mFolderComboLabel, 2, 0 );
04663
04664 mFolderComboStack = new QWidgetStack( mBox );
04665 grid->addWidget( mFolderComboStack, 2, 1 );
04666
04667
04668
04669 mFolderCombo = new FolderRequester( mBox,
04670 kmkernel->getKMMainWidget()->folderTree() );
04671 mFolderComboStack->addWidget( mFolderCombo, 0 );
04672 QToolTip::add( mFolderCombo, toolTip );
04673 QWhatsThis::add( mFolderCombo, whatsThis );
04674 connect( mFolderCombo, SIGNAL( folderChanged( KMFolder* ) ),
04675 this, SLOT( slotEmitChanged() ) );
04676
04677
04678
04679
04680 mAccountCombo = new KMail::AccountComboBox( mBox );
04681 mFolderComboStack->addWidget( mAccountCombo, 1 );
04682 QToolTip::add( mAccountCombo, toolTip );
04683 QWhatsThis::add( mAccountCombo, whatsThis );
04684 connect( mAccountCombo, SIGNAL( activated( int ) ),
04685 this, SLOT( slotEmitChanged() ) );
04686
04687 mHideGroupwareFolders = new QCheckBox( i18n( "&Hide groupware folders" ),
04688 mBox, "HideGroupwareFoldersBox" );
04689 grid->addMultiCellWidget( mHideGroupwareFolders, 3, 3, 0, 1 );
04690 QToolTip::add( mHideGroupwareFolders,
04691 i18n( "When this is checked, you will not see the IMAP "
04692 "resource folders in the folder tree." ) );
04693 QWhatsThis::add( mHideGroupwareFolders, i18n( GlobalSettings::self()
04694 ->hideGroupwareFoldersItem()->whatsThis().utf8() ) );
04695 connect( mHideGroupwareFolders, SIGNAL( toggled( bool ) ),
04696 this, SLOT( slotEmitChanged() ) );
04697
04698
04699 b1 = new QVGroupBox( i18n("Groupware Compatibility && Legacy Options"), this );
04700
04701 gBox = new QVBox( b1 );
04702 #if 0
04703
04704 mEnableGwCB = new QCheckBox( i18n("&Enable groupware functionality"), b1 );
04705 gBox->setSpacing( KDialog::spacingHint() );
04706 connect( mEnableGwCB, SIGNAL( toggled(bool) ),
04707 gBox, SLOT( setEnabled(bool) ) );
04708 connect( mEnableGwCB, SIGNAL( stateChanged( int ) ),
04709 this, SLOT( slotEmitChanged( void ) ) );
04710 #endif
04711 mEnableGwCB = 0;
04712 mLegacyMangleFromTo = new QCheckBox( i18n( "Mangle From:/To: headers in replies to invitations" ), gBox );
04713 QToolTip::add( mLegacyMangleFromTo, i18n( "Turn this option on in order to make Outlook(tm) understand your answers to invitation replies" ) );
04714 QWhatsThis::add( mLegacyMangleFromTo, i18n( GlobalSettings::self()->
04715 legacyMangleFromToHeadersItem()->whatsThis().utf8() ) );
04716 connect( mLegacyMangleFromTo, SIGNAL( stateChanged( int ) ),
04717 this, SLOT( slotEmitChanged( void ) ) );
04718 mLegacyBodyInvites = new QCheckBox( i18n( "Send invitations in the mail body" ), gBox );
04719 QToolTip::add( mLegacyBodyInvites, i18n( "Turn this option on in order to make Outlook(tm) understand your answers to invitations" ) );
04720 QWhatsThis::add( mLegacyMangleFromTo, i18n( GlobalSettings::self()->
04721 legacyBodyInvitesItem()->whatsThis().utf8() ) );
04722 connect( mLegacyBodyInvites, SIGNAL( toggled( bool ) ),
04723 this, SLOT( slotLegacyBodyInvitesToggled( bool ) ) );
04724 connect( mLegacyBodyInvites, SIGNAL( stateChanged( int ) ),
04725 this, SLOT( slotEmitChanged( void ) ) );
04726 mAutomaticSending = new QCheckBox( i18n( "Automatic invitation sending" ), gBox );
04727 QToolTip::add( mAutomaticSending, i18n( "When this is on, the user will not see the mail composer window. Invitation mails are sent automatically" ) );
04728 QWhatsThis::add( mAutomaticSending, i18n( GlobalSettings::self()->
04729 automaticSendingItem()->whatsThis().utf8() ) );
04730 connect( mAutomaticSending, SIGNAL( stateChanged( int ) ),
04731 this, SLOT( slotEmitChanged( void ) ) );
04732
04733
04734 new QLabel( this );
04735 }
04736
04737 void MiscPageGroupwareTab::slotLegacyBodyInvitesToggled( bool on )
04738 {
04739 if ( on ) {
04740 QString txt = i18n( "<qt>Invitations are normally sent as attachments to "
04741 "a mail. This switch changes the invitation mails to "
04742 "be sent in the text of the mail instead; this is "
04743 "necessary to send invitations and replies to "
04744 "Microsoft Outlook.<br>But, when you do this, you no "
04745 "longer get descriptive text that mail programs "
04746 "can read; so, to people who have email programs "
04747 "that do not understand the invitations, the "
04748 "resulting messages look very odd.<br>People that have email "
04749 "programs that do understand invitations will still "
04750 "be able to work with this.</qt>" );
04751 KMessageBox::information( this, txt, QString::null,
04752 "LegacyBodyInvitesWarning" );
04753 }
04754
04755
04756 mAutomaticSending->setEnabled( !mLegacyBodyInvites->isChecked() );
04757 }
04758
04759 void MiscPage::GroupwareTab::doLoadFromGlobalSettings() {
04760
04761 if ( mEnableGwCB ) {
04762 mEnableGwCB->setChecked( GlobalSettings::self()->groupwareEnabled() );
04763 gBox->setEnabled( mEnableGwCB->isChecked() );
04764 }
04765 mLegacyMangleFromTo->setChecked( GlobalSettings::self()->legacyMangleFromToHeaders() );
04766 mLegacyBodyInvites->blockSignals( true );
04767 mLegacyBodyInvites->setChecked( GlobalSettings::self()->legacyBodyInvites() );
04768 mLegacyBodyInvites->blockSignals( false );
04769 mAutomaticSending->setChecked( GlobalSettings::self()->automaticSending() );
04770 mAutomaticSending->setEnabled( !mLegacyBodyInvites->isChecked() );
04771
04772
04773 mEnableImapResCB->setChecked( GlobalSettings::self()->theIMAPResourceEnabled() );
04774 mBox->setEnabled( mEnableImapResCB->isChecked() );
04775
04776 mHideGroupwareFolders->setChecked( GlobalSettings::self()->hideGroupwareFolders() );
04777 int i = GlobalSettings::self()->theIMAPResourceFolderLanguage();
04778 mLanguageCombo->setCurrentItem(i);
04779 i = GlobalSettings::self()->theIMAPResourceStorageFormat();
04780 mStorageFormatCombo->setCurrentItem(i);
04781 slotStorageFormatChanged( i );
04782
04783 QString folderId( GlobalSettings::self()->theIMAPResourceFolderParent() );
04784 if( !folderId.isNull() && kmkernel->findFolderById( folderId ) ) {
04785 mFolderCombo->setFolder( folderId );
04786 } else {
04787
04788 mFolderCombo->setFolder( i18n( "<Choose a Folder>" ) );
04789 }
04790
04791 KMAccount* selectedAccount = 0;
04792 int accountId = GlobalSettings::self()->theIMAPResourceAccount();
04793 if ( accountId )
04794 selectedAccount = kmkernel->acctMgr()->find( accountId );
04795 else {
04796
04797 for( KMAccount *a = kmkernel->acctMgr()->first(); a!=0;
04798 a = kmkernel->acctMgr()->next() ) {
04799 if( a->folder() && a->folder()->child() ) {
04800
04801 KMFolderNode *node;
04802 for (node = a->folder()->child()->first(); node; node = a->folder()->child()->next())
04803 if (!node->isDir() && node->name() == "INBOX") break;
04804
04805 if ( node && static_cast<KMFolder*>(node)->idString() == folderId ) {
04806 selectedAccount = a;
04807 break;
04808 }
04809 }
04810 }
04811 }
04812 if ( selectedAccount )
04813 mAccountCombo->setCurrentAccount( selectedAccount );
04814 else if ( GlobalSettings::self()->theIMAPResourceStorageFormat() == 1 )
04815 kdDebug(5006) << "Folder " << folderId << " not found as an account's inbox" << endl;
04816 }
04817
04818 void MiscPage::GroupwareTab::save() {
04819
04820 if ( mEnableGwCB )
04821 GlobalSettings::self()->setGroupwareEnabled( mEnableGwCB->isChecked() );
04822 GlobalSettings::self()->setLegacyMangleFromToHeaders( mLegacyMangleFromTo->isChecked() );
04823 GlobalSettings::self()->setLegacyBodyInvites( mLegacyBodyInvites->isChecked() );
04824 GlobalSettings::self()->setAutomaticSending( mAutomaticSending->isChecked() );
04825
04826 int format = mStorageFormatCombo->currentItem();
04827 GlobalSettings::self()->setTheIMAPResourceStorageFormat( format );
04828
04829
04830 GlobalSettings::self()->setHideGroupwareFolders( mHideGroupwareFolders->isChecked() );
04831
04832
04833
04834 QString folderId;
04835 if ( format == 0 ) {
04836 KMFolder* folder = mFolderCombo->folder();
04837 if ( folder )
04838 folderId = folder->idString();
04839 } else {
04840
04841 KMAccount* acct = mAccountCombo->currentAccount();
04842 if ( acct ) {
04843 folderId = QString( ".%1.directory/INBOX" ).arg( acct->id() );
04844 GlobalSettings::self()->setTheIMAPResourceAccount( acct->id() );
04845 }
04846 }
04847
04848 bool enabled = mEnableImapResCB->isChecked() && !folderId.isEmpty();
04849 GlobalSettings::self()->setTheIMAPResourceEnabled( enabled );
04850 GlobalSettings::self()->setTheIMAPResourceFolderLanguage( mLanguageCombo->currentItem() );
04851 GlobalSettings::self()->setTheIMAPResourceFolderParent( folderId );
04852 }
04853
04854 void MiscPage::GroupwareTab::slotStorageFormatChanged( int format )
04855 {
04856 mLanguageCombo->setEnabled( format == 0 );
04857 mFolderComboStack->raiseWidget( format );
04858 if ( format == 0 ) {
04859 mFolderComboLabel->setText( i18n("&Resource folders are subfolders of:") );
04860 mFolderComboLabel->setBuddy( mFolderCombo );
04861 } else {
04862 mFolderComboLabel->setText( i18n("&Resource folders are in account:") );
04863 mFolderComboLabel->setBuddy( mAccountCombo );
04864 }
04865 slotEmitChanged();
04866 }
04867
04868
04869
04870
04871
04872
04873
04874 AccountUpdater::AccountUpdater(ImapAccountBase *account)
04875 : QObject()
04876 {
04877 mAccount = account;
04878 }
04879
04880 void AccountUpdater::update()
04881 {
04882 connect( mAccount, SIGNAL( connectionResult(int, const QString&) ),
04883 this, SLOT( namespacesFetched() ) );
04884 mAccount->makeConnection();
04885 }
04886
04887 void AccountUpdater::namespacesFetched()
04888 {
04889 mAccount->setCheckingMail( true );
04890 mAccount->processNewMail( false );
04891 deleteLater();
04892 }
04893
04894 #undef DIM
04895
04896
04897 #include "configuredialog.moc"