19 #include "vacationdialog.h"
21 #include <kmime_header_parsing.h>
22 using KMime::Types::AddrSpecList;
23 using KMime::Types::AddressList;
24 using KMime::Types::MailboxList;
25 using KMime::HeaderParsing::parseAddressList;
27 #include <knuminput.h>
28 #include <tdelocale.h>
31 #include <tdeapplication.h>
35 #include <tqcheckbox.h>
36 #include <tqlineedit.h>
37 #include <tqtextedit.h>
38 #include <tqvalidator.h>
42 VacationDialog::VacationDialog(
const TQString & caption, TQWidget * parent,
43 const char * name,
bool modal )
44 : KDialogBase( Plain, caption,
Ok|Cancel|Default,
Ok, parent, name, modal )
46 KWin::setIcons( winId(), kapp->icon(), kapp->miniIcon() );
48 static const int rows = 7;
51 TQGridLayout * glay =
new TQGridLayout( plainPage(), rows, 2, 0, spacingHint() );
52 glay->setColStretch( 1, 1 );
56 glay->addMultiCellWidget(
new TQLabel( i18n(
"Configure vacation "
57 "notifications to be sent:"),
58 plainPage() ), row, row, 0, 1 );
62 mActiveCheck =
new TQCheckBox( i18n(
"&Activate vacation notifications"), plainPage() );
63 glay->addMultiCellWidget( mActiveCheck, row, row, 0, 1 );
67 glay->setRowStretch( row, 1 );
68 mTextEdit =
new TQTextEdit( plainPage(),
"mTextEdit" );
69 mTextEdit->setTextFormat( TQTextEdit::PlainText );
70 glay->addMultiCellWidget( mTextEdit, row, row, 0, 1 );
74 int defDayInterval = 7;
75 mIntervalSpin =
new KIntSpinBox( 1, 356, 1, defDayInterval, 10, plainPage(),
"mIntervalSpin" );
76 mIntervalSpin->setSuffix( i18n(
" day",
" days", defDayInterval) );
77 connect(mIntervalSpin, TQ_SIGNAL( valueChanged(
int )), TQ_SLOT( slotIntervalSpinChanged(
int ) ) );
78 glay->addWidget(
new TQLabel( mIntervalSpin, i18n(
"&Resend notification only after:"), plainPage() ), row, 0 );
79 glay->addWidget( mIntervalSpin, row, 1 );
83 mMailAliasesEdit =
new TQLineEdit( plainPage(),
"mMailAliasesEdit" );
84 glay->addWidget(
new TQLabel( mMailAliasesEdit, i18n(
"&Send responses for these addresses:"), plainPage() ), row, 0 );
85 glay->addWidget( mMailAliasesEdit, row, 1 );
89 mSpamCheck =
new TQCheckBox( i18n(
"Do not send vacation replies to spam messages"), plainPage(),
"mSpamCheck" );
90 mSpamCheck->setChecked(
true );
91 glay->addMultiCellWidget( mSpamCheck, row, row, 0, 1 );
95 mDomainCheck =
new TQCheckBox( i18n(
"Only react to mail coming from domain"), plainPage(),
"mDomainCheck" );
96 mDomainCheck->setChecked(
false );
97 mDomainEdit =
new TQLineEdit( plainPage(),
"mDomainEdit" );
98 mDomainEdit->setEnabled(
false );
99 mDomainEdit->setValidator(
new TQRegExpValidator( TQRegExp(
"[a-zA-Z0-9+-]+(?:\\.[a-zA-Z0-9+-]+)*" ), mDomainEdit ) );
100 glay->addWidget( mDomainCheck, row, 0 );
101 glay->addWidget( mDomainEdit, row, 1 );
102 connect( mDomainCheck, TQ_SIGNAL(toggled(
bool)),
103 mDomainEdit, TQ_SLOT(setEnabled(
bool)) );
105 Q_ASSERT( row == rows - 1 );
108 VacationDialog::~VacationDialog() {
109 kdDebug(5006) <<
"~VacationDialog()" << endl;
112 bool VacationDialog::activateVacation()
const {
113 return mActiveCheck->isChecked();
116 void VacationDialog::setActivateVacation(
bool activate ) {
117 mActiveCheck->setChecked( activate );
120 TQString VacationDialog::messageText()
const {
121 return mTextEdit->text().stripWhiteSpace();
124 void VacationDialog::setMessageText(
const TQString & text ) {
125 mTextEdit->setText( text );
126 const int height = ( mTextEdit->fontMetrics().lineSpacing() + 1 ) * 11;
127 mTextEdit->setMinimumHeight( height );
130 int VacationDialog::notificationInterval()
const {
131 return mIntervalSpin->value();
134 void VacationDialog::setNotificationInterval(
int days ) {
135 mIntervalSpin->setValue( days );
138 AddrSpecList VacationDialog::mailAliases()
const {
139 TQCString text = mMailAliasesEdit->text().latin1();
141 const char * s = text.begin();
142 parseAddressList( s, text.end(), al );
145 for ( AddressList::const_iterator it = al.begin() ; it != al.end() ; ++it ) {
146 const MailboxList & mbl = (*it).mailboxList;
147 for ( MailboxList::const_iterator jt = mbl.begin() ; jt != mbl.end() ; ++jt )
148 asl.push_back( (*jt).addrSpec );
153 void VacationDialog::setMailAliases(
const AddrSpecList & aliases ) {
155 for ( AddrSpecList::const_iterator it = aliases.begin() ; it != aliases.end() ; ++it )
156 sl.push_back( (*it).asString() );
157 mMailAliasesEdit->setText( sl.join(
", ") );
160 void VacationDialog::setMailAliases(
const TQString & aliases ) {
161 mMailAliasesEdit->setText( aliases );
164 void VacationDialog::slotIntervalSpinChanged (
int value ) {
165 mIntervalSpin->setSuffix( i18n(
" day",
" days", value) );
168 TQString VacationDialog::domainName()
const {
169 return mDomainCheck->isChecked() ? mDomainEdit->text() : TQString() ;
172 void VacationDialog::setDomainName(
const TQString & domain ) {
173 if ( !domain.isEmpty() ) {
174 mDomainEdit->setText( domain );
175 mDomainCheck->setChecked(
true );
179 bool VacationDialog::domainCheck()
const
181 return mDomainCheck->isChecked();
184 void VacationDialog::setDomainCheck(
bool check )
186 mDomainCheck->setChecked( check );
189 bool VacationDialog::sendForSpam()
const
191 return !mSpamCheck->isChecked();
194 void VacationDialog::setSendForSpam(
bool enable )
196 mSpamCheck->setChecked( !enable );
200 void KMail::VacationDialog::enableDomainAndSendForSpam(
bool enable )
202 mDomainCheck->setEnabled( enable );
203 mDomainEdit->setEnabled( enable && mDomainCheck->isChecked() );
204 mSpamCheck->setEnabled( enable );
209 #include "vacationdialog.moc"
@ Ok
The user rights/ACL have been fetched from the server sucessfully.