-rw-r--r-- | kmicromail/composemail.cpp | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 976e309..ed8a2ee 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -120,82 +120,91 @@ ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, boo | |||
120 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 120 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
121 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); | 121 | connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) ); |
122 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); | 122 | connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) ); |
123 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 123 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
124 | mMail = 0; | 124 | mMail = 0; |
125 | warnAttach = true; | 125 | warnAttach = true; |
126 | QIconSet icon; | 126 | QIconSet icon; |
127 | //icon = SmallIcon("fileexport"); | 127 | //icon = SmallIcon("fileexport"); |
128 | icon = SmallIcon("filesave"); | 128 | icon = SmallIcon("filesave"); |
129 | SaveButton->setIconSet (icon ) ; | 129 | SaveButton->setIconSet (icon ) ; |
130 | if ( QApplication::desktop()->width() < 320 ) { | 130 | if ( QApplication::desktop()->width() < 320 ) { |
131 | SaveButton->setText ("") ; | 131 | SaveButton->setText ("") ; |
132 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; | 132 | SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ; |
133 | } | 133 | } |
134 | else | 134 | else |
135 | SaveButton->setText (i18n("Save")); | 135 | SaveButton->setText (i18n("Save")); |
136 | #ifndef DESKTOP_VERSION | 136 | #ifndef DESKTOP_VERSION |
137 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); | 137 | QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold ); |
138 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); | 138 | QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold ); |
139 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); | 139 | QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold ); |
140 | #endif | 140 | #endif |
141 | message->setFont ( KOPrefs::instance()->mComposeFont ); | 141 | message->setFont ( KOPrefs::instance()->mComposeFont ); |
142 | message->setWordWrap (QMultiLineEdit::WidgetWidth); | 142 | message->setWordWrap (QMultiLineEdit::WidgetWidth); |
143 | if ( smtpAccounts.count() > 0 ) { | 143 | if ( smtpAccounts.count() > 0 ) { |
144 | fillValues( smtpAccountBox->currentItem() ); | 144 | fillValues( smtpAccountBox->currentItem() ); |
145 | } else { | 145 | } else { |
146 | QMessageBox::information( 0, i18n( "Problem" ), | 146 | QMessageBox::information( 0, i18n( "Problem" ), |
147 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), | 147 | i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ), |
148 | i18n( "Ok" ) ); | 148 | i18n( "Ok" ) ); |
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 151 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
152 | 152 | connect( SaveSigButton, SIGNAL( clicked() ), SLOT( saveSig()) ); | |
153 | if ( smtpAccountBox->count()) | ||
154 | fillValues(0); | ||
153 | 155 | ||
154 | } | 156 | } |
155 | 157 | ||
156 | void ComposeMail::fillSettings() | 158 | void ComposeMail::fillSettings() |
157 | { | 159 | { |
158 | if ( QApplication::desktop()->width() < 320 ) | 160 | if ( QApplication::desktop()->width() < 320 ) |
159 | fromBox->setMaximumWidth( 100 ); | 161 | fromBox->setMaximumWidth( 100 ); |
160 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | 162 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); |
161 | QStringList::ConstIterator sit = mailList.begin(); | 163 | QStringList::ConstIterator sit = mailList.begin(); |
162 | int pref = 0; | 164 | int pref = 0; |
163 | for (;sit!=mailList.end();++sit) { | 165 | for (;sit!=mailList.end();++sit) { |
164 | fromBox->insertItem((*sit)); | 166 | fromBox->insertItem((*sit)); |
165 | } | 167 | } |
166 | senderNameEdit->setText(KOPrefs::instance()->mName); | 168 | senderNameEdit->setText(KOPrefs::instance()->mName); |
167 | } | 169 | } |
168 | 170 | void ComposeMail::saveSig() | |
169 | 171 | { | |
172 | if ( smtpAccountBox->count()) { | ||
173 | int cur = smtpAccountBox->currentItem (); | ||
174 | SMTPaccount *smtp = smtpAccounts.at( cur ); | ||
175 | if ( smtp ) | ||
176 | smtp->setSignature( sigMultiLine->text()); | ||
177 | } | ||
178 | } | ||
170 | void ComposeMail::saveAsDraft() | 179 | void ComposeMail::saveAsDraft() |
171 | { | 180 | { |
172 | 181 | ||
173 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 182 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
174 | mail->setMail(fromBox->currentText()); | 183 | mail->setMail(fromBox->currentText()); |
175 | mail->setTo( toLine->text() ); | 184 | mail->setTo( toLine->text() ); |
176 | mail->setName(senderNameEdit->text()); | 185 | mail->setName(senderNameEdit->text()); |
177 | mail->setCC( ccLine->text() ); | 186 | mail->setCC( ccLine->text() ); |
178 | mail->setBCC( bccLine->text() ); | 187 | mail->setBCC( bccLine->text() ); |
179 | mail->setReply( replyLine->text() ); | 188 | mail->setReply( replyLine->text() ); |
180 | mail->setSubject( subjectLine->text() ); | 189 | mail->setSubject( subjectLine->text() ); |
181 | if (!m_replyid.isEmpty()) { | 190 | if (!m_replyid.isEmpty()) { |
182 | QStringList ids; | 191 | QStringList ids; |
183 | ids.append(m_replyid); | 192 | ids.append(m_replyid); |
184 | mail->setInreply(ids); | 193 | mail->setInreply(ids); |
185 | } | 194 | } |
186 | QString txt = message->text(); | 195 | QString txt = message->text(); |
187 | if ( !sigMultiLine->text().isEmpty() ) { | 196 | if ( !sigMultiLine->text().isEmpty() ) { |
188 | txt.append( "\n--\n" ); | 197 | txt.append( "\n--\n" ); |
189 | txt.append( sigMultiLine->text() ); | 198 | txt.append( sigMultiLine->text() ); |
190 | } | 199 | } |
191 | mail->setMessage( txt ); | 200 | mail->setMessage( txt ); |
192 | mail->setCharset (mEncoding); | 201 | mail->setCharset (mEncoding); |
193 | /* only use the default drafts folder name! */ | 202 | /* only use the default drafts folder name! */ |
194 | Storemail wrapper(AbstractMail::draftFolder()); | 203 | Storemail wrapper(AbstractMail::draftFolder()); |
195 | wrapper.storeMail(mail); | 204 | wrapper.storeMail(mail); |
196 | 205 | ||
197 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); | 206 | AttachViewItem *it = (AttachViewItem *) attList->firstChild(); |
198 | /* attachments we will ignore! */ | 207 | /* attachments we will ignore! */ |
199 | if ( it != 0 ) { | 208 | if ( it != 0 ) { |
200 | if ( warnAttach ) | 209 | if ( warnAttach ) |
201 | QMessageBox::warning(0,i18n("Store message"), | 210 | QMessageBox::warning(0,i18n("Store message"), |
@@ -309,82 +318,84 @@ void ComposeMail::setInReplyTo( const QString & messageId ) | |||
309 | } | 318 | } |
310 | 319 | ||
311 | void ComposeMail::setMessage( const QString & text ) | 320 | void ComposeMail::setMessage( const QString & text ) |
312 | { | 321 | { |
313 | message->setText( text ); | 322 | message->setText( text ); |
314 | } | 323 | } |
315 | 324 | ||
316 | 325 | ||
317 | void ComposeMail::pickAddressTo() | 326 | void ComposeMail::pickAddressTo() |
318 | { | 327 | { |
319 | mPickLineEdit = toLine; | 328 | mPickLineEdit = toLine; |
320 | pickAddress( ); | 329 | pickAddress( ); |
321 | } | 330 | } |
322 | 331 | ||
323 | void ComposeMail::pickAddressCC() | 332 | void ComposeMail::pickAddressCC() |
324 | { | 333 | { |
325 | mPickLineEdit = ccLine; | 334 | mPickLineEdit = ccLine; |
326 | pickAddress( ); | 335 | pickAddress( ); |
327 | } | 336 | } |
328 | 337 | ||
329 | void ComposeMail::pickAddressBCC() | 338 | void ComposeMail::pickAddressBCC() |
330 | { | 339 | { |
331 | mPickLineEdit = bccLine; | 340 | mPickLineEdit = bccLine; |
332 | pickAddress( ); | 341 | pickAddress( ); |
333 | } | 342 | } |
334 | 343 | ||
335 | void ComposeMail::pickAddressReply() | 344 | void ComposeMail::pickAddressReply() |
336 | { | 345 | { |
337 | mPickLineEdit = replyLine; | 346 | mPickLineEdit = replyLine; |
338 | pickAddress( ); | 347 | pickAddress( ); |
339 | } | 348 | } |
340 | 349 | ||
341 | void ComposeMail::fillValues( int ) | 350 | void ComposeMail::fillValues( int current ) |
342 | { | 351 | { |
343 | #if 0 | 352 | #if 0 |
344 | SMTPaccount *smtp = smtpAccounts.at( current ); | 353 | SMTPaccount *smtp = smtpAccounts.at( current ); |
345 | ccLine->clear(); | 354 | ccLine->clear(); |
346 | if ( smtp->getUseCC() ) { | 355 | if ( smtp->getUseCC() ) { |
347 | ccLine->setText( smtp->getCC() ); | 356 | ccLine->setText( smtp->getCC() ); |
348 | } | 357 | } |
349 | bccLine->clear(); | 358 | bccLine->clear(); |
350 | if ( smtp->getUseBCC() ) { | 359 | if ( smtp->getUseBCC() ) { |
351 | bccLine->setText( smtp->getBCC() ); | 360 | bccLine->setText( smtp->getBCC() ); |
352 | } | 361 | } |
353 | replyLine->clear(); | 362 | replyLine->clear(); |
354 | if ( smtp->getUseReply() ) { | 363 | if ( smtp->getUseReply() ) { |
355 | replyLine->setText( smtp->getReply() ); | 364 | replyLine->setText( smtp->getReply() ); |
356 | } | 365 | } |
357 | sigMultiLine->setText( smtp->getSignature() ); | ||
358 | #endif | 366 | #endif |
367 | SMTPaccount *smtp = smtpAccounts.at( current ); | ||
368 | if ( smtp ) | ||
369 | sigMultiLine->setText( smtp->getSignature() ); | ||
359 | } | 370 | } |
360 | 371 | ||
361 | void ComposeMail::slotAdjustColumns() | 372 | void ComposeMail::slotAdjustColumns() |
362 | { | 373 | { |
363 | int currPage = tabWidget->currentPageIndex(); | 374 | int currPage = tabWidget->currentPageIndex(); |
364 | 375 | ||
365 | tabWidget->showPage( attachTab ); | 376 | tabWidget->showPage( attachTab ); |
366 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); | 377 | attList->setColumnWidth( 0, attList->visibleWidth() - 80 ); |
367 | attList->setColumnWidth( 1, 80 ); | 378 | attList->setColumnWidth( 1, 80 ); |
368 | 379 | ||
369 | tabWidget->setCurrentPage( currPage ); | 380 | tabWidget->setCurrentPage( currPage ); |
370 | } | 381 | } |
371 | 382 | ||
372 | void ComposeMail::addAttachment() | 383 | void ComposeMail::addAttachment() |
373 | { | 384 | { |
374 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); | 385 | QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this ); |
375 | if ( !lnk.isEmpty() ) { | 386 | if ( !lnk.isEmpty() ) { |
376 | Attachment *att = new Attachment( lnk ); | 387 | Attachment *att = new Attachment( lnk ); |
377 | (void) new AttachViewItem( attList, att ); | 388 | (void) new AttachViewItem( attList, att ); |
378 | } | 389 | } |
379 | } | 390 | } |
380 | 391 | ||
381 | void ComposeMail::removeAttachment() | 392 | void ComposeMail::removeAttachment() |
382 | { | 393 | { |
383 | if ( !attList->currentItem() ) { | 394 | if ( !attList->currentItem() ) { |
384 | QMessageBox::information( this, i18n( "Error" ), | 395 | QMessageBox::information( this, i18n( "Error" ), |
385 | i18n( "<p>Please select a File.</p>" ), | 396 | i18n( "<p>Please select a File.</p>" ), |
386 | i18n( "Ok" ) ); | 397 | i18n( "Ok" ) ); |
387 | } else { | 398 | } else { |
388 | attList->takeItem( attList->currentItem() ); | 399 | attList->takeItem( attList->currentItem() ); |
389 | } | 400 | } |
390 | } | 401 | } |