TDE personal information management applications
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

redirectdialog.cpp 4.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. This file is part of KMail.
  3. Copyright (c) 2003 Andreas Gungl <a.gungl@gmx.de>
  4. KMail is free software; you can redistribute it and/or modify it
  5. under the terms of the GNU General Public License, version 2, as
  6. published by the Free Software Foundation.
  7. KMail is distributed in the hope that it will be useful, but
  8. WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  10. General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program; if not, write to the Free Software
  13. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  14. In addition, as a special exception, the copyright holders give
  15. permission to link the code of this program with any edition of
  16. the TQt library by Trolltech AS, Norway (or with modified versions
  17. of TQt that use the same license as TQt), and distribute linked
  18. combinations including the two. You must obey the GNU General
  19. Public License in all respects for all of the code used other than
  20. TQt. If you modify this file, you may extend this exception to
  21. your version of the file, but you are not obligated to do so. If
  22. you do not wish to do so, delete this exception statement from
  23. your version.
  24. */
  25. #include "redirectdialog.h"
  26. #include "kmkernel.h"
  27. #include "kmlineeditspell.h"
  28. #include <libemailfunctions/email.h>
  29. #include <addressesdialog.h>
  30. using KPIM::AddressesDialog;
  31. #include "recentaddresses.h"
  32. using TDERecentAddress::RecentAddresses;
  33. #include <kiconloader.h>
  34. #include <tdelocale.h>
  35. #include <tdemessagebox.h>
  36. #include <tqvbox.h>
  37. #include <tqhbox.h>
  38. #include <tqtooltip.h>
  39. #include <tqwhatsthis.h>
  40. #include <tqlabel.h>
  41. #include <tqpushbutton.h>
  42. #include <tqstringlist.h>
  43. using namespace KMail;
  44. RedirectDialog::RedirectDialog( TQWidget *parent, const char *name,
  45. bool modal, bool immediate )
  46. : KDialogBase( parent, name, modal, i18n( "Redirect Message" ),
  47. User1|User2|Cancel, ( immediate ? User1 : User2 ), false )
  48. {
  49. TQVBox *vbox = makeVBoxMainWidget();
  50. mLabelTo = new TQLabel( i18n( "Select the recipient &addresses "
  51. "to redirect to:" ), vbox );
  52. TQHBox *hbox = new TQHBox( vbox );
  53. hbox->setSpacing(4);
  54. mEditTo = new KMLineEdit( true, hbox, "toLine" );
  55. mEditTo->setMinimumWidth( 300 );
  56. mBtnTo = new TQPushButton( TQString(), hbox, "toBtn" );
  57. mBtnTo->setPixmap( BarIcon( "contents", TDEIcon::SizeSmall ) );
  58. mBtnTo->setMinimumSize( mBtnTo->sizeHint() * 1.2 );
  59. TQToolTip::add( mBtnTo, i18n("Use the Address-Selection Dialog") );
  60. TQWhatsThis::add( mBtnTo, i18n("This button opens a separate dialog "
  61. "where you can select recipients out "
  62. "of all available addresses." ) );
  63. connect( mBtnTo, TQT_SIGNAL(clicked()), TQT_SLOT(slotAddrBook()) );
  64. connect( mEditTo, TQT_SIGNAL( textChanged ( const TQString & ) ), TQT_SLOT( slotEmailChanged( const TQString & ) ) );
  65. mLabelTo->setBuddy( mBtnTo );
  66. mEditTo->setFocus();
  67. setButtonGuiItem( User1, KGuiItem( i18n("&Send Now"), "mail_send" ) );
  68. setButtonGuiItem( User2, KGuiItem( i18n("Send &Later"), "queue" ) );
  69. enableButton( User1, false );
  70. enableButton( User2, false );
  71. }
  72. void RedirectDialog::slotEmailChanged( const TQString & text )
  73. {
  74. enableButton( User1, !text.isEmpty() );
  75. enableButton( User2, !text.isEmpty() );
  76. }
  77. //-----------------------------------------------------------------------------
  78. void RedirectDialog::slotUser1()
  79. {
  80. mImmediate = true;
  81. accept();
  82. }
  83. //-----------------------------------------------------------------------------
  84. void RedirectDialog::slotUser2()
  85. {
  86. mImmediate = false;
  87. accept();
  88. }
  89. //-----------------------------------------------------------------------------
  90. void RedirectDialog::accept()
  91. {
  92. mResentTo = mEditTo->text();
  93. if ( mResentTo.isEmpty() ) {
  94. KMessageBox::sorry( this,
  95. i18n("You cannot redirect the message without an address."),
  96. i18n("Empty Redirection Address") );
  97. }
  98. else done( Ok );
  99. }
  100. //-----------------------------------------------------------------------------
  101. void RedirectDialog::slotAddrBook()
  102. {
  103. AddressesDialog dlg( this );
  104. mResentTo = mEditTo->text();
  105. if ( !mResentTo.isEmpty() ) {
  106. TQStringList lst = KPIM::splitEmailAddrList( mResentTo );
  107. dlg.setSelectedTo( lst );
  108. }
  109. dlg.setRecentAddresses(
  110. RecentAddresses::self( KMKernel::config() )->tdeabcAddresses() );
  111. // Make it impossible to specify Cc or Bcc addresses as we support
  112. // only the Redirect-To header!
  113. dlg.setShowCC( false );
  114. dlg.setShowBCC( false );
  115. if (dlg.exec()==TQDialog::Rejected) return;
  116. mEditTo->setText( dlg.to().join(", ") );
  117. mEditTo->setEdited( true );
  118. }
  119. #include "redirectdialog.moc"