diff --git a/src/lib/data/html/restore.html b/src/lib/data/html/restore.html
index c9bffa483..22945f244 100644
--- a/src/lib/data/html/restore.html
+++ b/src/lib/data/html/restore.html
@@ -283,7 +283,7 @@ if (window.external) {
-
+
%OOPS%
%APOLOGIZE%
diff --git a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp
index 46db3d9bb..f7ee666fd 100644
--- a/src/lib/network/schemehandlers/qupzillaschemehandler.cpp
+++ b/src/lib/network/schemehandlers/qupzillaschemehandler.cpp
@@ -329,7 +329,7 @@ QString QupZillaSchemeReply::restorePage()
rPage.append(QzTools::readAllFileContents(":html/restore.html"));
rPage.replace(QLatin1String("%FAVICON%"), QLatin1String("qrc:icons/qupzilla.png"));
rPage.replace(QLatin1String("%BOX-BORDER%"), QLatin1String("qrc:html/box-border.png"));
- rPage.replace(QLatin1String("%IMAGE%"), QzTools::pixmapToByteArray(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45, 45)));
+ rPage.replace(QLatin1String("%IMAGE%"), QzTools::pixmapToDataUrl(IconProvider::standardIcon(QStyle::SP_MessageBoxWarning).pixmap(45)).toString());
rPage.replace(QLatin1String("%TITLE%"), tr("Restore Session"));
rPage.replace(QLatin1String("%OOPS%"), tr("Oops, QupZilla crashed."));
rPage.replace(QLatin1String("%APOLOGIZE%"), tr("We apologize for this. Would you like to restore the last saved state?"));
diff --git a/src/lib/plugins/speeddial.cpp b/src/lib/plugins/speeddial.cpp
index 0075842c5..f1621e083 100644
--- a/src/lib/plugins/speeddial.cpp
+++ b/src/lib/plugins/speeddial.cpp
@@ -218,8 +218,7 @@ QString SpeedDial::initialScript()
}
}
else {
- QByteArray data = QzTools::pixmapToByteArray(QPixmap(imgSource));
- imgSource = QByteArrayLiteral("data:image/png;base64,") + data;
+ imgSource = QzTools::pixmapToDataUrl(QPixmap(imgSource)).toString();
}
m_initialScript.append(QString("addBox('%1', '%2', '%3');\n").arg(page.url, page.title, imgSource));
@@ -289,10 +288,7 @@ QStringList SpeedDial::getOpenFileName()
if (image.isEmpty())
return QStringList();
- const QByteArray data = QzTools::pixmapToByteArray(QPixmap(image));
- const QByteArray imageData = QByteArrayLiteral("data:image/png;base64,") + data;
-
- return {imageData, QUrl::fromLocalFile(image).toEncoded()};
+ return {QzTools::pixmapToDataUrl(QPixmap(image)).toString(), QUrl::fromLocalFile(image).toEncoded()};
}
QString SpeedDial::urlFromUserInput(const QString &url)
@@ -302,8 +298,7 @@ QString SpeedDial::urlFromUserInput(const QString &url)
void SpeedDial::setBackgroundImage(const QString &image)
{
- const QByteArray data = QzTools::pixmapToByteArray(QPixmap(QUrl::fromEncoded(image.toUtf8()).toLocalFile()));
- m_backgroundImage = QByteArrayLiteral("data:image/png;base64,") + data;
+ m_backgroundImage = QzTools::pixmapToDataUrl(QPixmap(QUrl(image).toLocalFile())).toString();
m_backgroundImageUrl = image;
}
@@ -359,8 +354,7 @@ void SpeedDial::thumbnailCreated(const QPixmap &pixmap)
if (loadTitle)
emit pageTitleLoaded(url, title);
- QByteArray data = QzTools::pixmapToByteArray(QPixmap(fileName));
- emit thumbnailLoaded(url, QString(QByteArrayLiteral("data:image/png;base64,") + data));
+ emit thumbnailLoaded(url, QzTools::pixmapToDataUrl(QPixmap(fileName)).toString());
}
QString SpeedDial::escapeTitle(QString title) const
diff --git a/src/lib/session/recoveryjsobject.cpp b/src/lib/session/recoveryjsobject.cpp
index 296048a26..53808c776 100644
--- a/src/lib/session/recoveryjsobject.cpp
+++ b/src/lib/session/recoveryjsobject.cpp
@@ -50,7 +50,7 @@ QJsonArray RecoveryJsObject::restoreData() const
Q_FOREACH (const WebTab::SavedTab &t, w.tabsState) {
QJsonObject tab;
tab[QSL("tab")] = j++;
- tab[QSL("icon")] = QString(QSL("data:image/png;base64,") + QzTools::pixmapToByteArray(t.icon.pixmap(16)));
+ tab[QSL("icon")] = QzTools::pixmapToDataUrl(t.icon.pixmap(16)).toString();
tab[QSL("title")] = t.title;
tabs.append(tab);
}
diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp
index c8429d41d..5cb035191 100644
--- a/src/lib/tools/qztools.cpp
+++ b/src/lib/tools/qztools.cpp
@@ -78,6 +78,11 @@ QPixmap QzTools::pixmapFromByteArray(const QByteArray &data)
return image;
}
+QUrl QzTools::pixmapToDataUrl(const QPixmap &pix)
+{
+ return QUrl(QSL("data:image/png;base64,") + QString(pixmapToByteArray(pix)));
+}
+
QString QzTools::readAllFileContents(const QString &filename)
{
return QString::fromUtf8(readAllFileByteContents(filename));
diff --git a/src/lib/tools/qztools.h b/src/lib/tools/qztools.h
index 4f359d37f..ed902d2a5 100644
--- a/src/lib/tools/qztools.h
+++ b/src/lib/tools/qztools.h
@@ -34,6 +34,7 @@ class QUPZILLA_EXPORT QzTools
public:
static QByteArray pixmapToByteArray(const QPixmap &pix);
static QPixmap pixmapFromByteArray(const QByteArray &data);
+ static QUrl pixmapToDataUrl(const QPixmap &pix);
static QString readAllFileContents(const QString &filename);
static QByteArray readAllFileByteContents(const QString &filename);
diff --git a/src/plugins/AutoScroll/autoscrollplugin.cpp b/src/plugins/AutoScroll/autoscrollplugin.cpp
index d41f17796..8e9f52316 100644
--- a/src/plugins/AutoScroll/autoscrollplugin.cpp
+++ b/src/plugins/AutoScroll/autoscrollplugin.cpp
@@ -107,9 +107,9 @@ void AutoScrollPlugin::updateScript()
source.replace(QSL("%MOVE_SPEED%"), settings.value(QSL("Speed"), 5).toString());
source.replace(QSL("%CTRL_CLICK%"), settings.value(QSL("CtrlClick"), true).toString());
source.replace(QSL("%MIDDLE_CLICK%"), settings.value(QSL("MiddleClick"), true).toString());
- source.replace(QSL("%IMG_ALL%"), QzTools::pixmapToByteArray(QPixmap(QSL(":/autoscroll/data/scroll_all.png"))));
- source.replace(QSL("%IMG_HORIZONTAL%"), QzTools::pixmapToByteArray(QPixmap(QSL(":/autoscroll/data/scroll_horizontal.png"))));
- source.replace(QSL("%IMG_VERTICAL%"), QzTools::pixmapToByteArray(QPixmap(QSL(":/autoscroll/data/scroll_vertical.png"))));
+ source.replace(QSL("%IMG_ALL%"), QzTools::pixmapToDataUrl(QPixmap(QSL(":/autoscroll/data/scroll_all.png"))).toString());
+ source.replace(QSL("%IMG_HORIZONTAL%"), QzTools::pixmapToDataUrl(QPixmap(QSL(":/autoscroll/data/scroll_horizontal.png"))).toString());
+ source.replace(QSL("%IMG_VERTICAL%"), QzTools::pixmapToDataUrl(QPixmap(QSL(":/autoscroll/data/scroll_vertical.png"))).toString());
script.setSourceCode(source);
diff --git a/src/plugins/AutoScroll/data/autoscroll.js b/src/plugins/AutoScroll/data/autoscroll.js
index 4a4061db9..7bb690b84 100644
--- a/src/plugins/AutoScroll/data/autoscroll.js
+++ b/src/plugins/AutoScroll/data/autoscroll.js
@@ -60,11 +60,11 @@
function image(o) {
if (o.width && o.height) {
- return "data:image/png;base64,%IMG_ALL%"
+ return "%IMG_ALL%"
} else if (o.width) {
- return "data:image/png;base64,%IMG_HORIZONTAL%"
+ return "%IMG_HORIZONTAL%"
} else {
- return "data:image/png;base64,%IMG_VERTICAL%"
+ return "%IMG_VERTICAL%"
}
}