1 // -*- mode: C++; c-file-style: "gnu" -*-
5 * Copyright (c) 1997-2004 KMail Developers
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; version 2 of the License
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 * In addition, as a special exception, the copyright holders give
22 * permission to link the code of this program with any edition of
23 * the Qt library by Trolltech AS, Norway (or with modified versions
24 * of Qt that use the same license as Qt), and distribute linked
25 * combinations including the two. You must obey the GNU General
26 * Public License in all respects for all of the code used other than
27 * Qt. If you modify this file, you may extend this exception to
28 * your version of the file, but you are not obligated to do so. If
29 * you do not wish to do so, delete this exception statement from
34 #include "kmfolderdialog.h"
35 #include "kmacctfolder.h"
36 #include "kmfoldermgr.h"
37 #include <kpimidentities/identitycombo.h>
38 #include "kmfolderimap.h"
39 #include "kmfoldercachedimap.h"
41 #include "kmheaders.h"
42 #include "kmcommands.h"
43 #include "kmfoldertree.h"
44 #include "folderdialogacltab.h"
45 #include "folderdialogquotatab.h"
46 #include "kmailicalifaceimpl.h"
47 #include "globalsettings.h"
48 #include "folderrequester.h"
50 #include <keditlistbox.h>
51 #include <klineedit.h>
53 #include <knuminput.h>
54 #include <kmessagebox.h>
55 #include <kicondialog.h>
58 #include <k3listview.h>
63 #include <q3groupbox.h>
68 #include <QGridLayout>
70 #include <QHBoxLayout>
72 #include <QVBoxLayout>
75 #include <q3buttongroup.h>
76 #include <QRadioButton>
78 #include "templatesconfiguration.h"
79 #include "templatesconfiguration_kfg.h"
81 using namespace KMail
;
83 static QString
inCaseWeDecideToRenameTheTab( I18N_NOOP( "Permissions (ACL)" ) );
85 //-----------------------------------------------------------------------------
86 KMFolderDialog::KMFolderDialog(KMFolder
*aFolder
, KMFolderDir
*aFolderDir
,
87 KMFolderTree
* aParent
, const QString
& aCap
,
88 const QString
& aName
):
89 KPageDialog( aParent
),
91 mFolderDir( aFolderDir
),
93 mIsNewFolder( aFolder
== 0 ),
94 mFolderTree( aParent
)
96 setFaceType( Tabbed
);
98 setButtons( Ok
|Cancel
);
99 setDefaultButton( Ok
);
100 setObjectName( "KMFolderDialog" );
103 kDebug(5006)<<"KMFolderDialog::KMFolderDialog()";
105 QStringList folderNames
;
106 QList
<QPointer
<KMFolder
> > folders
;
107 // get all folders but search and folders that can not have children
108 aParent
->createFolderList(&folderNames
, &folders
, true, true,
109 true, false, true, false);
112 // search the parent folder of the folder
113 FolderList::ConstIterator it
;
115 for( it
= folders
.begin(); it
!= folders
.end(); ++it
, ++i
) {
116 if( (*it
)->child() == mFolderDir
) {
123 FolderDialogTab
* tab
;
127 addPage( box
, i18n("General") );
128 tab
= new FolderDialogGeneralTab( this, aName
, box
);
131 if (!mFolder
->isSystemFolder() || mFolder
->isMainInbox())
132 { // not for special folders
133 box
= new KVBox( this );
134 addPage( box
, i18n("Templates") );
135 tab
= new FolderDialogTemplatesTab( this, box
);
139 KMFolder
* refFolder
= mFolder
? mFolder
: mParentFolder
;
140 KMFolderType folderType
= refFolder
? refFolder
->folderType() : KMFolderTypeUnknown
;
141 bool noContent
= mFolder
? mFolder
->storage()->noContent() : false;
142 if ( !noContent
&& refFolder
&& ( folderType
== KMFolderTypeImap
|| folderType
== KMFolderTypeCachedImap
) ) {
143 if ( FolderDialogACLTab::supports( refFolder
) ) {
145 addPage( box
, i18n("Access Control") );
146 tab
= new FolderDialogACLTab( this, box
);
151 if ( !noContent
&& refFolder
&& ( folderType
== KMFolderTypeImap
|| folderType
== KMFolderTypeCachedImap
) ) {
152 if ( FolderDialogQuotaTab::supports( refFolder
) ) {
154 addPage( box
, i18n("Quota") );
155 tab
= new FolderDialogQuotaTab( this, box
);
160 for ( int i
= 0 ; i
< mTabs
.count() ; ++i
)
162 connect( this, SIGNAL( okClicked() ), SLOT( slotOk() ) );
165 void KMFolderDialog::addTab( FolderDialogTab
* tab
)
167 connect( tab
, SIGNAL( readyForAccept() ),
168 this, SLOT( slotReadyForAccept() ) );
169 connect( tab
, SIGNAL( cancelAccept() ),
170 this, SLOT( slotCancelAccept() ) );
171 //connect( tab, SIGNAL(changed( bool )),
172 // this, SLOT(slotChanged( bool )) );
176 // Not used yet (no button), but ready to be used :)
177 void KMFolderDialog::slotApply()
179 if ( mFolder
.isNull() && !mIsNewFolder
) { // deleted meanwhile?
180 //KDialog::slotApply();
182 #warning "kde4: port it 'slotApply'"
186 for ( int i
= 0 ; i
< mTabs
.count() ; ++i
)
188 if ( !mFolder
.isNull() && mIsNewFolder
) // we just created it
189 mIsNewFolder
= false; // so it's not new anymore :)
191 #warning "kde4: port it slotApply"
193 //KDialogBase::slotApply();
196 // Called when pressing Ok
197 // We want to apply the changes first (which is async), before closing the dialog,
198 // in case of errors during the upload.
199 void KMFolderDialog::slotOk()
201 if ( mFolder
.isNull() && !mIsNewFolder
) { // deleted meanwhile?
206 mDelayedSavingTabs
= 0; // number of tabs which need delayed saving
207 for ( int i
= 0 ; i
< mTabs
.count() ; ++i
) {
208 FolderDialogTab::AcceptStatus s
= mTabs
[i
]->accept();
209 if ( s
== FolderDialogTab::Canceled
) {
213 else if ( s
== FolderDialogTab::Delayed
)
214 ++mDelayedSavingTabs
;
217 if ( mDelayedSavingTabs
)
218 enableButtonOk( false );
223 void KMFolderDialog::slotReadyForAccept()
225 --mDelayedSavingTabs
;
226 if ( mDelayedSavingTabs
== 0 )
230 void KMFolderDialog::slotCancelAccept()
232 mDelayedSavingTabs
= -1;
233 enableButtonOk( true );
234 // Don't try to create it twice
235 if ( !mFolder
.isNull() )
236 mIsNewFolder
= false;
238 // Other tabs might call slotReadyForAccept. -1 ensures that it won't close the dialog,
239 // but the OK button being enabled means that people might succeed in running
240 // the same job from save more than once.
241 // Solution: mAcceptCanceled = true instead of -1.
242 // Bah for now we only have one tab which can delay saving -> later.
245 void KMFolderDialog::slotChanged( bool )
247 // TODO, support for 'changed', and Apply button.
248 // sample code for here: KCMultiDialog calls bool changed() on every KCModuleProxy...
251 void KMFolderDialog::setFolder( KMFolder
* folder
)
253 Q_ASSERT( mFolder
.isNull() );
257 KMFolderDir
* KMFolderDialog::folderDir() const
262 static void addLine( QWidget
*parent
, QVBoxLayout
* layout
)
264 QFrame
*line
= new QFrame( parent
);
265 line
->setObjectName( "line" );
266 line
->setGeometry( QRect( 80, 150, 250, 20 ) );
267 line
->setFrameShape( QFrame::HLine
);
268 line
->setFrameShadow( QFrame::Sunken
);
269 line
->setFrameShape( QFrame::HLine
);
270 layout
->addWidget( line
);
273 //----------------------------------------------------------------------------
274 KMail::FolderDialogGeneralTab::FolderDialogGeneralTab( KMFolderDialog
* dlg
,
275 const QString
& aName
,
276 QWidget
* parent
, const char* name
)
277 : FolderDialogTab( parent
, name
), mDlg( dlg
)
281 mIsLocalSystemFolder
= mDlg
->folder()->isSystemFolder() &&
282 mDlg
->folder()->folderType() != KMFolderTypeImap
&&
283 mDlg
->folder()->folderType() != KMFolderTypeCachedImap
;
287 QVBoxLayout
*topLayout
= new QVBoxLayout( this );
288 topLayout
->setSpacing( KDialog::spacingHint() );
289 topLayout
->setMargin( 0 );
291 // Musn't be able to edit details for a system folder.
292 if ( !mIsLocalSystemFolder
) {
294 QHBoxLayout
*hl
= new QHBoxLayout();
295 topLayout
->addItem( hl
);
296 hl
->setSpacing( KDialog::spacingHint() );
298 label
= new QLabel( i18n("&Name:"), this );
299 hl
->addWidget( label
);
301 mNameEdit
= new KLineEdit( this );
302 if( !mDlg
->folder() )
303 mNameEdit
->setFocus();
304 mNameEdit
->setText( mDlg
->folder() ? mDlg
->folder()->label() : i18n("unnamed") );
305 if (!aName
.isEmpty())
306 mNameEdit
->setText(aName
);
307 mNameEdit
->setMinimumSize(mNameEdit
->sizeHint());
308 // prevent renaming of IMAP inbox
309 if ( mDlg
->folder() && mDlg
->folder()->isSystemFolder() ) {
311 if ( mDlg
->folder()->folderType() == KMFolderTypeImap
)
312 imapPath
= static_cast<KMFolderImap
*>( mDlg
->folder()->storage() )->imapPath();
313 if ( mDlg
->folder()->folderType() == KMFolderTypeCachedImap
)
314 imapPath
= static_cast<KMFolderCachedImap
*>( mDlg
->folder()->storage() )->imapPath();
315 if ( imapPath
== "/INBOX/" )
316 mNameEdit
->setEnabled( false );
318 label
->setBuddy( mNameEdit
);
319 hl
->addWidget( mNameEdit
);
320 connect( mNameEdit
, SIGNAL( textChanged( const QString
& ) ),
321 this, SLOT( slotFolderNameChanged( const QString
& ) ) );
325 QVBoxLayout
*ivl
= new QVBoxLayout();
326 topLayout
->addItem( ivl
);
327 ivl
->setSpacing( KDialog::spacingHint() );
329 QHBoxLayout
*ihl
= new QHBoxLayout();
330 ivl
->addLayout( ihl
);
331 mIconsCheckBox
= new QCheckBox( i18n("Use custom &icons"), this );
332 mIconsCheckBox
->setChecked( false );
333 ihl
->addWidget( mIconsCheckBox
);
334 ihl
->addStretch( 2 );
336 mNormalIconLabel
= new QLabel( i18n("&Normal:"), this );
337 mNormalIconLabel
->setEnabled( false );
338 ihl
->addWidget( mNormalIconLabel
);
340 mNormalIconButton
= new KIconButton( this );
341 mNormalIconLabel
->setBuddy( mNormalIconButton
);
342 mNormalIconButton
->setIconType( KIconLoader::NoGroup
, KIconLoader::Place
, false );
343 mNormalIconButton
->setIconSize( 16 );
344 mNormalIconButton
->setStrictIconSize( true );
345 mNormalIconButton
->setFixedSize( 28, 28 );
346 // Can't use iconset here
347 mNormalIconButton
->setIcon( "folder" );
348 mNormalIconButton
->setEnabled( false );
349 ihl
->addWidget( mNormalIconButton
);
351 mUnreadIconLabel
= new QLabel( i18n("&Unread:"), this );
352 mUnreadIconLabel
->setEnabled( false );
353 ihl
->addWidget( mUnreadIconLabel
);
355 mUnreadIconButton
= new KIconButton( this );
356 mUnreadIconLabel
->setBuddy( mUnreadIconButton
);
357 mUnreadIconButton
->setIconType( KIconLoader::NoGroup
, KIconLoader::Place
, false );
358 mUnreadIconButton
->setIconSize( 16 );
359 mUnreadIconButton
->setStrictIconSize( true );
360 mUnreadIconButton
->setFixedSize( 28, 28 );
361 // Can't use iconset here
362 mUnreadIconButton
->setIcon( "folder-open" );
363 mUnreadIconButton
->setEnabled( false );
364 ihl
->addWidget( mUnreadIconButton
);
365 ihl
->addStretch( 1 );
367 connect( mIconsCheckBox
, SIGNAL(toggled(bool)),
368 mNormalIconButton
, SLOT(setEnabled(bool)) );
369 connect( mIconsCheckBox
, SIGNAL(toggled(bool)),
370 mUnreadIconButton
, SLOT(setEnabled(bool)) );
371 connect( mIconsCheckBox
, SIGNAL(toggled(bool)),
372 mNormalIconLabel
, SLOT(setEnabled(bool)) );
373 connect( mIconsCheckBox
, SIGNAL(toggled(bool)),
374 mUnreadIconLabel
, SLOT(setEnabled(bool)) );
376 connect( mNormalIconButton
, SIGNAL(iconChanged(const QString
&)),
377 this, SLOT(slotChangeIcon(const QString
&)) );
380 addLine( this, topLayout
);
384 // should new mail in this folder be ignored?
385 QHBoxLayout
*hbl
= new QHBoxLayout();
386 topLayout
->addItem( hbl
);
387 hbl
->setSpacing( KDialog::spacingHint() );
388 mNotifyOnNewMailCheckBox
=
389 new QCheckBox( i18n("Act on new/unread mail in this folder" ), this );
390 mNotifyOnNewMailCheckBox
->setWhatsThis(
391 i18n( "<qt><p>If this option is enabled then you will be notified about "
392 "new/unread mail in this folder. Moreover, going to the "
393 "next/previous folder with unread messages will stop at this "
395 "<p>Uncheck this option if you do not want to be notified about "
396 "new/unread mail in this folder and if you want this folder to "
397 "be skipped when going to the next/previous folder with unread "
398 "messages. This is useful for ignoring any new/unread mail in "
399 "your trash and spam folder.</p></qt>" ) );
400 hbl
->addWidget( mNotifyOnNewMailCheckBox
);
402 if ( mDlg
->folder()->folderType() == KMFolderTypeImap
) {
403 // should this folder be included in new-mail-checks?
405 QHBoxLayout
*nml
= new QHBoxLayout();
406 topLayout
->addItem( nml
);
407 nml
->setSpacing( KDialog::spacingHint() );
408 mNewMailCheckBox
= new QCheckBox( i18n("Include this folder in mail checks"), this );
410 mNewMailCheckBox
->setChecked(true);
411 nml
->addWidget( mNewMailCheckBox
);
412 nml
->addStretch( 1 );
415 // should replies to mails in this folder be kept in this same folder?
416 hbl
= new QHBoxLayout();
417 topLayout
->addItem( hbl
);
418 hbl
->setSpacing( KDialog::spacingHint() );
419 mKeepRepliesInSameFolderCheckBox
=
420 new QCheckBox( i18n("Keep replies in this folder" ), this );
421 mKeepRepliesInSameFolderCheckBox
->setWhatsThis(
422 i18n( "Check this option if you want replies you write "
423 "to mails in this folder to be put in this same folder "
424 "after sending, instead of in the configured sent-mail folder." ) );
425 hbl
->addWidget( mKeepRepliesInSameFolderCheckBox
);
426 hbl
->addStretch( 1 );
428 addLine( this, topLayout
);
430 // use grid layout for the following combobox settings
431 QGridLayout
*gl
= new QGridLayout();
432 topLayout
->addItem( gl
);
433 gl
->setSpacing( KDialog::spacingHint() );
434 gl
->setColumnStretch( 1, 100 ); // make the second column use all available space
439 mUseDefaultIdentityCheckBox
= new QCheckBox( i18n("Use &Default Identity"),
441 gl
->addWidget( mUseDefaultIdentityCheckBox
);
442 connect( mUseDefaultIdentityCheckBox
, SIGNAL( stateChanged(int) ),
443 this, SLOT( slotIdentityCheckboxChanged() ) );
445 label
= new QLabel( i18n("&Sender identity:"), this );
446 gl
->addWidget( label
, row
, 0 );
447 mIdentityComboBox
= new KPIMIdentities::IdentityCombo( kmkernel
->identityManager(), this );
448 label
->setBuddy( mIdentityComboBox
);
449 gl
->addWidget( mIdentityComboBox
, row
, 1 );
450 mIdentityComboBox
->setWhatsThis(
451 i18n( "Select the sender identity to be used when writing new mail "
452 "or replying to mail in this folder. This means that if you are in "
453 "one of your work folders, you can make KMail use the corresponding "
454 "sender email address, signature and signing or encryption keys "
455 "automatically. Identities can be set up in the main configuration "
456 "dialog. (Settings -> Configure KMail)") );
459 // sender or receiver column?
461 QString tip
= i18n("Show Sender/Receiver Column in List of Messages");
463 QLabel
*sender_label
= new QLabel( i18n("Sho&w column:" ), this );
464 gl
->addWidget( sender_label
, row
, 0 );
465 mShowSenderReceiverComboBox
= new QComboBox( this );
466 mShowSenderReceiverComboBox
->setToolTip( tip
);
467 sender_label
->setBuddy(mShowSenderReceiverComboBox
);
468 gl
->addWidget( mShowSenderReceiverComboBox
, row
, 1 );
469 mShowSenderReceiverComboBox
->insertItem(0, i18n("Default"));
470 mShowSenderReceiverComboBox
->insertItem(1, i18n("Sender"));
471 mShowSenderReceiverComboBox
->insertItem(2, i18n("Receiver"));
474 if (mDlg
->folder()) whoField
= mDlg
->folder()->userWhoField();
475 if (whoField
.isEmpty()) mShowSenderReceiverComboBox
->setCurrentIndex(0);
476 else if (whoField
== "From") mShowSenderReceiverComboBox
->setCurrentIndex(1);
477 else if (whoField
== "To") mShowSenderReceiverComboBox
->setCurrentIndex(2);
480 if ( !mIsLocalSystemFolder
&& kmkernel
->iCalIface().isEnabled() ) {
481 // Only do make this settable, if the IMAP resource is enabled
482 // and it's not the personal folders (those must not be changed)
484 label
= new QLabel( i18n("&Folder contents:"), this );
485 gl
->addWidget( label
, row
, 0 );
486 mContentsComboBox
= new QComboBox( this );
487 label
->setBuddy( mContentsComboBox
);
488 gl
->addWidget( mContentsComboBox
, row
, 1 );
490 mContentsComboBox
->addItem( i18n( "Mail" ) );
491 mContentsComboBox
->addItem( i18n( "Calendar" ) );
492 mContentsComboBox
->addItem( i18n( "Contacts" ) );
493 mContentsComboBox
->addItem( i18n( "Notes" ) );
494 mContentsComboBox
->addItem( i18n( "Tasks" ) );
495 mContentsComboBox
->addItem( i18n( "Journal" ) );
496 if ( mDlg
->folder() )
497 mContentsComboBox
->setCurrentIndex( mDlg
->folder()->storage()->contentsType() );
498 connect ( mContentsComboBox
, SIGNAL ( activated( int ) ),
499 this, SLOT( slotFolderContentsSelectionChanged( int ) ) );
500 if ( mDlg
->folder()->isReadOnly() )
501 mContentsComboBox
->setEnabled( false );
503 mContentsComboBox
= 0;
506 mIncidencesForComboBox
= 0;
507 mAlarmsBlockedCheckBox
= 0;
509 // Kolab incidences-for annotation.
510 // Show incidences-for combobox if the contents type can be changed (new folder),
511 // or if it's set to calendar or task (existing folder)
512 if ( ( GlobalSettings::self()->theIMAPResourceStorageFormat() ==
513 GlobalSettings::EnumTheIMAPResourceStorageFormat::XML
) &&
514 mContentsComboBox
) {
516 QLabel
* label
= new QLabel( i18n( "Generate free/&busy and activate alarms for:" ), this );
517 gl
->addWidget( label
, row
, 0 );
518 mIncidencesForComboBox
= new QComboBox( this );
519 label
->setBuddy( mIncidencesForComboBox
);
520 gl
->addWidget( mIncidencesForComboBox
, row
, 1 );
522 mIncidencesForComboBox
->addItem( i18n( "Nobody" ) );
523 mIncidencesForComboBox
->addItem( i18n( "Admins of This Folder" ) );
524 mIncidencesForComboBox
->addItem( i18n( "All Readers of This Folder" ) );
525 const QString whatsThisForMyOwnFolders
=
526 i18n( "This setting defines which users sharing "
527 "this folder should get \"busy\" periods in their freebusy lists "
528 "and should see the alarms for the events or tasks in this folder. "
529 "The setting applies to Calendar and Task folders only "
530 "(for tasks, this setting is only used for alarms).\n\n"
531 "Example use cases: if the boss shares a folder with his secretary, "
532 "only the boss should be marked as busy for his meetings, so he should "
533 "select \"Admins\", since the secretary has no admin rights on the folder.\n"
534 "On the other hand if a working group shares a Calendar for "
535 "group meetings, all readers of the folders should be marked "
536 "as busy for meetings.\n"
537 "A company-wide folder with optional events in it would use \"Nobody\" "
538 "since it is not known who will go to those events." );
540 mIncidencesForComboBox
->setWhatsThis( whatsThisForMyOwnFolders
);
543 const QString whatsThisForReadOnlyFolders
=
544 i18n( "This setting allows you to disable alarms for folders shared by "
546 mAlarmsBlockedCheckBox
= new QCheckBox( this );
547 gl
->addWidget( mAlarmsBlockedCheckBox
, row
, 0 );
548 label
= new QLabel( i18n( "Block free/&busy and alarms locally" ), this );
549 gl
->addWidget( label
, row
, 1 );
550 label
->setBuddy( mAlarmsBlockedCheckBox
);
551 mAlarmsBlockedCheckBox
->setWhatsThis( whatsThisForReadOnlyFolders
);
553 if ( mDlg
->folder()->storage()->contentsType() != KMail::ContentsTypeCalendar
554 && mDlg
->folder()->storage()->contentsType() != KMail::ContentsTypeTask
) {
555 mIncidencesForComboBox
->setEnabled( false );
556 mAlarmsBlockedCheckBox
->setEnabled( false );
559 mIncidencesForComboBox
= 0;
562 topLayout
->addStretch( 100 ); // eat all superfluous space
564 initializeWithValuesFromFolder( mDlg
->folder() );
567 void FolderDialogGeneralTab::load()
569 // Nothing here, all is done in the ctor
572 void FolderDialogGeneralTab::initializeWithValuesFromFolder( KMFolder
* folder
) {
576 if ( !mIsLocalSystemFolder
) {
578 mIconsCheckBox
->setChecked( folder
->useCustomIcons() );
579 mNormalIconLabel
->setEnabled( folder
->useCustomIcons() );
580 mNormalIconButton
->setEnabled( folder
->useCustomIcons() );
581 mUnreadIconLabel
->setEnabled( folder
->useCustomIcons() );
582 mUnreadIconButton
->setEnabled( folder
->useCustomIcons() );
583 QString iconPath
= folder
->normalIconPath();
584 if ( !iconPath
.isEmpty() )
585 mNormalIconButton
->setIcon( iconPath
);
586 iconPath
= folder
->unreadIconPath();
587 if ( !iconPath
.isEmpty() )
588 mUnreadIconButton
->setIcon( iconPath
);
592 mIdentityComboBox
->setCurrentIdentity( folder
->identity() );
593 mUseDefaultIdentityCheckBox
->setChecked( folder
->useDefaultIdentity() );
596 mNotifyOnNewMailCheckBox
->setChecked( !folder
->ignoreNewMail() );
598 const bool keepInFolder
= !folder
->isReadOnly() && folder
->putRepliesInSameFolder();
599 mKeepRepliesInSameFolderCheckBox
->setChecked( keepInFolder
);
600 mKeepRepliesInSameFolderCheckBox
->setDisabled( folder
->isReadOnly() );
602 if (folder
->folderType() == KMFolderTypeImap
)
604 KMFolderImap
* imapFolder
= static_cast<KMFolderImap
*>(folder
->storage());
605 bool checked
= imapFolder
->includeInMailCheck();
606 mNewMailCheckBox
->setChecked(checked
);
609 if ( mIncidencesForComboBox
) {
610 KMFolderCachedImap
* dimap
= static_cast<KMFolderCachedImap
*>( folder
->storage() );
611 mIncidencesForComboBox
->setCurrentIndex( dimap
->incidencesFor() );
612 mIncidencesForComboBox
->setDisabled( mDlg
->folder()->isReadOnly() );
614 if ( mAlarmsBlockedCheckBox
) {
615 KMFolderCachedImap
* dimap
= static_cast<KMFolderCachedImap
*>( folder
->storage() );
616 mAlarmsBlockedCheckBox
->setChecked( dimap
->alarmsBlocked() );
620 //-----------------------------------------------------------------------------
621 void FolderDialogGeneralTab::slotFolderNameChanged( const QString
& str
)
623 mDlg
->enableButtonOk( !str
.isEmpty() );
626 //-----------------------------------------------------------------------------
627 void FolderDialogGeneralTab::slotFolderContentsSelectionChanged( int )
629 KMail::FolderContentsType type
=
630 static_cast<KMail::FolderContentsType
>( mContentsComboBox
->currentIndex() );
631 if( type
!= KMail::ContentsTypeMail
&& GlobalSettings::self()->hideGroupwareFolders() ) {
632 QString message
= i18n("You have configured this folder to contain groupware information "
633 "and the general configuration option to hide groupware folders is "
634 "set. That means that this folder will disappear once the configuration "
635 "dialog is closed. If you want to remove the folder again, you will need "
636 "to temporarily disable hiding of groupware folders to be able to see it.");
637 KMessageBox::information( this, message
);
640 const bool enable
= type
== KMail::ContentsTypeCalendar
|| type
== KMail::ContentsTypeTask
;
641 if ( mIncidencesForComboBox
)
642 mIncidencesForComboBox
->setEnabled( enable
);
643 if ( mAlarmsBlockedCheckBox
)
644 mAlarmsBlockedCheckBox
->setEnabled( enable
);
647 //-----------------------------------------------------------------------------
648 void FolderDialogGeneralTab::slotIdentityCheckboxChanged()
650 mIdentityComboBox
->setEnabled( !mUseDefaultIdentityCheckBox
->isChecked() );
653 //-----------------------------------------------------------------------------
654 bool FolderDialogGeneralTab::save()
656 KMFolder
* folder
= mDlg
->folder();
657 folder
->setIdentity( mIdentityComboBox
->currentIdentity() );
658 folder
->setUseDefaultIdentity( mUseDefaultIdentityCheckBox
->isChecked() );
660 if (mShowSenderReceiverComboBox
->currentIndex() == 1)
661 folder
->setUserWhoField("From");
662 else if (mShowSenderReceiverComboBox
->currentIndex() == 2)
663 folder
->setUserWhoField("To");
665 folder
->setUserWhoField("");
667 folder
->setIgnoreNewMail( !mNotifyOnNewMailCheckBox
->isChecked() );
668 folder
->setPutRepliesInSameFolder( mKeepRepliesInSameFolderCheckBox
->isChecked() );
670 QString fldName
, oldFldName
;
671 if ( !mIsLocalSystemFolder
)
674 oldFldName
= mDlg
->folder()->name();
676 if (!mNameEdit
->text().isEmpty())
677 fldName
= mNameEdit
->text();
679 fldName
= oldFldName
;
681 if ( mDlg
->parentFolder() &&
682 mDlg
->parentFolder()->folderType() != KMFolderTypeImap
&&
683 mDlg
->parentFolder()->folderType() != KMFolderTypeCachedImap
)
685 fldName
.remove(QRegExp("^\\.*"));
686 if (fldName
.isEmpty()) fldName
= i18n("unnamed");
689 // Update the tree iff new icon paths are different and not empty or if
690 // useCustomIcons changed.
691 if ( folder
->useCustomIcons() != mIconsCheckBox
->isChecked() ) {
692 folder
->setUseCustomIcons( mIconsCheckBox
->isChecked() );
693 // Reset icons, useCustomIcons was turned off.
694 if ( !folder
->useCustomIcons() ) {
695 folder
->setIconPaths( "", "" );
698 if ( folder
->useCustomIcons() &&
699 (( mNormalIconButton
->icon() != folder
->normalIconPath() ) &&
700 ( !mNormalIconButton
->icon().isEmpty())) ||
701 (( mUnreadIconButton
->icon() != folder
->unreadIconPath() ) &&
702 ( !mUnreadIconButton
->icon().isEmpty())) ) {
703 folder
->setIconPaths( mNormalIconButton
->icon(), mUnreadIconButton
->icon() );
707 if ( mContentsComboBox
) {
708 KMail::FolderContentsType type
=
709 static_cast<KMail::FolderContentsType
>( mContentsComboBox
->currentIndex() );
710 folder
->storage()->setContentsType( type
);
713 if ( folder
->folderType() == KMFolderTypeCachedImap
) {
714 KMFolderCachedImap
* dimap
= static_cast<KMFolderCachedImap
*>( mDlg
->folder()->storage() );
715 if ( mIncidencesForComboBox
) {
716 KMFolderCachedImap::IncidencesFor incfor
=
717 static_cast<KMFolderCachedImap::IncidencesFor
>( mIncidencesForComboBox
->currentIndex() );
718 if ( dimap
->incidencesFor() != incfor
) {
719 dimap
->setIncidencesFor( incfor
);
720 dimap
->writeConfig();
723 if ( mAlarmsBlockedCheckBox
&& mAlarmsBlockedCheckBox
->isChecked() != dimap
->alarmsBlocked() ) {
724 dimap
->setAlarmsBlocked( mAlarmsBlockedCheckBox
->isChecked() );
725 dimap
->writeConfig();
729 if( folder
->folderType() == KMFolderTypeImap
)
731 KMFolderImap
* imapFolder
= static_cast<KMFolderImap
*>( folder
->storage() );
732 imapFolder
->setIncludeInMailCheck(
733 mNewMailCheckBox
->isChecked() );
735 // make sure everything is on disk, connected slots will call readConfig()
736 // when creating a new folder.
737 folder
->storage()->writeConfig();
738 // Renamed an existing folder? We don't check for oldName == newName on
739 // purpose here. The folder might be pending renaming on the next dimap
740 // sync already, in which case the old name would still be around and
741 // something like Calendar -> CalendarFoo -> Calendar inbetween syncs would
742 // fail. Therefor let the folder sort it out itself, whether the rename is
744 if ( !oldFldName
.isEmpty() )
746 kmkernel
->folderMgr()->renameFolder( folder
, fldName
);
748 kmkernel
->folderMgr()->contentsChanged();
754 void FolderDialogGeneralTab::slotChangeIcon( const QString
&icon
)
756 mUnreadIconButton
->setIcon( icon
);
759 //----------------------------------------------------------------------------
760 KMail::FolderDialogTemplatesTab::FolderDialogTemplatesTab( KMFolderDialog
*dlg
,
762 : FolderDialogTab( parent
, 0 ), mDlg( dlg
)
765 mIsLocalSystemFolder
= mDlg
->folder()->isSystemFolder() &&
766 mDlg
->folder()->folderType() != KMFolderTypeImap
&&
767 mDlg
->folder()->folderType() != KMFolderTypeCachedImap
;
769 QVBoxLayout
*topLayout
= new QVBoxLayout( this );
770 topLayout
->setMargin( 0 );
771 topLayout
->setSpacing( KDialog::spacingHint() );
773 mCustom
= new QCheckBox( i18n("&Use custom message templates"), this );
774 topLayout
->addWidget( mCustom
);
776 mWidget
= new TemplatesConfiguration( this , "folder-templates" );
777 mWidget
->setEnabled( false );
778 topLayout
->addWidget( mWidget
);
780 QHBoxLayout
*btns
= new QHBoxLayout();
781 btns
->setSpacing( KDialog::spacingHint() );
782 mCopyGlobal
= new KPushButton( i18n("&Copy Global Templates"), this );
783 mCopyGlobal
->setEnabled( false );
784 btns
->addWidget( mCopyGlobal
);
785 topLayout
->addLayout( btns
);
787 connect( mCustom
, SIGNAL(toggled(bool)),
788 mWidget
, SLOT(setEnabled(bool)) );
789 connect( mCustom
, SIGNAL(toggled(bool)),
790 mCopyGlobal
, SLOT(setEnabled(bool)) );
792 connect( mCopyGlobal
, SIGNAL(clicked()),
793 this, SLOT(slotCopyGlobal()) );
795 initializeWithValuesFromFolder( mDlg
->folder() );
797 connect( mWidget
, SIGNAL( changed() ),
798 this, SLOT( slotEmitChanged( void ) ) );
801 void FolderDialogTemplatesTab::load()
806 void FolderDialogTemplatesTab::initializeWithValuesFromFolder( KMFolder
* folder
) {
812 QString fid
= folder
->idString();
816 mCustom
->setChecked(t
.useCustomTemplates());
818 mIdentity
= folder
->identity();
820 mWidget
->loadFromFolder( fid
, mIdentity
);
823 //-----------------------------------------------------------------------------
824 bool FolderDialogTemplatesTab::save()
826 KMFolder
* folder
= mDlg
->folder();
828 QString fid
= folder
->idString();
831 kDebug(5006) <<"use custom templates for folder" << fid
<<":" << mCustom
->isChecked();
832 t
.setUseCustomTemplates(mCustom
->isChecked());
835 mWidget
->saveToFolder(fid
);
841 void FolderDialogTemplatesTab::slotEmitChanged() {}
843 void FolderDialogTemplatesTab::slotCopyGlobal() {
845 mWidget
->loadFromIdentity( mIdentity
);
848 mWidget
->loadFromGlobal();
852 #include "kmfolderdialog.moc"