diff options
Diffstat (limited to 'src/webview/qwebview.cpp')
-rw-r--r-- | src/webview/qwebview.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/webview/qwebview.cpp b/src/webview/qwebview.cpp index 7e457be..943218b 100644 --- a/src/webview/qwebview.cpp +++ b/src/webview/qwebview.cpp @@ -54,6 +54,7 @@ QWebView::QWebView(QObject *p) connect(d, &QAbstractWebView::urlChanged, this, &QWebView::onUrlChanged); connect(d, &QAbstractWebView::loadingChanged, this, &QWebView::onLoadingChanged); connect(d, &QAbstractWebView::loadProgressChanged, this, &QWebView::onLoadProgressChanged); + connect(d, &QAbstractWebView::httpUserAgentChanged, this, &QWebView::onHttpUserAgentChanged); connect(d, &QAbstractWebView::requestFocus, this, &QWebView::requestFocus); connect(d, &QAbstractWebView::javaScriptResult, this, &QWebView::javaScriptResult); @@ -63,6 +64,19 @@ QWebView::~QWebView() { } +QString QWebView::httpUserAgent() const +{ + if (m_httpUserAgent.isEmpty()){ + m_httpUserAgent = d->httpUserAgent(); + } + return m_httpUserAgent; +} + +void QWebView::setHttpUserAgent(const QString &userAgent) +{ + return d->setHttpUserAgent(userAgent); +} + QUrl QWebView::url() const { return m_url; @@ -193,7 +207,14 @@ void QWebView::onLoadingChanged(const QWebViewLoadRequestPrivate &loadRequest) onUrlChanged(loadRequest.m_url); Q_EMIT loadingChanged(loadRequest); +} +void QWebView::onHttpUserAgentChanged(const QString &userAgent) +{ + if (m_httpUserAgent == userAgent) + return; + m_httpUserAgent = userAgent; + Q_EMIT httpUserAgentChanged(); } void QWebView::init() |