Info-view

This commit is contained in:
Brad Davis 2015-04-26 10:37:14 -07:00
parent d4d469b881
commit fa31ba0754
6 changed files with 263 additions and 43 deletions

View file

@ -1,8 +1,7 @@
<!-- Copyright 2015 High Fidelity, Inc. --> <!-- Copyright 2015 High Fidelity, Inc. -->
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8"/>
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<input type="hidden" id="version" value="1"/> <input type="hidden" id="version" value="1"/>
<title>Welcome to Interface</title> <title>Welcome to Interface</title>
@ -85,63 +84,63 @@
<div id="container" class="grid"> <div id="container" class="grid">
<div class="grid-unit"> <div class="grid-unit">
<h3>Move around</h3> <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> <p>
Move around with WASD & fly<br> Move around with WASD &amp; fly<br/>
up or down with E & C.<br> up or down with E &amp; C.<br/>
Cmnd/Ctrl+G will send you<br> Cmnd/Ctrl+G will send you<br/>
home. Hitting Enter will let you<br> home. Hitting Enter will let you<br/>
teleport to a user or location. teleport to a user or location.
</p> </p>
</div> </div>
<div class="grid-unit"> <div class="grid-unit">
<h3>Listen & talk</h3> <h3>Listen &amp; talk</h3>
<img class="grid-img" src="img/talk.png" alt"Talk"></img> <img class="grid-img" src="img/talk.png" alt="Talk"></img>
<p> <p>
Use your best headphones<br> Use your best headphones<br/>
and microphone for high<br> and microphone for high<br/>
fidelity audio. Chat via text by<br> fidelity audio. Chat via text by<br/>
pressing the \ key. pressing the \ key.
</p> </p>
</div> </div>
<div class="grid-unit"> <div class="grid-unit">
<h3>Connect devices</h3> <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> <p>
Have an Oculus Rift, a Razer<br> Have an Oculus Rift, a Razer<br/>
Hydra, or a PrimeSense 3D<br> Hydra, or a PrimeSense 3D<br/>
camera? We support them all. camera? We support them all.
</p> </p>
</div> </div>
<div class="grid-unit"> <div class="grid-unit">
<h3>Run a script</h3> <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> <p>
Cmnd/Cntrl+J will launch a<br> Cmnd/Cntrl+J will launch a<br/>
Running Scripts dialog to help<br> Running Scripts dialog to help<br/>
manage your scripts and search<br> manage your scripts and search<br/>
for new ones to run. for new ones to run.
</p> </p>
</div> </div>
<div class="grid-unit"> <div class="grid-unit">
<h3>Script something</h3> <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> <p>
Write a script; we're always<br> Write a script; we're always<br/>
adding new features.<br> adding new features.<br/>
Cmnd/Cntrl+J will launch a<br> Cmnd/Cntrl+J will launch a<br/>
Running Scripts dialog to help<br> Running Scripts dialog to help<br/>
manage your scripts. manage your scripts.
</p> </p>
</div> </div>
<div class="grid-unit"> <div class="grid-unit">
<h3>Import models</h3> <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> <p>
Use the <strong>edit.js</strong> script to<br> Use the <strong>edit.js</strong> script to<br/>
add FBX models in-world. You<br> add FBX models in-world. You<br/>
can use grids and fine tune<br> can use grids and fine tune<br/>
placement-related parameters<br> placement-related parameters<br/>
with ease. with ease.
</p> </p>
</div> </div>
@ -149,20 +148,19 @@
<div class="grid-unit"> <div class="grid-unit">
<h3>Read the docs</h3> <h3>Read the docs</h3>
<p> <p>
We are writing documentation on<br> We are writing documentation on<br/>
just about everything. Please,<br> just about everything. Please,<br/>
devour all we've written and make<br> devour all we've written and make<br/>
suggestions where necessary.<br> suggestions where necessary.<br/>
Documentation is always at<br> Documentation is always at<br/>
<a href="http://docs.highfidelity.com/"><b>docs.highfidelity.com</b></a> <a href="http://docs.highfidelity.com/"><b>docs.highfidelity.com</b></a>
</p> </p>
</div> </div>
<div class="grid-unit padding-block"></div> <div class="grid-unit padding-block"></div>
</div>
</div> </div>
</body> </body>
<script> <script>//<![CDATA[
<!-- Masonry PACKAGED v3.2.2 --> <!-- Masonry PACKAGED v3.2.2 -->
<!-- Cascading grid layout library --> <!-- Cascading grid layout library -->
<!-- http://masonry.desandro.com --> <!-- http://masonry.desandro.com -->
@ -185,6 +183,6 @@
<!-- Force reset layout after body resized--> <!-- Force reset layout after body resized-->
container.style.width = "0"; container.style.width = "0";
} }
</script> //]]></script>
</html> </html>

