diff --git a/configuredialog.cpp b/configuredialog.cpp index a120545b1..632cb4108 100644 --- a/configuredialog.cpp +++ b/configuredialog.cpp @@ -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 ); diff --git a/configuredialog_p.h b/configuredialog_p.h index d6e32ab48..42c8469f8 100644 --- a/configuredialog_p.h +++ b/configuredialog_p.h @@ -614,6 +614,8 @@ private: QCheckBox *mShowRecentAddressesInComposer; QCheckBox *mWordWrapCheck; KIntSpinBox *mWrapColumnSpin; + QCheckBox *mRecipientCheck; + KIntSpinBox *mRecipientSpin; KIntSpinBox *mAutoSave; QCheckBox *mExternalEditorCheck; KURLRequester *mEditorRequester; diff --git a/kmail.kcfg b/kmail.kcfg index 32a7447b9..fcffb6ac8 100644 --- a/kmail.kcfg +++ b/kmail.kcfg @@ -341,6 +341,18 @@ 30 255 + + + true + 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. + + + + 5 + 1 + 255 + If there are more recipients than this number for a mail, KMail warns the user and asks for a confirmation before sending the mail. + diff --git a/kmcomposewin.cpp b/kmcomposewin.cpp index 1bd138071..dcf255cf5 100644 --- a/kmcomposewin.cpp +++ b/kmcomposewin.cpp @@ -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() { diff --git a/kmcomposewin.h b/kmcomposewin.h index 5dd7da3a5..505cfe138 100644 --- a/kmcomposewin.h +++ b/kmcomposewin.h @@ -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