mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:43:31 +02:00
Working on marketplace dialog
This commit is contained in:
parent
ae804357d8
commit
a9d65f168b
7 changed files with 168 additions and 31 deletions
51
interface/resources/qml/MarketplaceDialog.qml
Normal file
51
interface/resources/qml/MarketplaceDialog.qml
Normal file
|
@ -0,0 +1,51 @@
|
||||||
|
import Hifi 1.0
|
||||||
|
import QtQuick 2.3
|
||||||
|
import QtQuick.Controls 1.2
|
||||||
|
import QtQuick.Window 2.2
|
||||||
|
import QtQuick.Dialogs 1.2
|
||||||
|
import QtQuick.Controls.Styles 1.3
|
||||||
|
import QtWebKit 3.0
|
||||||
|
|
||||||
|
CustomDialog {
|
||||||
|
title: "Test Dlg"
|
||||||
|
id: testDialog
|
||||||
|
objectName: "Browser"
|
||||||
|
width: 720
|
||||||
|
height: 720
|
||||||
|
resizable: true
|
||||||
|
|
||||||
|
MarketplaceDialog {
|
||||||
|
id: marketplaceDialog
|
||||||
|
}
|
||||||
|
|
||||||
|
Item {
|
||||||
|
id: clientArea
|
||||||
|
// The client area
|
||||||
|
anchors.fill: parent
|
||||||
|
anchors.margins: parent.margins
|
||||||
|
anchors.topMargin: parent.topMargin
|
||||||
|
|
||||||
|
|
||||||
|
ScrollView {
|
||||||
|
anchors.fill: parent
|
||||||
|
WebView {
|
||||||
|
objectName: "WebView"
|
||||||
|
id: webview
|
||||||
|
url: "https://metaverse.highfidelity.com/marketplace"
|
||||||
|
anchors.fill: parent
|
||||||
|
onNavigationRequested: {
|
||||||
|
console.log(request.url)
|
||||||
|
if (!marketplaceDialog.navigationRequested(request.url)) {
|
||||||
|
console.log("Application absorbed the request")
|
||||||
|
request.action = WebView.IgnoreRequest;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log("Application passed on the request")
|
||||||
|
request.action = WebView.AcceptRequest;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,29 +0,0 @@
|
||||||
var component;
|
|
||||||
var instance;
|
|
||||||
var parent;
|
|
||||||
|
|
||||||
function createObject(parentObject, url) {
|
|
||||||
parent = parentObject;
|
|
||||||
component = Qt.createComponent(url);
|
|
||||||
if (component.status == Component.Ready)
|
|
||||||
finishCreation();
|
|
||||||
else
|
|
||||||
component.statusChanged.connect(finishCreation);
|
|
||||||
}
|
|
||||||
|
|
||||||
function finishCreation() {
|
|
||||||
if (component.status == Component.Ready) {
|
|
||||||
instance = component.createObject(parent, {"x": 100, "y": 100});
|
|
||||||
if (instance == null) {
|
|
||||||
// Error Handling
|
|
||||||
console.log("Error creating object");
|
|
||||||
} else {
|
|
||||||
instance.enabled = true
|
|
||||||
}
|
|
||||||
} else if (component.status == Component.Error) {
|
|
||||||
// Error Handling
|
|
||||||
console.log("Error loading component:", component.errorString());
|
|
||||||
} else {
|
|
||||||
console.log("Unknown component status: " + component.status);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -52,6 +52,8 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
|
#include <QQmlNetworkAccessManagerFactory>
|
||||||
|
#include <QThreadStorage>
|
||||||
|
|
||||||
#include <AddressManager.h>
|
#include <AddressManager.h>
|
||||||
#include <AccountManager.h>
|
#include <AccountManager.h>
|
||||||
|
@ -82,6 +84,7 @@
|
||||||
#include <TextRenderer.h>
|
#include <TextRenderer.h>
|
||||||
#include <UserActivityLogger.h>
|
#include <UserActivityLogger.h>
|
||||||
#include <UUID.h>
|
#include <UUID.h>
|
||||||
|
#include <OAuthNetworkAccessManager.h>
|
||||||
|
|
||||||
#include <SceneScriptingInterface.h>
|
#include <SceneScriptingInterface.h>
|
||||||
|
|
||||||
|
@ -132,6 +135,7 @@
|
||||||
#include "ui/DialogsManager.h"
|
#include "ui/DialogsManager.h"
|
||||||
#include "ui/InfoView.h"
|
#include "ui/InfoView.h"
|
||||||
#include "ui/LoginDialog.h"
|
#include "ui/LoginDialog.h"
|
||||||
|
#include "ui/MarketplaceDialog.h"
|
||||||
#include "ui/Snapshot.h"
|
#include "ui/Snapshot.h"
|
||||||
#include "ui/StandAloneJSConsole.h"
|
#include "ui/StandAloneJSConsole.h"
|
||||||
#include "ui/Stats.h"
|
#include "ui/Stats.h"
|
||||||
|
@ -743,12 +747,26 @@ void Application::initializeGL() {
|
||||||
InfoView::showFirstTime(INFO_HELP_PATH);
|
InfoView::showFirstTime(INFO_HELP_PATH);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OAuthFactory : public QQmlNetworkAccessManagerFactory {
|
||||||
|
QThreadStorage<OAuthNetworkAccessManager*> oauthNetworkAccessManagers;
|
||||||
|
public:
|
||||||
|
virtual QNetworkAccessManager * create(QObject * parent) {
|
||||||
|
if (!oauthNetworkAccessManagers.hasLocalData()) {
|
||||||
|
oauthNetworkAccessManagers.setLocalData(OAuthNetworkAccessManager::getInstance());
|
||||||
|
}
|
||||||
|
return oauthNetworkAccessManagers.localData();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
void Application::initializeUi() {
|
void Application::initializeUi() {
|
||||||
AddressBarDialog::registerType();
|
AddressBarDialog::registerType();
|
||||||
LoginDialog::registerType();
|
LoginDialog::registerType();
|
||||||
|
MarketplaceDialog::registerType();
|
||||||
|
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
offscreenUi->create(_glWidget->context()->contextHandle());
|
offscreenUi->create(_glWidget->context()->contextHandle());
|
||||||
|
offscreenUi->qmlEngine()->setNetworkAccessManagerFactory(new OAuthFactory());
|
||||||
|
offscreenUi->qmlEngine()->networkAccessManager();
|
||||||
offscreenUi->resize(_glWidget->size());
|
offscreenUi->resize(_glWidget->size());
|
||||||
offscreenUi->setProxyWindow(_window->windowHandle());
|
offscreenUi->setProxyWindow(_window->windowHandle());
|
||||||
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
offscreenUi->setBaseUrl(QUrl::fromLocalFile(PathUtils::resourcesPath() + "/qml/"));
|
||||||
|
@ -1129,7 +1147,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Backslash:
|
case Qt::Key_Backslash:
|
||||||
Menu::getInstance()->triggerOption(MenuOption::Chat);
|
MarketplaceDialog::show();
|
||||||
|
|
||||||
|
//Menu::getInstance()->triggerOption(MenuOption::Chat);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Qt::Key_Up:
|
case Qt::Key_Up:
|
||||||
|
|
|
@ -51,7 +51,7 @@ void WindowScriptingInterface::setFocus() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::raiseMainWindow() {
|
void WindowScriptingInterface::raiseMainWindow() {
|
||||||
Application::getInstance()->getWindow()->raise();
|
// Application::getInstance()->getWindow()->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void WindowScriptingInterface::setCursorVisible(bool visible) {
|
void WindowScriptingInterface::setCursorVisible(bool visible) {
|
||||||
|
|
49
interface/src/ui/MarketplaceDialog.cpp
Normal file
49
interface/src/ui/MarketplaceDialog.cpp
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
//
|
||||||
|
// AddressBarDialog.cpp
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/04/14
|
||||||
|
// Copyright 2015 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 "Application.h"
|
||||||
|
#include "MarketplaceDialog.h"
|
||||||
|
|
||||||
|
|
||||||
|
#include <QWebEnginePage>
|
||||||
|
|
||||||
|
#include "DependencyManager.h"
|
||||||
|
|
||||||
|
QML_DIALOG_DEF(MarketplaceDialog)
|
||||||
|
|
||||||
|
|
||||||
|
MarketplaceDialog::MarketplaceDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) {
|
||||||
|
this->
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MarketplaceDialog::navigationRequested(const QString & url) {
|
||||||
|
qDebug() << url;
|
||||||
|
if (Application::getInstance()->canAcceptURL(url)) {
|
||||||
|
qDebug() << "Trying to send url to the app";
|
||||||
|
if (Application::getInstance()->acceptURL(url)) {
|
||||||
|
qDebug() << "Sent url to the app";
|
||||||
|
return false; // we handled it, so QWebPage doesn't need to handle it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
//https://metaverse.highfidelity.com/marketplace
|
||||||
|
|
||||||
|
//
|
||||||
|
//bool DataWebPage::acceptNavigationRequest(QWebFrame* frame, const QNetworkRequest& request, QWebPage::NavigationType type) {
|
||||||
|
// QString urlString = request.url().toString();
|
||||||
|
// if (Application::getInstance()->canAcceptURL(urlString)) {
|
||||||
|
// if (Application::getInstance()->acceptURL(urlString)) {
|
||||||
|
// return false; // we handled it, so QWebPage doesn't need to handle it
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return true;
|
||||||
|
//}
|
29
interface/src/ui/MarketplaceDialog.h
Normal file
29
interface/src/ui/MarketplaceDialog.h
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
//
|
||||||
|
// AddressBarDialog.h
|
||||||
|
//
|
||||||
|
// Created by Bradley Austin Davis on 2015/04/14
|
||||||
|
// Copyright 2015 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#ifndef hifi_MarketplaceDialog_h
|
||||||
|
#define hifi_MarketplaceDialog_h
|
||||||
|
|
||||||
|
#include <OffscreenQmlDialog.h>
|
||||||
|
|
||||||
|
class MarketplaceDialog : public OffscreenQmlDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
QML_DIALOG_DECL
|
||||||
|
|
||||||
|
public:
|
||||||
|
MarketplaceDialog(QQuickItem *parent = 0);
|
||||||
|
|
||||||
|
Q_INVOKABLE bool navigationRequested(const QString & url);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -27,6 +27,8 @@
|
||||||
#include <QOpenGLVertexArrayObject>
|
#include <QOpenGLVertexArrayObject>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
#include <QOpenGLDebugLogger>
|
#include <QOpenGLDebugLogger>
|
||||||
|
#include <QWebEnginePage>
|
||||||
|
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
@ -189,6 +191,8 @@ public:
|
||||||
});
|
});
|
||||||
installEventFilter(offscreenUi.data());
|
installEventFilter(offscreenUi.data());
|
||||||
offscreenUi->resume();
|
offscreenUi->resume();
|
||||||
|
QWebEnginePage *page = new QWebEnginePage;
|
||||||
|
page->runJavaScript("'Java''' 'Script'", [](const QVariant &result) { qDebug() << result; });
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~QTestWindow() {
|
virtual ~QTestWindow() {
|
||||||
|
@ -210,9 +214,22 @@ protected:
|
||||||
switch (event->key()) {
|
switch (event->key()) {
|
||||||
case Qt::Key_L:
|
case Qt::Key_L:
|
||||||
if (event->modifiers() & Qt::CTRL) {
|
if (event->modifiers() & Qt::CTRL) {
|
||||||
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
|
offscreenUi->qmlEngine()->clearComponentCache();
|
||||||
DependencyManager::get<OffscreenUi>()->toggle(QString("TestDialog.qml"), "TestDialog");
|
DependencyManager::get<OffscreenUi>()->toggle(QString("TestDialog.qml"), "TestDialog");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Qt::Key_K:
|
||||||
|
if (event->modifiers() & Qt::CTRL) {
|
||||||
|
DependencyManager::get<OffscreenUi>()->toggle(QString("Browser.qml"), "Browser");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Qt::Key_J:
|
||||||
|
if (event->modifiers() & Qt::CTRL) {
|
||||||
|
QObject * obj = DependencyManager::get<OffscreenUi>()->findObject("WebView");
|
||||||
|
qDebug() << obj;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
QWindow::keyPressEvent(event);
|
QWindow::keyPressEvent(event);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue