-rw-r--r-- | kmicromail/composemail.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/kmicromail/composemail.cpp b/kmicromail/composemail.cpp index 9b799b3..e6f7daa 100644 --- a/kmicromail/composemail.cpp +++ b/kmicromail/composemail.cpp | |||
@@ -3,99 +3,105 @@ | |||
3 | #include "composemail.h" | 3 | #include "composemail.h" |
4 | 4 | ||
5 | #include <libmailwrapper/smtpwrapper.h> | 5 | #include <libmailwrapper/smtpwrapper.h> |
6 | #include <libmailwrapper/storemail.h> | 6 | #include <libmailwrapper/storemail.h> |
7 | #include <libmailwrapper/abstractmail.h> | 7 | #include <libmailwrapper/abstractmail.h> |
8 | #include <libmailwrapper/mailtypes.h> | 8 | #include <libmailwrapper/mailtypes.h> |
9 | 9 | ||
10 | /* OPIE */ | 10 | /* OPIE */ |
11 | //#include <opie2/ofiledialog.h> | 11 | //#include <opie2/ofiledialog.h> |
12 | //#include <opie2/odebug.h> | 12 | //#include <opie2/odebug.h> |
13 | #include <kfiledialog.h> | 13 | #include <kfiledialog.h> |
14 | //#include <qpe/resource.h> | 14 | //#include <qpe/resource.h> |
15 | #include <qpe/config.h> | ||
16 | #include <qpe/global.h> | 15 | #include <qpe/global.h> |
17 | //#include <qpe/contact.h> | 16 | //#include <qpe/contact.h> |
18 | 17 | ||
19 | 18 | ||
20 | #include <qcombobox.h> | 19 | #include <qcombobox.h> |
21 | #include <qcheckbox.h> | 20 | #include <qcheckbox.h> |
22 | #include <qtimer.h> | 21 | #include <qtimer.h> |
23 | #include <qmessagebox.h> | 22 | #include <qmessagebox.h> |
24 | #include <qpushbutton.h> | 23 | #include <qpushbutton.h> |
25 | #include <qmultilineedit.h> | 24 | #include <qmultilineedit.h> |
26 | #include <qlabel.h> | 25 | #include <qlabel.h> |
27 | #include <qtabwidget.h> | 26 | #include <qtabwidget.h> |
28 | #include <qlistview.h> | 27 | #include <qlistview.h> |
29 | #include <kabc/addresseedialog.h> | 28 | #include <kabc/addresseedialog.h> |
30 | #include <kabc/stdaddressbook.h> | 29 | #include <kabc/stdaddressbook.h> |
31 | #include <kabc/addressee.h> | 30 | #include <kabc/addressee.h> |
32 | #ifdef DESKTOP_VERSION | 31 | #ifdef DESKTOP_VERSION |
33 | #include <kabc/addresseedialog.h> | 32 | #include <kabc/addresseedialog.h> |
34 | #else //DESKTOP_VERSION | 33 | #else //DESKTOP_VERSION |
35 | #include <libkdepim/externalapphandler.h> | 34 | #include <libkdepim/externalapphandler.h> |
36 | #endif //DESKTOP_VERSION | 35 | #endif //DESKTOP_VERSION |
37 | 36 | ||
37 | #include "koprefs.h" | ||
38 | 38 | ||
39 | //using namespace Opie::Core; | 39 | //using namespace Opie::Core; |
40 | //using namespace Opie::Ui; | 40 | //using namespace Opie::Ui; |
41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) | 41 | ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool modal ) |
42 | : ComposeMailUI( parent, name, modal ) | 42 | : ComposeMailUI( parent, name, modal ) |
43 | { | 43 | { |
44 | |||
45 | mPickLineEdit = 0; | 44 | mPickLineEdit = 0; |
46 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), | 45 | connect(ExternalAppHandler::instance(), SIGNAL(receivedNameEmailUidListEvent(const QString&, const QStringList&, const QStringList&, const QStringList&)), |
47 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); | 46 | this, SLOT(insertAttendees(const QString&, const QStringList&, const QStringList&, const QStringList&))); |
48 | settings = s; | 47 | settings = s; |
49 | m_replyid = ""; | 48 | m_replyid = ""; |
49 | if ( KOPrefs::instance()->mUseKapi) { | ||
50 | KConfig config( locateLocal("config", "kabcrc") ); | 50 | KConfig config( locateLocal("config", "kabcrc") ); |
51 | config.setGroup( "General" ); | 51 | config.setGroup( "General" ); |
52 | QString whoami_uid = config.readEntry( "WhoAmI" ); | 52 | QString whoami_uid = config.readEntry( "WhoAmI" ); |
53 | 53 | ||
54 | if ( whoami_uid.isEmpty() ) { | 54 | if ( whoami_uid.isEmpty() ) { |
55 | QMessageBox::information( 0, tr( "Hint" ), | 55 | QMessageBox::information( 0, tr( "Hint" ), |
56 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 56 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
57 | tr( "Ok" ) ); | 57 | tr( "Ok" ) ); |
58 | 58 | ||
59 | |||
60 | fillSettings(); | ||
59 | } else | 61 | } else |
60 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); | 62 | ExternalAppHandler::instance()->requestDetailsFromKAPI("", "sendbacklist", whoami_uid); |
61 | 63 | ||
62 | 64 | ||
63 | #ifdef DESKTOP_VERSION | 65 | #ifdef DESKTOP_VERSION |
64 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); | 66 | KABC::Addressee con = KABC::StdAddressBook::self()->whoAmI( ); |
65 | QStringList mails = con.emails(); | 67 | QStringList mails = con.emails(); |
66 | QString defmail = con.preferredEmail(); | 68 | QString defmail = con.preferredEmail(); |
67 | if ( mails.count() == 0) | 69 | if ( mails.count() == 0) |
68 | QMessageBox::information( 0, tr( "Hint" ), | 70 | QMessageBox::information( 0, tr( "Hint" ), |
69 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), | 71 | tr( "Please apply\n\"Set Who Am I\"\nin KA/Pi to get the from\nfield automatically filled out!\n" ), |
70 | tr( "Ok" ) ); | 72 | tr( "Ok" ) ); |
71 | if (defmail.length()!=0) { | 73 | if (defmail.length()!=0) { |
72 | fromBox->insertItem(defmail); | 74 | fromBox->insertItem(defmail); |
73 | } | 75 | } |
74 | QStringList::ConstIterator sit = mails.begin(); | 76 | QStringList::ConstIterator sit = mails.begin(); |
75 | for (;sit!=mails.end();++sit) { | 77 | for (;sit!=mails.end();++sit) { |
76 | if ( (*sit)==defmail) | 78 | if ( (*sit)==defmail) |
77 | continue; | 79 | continue; |
78 | fromBox->insertItem((*sit)); | 80 | fromBox->insertItem((*sit)); |
79 | } | 81 | } |
80 | senderNameEdit->setText(con.formattedName()); | 82 | senderNameEdit->setText(con.formattedName()); |
81 | #endif | 83 | #endif |
82 | Config cfg( "mail" ); | 84 | |
83 | cfg.setGroup( "Compose" ); | 85 | } else { |
84 | checkBoxLater->setChecked( cfg.readBoolEntry( "sendLater", false ) ); | 86 | fillSettings(); |
87 | } | ||
88 | checkBoxLater->setChecked( KOPrefs::instance()->mSendLater ); | ||
85 | 89 | ||
86 | attList->addColumn( tr( "Name" ) ); | 90 | attList->addColumn( tr( "Name" ) ); |
87 | attList->addColumn( tr( "Size" ) ); | 91 | attList->addColumn( tr( "Size" ) ); |
88 | QList<Account> accounts = settings->getAccounts(); | 92 | QList<Account> accounts = settings->getAccounts(); |
89 | 93 | ||
94 | if ( QApplication::desktop()->width() < 320 ) | ||
95 | smtpAccountBox->setMaximumWidth( 80 ); | ||
90 | Account *it; | 96 | Account *it; |
91 | for ( it = accounts.first(); it; it = accounts.next() ) { | 97 | for ( it = accounts.first(); it; it = accounts.next() ) { |
92 | if ( it->getType()==MAILLIB::A_SMTP ) { | 98 | if ( it->getType()==MAILLIB::A_SMTP ) { |
93 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); | 99 | SMTPaccount *smtp = static_cast<SMTPaccount *>(it); |
94 | smtpAccountBox->insertItem( smtp->getAccountName() ); | 100 | smtpAccountBox->insertItem( smtp->getAccountName() ); |
95 | smtpAccounts.append( smtp ); | 101 | smtpAccounts.append( smtp ); |
96 | } | 102 | } |
97 | } | 103 | } |
98 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); | 104 | connect( toButton, SIGNAL( clicked() ), SLOT( pickAddressTo() ) ); |
99 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); | 105 | connect( ccButton, SIGNAL( clicked() ), SLOT( pickAddressCC() ) ); |
100 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); | 106 | connect( bccButton, SIGNAL( clicked() ), SLOT( pickAddressBCC() ) ); |
101 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); | 107 | connect( replyButton, SIGNAL( clicked() ), SLOT( pickAddressReply() ) ); |
@@ -104,27 +110,39 @@ ComposeMail::ComposeMail( Settings *s, QWidget *parent, const char *name, bool m | |||
104 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); | 110 | connect( SaveButton, SIGNAL( clicked() ), SLOT( saveAsDraft()) ); |
105 | mMail = 0; | 111 | mMail = 0; |
106 | warnAttach = true; | 112 | warnAttach = true; |
107 | if ( smtpAccounts.count() > 0 ) { | 113 | if ( smtpAccounts.count() > 0 ) { |
108 | fillValues( smtpAccountBox->currentItem() ); | 114 | fillValues( smtpAccountBox->currentItem() ); |
109 | } else { | 115 | } else { |
110 | QMessageBox::information( 0, tr( "Problem" ), | 116 | QMessageBox::information( 0, tr( "Problem" ), |
111 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), | 117 | tr( "Please create an SMTP account first.\nThe SMTP is needed for sending mail.\n" ), |
112 | tr( "Ok" ) ); | 118 | tr( "Ok" ) ); |
113 | return; | 119 | return; |
114 | } | 120 | } |
115 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); | 121 | connect( smtpAccountBox, SIGNAL( activated(int) ), SLOT( fillValues(int) ) ); |
116 | 122 | message->setFont ( KOPrefs::instance()->mComposeFont ); | |
117 | } | 123 | } |
118 | 124 | ||
125 | void ComposeMail::fillSettings() | ||
126 | { | ||
127 | if ( QApplication::desktop()->width() < 320 ) | ||
128 | fromBox->setMaximumWidth( 100 ); | ||
129 | QStringList mailList = QStringList::split(";",KOPrefs::instance()->mEmail); | ||
130 | QStringList::ConstIterator sit = mailList.begin(); | ||
131 | int pref = 0; | ||
132 | for (;sit!=mailList.end();++sit) { | ||
133 | fromBox->insertItem((*sit)); | ||
134 | } | ||
135 | senderNameEdit->setText(KOPrefs::instance()->mName); | ||
136 | } | ||
119 | 137 | ||
120 | 138 | ||
121 | void ComposeMail::saveAsDraft() | 139 | void ComposeMail::saveAsDraft() |
122 | { | 140 | { |
123 | 141 | ||
124 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); | 142 | Opie::Core::OSmartPointer<Mail> mail= new Mail(); |
125 | mail->setMail(fromBox->currentText()); | 143 | mail->setMail(fromBox->currentText()); |
126 | mail->setTo( toLine->text() ); | 144 | mail->setTo( toLine->text() ); |
127 | mail->setName(senderNameEdit->text()); | 145 | mail->setName(senderNameEdit->text()); |
128 | mail->setCC( ccLine->text() ); | 146 | mail->setCC( ccLine->text() ); |
129 | mail->setBCC( bccLine->text() ); | 147 | mail->setBCC( bccLine->text() ); |
130 | mail->setReply( replyLine->text() ); | 148 | mail->setReply( replyLine->text() ); |