summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/webview.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/webview.cpp b/src/webview.cpp
index 0ca7328..17a5261 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -9,6 +9,21 @@
#include <QWebHistory>
#include <QNetworkCookieJar>
#include <QWebElement>
+#include <QRegularExpression>
+#include <QWebPage>
+
+// Override user-agent to make it appear mobile
+class UaWebPage : public QWebPage
+{
+public:
+ static QRegularExpression re;
+
+ QString userAgentForUrl(const QUrl &url) const override {
+ return QWebPage::userAgentForUrl(url).replace(re, "Mobile \\1");
+ }
+};
+
+QRegularExpression UaWebPage::re("(\\S+)$");
WebView::WebView(QWidget* parent)
: QWebView(parent),
@@ -16,6 +31,7 @@ WebView::WebView(QWidget* parent)
_abortedDownload(false),
_timerReset(new QTimer(this))
{
+ this->setPage(new UaWebPage);
_timerAbortMessage->setSingleShot(true);
_timerReset->setSingleShot(true);
connect(page(), SIGNAL(windowCloseRequested()), this, SLOT(windowCloseRequested()));