mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-24 12:46:35 +01:00
Show correct default user agent in About dialog
This commit is contained in:
parent
5b82102075
commit
5c40121aa9
@ -22,6 +22,7 @@
|
||||
#include "tabbedwebview.h"
|
||||
#include "webpage.h"
|
||||
#include "qtwin.h"
|
||||
#include "useragentmanager.h"
|
||||
|
||||
#include <QWebEnginePage>
|
||||
#include <QWebEngineProfile>
|
||||
@ -76,7 +77,7 @@ void AboutDialog::showAbout()
|
||||
m_aboutHtml += QString("<p>© %1 %2<br/>").arg(Qz::COPYRIGHT, Qz::AUTHOR);
|
||||
m_aboutHtml += tr("<small>Build time: %1 </small></p>").arg(Qz::BUILDTIME);
|
||||
m_aboutHtml += QString("<p><a href=%1>%1</a></p>").arg(Qz::WWWADDRESS);
|
||||
m_aboutHtml += "<p>" + mApp->webProfile()->httpUserAgent() + "</p>";
|
||||
m_aboutHtml += "<p>" + mApp->userAgentManager()->defaultUserAgent() + "</p>";
|
||||
m_aboutHtml += "</div></center>";
|
||||
}
|
||||
ui->textBrowser->setHtml(m_aboutHtml);
|
||||
|
@ -21,11 +21,14 @@
|
||||
#include "settings.h"
|
||||
|
||||
#include <QWebEngineProfile>
|
||||
#include <QRegularExpression>
|
||||
|
||||
UserAgentManager::UserAgentManager(QObject* parent)
|
||||
: QObject(parent)
|
||||
, m_usePerDomainUserAgent(false)
|
||||
{
|
||||
m_defaultUserAgent = QWebEngineProfile::defaultProfile()->httpUserAgent();
|
||||
m_defaultUserAgent.replace(QRegularExpression(QSL("QtWebEngine/[^\\s]+")), QSL("QupZilla/%1").arg(Qz::VERSION));
|
||||
}
|
||||
|
||||
void UserAgentManager::loadSettings()
|
||||
@ -49,11 +52,7 @@ void UserAgentManager::loadSettings()
|
||||
}
|
||||
}
|
||||
|
||||
QString userAgent = m_globalUserAgent;
|
||||
if (userAgent.isEmpty()) {
|
||||
userAgent = QWebEngineProfile::defaultProfile()->httpUserAgent();
|
||||
userAgent.replace(QSL("QtWebEngine/%1").arg(qVersion()), QSL("QupZilla/%1").arg(Qz::VERSION));
|
||||
}
|
||||
const QString userAgent = m_globalUserAgent.isEmpty() ? m_defaultUserAgent : m_globalUserAgent;
|
||||
QWebEngineProfile::defaultProfile()->setHttpUserAgent(userAgent);
|
||||
}
|
||||
|
||||
@ -79,6 +78,11 @@ QString UserAgentManager::globalUserAgent() const
|
||||
return m_globalUserAgent;
|
||||
}
|
||||
|
||||
QString UserAgentManager::defaultUserAgent() const
|
||||
{
|
||||
return m_defaultUserAgent;
|
||||
}
|
||||
|
||||
bool UserAgentManager::usePerDomainUserAgents() const
|
||||
{
|
||||
return m_usePerDomainUserAgent;
|
||||
|
@ -35,13 +35,16 @@ public:
|
||||
void loadSettings();
|
||||
|
||||
QString userAgentForUrl(const QUrl &url) const;
|
||||
|
||||
QString globalUserAgent() const;
|
||||
QString defaultUserAgent() const;
|
||||
|
||||
bool usePerDomainUserAgents() const;
|
||||
QHash<QString, QString> perDomainUserAgentsList() const;
|
||||
|
||||
private:
|
||||
QString m_globalUserAgent;
|
||||
QString m_defaultUserAgent;
|
||||
|
||||
bool m_usePerDomainUserAgent;
|
||||
QHash<QString, QString> m_userAgentsList;
|
||||
|
Loading…
Reference in New Issue
Block a user