From 174e9f21333eecb7a9a93f9c1efae3a89e5b7db5 Mon Sep 17 00:00:00 2001 From: ZappoMan Date: Tue, 14 Apr 2015 12:38:29 -0700 Subject: [PATCH] more tweaks to preferences UI --- interface/src/avatar/MyAvatar.cpp | 23 +++++++++++++++++++++ interface/src/avatar/MyAvatar.h | 2 ++ interface/src/ui/AvatarAppearanceDialog.cpp | 20 ++++++++---------- interface/src/ui/AvatarAppearanceDialog.h | 1 + interface/src/ui/DialogsManager.h | 1 + interface/src/ui/PreferencesDialog.cpp | 14 +++++++------ interface/src/ui/PreferencesDialog.h | 2 ++ 7 files changed, 46 insertions(+), 17 deletions(-) diff --git a/interface/src/avatar/MyAvatar.cpp b/interface/src/avatar/MyAvatar.cpp index 3073bbb219..5a372ae274 100644 --- a/interface/src/avatar/MyAvatar.cpp +++ b/interface/src/avatar/MyAvatar.cpp @@ -943,6 +943,29 @@ void MyAvatar::clearJointAnimationPriorities() { } } +QString MyAvatar::getModelDescription() const { + QString result; + if (_useFullAvatar) { + if (!getFullAvartarModelName().isEmpty()) { + result = "Full Avatar \"" + getFullAvartarModelName() + "\""; + } else { + result = "Full Avatar \"" + _fullAvatarURLFromPreferences.fileName() + "\""; + } + } else { + if (!getHeadModelName().isEmpty()) { + result = "Head \"" + getHeadModelName() + "\""; + } else { + result = "Head \"" + _headURLFromPreferences.fileName() + "\""; + } + if (!getBodyModelName().isEmpty()) { + result += " and Body \"" + getBodyModelName() + "\""; + } else { + result += " and Body \"" + _skeletonURLFromPreferences.fileName() + "\""; + } + } + return result; +} + void MyAvatar::setFaceModelURL(const QUrl& faceModelURL) { Avatar::setFaceModelURL(faceModelURL); _billboardValid = false; diff --git a/interface/src/avatar/MyAvatar.h b/interface/src/avatar/MyAvatar.h index 9c1f78c696..066bfdd930 100644 --- a/interface/src/avatar/MyAvatar.h +++ b/interface/src/avatar/MyAvatar.h @@ -131,6 +131,8 @@ public: const QString& getBodyModelName() const { return _bodyModelName; } const QString& getFullAvartarModelName() const { return _fullAvatarModelName; } + QString getModelDescription() const; + virtual void setAttachmentData(const QVector& attachmentData); virtual glm::vec3 getSkeletonPosition() const; diff --git a/interface/src/ui/AvatarAppearanceDialog.cpp b/interface/src/ui/AvatarAppearanceDialog.cpp index 1200c71cac..ceaaf140c4 100644 --- a/interface/src/ui/AvatarAppearanceDialog.cpp +++ b/interface/src/ui/AvatarAppearanceDialog.cpp @@ -26,9 +26,8 @@ #include "Snapshot.h" #include "UserActivityLogger.h" #include "UIUtil.h" - - -const int PREFERENCES_HEIGHT_PADDING = 20; +#include "ui/DialogsManager.h" +#include "ui/PreferencesDialog.h" AvatarAppearanceDialog::AvatarAppearanceDialog(QWidget* parent) : QDialog(parent) { @@ -52,10 +51,6 @@ AvatarAppearanceDialog::AvatarAppearanceDialog(QWidget* parent) : connect(Application::getInstance(), &Application::bodyURLChanged, this, &AvatarAppearanceDialog::bodyURLChanged); connect(Application::getInstance(), &Application::fullAvatarURLChanged, this, &AvatarAppearanceDialog::fullAvatarURLChanged); - // move dialog to left side - //move(parentWidget()->geometry().topLeft()); - //setFixedHeight(parentWidget()->size().height() - PREFERENCES_HEIGHT_PADDING); - auto myAvatar = DependencyManager::get()->getMyAvatar(); ui.bodyNameLabel->setText("Body - " + myAvatar->getBodyModelName()); @@ -66,18 +61,16 @@ AvatarAppearanceDialog::AvatarAppearanceDialog(QWidget* parent) : } void AvatarAppearanceDialog::useSeparateBodyAndHead(bool checked) { - setUseFullAvatar(!checked); - QUrl headURL(ui.faceURLEdit->text()); QUrl bodyURL(ui.skeletonURLEdit->text()); - DependencyManager::get()->getMyAvatar()->useHeadAndBodyURLs(headURL, bodyURL); + setUseFullAvatar(!checked); } void AvatarAppearanceDialog::useFullAvatar(bool checked) { - setUseFullAvatar(checked); QUrl fullAvatarURL(ui.fullAvatarURLEdit->text()); DependencyManager::get()->getMyAvatar()->useFullAvatarURL(fullAvatarURL); + setUseFullAvatar(checked); } void AvatarAppearanceDialog::setUseFullAvatar(bool useFullAvatar) { @@ -88,6 +81,8 @@ void AvatarAppearanceDialog::setUseFullAvatar(bool useFullAvatar) { ui.useFullAvatar->setChecked(_useFullAvatar); ui.useSeparateBodyAndHead->setChecked(!_useFullAvatar); + + DependencyManager::get()->getPreferencesDialog()->avatarDescriptionChanged(); } void AvatarAppearanceDialog::headURLChanged(const QString& newValue, const QString& modelName) { @@ -110,6 +105,9 @@ void AvatarAppearanceDialog::fullAvatarURLChanged(const QString& newValue, const void AvatarAppearanceDialog::accept() { saveAvatarAppearance(); + + DependencyManager::get()->getPreferencesDialog()->avatarDescriptionChanged(); + close(); delete _marketplaceWindow; _marketplaceWindow = NULL; diff --git a/interface/src/ui/AvatarAppearanceDialog.h b/interface/src/ui/AvatarAppearanceDialog.h index f7a735e611..be30caeedb 100644 --- a/interface/src/ui/AvatarAppearanceDialog.h +++ b/interface/src/ui/AvatarAppearanceDialog.h @@ -58,6 +58,7 @@ private slots: void useSeparateBodyAndHead(bool checked); void useFullAvatar(bool checked); + }; #endif // hifi_AvatarAppearanceDialog_h diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index e7f017d54d..d5d9c33a9a 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -44,6 +44,7 @@ public: QPointer getHMDToolsDialog() const { return _hmdToolsDialog; } QPointer getLodToolsDialog() const { return _lodToolsDialog; } QPointer getOctreeStatsDialog() const { return _octreeStatsDialog; } + QPointer getPreferencesDialog() const { return _preferencesDialog; } public slots: void toggleAddressBar(); diff --git a/interface/src/ui/PreferencesDialog.cpp b/interface/src/ui/PreferencesDialog.cpp index 99ad98ef2d..98f7382097 100644 --- a/interface/src/ui/PreferencesDialog.cpp +++ b/interface/src/ui/PreferencesDialog.cpp @@ -57,23 +57,25 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) : move(parentWidget()->geometry().topLeft()); setFixedHeight(parentWidget()->size().height() - PREFERENCES_HEIGHT_PADDING); - auto myAvatar = DependencyManager::get()->getMyAvatar(); - - ui.apperanceDescription->setText("Body - " + myAvatar->getBodyModelName()); + ui.apperanceDescription->setText(DependencyManager::get()->getMyAvatar()->getModelDescription()); UIUtil::scaleWidgetFontSizes(this); } +void PreferencesDialog::avatarDescriptionChanged() { + ui.apperanceDescription->setText(DependencyManager::get()->getMyAvatar()->getModelDescription()); +} + void PreferencesDialog::headURLChanged(const QString& newValue, const QString& modelName) { - ui.apperanceDescription->setText("Head - " + modelName); + ui.apperanceDescription->setText(DependencyManager::get()->getMyAvatar()->getModelDescription()); } void PreferencesDialog::bodyURLChanged(const QString& newValue, const QString& modelName) { - ui.apperanceDescription->setText("Body - " + modelName); + ui.apperanceDescription->setText(DependencyManager::get()->getMyAvatar()->getModelDescription()); } void PreferencesDialog::fullAvatarURLChanged(const QString& newValue, const QString& modelName) { - ui.apperanceDescription->setText("Full Avatar - " + modelName); + ui.apperanceDescription->setText(DependencyManager::get()->getMyAvatar()->getModelDescription()); } void PreferencesDialog::accept() { diff --git a/interface/src/ui/PreferencesDialog.h b/interface/src/ui/PreferencesDialog.h index 22efe3489d..8e699c80a2 100644 --- a/interface/src/ui/PreferencesDialog.h +++ b/interface/src/ui/PreferencesDialog.h @@ -25,6 +25,8 @@ class PreferencesDialog : public QDialog { public: PreferencesDialog(QWidget* parent = nullptr); + void avatarDescriptionChanged(); + protected: void resizeEvent(QResizeEvent* resizeEvent);