Merge branch 'master' of github.com:highfidelity/hifi into fix-collision-mask-for-children

This commit is contained in:
Dante Ruiz 2017-12-05 15:48:45 -08:00
commit 36aa0ae476
15 changed files with 118 additions and 153 deletions

View file

@ -65,21 +65,23 @@ var EventBridge;
// we need to listen to events that might precede the addition of this elements. // we need to listen to events that might precede the addition of this elements.
// A more robust hack will be to add a setInterval that look for DOM changes every 100-300 ms (low performance?) // A more robust hack will be to add a setInterval that look for DOM changes every 100-300 ms (low performance?)
window.onload = function(){ window.addEventListener("load",function(event) {
setTimeout(function() { setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate(); EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200); }, 1200);
}; }, false);
document.onclick = function(){
document.addEventListener("click",function(){
setTimeout(function() { setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate(); EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200); }, 1200);
}; }, false);
document.onchange = function(){
document.addEventListener("change",function(){
setTimeout(function() { setTimeout(function() {
EventBridge.forceHtmlAudioOutputDeviceUpdate(); EventBridge.forceHtmlAudioOutputDeviceUpdate();
}, 1200); }, 1200);
}; }, false);
tempEventBridge._callbacks.forEach(function (callback) { tempEventBridge._callbacks.forEach(function (callback) {
EventBridge.scriptEventReceived.connect(callback); EventBridge.scriptEventReceived.connect(callback);

View file

@ -12,9 +12,9 @@
var MAX_WARNINGS = 3; var MAX_WARNINGS = 3;
var numWarnings = 0; var numWarnings = 0;
var isWindowFocused = true; var isWindowFocused = true;
var isKeyboardRaised = false; window.isKeyboardRaised = false;
var isNumericKeyboard = false; window.isNumericKeyboard = false;
var isPasswordField = false; window.isPasswordField = false;
function shouldSetPasswordField() { function shouldSetPasswordField() {
var nodeType = document.activeElement.type; var nodeType = document.activeElement.type;
@ -62,7 +62,7 @@
var passwordField = shouldSetPasswordField(); var passwordField = shouldSetPasswordField();
if (isWindowFocused && if (isWindowFocused &&
(keyboardRaised !== isKeyboardRaised || numericKeyboard !== isNumericKeyboard || passwordField !== isPasswordField)) { (keyboardRaised !== window.isKeyboardRaised || numericKeyboard !== window.isNumericKeyboard || passwordField !== window.isPasswordField)) {
if (typeof EventBridge !== "undefined" && EventBridge !== null) { if (typeof EventBridge !== "undefined" && EventBridge !== null) {
EventBridge.emitWebEvent( EventBridge.emitWebEvent(
@ -75,20 +75,20 @@
} }
} }
if (!isKeyboardRaised) { if (!window.isKeyboardRaised) {
scheduleBringToView(250); // Allow time for keyboard to be raised in QML. scheduleBringToView(250); // Allow time for keyboard to be raised in QML.
// 2DO: should it be rather done from 'client area height changed' event? // 2DO: should it be rather done from 'client area height changed' event?
} }
isKeyboardRaised = keyboardRaised; window.isKeyboardRaised = keyboardRaised;
isNumericKeyboard = numericKeyboard; window.isNumericKeyboard = numericKeyboard;
isPasswordField = passwordField; window.isPasswordField = passwordField;
} }
}, POLL_FREQUENCY); }, POLL_FREQUENCY);
window.addEventListener("click", function () { window.addEventListener("click", function () {
var keyboardRaised = shouldRaiseKeyboard(); var keyboardRaised = shouldRaiseKeyboard();
if(keyboardRaised && isKeyboardRaised) { if (keyboardRaised && window.isKeyboardRaised) {
scheduleBringToView(150); scheduleBringToView(150);
} }
}); });
@ -99,7 +99,7 @@
window.addEventListener("blur", function () { window.addEventListener("blur", function () {
isWindowFocused = false; isWindowFocused = false;
isKeyboardRaised = false; window.isKeyboardRaised = false;
isNumericKeyboard = false; window.isNumericKeyboard = false;
}); });
})(); })();

