Skip to content
Browse files

set IE user agent for VdomBrowser

  • Loading branch information...
1 parent bd71ac2 commit 618a3942bf8a10432e7ee17b1efede8f0ad847e7 agentzh committed Jun 30, 2009
Showing with 22 additions and 4 deletions.
  1. +3 −2 mainwindow.cpp
  2. +3 −2 mainwindow.h
  3. +12 −0 webpage.cpp
  4. +4 −0 webpage.h
View
5 mainwindow.cpp
@@ -151,7 +151,7 @@ void MainWindow::createWebView() {
//m_view = new QWebView(this);
//QWebPage* page = new QWebPage(m_view);
m_view = new WebView(this);
- QWebPage* page = webPage();
+ WebPage* page = webPage();
page->settings()->setAttribute(QWebSettings::JavascriptEnabled, m_enableJavascript);
page->settings()->setAttribute(QWebSettings::PluginsEnabled, m_enablePlugins);
@@ -160,6 +160,7 @@ void MainWindow::createWebView() {
m_view->setPage(page);
m_webvdom = new QWebVDom(page->mainFrame());
+ page->setUserAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1)");
connect(m_view->page(), SIGNAL(loadFinished(bool)),
this, SLOT(loadFinished(bool)));
@@ -510,7 +511,7 @@ void MainWindow::permanentSaveViwie() {
}
-void MainWindow::showDetailField(const QVariant& detail) {
+void MainWindow::showDetailField(const QVariant& /* detail */) {
}
void MainWindow::writeSettings() {
View
5 mainwindow.h
@@ -19,15 +19,16 @@
#include "fielddialog.h"
#include "viwiedialog.h"
#include "webview.h"
+#include "webpage.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow(const QString& url = QString());
- QWebPage* webPage() const {
- return m_view->page();
+ WebPage* webPage() const {
+ return (WebPage*) m_view->page();
}
QWebView* webView() const {
View
12 webpage.cpp
@@ -23,3 +23,15 @@ void WebPage::javaScriptConsoleMessage ( const QString & message, int lineNumber
": " << message << endl;
}
+QString WebPage::userAgentForUrl(const QUrl& url) const {
+
+ if (!m_userAgent.isNull())
+ return m_userAgent;
+
+ return QWebPage::userAgentForUrl(url);
+}
+
+void WebPage::setUserAgent(const QString& userAgent) {
+ m_userAgent = userAgent;
+}
+
View
4 webpage.h
@@ -11,6 +11,10 @@ class WebPage : public QWebPage
virtual QWebPage *createWindow(QWebPage::WebWindowType);
virtual QObject* createPlugin(const QString&, const QUrl&, const QStringList&, const QStringList&);
virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID);
+ virtual QString userAgentForUrl(const QUrl& url) const;
+ void setUserAgent(const QString& userAgent);
+private:
+ QString m_userAgent;
};
#endif

0 comments on commit 618a394

Please sign in to comment.
Something went wrong with that request. Please try again.