Warn if the mail is sent to a large number of recipient (kolab issue 3377)

svn path=/branches/kdepim/enterprise/kdepim/; revision=928979
wilder-work
Andras Mantia 17 years ago
parent 9fb1e5beec
commit 4db34232b5
  1. 39
      configuredialog.cpp
  2. 2
      configuredialog_p.h
  3. 12
      kmail.kcfg
  4. 18
      kmcomposewin.cpp
  5. 6
      kmcomposewin.h

@ -2634,6 +2634,37 @@ ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent, const char * n
connect( mWordWrapCheck, SIGNAL(toggled(bool)),
mWrapColumnSpin, SLOT(setEnabled(bool)) );
// a checkbox for "too many recipient warning" and a spinbox for the recipient threshold
hlay = new QHBoxLayout( vlay ); // inherits spacing
mRecipientCheck = new QCheckBox(
GlobalSettings::self()->tooManyRecipientsItem()->label(),
this, "kcfg_TooManyReceipients" );
hlay->addWidget( mRecipientCheck );
connect( mRecipientCheck, SIGNAL( stateChanged(int) ),
this, SLOT( slotEmitChanged( void ) ) );
QString recipientCheckWhatsthis =
i18n( GlobalSettings::self()->tooManyRecipientsItem()->whatsThis().utf8() );
QWhatsThis::add( mRecipientCheck, recipientCheckWhatsthis );
mRecipientSpin = new KIntSpinBox( 1/*min*/, 255/*max*/, 1/*step*/,
5/*init*/, 10 /*base*/, this, "kcfg_RecipientThreshold" );
mRecipientSpin->setEnabled( false );
connect( mRecipientSpin, SIGNAL( valueChanged(int) ),
this, SLOT( slotEmitChanged( void ) ) );
QString recipientWhatsthis =
i18n( GlobalSettings::self()->recipientThresholdItem()->whatsThis().utf8() );
QWhatsThis::add( mRecipientSpin, recipientWhatsthis );
hlay->addWidget( mRecipientSpin );
hlay->addStretch( 1 );
// only enable the spinbox if the checkbox is checked:
connect( mRecipientCheck, SIGNAL(toggled(bool)),
mRecipientSpin, SLOT(setEnabled(bool)) );
hlay = new QHBoxLayout( vlay ); // inherits spacing
mAutoSave = new KIntSpinBox( 0, 60, 1, 1, 10, this, "kcfg_AutosaveInterval" );
label = new QLabel( mAutoSave,
@ -2728,6 +2759,8 @@ void ComposerPage::GeneralTab::doLoadFromGlobalSettings() {
mWordWrapCheck->setChecked( GlobalSettings::self()->wordWrap() );
mWrapColumnSpin->setValue( GlobalSettings::self()->lineWrapWidth() );
mRecipientCheck->setChecked( GlobalSettings::self()->tooManyRecipients() );
mRecipientSpin->setValue( GlobalSettings::self()->recipientThreshold() );
mAutoSave->setValue( GlobalSettings::self()->autosaveInterval() );
if ( GlobalSettings::self()->forwardingInlineByDefault() )
mForwardTypeCombo->setCurrentItem( 0 );
@ -2757,6 +2790,10 @@ void ComposerPage::GeneralTab::installProfile( KConfig * profile ) {
mWordWrapCheck->setChecked( composer.readBoolEntry( "word-wrap" ) );
if ( composer.hasKey( "break-at" ) )
mWrapColumnSpin->setValue( composer.readNumEntry( "break-at" ) );
if ( composer.hasKey( "too-many-recipients" ) )
mRecipientCheck->setChecked( composer.readBoolEntry( "too-many-recipients" ) );
if ( composer.hasKey( "recipient-threshold" ) )
mRecipientSpin->setValue( composer.readNumEntry( "recipient-threshold" ) );
if ( composer.hasKey( "autosave" ) )
mAutoSave->setValue( composer.readNumEntry( "autosave" ) );
@ -2776,6 +2813,8 @@ void ComposerPage::GeneralTab::save() {
GlobalSettings::self()->setWordWrap( mWordWrapCheck->isChecked() );
GlobalSettings::self()->setLineWrapWidth( mWrapColumnSpin->value() );
GlobalSettings::self()->setTooManyRecipients( mRecipientCheck->isChecked() );
GlobalSettings::self()->setRecipientThreshold( mRecipientSpin->value() );
GlobalSettings::self()->setAutosaveInterval( mAutoSave->value() );
GlobalSettings::self()->setForwardingInlineByDefault( mForwardTypeCombo->currentItem() == 0 );

@ -614,6 +614,8 @@ private:
QCheckBox *mShowRecentAddressesInComposer;
QCheckBox *mWordWrapCheck;
KIntSpinBox *mWrapColumnSpin;
QCheckBox *mRecipientCheck;
KIntSpinBox *mRecipientSpin;
KIntSpinBox *mAutoSave;
QCheckBox *mExternalEditorCheck;
KURLRequester *mEditorRequester;

@ -341,6 +341,18 @@
<min>30</min>
<max>255</max>
</entry>
<entry name="TooManyRecipients" type="Bool" key="too-many-recipients">
<label>Warn if the recipient number is bigger than</label>
<default>true</default>
<whatsthis>If there are more recipients than this number for a mail, KMail warns the user and asks for a confirmation before sending the mail. The warning can be turned off.</whatsthis>
</entry>
<entry name="RecipientThreshold" type="Int" key="recipient-threshold">
<label></label>
<default>5</default>
<min>1</min>
<max>255</max>
<whatsthis>If there are more recipients than this number for a mail, KMail warns the user and asks for a confirmation before sending the mail.</whatsthis>
</entry>
<entry name="PreviousIdentity" type="UInt" key="previous-identity" />
<entry name="PreviousFcc" type="String" key="previous-fcc" />
<entry name="TransportHistory" type="StringList" key="transport-history" />

@ -4284,6 +4284,8 @@ void KMComposeWin::slotContinueDoSend( bool sentOk )
//----------------------------------------------------------------------------
void KMComposeWin::slotSendLater()
{
if ( !checkRecipientNumber() )
return;
if ( mEditor->checkExternalEditorFinished() )
doSend( KMail::MessageSender::SendLater );
}
@ -4326,6 +4328,8 @@ void KMComposeWin::slotSendLaterVia( int item )
void KMComposeWin::slotSendNow() {
if ( !mEditor->checkExternalEditorFinished() )
return;
if ( !checkRecipientNumber() )
return;
if ( GlobalSettings::self()->confirmBeforeSend() )
{
int rc = KMessageBox::warningYesNoCancel( mMainWidget,
@ -4343,6 +4347,20 @@ void KMComposeWin::slotSendNow() {
doSend( KMail::MessageSender::SendImmediate );
}
//----------------------------------------------------------------------------
bool KMComposeWin::checkRecipientNumber() const
{
int thresHold = GlobalSettings::self()->recipientThreshold();
if ( GlobalSettings::self()->tooManyRecipients() && mRecipientsEditor->recipients().count() > thresHold ) {
if ( KMessageBox::questionYesNo( mMainWidget, i18n("You are trying to send the mail to more than %1 recipients. Send message anyway?").arg(thresHold), i18n("Too many receipients") ) == KMessageBox::No ) {
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
void KMComposeWin::slotAppendSignature()
{

@ -536,6 +536,12 @@ private:
void rethinkHeaderLine( int value, int mask, int& row,
const QString& labelStr, QLabel* lbl,
QComboBox* cbx, QCheckBox *chk );
/**
* Checks how many recipients are and warns if there are too many.
* @return true, if the user accepted the warning and the message should be sent
*/
bool checkRecipientNumber() const;
/**
* Initialization methods

Loading…
Cancel
Save