From 523a4e6ba251982183b4324fcf09dc9137e1db04 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Mon, 22 Sep 2014 11:58:23 -0700 Subject: [PATCH] allow moving of location from DataWebDialog for locations --- interface/src/ui/DataWebDialog.cpp | 9 +++------ interface/src/ui/DataWebPage.cpp | 31 ++++++++++++++++++++++++++++++ interface/src/ui/DataWebPage.h | 24 +++++++++++++++++++++++ 3 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 interface/src/ui/DataWebPage.cpp create mode 100644 interface/src/ui/DataWebPage.h diff --git a/interface/src/ui/DataWebDialog.cpp b/interface/src/ui/DataWebDialog.cpp index 2094fe2dbf..e28dcf8df7 100644 --- a/interface/src/ui/DataWebDialog.cpp +++ b/interface/src/ui/DataWebDialog.cpp @@ -14,9 +14,9 @@ #include #include -#include #include "Application.h" +#include "DataWebPage.h" #include "DataWebDialog.h" @@ -24,11 +24,8 @@ DataWebDialog::DataWebDialog() { // make sure the dialog deletes itself when it closes setAttribute(Qt::WA_DeleteOnClose); - // use an OAuthNetworkAccessManager instead of regular QNetworkAccessManager so our requests are authed - page()->setNetworkAccessManager(OAuthNetworkAccessManager::getInstance()); - - // have the page delegate external links so they can be captured by the Application in case they are a hifi link - page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); + // set our page to a DataWebPage + setPage(new DataWebPage(this)); // have the Application handle external links connect(this, &QWebView::linkClicked, Application::getInstance(), &Application::openUrl); diff --git a/interface/src/ui/DataWebPage.cpp b/interface/src/ui/DataWebPage.cpp new file mode 100644 index 0000000000..812489a34d --- /dev/null +++ b/interface/src/ui/DataWebPage.cpp @@ -0,0 +1,31 @@ +// +// DataWebPage.cpp +// interface/src/ui +// +// Created by Stephen Birarda on 2014-09-22. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#include + +#include "DataWebPage.h" + +DataWebPage::DataWebPage(QObject* parent) : + QWebPage(parent) +{ + // use an OAuthNetworkAccessManager instead of regular QNetworkAccessManager so our requests are authed + setNetworkAccessManager(OAuthNetworkAccessManager::getInstance()); + + // have the page delegate external links so they can be captured by the Application in case they are a hifi link + setLinkDelegationPolicy(QWebPage::DelegateExternalLinks); + + // give the page an empty stylesheet + settings()->setUserStyleSheetUrl(QUrl()); +} + +void DataWebPage::javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) { + qDebug() << "JS console message at line" << lineNumber << "from" << sourceID << "-" << message; +} \ No newline at end of file diff --git a/interface/src/ui/DataWebPage.h b/interface/src/ui/DataWebPage.h new file mode 100644 index 0000000000..72fcbb5992 --- /dev/null +++ b/interface/src/ui/DataWebPage.h @@ -0,0 +1,24 @@ +// +// DataWebPage.h +// interface/src/ui +// +// Created by Stephen Birarda on 2014-09-22. +// Copyright 2014 High Fidelity, Inc. +// +// Distributed under the Apache License, Version 2.0. +// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html +// + +#ifndef hifi_DataWebPage_h +#define hifi_DataWebPage_h + +#include + +class DataWebPage : public QWebPage { +public: + DataWebPage(QObject* parent = 0); +protected: + void javaScriptConsoleMessage(const QString & message, int lineNumber, const QString & sourceID); +}; + +#endif // hifi_DataWebPage_h \ No newline at end of file