mirror of
https://github.com/overte-org/overte.git
synced 2025-04-08 08:14:48 +02:00
Merge pull request #4701 from jherico/infoview
Infoviews & Browser in QML
This commit is contained in:
commit
4de6d645e5
11 changed files with 386 additions and 212 deletions
|
@ -1,8 +1,7 @@
|
|||
<!-- Copyright 2015 High Fidelity, Inc. -->
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<meta charset="utf-8"/>
|
||||
<input type="hidden" id="version" value="1"/>
|
||||
<title>Welcome to Interface</title>
|
||||
|
||||
|
@ -85,63 +84,63 @@
|
|||
<div id="container" class="grid">
|
||||
<div class="grid-unit">
|
||||
<h3>Move around</h3>
|
||||
<img class="grid-img" src="img/move.png" alt"Move around"></img>
|
||||
<img class="grid-img" src="img/move.png" alt="Move around"></img>
|
||||
<p>
|
||||
Move around with WASD & fly<br>
|
||||
up or down with E & C.<br>
|
||||
Cmnd/Ctrl+G will send you<br>
|
||||
home. Hitting Enter will let you<br>
|
||||
Move around with WASD & fly<br/>
|
||||
up or down with E & C.<br/>
|
||||
Cmnd/Ctrl+G will send you<br/>
|
||||
home. Hitting Enter will let you<br/>
|
||||
teleport to a user or location.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid-unit">
|
||||
<h3>Listen & talk</h3>
|
||||
<img class="grid-img" src="img/talk.png" alt"Talk"></img>
|
||||
<h3>Listen & talk</h3>
|
||||
<img class="grid-img" src="img/talk.png" alt="Talk"></img>
|
||||
<p>
|
||||
Use your best headphones<br>
|
||||
and microphone for high<br>
|
||||
fidelity audio. Chat via text by<br>
|
||||
Use your best headphones<br/>
|
||||
and microphone for high<br/>
|
||||
fidelity audio. Chat via text by<br/>
|
||||
pressing the \ key.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid-unit">
|
||||
<h3>Connect devices</h3>
|
||||
<img class="grid-img" src="img/devices.png" alt"Connect devices"></img>
|
||||
<img class="grid-img" src="img/devices.png" alt="Connect devices"></img>
|
||||
<p>
|
||||
Have an Oculus Rift, a Razer<br>
|
||||
Hydra, or a PrimeSense 3D<br>
|
||||
Have an Oculus Rift, a Razer<br/>
|
||||
Hydra, or a PrimeSense 3D<br/>
|
||||
camera? We support them all.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid-unit">
|
||||
<h3>Run a script</h3>
|
||||
<img class="grid-img" src="img/run-script.png" alt"Run a script"></img>
|
||||
<img class="grid-img" src="img/run-script.png" alt="Run a script"></img>
|
||||
<p>
|
||||
Cmnd/Cntrl+J will launch a<br>
|
||||
Running Scripts dialog to help<br>
|
||||
manage your scripts and search<br>
|
||||
Cmnd/Cntrl+J will launch a<br/>
|
||||
Running Scripts dialog to help<br/>
|
||||
manage your scripts and search<br/>
|
||||
for new ones to run.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid-unit">
|
||||
<h3>Script something</h3>
|
||||
<img class="grid-img" src="img/write-script.png" alt"Write a script"></img>
|
||||
<img class="grid-img" src="img/write-script.png" alt="Write a script"></img>
|
||||
<p>
|
||||
Write a script; we're always<br>
|
||||
adding new features.<br>
|
||||
Cmnd/Cntrl+J will launch a<br>
|
||||
Running Scripts dialog to help<br>
|
||||
Write a script; we're always<br/>
|
||||
adding new features.<br/>
|
||||
Cmnd/Cntrl+J will launch a<br/>
|
||||
Running Scripts dialog to help<br/>
|
||||
manage your scripts.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid-unit">
|
||||
<h3>Import models</h3>
|
||||
<img class="grid-img" src="img/models.png" alt"Import models"></img>
|
||||
<img class="grid-img" src="img/models.png" alt="Import models"></img>
|
||||
<p>
|
||||
Use the <strong>edit.js</strong> script to<br>
|
||||
add FBX models in-world. You<br>
|
||||
can use grids and fine tune<br>
|
||||
placement-related parameters<br>
|
||||
Use the <strong>edit.js</strong> script to<br/>
|
||||
add FBX models in-world. You<br/>
|
||||
can use grids and fine tune<br/>
|
||||
placement-related parameters<br/>
|
||||
with ease.
|
||||
</p>
|
||||
</div>
|
||||
|
@ -149,20 +148,19 @@
|
|||
<div class="grid-unit">
|
||||
<h3>Read the docs</h3>
|
||||
<p>
|
||||
We are writing documentation on<br>
|
||||
just about everything. Please,<br>
|
||||
devour all we've written and make<br>
|
||||
suggestions where necessary.<br>
|
||||
Documentation is always at<br>
|
||||
We are writing documentation on<br/>
|
||||
just about everything. Please,<br/>
|
||||
devour all we've written and make<br/>
|
||||
suggestions where necessary.<br/>
|
||||
Documentation is always at<br/>
|
||||
<a href="http://docs.highfidelity.com/"><b>docs.highfidelity.com</b></a>
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid-unit padding-block"></div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
<script>
|
||||
<script>//<![CDATA[
|
||||
<!-- Masonry PACKAGED v3.2.2 -->
|
||||
<!-- Cascading grid layout library -->
|
||||
<!-- http://masonry.desandro.com -->
|
||||
|
@ -185,6 +183,6 @@
|
|||
<!-- Force reset layout after body resized-->
|
||||
container.style.width = "0";
|
||||
}
|
||||
</script>
|
||||
//]]></script>
|
||||
|
||||
</html>
|
||||
|
|
|
@ -2,29 +2,149 @@ import QtQuick 2.3
|
|||
import QtQuick.Controls 1.2
|
||||
import QtWebKit 3.0
|
||||
import "controls"
|
||||
import "styles"
|
||||
|
||||
Dialog {
|
||||
title: "Browser Window"
|
||||
id: testDialog
|
||||
objectName: "Browser"
|
||||
width: 1280
|
||||
height: 720
|
||||
id: root
|
||||
HifiConstants { id: hifi }
|
||||
title: "Browser"
|
||||
resizable: true
|
||||
contentImplicitWidth: clientArea.implicitWidth
|
||||
contentImplicitHeight: clientArea.implicitHeight
|
||||
backgroundColor: "#7f000000"
|
||||
|
||||
|
||||
Component.onCompleted: {
|
||||
enabled = true
|
||||
addressBar.text = webview.url
|
||||
}
|
||||
|
||||
onParentChanged: {
|
||||
if (visible && enabled) {
|
||||
addressBar.forceActiveFocus();
|
||||
addressBar.selectAll()
|
||||
}
|
||||
}
|
||||
|
||||
Item {
|
||||
id: clientArea
|
||||
// The client area
|
||||
anchors.fill: parent
|
||||
anchors.margins: parent.margins
|
||||
anchors.topMargin: parent.topMargin
|
||||
|
||||
implicitHeight: 600
|
||||
implicitWidth: 800
|
||||
x: root.clientX
|
||||
y: root.clientY
|
||||
width: root.clientWidth
|
||||
height: root.clientHeight
|
||||
|
||||
Rectangle {
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.top: parent.top
|
||||
anchors.bottom: scrollView.top
|
||||
color: "white"
|
||||
}
|
||||
Row {
|
||||
id: buttons
|
||||
spacing: 4
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8
|
||||
anchors.left: parent.left
|
||||
anchors.leftMargin: 8
|
||||
FontAwesome {
|
||||
id: back; text: "\uf0a8"; size: 48; enabled: webview.canGoBack;
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
|
||||
}
|
||||
FontAwesome {
|
||||
id: forward; text: "\uf0a9"; size: 48; enabled: webview.canGoForward;
|
||||
color: enabled ? hifi.colors.text : hifi.colors.disabledText
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.goBack() }
|
||||
}
|
||||
FontAwesome {
|
||||
id: reload; size: 48; text: webview.loading ? "\uf057" : "\uf021"
|
||||
MouseArea { anchors.fill: parent; onClicked: webview.loading ? webview.stop() : webview.reload() }
|
||||
}
|
||||
}
|
||||
|
||||
Border {
|
||||
height: 48
|
||||
radius: 8
|
||||
anchors.top: parent.top
|
||||
anchors.topMargin: 8
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.left: buttons.right
|
||||
anchors.leftMargin: 8
|
||||
|
||||
Item {
|
||||
id: barIcon
|
||||
width: parent.height
|
||||
height: parent.height
|
||||
Image {
|
||||
source: webview.icon;
|
||||
x: (parent.height - height) / 2
|
||||
y: (parent.width - width) / 2
|
||||
verticalAlignment: Image.AlignVCenter;
|
||||
horizontalAlignment: Image.AlignHCenter
|
||||
onSourceChanged: console.log("Icon url: " + source)
|
||||
}
|
||||
}
|
||||
|
||||
TextInput {
|
||||
id: addressBar
|
||||
anchors.right: parent.right
|
||||
anchors.rightMargin: 8
|
||||
anchors.left: barIcon.right
|
||||
anchors.leftMargin: 0
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_Enter:
|
||||
case Qt.Key_Return:
|
||||
event.accepted = true
|
||||
if (text.indexOf("http") != 0) {
|
||||
text = "http://" + text
|
||||
}
|
||||
webview.url = text
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ScrollView {
|
||||
anchors.fill: parent
|
||||
id: scrollView
|
||||
anchors.top: buttons.bottom
|
||||
anchors.topMargin: 8
|
||||
anchors.bottom: parent.bottom
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
WebView {
|
||||
id: webview
|
||||
url: "http://slashdot.org"
|
||||
url: "http://highfidelity.com"
|
||||
anchors.fill: parent
|
||||
onLoadingChanged: {
|
||||
if (loadRequest.status == WebView.LoadSucceededStarted) {
|
||||
addressBar.text = loadRequest.url
|
||||
}
|
||||
}
|
||||
onIconChanged: {
|
||||
barIcon.source = icon
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
} // item
|
||||
|
||||
Keys.onPressed: {
|
||||
switch(event.key) {
|
||||
case Qt.Key_L:
|
||||
if (event.modifiers == Qt.ControlModifier) {
|
||||
event.accepted = true
|
||||
addressBar.selectAll()
|
||||
addressBar.forceActiveFocus()
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} // dialog
|
||||
|
|
32
interface/resources/qml/InfoView.qml
Normal file
32
interface/resources/qml/InfoView.qml
Normal file
|
@ -0,0 +1,32 @@
|
|||
import Hifi 1.0 as Hifi
|
||||
import QtQuick 2.3
|
||||
import QtQuick.Controls 1.2
|
||||
import QtQuick.Controls.Styles 1.3
|
||||
import QtWebKit 3.0
|
||||
import "controls"
|
||||
|
||||
Dialog {
|
||||
id: root
|
||||
width: 800
|
||||
height: 800
|
||||
resizable: true
|
||||
|
||||
Hifi.InfoView {
|
||||
id: infoView
|
||||
// Fille the client area
|
||||
anchors.fill: parent
|
||||
anchors.margins: parent.margins
|
||||
anchors.topMargin: parent.topMargin
|
||||
|
||||
ScrollView {
|
||||
anchors.fill: parent
|
||||
WebView {
|
||||
objectName: "WebView"
|
||||
id: webview
|
||||
url: infoView.url
|
||||
anchors.fill: parent
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -84,7 +84,7 @@
|
|||
#include <UserActivityLogger.h>
|
||||
#include <UUID.h>
|
||||
#include <MessageDialog.h>
|
||||
|
||||
#include <InfoView.h>
|
||||
#include <SceneScriptingInterface.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
@ -133,7 +133,6 @@
|
|||
|
||||
#include "ui/DataWebDialog.h"
|
||||
#include "ui/DialogsManager.h"
|
||||
#include "ui/InfoView.h"
|
||||
#include "ui/LoginDialog.h"
|
||||
#include "ui/Snapshot.h"
|
||||
#include "ui/StandAloneJSConsole.h"
|
||||
|
@ -775,8 +774,8 @@ void Application::initializeGL() {
|
|||
|
||||
// update before the first render
|
||||
update(1.0f / _fps);
|
||||
|
||||
InfoView::showFirstTime(INFO_HELP_PATH);
|
||||
|
||||
InfoView::show(INFO_HELP_PATH, true);
|
||||
}
|
||||
|
||||
void Application::initializeUi() {
|
||||
|
@ -940,11 +939,11 @@ void Application::faceTrackerMuteToggled() {
|
|||
}
|
||||
|
||||
void Application::aboutApp() {
|
||||
InfoView::forcedShow(INFO_HELP_PATH);
|
||||
InfoView::show(INFO_HELP_PATH);
|
||||
}
|
||||
|
||||
void Application::showEditEntitiesHelp() {
|
||||
InfoView::forcedShow(INFO_EDIT_ENTITIES_PATH);
|
||||
InfoView::show(INFO_EDIT_ENTITIES_PATH);
|
||||
}
|
||||
|
||||
void Application::resetCamerasOnResizeGL(Camera& camera, int width, int height) {
|
||||
|
@ -1131,6 +1130,13 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
|||
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
|
||||
break;
|
||||
|
||||
case Qt::Key_B:
|
||||
if (isMeta) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
offscreenUi->load("Browser.qml");
|
||||
}
|
||||
break;
|
||||
|
||||
case Qt::Key_L:
|
||||
if (isShifted && isMeta) {
|
||||
Menu::getInstance()->triggerOption(MenuOption::Log);
|
||||
|
|
|
@ -1,94 +0,0 @@
|
|||
//
|
||||
// InfoView.cpp
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Stojce Slavkovski on 9/7/13.
|
||||
// Copyright 2013 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 <QApplication>
|
||||
#include <QDesktopWidget>
|
||||
#include <QDesktopServices>
|
||||
#include <QFileInfo>
|
||||
#include <QtWebKitWidgets/QWebFrame>
|
||||
#include <QtWebKit/QWebElement>
|
||||
|
||||
#include <PathUtils.h>
|
||||
#include <SettingHandle.h>
|
||||
|
||||
#include "InfoView.h"
|
||||
|
||||
static const float MAX_DIALOG_HEIGHT_RATIO = 0.9f;
|
||||
|
||||
Setting::Handle<QString> infoVersion("info-version", QString());
|
||||
|
||||
InfoView::InfoView(bool forced, QString path) :
|
||||
_forced(forced)
|
||||
{
|
||||
setWindowFlags(Qt::WindowStaysOnTopHint | Qt::CustomizeWindowHint | Qt::WindowCloseButtonHint);
|
||||
|
||||
QString absPath = QFileInfo(PathUtils::resourcesPath() + path).absoluteFilePath();
|
||||
QUrl url = QUrl::fromLocalFile(absPath);
|
||||
|
||||
page()->setLinkDelegationPolicy(QWebPage::DelegateExternalLinks);
|
||||
connect(this, SIGNAL(linkClicked(QUrl)), this, SLOT(linkClickedInfoView(QUrl)));
|
||||
|
||||
load(url);
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loaded(bool)));
|
||||
}
|
||||
|
||||
void InfoView::showFirstTime(QString path) {
|
||||
new InfoView(false, path);
|
||||
}
|
||||
|
||||
void InfoView::forcedShow(QString path) {
|
||||
new InfoView(true, path);
|
||||
}
|
||||
|
||||
bool InfoView::shouldShow() {
|
||||
bool shouldShow = false;
|
||||
if (_forced) {
|
||||
return true;
|
||||
}
|
||||
|
||||
QString lastVersion = infoVersion.get();
|
||||
|
||||
QWebElement versionTag = page()->mainFrame()->findFirstElement("#version");
|
||||
QString version = versionTag.attribute("value");
|
||||
|
||||
if (version != QString::null && (lastVersion == QString::null || lastVersion != version)) {
|
||||
infoVersion.set(version);
|
||||
shouldShow = true;
|
||||
} else {
|
||||
shouldShow = false;
|
||||
}
|
||||
return shouldShow;
|
||||
}
|
||||
|
||||
void InfoView::loaded(bool ok) {
|
||||
if (!ok || !shouldShow()) {
|
||||
deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
QDesktopWidget* desktop = qApp->desktop();
|
||||
QWebFrame* mainFrame = page()->mainFrame();
|
||||
|
||||
int height = mainFrame->contentsSize().height() > desktop->height() ?
|
||||
desktop->height() * MAX_DIALOG_HEIGHT_RATIO :
|
||||
mainFrame->contentsSize().height();
|
||||
|
||||
resize(mainFrame->contentsSize().width(), height);
|
||||
move(desktop->screen()->rect().center() - rect().center());
|
||||
setWindowTitle(title());
|
||||
setAttribute(Qt::WA_DeleteOnClose);
|
||||
show();
|
||||
}
|
||||
|
||||
void InfoView::linkClickedInfoView(QUrl url) {
|
||||
close();
|
||||
QDesktopServices::openUrl(url);
|
||||
}
|
|
@ -1,33 +0,0 @@
|
|||
//
|
||||
// InfoView.h
|
||||
// interface/src/ui
|
||||
//
|
||||
// Created by Stojce Slavkovski on 9/7/13.
|
||||
// Copyright 2013 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_InfoView_h
|
||||
#define hifi_InfoView_h
|
||||
|
||||
#include <QtWebKitWidgets/QWebView>
|
||||
|
||||
class InfoView : public QWebView {
|
||||
Q_OBJECT
|
||||
public:
|
||||
static void showFirstTime(QString path);
|
||||
static void forcedShow(QString path);
|
||||
|
||||
private:
|
||||
InfoView(bool forced, QString path);
|
||||
bool _forced;
|
||||
bool shouldShow();
|
||||
|
||||
private slots:
|
||||
void loaded(bool ok);
|
||||
void linkClickedInfoView(QUrl url);
|
||||
};
|
||||
|
||||
#endif // hifi_InfoView_h
|
|
@ -1,7 +1,7 @@
|
|||
set(TARGET_NAME ui)
|
||||
|
||||
# use setup_hifi_library macro to setup our project and link appropriate Qt modules
|
||||
setup_hifi_library(OpenGL Network Qml Quick Script)
|
||||
setup_hifi_library(OpenGL Network Qml Quick Script XmlPatterns)
|
||||
|
||||
link_hifi_libraries(render-utils shared)
|
||||
|
||||
|
|
87
libraries/ui/src/InfoView.cpp
Normal file
87
libraries/ui/src/InfoView.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
//
|
||||
//
|
||||
// InfoView.h
|
||||
//
|
||||
// Created by Bradley Austin Davis 2015/04/25
|
||||
// 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 "InfoView.h"
|
||||
|
||||
#include <SettingHandle.h>
|
||||
#include <PathUtils.h>
|
||||
#include <QXmlQuery>
|
||||
#include <QDir>
|
||||
const QUrl InfoView::QML{ "InfoView.qml" };
|
||||
const QString InfoView::NAME{ "InfoView" };
|
||||
|
||||
Setting::Handle<QString> infoVersion("info-version", QString());
|
||||
|
||||
InfoView::InfoView(QQuickItem* parent) : QQuickItem(parent) {
|
||||
|
||||
}
|
||||
|
||||
void InfoView::registerType() {
|
||||
qmlRegisterType<InfoView>("Hifi", 1, 0, NAME.toLocal8Bit().constData());
|
||||
}
|
||||
|
||||
QString fetchVersion(const QUrl& url) {
|
||||
QXmlQuery query;
|
||||
query.bindVariable("file", QVariant(url));
|
||||
query.setQuery("string((doc($file)//input[@id='version'])[1]/@value)");
|
||||
QString r;
|
||||
query.evaluateTo(&r);
|
||||
return r.trimmed();
|
||||
}
|
||||
|
||||
void InfoView::show(const QString& path, bool firstOrChangedOnly) {
|
||||
static bool registered{ false };
|
||||
if (!registered) {
|
||||
registerType();
|
||||
registered = true;
|
||||
}
|
||||
QUrl url;
|
||||
if (QDir(path).isRelative()) {
|
||||
url = QUrl::fromLocalFile(PathUtils::resourcesPath() + path);
|
||||
} else {
|
||||
url = QUrl::fromLocalFile(path);
|
||||
}
|
||||
if (firstOrChangedOnly) {
|
||||
const QString lastVersion = infoVersion.get();
|
||||
// If we have version information stored
|
||||
if (lastVersion != QString::null) {
|
||||
// Check to see the document version. If it's valid and matches
|
||||
// the stored version, we're done, so exit
|
||||
const QString version = fetchVersion(url);
|
||||
if (version == QString::null || version == lastVersion) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
QString infoViewName(NAME + "_" + path);
|
||||
offscreenUi->show(QML, NAME + "_" + path, [=](QQmlContext* context, QObject* newObject){
|
||||
QQuickItem* item = dynamic_cast<QQuickItem*>(newObject);
|
||||
item->setWidth(720);
|
||||
item->setHeight(720);
|
||||
InfoView* newInfoView = newObject->findChild<InfoView*>();
|
||||
Q_ASSERT(newInfoView);
|
||||
newInfoView->parent()->setObjectName(infoViewName);
|
||||
newInfoView->setUrl(url);
|
||||
});
|
||||
}
|
||||
|
||||
QUrl InfoView::url() {
|
||||
return _url;
|
||||
}
|
||||
|
||||
void InfoView::setUrl(const QUrl& url) {
|
||||
if (url != _url) {
|
||||
_url = url;
|
||||
emit urlChanged();
|
||||
}
|
||||
}
|
||||
|
38
libraries/ui/src/InfoView.h
Normal file
38
libraries/ui/src/InfoView.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// InfoView.h
|
||||
//
|
||||
// Created by Bradley Austin Davis 2015/04/25
|
||||
// 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
|
||||
//
|
||||
|
||||
#ifndef hifi_InfoView_h
|
||||
#define hifi_InfoView_h
|
||||
|
||||
#include <QQuickItem>
|
||||
#include "OffscreenUi.h"
|
||||
|
||||
class InfoView : public QQuickItem {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
|
||||
|
||||
static const QUrl QML;
|
||||
static const QString NAME;
|
||||
public:
|
||||
static void registerType();
|
||||
static void show(const QString& path, bool firstOrChangedOnly = false);
|
||||
|
||||
InfoView(QQuickItem* parent = nullptr);
|
||||
QUrl url();
|
||||
void setUrl(const QUrl& url);
|
||||
|
||||
signals:
|
||||
void urlChanged();
|
||||
|
||||
private:
|
||||
QUrl _url;
|
||||
};
|
||||
|
||||
#endif // hifi_InfoView_h
|
|
@ -254,8 +254,11 @@ void OffscreenUi::updateQuick() {
|
|||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
_renderControl->render();
|
||||
|
||||
Q_ASSERT(!glGetError());
|
||||
// FIXME The web browsers seem to be leaving GL in an error state.
|
||||
// Need a debug context with sync logging to figure out why.
|
||||
// for now just clear the errors
|
||||
glGetError();
|
||||
// Q_ASSERT(!glGetError());
|
||||
|
||||
_quickWindow->resetOpenGLState();
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@
|
|||
#include <QOpenGLFunctions>
|
||||
#include <QQmlContext>
|
||||
#include <QtQml/QQmlApplicationEngine>
|
||||
|
||||
#include <PathUtils.h>
|
||||
#include <unordered_map>
|
||||
#include <memory>
|
||||
#include <glm/glm.hpp>
|
||||
#include <PathUtils.h>
|
||||
#include <QDir>
|
||||
|
||||
#include "MessageDialog.h"
|
||||
#include "VrMenu.h"
|
||||
#include "InfoView.h"
|
||||
#include <QDesktopWidget>
|
||||
|
||||
class RateCounter {
|
||||
|
@ -241,12 +241,21 @@ public:
|
|||
}
|
||||
};
|
||||
|
||||
const QString& getQmlDir() {
|
||||
const QString& getResourcesDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
QDir path(__FILE__);
|
||||
path.cdUp();
|
||||
dir = path.cleanPath(path.absoluteFilePath("../../../interface/resources/qml/")) + "/";
|
||||
dir = path.cleanPath(path.absoluteFilePath("../../../interface/resources/")) + "/";
|
||||
qDebug() << "Resources Path: " << dir;
|
||||
}
|
||||
return dir;
|
||||
}
|
||||
|
||||
const QString& getQmlDir() {
|
||||
static QString dir;
|
||||
if (dir.isEmpty()) {
|
||||
dir = getResourcesDir() + "qml/";
|
||||
qDebug() << "Qml Path: " << dir;
|
||||
}
|
||||
return dir;
|
||||
|
@ -323,6 +332,7 @@ public:
|
|||
|
||||
MessageDialog::registerType();
|
||||
VrMenu::registerType();
|
||||
InfoView::registerType();
|
||||
qmlRegisterType<MenuConstants>("Hifi", 1, 0, "MenuConstants");
|
||||
|
||||
|
||||
|
@ -412,24 +422,31 @@ protected:
|
|||
void keyPressEvent(QKeyEvent* event) {
|
||||
_altPressed = Qt::Key_Alt == event->key();
|
||||
switch (event->key()) {
|
||||
case Qt::Key_L:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
}
|
||||
break;
|
||||
case Qt::Key_K:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
OffscreenUi::question("Message title", "Message contents", [](QMessageBox::Button b){
|
||||
qDebug() << b;
|
||||
});
|
||||
}
|
||||
break;
|
||||
case Qt::Key_J:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
rootMenu = offscreenUi->getRootItem()->findChild<QObject*>("rootMenu");
|
||||
QMetaObject::invokeMethod(rootMenu, "popup");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_B:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
offscreenUi->load("Browser.qml");
|
||||
}
|
||||
break;
|
||||
case Qt::Key_L:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
InfoView::show(getResourcesDir() + "html/interface-welcome.html", true);
|
||||
}
|
||||
break;
|
||||
case Qt::Key_K:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
OffscreenUi::question("Message title", "Message contents", [](QMessageBox::Button b){
|
||||
qDebug() << b;
|
||||
});
|
||||
}
|
||||
break;
|
||||
case Qt::Key_J:
|
||||
if (event->modifiers() & Qt::CTRL) {
|
||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||
rootMenu = offscreenUi->getRootItem()->findChild<QObject*>("rootMenu");
|
||||
QMetaObject::invokeMethod(rootMenu, "popup");
|
||||
}
|
||||
break;
|
||||
}
|
||||
QWindow::keyPressEvent(event);
|
||||
}
|
||||
|
@ -445,7 +462,7 @@ protected:
|
|||
if (devicePixelRatio() != oldPixelRatio) {
|
||||
oldPixelRatio = devicePixelRatio();
|
||||
resizeWindow(size());
|
||||
}
|
||||
}
|
||||
QWindow::moveEvent(event);
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue