From fa31ba0754a8c615f9fa09e074761d90171371c4 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Sun, 26 Apr 2015 10:37:14 -0700 Subject: [PATCH 01/10] 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; From aafecae4b5865d85d9f3e7a811a4e64e730c4c1e Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Sun, 26 Apr 2015 20:10:22 -0700 Subject: [PATCH 02/10] Coding standards --- libraries/ui/src/InfoView.cpp | 4 ++-- libraries/ui/src/InfoView.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libraries/ui/src/InfoView.cpp b/libraries/ui/src/InfoView.cpp index dee3caffc3..5a5e20e28a 100644 --- a/libraries/ui/src/InfoView.cpp +++ b/libraries/ui/src/InfoView.cpp @@ -28,7 +28,7 @@ void InfoView::registerType() { qmlRegisterType("Hifi", 1, 0, NAME.toLocal8Bit().constData()); } -QString fetchVersion(const QUrl & url) { +QString fetchVersion(const QUrl& url) { QXmlQuery query; query.bindVariable("file", QVariant(url)); query.setQuery("string((doc($file)//input[@id='version'])[1]/@value)"); @@ -65,7 +65,7 @@ QUrl InfoView::url() { return _url; } -void InfoView::setUrl(const QUrl & url) { +void InfoView::setUrl(const QUrl& url) { if (url != _url) { _url = url; emit urlChanged(); diff --git a/libraries/ui/src/InfoView.h b/libraries/ui/src/InfoView.h index ba415c5f37..76a4cdbd40 100644 --- a/libraries/ui/src/InfoView.h +++ b/libraries/ui/src/InfoView.h @@ -26,7 +26,7 @@ public: InfoView(QQuickItem* parent = nullptr); QUrl url(); - void setUrl(const QUrl & url); + void setUrl(const QUrl& url); signals: void urlChanged(); From b216689b45432ed5780f2285b42b838242e946a3 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 27 Apr 2015 00:02:11 -0700 Subject: [PATCH 03/10] Removing old infoview, testing new dialogs --- interface/resources/qml/InfoView.qml | 8 +-- interface/src/Application.cpp | 11 ++-- interface/src/ui/InfoView.cpp | 94 ---------------------------- interface/src/ui/InfoView.h | 33 ---------- libraries/ui/src/InfoView.cpp | 21 +++++-- libraries/ui/src/InfoView.h | 2 +- 6 files changed, 27 insertions(+), 142 deletions(-) delete mode 100644 interface/src/ui/InfoView.cpp delete mode 100644 interface/src/ui/InfoView.h diff --git a/interface/resources/qml/InfoView.qml b/interface/resources/qml/InfoView.qml index bd46ec2faa..6b49e6f0c7 100644 --- a/interface/resources/qml/InfoView.qml +++ b/interface/resources/qml/InfoView.qml @@ -1,4 +1,4 @@ -import Hifi 1.0 +import Hifi 1.0 as Hifi import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.3 @@ -7,11 +7,11 @@ import "controls" Dialog { id: root - width: 720 - height: 1024 + width: 800 + height: 800 resizable: true - InfoView { + Hifi.InfoView { id: infoView // Fille the client area anchors.fill: parent diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 5fd3cc48ab..ad2b4e2151 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -84,7 +84,7 @@ #include #include #include - +#include #include #include "Application.h" @@ -132,7 +132,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" @@ -761,8 +760,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() { @@ -910,11 +909,11 @@ void Application::audioMuteToggled() { } 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) { diff --git a/interface/src/ui/InfoView.cpp b/interface/src/ui/InfoView.cpp deleted file mode 100644 index b62b8f3f2d..0000000000 --- a/interface/src/ui/InfoView.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include -#include - -#include -#include - -#include "InfoView.h" - -static const float MAX_DIALOG_HEIGHT_RATIO = 0.9f; - -Setting::Handle 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); -} diff --git a/interface/src/ui/InfoView.h b/interface/src/ui/InfoView.h deleted file mode 100644 index 1198a703e4..0000000000 --- a/interface/src/ui/InfoView.h +++ /dev/null @@ -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 - -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 diff --git a/libraries/ui/src/InfoView.cpp b/libraries/ui/src/InfoView.cpp index 5a5e20e28a..264848cf05 100644 --- a/libraries/ui/src/InfoView.cpp +++ b/libraries/ui/src/InfoView.cpp @@ -14,7 +14,7 @@ #include #include #include - +#include const QUrl InfoView::QML{ "InfoView.qml" }; const QString InfoView::NAME{ "InfoView" }; @@ -37,9 +37,19 @@ QString fetchVersion(const QUrl& url) { return r.trimmed(); } -void InfoView::show(const QString& path, bool forced) { - QUrl url = QUrl::fromLocalFile(path); - if (!forced) { +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) { @@ -54,6 +64,9 @@ void InfoView::show(const QString& path, bool forced) { auto offscreenUi = DependencyManager::get(); QString infoViewName(NAME + "_" + path); offscreenUi->show(QML, NAME + "_" + path, [=](QQmlContext* context, QObject* newObject){ + QQuickItem* item = dynamic_cast(newObject); + item->setWidth(720); + item->setHeight(720); InfoView* newInfoView = newObject->findChild(); Q_ASSERT(newInfoView); newInfoView->parent()->setObjectName(infoViewName); diff --git a/libraries/ui/src/InfoView.h b/libraries/ui/src/InfoView.h index 76a4cdbd40..275effbfa5 100644 --- a/libraries/ui/src/InfoView.h +++ b/libraries/ui/src/InfoView.h @@ -22,7 +22,7 @@ class InfoView : public QQuickItem { static const QString NAME; public: static void registerType(); - static void show(const QString& path, bool forced = false); + static void show(const QString& path, bool firstOrChangedOnly = false); InfoView(QQuickItem* parent = nullptr); QUrl url(); From d8b814082e16ddc3dfd02ed5a70e8b7d223a2d64 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 27 Apr 2015 12:15:16 -0700 Subject: [PATCH 04/10] Removing extraneous header --- tests/ui/src/main.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/tests/ui/src/main.cpp b/tests/ui/src/main.cpp index a2e78936ff..b5d9480a36 100644 --- a/tests/ui/src/main.cpp +++ b/tests/ui/src/main.cpp @@ -28,13 +28,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include "MessageDialog.h" #include "VrMenu.h" #include "InfoView.h" From c799ecbf83eeda4d79a99ddbb846aa459a28c4d0 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 27 Apr 2015 12:16:04 -0700 Subject: [PATCH 05/10] Fixing bad merge --- tests/ui/src/main.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/ui/src/main.cpp b/tests/ui/src/main.cpp index b5d9480a36..6235187a9f 100644 --- a/tests/ui/src/main.cpp +++ b/tests/ui/src/main.cpp @@ -239,11 +239,7 @@ public: } }; -<<<<<<< HEAD -const QString & getResourcesDir() { -======= -const QString& getQmlDir() { ->>>>>>> vr_menus +const QString& getResourcesDir() { static QString dir; if (dir.isEmpty()) { QDir path(__FILE__); @@ -254,7 +250,7 @@ const QString& getQmlDir() { return dir; } -const QString & getQmlDir() { +const QString& getQmlDir() { static QString dir; if (dir.isEmpty()) { dir = getResourcesDir() + "qml/"; From 4bb5e562ea33be1168fba7d9408b9325ed669a61 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 27 Apr 2015 22:39:48 -0700 Subject: [PATCH 06/10] Browser work --- interface/resources/qml/Browser.qml | 124 +++++++++++++++--- interface/resources/qml/controls/Dialog.qml | 1 + .../resources/qml/controls/DialogBase.qml | 9 +- .../resources/qml/controls/TextInput.qml | 4 +- .../resources/qml/styles/HifiConstants.qml | 2 +- tests/ui/src/main.cpp | 2 + 6 files changed, 122 insertions(+), 20 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index a439f9114c..1f33cc0d49 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -2,29 +2,121 @@ 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 + + + Component.onCompleted: { + enabled = true + addressBar.text = webview.url + + } + + onParentChanged: { + if (visible && enabled) { + forceActiveFocus(); + } + } Item { id: clientArea - // The client area - anchors.fill: parent - anchors.margins: parent.margins - anchors.topMargin: parent.topMargin - + implicitHeight: 400 + implicitWidth: 600 + x: root.clientX + y: root.clientY + width: root.clientWidth + height: root.clientHeight + + Row { + id: buttons + spacing: 4 + anchors.top: parent.top + anchors.topMargin: 8 + anchors.left: parent.left + anchors.leftMargin: 8 + FontAwesome { + id: back; size: 48; enabled: webview.canGoBack; text: "\uf0a8" + MouseArea { anchors.fill: parent; onClicked: webview.goBack() } + } + FontAwesome { + id: forward; size: 48; enabled: webview.canGoForward; text: "\uf0a9" + 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 { + id: border1 + height: 48 + radius: 8 + color: "gray" + 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 + onAccepted: { + if (text.indexOf("http") != 0) { + text = "http://" + text; + } + webview.url = text + } + } + + } + ScrollView { - anchors.fill: parent + anchors.top: buttons.bottom + anchors.topMargin: 8 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + Rectangle { anchors.fill: parent; color: "#7500ff00" } 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 +} // dialog diff --git a/interface/resources/qml/controls/Dialog.qml b/interface/resources/qml/controls/Dialog.qml index 629813d3b5..01a2ae5a85 100644 --- a/interface/resources/qml/controls/Dialog.qml +++ b/interface/resources/qml/controls/Dialog.qml @@ -92,6 +92,7 @@ DialogBase { anchors.bottom: parent.bottom width: 16 height: 16 + z: 1000 hoverEnabled: true onPressed: { startX = mouseX diff --git a/interface/resources/qml/controls/DialogBase.qml b/interface/resources/qml/controls/DialogBase.qml index 050237c184..09fb8162e8 100644 --- a/interface/resources/qml/controls/DialogBase.qml +++ b/interface/resources/qml/controls/DialogBase.qml @@ -44,10 +44,18 @@ Item { anchors.left: parent.left border.color: root.frameColor clip: true + radius: 10 color: root.active ? hifi.colors.activeWindow.headerBackground : hifi.colors.inactiveWindow.headerBackground + Rectangle { + y: titleBorder.height / 2 + width: titleBorder.width + height: titleBorder.height /2 + color: titleBorder.color + } + Text { id: titleText color: root.active ? @@ -69,7 +77,6 @@ Item { anchors.topMargin: -titleBorder.border.width anchors.right: parent.right anchors.left: parent.left - clip: true } // client border } // window border diff --git a/interface/resources/qml/controls/TextInput.qml b/interface/resources/qml/controls/TextInput.qml index ceaca0c073..d533c67bd6 100644 --- a/interface/resources/qml/controls/TextInput.qml +++ b/interface/resources/qml/controls/TextInput.qml @@ -13,14 +13,14 @@ Original.TextInput { font.family: hifi.fonts.fontFamily font.pointSize: hifi.fonts.fontSize - +/* Original.Rectangle { // Render the rectangle as background z: -1 anchors.fill: parent color: hifi.colors.inputBackground } - +*/ Text { anchors.fill: parent font.pointSize: parent.font.pointSize diff --git a/interface/resources/qml/styles/HifiConstants.qml b/interface/resources/qml/styles/HifiConstants.qml index d24e9ca9be..ba82ac04d3 100644 --- a/interface/resources/qml/styles/HifiConstants.qml +++ b/interface/resources/qml/styles/HifiConstants.qml @@ -50,7 +50,7 @@ Item { QtObject { id: styles - readonly property int borderWidth: 5 + readonly property int borderWidth: 0 readonly property int borderRadius: borderWidth * 2 } diff --git a/tests/ui/src/main.cpp b/tests/ui/src/main.cpp index a5bc50b288..a05e1c68a9 100644 --- a/tests/ui/src/main.cpp +++ b/tests/ui/src/main.cpp @@ -406,6 +406,8 @@ protected: switch (event->key()) { case Qt::Key_L: if (event->modifiers() & Qt::CTRL) { + auto offscreenUi = DependencyManager::get(); + offscreenUi->load("Browser.qml"); } break; case Qt::Key_K: From f86b9f62b9c1820f233ea4f4ed1361f285d30695 Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Mon, 27 Apr 2015 23:16:35 -0700 Subject: [PATCH 07/10] Adding key to trigger a browser window --- interface/src/Application.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 3b2173f05e..372c399040 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1096,6 +1096,13 @@ void Application::keyPressEvent(QKeyEvent* event) { Menu::getInstance()->triggerOption(MenuOption::AddressBar); break; + case Qt::Key_B: + if (isMeta) { + auto offscreenUi = DependencyManager::get(); + offscreenUi->load("Browser.qml"); + } + break; + case Qt::Key_L: if (isShifted && isMeta) { Menu::getInstance()->triggerOption(MenuOption::Log); From 1f9f4270d70e61fd7d26e0e030a23254092c603b Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Tue, 28 Apr 2015 00:24:18 -0700 Subject: [PATCH 08/10] Working on browsers and look of dialogs --- interface/resources/qml/Browser.qml | 58 ++++++++++++++----- interface/resources/qml/controls/Dialog.qml | 11 ++++ .../resources/qml/controls/DialogBase.qml | 39 +++++++++---- .../resources/qml/styles/HifiConstants.qml | 2 +- 4 files changed, 82 insertions(+), 28 deletions(-) diff --git a/interface/resources/qml/Browser.qml b/interface/resources/qml/Browser.qml index 1f33cc0d49..55a0a6a461 100644 --- a/interface/resources/qml/Browser.qml +++ b/interface/resources/qml/Browser.qml @@ -11,29 +11,37 @@ Dialog { resizable: true contentImplicitWidth: clientArea.implicitWidth contentImplicitHeight: clientArea.implicitHeight + backgroundColor: "#7f000000" Component.onCompleted: { enabled = true addressBar.text = webview.url - } onParentChanged: { if (visible && enabled) { - forceActiveFocus(); + addressBar.forceActiveFocus(); + addressBar.selectAll() } } Item { id: clientArea - implicitHeight: 400 - implicitWidth: 600 + 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 @@ -42,11 +50,13 @@ Dialog { anchors.left: parent.left anchors.leftMargin: 8 FontAwesome { - id: back; size: 48; enabled: webview.canGoBack; text: "\uf0a8" + 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; size: 48; enabled: webview.canGoForward; text: "\uf0a9" + 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 { @@ -54,11 +64,10 @@ Dialog { MouseArea { anchors.fill: parent; onClicked: webview.loading ? webview.stop() : webview.reload() } } } + Border { - id: border1 height: 48 radius: 8 - color: "gray" anchors.top: parent.top anchors.topMargin: 8 anchors.right: parent.right @@ -87,23 +96,29 @@ Dialog { anchors.left: barIcon.right anchors.leftMargin: 0 anchors.verticalCenter: parent.verticalCenter - onAccepted: { - if (text.indexOf("http") != 0) { - text = "http://" + text; + + 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; } - webview.url = text } } - } - + ScrollView { + id: scrollView anchors.top: buttons.bottom anchors.topMargin: 8 anchors.bottom: parent.bottom anchors.left: parent.left anchors.right: parent.right - Rectangle { anchors.fill: parent; color: "#7500ff00" } WebView { id: webview url: "http://highfidelity.com" @@ -119,4 +134,17 @@ Dialog { } } } // item + + Keys.onPressed: { + switch(event.key) { + case Qt.Key_L: + if (event.modifiers == Qt.ControlModifier) { + event.accepted = true + addressBar.selectAll() + addressBar.forceActiveFocus() + } + break; + } + } + } // dialog diff --git a/interface/resources/qml/controls/Dialog.qml b/interface/resources/qml/controls/Dialog.qml index 01a2ae5a85..46add1dc07 100644 --- a/interface/resources/qml/controls/Dialog.qml +++ b/interface/resources/qml/controls/Dialog.qml @@ -144,4 +144,15 @@ DialogBase { } } } + + Keys.onPressed: { + switch(event.key) { + case Qt.Key_W: + if (event.modifiers == Qt.ControlModifier) { + event.accepted = true + enabled = false + } + break; + } + } } diff --git a/interface/resources/qml/controls/DialogBase.qml b/interface/resources/qml/controls/DialogBase.qml index 09fb8162e8..a6616fc731 100644 --- a/interface/resources/qml/controls/DialogBase.qml +++ b/interface/resources/qml/controls/DialogBase.qml @@ -22,11 +22,13 @@ Item { readonly property alias titleWidth: titleBorder.width readonly property alias titleHeight: titleBorder.height + // readonly property real borderWidth: hifi.styles.borderWidth + readonly property real borderWidth: 0 property alias clientBorder: clientBorder - readonly property real clientX: clientBorder.x + hifi.styles.borderWidth - readonly property real clientY: clientBorder.y + hifi.styles.borderWidth - readonly property real clientWidth: clientBorder.width - hifi.styles.borderWidth * 2 - readonly property real clientHeight: clientBorder.height - hifi.styles.borderWidth * 2 + readonly property real clientX: clientBorder.x + borderWidth + readonly property real clientY: clientBorder.y + borderWidth + readonly property real clientWidth: clientBorder.width - borderWidth * 2 + readonly property real clientHeight: clientBorder.height - borderWidth * 2 /* * Window decorations, with a title bar and frames @@ -35,6 +37,7 @@ Item { id: windowBorder anchors.fill: parent border.color: root.frameColor + border.width: 0 color: "#00000000" Border { @@ -43,19 +46,13 @@ Item { anchors.right: parent.right anchors.left: parent.left border.color: root.frameColor + border.width: 0 clip: true - radius: 10 color: root.active ? hifi.colors.activeWindow.headerBackground : hifi.colors.inactiveWindow.headerBackground - Rectangle { - y: titleBorder.height / 2 - width: titleBorder.width - height: titleBorder.height /2 - color: titleBorder.color - } - + Text { id: titleText color: root.active ? @@ -68,8 +65,26 @@ Item { } } // header border + // These two rectangles hide the curves between the title area + // and the client area + Rectangle { + y: titleBorder.height - titleBorder.radius + height: titleBorder.radius + width: titleBorder.width + color: titleBorder.color + visible: borderWidth == 0 + } + + Rectangle { + y: titleBorder.height + width: clientBorder.width + height: clientBorder.radius + color: clientBorder.color + } + Border { id: clientBorder + border.width: 0 border.color: root.frameColor color: root.backgroundColor anchors.bottom: parent.bottom diff --git a/interface/resources/qml/styles/HifiConstants.qml b/interface/resources/qml/styles/HifiConstants.qml index ba82ac04d3..d24e9ca9be 100644 --- a/interface/resources/qml/styles/HifiConstants.qml +++ b/interface/resources/qml/styles/HifiConstants.qml @@ -50,7 +50,7 @@ Item { QtObject { id: styles - readonly property int borderWidth: 0 + readonly property int borderWidth: 5 readonly property int borderRadius: borderWidth * 2 } From fbee3c1782daec19d64208ca1064f8a7a51f88b5 Mon Sep 17 00:00:00 2001 From: Bradley Austin Davis Date: Tue, 5 May 2015 10:49:12 -0700 Subject: [PATCH 09/10] Clearing a GL error from Qt internals that triggers an assert --- libraries/ui/src/OffscreenUi.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libraries/ui/src/OffscreenUi.cpp b/libraries/ui/src/OffscreenUi.cpp index d9c7cd890d..9b32aca96f 100644 --- a/libraries/ui/src/OffscreenUi.cpp +++ b/libraries/ui/src/OffscreenUi.cpp @@ -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(); From a9de502e769a4921c248f2d921cdec346551fb4e Mon Sep 17 00:00:00 2001 From: Brad Davis Date: Wed, 6 May 2015 12:03:47 -0700 Subject: [PATCH 10/10] removing commented out old implementation. --- libraries/ui/src/InfoView.cpp | 65 ----------------------------------- 1 file changed, 65 deletions(-) diff --git a/libraries/ui/src/InfoView.cpp b/libraries/ui/src/InfoView.cpp index 264848cf05..3f80c97c4c 100644 --- a/libraries/ui/src/InfoView.cpp +++ b/libraries/ui/src/InfoView.cpp @@ -85,68 +85,3 @@ void InfoView::setUrl(const QUrl& url) { } } - -//#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