-rw-r--r-- | noncore/net/mail/viewmail.cpp | 40 |
1 files changed, 38 insertions, 2 deletions
diff --git a/noncore/net/mail/viewmail.cpp b/noncore/net/mail/viewmail.cpp index d2f1584..a64a168 100644 --- a/noncore/net/mail/viewmail.cpp +++ b/noncore/net/mail/viewmail.cpp @@ -252,5 +252,5 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int { - QString tmpfile = "/tmp/opiemail-image"; + QString tmpfile = QString("/tmp/opiemail-image-%1").arg(_icounter++); encodedString*content = m_recMail->Wrapper()->fetchDecodedPart( m_recMail, m_body->Parts()[ ( ( AttachItem* )item )->Partnumber() ] ); - if (content) { + if (content && content->Length()) { QFile output(tmpfile); @@ -260,2 +260,3 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int delete content; + if (!m_PicsInline) { MailImageDlg iview(""); @@ -263,3 +264,15 @@ void ViewMail::slotItemClicked( QListViewItem * item , const QPoint & point, int QPEApplication::execDialog(&iview); + } else { + if (!m_lastdlg) { + m_lastdlg=new Opie::MM::OImageScrollView("",browser->parentWidget(),false); + m_lastdlg->setAutoScale(true); + } + //m_lastdlg->setImage(""); + m_lastdlg->setImage(tmpfile); + browser->hide(); + m_lastdlg->show(); + } output.remove(); + } else { + QMessageBox::critical(this, tr("Reading attachment"), tr("Could not read content of attachment")); } @@ -315,2 +328,3 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) connect( showHtml, SIGNAL( toggled(bool) ), SLOT( slotShowHtml(bool) ) ); + connect( showPicsInline, SIGNAL( toggled(bool) ), SLOT( slotImageInline(bool) ) ); @@ -318,2 +332,4 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) connect( attachments, SIGNAL( clicked(QListViewItem*,const QPoint&, int) ), SLOT( slotItemClicked(QListViewItem*,const QPoint&, int) ) ); + m_lastdlg = 0; + _icounter = 0; @@ -323,2 +339,16 @@ ViewMail::ViewMail( QWidget *parent, const char *name, WFlags fl) +void ViewMail::slotImageInline(bool how) +{ + Config cfg( "mail" ); + cfg.writeEntry( "showPicsInline", how); + m_PicsInline = how; + if (m_lastdlg&&!how) { + browser->show(); + m_lastdlg->hide(); + m_lastdlg->reparent(0,QPoint(0,0),false); + delete m_lastdlg; + m_lastdlg = 0; + } +} + void ViewMail::readConfig() @@ -328,2 +358,4 @@ void ViewMail::readConfig() m_showHtml = cfg.readBoolEntry( "showHtml", false ); + m_PicsInline = cfg.readBoolEntry( "showPicsInline", true ); + showPicsInline->setOn(m_PicsInline); showHtml->setOn( m_showHtml ); @@ -338,2 +370,6 @@ void ViewMail::setText() + if (m_lastdlg) { + m_lastdlg->hide(); + } + browser->show(); for ( QStringList::Iterator it = ( m_mail2[0] ).begin(); it != ( m_mail2[0] ).end(); ++it ) |