Merge pull request #12606 from ElderOrb/FB12956_RC65

Fix for broken 'toggle audio meter' button
This commit is contained in:
John Conklin II 2018-03-09 11:20:27 -08:00 committed by GitHub
commit 25b93d9fd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 11 deletions

View file

@ -14,9 +14,9 @@ import Qt.labs.settings 1.0
import "./hifi/audio" as HifiAudio import "./hifi/audio" as HifiAudio
Hifi.AvatarInputs { Item {
id: root; id: root;
objectName: "AvatarInputs" objectName: "AvatarInputsBar"
property int modality: Qt.NonModal property int modality: Qt.NonModal
width: audio.width; width: audio.width;
height: audio.height; height: audio.height;
@ -26,7 +26,7 @@ Hifi.AvatarInputs {
HifiAudio.MicBar { HifiAudio.MicBar {
id: audio; id: audio;
visible: root.showAudioTools; visible: AvatarInputs.showAudioTools;
standalone: true; standalone: true;
dragTarget: parent; dragTarget: parent;
} }

View file

@ -2725,7 +2725,12 @@ void Application::onDesktopRootContextCreated(QQmlContext* surfaceContext) {
void Application::onDesktopRootItemCreated(QQuickItem* rootItem) { void Application::onDesktopRootItemCreated(QQuickItem* rootItem) {
Stats::show(); Stats::show();
AvatarInputs::show(); auto surfaceContext = DependencyManager::get<OffscreenUi>()->getSurfaceContext();
surfaceContext->setContextProperty("Stats", Stats::getInstance());
auto offscreenUi = DependencyManager::get<OffscreenUi>();
auto qml = PathUtils::qmlUrl("AvatarInputsBar.qml");
offscreenUi->show(qml, "AvatarInputsBar");
} }
void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) { void Application::updateCamera(RenderArgs& renderArgs, float deltaTime) {

View file

@ -16,22 +16,19 @@
#include "Application.h" #include "Application.h"
#include "Menu.h" #include "Menu.h"
HIFI_QML_DEF(AvatarInputs)
static AvatarInputs* INSTANCE{ nullptr }; static AvatarInputs* INSTANCE{ nullptr };
Setting::Handle<bool> showAudioToolsSetting { QStringList { "AvatarInputs", "showAudioTools" }, false }; Setting::Handle<bool> showAudioToolsSetting { QStringList { "AvatarInputs", "showAudioTools" }, false };
AvatarInputs* AvatarInputs::getInstance() { AvatarInputs* AvatarInputs::getInstance() {
if (!INSTANCE) { if (!INSTANCE) {
AvatarInputs::registerType(); INSTANCE = new AvatarInputs();
Q_ASSERT(INSTANCE); Q_ASSERT(INSTANCE);
} }
return INSTANCE; return INSTANCE;
} }
AvatarInputs::AvatarInputs(QQuickItem* parent) : QQuickItem(parent) { AvatarInputs::AvatarInputs(QObject* parent) : QObject(parent) {
INSTANCE = this;
_showAudioTools = showAudioToolsSetting.get(); _showAudioTools = showAudioToolsSetting.get();
} }

View file

@ -19,7 +19,7 @@ public: \
private: \ private: \
type _##name{ initialValue }; type _##name{ initialValue };
class AvatarInputs : public QQuickItem { class AvatarInputs : public QObject {
Q_OBJECT Q_OBJECT
HIFI_QML_DECL HIFI_QML_DECL
@ -32,7 +32,7 @@ class AvatarInputs : public QQuickItem {
public: public:
static AvatarInputs* getInstance(); static AvatarInputs* getInstance();
Q_INVOKABLE float loudnessToAudioLevel(float loudness); Q_INVOKABLE float loudnessToAudioLevel(float loudness);
AvatarInputs(QQuickItem* parent = nullptr); AvatarInputs(QObject* parent = nullptr);
void update(); void update();
bool showAudioTools() const { return _showAudioTools; } bool showAudioTools() const { return _showAudioTools; }