#19418 Load a local HTML file in a web view within Interface

This commit is contained in:
stojce 2013-09-08 21:28:30 +02:00
parent 8fb3068816
commit fef70098a3
5 changed files with 228 additions and 0 deletions

View file

@ -52,6 +52,7 @@ find_package(Qt5Multimedia REQUIRED)
find_package(Qt5Network REQUIRED)
find_package(Qt5OpenGL REQUIRED)
find_package(Qt5Svg REQUIRED)
find_package(Qt5WebKitWidgets REQUIRED)
if (APPLE)
set(MACOSX_BUNDLE_BUNDLE_NAME Interface)

File diff suppressed because one or more lines are too long

View file

@ -65,6 +65,7 @@
#include "devices/OculusManager.h"
#include "renderer/ProgramObject.h"
#include "ui/TextRenderer.h"
#include "InfoView.h"
using namespace std;
@ -328,6 +329,8 @@ void Application::initializeGL() {
#if defined(Q_OS_MAC) && defined(QT_NO_DEBUG)
Menu::getInstance()->checkForUpdates();
#endif
InfoView::showFirstTime();
}
void Application::paintGL() {

View file

@ -0,0 +1,60 @@
//
// InfoView
// hifi
//
// Created by Stojce Slavkovski on 9/7/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#include "InfoView.h"
#include <QApplication>
#include "Application.h"
#include <QWebFrame>
#include <QWebElement>
#include <QDebug>
#define VIEW_FIXED_WIDTH 808
#define SETTINGS_KEY_VERSION "info-version"
InfoView::InfoView()
{
this->settings()->setAttribute(QWebSettings::LocalContentCanAccessFileUrls, true);
#ifdef Q_OS_MAC
QString resourcesPath = QCoreApplication::applicationDirPath() + "/../Resources";
#else
QString resourcesPath = QCoreApplication::applicationDirPath() + "/resources";
#endif
QUrl url = QUrl::fromLocalFile(resourcesPath + "/html/interface-welcome-allsvg.html");
this->load(url);
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loaded(bool)));
}
void InfoView::showFirstTime()
{
new InfoView();
}
void InfoView::loaded(bool ok)
{
QSettings* settings = Application::getInstance()->getSettings();
QString lastVersion = settings->value(SETTINGS_KEY_VERSION).toString();
QWebFrame* mainFrame = this->page()->mainFrame();
QWebElement versionTag = mainFrame->findFirstElement("#version");
QString version = versionTag.attribute("value");
if (lastVersion == QString::null || version == QString::null || lastVersion != version) {
if (version != QString::null) {
settings->setValue(SETTINGS_KEY_VERSION, version);
}
this->setWindowModality(Qt::WindowModal);
this->setFixedSize(VIEW_FIXED_WIDTH, this->height());
this->setWindowTitle(this->title());
this->show();
}
}

27
interface/src/InfoView.h Normal file
View file

@ -0,0 +1,27 @@
//
// InfoView.h
// hifi
//
// Created by Stojce Slavkovski on 9/7/13.
// Copyright (c) 2013 HighFidelity, Inc. All rights reserved.
//
#ifndef __hifi__InfoView__
#define __hifi__InfoView__
#include <QWebView>
class InfoView : public QWebView
{
Q_OBJECT
public:
static void showFirstTime();
private:
InfoView();
private slots:
void loaded(bool ok);
};
#endif /* defined(__hifi__InfoView__) */