View file

@ -206,16 +206,6 @@ Item {
root.isPasswordField = (focus && passphraseField.echoMode === TextInput.Password); root.isPasswordField = (focus && passphraseField.echoMode === TextInput.Password);
} }
MouseArea {
anchors.fill: parent;
onClicked: {
root.keyboardRaised = true;
root.isPasswordField = (passphraseField.echoMode === TextInput.Password);
mouse.accepted = false;
}
}
onAccepted: { onAccepted: {
submitPassphraseInputButton.enabled = false; submitPassphraseInputButton.enabled = false;
commerce.setPassphrase(passphraseField.text); commerce.setPassphrase(passphraseField.text);
@ -362,25 +352,6 @@ Item {
right: parent.right; right: parent.right;
} }
Image {
id: lowerKeyboardButton;
z: 999;
source: "images/lowerKeyboard.png";
anchors.right: keyboard.right;
anchors.top: keyboard.showMirrorText ? keyboard.top : undefined;
anchors.bottom: keyboard.showMirrorText ? undefined : keyboard.bottom;
height: 50;
width: 60;
MouseArea {
anchors.fill: parent;
onClicked: {
root.keyboardRaised = false;
}
}
}
HifiControlsUit.Keyboard { HifiControlsUit.Keyboard {
id: keyboard; id: keyboard;
raised: HMD.mounted && root.keyboardRaised; raised: HMD.mounted && root.keyboardRaised;

View file

@ -82,17 +82,6 @@ Item {
if (focus) { if (focus) {
var hidePassword = (currentPassphraseField.echoMode === TextInput.Password); var hidePassword = (currentPassphraseField.echoMode === TextInput.Password);
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword}); sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
} else if (!passphraseFieldAgain.focus) {
sendSignalToWallet({method: 'walletSetup_lowerKeyboard', isPasswordField: false});
}
}
MouseArea {
anchors.fill: parent;
onPressed: {
var hidePassword = (currentPassphraseField.echoMode === TextInput.Password);
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
mouse.accepted = false;
} }
} }
@ -115,21 +104,10 @@ Item {
activeFocusOnPress: true; activeFocusOnPress: true;
activeFocusOnTab: true; activeFocusOnTab: true;
MouseArea {
anchors.fill: parent;
onPressed: {
var hidePassword = (passphraseField.echoMode === TextInput.Password);
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
mouse.accepted = false;
}
}
onFocusChanged: { onFocusChanged: {
if (focus) { if (focus) {
var hidePassword = (passphraseField.echoMode === TextInput.Password); var hidePassword = (passphraseField.echoMode === TextInput.Password);
sendMessageToLightbox({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword}); sendMessageToLightbox({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
} else if (!passphraseFieldAgain.focus) {
sendMessageToLightbox({method: 'walletSetup_lowerKeyboard', isPasswordField: false});
} }
} }
@ -151,21 +129,10 @@ Item {
activeFocusOnPress: true; activeFocusOnPress: true;
activeFocusOnTab: true; activeFocusOnTab: true;
MouseArea {
anchors.fill: parent;
onPressed: {
var hidePassword = (passphraseFieldAgain.echoMode === TextInput.Password);
sendSignalToWallet({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
mouse.accepted = false;
}
}
onFocusChanged: { onFocusChanged: {
if (focus) { if (focus) {
var hidePassword = (passphraseFieldAgain.echoMode === TextInput.Password); var hidePassword = (passphraseFieldAgain.echoMode === TextInput.Password);
sendMessageToLightbox({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword}); sendMessageToLightbox({method: 'walletSetup_raiseKeyboard', isPasswordField: hidePassword});
} else if (!passphraseField.focus) {
sendMessageToLightbox({method: 'walletSetup_lowerKeyboard', isPasswordField: false});
} }
} }

View file

@ -47,6 +47,7 @@ Rectangle {
} else if (walletStatus === 1) { } else if (walletStatus === 1) {
if (root.activeView !== "walletSetup") { if (root.activeView !== "walletSetup") {
root.activeView = "walletSetup"; root.activeView = "walletSetup";
commerce.resetLocalWalletOnly();
} }
} else if (walletStatus === 2) { } else if (walletStatus === 2) {
if (root.activeView !== "passphraseModal") { if (root.activeView !== "passphraseModal") {
@ -666,25 +667,6 @@ Rectangle {
right: parent.right; right: parent.right;
} }
Image {
id: lowerKeyboardButton;
z: 999;
source: "images/lowerKeyboard.png";
anchors.right: keyboard.right;
anchors.top: keyboard.showMirrorText ? keyboard.top : undefined;
anchors.bottom: keyboard.showMirrorText ? undefined : keyboard.bottom;
height: 50;
width: 60;
MouseArea {
anchors.fill: parent;
onClicked: {
root.keyboardRaised = false;
}
}
}
HifiControlsUit.Keyboard { HifiControlsUit.Keyboard {
id: keyboard; id: keyboard;
raised: HMD.mounted && root.keyboardRaised; raised: HMD.mounted && root.keyboardRaised;

View file

@ -68,6 +68,7 @@ Item {
Connections { Connections {
target: GlobalServices target: GlobalServices
onMyUsernameChanged: { onMyUsernameChanged: {
transactionHistoryModel.clear();
usernameText.text = Account.username; usernameText.text = Account.username;
} }
} }

View file

@ -371,7 +371,7 @@ Item {
Item { Item {
id: securityImageTip; id: securityImageTip;
visible: false; visible: !root.hasShownSecurityImageTip && root.activeView === "step_3";
z: 999; z: 999;
anchors.fill: root; anchors.fill: root;
@ -421,7 +421,6 @@ Item {
text: "Got It"; text: "Got It";
onClicked: { onClicked: {
root.hasShownSecurityImageTip = true; root.hasShownSecurityImageTip = true;
securityImageTip.visible = false;
passphraseSelection.focusFirstTextField(); passphraseSelection.focusFirstTextField();
} }
} }
@ -439,9 +438,6 @@ Item {
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
commerce.getWalletAuthenticatedStatus(); commerce.getWalletAuthenticatedStatus();
if (!root.hasShownSecurityImageTip) {
securityImageTip.visible = true;
}
} }
} }
@ -732,6 +728,7 @@ Item {
text: "Finish"; text: "Finish";
onClicked: { onClicked: {
root.visible = false; root.visible = false;
root.hasShownSecurityImageTip = false;
sendSignalToWallet({method: 'walletSetup_finished', referrer: root.referrer ? root.referrer : ""}); sendSignalToWallet({method: 'walletSetup_finished', referrer: root.referrer ? root.referrer : ""});
} }
} }

View file

@ -128,6 +128,11 @@ void QmlCommerce::reset() {
wallet->reset(); wallet->reset();
} }
void QmlCommerce::resetLocalWalletOnly() {
auto wallet = DependencyManager::get<Wallet>();
wallet->reset();
}
void QmlCommerce::account() { void QmlCommerce::account() {
auto ledger = DependencyManager::get<Ledger>(); auto ledger = DependencyManager::get<Ledger>();
ledger->account(); ledger->account();

View file

@ -65,6 +65,7 @@ protected:
Q_INVOKABLE void history(); Q_INVOKABLE void history();
Q_INVOKABLE void generateKeyPair(); Q_INVOKABLE void generateKeyPair();
Q_INVOKABLE void reset(); Q_INVOKABLE void reset();
Q_INVOKABLE void resetLocalWalletOnly();
Q_INVOKABLE void account(); Q_INVOKABLE void account();
Q_INVOKABLE void certificateInfo(const QString& certificateId); Q_INVOKABLE void certificateInfo(const QString& certificateId);

View file

@ -321,6 +321,16 @@ Wallet::Wallet() {
auto accountManager = DependencyManager::get<AccountManager>(); auto accountManager = DependencyManager::get<AccountManager>();
connect(accountManager.data(), &AccountManager::usernameChanged, this, [&]() { connect(accountManager.data(), &AccountManager::usernameChanged, this, [&]() {
getWalletStatus(); getWalletStatus();
_publicKeys.clear();
if (_securityImage) {
delete _securityImage;
}
_securityImage = nullptr;
// tell the provider we got nothing
updateImageProvider();
_passphrase->clear();
}); });
} }

View file

@ -121,26 +121,20 @@ uint64_t uvec2ToUint64(const uvec2& v) {
class AudioHandler : public QObject, QRunnable { class AudioHandler : public QObject, QRunnable {
Q_OBJECT Q_OBJECT
public: public:
AudioHandler(QObject* container, const QString& deviceName, int runDelayMs = 0, QObject* parent = nullptr) : QObject(parent) { AudioHandler(QSharedPointer<OffscreenQmlSurface> surface, const QString& deviceName, QObject* parent = nullptr) : QObject(parent) {
_container = container;
_newTargetDevice = deviceName; _newTargetDevice = deviceName;
_runDelayMs = runDelayMs; _surface = surface;
setAutoDelete(true); setAutoDelete(true);
if (deviceName.size() > 0) {
QThreadPool::globalInstance()->start(this); QThreadPool::globalInstance()->start(this);
} }
}
virtual ~AudioHandler() { virtual ~AudioHandler() {
qDebug() << "Audio Handler Destroyed"; qDebug() << "Audio Handler Destroyed";
} }
void run() override { void run() override {
if (_newTargetDevice.isEmpty()) { if (!_surface.isNull() && _surface->getRootItem() && !_surface->getCleaned()) {
return; for (auto player : _surface->getRootItem()->findChildren<QMediaPlayer*>()) {
}
if (_runDelayMs > 0) {
QThread::msleep(_runDelayMs);
}
auto audioIO = DependencyManager::get<AudioClient>();
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
for (auto player : _container->findChildren<QMediaPlayer*>()) {
auto mediaState = player->state(); auto mediaState = player->state();
QMediaService *svc = player->service(); QMediaService *svc = player->service();
if (nullptr == svc) { if (nullptr == svc) {
@ -156,7 +150,7 @@ public:
for (int i = 0; i < outputs.size(); i++) { for (int i = 0; i < outputs.size(); i++) {
QString output = outputs[i]; QString output = outputs[i];
QString description = out->outputDescription(output); QString description = out->outputDescription(output);
if (description == deviceName) { if (description == _newTargetDevice) {
deviceOuput = output; deviceOuput = output;
break; break;
} }
@ -167,17 +161,18 @@ public:
// this will reset it back to a paused state // this will reset it back to a paused state
if (mediaState == QMediaPlayer::State::PausedState) { if (mediaState == QMediaPlayer::State::PausedState) {
player->pause(); player->pause();
} else if (mediaState == QMediaPlayer::State::StoppedState) { }
else if (mediaState == QMediaPlayer::State::StoppedState) {
player->stop(); player->stop();
} }
} }
qDebug() << "QML Audio changed to " << deviceName; }
qDebug() << "QML Audio changed to " << _newTargetDevice;
} }
private: private:
QString _newTargetDevice; QString _newTargetDevice;
QObject* _container; QSharedPointer<OffscreenQmlSurface> _surface;
int _runDelayMs;
}; };
class OffscreenTextures { class OffscreenTextures {
@ -502,6 +497,7 @@ QOpenGLContext* OffscreenQmlSurface::getSharedContext() {
} }
void OffscreenQmlSurface::cleanup() { void OffscreenQmlSurface::cleanup() {
_isCleaned = true;
_canvas->makeCurrent(); _canvas->makeCurrent();
_renderControl->invalidate(); _renderControl->invalidate();
@ -600,6 +596,7 @@ OffscreenQmlSurface::OffscreenQmlSurface() {
OffscreenQmlSurface::~OffscreenQmlSurface() { OffscreenQmlSurface::~OffscreenQmlSurface() {
QObject::disconnect(&_updateTimer); QObject::disconnect(&_updateTimer);
disconnectAudioOutputTimer();
QObject::disconnect(qApp); QObject::disconnect(qApp);
cleanup(); cleanup();
@ -613,6 +610,15 @@ OffscreenQmlSurface::~OffscreenQmlSurface() {
void OffscreenQmlSurface::onAboutToQuit() { void OffscreenQmlSurface::onAboutToQuit() {
_paused = true; _paused = true;
QObject::disconnect(&_updateTimer); QObject::disconnect(&_updateTimer);
disconnectAudioOutputTimer();
}
void OffscreenQmlSurface::disconnectAudioOutputTimer() {
if (_audioOutputUpdateTimer.isActive()) {
_audioOutputUpdateTimer.stop();
}
QObject::disconnect(&_audioOutputUpdateTimer);
} }
void OffscreenQmlSurface::create() { void OffscreenQmlSurface::create() {
@ -671,6 +677,14 @@ void OffscreenQmlSurface::create() {
} }
}); });
// Setup the update of the QML media components with the current audio output device
QObject::connect(&_audioOutputUpdateTimer, &QTimer::timeout, this, [this]() {
new AudioHandler(sharedFromThis(), _currentAudioOutputDevice);
});
int waitForAudioQmlMs = 200;
_audioOutputUpdateTimer.setInterval(waitForAudioQmlMs);
_audioOutputUpdateTimer.setSingleShot(true);
// When Quick says there is a need to render, we will not render immediately. Instead, // When Quick says there is a need to render, we will not render immediately. Instead,
// a timer with a small interval is used to get better performance. // a timer with a small interval is used to get better performance.
QObject::connect(&_updateTimer, &QTimer::timeout, this, &OffscreenQmlSurface::updateQuick); QObject::connect(&_updateTimer, &QTimer::timeout, this, &OffscreenQmlSurface::updateQuick);
@ -699,10 +713,11 @@ void OffscreenQmlSurface::forceQmlAudioOutputDeviceUpdate() {
QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection); QMetaObject::invokeMethod(this, "forceQmlAudioOutputDeviceUpdate", Qt::QueuedConnection);
} else { } else {
auto audioIO = DependencyManager::get<AudioClient>(); auto audioIO = DependencyManager::get<AudioClient>();
QString deviceName = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName(); _currentAudioOutputDevice = audioIO->getActiveAudioDevice(QAudio::AudioOutput).deviceName();
int waitForAudioQmlMs = 500; if (_audioOutputUpdateTimer.isActive()) {
// The audio device need to be change using oth _audioOutputUpdateTimer.stop();
new AudioHandler(_rootItem, deviceName, waitForAudioQmlMs); }
_audioOutputUpdateTimer.start();
} }
} }

View file

@ -40,7 +40,7 @@ class QQuickItem;
using QmlContextCallback = std::function<void(QQmlContext*, QObject*)>; using QmlContextCallback = std::function<void(QQmlContext*, QObject*)>;
class OffscreenQmlSurface : public QObject { class OffscreenQmlSurface : public QObject, public QEnableSharedFromThis<OffscreenQmlSurface> {
Q_OBJECT Q_OBJECT
Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged) Q_PROPERTY(bool focusText READ isFocusText NOTIFY focusTextChanged)
public: public:
@ -75,6 +75,7 @@ public:
void pause(); void pause();
void resume(); void resume();
bool isPaused() const; bool isPaused() const;
bool getCleaned() { return _isCleaned; }
void setBaseUrl(const QUrl& baseUrl); void setBaseUrl(const QUrl& baseUrl);
QQuickItem* getRootItem(); QQuickItem* getRootItem();
@ -116,6 +117,7 @@ public slots:
void changeAudioOutputDevice(const QString& deviceName, bool isHtmlUpdate = false); void changeAudioOutputDevice(const QString& deviceName, bool isHtmlUpdate = false);
void forceHtmlAudioOutputDeviceUpdate(); void forceHtmlAudioOutputDeviceUpdate();
void forceQmlAudioOutputDeviceUpdate(); void forceQmlAudioOutputDeviceUpdate();
signals: signals:
void audioOutputDeviceChanged(const QString& deviceName); void audioOutputDeviceChanged(const QString& deviceName);
@ -147,6 +149,7 @@ private:
void render(); void render();
void cleanup(); void cleanup();
QJsonObject getGLContextData(); QJsonObject getGLContextData();
void disconnectAudioOutputTimer();
private slots: private slots:
void updateQuick(); void updateQuick();
@ -170,6 +173,9 @@ private:
uint64_t _lastRenderTime { 0 }; uint64_t _lastRenderTime { 0 };
uvec2 _size; uvec2 _size;
QTimer _audioOutputUpdateTimer;
QString _currentAudioOutputDevice;
// Texture management // Texture management
TextureAndFence _latestTextureAndFence { 0, 0 }; TextureAndFence _latestTextureAndFence { 0, 0 };
@ -177,6 +183,7 @@ private:
bool _polish { true }; bool _polish { true };
bool _paused { true }; bool _paused { true };
bool _focusText { false }; bool _focusText { false };
bool _isCleaned{ false };
uint8_t _maxFps { 60 }; uint8_t _maxFps { 60 };
MouseTranslator _mouseTranslator { [](const QPointF& p) { return p.toPoint(); } }; MouseTranslator _mouseTranslator { [](const QPointF& p) { return p.toPoint(); } };
QWindow* _proxyWindow { nullptr }; QWindow* _proxyWindow { nullptr };

View file

@ -62,7 +62,7 @@
this.pointingAtTablet = function(controllerData) { this.pointingAtTablet = function(controllerData) {
var rayPick = controllerData.rayPicks[this.hand]; var rayPick = controllerData.rayPicks[this.hand];
return (rayPick.objectID === HMD.tabletScreenID || rayPick.objectID === HMD.homeButtonID); return (HMD.tabletScreenID && HMD.homeButtonID && (rayPick.objectID === HMD.tabletScreenID || rayPick.objectID === HMD.homeButtonID));
}; };
this.getOtherModule = function() { this.getOtherModule = function() {

View file

@ -81,7 +81,8 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
}; };
this.otherHandIsParent = function(props) { this.otherHandIsParent = function(props) {
return this.getOtherModule().thisHandIsParent(props); var otherModule = this.getOtherModule();
return (otherModule.thisHandIsParent(props) && otherModule.grabbing);
}; };
this.startNearParentingGrabEntity = function (controllerData, targetProps) { this.startNearParentingGrabEntity = function (controllerData, targetProps) {

View file

@ -15,6 +15,9 @@ function setUpKeyboardControl() {
var KEYBOARD_HEIGHT = 200; var KEYBOARD_HEIGHT = 200;
function raiseKeyboard() { function raiseKeyboard() {
window.isKeyboardRaised = true;
window.isNumericKeyboard = this.type === "number";
if (lowerTimer !== null) { if (lowerTimer !== null) {
clearTimeout(lowerTimer); clearTimeout(lowerTimer);
lowerTimer = null; lowerTimer = null;
@ -35,6 +38,9 @@ function setUpKeyboardControl() {
} }
function doLowerKeyboard() { function doLowerKeyboard() {
window.isKeyboardRaised = false;
window.isNumericKeyboard = false;
EventBridge.emitWebEvent("_LOWER_KEYBOARD"); EventBridge.emitWebEvent("_LOWER_KEYBOARD");
lowerTimer = null; lowerTimer = null;
isRaised = false; isRaised = false;