author | harlekin <harlekin> | 2003-12-20 00:05:37 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-12-20 00:05:37 (UTC) |
commit | dc088ad432189b4883f7654ef6b2c1e2f69112cc (patch) (side-by-side diff) | |
tree | 090f6afd960e644d7da1fae3b8c8ffa97b669b59 | |
parent | 00a0c8cf03fe746c1e3ba608bf298c8e66d065f9 (diff) | |
download | opie-dc088ad432189b4883f7654ef6b2c1e2f69112cc.zip opie-dc088ad432189b4883f7654ef6b2c1e2f69112cc.tar.gz opie-dc088ad432189b4883f7654ef6b2c1e2f69112cc.tar.bz2 |
- beginning of a settings dialog
- button for switching between html and plain text view of the mail
- hide some unused icons
- completed alwins idea about status icons ( alwin you missed the one that sets the read icon .-) )
- beginning of a status widget
-
-rw-r--r-- | noncore/net/mail/mail.pro | 12 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.cpp | 20 | ||||
-rw-r--r-- | noncore/net/mail/mainwindow.h | 3 | ||||
-rw-r--r-- | noncore/net/mail/opiemail.cpp | 2 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.cpp | 21 | ||||
-rw-r--r-- | noncore/net/mail/viewmail.h | 5 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.cpp | 5 | ||||
-rw-r--r-- | noncore/net/mail/viewmailbase.h | 3 |
8 files changed, 64 insertions, 7 deletions
diff --git a/noncore/net/mail/mail.pro b/noncore/net/mail/mail.pro index d058db7..49be889 100644 --- a/noncore/net/mail/mail.pro +++ b/noncore/net/mail/mail.pro @@ -1,58 +1,64 @@ CONFIG += qt warn_on debug quick-app HEADERS = defines.h \ logindialog.h \ settings.h \ editaccounts.h \ mailwrapper.h \ composemail.h \ accountview.h \ mainwindow.h \ viewmail.h \ viewmailbase.h \ opiemail.h \ imapwrapper.h \ mailtypes.h \ mailistviewitem.h \ pop3wrapper.h \ - abstractmail.h + abstractmail.h \ + settingsdialog.h \ + statuswidget.h SOURCES = main.cpp \ opiemail.cpp \ mainwindow.cpp \ accountview.cpp \ composemail.cpp \ mailwrapper.cpp \ imapwrapper.cpp \ addresspicker.cpp \ editaccounts.cpp \ logindialog.cpp \ viewmail.cpp \ viewmailbase.cpp \ settings.cpp \ mailtypes.cpp \ pop3wrapper.cpp \ - abstractmail.cpp + abstractmail.cpp \ + settingsdialog.cpp \ + statuswidget.cpp INTERFACES = editaccountsui.ui \ selectmailtypeui.ui \ imapconfigui.ui \ pop3configui.ui \ nntpconfigui.ui \ smtpconfigui.ui \ addresspickerui.ui \ logindialogui.ui \ - composemailui.ui + composemailui.ui \ + settingsdialogui.ui \ + statuswidgetui.ui INCLUDEPATH += $(OPIEDIR)/include CONFTEST = $$system( echo $CONFIG_TARGET_MACOSX ) contains( CONFTEST, y ){ LIBS += -lqpe -letpan -lssl -lcrypto -lopie -liconv }else{ LIBS += -lqpe -letpan -lssl -lcrypto -lopie } TARGET = opiemail include ( $(OPIEDIR)/include.pro ) diff --git a/noncore/net/mail/mainwindow.cpp b/noncore/net/mail/mainwindow.cpp index 9a37510..d3b9c34 100644 --- a/noncore/net/mail/mainwindow.cpp +++ b/noncore/net/mail/mainwindow.cpp @@ -1,206 +1,224 @@ #include <qlabel.h> #include <qvbox.h> #include <qheader.h> #include <qtimer.h> #include <qlayout.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include "defines.h" #include "mainwindow.h" +#include "settingsdialog.h" #include "viewmail.h" #include "mailtypes.h" #include "mailistviewitem.h" + MainWindow::MainWindow( QWidget *parent, const char *name, WFlags flags ) : QMainWindow( parent, name, flags ) { setCaption( tr( "Mail" ) ); setToolBarsMovable( false ); toolBar = new QToolBar( this ); menuBar = new QMenuBar( toolBar ); mailMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Mail" ), mailMenu ); settingsMenu = new QPopupMenu( menuBar ); menuBar->insertItem( tr( "Settings" ), settingsMenu ); addToolBar( toolBar ); toolBar->setHorizontalStretchable( true ); QLabel *spacer = new QLabel( toolBar ); spacer->setBackgroundMode( QWidget::PaletteButton ); toolBar->setStretchableWidget( spacer ); composeMail = new QAction( tr( "Compose new mail" ), ICON_COMPOSEMAIL, 0, 0, this ); composeMail->addTo( toolBar ); composeMail->addTo( mailMenu ); sendQueued = new QAction( tr( "Send queued mails" ), ICON_SENDQUEUED, 0, 0, this ); sendQueued->addTo( toolBar ); sendQueued->addTo( mailMenu ); + /* syncFolders = new QAction( tr( "Sync mailfolders" ), ICON_SYNC, 0, 0, this ); syncFolders->addTo( toolBar ); syncFolders->addTo( mailMenu ); + */ showFolders = new QAction( tr( "Show/Hide folders" ), ICON_SHOWFOLDERS, 0, 0, this, 0, true ); showFolders->addTo( toolBar ); showFolders->addTo( mailMenu ); showFolders->setOn( true ); connect(showFolders, SIGNAL( toggled( bool ) ), SLOT( slotShowFolders( bool ) ) ); + /* searchMails = new QAction( tr( "Search mails" ), ICON_SEARCHMAILS, 0, 0, this ); searchMails->addTo( toolBar ); searchMails->addTo( mailMenu ); + */ deleteMails = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); deleteMails->addTo( toolBar ); deleteMails->addTo( mailMenu ); connect( deleteMails, SIGNAL( activated() ), SLOT( slotDeleteMail() ) ); editSettings = new QAction( tr( "Edit settings" ), ICON_EDITSETTINGS, 0, 0, this ); editSettings->addTo( settingsMenu ); + connect( editSettings, SIGNAL( activated() ), + SLOT( slotEditSettings() ) ); editAccounts = new QAction( tr( "Configure accounts" ), ICON_EDITACCOUNTS, 0, 0, this ); editAccounts->addTo( settingsMenu ); QWidget *view = new QWidget( this ); setCentralWidget( view ); layout = new QBoxLayout ( view, QBoxLayout::LeftToRight ); folderView = new AccountView( view ); folderView->header()->hide(); folderView->setRootIsDecorated( true ); folderView->addColumn( tr( "Mailbox" ) ); //folderView->hide(); layout->addWidget( folderView ); mailView = new QListView( view ); mailView->addColumn( tr( "" ) ); mailView->addColumn( tr( "Subject" ),QListView::Manual ); mailView->addColumn( tr( "Sender" ),QListView::Manual ); mailView->addColumn( tr( "Size" ),QListView::Manual); mailView->addColumn( tr( "Date" )); mailView->setAllColumnsShowFocus(true); mailView->setSorting(-1); + statusWidget = new StatusWidget( view ); + layout->addWidget( mailView ); + layout->addWidget( statusWidget ); layout->setStretchFactor( folderView, 1 ); layout->setStretchFactor( mailView, 2 ); + slotAdjustLayout(); connect( mailView, SIGNAL( clicked( QListViewItem * ) ),this, SLOT( displayMail( QListViewItem * ) ) ); connect(folderView, SIGNAL(refreshMailview(QList<RecMail>*)),this,SLOT(refreshMailView(QList<RecMail>*))); QTimer::singleShot( 1000, this, SLOT( slotAdjustColumns() ) ); } void MainWindow::slotAdjustLayout() { QWidget *d = QApplication::desktop(); if ( d->width() < d->height() ) { layout->setDirection( QBoxLayout::TopToBottom ); } else { layout->setDirection( QBoxLayout::LeftToRight ); } delete d; } void MainWindow::slotAdjustColumns() { bool hidden = folderView->isHidden(); if ( hidden ) folderView->show(); folderView->setColumnWidth( 0, folderView->visibleWidth() ); if ( hidden ) folderView->hide(); mailView->setColumnWidth( 0, 10 ); mailView->setColumnWidth( 1, mailView->visibleWidth() - 130 ); mailView->setColumnWidth( 2, 80 ); mailView->setColumnWidth( 3, 50 ); mailView->setColumnWidth( 4, 50 ); } +void MainWindow::slotEditSettings() { + SettingsDialog settingsDialog( this, 0, true ); + settingsDialog.showMaximized(); + settingsDialog.exec(); +} + void MainWindow::slotShowFolders( bool show ) { qDebug( "Show Folders" ); if ( show && folderView->isHidden() ) { qDebug( "-> showing" ); folderView->show(); } else if ( !show && !folderView->isHidden() ) { qDebug( "-> hiding" ); folderView->hide(); } } void MainWindow::refreshMailView(QList<RecMail>*list) { MailListViewItem*item = 0; mailView->clear(); for (unsigned int i = 0; i < list->count();++i) { item = new MailListViewItem(mailView,item); item->storeData(*(list->at(i))); item->showEntry(); } } void MainWindow::displayMail(QListViewItem*item) { if (!item) return; RecMail mail = ((MailListViewItem*)item)->data(); RecBody body = folderView->fetchBody(mail); ViewMail readMail( this ); readMail.setBody( body ); readMail.setMail( mail ); readMail.showMaximized(); readMail.exec(); if ( readMail.deleted ) { folderView->refreshCurrent(); } else { - ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "mail/kmmsgunseen") ); + ( (MailListViewItem*)item )->setPixmap( 0, Resource::loadPixmap( "") ); } } void MainWindow::slotDeleteMail() { if (!mailView->currentItem()) return; RecMail mail = ((MailListViewItem*)mailView->currentItem() )->data(); if ( QMessageBox::warning(this, tr("Delete Mail"), QString( tr("<p>Do you really want to delete this mail? <br><br>" ) + mail.getFrom() + " - " + mail.getSubject() ) , QMessageBox::Yes, QMessageBox::No ) == QMessageBox::Yes ) { mail.Wrapper()->deleteMail( mail ); folderView->refreshCurrent(); } } MailListViewItem::MailListViewItem(QListView * parent, MailListViewItem * item ) :QListViewItem(parent,item),mail_data() { } void MailListViewItem::showEntry() { if ( mail_data.getFlags().testBit( FLAG_ANSWERED ) == true) { setPixmap( 0, Resource::loadPixmap( "mail/kmmsgreplied") ); diff --git a/noncore/net/mail/mainwindow.h b/noncore/net/mail/mainwindow.h index 21af190..4e4f4bb 100644 --- a/noncore/net/mail/mainwindow.h +++ b/noncore/net/mail/mainwindow.h @@ -1,43 +1,46 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> #include <qlistview.h> #include <qaction.h> #include <qtoolbar.h> #include <qmenubar.h> #include "accountview.h" +#include "statuswidget.h" class RecMail; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags flags = 0 ); public slots: void slotAdjustColumns(); protected slots: virtual void slotShowFolders( bool show ); virtual void refreshMailView(QList<RecMail>*); virtual void displayMail(QListViewItem*); virtual void slotDeleteMail(); void slotAdjustLayout(); + void slotEditSettings(); protected: QToolBar *toolBar; + StatusWidget *statusWidget; QMenuBar *menuBar; QPopupMenu *mailMenu, *settingsMenu; QAction *composeMail, *sendQueued, *showFolders, *searchMails, *deleteMails, *editSettings, *editAccounts, *syncFolders; AccountView *folderView; QListView *mailView; QBoxLayout *layout; }; #endif diff --git a/noncore/net/mail/opiemail.cpp b/noncore/net/mail/opiemail.cpp index 740e4cf..7ab4e0d 100644 --- a/noncore/net/mail/opiemail.cpp +++ b/noncore/net/mail/opiemail.cpp @@ -1,38 +1,38 @@ #include "opiemail.h" #include "editaccounts.h" #include "composemail.h" OpieMail::OpieMail( QWidget *parent, const char *name, WFlags flags ) : MainWindow( parent, name, flags ) { settings = new Settings(); folderView->populate( settings->getAccounts() ); connect( composeMail, SIGNAL( activated() ), SLOT( slotComposeMail() ) ); connect( sendQueued, SIGNAL( activated() ), SLOT( slotSendQueued() ) ); - connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); +// connect( searchMails, SIGNAL( activated() ), SLOT( slotSearchMails() ) ); connect( editSettings, SIGNAL( activated() ), SLOT( slotEditSettings() ) ); connect( editAccounts, SIGNAL( activated() ), SLOT( slotEditAccounts() ) ); } void OpieMail::slotComposeMail() { qDebug( "Compose Mail" ); ComposeMail compose( settings, this, 0 , true ); compose.showMaximized(); compose.slotAdjustColumns(); compose.exec(); } void OpieMail::slotSendQueued() { qDebug( "Send Queued" ); } void OpieMail::slotSearchMails() { qDebug( "Search Mails" ); } void OpieMail::slotEditSettings() diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index d86454c..e11fe1f 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -1,32 +1,34 @@ #include <qtextbrowser.h> #include <qmessagebox.h> #include <qtextstream.h> #include <qaction.h> #include <qpopupmenu.h> #include <qfile.h> #include <qapplication.h> +#include <qpe/config.h> + #include <opie/ofiledialog.h> #include "settings.h" #include "composemail.h" #include "viewmail.h" #include "abstractmail.h" #include "accountview.h" #include "mailtypes.h" AttachItem::AttachItem(QListView * parent,QListViewItem *after, const QString&mime,const QString&desc,const QString&file, const QString&fsize,int num) : QListViewItem(parent,after),_partNum(num) { setText(0, mime); setText(1, desc); setText(2, file); setText(3, fsize); } void ViewMail::setBody( RecBody body ) { m_body = body; m_mail[2] = body.Bodytext(); attachbutton->setEnabled(body.Parts().count()>0); @@ -88,48 +90,54 @@ for (unsigned int i = 0; i < body.Parts().count();++i) { s/=1024; ++w; if (w>=2) break; } switch(w) { case 1: q="k"; break; case 2: q="M"; break; default: q=""; break; } QTextOStream o(&fsize); if (w>0) o.precision(2); else o.precision(0); o.setf(QTextStream::fixed); o << s << " " << q << "Byte"; desc = body.Parts()[i].Description(); curItem=new AttachItem(attachments,curItem,type,desc,filename,fsize,i); } } + +void ViewMail::slotShowHtml( bool state ) { + m_showHtml = state; + setText(); +} + void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int ) { if (!item ) return; if ( ( ( AttachItem* )item )->Partnumber() == -1 ) { setText(); return; } QPopupMenu *menu = new QPopupMenu(); int ret=0; if ( item->text( 0 ).left( 5 ) == "text/" ) { menu->insertItem( tr( "Show Text" ), 1 ); } menu->insertItem( tr( "Save Attachment" ), 0 ); menu->insertSeparator(1); ret = menu->exec( point, 0 ); switch(ret) { case 0: { MimeTypes types; types.insert( "all", "*" ); QString str = OFileDialog::getSaveFileName( 1, @@ -168,85 +176,98 @@ m_recMail = mail; m_mail[0] = mail.getFrom(); m_mail[1] = mail.getSubject(); m_mail[3] = mail.getDate(); m_mail[4] = mail.Msgid(); m_mail2[0] = mail.To(); m_mail2[1] = mail.CC(); m_mail2[2] = mail.Bcc(); setText(); } ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) : ViewMailBase(parent, name, fl), _inLoop(false) { m_gotBody = false; deleted = false; connect(reply, SIGNAL(activated()), SLOT(slotReply())); connect(forward, SIGNAL(activated()), SLOT(slotForward())); connect( deleteMail, SIGNAL( activated() ), SLOT( slotDeleteMail( ) ) ); + connect( showHtml, SIGNAL( toggled( bool ) ), SLOT( slotShowHtml( bool ) ) ); attachments->setEnabled(m_gotBody); connect( attachments, SIGNAL( clicked ( QListViewItem *, const QPoint & , int ) ), SLOT( slotItemClicked( QListViewItem *, const QPoint & , int ) ) ); + readConfig(); } +void ViewMail::readConfig() { + Config cfg( "mail" ); + cfg.setGroup( "Settings" ); + m_showHtml = cfg.readBoolEntry( "showHtml", false ); + showHtml->setOn( m_showHtml ); +} + void ViewMail::setText() { QString toString; QString ccString; QString bccString; for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) { toString += (*it); } for ( QStringList::Iterator it = ( m_mail2[1] ).begin(); it != ( m_mail2[1] ).end(); ++it ) { ccString += (*it); } for ( QStringList::Iterator it = ( m_mail2[2] ).begin(); it != ( m_mail2[2] ).end(); ++it ) { bccString += (*it); } setCaption( caption().arg( m_mail[0] ) ); m_mailHtml = "<html><body>" "<table width=\"100%\" border=\"0\"><tr bgcolor=\"#FFDD76\"><td>" "<div align=left><b>" + deHtml( m_mail[1] ) + "</b></div>" "</td></tr><tr bgcolor=\"#EEEEE6\"><td>" "<b>" + tr( "From" ) + ": </b><font color=#6C86C0>" + deHtml( m_mail[0] ) + "</font><br>" "<b>" + tr( "To" ) + ": </b><font color=#6C86C0>" + deHtml( toString ) + "</font><br><b>" + tr( "Cc" ) + ": </b>" + deHtml( ccString ) + "<br>" "<b>" + tr( "Date" ) + ": </b> " + m_mail[3] + "</td></tr></table><font face=fixed>"; + if ( !m_showHtml ) { browser->setText( QString( m_mailHtml) + deHtml( m_mail[2] ) + "</font></html>" ); + } else { + browser->setText( QString( m_mailHtml) + m_mail[2] + "</font></html>" ); + } // remove later in favor of a real handling m_gotBody = true; } ViewMail::~ViewMail() { hide(); } void ViewMail::hide() { QWidget::hide(); if (_inLoop) { _inLoop = false; qApp->exit_loop(); } } void ViewMail::exec() { diff --git a/noncore/net/mail/viewmail.h b/noncore/net/mail/viewmail.h index dd7f854..bf7a4dd 100644 --- a/noncore/net/mail/viewmail.h +++ b/noncore/net/mail/viewmail.h @@ -21,41 +21,44 @@ private: class ViewMail : public ViewMailBase { Q_OBJECT public: ViewMail( QWidget *parent = 0, const char *name = 0, WFlags fl = Qt::WType_Modal); ~ViewMail(); void hide(); void exec(); void setMail( RecMail mail ); void setBody( RecBody body ); bool deleted; protected: QString deHtml(const QString &string); protected slots: void slotReply(); void slotForward(); void setText(); void slotItemClicked( QListViewItem * item , const QPoint & point, int c ); void slotDeleteMail( ); - + void slotShowHtml( bool ); private: + void readConfig(); + bool _inLoop; QString m_mailHtml; bool m_gotBody; RecBody m_body; RecMail m_recMail; + bool m_showHtml; // 0 from 1 subject 2 bodytext 3 date QMap <int,QString> m_mail; // 0 to 1 cc 2 bcc QMap <int,QStringList> m_mail2; }; #endif diff --git a/noncore/net/mail/viewmailbase.cpp b/noncore/net/mail/viewmailbase.cpp index 0c7f671..e69617d 100644 --- a/noncore/net/mail/viewmailbase.cpp +++ b/noncore/net/mail/viewmailbase.cpp @@ -22,48 +22,53 @@ ViewMailBase::ViewMailBase(QWidget *parent, const char *name, WFlags fl) menubar = new QMenuBar( toolbar ); mailmenu = new QPopupMenu( menubar ); menubar->insertItem( tr( "Mail" ), mailmenu ); toolbar->setHorizontalStretchable(true); addToolBar(toolbar); QLabel *spacer = new QLabel(toolbar); spacer->setBackgroundMode(QWidget::PaletteButton); toolbar->setStretchableWidget(spacer); reply = new QAction(tr("Reply"), QIconSet(Resource::loadPixmap("mail/reply")), 0, 0, this); reply->addTo(toolbar); reply->addTo(mailmenu); forward = new QAction(tr("Forward"), QIconSet(Resource::loadPixmap("mail/forward")), 0, 0, this); forward->addTo(toolbar); forward->addTo(mailmenu); attachbutton = new QAction(tr("Attachments"), QIconSet(Resource::loadPixmap("mail/attach")), 0, 0, this, 0, true); attachbutton->addTo(toolbar); attachbutton->addTo(mailmenu); connect(attachbutton, SIGNAL(toggled(bool)), SLOT(slotChangeAttachview(bool))); + + showHtml = new QAction( tr( "Show Html" ), QIconSet( Resource::loadPixmap( "mail/attach" ) ), 0, 0, this, 0, true ); + showHtml->addTo( toolbar ); + showHtml->addTo( mailmenu ); + deleteMail = new QAction(tr("Delete Mail"), QIconSet(Resource::loadPixmap("mail/delete")), 0, 0, this); deleteMail->addTo(toolbar); deleteMail->addTo(mailmenu); QVBox *view = new QVBox(this); setCentralWidget(view); attachments = new QListView(view); attachments->setMinimumHeight(90); attachments->setMaximumHeight(90); attachments->setAllColumnsShowFocus(true); attachments->addColumn("Mime Type", 60); attachments->addColumn(tr("Description"), 100); attachments->addColumn(tr("Filename"), 80); attachments->addColumn(tr("Size"), 80); attachments->setSorting(-1); attachments->hide(); browser = new QTextBrowser(view); // openDiag = new OpenDiag(view); // openDiag->hide(); } diff --git a/noncore/net/mail/viewmailbase.h b/noncore/net/mail/viewmailbase.h index 898522e..6d2a5b2 100644 --- a/noncore/net/mail/viewmailbase.h +++ b/noncore/net/mail/viewmailbase.h @@ -1,36 +1,37 @@ #ifndef VIEWMAILBASE_H #define VIEWMAILBASE_H #include <qmainwindow.h> class QAction; class OpenDiag; class QListView; class QToolBar; class QTextBrowser; class QMenuBar; class QPopupMenu; class ViewMailBase : public QMainWindow { Q_OBJECT public: ViewMailBase(QWidget *parent = 0, const char *name = 0, WFlags fl = 0); protected: - QAction *reply, *forward, *attachbutton, *deleteMail; + QAction *reply, *forward, *attachbutton, *deleteMail, *showHtml; QListView *attachments; QToolBar *toolbar; QTextBrowser *browser; OpenDiag *openDiag; QMenuBar *menubar; QPopupMenu *mailmenu; protected slots: void slotChangeAttachview(bool state); + }; #endif |