summaryrefslogtreecommitdiff
path: root/noncore/unsupported/mail2/composerbase.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/mail2/composerbase.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/mail2/composerbase.cpp199
1 files changed, 199 insertions, 0 deletions
diff --git a/noncore/unsupported/mail2/composerbase.cpp b/noncore/unsupported/mail2/composerbase.cpp
new file mode 100644
index 0000000..7754863
--- a/dev/null
+++ b/noncore/unsupported/mail2/composerbase.cpp
@@ -0,0 +1,199 @@
1#include <qmultilineedit.h>
2#include <qpopupmenu.h>
3#include <qcombobox.h>
4#include <qlineedit.h>
5#include <qtoolbar.h>
6#include <qlayout.h>
7#include <qaction.h>
8#include <qlabel.h>
9#include <qvbox.h>
10
11#include <qpe/resource.h>
12
13#include "listviewplus.h"
14#include "composerbase.h"
15
16ComposerBase::ComposerBase(QWidget *parent, const char *name, WFlags fl)
17 : QMainWindow(parent, name, fl)
18{
19 setCaption(tr("Compose Message"));
20 setToolBarsMovable(false);
21
22 toolbar = new QToolBar(this);
23 addToolBar(toolbar);
24 toolbar->setHorizontalStretchable(true);
25
26 sendmail = new QAction(tr("Send the mail"), QIconSet(Resource::loadPixmap("mail/sendmail")), 0, 0, this);
27 sendmail->addTo(toolbar);
28
29 attachfile = new QAction(tr("Attach a file"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true);
30 attachfile->addTo(toolbar);
31 connect(attachfile, SIGNAL(toggled(bool)), SLOT(slotAttachfileChanged(bool)));
32
33 addressbook = new QAction(tr("Addressbook"), QIconSet(Resource::loadPixmap("mail/addbook")), 0, 0, this);
34 addressbook->addTo(toolbar);
35
36 QLabel *spacer = new QLabel(toolbar);
37 spacer->setBackgroundMode(QWidget::PaletteButton);
38 toolbar->setStretchableWidget(spacer);
39
40 abort = new QAction(tr("Abort sending"), QIconSet(Resource::loadPixmap("mail/abort")), 0, 0, this);
41 abort->addTo(toolbar);
42
43 QWidget *main = new QWidget(this);
44 setCentralWidget(main);
45
46 QGridLayout *layout = new QGridLayout(main);
47
48 fromBox = new QComboBox(main);
49 fromBox->insertItem(tr("From"), POPUP_FROM_FROM);
50 fromBox->insertItem(tr("Reply"), POPUP_FROM_REPLYTO);
51 layout->addWidget(fromBox, 0, 0);
52
53 connect(fromBox, SIGNAL(activated(int)), SLOT(slotFromMenuChanged(int)));
54
55 QHBoxLayout *fromLayout = new QHBoxLayout();
56 layout->addLayout(fromLayout, 0, 1);
57
58 from = new QComboBox(main);
59 fromLayout->addWidget(from);
60
61 replyto = new QLineEdit(main);
62 replyto->hide();
63 fromLayout->addWidget(replyto);
64
65 receiversBox = new QComboBox(main);
66 receiversBox->insertItem(tr("To"), POPUP_RECV_TO);
67 receiversBox->insertItem(tr("Cc"), POPUP_RECV_CC);
68 receiversBox->insertItem(tr("Bcc"), POPUP_RECV_BCC);
69 layout->addWidget(receiversBox, 1, 0);
70
71 connect(receiversBox, SIGNAL(activated(int)), SLOT(slotReceiverMenuChanged(int)));
72
73 QHBoxLayout *receiverLayout = new QHBoxLayout();
74 layout->addLayout(receiverLayout, 1, 1);
75
76 to = new QLineEdit(main);
77 receiverLayout->addWidget(to);
78
79 cc = new QLineEdit(main);
80 cc->hide();
81 receiverLayout->addWidget(cc);
82
83 bcc = new QLineEdit(main);
84 bcc->hide();
85 receiverLayout->addWidget(bcc);
86
87 subjectBox = new QComboBox(main);
88 subjectBox->insertItem(tr("Subj."), POPUP_SUBJ_SUBJECT);
89 subjectBox->insertItem(tr("Prio."), POPUP_SUBJ_PRIORITY);
90 layout->addWidget(subjectBox, 2, 0);
91 connect(subjectBox, SIGNAL(activated(int)), SLOT(slotSubjectMenuChanged(int)));
92
93 QHBoxLayout *subjectLayout = new QHBoxLayout();
94 layout->addLayout(subjectLayout, 2, 1);
95
96 subject = new QLineEdit(main);
97 subjectLayout->addWidget(subject);
98
99 priority = new QComboBox(main);
100 priority->insertItem(tr("Low"), POPUP_PRIO_LOW);
101 priority->insertItem(tr("Normal"), POPUP_PRIO_NORMAL);
102 priority->insertItem(tr("High"), POPUP_PRIO_HIGH);
103 priority->setCurrentItem(POPUP_PRIO_NORMAL);
104 priority->hide();
105 subjectLayout->addWidget(priority);
106
107 QVBox *view = new QVBox(main);
108 layout->addMultiCellWidget(view, 3, 3, 0, 1);
109
110 message = new QMultiLineEdit(view);
111 message->setMinimumHeight(30);
112
113 attachWindow = new QMainWindow(view, 0, 0);
114 attachWindow->setMinimumHeight(100);
115 attachWindow->setMaximumHeight(100);
116 attachWindow->setToolBarsMovable(false);
117 attachWindow->hide();
118
119 attachToolbar = new QToolBar(attachWindow);
120 attachToolbar->setVerticalStretchable(true);
121
122 addattach = new QAction(tr("Add an Attachement"), QIconSet(Resource::loadPixmap("mail/newmail")), 0, 0, this);
123 addattach->addTo(attachToolbar);
124
125 delattach = new QAction(tr("Remove Attachement"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this);
126 delattach->addTo(attachToolbar);
127
128 QLabel *attachSpacer = new QLabel(attachToolbar);
129 attachSpacer->setBackgroundMode(QWidget::PaletteButton);
130 attachToolbar->setStretchableWidget(attachSpacer);
131
132 attachWindow->addToolBar(attachToolbar, QMainWindow::Left);
133
134 attachView = new ListViewPlus(attachWindow);
135 attachView->addColumn(tr("Name"), 80);
136 attachView->addColumn(tr("Description"), 110);
137 attachView->setAllColumnsShowFocus(true);
138 attachWindow->setCentralWidget(attachView);
139
140 attachPopup = new QPopupMenu(attachView);
141 attachPopup->insertItem(tr("Rename"), POPUP_ATTACH_RENAME);
142 attachPopup->insertItem(tr("Change Description"), POPUP_ATTACH_DESC);
143 attachPopup->insertSeparator();
144 attachPopup->insertItem(tr("Remove"), POPUP_ATTACH_REMOVE);
145 attachView->setPopup(attachPopup);
146
147 status = new QLabel(view);
148 QFont tmpFont = status->font();
149 tmpFont.setPixelSize(8);
150 status->setFont(tmpFont);
151}
152
153void ComposerBase::slotAttachfileChanged(bool toggled)
154{
155 if (toggled) {
156 if (attachWindow->isHidden()) attachWindow->show();
157 } else {
158 if (!attachWindow->isHidden()) attachWindow->hide();
159 }
160}
161
162void ComposerBase::slotFromMenuChanged(int id)
163{
164 if (POPUP_FROM_FROM == id) {
165 if (from->isHidden()) from->show();
166 if (!replyto->isHidden()) replyto->hide();
167 } else if (POPUP_FROM_REPLYTO == id) {
168 if (!from->isHidden()) from->hide();
169 if (replyto->isHidden()) replyto->show();
170 }
171}
172
173void ComposerBase::slotReceiverMenuChanged(int id)
174{
175 if (POPUP_RECV_TO == id) {
176 if (to->isHidden()) to->show();
177 if (!cc->isHidden()) cc->hide();
178 if (!bcc->isHidden()) bcc->hide();
179 } else if (POPUP_RECV_CC == id) {
180 if (!to->isHidden()) to->hide();
181 if (cc->isHidden()) cc->show();
182 if (!bcc->isHidden()) bcc->hide();
183 } else if (POPUP_RECV_BCC == id) {
184 if (!to->isHidden()) to->hide();
185 if (!cc->isHidden()) cc->hide();
186 if (bcc->isHidden()) bcc->show();
187 }
188}
189
190void ComposerBase::slotSubjectMenuChanged(int id)
191{
192 if (POPUP_SUBJ_SUBJECT == id) {
193 if (subject->isHidden()) subject->show();
194 if (!priority->isHidden()) priority->hide();
195 } else if (POPUP_SUBJ_PRIORITY == id) {
196 if (!subject->isHidden()) subject->hide();
197 if (priority->isHidden()) priority->show();
198 }
199}