Some work on images.
This commit is contained in:
parent
0402a5dddb
commit
7f139b98b1
@ -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.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.setInformativeText(tr("What action do you want to take?"));
|
||||||
box.setDetailedText(url.toString());
|
box.setDetailedText(url.toString());
|
||||||
QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::AcceptRole);
|
QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::ActionRole);
|
||||||
QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::RejectRole);
|
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);
|
QAbstractButton *btn_cancel = box.addButton(QMessageBox::Cancel);
|
||||||
|
|
||||||
box.setDefaultButton(QMessageBox::Cancel);
|
box.setDefaultButton(QMessageBox::Cancel);
|
||||||
@ -51,6 +52,9 @@ void MessagePreviewer::createConnections() {
|
|||||||
else if (box.clickedButton() == btn_download) {
|
else if (box.clickedButton() == btn_download) {
|
||||||
qApp->downloadManager()->download(url);
|
qApp->downloadManager()->download(url);
|
||||||
}
|
}
|
||||||
|
else if (box.clickedButton() == btn_display) {
|
||||||
|
// TODO: Zobrazit obrázek.
|
||||||
|
}
|
||||||
|
|
||||||
btn_download->deleteLater();
|
btn_download->deleteLater();
|
||||||
btn_open->deleteLater();
|
btn_open->deleteLater();
|
||||||
@ -83,7 +87,7 @@ void MessagePreviewer::createConnections() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
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->setupUi(this);
|
||||||
m_ui->m_txtMessage->viewport()->setAutoFillBackground(true);
|
m_ui->m_txtMessage->viewport()->setAutoFillBackground(true);
|
||||||
m_toolBar = new QToolBar(this);
|
m_toolBar = new QToolBar(this);
|
||||||
@ -113,6 +117,7 @@ void MessagePreviewer::reloadFontSettings() {
|
|||||||
|
|
||||||
void MessagePreviewer::clear() {
|
void MessagePreviewer::clear() {
|
||||||
m_ui->m_txtMessage->clear();
|
m_ui->m_txtMessage->clear();
|
||||||
|
m_pictures.clear();
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,6 +216,8 @@ QString MessagePreviewer::prepareHtmlForMessage(const Message &message) {
|
|||||||
imgTagRegex.setMinimal(true);
|
imgTagRegex.setMinimal(true);
|
||||||
|
|
||||||
while( (offset = imgTagRegex.indexIn(message.m_contents, offset)) != -1){
|
while( (offset = imgTagRegex.indexIn(message.m_contents, offset)) != -1){
|
||||||
|
m_pictures.append(imgTagRegex.cap(1));
|
||||||
|
|
||||||
offset += imgTagRegex.matchedLength();
|
offset += imgTagRegex.matchedLength();
|
||||||
html += QString("[%2] <a href=\"%1\">%1</a><br/>").arg(imgTagRegex.cap(1), tr("image"));
|
html += QString("[%2] <a href=\"%1\">%1</a><br/>").arg(imgTagRegex.cap(1), tr("image"));
|
||||||
}
|
}
|
||||||
|
@ -63,6 +63,7 @@ class MessagePreviewer : public QWidget {
|
|||||||
QToolBar *m_toolBar;
|
QToolBar *m_toolBar;
|
||||||
QScopedPointer<Ui::MessagePreviewer> m_ui;
|
QScopedPointer<Ui::MessagePreviewer> m_ui;
|
||||||
Message m_message;
|
Message m_message;
|
||||||
|
QStringList m_pictures;
|
||||||
QPointer<RootItem> m_root;
|
QPointer<RootItem> m_root;
|
||||||
|
|
||||||
QAction *m_actionMarkRead;
|
QAction *m_actionMarkRead;
|
||||||
|
@ -148,10 +148,7 @@ void Downloader::progressInternal(qint64 bytes_received, qint64 bytes_total) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::timeout() {
|
void Downloader::timeout() {
|
||||||
if (m_activeReply != NULL) {
|
cancel();
|
||||||
// Download action timed-out, too slow connection or target is not reachable.
|
|
||||||
m_activeReply->abort();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Downloader::runDeleteRequest(const QNetworkRequest &request) {
|
void Downloader::runDeleteRequest(const QNetworkRequest &request) {
|
||||||
@ -206,6 +203,13 @@ QVariant Downloader::lastContentType() const {
|
|||||||
return m_lastContentType;
|
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) {
|
void Downloader::appendRawHeader(const QByteArray &name, const QByteArray &value) {
|
||||||
if (!value.isEmpty()) {
|
if (!value.isEmpty()) {
|
||||||
m_customHeaders.insert(name, value);
|
m_customHeaders.insert(name, value);
|
||||||
|
@ -43,6 +43,8 @@ class Downloader : public QObject {
|
|||||||
QVariant lastContentType() const;
|
QVariant lastContentType() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
void cancel();
|
||||||
|
|
||||||
void appendRawHeader(const QByteArray &name, const QByteArray &value);
|
void appendRawHeader(const QByteArray &name, const QByteArray &value);
|
||||||
|
|
||||||
// Performs asynchronous download of given file. Redirections are handled.
|
// Performs asynchronous download of given file. Redirections are handled.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user