initial skeleton of qml objects

This commit is contained in:
David Kelly 2017-06-14 14:36:37 -07:00
parent 6b6b6026a4
commit 54dfc33b38
4 changed files with 78 additions and 21 deletions

View file

@ -11,6 +11,7 @@
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
// //
import Hifi 1.0 as Hifi
import QtQuick 2.5 import QtQuick 2.5
import QtQuick.Controls 1.4 import QtQuick.Controls 1.4
import "../styles-uit" import "../styles-uit"
@ -25,7 +26,7 @@ Rectangle {
id: spectatorCamera; id: spectatorCamera;
// Style // Style
color: hifi.colors.baseGray; color: hifi.colors.baseGray;
// //
// TITLE BAR START // TITLE BAR START
// //
@ -64,7 +65,7 @@ Rectangle {
// //
// TITLE BAR END // TITLE BAR END
// //
// //
// SPECTATOR APP DESCRIPTION START // SPECTATOR APP DESCRIPTION START
// //
@ -139,7 +140,7 @@ Rectangle {
// Alignment // Alignment
horizontalAlignment: Text.AlignHLeft; horizontalAlignment: Text.AlignHLeft;
verticalAlignment: Text.AlignVCenter; verticalAlignment: Text.AlignVCenter;
MouseArea { MouseArea {
anchors.fill: parent; anchors.fill: parent;
hoverEnabled: enabled; hoverEnabled: enabled;
@ -163,7 +164,7 @@ Rectangle {
// SPECTATOR APP DESCRIPTION END // SPECTATOR APP DESCRIPTION END
// //
// //
// SPECTATOR CONTROLS START // SPECTATOR CONTROLS START
// //
@ -193,19 +194,18 @@ Rectangle {
} }
// Spectator Camera Preview // Spectator Camera Preview
Image { Rectangle {
id: spectatorCameraPreview; id: spectatorCameraPreview;
height: 250; height: 250;
anchors.left: parent.left; anchors.left: parent.left;
anchors.top: cameraToggleCheckBox.bottom; anchors.top: cameraToggleCheckBox.bottom;
anchors.topMargin: 20; anchors.topMargin: 20;
anchors.right: parent.right; anchors.right: parent.right;
fillMode: Image.PreserveAspectFit; Hifi.ResourceImageItem {
horizontalAlignment: Image.AlignHCenter; anchors.fill: parent;
verticalAlignment: Image.AlignVCenter; }
source: "http://1.bp.blogspot.com/-1GABEq__054/T03B00j_OII/AAAAAAAAAa8/jo55LcvEPHI/s1600/Winning.jpg";
} }
// "Monitor Shows" Switch Label Glyph // "Monitor Shows" Switch Label Glyph
HiFiGlyphs { HiFiGlyphs {
id: monitorShowsSwitchLabelGlyph; id: monitorShowsSwitchLabelGlyph;
@ -259,7 +259,7 @@ Rectangle {
sendToScript({method: 'changeSwitchViewFromControllerPreference', params: checked}); sendToScript({method: 'changeSwitchViewFromControllerPreference', params: checked});
} }
} }
} }
// //
// SPECTATOR CONTROLS END // SPECTATOR CONTROLS END
// //
@ -272,11 +272,11 @@ Rectangle {
// //
// Relevant Variables: // Relevant Variables:
// None // None
// //
// Arguments: // Arguments:
// message: The message sent from the SpectatorCamera JavaScript. // message: The message sent from the SpectatorCamera JavaScript.
// Messages are in format "{method, params}", like json-rpc. // Messages are in format "{method, params}", like json-rpc.
// //
// Description: // Description:
// Called when a message is received from spectatorCamera.js. // Called when a message is received from spectatorCamera.js.
// //

View file

@ -170,6 +170,7 @@
#if defined(Q_OS_MAC) || defined(Q_OS_WIN) #if defined(Q_OS_MAC) || defined(Q_OS_WIN)
#include "SpeechRecognizer.h" #include "SpeechRecognizer.h"
#endif #endif
#include "ui/ResourceImageItem.h"
#include "ui/AddressBarDialog.h" #include "ui/AddressBarDialog.h"
#include "ui/AvatarInputs.h" #include "ui/AvatarInputs.h"
#include "ui/DialogsManager.h" #include "ui/DialogsManager.h"
@ -214,7 +215,7 @@ static QTimer pingTimer;
static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16; static const int MAX_CONCURRENT_RESOURCE_DOWNLOADS = 16;
// For processing on QThreadPool, we target a number of threads after reserving some // For processing on QThreadPool, we target a number of threads after reserving some
// based on how many are being consumed by the application and the display plugin. However, // based on how many are being consumed by the application and the display plugin. However,
// we will never drop below the 'min' value // we will never drop below the 'min' value
static const int MIN_PROCESSING_THREAD_POOL_SIZE = 1; static const int MIN_PROCESSING_THREAD_POOL_SIZE = 1;
@ -1247,7 +1248,7 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
// Add periodic checks to send user activity data // Add periodic checks to send user activity data
static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000; static int CHECK_NEARBY_AVATARS_INTERVAL_MS = 10000;
static int NEARBY_AVATAR_RADIUS_METERS = 10; static int NEARBY_AVATAR_RADIUS_METERS = 10;
// setup the stats interval depending on if the 1s faster hearbeat was requested // setup the stats interval depending on if the 1s faster hearbeat was requested
static const QString FAST_STATS_ARG = "--fast-heartbeat"; static const QString FAST_STATS_ARG = "--fast-heartbeat";
static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000; static int SEND_STATS_INTERVAL_MS = arguments().indexOf(FAST_STATS_ARG) != -1 ? 1000 : 10000;
@ -1397,10 +1398,10 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
_autoSwitchDisplayModeSupportedHMDPlugin = nullptr; _autoSwitchDisplayModeSupportedHMDPlugin = nullptr;
foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) { foreach(DisplayPluginPointer displayPlugin, PluginManager::getInstance()->getDisplayPlugins()) {
if (displayPlugin->isHmd() && if (displayPlugin->isHmd() &&
displayPlugin->getSupportsAutoSwitch()) { displayPlugin->getSupportsAutoSwitch()) {
_autoSwitchDisplayModeSupportedHMDPlugin = displayPlugin; _autoSwitchDisplayModeSupportedHMDPlugin = displayPlugin;
_autoSwitchDisplayModeSupportedHMDPluginName = _autoSwitchDisplayModeSupportedHMDPluginName =
_autoSwitchDisplayModeSupportedHMDPlugin->getName(); _autoSwitchDisplayModeSupportedHMDPlugin->getName();
_previousHMDWornStatus = _previousHMDWornStatus =
_autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible(); _autoSwitchDisplayModeSupportedHMDPlugin->isDisplayVisible();
@ -1653,7 +1654,7 @@ void Application::aboutToQuit() {
} }
getActiveDisplayPlugin()->deactivate(); getActiveDisplayPlugin()->deactivate();
if (_autoSwitchDisplayModeSupportedHMDPlugin if (_autoSwitchDisplayModeSupportedHMDPlugin
&& _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) { && _autoSwitchDisplayModeSupportedHMDPlugin->isSessionActive()) {
_autoSwitchDisplayModeSupportedHMDPlugin->endSession(); _autoSwitchDisplayModeSupportedHMDPlugin->endSession();
} }
@ -1918,6 +1919,7 @@ void Application::initializeUi() {
LoginDialog::registerType(); LoginDialog::registerType();
Tooltip::registerType(); Tooltip::registerType();
UpdateDialog::registerType(); UpdateDialog::registerType();
qmlRegisterType<ResourceImageItem>("Hifi", 1, 0, "ResourceImageItem");
qmlRegisterType<Preference>("Hifi", 1, 0, "Preference"); qmlRegisterType<Preference>("Hifi", 1, 0, "Preference");
auto offscreenUi = DependencyManager::get<OffscreenUi>(); auto offscreenUi = DependencyManager::get<OffscreenUi>();
@ -5231,7 +5233,7 @@ void Application::clearDomainOctreeDetails() {
skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT); skyStage->setBackgroundMode(model::SunSkyStage::SKY_DEFAULT);
_recentlyClearedDomain = true; _recentlyClearedDomain = true;
DependencyManager::get<AnimationCache>()->clearUnusedResources(); DependencyManager::get<AnimationCache>()->clearUnusedResources();
DependencyManager::get<ModelCache>()->clearUnusedResources(); DependencyManager::get<ModelCache>()->clearUnusedResources();
DependencyManager::get<SoundCache>()->clearUnusedResources(); DependencyManager::get<SoundCache>()->clearUnusedResources();
@ -5793,7 +5795,7 @@ bool Application::displayAvatarAttachmentConfirmationDialog(const QString& name)
} }
} }
void Application::toggleRunningScriptsWidget() const { void Application::toggleRunningScriptsWidget() const {
auto scriptEngines = DependencyManager::get<ScriptEngines>(); auto scriptEngines = DependencyManager::get<ScriptEngines>();
bool scriptsRunning = !scriptEngines->getRunningScripts().isEmpty(); bool scriptsRunning = !scriptEngines->getRunningScripts().isEmpty();
auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>(); auto tabletScriptingInterface = DependencyManager::get<TabletScriptingInterface>();
@ -5892,7 +5894,7 @@ void Application::showDialog(const QString& desktopURL, const QString& tabletURL
if (!hmd->getShouldShowTablet() && !isHMDMode()) { if (!hmd->getShouldShowTablet() && !isHMDMode()) {
hmd->openTablet(); hmd->openTablet();
} }
} }
} }

View file

@ -0,0 +1,28 @@
//
// ResourceImageItem.cpp
//
// Created by David Kelly and Howard Stearns on 2017/06/08
// Copyright 2017 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 "ResourceImageItem.h"
#include <QOpenGLFramebufferObjectFormat>
#include <DependencyManager.h>
#include <TextureCache.h>
QOpenGLFramebufferObject* ResourceImageItemRenderer::createFramebufferObject(const QSize& size) {
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
return new QOpenGLFramebufferObject(size, format);
}
void ResourceImageItemRenderer::render() {
auto texture = DependencyManager::get<TextureCache>()->getTexture(QUrl("resource://spectatorCameraFrame"));
if (texture) {
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture->getGPUTexture(), 0);
}
}

View file

@ -0,0 +1,27 @@
//
// ResourceImageItem.h
//
// Created by David Kelly and Howard Stearns on 2017/06/08
// Copyright 2017 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
//
#pragma once
#ifndef hifi_ResourceImageItem_h
#define hifi_ResourceImageItem_h
#include <QQuickFramebufferObject>
#include <QOpenGLFunctions>
class ResourceImageItemRenderer : public QQuickFramebufferObject::Renderer, protected QOpenGLFunctions {
QOpenGLFramebufferObject* createFramebufferObject(const QSize& size);
void render();
};
class ResourceImageItem : public QQuickFramebufferObject {
QQuickFramebufferObject::Renderer* createRenderer() const { return new ResourceImageItemRenderer; }
};
#endif // hifi_ResourceImageItem_h