kmail
redirectdialog.cppGo to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include "redirectdialog.h"
00031
00032 #include "kmkernel.h"
00033 #include "kmlineeditspell.h"
00034
00035 #include <libemailfunctions/email.h>
00036 #include <addressesdialog.h>
00037 using KPIM::AddressesDialog;
00038 #include "recentaddresses.h"
00039 using KRecentAddress::RecentAddresses;
00040
00041 #include <kiconloader.h>
00042 #include <klocale.h>
00043 #include <kmessagebox.h>
00044
00045 #include <qvbox.h>
00046 #include <qhbox.h>
00047 #include <qtooltip.h>
00048 #include <qwhatsthis.h>
00049 #include <qlabel.h>
00050 #include <qpushbutton.h>
00051 #include <qstringlist.h>
00052
00053 using namespace KMail;
00054
00055 RedirectDialog::RedirectDialog( QWidget *parent, const char *name,
00056 bool modal, bool immediate )
00057 : KDialogBase( parent, name, modal, i18n( "Redirect Message" ),
00058 User1|User2|Cancel, ( immediate ? User1 : User2 ), false )
00059 {
00060 QVBox *vbox = makeVBoxMainWidget();
00061 mLabelTo = new QLabel( i18n( "Select the recipient &addresses "
00062 "to redirect to:" ), vbox );
00063
00064 QHBox *hbox = new QHBox( vbox );
00065 hbox->setSpacing(4);
00066 mEditTo = new KMLineEdit( true, hbox, "toLine" );
00067 mEditTo->setMinimumWidth( 300 );
00068
00069 mBtnTo = new QPushButton( QString::null, hbox, "toBtn" );
00070 mBtnTo->setPixmap( BarIcon( "contents", KIcon::SizeSmall ) );
00071 mBtnTo->setMinimumSize( mBtnTo->sizeHint() * 1.2 );
00072 QToolTip::add( mBtnTo, i18n("Use the Address-Selection Dialog") );
00073 QWhatsThis::add( mBtnTo, i18n("This button opens a separate dialog "
00074 "where you can select recipients out "
00075 "of all available addresses." ) );
00076
00077 connect( mBtnTo, SIGNAL(clicked()), SLOT(slotAddrBook()) );
00078
00079 mLabelTo->setBuddy( mBtnTo );
00080 mEditTo->setFocus();
00081
00082 setButtonGuiItem( User1, KGuiItem( i18n("&Send Now"), "mail_send" ) );
00083 setButtonGuiItem( User2, KGuiItem( i18n("Send &Later"), "queue" ) );
00084 }
00085
00086
00087
00088 void RedirectDialog::slotUser1()
00089 {
00090 mImmediate = true;
00091 accept();
00092 }
00093
00094
00095 void RedirectDialog::slotUser2()
00096 {
00097 mImmediate = false;
00098 accept();
00099 }
00100
00101
00102 void RedirectDialog::accept()
00103 {
00104 mResentTo = mEditTo->text();
00105 if ( mResentTo.isEmpty() ) {
00106 KMessageBox::sorry( this,
00107 i18n("You cannot redirect the message without an address."),
00108 i18n("Empty Redirection Address") );
00109 }
00110 else done( Ok );
00111 }
00112
00113
00114
00115 void RedirectDialog::slotAddrBook()
00116 {
00117 AddressesDialog dlg( this );
00118
00119 mResentTo = mEditTo->text();
00120 if ( !mResentTo.isEmpty() ) {
00121 QStringList lst = KPIM::splitEmailAddrList( mResentTo );
00122 dlg.setSelectedTo( lst );
00123 }
00124
00125 dlg.setRecentAddresses(
00126 RecentAddresses::self( KMKernel::config() )->kabcAddresses() );
00127
00128
00129
00130 dlg.setShowCC( false );
00131 dlg.setShowBCC( false );
00132
00133 if (dlg.exec()==QDialog::Rejected) return;
00134
00135 mEditTo->setText( dlg.to().join(", ") );
00136 mEditTo->setEdited( true );
00137 }
00138
00139
00140 #include "redirectdialog.moc"
|