Merge branch 'ui-refactor' into m_and_m

Conflicts:
	interface/resources/qml/HifiMenu.qml
	interface/resources/qml/MessageDialog.qml
	interface/resources/qml/Root.qml
	interface/resources/qml/TestRoot.qml
	interface/resources/qml/controls/Dialog.qml
	interface/src/Application.cpp
	interface/src/ui/LoginDialog.cpp
	libraries/ui/src/MessageDialog.cpp
	libraries/ui/src/MessageDialog.h
	libraries/ui/src/OffscreenQmlDialog.h
	libraries/ui/src/OffscreenUi.cpp
	libraries/ui/src/OffscreenUi.h
	tests/ui/src/main.cpp
This commit is contained in:
Brad Davis 2015-04-24 18:02:12 -07:00
commit fbdb9b143e
31 changed files with 419 additions and 323 deletions

View file

@ -95,6 +95,7 @@
};
function loaded() {
var allSections = [];
var elID = document.getElementById("property-id");
var elType = document.getElementById("property-type");
var elLocked = document.getElementById("property-locked");
@ -146,11 +147,13 @@
var elUserData = document.getElementById("property-user-data");
var elBoxSections = document.querySelectorAll(".box-section");
allSections.push(elBoxSections);
var elBoxColorRed = document.getElementById("property-box-red");
var elBoxColorGreen = document.getElementById("property-box-green");
var elBoxColorBlue = document.getElementById("property-box-blue");
var elLightSections = document.querySelectorAll(".light-section");
allSections.push(elLightSections);
var elLightSpotLight = document.getElementById("property-light-spot-light");
var elLightColorRed = document.getElementById("property-light-color-red");
var elLightColorGreen = document.getElementById("property-light-color-green");
@ -161,7 +164,9 @@
var elLightCutoff = document.getElementById("property-light-cutoff");
var elModelSections = document.querySelectorAll(".model-section");
allSections.push(elModelSections);
var elModelURL = document.getElementById("property-model-url");
var elShapeType = document.getElementById("property-shape-type");
var elCompoundShapeURL = document.getElementById("property-compound-shape-url");
var elModelAnimationURL = document.getElementById("property-model-animation-url");
var elModelAnimationPlaying = document.getElementById("property-model-animation-playing");
@ -170,9 +175,9 @@
var elModelAnimationSettings = document.getElementById("property-model-animation-settings");
var elModelTextures = document.getElementById("property-model-textures");
var elModelOriginalTextures = document.getElementById("property-model-original-textures");
var elModelShapeType = document.getElementById("property-model-shape");
var elTextSections = document.querySelectorAll(".text-section");
allSections.push(elTextSections);
var elTextText = document.getElementById("property-text-text");
var elTextLineHeight = document.getElementById("property-text-line-height");
var elTextTextColorRed = document.getElementById("property-text-text-color-red");
@ -183,6 +188,7 @@
var elTextBackgroundColorBlue = document.getElementById("property-text-background-color-blue");
var elZoneSections = document.querySelectorAll(".zone-section");
allSections.push(elZoneSections);
var elZoneStageSunModelEnabled = document.getElementById("property-zone-stage-sun-model-enabled");
var elZoneKeyLightColorRed = document.getElementById("property-zone-key-light-color-red");
var elZoneKeyLightColorGreen = document.getElementById("property-zone-key-light-color-green");
@ -299,11 +305,13 @@
elScriptURL.value = properties.script;
elUserData.value = properties.userData;
if (properties.type != "Box") {
for (var i = 0; i < elBoxSections.length; i++) {
elBoxSections[i].style.display = 'none';
for (var i = 0; i < allSections.length; i++) {
for (var j = 0; j < allSections[i].length; j++) {
allSections[i][j].style.display = 'none';
}
} else {
}
if (properties.type == "Box") {
for (var i = 0; i < elBoxSections.length; i++) {
elBoxSections[i].style.display = 'block';
}
@ -311,18 +319,13 @@
elBoxColorRed.value = properties.color.red;
elBoxColorGreen.value = properties.color.green;
elBoxColorBlue.value = properties.color.blue;
}
if (properties.type != "Model") {
for (var i = 0; i < elModelSections.length; i++) {
elModelSections[i].style.display = 'none';
}
} else {
} else if (properties.type == "Model") {
for (var i = 0; i < elModelSections.length; i++) {
elModelSections[i].style.display = 'block';
}
elModelURL.value = properties.modelURL;
elShapeType.value = properties.shapeType;
elCompoundShapeURL.value = properties.compoundShapeURL;
elModelAnimationURL.value = properties.animationURL;
elModelAnimationPlaying.checked = properties.animationIsPlaying;
@ -331,14 +334,7 @@
elModelAnimationSettings.value = properties.animationSettings;
elModelTextures.value = properties.textures;
elModelOriginalTextures.value = properties.originalTextures;
elModelShapeType.value = properties.shapeType;
}
if (properties.type != "Text") {
for (var i = 0; i < elTextSections.length; i++) {
elTextSections[i].style.display = 'none';
}
} else {
} else if (properties.type == "Text") {
for (var i = 0; i < elTextSections.length; i++) {
elTextSections[i].style.display = 'block';
}
@ -351,13 +347,7 @@
elTextBackgroundColorRed.value = properties.backgroundColor.red;
elTextBackgroundColorGreen.value = properties.backgroundColor.green;
elTextBackgroundColorBlue.value = properties.backgroundColor.blue;
}
if (properties.type != "Light") {
for (var i = 0; i < elLightSections.length; i++) {
elLightSections[i].style.display = 'none';
}
} else {
} else if (properties.type == "Light") {
for (var i = 0; i < elLightSections.length; i++) {
elLightSections[i].style.display = 'block';
}
@ -371,13 +361,7 @@
elLightIntensity.value = properties.intensity;
elLightExponent.value = properties.exponent;
elLightCutoff.value = properties.cutoff;
}
if (properties.type != "Zone") {
for (var i = 0; i < elZoneSections.length; i++) {
elZoneSections[i].style.display = 'none';
}
} else {
} else if (properties.type == "Zone") {
for (var i = 0; i < elZoneSections.length; i++) {
elZoneSections[i].style.display = 'block';
}
@ -397,6 +381,8 @@
elZoneStageAltitude.value = properties.stageAltitude.toFixed(2);
elZoneStageDay.value = properties.stageDay;
elZoneStageHour.value = properties.stageHour;
elShapeType.value = properties.shapeType;
elCompoundShapeURL.value = properties.compoundShapeURL;
}
if (selected) {
@ -487,6 +473,7 @@
elLightCutoff.addEventListener('change', createEmitNumberPropertyUpdateFunction('cutoff'));
elModelURL.addEventListener('change', createEmitTextPropertyUpdateFunction('modelURL'));
elShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType'));
elCompoundShapeURL.addEventListener('change', createEmitTextPropertyUpdateFunction('compoundShapeURL'));
elModelAnimationURL.addEventListener('change', createEmitTextPropertyUpdateFunction('animationURL'));
elModelAnimationPlaying.addEventListener('change', createEmitCheckedPropertyUpdateFunction('animationIsPlaying'));
@ -494,7 +481,6 @@
elModelAnimationFrame.addEventListener('change', createEmitNumberPropertyUpdateFunction('animationFrameIndex'));
elModelAnimationSettings.addEventListener('change', createEmitTextPropertyUpdateFunction('animationSettings'));
elModelTextures.addEventListener('change', createEmitTextPropertyUpdateFunction('textures'));
elModelShapeType.addEventListener('change', createEmitTextPropertyUpdateFunction('shapeType'));
elTextText.addEventListener('change', createEmitTextPropertyUpdateFunction('text'));
elTextLineHeight.addEventListener('change', createEmitNumberPropertyUpdateFunction('lineHeight'));
@ -774,7 +760,18 @@
<input type="text" id="property-model-url" class="url"></input>
</div>
</div>
<div class="model-section property">
<div class="model-section zone-section property">
<div class="label">Shape Type</div>
<div class="value">
<select name="SelectShapeType" id="property-shape-type" name="SelectShapeType">
<option value='none'>none</option>
<option value='box'>box</option>
<option value='sphere'>sphere</option>
<option value='compound'>compound</option>
</select>
</div>
</div>
<div class="model-section zone-section property">
<div class="label">Compound Shape URL</div>
<div class="value">
<input type="text" id="property-compound-shape-url" class="url"></input>
@ -823,18 +820,6 @@
</div>
</div>
<div class="model-section property">
<div class="label">Shape Type</div>
<div class="value">
<select name="SelectShapeType" id="property-model-shape" name="SelectShapeType">
<option value='none'>none</option>
<option value='box'>box</option>
<option value='sphere'>sphere</option>
</select>
</div>
</div>
<div class="text-section property">
<div class="label">Text</div>
<div class="value">

View file

@ -53,6 +53,7 @@ function Tooltip() {
text += "ID: " + properties.id + "\n"
if (properties.type == "Model") {
text += "Model URL: " + properties.modelURL + "\n"
text += "Shape Type: " + properties.shapeType + "\n"
text += "Compound Shape URL: " + properties.compoundShapeURL + "\n"
text += "Animation URL: " + properties.animationURL + "\n"
text += "Animation is playing: " + properties.animationIsPlaying + "\n"

View file

@ -52,6 +52,8 @@ EntityPropertyDialogBox = (function () {
if (properties.type == "Model") {
array.push({ label: "Model URL:", value: properties.modelURL });
index++;
array.push({ label: "Shape Type:", value: properties.shapeType });
index++;
array.push({ label: "Compound Shape URL:", value: properties.compoundShapeURL });
index++;
array.push({ label: "Animation URL:", value: properties.animationURL });
@ -284,6 +286,7 @@ EntityPropertyDialogBox = (function () {
properties.locked = array[index++].value;
if (properties.type == "Model") {
properties.modelURL = array[index++].value;
properties.shapeType = array[index++].value;
properties.compoundShapeURL = array[index++].value;
properties.animationURL = array[index++].value;

View file

@ -105,6 +105,7 @@ ZoneOverlayManager = function(isEntityFunc, entityAddedFunc, entityRemovedFunc,
if (entityID.id in entityOverlays) {
releaseOverlay(entityOverlays[entityID.id].outline);
releaseOverlay(entityOverlays[entityID.id].solid);
delete entityIDs[entityID.id];
delete entityOverlays[entityID.id];
}
}

View file

@ -31,7 +31,9 @@ var yawFromTouch = 0;
var pitchFromTouch = 0;
// Touch Data
var TIME_BEFORE_GENERATED_END_TOUCH_EVENT = 50; // ms
var startedTouching = false;
var lastTouchEvent = 0;
var lastMouseX = 0;
var lastMouseY = 0;
var yawFromMouse = 0;
@ -80,11 +82,17 @@ function touchBeginEvent(event) {
yawFromTouch = 0;
pitchFromTouch = 0;
startedTouching = true;
var d = new Date();
lastTouchEvent = d.getTime();
}
function touchEndEvent(event) {
if (wantDebugging) {
print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
if (event) {
print("touchEndEvent event.x,y=" + event.x + ", " + event.y);
} else {
print("touchEndEvent generated");
}
}
startedTouching = false;
}
@ -96,16 +104,17 @@ function touchUpdateEvent(event) {
}
if (!startedTouching) {
// handle Qt 5.4.x bug where we get touch update without a touch begin event
startedTouching = true;
lastTouchX = event.x;
lastTouchY = event.y;
// handle Qt 5.4.x bug where we get touch update without a touch begin event
touchBeginEvent(event);
return;
}
yawFromTouch += ((event.x - lastTouchX) * TOUCH_YAW_SCALE * FIXED_TOUCH_TIMESTEP);
pitchFromTouch += ((event.y - lastTouchY) * TOUCH_PITCH_SCALE * FIXED_TOUCH_TIMESTEP);
lastTouchX = event.x;
lastTouchY = event.y;
var d = new Date();
lastTouchEvent = d.getTime();
}
@ -113,6 +122,14 @@ function update(deltaTime) {
if (wantDebugging) {
print("update()...");
}
if (startedTouching) {
var d = new Date();
var sinceLastTouch = d.getTime() - lastTouchEvent;
if (sinceLastTouch > TIME_BEFORE_GENERATED_END_TOUCH_EVENT) {
touchEndEvent();
}
}
if (yawFromTouch != 0 || yawFromMouse != 0) {
var newOrientation = Quat.multiply(MyAvatar.orientation, Quat.fromPitchYawRollRadians(0, yawFromTouch + yawFromMouse, 0));

View file

@ -48,6 +48,7 @@ Dialog {
helperText: "domain, location, @user, /x,y,z"
anchors.margins: 8
onAccepted: {
event.accepted
addressBarDialog.loadAddress(addressLine.text)
}
}
@ -71,5 +72,20 @@ Dialog {
}
}
}
Keys.onEscapePressed: {
enabled = false;
}
function toggleOrGo() {
if (addressLine.text == "") {
enabled = false
} else {
addressBarDialog.loadAddress(addressLine.text)
}
}
Keys.onReturnPressed: toggleOrGo()
Keys.onEnterPressed: toggleOrGo()
}

View file

@ -111,8 +111,8 @@ Hifi.HifiMenu {
Border {
SystemPalette { id: sysPalette; colorGroup: SystemPalette.Active }
x: root.models.length == 1 ?
(root.width / 2 - width / 2) :
root.columns[root.models.length - 2].x + 60;
(root.width / 2 - width / 2) :
root.columns[root.models.length - 2].x + 60;
anchors.verticalCenter: parent.verticalCenter
border.color: hifiPalette.hifiBlue
color: sysPalette.window

View file

@ -0,0 +1,20 @@
import QtQuick 2.4
import QtQuick.Controls 1.3
ApplicationWindow {
id: root
width: 800
height: 600
visible: true
menuBar: MenuBar {
Menu {
title: "File"
MenuItem {
text: "Quit"
}
}
}
}

View file

@ -1,43 +1,3 @@
/*****************************************************************************
**
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the QtQuick.Dialogs module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** You may use this file under the terms of the BSD license as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of Digia Plc and its Subsidiary(-ies) nor the names
** of its contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
*****************************************************************************/
import Hifi 1.0 as Hifi
import QtQuick 2.2
import QtQuick.Controls 1.2
@ -69,9 +29,13 @@ Dialog {
content.buttonsRowImplicitWidth = outerSpacing + calcWidth + 48
}
Component.onCompleted: {
enabled = true
}
onEnabledChanged: {
if (enabled) {
content.forceActiveFocus();
root.forceActiveFocus();
}
}
@ -87,37 +51,6 @@ Dialog {
implicitWidth: Math.max(mainText.implicitWidth, buttonsRowImplicitWidth);
property real buttonsRowImplicitWidth: Screen.pixelDensity * 50
Keys.onPressed: {
console.log("Key press at content")
event.accepted = true
if (event.modifiers === Qt.ControlModifier)
switch (event.key) {
case Qt.Key_A:
console.log("Select All")
detailedText.selectAll()
break
case Qt.Key_C:
console.log("Copy")
detailedText.copy()
break
case Qt.Key_Period:
if (Qt.platform.os === "osx")
reject()
break
} else switch (event.key) {
case Qt.Key_Escape:
case Qt.Key_Back:
console.log("Rejecting")
reject()
break
case Qt.Key_Enter:
case Qt.Key_Return:
console.log("Accepting")
accept()
break
}
}
onImplicitWidthChanged: root.width = implicitWidth
Component.onCompleted: {
@ -140,9 +73,46 @@ Dialog {
Item {
width: parent.width
height: Math.max(icon.height, mainText.height + informativeText.height + root.spacing)
Image {
FontAwesome {
id: icon
source: content.standardIconSource
width: content.icon ? 48 : 0
height: content.icon ? 48 : 0
visible: content.icon ? true : false
font.pixelSize: 48
verticalAlignment: Text.AlignTop
horizontalAlignment: Text.AlignLeft
color: iconColor()
text: iconSymbol()
function iconSymbol() {
switch (content.icon) {
case Hifi.MessageDialog.Information:
return "\uF05A"
case Hifi.MessageDialog.Question:
return "\uF059"
case Hifi.MessageDialog.Warning:
return "\uF071"
case Hifi.MessageDialog.Critical:
return "\uF057"
default:
break;
}
return content.icon;
}
function iconColor() {
switch (content.icon) {
case Hifi.MessageDialog.Information:
case Hifi.MessageDialog.Question:
return "blue"
case Hifi.MessageDialog.Warning:
case Hifi.MessageDialog.Critical:
return "red"
default:
break
}
return "black"
}
}
Text {
@ -348,12 +318,38 @@ Dialog {
}
}
]
/*
Rectangle {
}
Keys.onPressed: {
if (event.modifiers === Qt.ControlModifier)
switch (event.key) {
case Qt.Key_A:
event.accepted = true
detailedText.selectAll()
break
case Qt.Key_C:
event.accepted = true
detailedText.copy()
break
case Qt.Key_Period:
if (Qt.platform.os === "osx") {
event.accepted = true
content.reject()
}
break
} else switch (event.key) {
case Qt.Key_Escape:
case Qt.Key_Back:
event.accepted = true
content.reject()
break
case Qt.Key_Enter:
case Qt.Key_Return:
console.log("Accepting");
event.accepted = true
content.accept()
break
}
Component.onCompleted: calculateImplicitWidth()
*/
}
}

View file

@ -6,5 +6,9 @@ import QtQuick 2.3
Root {
id: root
anchors.fill: parent
onParentChanged: {
forceActiveFocus();
}
}

View file

@ -6,21 +6,12 @@ import QtQuick.Controls 1.3
import "controls"
Root {
id: root
id: root
anchors.fill: parent
onParentChanged: {
forceActiveFocus();
}
onWidthChanged: {
console.log("Root width: " + width)
}
onHeightChanged: {
console.log("Root height: " + height)
}
Component.onCompleted: {
console.log("Completed root")
root.forceActiveFocus()
}
Button {
id: messageBox
anchors.right: createDialog.left
@ -34,7 +25,6 @@ Root {
console.log("Bar")
}
}
Button {
id: createDialog
anchors.right: parent.right

View file

@ -84,7 +84,6 @@
#include <TextRenderer.h>
#include <UserActivityLogger.h>
#include <UUID.h>
#include <OAuthNetworkAccessManager.h>
#include <MessageDialog.h>
#include <SceneScriptingInterface.h>
@ -1101,6 +1100,11 @@ void Application::keyPressEvent(QKeyEvent* event) {
bool isKeypad = event->modifiers().testFlag(Qt::KeypadModifier);
switch (event->key()) {
break;
case Qt::Key_Enter:
case Qt::Key_Return:
Menu::getInstance()->triggerOption(MenuOption::AddressBar);
break;
case Qt::Key_L:
if (isShifted && isMeta) {
Menu::getInstance()->triggerOption(MenuOption::Log);
@ -1533,9 +1537,11 @@ void Application::mouseReleaseEvent(QMouseEvent* event, unsigned int deviceID) {
}
void Application::touchUpdateEvent(QTouchEvent* event) {
TouchEvent thisEvent(*event, _lastTouchEvent);
_controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
_lastTouchEvent = thisEvent;
if (event->type() == QEvent::TouchUpdate) {
TouchEvent thisEvent(*event, _lastTouchEvent);
_controllerScriptingInterface.emitTouchUpdateEvent(thisEvent); // send events to any registered scripts
_lastTouchEvent = thisEvent;
}
// if one of our scripts have asked to capture this event, then stop processing it
if (_controllerScriptingInterface.isTouchCaptured()) {

View file

@ -683,12 +683,12 @@ void MyAvatar::loadData() {
_useFullAvatar = settings.value("useFullAvatar").toBool();
_headURLFromPreferences = settings.value("faceModelURL", DEFAULT_HEAD_MODEL_URL).toUrl();
_fullAvatarURLFromPreferences = settings.value("fullAvatarURL").toUrl();
_skeletonURLFromPreferences = settings.value("skeletonModelURL").toUrl();
_headModelName = settings.value("headModelName").toString();
_bodyModelName = settings.value("bodyModelName").toString();
_fullAvatarModelName = settings.value("fullAvatarModelName").toString();;
_fullAvatarURLFromPreferences = settings.value("fullAvatarURL", DEFAULT_FULL_AVATAR_MODEL_URL).toUrl();
_skeletonURLFromPreferences = settings.value("skeletonModelURL", DEFAULT_BODY_MODEL_URL).toUrl();
_headModelName = settings.value("headModelName", DEFAULT_HEAD_MODEL_NAME).toString();
_bodyModelName = settings.value("bodyModelName", DEFAULT_BODY_MODEL_NAME).toString();
_fullAvatarModelName = settings.value("fullAvatarModelName", DEFAULT_FULL_AVATAR_MODEL_NAME).toString();
if (isOldSettings) {
bool assumeFullAvatar = _headURLFromPreferences.isEmpty();
_useFullAvatar = assumeFullAvatar;
@ -706,13 +706,22 @@ void MyAvatar::loadData() {
} else {
_fullAvatarURLFromPreferences = DEFAULT_FULL_AVATAR_MODEL_URL;
_skeletonURLFromPreferences = settings.value("skeletonModelURL").toUrl();
_skeletonURLFromPreferences = settings.value("skeletonModelURL", DEFAULT_BODY_MODEL_URL).toUrl();
QVariantHash headFST = FSTReader::downloadMapping(_headURLFromPreferences.toString());
QVariantHash bodyFST = FSTReader::downloadMapping(_skeletonURLFromPreferences.toString());
_headModelName = headFST["name"].toString();
_bodyModelName = bodyFST["name"].toString();
if (_skeletonURLFromPreferences == DEFAULT_BODY_MODEL_URL) {
_bodyModelName = DEFAULT_BODY_MODEL_NAME;
} else {
QVariantHash bodyFST = FSTReader::downloadMapping(_skeletonURLFromPreferences.toString());
_bodyModelName = bodyFST["name"].toString();
}
if (_headURLFromPreferences == DEFAULT_HEAD_MODEL_URL) {
_headModelName = DEFAULT_HEAD_MODEL_NAME;
} else {
QVariantHash headFST = FSTReader::downloadMapping(_headURLFromPreferences.toString());
_headModelName = headFST["name"].toString();
}
_fullAvatarModelName = "Default";
}
}

View file

@ -15,7 +15,7 @@
#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <QElapsedTimer>
#include <QTimer>
#include <GLMHelpers.h>
@ -136,6 +136,9 @@ struct Packet {
const float STARTING_DDE_MESSAGE_TIME = 0.033f;
const int FPS_TIMER_DELAY = 2000; // ms
const int FPS_TIMER_DURATION = 2000; // ms
DdeFaceTracker::DdeFaceTracker() :
DdeFaceTracker(QHostAddress::Any, DDE_SERVER_PORT, DDE_CONTROL_PORT)
{
@ -168,7 +171,9 @@ DdeFaceTracker::DdeFaceTracker(const QHostAddress& host, quint16 serverPort, qui
_lastLeftEyeBlink(0.0f),
_filteredLeftEyeBlink(0.0f),
_lastRightEyeBlink(0.0f),
_filteredRightEyeBlink(0.0f)
_filteredRightEyeBlink(0.0f),
_isCalculatingFPS(false),
_frameCount(0)
{
_coefficients.resize(NUM_FACESHIFT_BLENDSHAPES);
@ -200,7 +205,7 @@ void DdeFaceTracker::setEnabled(bool enabled) {
qDebug() << "[Info] DDE Face Tracker Starting";
_ddeProcess = new QProcess(qApp);
connect(_ddeProcess, SIGNAL(finished(int, QProcess::ExitStatus)), SLOT(processFinished(int, QProcess::ExitStatus)));
_ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS, QIODevice::ReadOnly);
_ddeProcess->start(QCoreApplication::applicationDirPath() + DDE_PROGRAM_PATH, DDE_ARGUMENTS);
}
if (!enabled && _ddeProcess) {
@ -229,6 +234,12 @@ void DdeFaceTracker::reset() {
const char* DDE_RESET_COMMAND = "reset";
_udpSocket.writeDatagram(DDE_RESET_COMMAND, DDE_SERVER_ADDR, _controlPort);
// Log camera FPS after a reset
if (!_isCalculatingFPS) {
QTimer::singleShot(FPS_TIMER_DELAY, this, SLOT(startFPSTimer()));
_isCalculatingFPS = true;
}
_reset = true;
}
@ -407,9 +418,24 @@ void DdeFaceTracker::decodePacket(const QByteArray& buffer) {
+ (1.0f - FRAME_AVERAGING_FACTOR) * (float)(usecsNow - _lastMessageReceived) / 1000000.0f;
}
_lastMessageReceived = usecsNow;
// Count frames if timing
if (_isCalculatingFPS) {
_frameCount++;
}
} else {
qCDebug(interfaceapp) << "[Error] DDE Face Tracker Decode Error";
}
_lastReceiveTimestamp = usecTimestampNow();
}
void DdeFaceTracker::startFPSTimer() {
_frameCount = 0;
QTimer::singleShot(FPS_TIMER_DURATION, this, SLOT(finishFPSTimer()));
}
void DdeFaceTracker::finishFPSTimer() {
qDebug() << "[Info] DDE FPS =" << (float)_frameCount / ((float)FPS_TIMER_DURATION / 1000.0f);
_isCalculatingFPS = false;
}

View file

@ -58,6 +58,9 @@ private slots:
void socketErrorOccurred(QAbstractSocket::SocketError socketError);
void readPendingDatagrams();
void socketStateChanged(QAbstractSocket::SocketState socketState);
void startFPSTimer();
void finishFPSTimer();
private:
DdeFaceTracker();
@ -108,6 +111,9 @@ private:
float _filteredLeftEyeBlink;
float _lastRightEyeBlink;
float _filteredRightEyeBlink;
bool _isCalculatingFPS;
int _frameCount;
};
#endif // hifi_DdeFaceTracker_h

View file

@ -30,9 +30,14 @@ const QString DEFAULT_FACESHIFT_HOSTNAME = "localhost";
const quint16 FACESHIFT_PORT = 33433;
const float DEFAULT_FACESHIFT_EYE_DEFLECTION = 0.25f;
const int FPS_TIMER_DELAY = 2000; // ms
const int FPS_TIMER_DURATION = 2000; // ms
Faceshift::Faceshift() :
_eyeDeflection("faceshiftEyeDeflection", DEFAULT_FACESHIFT_EYE_DEFLECTION),
_hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME)
_hostname("faceshiftHostname", DEFAULT_FACESHIFT_HOSTNAME),
_isCalculatingFPS(false),
_frameCount(0)
{
#ifdef HAVE_FACESHIFT
connect(&_tcpSocket, SIGNAL(connected()), SLOT(noteConnected()));
@ -81,6 +86,12 @@ void Faceshift::reset() {
string message;
fsBinaryStream::encode_message(message, fsMsgCalibrateNeutral());
send(message);
// Log camera FPS after a reset
if (!_isCalculatingFPS) {
QTimer::singleShot(FPS_TIMER_DELAY, this, SLOT(startFPSTimer()));
_isCalculatingFPS = true;
}
}
_longTermAverageInitialized = false;
}
@ -283,6 +294,10 @@ void Faceshift::receive(const QByteArray& buffer) {
}
}
#endif
// Count frames if timing
if (_isCalculatingFPS) {
_frameCount++;
}
}
void Faceshift::setEyeDeflection(float faceshiftEyeDeflection) {
@ -292,3 +307,13 @@ void Faceshift::setEyeDeflection(float faceshiftEyeDeflection) {
void Faceshift::setHostname(const QString& hostname) {
_hostname.set(hostname);
}
void Faceshift::startFPSTimer() {
_frameCount = 0;
QTimer::singleShot(FPS_TIMER_DURATION, this, SLOT(finishFPSTimer()));
}
void Faceshift::finishFPSTimer() {
qCDebug(interfaceapp) << "Faceshift: FPS =" << (float)_frameCount / ((float)FPS_TIMER_DURATION / 1000.0f);
_isCalculatingFPS = false;
}

View file

@ -95,7 +95,9 @@ private slots:
void noteError(QAbstractSocket::SocketError error);
void readPendingDatagrams();
void readFromSocket();
void startFPSTimer();
void finishFPSTimer();
private:
Faceshift();
virtual ~Faceshift() {}
@ -152,6 +154,9 @@ private:
int _mouthSmileRightIndex = 29;
int _jawOpenIndex = 21;
bool _isCalculatingFPS;
int _frameCount;
};
#endif // hifi_Faceshift_h

View file

@ -16,6 +16,7 @@
#include <QWebFrame>
#include <QWebView>
#include <QListWidget>
#include <QStyleFactory>
#include "Application.h"
#include "ui/DataWebPage.h"
@ -72,6 +73,11 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid
_windowWidget = dialogWidget;
}
auto style = QStyleFactory::create("fusion");
if (style) {
_webView->setStyle(style);
}
_webView->setPage(new DataWebPage());
_webView->setUrl(url);

View file

@ -15,7 +15,7 @@
#include "DependencyManager.h"
#include "AddressManager.h"
QML_DIALOG_DEF(AddressBarDialog)
HIFI_QML_DEF(AddressBarDialog)
AddressBarDialog::AddressBarDialog(QQuickItem* parent) : OffscreenQmlDialog(parent) {
auto addressManager = DependencyManager::get<AddressManager>();

View file

@ -17,7 +17,7 @@
class AddressBarDialog : public OffscreenQmlDialog
{
Q_OBJECT
QML_DIALOG_DECL
HIFI_QML_DECL
public:
AddressBarDialog(QQuickItem* parent = nullptr);

View file

@ -15,7 +15,7 @@
#include "Menu.h"
#include <NetworkingConstants.h>
QML_DIALOG_DEF(LoginDialog)
HIFI_QML_DEF(LoginDialog)
LoginDialog::LoginDialog(QQuickItem *parent) : OffscreenQmlDialog(parent), _rootUrl(NetworkingConstants::METAVERSE_SERVER_URL.toString()) {
connect(&AccountManager::getInstance(), &AccountManager::loginComplete,
@ -35,8 +35,8 @@ void LoginDialog::toggleAction() {
});
} else {
// change the menu item to login
menu->setOptionText(MenuOption::Login, "Login");
menu->setOptionTriggerAction(MenuOption::Login, [] {
loginAction->setText("Login");
connect(loginAction, &QAction::triggered, [] {
LoginDialog::show();
});
}

View file

@ -17,7 +17,7 @@
class LoginDialog : public OffscreenQmlDialog
{
Q_OBJECT
QML_DIALOG_DECL
HIFI_QML_DECL
Q_PROPERTY(QString statusText READ statusText WRITE setStatusText NOTIFY statusTextChanged)
Q_PROPERTY(QString rootUrl READ rootUrl)

View file

@ -105,6 +105,10 @@ const QUrl DEFAULT_HEAD_MODEL_URL = QUrl("http://public.highfidelity.io/models/h
const QUrl DEFAULT_BODY_MODEL_URL = QUrl("http://public.highfidelity.io/models/skeletons/defaultAvatar_body.fst");
const QUrl DEFAULT_FULL_AVATAR_MODEL_URL = QUrl("http://public.highfidelity.io/marketplace/contents/029db3d4-da2c-4cb2-9c08-b9612ba576f5/02949063e7c4aed42ad9d1a58461f56d.fst");
const QString DEFAULT_HEAD_MODEL_NAME = QString("Robot");
const QString DEFAULT_BODY_MODEL_NAME = QString("Robot");
const QString DEFAULT_FULL_AVATAR_MODEL_NAME = QString("Default");
// Where one's own Avatar begins in the world (will be overwritten if avatar data file is found).
// This is the start location in the Sandbox (xyz: 6270, 211, 6000).

View file

@ -643,7 +643,7 @@ void EntityTreeRenderer::renderElement(OctreeElement* element, RenderArgs* args)
// NOTE: Zone Entities are a special case we handle here... Zones don't render
// like other entity types. So we will skip the normal rendering tests
if (entityItem->getType() == EntityTypes::Zone) {
if (entityItem->contains(args->_viewFrustum->getPosition())) {
if (entityItem->contains(_viewState->getAvatarPosition())) {
float entityVolumeEstimate = entityItem->getVolumeEstimate();
if (entityVolumeEstimate < _bestZoneVolume) {
_bestZoneVolume = entityVolumeEstimate;

View file

@ -192,31 +192,34 @@ void EntityItemProperties::setLastEdited(quint64 usecTime) {
_lastEdited = usecTime > _created ? usecTime : _created;
}
const char* shapeTypeNames[] = {"none", "box", "sphere", "ellipsoid", "convex-hull", "plane", "compound", "capsule-x",
const char* shapeTypeNames[] = {"none", "box", "sphere", "ellipsoid", "plane", "compound", "capsule-x",
"capsule-y", "capsule-z", "cylinder-x", "cylinder-y", "cylinder-z"};
QHash<QString, ShapeType> stringToShapeTypeLookup;
void addShapeType(ShapeType type) {
stringToShapeTypeLookup[shapeTypeNames[type]] = type;
}
void buildStringToShapeTypeLookup() {
stringToShapeTypeLookup["none"] = SHAPE_TYPE_NONE;
stringToShapeTypeLookup["box"] = SHAPE_TYPE_BOX;
stringToShapeTypeLookup["sphere"] = SHAPE_TYPE_SPHERE;
stringToShapeTypeLookup["ellipsoid"] = SHAPE_TYPE_ELLIPSOID;
stringToShapeTypeLookup["convex-hull"] = SHAPE_TYPE_COMPOUND;
stringToShapeTypeLookup["plane"] = SHAPE_TYPE_PLANE;
stringToShapeTypeLookup["compound"] = SHAPE_TYPE_COMPOUND;
stringToShapeTypeLookup["capsule-x"] = SHAPE_TYPE_CAPSULE_X;
stringToShapeTypeLookup["capsule-y"] = SHAPE_TYPE_CAPSULE_Y;
stringToShapeTypeLookup["capsule-z"] = SHAPE_TYPE_CAPSULE_Z;
stringToShapeTypeLookup["cylinder-x"] = SHAPE_TYPE_CYLINDER_X;
stringToShapeTypeLookup["cylinder-y"] = SHAPE_TYPE_CYLINDER_Y;
stringToShapeTypeLookup["cylinder-z"] = SHAPE_TYPE_CYLINDER_Z;
addShapeType(SHAPE_TYPE_NONE);
addShapeType(SHAPE_TYPE_BOX);
addShapeType(SHAPE_TYPE_SPHERE);
addShapeType(SHAPE_TYPE_ELLIPSOID);
addShapeType(SHAPE_TYPE_PLANE);
addShapeType(SHAPE_TYPE_COMPOUND);
addShapeType(SHAPE_TYPE_CAPSULE_X);
addShapeType(SHAPE_TYPE_CAPSULE_Y);
addShapeType(SHAPE_TYPE_CAPSULE_Z);
addShapeType(SHAPE_TYPE_CYLINDER_X);
addShapeType(SHAPE_TYPE_CYLINDER_Y);
addShapeType(SHAPE_TYPE_CYLINDER_Z);
}
QString EntityItemProperties::getShapeTypeAsString() const {
if (_shapeType < sizeof(shapeTypeNames) / sizeof(char *))
return QString(shapeTypeNames[_shapeType]);
return QString("none");
return QString(shapeTypeNames[SHAPE_TYPE_NONE]);
}
void EntityItemProperties::setShapeTypeFromString(const QString& shapeName) {

View file

@ -55,9 +55,9 @@ public:
glm::vec3 getKeyLightColorVec3() const {
const quint8 MAX_COLOR = 255;
glm::vec3 color = { _keyLightColor[RED_INDEX] / MAX_COLOR,
_keyLightColor[GREEN_INDEX] / MAX_COLOR,
_keyLightColor[BLUE_INDEX] / MAX_COLOR };
glm::vec3 color = { (float)_keyLightColor[RED_INDEX] / (float)MAX_COLOR,
(float)_keyLightColor[GREEN_INDEX] / (float)MAX_COLOR,
(float)_keyLightColor[BLUE_INDEX] / (float)MAX_COLOR };
return color;
}

View file

@ -10,8 +10,7 @@
//
#include "MessageDialog.h"
QML_DIALOG_DEF(MessageDialog)
HIFI_QML_DEF(MessageDialog)
MessageDialog::MessageDialog(QQuickItem *parent) : OffscreenQmlDialog(parent) {
_buttons = StandardButtons(Ok | Cancel);
@ -76,29 +75,8 @@ void MessageDialog::setStandardButtons(StandardButtons buttons) {
}
void MessageDialog::click(StandardButton button) {
click(static_cast<StandardButton>(button),
static_cast<QPlatformDialogHelper::ButtonRole>(
QPlatformDialogHelper::buttonRole(static_cast<QPlatformDialogHelper::StandardButton>(button))));
}
QUrl MessageDialog::standardIconSource() {
switch (icon()) {
case QMessageDialogOptions::Information:
return QUrl("images/information.png");
break;
case QMessageDialogOptions::Warning:
return QUrl("images/warning.png");
break;
case QMessageDialogOptions::Critical:
return QUrl("images/critical.png");
break;
case QMessageDialogOptions::Question:
return QUrl("images/question.png");
break;
default:
return QUrl();
break;
}
// FIXME try to do it more like the standard dialog
click(StandardButton(button), ButtonRole::NoRole);
}
MessageDialog::StandardButtons MessageDialog::standardButtons() const {
@ -109,7 +87,7 @@ MessageDialog::StandardButton MessageDialog::clickedButton() const {
return _clickedButton;
}
void MessageDialog::click(StandardButton button, QPlatformDialogHelper::ButtonRole) {
void MessageDialog::click(StandardButton button, ButtonRole) {
_clickedButton = button;
if (_resultCallback) {
_resultCallback(QMessageBox::StandardButton(_clickedButton));

View file

@ -13,12 +13,11 @@
#define hifi_MessageDialog_h
#include "OffscreenQmlDialog.h"
#include <5.4.1/QtGui/qpa/qplatformdialoghelper.h>
class MessageDialog : public OffscreenQmlDialog
{
Q_OBJECT
QML_DIALOG_DECL
HIFI_QML_DECL
private:
Q_ENUMS(Icon)
@ -26,19 +25,27 @@ private:
Q_PROPERTY(QString informativeText READ informativeText WRITE setInformativeText NOTIFY informativeTextChanged)
Q_PROPERTY(QString detailedText READ detailedText WRITE setDetailedText NOTIFY detailedTextChanged)
Q_PROPERTY(Icon icon READ icon WRITE setIcon NOTIFY iconChanged)
Q_PROPERTY(QUrl standardIconSource READ standardIconSource NOTIFY iconChanged)
Q_PROPERTY(StandardButtons standardButtons READ standardButtons WRITE setStandardButtons NOTIFY standardButtonsChanged)
Q_PROPERTY(StandardButton clickedButton READ clickedButton NOTIFY buttonClicked)
public:
enum Icon {
NoIcon = QMessageDialogOptions::NoIcon,
Information = QMessageDialogOptions::Information,
Warning = QMessageDialogOptions::Warning,
Critical = QMessageDialogOptions::Critical,
Question = QMessageDialogOptions::Question
};
enum Icon { NoIcon, Information, Warning, Critical, Question };
enum ButtonRole {
// keep this in sync with QDialogButtonBox::ButtonRole and QPlatformDialogHelper::ButtonRole
InvalidRole = -1,
AcceptRole,
RejectRole,
DestructiveRole,
ActionRole,
HelpRole,
YesRole,
NoRole,
ResetRole,
ApplyRole,
NRoles
};
MessageDialog(QQuickItem *parent = 0);
virtual ~MessageDialog();
@ -57,7 +64,6 @@ public slots:
void setStandardButtons(StandardButtons buttons);
void setResultCallback(OffscreenUi::ButtonCallback callback);
void click(StandardButton button);
QUrl standardIconSource();
StandardButtons standardButtons() const;
StandardButton clickedButton() const;
@ -76,7 +82,7 @@ signals:
void reset();
protected slots:
virtual void click(StandardButton button, QPlatformDialogHelper::ButtonRole);
virtual void click(StandardButton button, ButtonRole);
virtual void accept();
virtual void reject();

View file

@ -13,38 +13,9 @@
#define hifi_OffscreenQmlDialog_h
#include <QQuickItem>
#include <5.4.1/QtGui/qpa/qplatformdialoghelper.h>
#include "OffscreenUi.h"
#define QML_DIALOG_DECL \
private: \
static const QString NAME; \
static const QUrl QML; \
public: \
static void registerType(); \
static void show(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
static void toggle(std::function<void(QQmlContext*, QObject*)> f = [](QQmlContext*, QObject*) {}); \
private:
#define QML_DIALOG_DEF(x) \
const QUrl x::QML = QUrl(#x ".qml"); \
const QString x::NAME = #x; \
\
void x::registerType() { \
qmlRegisterType<x>("Hifi", 1, 0, NAME.toLocal8Bit().constData()); \
} \
\
void x::show(std::function<void(QQmlContext*, QObject*)> f) { \
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
offscreenUi->show(QML, NAME, f); \
} \
\
void x::toggle(std::function<void(QQmlContext*, QObject*)> f) { \
auto offscreenUi = DependencyManager::get<OffscreenUi>(); \
offscreenUi->toggle(QML, NAME, f); \
}
class OffscreenQmlDialog : public QQuickItem
{
Q_OBJECT
@ -57,25 +28,26 @@ public:
virtual ~OffscreenQmlDialog();
enum StandardButton {
NoButton = QPlatformDialogHelper::NoButton,
Ok = QPlatformDialogHelper::Ok,
Save = QPlatformDialogHelper::Save,
SaveAll = QPlatformDialogHelper::SaveAll,
Open = QPlatformDialogHelper::Open,
Yes = QPlatformDialogHelper::Yes,
YesToAll = QPlatformDialogHelper::YesToAll,
No = QPlatformDialogHelper::No,
NoToAll = QPlatformDialogHelper::NoToAll,
Abort = QPlatformDialogHelper::Abort,
Retry = QPlatformDialogHelper::Retry,
Ignore = QPlatformDialogHelper::Ignore,
Close = QPlatformDialogHelper::Close,
Cancel = QPlatformDialogHelper::Cancel,
Discard = QPlatformDialogHelper::Discard,
Help = QPlatformDialogHelper::Help,
Apply = QPlatformDialogHelper::Apply,
Reset = QPlatformDialogHelper::Reset,
RestoreDefaults = QPlatformDialogHelper::RestoreDefaults,
// keep this in sync with QDialogButtonBox::StandardButton and QMessageBox::StandardButton
NoButton = 0x00000000,
Ok = 0x00000400,
Save = 0x00000800,
SaveAll = 0x00001000,
Open = 0x00002000,
Yes = 0x00004000,
YesToAll = 0x00008000,
No = 0x00010000,
NoToAll = 0x00020000,
Abort = 0x00040000,
Retry = 0x00080000,
Ignore = 0x00100000,
Close = 0x00200000,
Cancel = 0x00400000,
Discard = 0x00800000,
Help = 0x01000000,
Apply = 0x02000000,
Reset = 0x04000000,
RestoreDefaults = 0x08000000,
NButtons
};
Q_DECLARE_FLAGS(StandardButtons, StandardButton)

View file

@ -151,17 +151,18 @@ void OffscreenUi::setBaseUrl(const QUrl& baseUrl) {
_qmlEngine->setBaseUrl(baseUrl);
}
void OffscreenUi::load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f) {
QObject* OffscreenUi::load(const QUrl& qmlSource, std::function<void(QQmlContext*, QObject*)> f) {
qDebug() << "Loading QML from URL " << qmlSource;
_qmlComponent->loadUrl(qmlSource);
if (_qmlComponent->isLoading())
if (_qmlComponent->isLoading()) {
connect(_qmlComponent, &QQmlComponent::statusChanged, this,
[this, f](QQmlComponent::Status){
finishQmlLoad(f);
});
else {
finishQmlLoad(f);
return nullptr;
}
return finishQmlLoad(f);
}
void OffscreenUi::requestUpdate() {
@ -177,14 +178,14 @@ void OffscreenUi::requestRender() {
}
}
void OffscreenUi::finishQmlLoad(std::function<void(QQmlContext*, QObject*)> f) {
QObject* OffscreenUi::finishQmlLoad(std::function<void(QQmlContext*, QObject*)> f) {
disconnect(_qmlComponent, &QQmlComponent::statusChanged, this, 0);
if (_qmlComponent->isError()) {
QList<QQmlError> errorList = _qmlComponent->errors();
foreach(const QQmlError &error, errorList) {
qWarning() << error.url() << error.line() << error;
}
return;
return nullptr;
}
QQmlContext * newContext = new QQmlContext(_qmlEngine, qApp);
@ -196,38 +197,41 @@ void OffscreenUi::finishQmlLoad(std::function<void(QQmlContext*, QObject*)> f) {
if (!_rootItem) {
qFatal("Unable to finish loading QML root");
}
return;
return nullptr;
}
f(newContext, newObject);
_qmlComponent->completeCreate();
// All quick items should be focusable
QQuickItem* newItem = qobject_cast<QQuickItem*>(newObject);
if (!newItem) {
qWarning("run: Not a QQuickItem");
return;
delete newObject;
if (!_rootItem) {
qFatal("Unable to find root QQuickItem");
}
return;
if (newItem) {
// Make sure we make items focusable (critical for
// supporting keyboard shortcuts)
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
}
// Make sure we make items focusable (critical for
// supporting keyboard shortcuts)
newItem->setFlag(QQuickItem::ItemIsFocusScope, true);
if (!_rootItem) {
// The root item is ready. Associate it with the window.
_rootItem = newItem;
_rootItem->setParentItem(_quickWindow->contentItem());
_rootItem->setSize(_quickWindow->renderTargetSize());
_rootItem->forceActiveFocus();
} else {
// If we already have a root, just set a couple of flags and the ancestry
if (_rootItem) {
// Allow child windows to be destroyed from JS
QQmlEngine::setObjectOwnership(newItem, QQmlEngine::JavaScriptOwnership);
newItem->setParent(_rootItem);
newItem->setParentItem(_rootItem);
QQmlEngine::setObjectOwnership(newObject, QQmlEngine::JavaScriptOwnership);
newObject->setParent(_rootItem);
if (newItem) {
newItem->setParentItem(_rootItem);
}
return newObject;
}
if (!newItem) {
qFatal("Could not load object as root item");
return nullptr;
}
// The root item is ready. Associate it with the window.
_rootItem = newItem;
_rootItem->setParentItem(_quickWindow->contentItem());
_rootItem->setSize(_quickWindow->renderTargetSize());
return _rootItem;
}
@ -336,8 +340,6 @@ bool OffscreenUi::eventFilter(QObject* originalDestination, QEvent* event) {
case QEvent::KeyPress:
case QEvent::KeyRelease: {
event->ignore();
//if (_quickWindow->activeFocusItem()) {
// _quickWindow->sendEvent(_quickWindow->activeFocusItem(), event);
if (QCoreApplication::sendEvent(_quickWindow, event)) {
return event->isAccepted();
}
@ -415,7 +417,9 @@ void OffscreenUi::show(const QUrl& url, const QString& name, std::function<void(
load(url, f);
item = _rootItem->findChild<QQuickItem*>(name);
}
item->setEnabled(true);
if (item) {
item->setEnabled(true);
}
}
void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<void(QQmlContext*, QObject*)> f) {
@ -425,21 +429,25 @@ void OffscreenUi::toggle(const QUrl& url, const QString& name, std::function<voi
load(url, f);
item = _rootItem->findChild<QQuickItem*>(name);
}
item->setEnabled(!item->isEnabled());
if (item) {
item->setEnabled(!item->isEnabled());
}
}
void OffscreenUi::messageBox(const QString& title, const QString& text,
ButtonCallback callback,
QMessageBox::Icon icon,
QMessageBox::StandardButtons buttons) {
MessageDialog::show([=](QQmlContext*ctx, QObject*item) {
MessageDialog * pDialog = item->findChild<MessageDialog*>();
MessageDialog * pDialog{ nullptr };
MessageDialog::show([&](QQmlContext*ctx, QObject*item) {
pDialog = item->findChild<MessageDialog*>();
pDialog->setIcon((MessageDialog::Icon)icon);
pDialog->setTitle(title);
pDialog->setText(text);
pDialog->setStandardButtons(MessageDialog::StandardButtons((int)buttons));
pDialog->setResultCallback(callback);
});
pDialog->setEnabled(true);
}
void OffscreenUi::information(const QString& title, const QString& text,

View file

@ -26,6 +26,7 @@
#include <QOpenGLDebugLogger>
#include <QOpenGLFunctions>
#include <QQmlContext>
#include <QtQml/QQmlApplicationEngine>
#include <unordered_map>
#include <memory>
@ -185,18 +186,18 @@ public:
QObject* menuObject = offscreenUi->getRootItem()->findChild<QObject*>("HifiMenu");
HifiMenu* menu = offscreenUi->getRootItem()->findChild<HifiMenu*>();
menu->addMenu("", "File");
menu->addMenuItem("File", "Quit", []{
menu->addItem("File", "Quit", []{
QApplication::quit();
});
menu->addCheckableMenuItem("File", "Toggle", false, [](bool toggled) {
menu->addCheckableItem("File", "Toggle", false, [](bool toggled) {
qDebug() << "Toggle is " << toggled;
});
menu->addMenu("", "Edit");
menu->addMenuItem("Edit", "Undo");
menu->addMenuItem("Edit", "Redo");
menu->addMenuItem("Edit", "Copy");
menu->addMenuItem("Edit", "Cut");
menu->addMenuItem("Edit", "Paste");
menu->addItem("Edit", "Undo");
menu->addItem("Edit", "Redo");
menu->addItem("Edit", "Copy");
menu->addItem("Edit", "Cut");
menu->addItem("Edit", "Paste");
menu->addMenu("", "Long Menu Name...");
#endif
installEventFilter(offscreenUi.data());
@ -255,8 +256,8 @@ protected:
if (event->modifiers() & Qt::CTRL) {
auto offscreenUi = DependencyManager::get<OffscreenUi>();
HifiMenu * menu = offscreenUi->findChild<HifiMenu*>();
menu->addMenuItem("", "Test 3");
menu->addMenuItem("File", "Test 3");
menu->addItem("", "Test 3");
menu->addItem("File", "Test 3");
}
break;
case Qt::Key_K:
@ -325,6 +326,14 @@ const char * LOG_FILTER_RULES = R"V0G0N(
qt.quick.mouse.debug=false
)V0G0N";
//int main(int argc, char *argv[]) {
// QGuiApplication app(argc, argv);
// QQmlApplicationEngine engine;
// engine.setBaseUrl(QUrl::fromLocalFile(getQmlDir()));
// engine.load(QUrl("Main.qml"));
// return app.exec();
//}
int main(int argc, char** argv) {
QGuiApplication app(argc, argv);
// QLoggingCategory::setFilterRules(LOG_FILTER_RULES);