From d68143675a9877ca582bdc53d5b345a71e1c6865 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 31 Mar 2015 16:24:27 -0700 Subject: [PATCH] first simple pass at using marketplace windows in preferences --- interface/src/Application.cpp | 5 +++ interface/src/Application.h | 3 ++ interface/src/scripting/WebWindowClass.cpp | 11 ++++--- interface/src/ui/PreferencesDialog.cpp | 37 ++++++++++++++++------ interface/src/ui/PreferencesDialog.h | 6 ++++ 5 files changed, 48 insertions(+), 14 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index eb427737e1..fc88511c57 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -3724,22 +3724,27 @@ bool Application::askToSetAvatarUrl(const QString& url) { _myAvatar->setFaceModelURL(url); UserActivityLogger::getInstance().changedModel("head", url); _myAvatar->sendIdentityPacket(); + emit faceURLChanged(url); } else if (msgBox.clickedButton() == bodyButton) { qDebug() << "Chose to use for body: " << url; _myAvatar->setSkeletonModelURL(url); // if the head is empty, reset it to the default head. if (_myAvatar->getFaceModelURLString().isEmpty()) { _myAvatar->setFaceModelURL(DEFAULT_HEAD_MODEL_URL); + emit faceURLChanged(DEFAULT_HEAD_MODEL_URL.toString()); UserActivityLogger::getInstance().changedModel("head", DEFAULT_HEAD_MODEL_URL.toString()); } UserActivityLogger::getInstance().changedModel("skeleton", url); _myAvatar->sendIdentityPacket(); + emit skeletonURLChanged(url); } else if (msgBox.clickedButton() == bodyAndHeadButton) { qDebug() << "Chose to use for body + head: " << url; _myAvatar->setFaceModelURL(QString()); _myAvatar->setSkeletonModelURL(url); UserActivityLogger::getInstance().changedModel("skeleton", url); _myAvatar->sendIdentityPacket(); + emit faceURLChanged(QString()); + emit skeletonURLChanged(url); } else { qDebug() << "Declined to use the avatar: " << url; } diff --git a/interface/src/Application.h b/interface/src/Application.h index 84b443b876..80e2d9e8de 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -336,6 +336,9 @@ signals: void checkBackgroundDownloads(); void domainConnectionRefused(const QString& reason); + void faceURLChanged(const QString& newValue); + void skeletonURLChanged(const QString& newValue); + public slots: void domainChanged(const QString& domainHostname); void updateWindowTitle(); diff --git a/interface/src/scripting/WebWindowClass.cpp b/interface/src/scripting/WebWindowClass.cpp index 61b3ce225f..31bd4029ac 100644 --- a/interface/src/scripting/WebWindowClass.cpp +++ b/interface/src/scripting/WebWindowClass.cpp @@ -54,6 +54,7 @@ WebWindowClass::WebWindowClass(const QString& title, const QString& url, int wid _windowWidget = dockWidget; } else { + _windowWidget = new QWidget(Application::getInstance()->getWindow(), Qt::Window); _windowWidget->setWindowTitle(title); _windowWidget->setMinimumSize(width, height); @@ -89,24 +90,24 @@ void WebWindowClass::setVisible(bool visible) { if (visible) { if (_isToolWindow) { QMetaObject::invokeMethod( - Application::getInstance()->getToolWindow(), "setVisible", Qt::BlockingQueuedConnection, Q_ARG(bool, visible)); + Application::getInstance()->getToolWindow(), "setVisible", Qt::AutoConnection, Q_ARG(bool, visible)); } else { - QMetaObject::invokeMethod(_windowWidget, "raise", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(_windowWidget, "raise", Qt::AutoConnection); } } - QMetaObject::invokeMethod(_windowWidget, "setVisible", Qt::BlockingQueuedConnection, Q_ARG(bool, visible)); + QMetaObject::invokeMethod(_windowWidget, "setVisible", Qt::AutoConnection, Q_ARG(bool, visible)); } void WebWindowClass::setURL(const QString& url) { if (QThread::currentThread() != thread()) { - QMetaObject::invokeMethod(this, "setURL", Qt::BlockingQueuedConnection, Q_ARG(QString, url)); + QMetaObject::invokeMethod(this, "setURL", Qt::AutoConnection, Q_ARG(QString, url)); return; } _webView->setUrl(url); } void WebWindowClass::raise() { - QMetaObject::invokeMethod(_windowWidget, "raise", Qt::BlockingQueuedConnection); + QMetaObject::invokeMethod(_windowWidget, "raise", Qt::AutoConnection); } QScriptValue WebWindowClass::constructor(QScriptContext* context, QScriptEngine* engine) { diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 4a9165ae44..ebb7777d27 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -21,12 +21,12 @@ #include "MainWindow.h" #include "LODManager.h" #include "Menu.h" -#include "ModelsBrowser.h" #include "PreferencesDialog.h" #include "Snapshot.h" #include "UserActivityLogger.h" #include "UIUtil.h" + const int PREFERENCES_HEIGHT_PADDING = 20; PreferencesDialog::PreferencesDialog(QWidget* parent) : @@ -46,6 +46,11 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) : connect(ui.buttonBrowseScriptsLocation, &QPushButton::clicked, this, &PreferencesDialog::openScriptsLocationBrowser); connect(ui.buttonReloadDefaultScripts, &QPushButton::clicked, Application::getInstance(), &Application::loadDefaultScripts); + + + connect(Application::getInstance(), &Application::faceURLChanged, this, &PreferencesDialog::faceURLChanged); + connect(Application::getInstance(), &Application::skeletonURLChanged, this, &PreferencesDialog::skeletonURLChanged); + // move dialog to left side move(parentWidget()->geometry().topLeft()); setFixedHeight(parentWidget()->size().height() - PREFERENCES_HEIGHT_PADDING); @@ -53,9 +58,19 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) : UIUtil::scaleWidgetFontSizes(this); } +void PreferencesDialog::faceURLChanged(const QString& newValue) { + ui.faceURLEdit->setText(newValue); +} + +void PreferencesDialog::skeletonURLChanged(const QString& newValue) { + ui.skeletonURLEdit->setText(newValue); +} + void PreferencesDialog::accept() { savePreferences(); close(); + delete _marketplaceWindow; + _marketplaceWindow = NULL; } void PreferencesDialog::setHeadUrl(QString modelUrl) { @@ -67,15 +82,19 @@ void PreferencesDialog::setSkeletonUrl(QString modelUrl) { } void PreferencesDialog::openHeadModelBrowser() { - ModelsBrowser modelBrowser(FSTReader::HEAD_MODEL); - connect(&modelBrowser, &ModelsBrowser::selected, this, &PreferencesDialog::setHeadUrl); - modelBrowser.browse(); + auto MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace?category=avatars"; + if (!_marketplaceWindow) { + _marketplaceWindow = new WebWindowClass("Marketplace", MARKETPLACE_URL, 900, 700, false); + } + _marketplaceWindow->setVisible(true); } void PreferencesDialog::openBodyModelBrowser() { - ModelsBrowser modelBrowser(FSTReader::HEAD_AND_BODY_MODEL); - connect(&modelBrowser, &ModelsBrowser::selected, this, &PreferencesDialog::setSkeletonUrl); - modelBrowser.browse(); + auto MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace?category=avatars"; + if (!_marketplaceWindow) { + _marketplaceWindow = new WebWindowClass("Marketplace", MARKETPLACE_URL, 900, 700, false); + } + _marketplaceWindow->setVisible(true); } void PreferencesDialog::openSnapshotLocationBrowser() { @@ -196,7 +215,7 @@ void PreferencesDialog::savePreferences() { QUrl faceModelURL(ui.faceURLEdit->text()); QString faceModelURLString = faceModelURL.toString(); if (faceModelURLString != _faceURLString) { - if (faceModelURLString.isEmpty() || faceModelURLString.toLower().endsWith(".fst")) { + if (faceModelURLString.isEmpty() || faceModelURLString.toLower().contains(".fst")) { // change the faceModelURL in the profile, it will also update this user's BlendFace myAvatar->setFaceModelURL(faceModelURL); UserActivityLogger::getInstance().changedModel("head", faceModelURLString); @@ -209,7 +228,7 @@ void PreferencesDialog::savePreferences() { QUrl skeletonModelURL(ui.skeletonURLEdit->text()); QString skeletonModelURLString = skeletonModelURL.toString(); if (skeletonModelURLString != _skeletonURLString) { - if (skeletonModelURLString.isEmpty() || skeletonModelURLString.toLower().endsWith(".fst")) { + if (skeletonModelURLString.isEmpty() || skeletonModelURLString.toLower().contains(".fst")) { // change the skeletonModelURL in the profile, it will also update this user's Body myAvatar->setSkeletonModelURL(skeletonModelURL); UserActivityLogger::getInstance().changedModel("skeleton", skeletonModelURLString); diff --git a/interface/src/ui/PreferencesDialog.h b/interface/src/ui/PreferencesDialog.h index ddacaa7127..4daa2d9696 100644 --- a/interface/src/ui/PreferencesDialog.h +++ b/interface/src/ui/PreferencesDialog.h @@ -17,6 +17,8 @@ #include #include +#include "scripting/WebWindowClass.h" + class PreferencesDialog : public QDialog { Q_OBJECT @@ -36,6 +38,8 @@ private: QString _faceURLString; QString _skeletonURLString; QString _displayNameString; + + WebWindowClass* _marketplaceWindow = NULL; private slots: void accept(); @@ -43,6 +47,8 @@ private slots: void setSkeletonUrl(QString modelUrl); void openSnapshotLocationBrowser(); void openScriptsLocationBrowser(); + void faceURLChanged(const QString& newValue); + void skeletonURLChanged(const QString& newValue); };