From a6ef459723cb994ff943450265e3467bc01e9b14 Mon Sep 17 00:00:00 2001 From: vladest Date: Tue, 15 May 2018 16:07:32 +0200 Subject: [PATCH] Open browser within Interface --- .../qml/hifi/dialogs/TabletAboutDialog.qml | 19 +++++- interface/src/AboutUtil.cpp | 63 +++++++++++++++++++ interface/src/AboutUtil.h | 40 ++++++++++++ 3 files changed, 119 insertions(+), 3 deletions(-) create mode 100644 interface/src/AboutUtil.cpp create mode 100644 interface/src/AboutUtil.h diff --git a/interface/resources/qml/hifi/dialogs/TabletAboutDialog.qml b/interface/resources/qml/hifi/dialogs/TabletAboutDialog.qml index 34767c607d..2cb079a070 100644 --- a/interface/resources/qml/hifi/dialogs/TabletAboutDialog.qml +++ b/interface/resources/qml/hifi/dialogs/TabletAboutDialog.qml @@ -15,9 +15,7 @@ Rectangle { width: 480 height: 706 - HifiConstants { id: hifi; } - - color: hifi.colors.baseGray + color: "#404040" Column { x: 45 @@ -56,6 +54,9 @@ Rectangle { color: "white" text: "www.highfidelity.com." size: 20 + onLinkActivated: { + HiFiAbout.openUrl("https:/www.highfidelity.com"); + } } Item { height: 40; width: 1 } Row { @@ -64,6 +65,12 @@ Rectangle { sourceSize.width: 34 sourceSize.height: 25 source: "../../../images/about-qt.png" + MouseArea { + anchors.fill: parent + onClicked: { + HiFiAbout.openUrl("https://www.qt.io/"); + } + } } RalewayRegular { color: "white" @@ -91,6 +98,9 @@ Rectangle { color: "white" text: "Blockchain technology from Elements." size: 14 + onLinkActivated: { + HiFiAbout.openUrl("https://elementsproject.org/elements/"); + } } RalewayRegular { color: "white" @@ -103,6 +113,9 @@ Rectangle { linkColor: "#00B4EF" text: "Distributed under the Apache License, Version 2.0.." size: 14 + onLinkActivated: { + HiFiAbout.openUrl("http://www.apache.org/licenses/LICENSE-2.0.html"); + } } } } diff --git a/interface/src/AboutUtil.cpp b/interface/src/AboutUtil.cpp new file mode 100644 index 0000000000..e70ad9bbbf --- /dev/null +++ b/interface/src/AboutUtil.cpp @@ -0,0 +1,63 @@ +// +// AboutUtil.cpp +// interface/src +// +// Created by Vlad Stelmahovsky on 15/5/2018. +// Copyright 2018 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 "AboutUtil.h" +#include "BuildInfo.h" +#include +#include "DependencyManager.h" +#include "scripting/HMDScriptingInterface.h" +#include "Application.h" +#include + +AboutUtil::AboutUtil(QObject *parent) : QObject(parent) {} + +AboutUtil *AboutUtil::getInstance() +{ + static AboutUtil instance; + return &instance; +} + +QString AboutUtil::buildDate() const +{ + return BuildInfo::BUILD_TIME; +} + +QString AboutUtil::buildVersion() const +{ + return BuildInfo::VERSION; +} + +QString AboutUtil::qtVersion() const +{ + return qVersion(); +} + +void AboutUtil::openUrl(const QString& url) const { + + auto tabletScriptingInterface = DependencyManager::get(); + auto tablet = dynamic_cast(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system")); + auto hmd = DependencyManager::get(); + auto offscreenUi = DependencyManager::get(); + + if (tablet->getToolbarMode()) { + offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { + newObject->setProperty("url", url); + }); + } else { + if (!hmd->getShouldShowTablet() && !qApp->isHMDMode()) { + offscreenUi->load("Browser.qml", [=](QQmlContext* context, QObject* newObject) { + newObject->setProperty("url", url); + }); + } else { + tablet->gotoWebScreen(url); + } + } +} diff --git a/interface/src/AboutUtil.h b/interface/src/AboutUtil.h new file mode 100644 index 0000000000..94e9e7b8f3 --- /dev/null +++ b/interface/src/AboutUtil.h @@ -0,0 +1,40 @@ +// +// AboutUtil.h +// interface/src +// +// Created by Vlad Stelmahovsky on 15/5/2018. +// Copyright 2018 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_AboutUtil_h +#define hifi_AboutUtil_h + +#include + +class AboutUtil : public QObject { + + Q_OBJECT + + Q_PROPERTY(QString buildDate READ buildDate CONSTANT) + Q_PROPERTY(QString buildVersion READ buildVersion CONSTANT) + Q_PROPERTY(QString qtVersion READ qtVersion CONSTANT) + + AboutUtil(QObject* parent = nullptr); +public: + static AboutUtil* getInstance(); + ~AboutUtil() {} + + QString buildDate() const; + QString buildVersion() const; + QString qtVersion() const; + +public slots: + void openUrl(const QString &url) const; +private: +}; + +#endif // hifi_AboutUtil_h