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

svn path=/branches/kdepim/enterprise4/kdepim/; revision=930375
wilder-work
Andras Mantia 17 years ago
parent 99f9184b80
commit 04959eec42
  1. 44
      configuredialog.cpp
  2. 2
      configuredialog_p.h
  3. 16
      kmail.kcfg
  4. 20
      kmcomposewin.cpp
  5. 6
      kmcomposewin.h

@ -2913,6 +2913,40 @@ ComposerPageGeneralTab::ComposerPageGeneralTab( QWidget * parent )
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(); // inherits spacing
vlay->addLayout( hlay );
mRecipientCheck = new QCheckBox(
GlobalSettings::self()->tooManyRecipientsItem()->label(), this);
mRecipientCheck->setObjectName( "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 );
QToolTip::add( mRecipientCheck, recipientCheckWhatsthis );
mRecipientSpin = new KIntSpinBox( 1/*min*/, 255/*max*/, 1/*step*/,
5/*init*/, this );
mRecipientSpin->setObjectName( "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 );
QToolTip::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(); // inherits spacing
vlay->addLayout( hlay );
mAutoSave = new KIntSpinBox( 0, 60, 1, 1, this );
@ -3002,8 +3036,9 @@ void ComposerPage::GeneralTab::doLoadFromGlobalSettings() {
mSmartQuoteCheck->setChecked( GlobalSettings::self()->smartQuote() );
mAutoRequestMDNCheck->setChecked( GlobalSettings::self()->requestMDN() );
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() );
// editor group:
@ -3031,6 +3066,10 @@ void ComposerPage::GeneralTab::installProfile( KConfig * profile ) {
mWordWrapCheck->setChecked( composer.readEntry( "word-wrap", false ) );
if ( composer.hasKey( "break-at" ) )
mWrapColumnSpin->setValue( composer.readEntry( "break-at", 0 ) );
if ( composer.hasKey( "too-many-recipients" ) )
mRecipientCheck->setChecked( composer.readEntry( "too-many-recipients", false ) );
if ( composer.hasKey( "recipient-threshold" ) )
mRecipientSpin->setValue( composer.readEntry( "recipient-threshold", 5 ) );
if ( composer.hasKey( "autosave" ) )
mAutoSave->setValue( composer.readEntry( "autosave", 0 ) );
@ -3050,8 +3089,9 @@ void ComposerPage::GeneralTab::save() {
GlobalSettings::self()->setSmartQuote( mSmartQuoteCheck->isChecked() );
GlobalSettings::self()->setRequestMDN( mAutoRequestMDNCheck->isChecked() );
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() );
// editor group:

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

@ -334,7 +334,19 @@
<min>30</min>
<max>255</max>
</entry>
<entry name="PreviousIdentity" type="UInt" key="previous-identity" />
<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="CurrentTransport" type="String" key="current-transport" />
<entry name="MaxTransportEntries" type="Int" key="max-transport-items">
@ -448,7 +460,7 @@
<default>false</default>
</entry>
<entry name="SnippetSplitterPosition" type="IntList"/>
<entry name="MaximumAttachmentSize" type="Int">
<label>The maximum size in MB that email attachments are allowed to have (-1 for no limit).</label>
<default>-1</default>

@ -3735,6 +3735,8 @@ void KMComposeWin::slotContinueDoSend( bool sentOk )
//----------------------------------------------------------------------------
void KMComposeWin::slotSendLater()
{
if ( !checkRecipientNumber() )
return;
if ( mEditor->checkExternalEditorFinished() ) {
doSend( KMail::MessageSender::SendLater );
}
@ -3784,6 +3786,8 @@ void KMComposeWin::slotSendNow()
if ( !mEditor->checkExternalEditorFinished() ) {
return;
}
if ( !checkRecipientNumber() )
return;
if ( GlobalSettings::self()->confirmBeforeSend() ) {
int rc = KMessageBox::warningYesNoCancel( mMainWidget,
@ -3802,6 +3806,22 @@ void KMComposeWin::slotSendNow()
}
}
//----------------------------------------------------------------------------
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"),
KGuiItem( i18n("&Send as Is") ),
KGuiItem( i18n("&Edit Recipients") ) ) == KMessageBox::No ) {
return false;
}
}
return true;
}
//----------------------------------------------------------------------------
void KMComposeWin::slotAppendSignature()
{

@ -537,6 +537,12 @@ class KMComposeWin : public KMail::Composer
void rethinkHeaderLine( int value, int mask, int &row,
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