From fa31ba0754a8c615f9fa09e074761d90171371c4 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Sun, 26 Apr 2015 10:37:14 -0700 Subject: [PATCH] Info-view --- .../resources/html/interface-welcome.html | 72 +++++---- interface/resources/qml/InfoView.qml | 32 ++++ libraries/ui/CMakeLists.txt | 2 +- libraries/ui/src/InfoView.cpp | 139 ++++++++++++++++++ libraries/ui/src/InfoView.h | 38 +++++ tests/ui/src/main.cpp | 23 ++- 6 files changed, 263 insertions(+), 43 deletions(-) create mode 100644 interface/resources/qml/InfoView.qml create mode 100644 libraries/ui/src/InfoView.cpp create mode 100644 libraries/ui/src/InfoView.h diff --git a/interface/resources/html/interface-welcome.html b/interface/resources/html/interface-welcome.html index 26ae6ff5c0..1fc719ed72 100644 --- a/interface/resources/html/interface-welcome.html +++ b/interface/resources/html/interface-welcome.html @@ -1,8 +1,7 @@ - - + Welcome to Interface @@ -85,63 +84,63 @@

Move around

- + Move around

- Move around with WASD & fly
- up or down with E & C.
- Cmnd/Ctrl+G will send you
- home. Hitting Enter will let you
+ Move around with WASD & fly
+ up or down with E & C.
+ Cmnd/Ctrl+G will send you
+ home. Hitting Enter will let you
teleport to a user or location.

-

Listen & talk

- +

Listen & talk

+ Talk

- Use your best headphones
- and microphone for high
- fidelity audio. Chat via text by
+ Use your best headphones
+ and microphone for high
+ fidelity audio. Chat via text by
pressing the \ key.

Connect devices

- + Connect devices

- Have an Oculus Rift, a Razer
- Hydra, or a PrimeSense 3D
+ Have an Oculus Rift, a Razer
+ Hydra, or a PrimeSense 3D
camera? We support them all.

Run a script

- + Run a script

- Cmnd/Cntrl+J will launch a
- Running Scripts dialog to help
- manage your scripts and search
+ Cmnd/Cntrl+J will launch a
+ Running Scripts dialog to help
+ manage your scripts and search
for new ones to run.

Script something

- + Write a script

- Write a script; we're always
- adding new features.
- Cmnd/Cntrl+J will launch a
- Running Scripts dialog to help
+ Write a script; we're always
+ adding new features.
+ Cmnd/Cntrl+J will launch a
+ Running Scripts dialog to help
manage your scripts.

Import models

- + Import models

- Use the edit.js script to
- add FBX models in-world. You
- can use grids and fine tune
- placement-related parameters
+ Use the edit.js script to
+ add FBX models in-world. You
+ can use grids and fine tune
+ placement-related parameters
with ease.

@@ -149,20 +148,19 @@

Read the docs

- We are writing documentation on
- just about everything. Please,
- devour all we've written and make
- suggestions where necessary.
- Documentation is always at
+ We are writing documentation on
+ just about everything. Please,
+ devour all we've written and make
+ suggestions where necessary.
+ Documentation is always at
docs.highfidelity.com

-
- +//]]> diff --git a/interface/resources/qml/InfoView.qml b/interface/resources/qml/InfoView.qml new file mode 100644 index 0000000000..bd46ec2faa --- /dev/null +++ b/interface/resources/qml/InfoView.qml @@ -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 + } + } + + } +} diff --git a/libraries/ui/CMakeLists.txt b/libraries/ui/CMakeLists.txt index 36a0a1a846..1aefc99c78 100644 --- a/libraries/ui/CMakeLists.txt +++ b/libraries/ui/CMakeLists.txt @@ -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) diff --git a/libraries/ui/src/InfoView.cpp b/libraries/ui/src/InfoView.cpp new file mode 100644 index 0000000000..dee3caffc3 --- /dev/null +++ b/libraries/ui/src/InfoView.cpp @@ -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 +#include +#include + +const QUrl InfoView::QML{ "InfoView.qml" }; +const QString InfoView::NAME{ "InfoView" }; + +Setting::Handle infoVersion("info-version", QString()); + +InfoView::InfoView(QQuickItem* parent) : QQuickItem(parent) { + +} + +void InfoView::registerType() { + qmlRegisterType("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(); + QString infoViewName(NAME + "_" + path); + offscreenUi->show(QML, NAME + "_" + path, [=](QQmlContext* context, QObject* newObject){ + InfoView* newInfoView = newObject->findChild(); + 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 +//#include +//#include +//#include +//#include +//#include +// +//#include +//#include +// +//#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 \ No newline at end of file diff --git a/libraries/ui/src/InfoView.h b/libraries/ui/src/InfoView.h new file mode 100644 index 0000000000..ba415c5f37 --- /dev/null +++ b/libraries/ui/src/InfoView.h @@ -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 +#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 diff --git a/tests/ui/src/main.cpp b/tests/ui/src/main.cpp index 192bfd928b..39bd88d2f1 100644 --- a/tests/ui/src/main.cpp +++ b/tests/ui/src/main.cpp @@ -27,15 +27,17 @@ #include #include #include - +#include +#include #include #include #include #include #include - +#include #include "MessageDialog.h" #include "HifiMenu.h" +#include "InfoView.h" class RateCounter { std::vector times; @@ -239,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; @@ -321,6 +332,7 @@ public: MessageDialog::registerType(); VrMenu::registerType(); + InfoView::registerType(); qmlRegisterType("Hifi", 1, 0, "MenuConstants"); @@ -406,6 +418,7 @@ protected: switch (event->key()) { case Qt::Key_L: if (event->modifiers() & Qt::CTRL) { + InfoView::show(getResourcesDir() + "html/interface-welcome.html", true); } break; case Qt::Key_K: @@ -484,7 +497,7 @@ qt.quick.mouse.debug=false int main(int argc, char** argv) { QGuiApplication app(argc, argv); -// QLoggingCategory::setFilterRules(LOG_FILTER_RULES); + // QLoggingCategory::setFilterRules(LOG_FILTER_RULES); QTestWindow window; app.exec(); return 0;