summaryrefslogtreecommitdiffabout
path: root/kmicromail/composemail.cpp
Side-by-side diff
Diffstat (limited to 'kmicromail/composemail.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--kmicromail/composemail.cpp21
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
@@ -104,114 +104,123 @@ ComposeMail::ComposeMail( Settings *sett, QWidget *parent, const char *name, boo
attList->addColumn( i18n( "Size" ) );
QList<Account> accounts = settings->getAccounts();
if ( QApplication::desktop()->width() < 320 )
smtpAccountBox->setMaximumWidth( 80 );
Account *it;
for ( it = accounts.first(); it; it = accounts.next() ) {
if ( it->getType()==MAILLIB::A_SMTP ) {
SMTPaccount *smtp = static_cast<SMTPaccount *>(it);
smtpAccountBox->insertItem( smtp->getAccountName() );
smtpAccounts.append( smtp );
}
}
connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) );
connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) );
connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) );
connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) );
connect( addButton, SIGNAL( clicked() ), SLOT( addAttachment() ) );
connect( deleteButton, SIGNAL( clicked() ), SLOT( removeAttachment() ) );
connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) );
mMail = 0;
warnAttach = true;
QIconSet icon;
//icon = SmallIcon("fileexport");
icon = SmallIcon("filesave");
SaveButton->setIconSet (icon ) ;
if ( QApplication::desktop()->width() < 320 ) {
SaveButton->setText ("") ;
SaveButton->setMaximumSize ( SaveButton->sizeHint().height(),SaveButton->sizeHint().height()) ;
}
else
SaveButton->setText (i18n("Save"));
#ifndef DESKTOP_VERSION
QPEApplication::setStylusOperation( message, QPEApplication::RightOnHold );
QPEApplication::setStylusOperation( senderNameEdit, QPEApplication::RightOnHold );
QPEApplication::setStylusOperation( subjectLine, QPEApplication::RightOnHold );
#endif
message->setFont ( KOPrefs::instance()->mComposeFont );
message->setWordWrap (QMultiLineEdit::WidgetWidth);
if ( smtpAccounts.count() > 0 ) {
fillValues( smtpAccountBox->currentItem() );
} else {
QMessageBox::information( 0, i18n( "Problem" ),
i18n( "Please create an\nSMTP account first.\nThe SMTP is needed\nfor sending mail.\n" ),
i18n( "Ok" ) );
return;
}
connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) );
-
+ connect( SaveSigButton, SIGNAL( clicked() ), SLOT( saveSig()) );
+ if ( smtpAccountBox->count())
+ fillValues(0);
}
void ComposeMail::fillSettings()
{
if ( QApplication::desktop()->width() < 320 )
fromBox->setMaximumWidth( 100 );
QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail);
QStringList::ConstIterator sit = mailList.begin();
int pref = 0;
for (;sit!=mailList.end();++sit) {
fromBox->insertItem((*sit));
}
senderNameEdit->setText(KOPrefs::instance()->mName);
}
-
-
+void ComposeMail::saveSig()
+{
+ if ( smtpAccountBox->count()) {
+ int cur = smtpAccountBox->currentItem ();
+ SMTPaccount *smtp = smtpAccounts.at( cur );
+ if ( smtp )
+ smtp->setSignature( sigMultiLine->text());
+ }
+}
void ComposeMail::saveAsDraft()
{
Opie::Core::OSmartPointer<Mail> mail= new Mail();
mail->setMail(fromBox->currentText());
mail->setTo( toLine->text() );
mail->setName(senderNameEdit->text());
mail->setCC( ccLine->text() );
mail->setBCC( bccLine->text() );
mail->setReply( replyLine->text() );
mail->setSubject( subjectLine->text() );
if (!m_replyid.isEmpty()) {
QStringList ids;
ids.append(m_replyid);
mail->setInreply(ids);
}
QString txt = message->text();
if ( !sigMultiLine->text().isEmpty() ) {
txt.append( "\n--\n" );
txt.append( sigMultiLine->text() );
}
mail->setMessage( txt );
mail->setCharset (mEncoding);
/* only use the default drafts folder name! */
Storemail wrapper(AbstractMail::draftFolder());
wrapper.storeMail(mail);
AttachViewItem *it = (AttachViewItem *) attList->firstChild();
/* attachments we will ignore! */
if ( it != 0 ) {
if ( warnAttach )
QMessageBox::warning(0,i18n("Store message"),
i18n("<center>Attachments will not be stored in \"Draft\" folder</center>"));
warnAttach = false;
}
setStatus( i18n("Mail saved as draft!") );
}
void ComposeMail::clearStatus()
{
topLevelWidget()->setCaption( i18n("Compose mail") );
}
void ComposeMail::setStatus( QString status )
{
topLevelWidget()->setCaption( status );
QTimer::singleShot ( 10000, this, SLOT( clearStatus() ) ) ;
}
void ComposeMail::pickAddress( )
{
@@ -293,114 +302,116 @@ void ComposeMail::insertAttendees(const QString& uid,const QStringList& nameLis
}
}
void ComposeMail::setTo( const QString & to )
{
toLine->setText( to );
}
void ComposeMail::setSubject( const QString & subject )
{
subjectLine->setText( subject );
}
void ComposeMail::setInReplyTo( const QString & messageId )
{
m_replyid = messageId;
}
void ComposeMail::setMessage( const QString & text )
{
message->setText( text );
}
void ComposeMail::pickAddressTo()
{
mPickLineEdit = toLine;
pickAddress( );
}
void ComposeMail::pickAddressCC()
{
mPickLineEdit = ccLine;
pickAddress( );
}
void ComposeMail::pickAddressBCC()
{
mPickLineEdit = bccLine;
pickAddress( );
}
void ComposeMail::pickAddressReply()
{
mPickLineEdit = replyLine;
pickAddress( );
}
-void ComposeMail::fillValues( int )
+void ComposeMail::fillValues( int current )
{
#if 0
SMTPaccount *smtp = smtpAccounts.at( current );
ccLine->clear();
if ( smtp->getUseCC() ) {
ccLine->setText( smtp->getCC() );
}
bccLine->clear();
if ( smtp->getUseBCC() ) {
bccLine->setText( smtp->getBCC() );
}
replyLine->clear();
if ( smtp->getUseReply() ) {
replyLine->setText( smtp->getReply() );
}
- sigMultiLine->setText( smtp->getSignature() );
#endif
+ SMTPaccount *smtp = smtpAccounts.at( current );
+ if ( smtp )
+ sigMultiLine->setText( smtp->getSignature() );
}
void ComposeMail::slotAdjustColumns()
{
int currPage = tabWidget->currentPageIndex();
tabWidget->showPage( attachTab );
attList->setColumnWidth( 0, attList->visibleWidth() - 80 );
attList->setColumnWidth( 1, 80 );
tabWidget->setCurrentPage( currPage );
}
void ComposeMail::addAttachment()
{
QString lnk = KFileDialog::getOpenFileName( "", "Add Attachment", this );
if ( !lnk.isEmpty() ) {
Attachment *att = new Attachment( lnk );
(void) new AttachViewItem( attList, att );
}
}
void ComposeMail::removeAttachment()
{
if ( !attList->currentItem() ) {
QMessageBox::information( this, i18n( "Error" ),
i18n( "<p>Please select a File.</p>" ),
i18n( "Ok" ) );
} else {
attList->takeItem( attList->currentItem() );
}
}
void ComposeMail::accept()
{
if ( smtpAccountBox->count() == 0 ) {
reject();
return;
}
if (! checkBoxLater->isChecked() ) {
int yesno = QMessageBox::warning(0,i18n("Stop editing message"),
i18n("Send this message?"),
i18n("Yes"),
i18n("Cancel"));
if (yesno == 1) {