From b62ed5edb3cf867fe831c1390e0ee3c9dcc1217e Mon Sep 17 00:00:00 2001 From: nowrep Date: Sat, 5 Nov 2011 11:51:46 +0100 Subject: [PATCH] Supporting data: scheme You can now enter image with data: scheme to locationbar to show it and data: images will now be showed in Site Info dialog --- bin/locale/de_DE.qm | Bin 88684 -> 89219 bytes src/tools/globalfunctions.cpp | 23 ++++++++++++++- src/tools/globalfunctions.h | 4 +++ src/webview/siteinfo.cpp | 53 +++++++++++++++++----------------- src/webview/siteinfo.h | 2 ++ src/webview/webview.cpp | 7 +++++ translations/de_DE.ts | 2 +- 7 files changed, 62 insertions(+), 29 deletions(-) diff --git a/bin/locale/de_DE.qm b/bin/locale/de_DE.qm index 887fadfd25cee59eaff35066b9c73ade6446e96e..a2f6ef971af5720f9e7a5b1a694bb7fc4520db8e 100644 GIT binary patch delta 7171 zcmYkA2UrwW*T>J@o!K(m6i@_d(iCh&MFR+my#QiGv4pmih@h0HXj}`}#j=V8g2pZ? z8rKrVhJu0xI}!`V9vdQxEtc=k&iB3F>+|4mW_D)oz32Q-x$|;AKj$#N%*xQ6h<+ei zG?s`zNu;*MsTSv*i280O$}AK4`MAh04~Y7;!SQ~g0Y{0v4v0*&0!xV5-69$qNAw~Y zTtGA_fGBJZQD6a4_+(<%>xsrJCh|~=G;~sl2gw?e6qFF1Ur*e;T%xHhiQ76AFWf@h z_TPz~b|CIxHIa%DSHuxn?>CbvnuxR?NZe&NVvaq*USJAwe=Q^0WkuZUDx!Zh#J%?> z%J3!L&WC8?L9jO&XyQZSgB}vqXMyjC+!hg^a054{5x-~;F{hTqFUEkkaeYlGQ2_4C zb0gC20ecbES`)v`NOW>6@jD}k{@q7>37&J_LVVe0q681(FP+7CHSxELV5JYFYMx27 zt_Qh3dte~u+KF1m4I%2#Ut|{~fG%yO)(sQ8Y@pVd7+routuZ0GVn=PN424A6 z5Ng-Rftc?;YG3e}=&yFr7ON&XjS5IwJ;-j!2{uDehlPn^FVPW`5Q zAxie40j*~fjdT+k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xp*D>=o8E9u;)@ot?#D%X>XUSKelV$7sLt6AKK_!g zb3KV>z12mL7EI@DV~p6T>2-B3%q`=b9Ub&QCBia)w4nW69}QX3YF! zvz({U3Y@TKtpFOpc8h&`u$C&?OGoPK@nRPKdeWEoCu6N4b z)`xYpRRqkO9vl}RAI4xI5@-m;Q9MOclmfRT!#~b&<7qqN&iZdk37HtQFD!XJFflRS zX!v-NWqWzC&c^!zrrp32QWI<2WI4rntQSwZO4g vZJ1MQ=8|n@&%Qh6W6##NGiyI4ab{A)|1%SopBy$TJJFN1KPL5Ji>&_#G2thf diff --git a/src/tools/globalfunctions.cpp b/src/tools/globalfunctions.cpp index 14270a310..2f2aaef37 100644 --- a/src/tools/globalfunctions.cpp +++ b/src/tools/globalfunctions.cpp @@ -28,6 +28,15 @@ QByteArray qz_pixmapToByteArray(const QPixmap &pix) return QByteArray(); } +QPixmap qz_pixmapFromByteArray(const QByteArray &data) +{ + QPixmap image; + QByteArray bArray = QByteArray::fromBase64(data); + image.loadFromData(bArray); + + return image; +} + QByteArray qz_readAllFileContents(const QString &filename) { QFile file(filename); @@ -115,7 +124,8 @@ QString qz_ensureUniqueFilename(const QString &pathToFile) if (index == -1) { tmpFileName.append("("+QString::number(i)+")"); - } else { + } + else { tmpFileName = tmpFileName.mid(0, index) + "("+QString::number(i)+")" + tmpFileName.mid(index); } i++; @@ -123,6 +133,17 @@ QString qz_ensureUniqueFilename(const QString &pathToFile) return tmpFileName; } +QString qz_getFileNameFromUrl(const QUrl &url) +{ + QString fileName = url.toString(QUrl::RemoveFragment | QUrl::RemoveQuery | QUrl::RemoveScheme | QUrl::RemovePort); + if (fileName.indexOf("/") != -1) { + int pos = fileName.lastIndexOf("/"); + fileName = fileName.mid(pos); + fileName.remove("/"); + } + return fileName; +} + QString qz_buildSystem() { #ifdef Q_OS_LINUX diff --git a/src/tools/globalfunctions.h b/src/tools/globalfunctions.h index d3f3bcf10..c6338f3e3 100644 --- a/src/tools/globalfunctions.h +++ b/src/tools/globalfunctions.h @@ -26,8 +26,11 @@ #include #include #include +#include QByteArray qz_pixmapToByteArray(const QPixmap &pix); +QPixmap qz_pixmapFromByteArray(const QByteArray &data); + QByteArray qz_readAllFileContents(const QString &filename); void qz_centerWidgetOnScreen(QWidget* w); @@ -37,6 +40,7 @@ QString qz_samePartOfStrings(const QString &one, const QString &other); QUrl qz_makeRelativeUrl(const QUrl &baseUrl, const QUrl &rUrl); QString qz_ensureUniqueFilename(const QString &name); +QString qz_getFileNameFromUrl(const QUrl &url); QString qz_buildSystem(); diff --git a/src/webview/siteinfo.cpp b/src/webview/siteinfo.cpp index 05ab7f4de..d287a1d2d 100644 --- a/src/webview/siteinfo.cpp +++ b/src/webview/siteinfo.cpp @@ -22,6 +22,8 @@ #include "webpage.h" #include "downloaditem.h" #include "certificateinfowidget.h" +#include "globalfunctions.h" +#include "iconprovider.h" QString SiteInfo::showCertInfo(const QString &string) { @@ -144,28 +146,21 @@ void SiteInfo::downloadImage() if (!item) return; - QUrl imageUrl = item->text(1); - if (imageUrl.host().isEmpty()) { - imageUrl.setHost(QUrl(ui->siteAddress->text()).host()); - imageUrl.setScheme(QUrl(ui->siteAddress->text()).scheme()); - } - QIODevice* cacheData = mApp->networkCache()->data(imageUrl); - if (!cacheData) { + if (m_activePixmap.isNull()) { QMessageBox::warning(this, tr("Error!"), tr("This preview is not available!")); return; } - QString filePath = QFileDialog::getSaveFileName(this, tr("Save image..."), QDir::homePath()+"/"+item->text(0)); + QString imageFileName = qz_getFileNameFromUrl(QUrl(item->text(1))); + + QString filePath = QFileDialog::getSaveFileName(this, tr("Save image..."), QDir::homePath() + "/" + imageFileName); if (filePath.isEmpty()) return; - QFile file(filePath); - if (!file.open(QFile::WriteOnly)) { + if (!m_activePixmap.save(filePath)) { QMessageBox::critical(this, tr("Error!"), tr("Cannot write to file!")); return; } - file.write(cacheData->readAll()); - file.close(); } } @@ -174,26 +169,30 @@ void SiteInfo::showImagePreview(QTreeWidgetItem *item) if (!item) return; QUrl imageUrl = item->text(1); - if (imageUrl.host().isEmpty()) { - imageUrl.setHost(QUrl(ui->siteAddress->text()).host()); - imageUrl.setScheme(QUrl(ui->siteAddress->text()).scheme()); - } - QIODevice* cacheData = mApp->networkCache()->data(imageUrl); - QPixmap pixmap; - bool invalidPixmap = false; QGraphicsScene* scene = new QGraphicsScene(ui->mediaPreview); - if (!cacheData) - invalidPixmap = true; - else { - pixmap.loadFromData(cacheData->readAll()); - if (pixmap.isNull()) - invalidPixmap = true; + if (imageUrl.scheme() == "data") { + QByteArray encodedUrl = item->text(1).toAscii(); + QByteArray imageData = encodedUrl.mid(encodedUrl.indexOf(",") + 1); + m_activePixmap = qz_pixmapFromByteArray(imageData); } - if (invalidPixmap) + else { + if (imageUrl.host().isEmpty()) { + imageUrl.setHost(QUrl(ui->siteAddress->text()).host()); + imageUrl.setScheme(QUrl(ui->siteAddress->text()).scheme()); + } + + QIODevice* cacheData = mApp->networkCache()->data(imageUrl); + if (!cacheData) + m_activePixmap = QPixmap(); + else + m_activePixmap.loadFromData(cacheData->readAll()); + } + + if (m_activePixmap.isNull()) scene->addText(tr("Preview not available")); else - scene->addPixmap(pixmap); + scene->addPixmap(m_activePixmap); ui->mediaPreview->setScene(scene); } diff --git a/src/webview/siteinfo.h b/src/webview/siteinfo.h index 45dd7436d..82cd3cf47 100644 --- a/src/webview/siteinfo.h +++ b/src/webview/siteinfo.h @@ -52,6 +52,8 @@ private: Ui::SiteInfo* ui; QupZilla* p_QupZilla; CertificateInfoWidget* m_certWidget; + + QPixmap m_activePixmap; }; #endif // SITEINFO_H diff --git a/src/webview/webview.cpp b/src/webview/webview.cpp index be03a8435..26e64372a 100644 --- a/src/webview/webview.cpp +++ b/src/webview/webview.cpp @@ -775,6 +775,13 @@ void WebView::load(const QUrl &url) page()->mainFrame()->evaluateJavaScript(url.toString()); return; } + + if (url.scheme() == "data") { + QWebView::load(url); + m_aboutToLoadUrl = url; + return; + } + if (isUrlValid(url)) { QWebView::load(url); m_aboutToLoadUrl = url; diff --git a/translations/de_DE.ts b/translations/de_DE.ts index b78a0cb64..1128c979e 100644 --- a/translations/de_DE.ts +++ b/translations/de_DE.ts @@ -808,7 +808,7 @@ p, li { white-space: pre-wrap; } Database successfully optimized.<br/><br/><b>Database Size Before: </b>%1<br/><b>Database Size After: </b>%2 - + Datenbank erfolgreich optimiert.<br/><br/><b>Datenbankgröße vorher: </b>%1<br/><b>Datenbankgröße nachher: </b>%2