Open browser within Interface

This commit is contained in:
vladest 2018-05-15 16:07:32 +02:00
parent fee3cc0aca
commit a6ef459723
3 changed files with 119 additions and 3 deletions

View file

@ -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: "<a href=\"https:/www.highfidelity.com\">www.highfidelity.com</a>."
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 <a href=\"https://elementsproject.org/elements/\">Elements</a>."
size: 14
onLinkActivated: {
HiFiAbout.openUrl("https://elementsproject.org/elements/");
}
}
RalewayRegular {
color: "white"
@ -103,6 +113,9 @@ Rectangle {
linkColor: "#00B4EF"
text: "Distributed under the <a href=\"http://www.apache.org/licenses/LICENSE-2.0.html\">Apache License, Version 2.0.</a>."
size: 14
onLinkActivated: {
HiFiAbout.openUrl("http://www.apache.org/licenses/LICENSE-2.0.html");
}
}
}
}

View file

@ -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 <ui/TabletScriptingInterface.h>
#include "DependencyManager.h"
#include "scripting/HMDScriptingInterface.h"
#include "Application.h"
#include <OffscreenQmlDialog.h>
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<TabletScriptingInterface>();
auto tablet = dynamic_cast<TabletProxy*>(tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
auto hmd = DependencyManager::get<HMDScriptingInterface>();
auto offscreenUi = DependencyManager::get<OffscreenUi>();
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);
}
}
}

40
interface/src/AboutUtil.h Normal file
View file

@ -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 <QObject>
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