View file

@ -0,0 +1,32 @@
import Hifi 1.0
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: 720
height: 1024
resizable: true
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
}
}
}
}

View file

@ -1,7 +1,7 @@
set(TARGET_NAME ui) set(TARGET_NAME ui)
# use setup_hifi_library macro to setup our project and link appropriate Qt modules # 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) link_hifi_libraries(render-utils shared)

View file

@ -0,0 +1,139 @@
//
//
// 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>
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 forced) {
QUrl url = QUrl::fromLocalFile(path);
if (!forced) {
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){
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();
}
}
//#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;
//
//
//
//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);
//}
//
//
//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);
//}
//#endif

View 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 forced = false);
InfoView(QQuickItem* parent = nullptr);
QUrl url();
void setUrl(const QUrl & url);
signals:
void urlChanged();
private:
QUrl _url;
};
#endif // hifi_InfoView_h

View file

@ -27,15 +27,17 @@
#include <QOpenGLFunctions> #include <QOpenGLFunctions>
#include <QQmlContext> #include <QQmlContext>
#include <QtQml/QQmlApplicationEngine> #include <QtQml/QQmlApplicationEngine>
#include <PathUtils.h>
#include <QXmlQuery>
#include <unordered_map> #include <unordered_map>
#include <memory> #include <memory>
#include <glm/glm.hpp> #include <glm/glm.hpp>
#include <PathUtils.h> #include <PathUtils.h>
#include <QDir> #include <QDir>
#include <QXmlResultItems>
#include "MessageDialog.h" #include "MessageDialog.h"
#include "HifiMenu.h" #include "HifiMenu.h"
#include "InfoView.h"
class RateCounter { class RateCounter {
std::vector<float> times; std::vector<float> times;
@ -239,12 +241,21 @@ public:
} }
}; };
const QString & getQmlDir() { const QString & getResourcesDir() {
static QString dir; static QString dir;
if (dir.isEmpty()) { if (dir.isEmpty()) {
QDir path(__FILE__); QDir path(__FILE__);
path.cdUp(); 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; qDebug() << "Qml Path: " << dir;
} }
return dir; return dir;
@ -321,6 +332,7 @@ public:
MessageDialog::registerType(); MessageDialog::registerType();
VrMenu::registerType(); VrMenu::registerType();
InfoView::registerType();
qmlRegisterType<MenuConstants>("Hifi", 1, 0, "MenuConstants"); qmlRegisterType<MenuConstants>("Hifi", 1, 0, "MenuConstants");
@ -406,6 +418,7 @@ 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) {
InfoView::show(getResourcesDir() + "html/interface-welcome.html", true);
} }
break; break;
case Qt::Key_K: case Qt::Key_K:
@ -484,7 +497,7 @@ qt.quick.mouse.debug=false
int main(int argc, char** argv) { int main(int argc, char** argv) {
QGuiApplication app(argc, argv); QGuiApplication app(argc, argv);
// QLoggingCategory::setFilterRules(LOG_FILTER_RULES); // QLoggingCategory::setFilterRules(LOG_FILTER_RULES);
QTestWindow window; QTestWindow window;
app.exec(); app.exec();
return 0; return 0;