diff --git a/src/gui/messagepreviewer.cpp b/src/gui/messagepreviewer.cpp index 844afad05..a5f20624a 100644 --- a/src/gui/messagepreviewer.cpp +++ b/src/gui/messagepreviewer.cpp @@ -38,8 +38,9 @@ void MessagePreviewer::createConnections() { box.setText(tr("You clicked some link. You can download the link contents or open it in external web browser.")); box.setInformativeText(tr("What action do you want to take?")); box.setDetailedText(url.toString()); - QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::AcceptRole); - QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::RejectRole); + QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::ActionRole); + QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::ActionRole); + QAbstractButton *btn_display = box.addButton(tr("Display"), QMessageBox::ActionRole); QAbstractButton *btn_cancel = box.addButton(QMessageBox::Cancel); box.setDefaultButton(QMessageBox::Cancel); @@ -51,6 +52,9 @@ void MessagePreviewer::createConnections() { else if (box.clickedButton() == btn_download) { qApp->downloadManager()->download(url); } + else if (box.clickedButton() == btn_display) { + // TODO: Zobrazit obrázek. + } btn_download->deleteLater(); btn_open->deleteLater(); @@ -83,7 +87,7 @@ void MessagePreviewer::createConnections() { } MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent), - m_ui(new Ui::MessagePreviewer) { + m_ui(new Ui::MessagePreviewer), m_pictures(QStringList()) { m_ui->setupUi(this); m_ui->m_txtMessage->viewport()->setAutoFillBackground(true); m_toolBar = new QToolBar(this); @@ -113,6 +117,7 @@ void MessagePreviewer::reloadFontSettings() { void MessagePreviewer::clear() { m_ui->m_txtMessage->clear(); + m_pictures.clear(); hide(); } @@ -211,6 +216,8 @@ QString MessagePreviewer::prepareHtmlForMessage(const Message &message) { imgTagRegex.setMinimal(true); while( (offset = imgTagRegex.indexIn(message.m_contents, offset)) != -1){ + m_pictures.append(imgTagRegex.cap(1)); + offset += imgTagRegex.matchedLength(); html += QString("[%2] %1
").arg(imgTagRegex.cap(1), tr("image")); } diff --git a/src/gui/messagepreviewer.h b/src/gui/messagepreviewer.h index 328ff864c..a4ec0f269 100644 --- a/src/gui/messagepreviewer.h +++ b/src/gui/messagepreviewer.h @@ -63,6 +63,7 @@ class MessagePreviewer : public QWidget { QToolBar *m_toolBar; QScopedPointer m_ui; Message m_message; + QStringList m_pictures; QPointer m_root; QAction *m_actionMarkRead; diff --git a/src/network-web/downloader.cpp b/src/network-web/downloader.cpp index c94205351..56e99d611 100755 --- a/src/network-web/downloader.cpp +++ b/src/network-web/downloader.cpp @@ -148,10 +148,7 @@ void Downloader::progressInternal(qint64 bytes_received, qint64 bytes_total) { } void Downloader::timeout() { - if (m_activeReply != NULL) { - // Download action timed-out, too slow connection or target is not reachable. - m_activeReply->abort(); - } + cancel(); } void Downloader::runDeleteRequest(const QNetworkRequest &request) { @@ -206,6 +203,13 @@ QVariant Downloader::lastContentType() const { return m_lastContentType; } +void Downloader::cancel() { + if (m_activeReply != NULL) { + // Download action timed-out, too slow connection or target is not reachable. + m_activeReply->abort(); + } +} + void Downloader::appendRawHeader(const QByteArray &name, const QByteArray &value) { if (!value.isEmpty()) { m_customHeaders.insert(name, value); diff --git a/src/network-web/downloader.h b/src/network-web/downloader.h index 54f40c8bd..eeb2f9d9c 100755 --- a/src/network-web/downloader.h +++ b/src/network-web/downloader.h @@ -43,6 +43,8 @@ class Downloader : public QObject { QVariant lastContentType() const; public slots: + void cancel(); + void appendRawHeader(const QByteArray &name, const QByteArray &value); // Performs asynchronous download of given file. Redirections are handled.