Added browse buttons in the menu

This commit is contained in:
Atlante45 2014-03-18 13:59:08 -07:00
parent 388f8d480a
commit 0a80f8fcd6

View file

@ -24,11 +24,12 @@
#include <QSlider> #include <QSlider>
#include <QStandardPaths> #include <QStandardPaths>
#include <QUuid> #include <QUuid>
#include <QWindow> #include <QHBoxLayout>
#include <AccountManager.h> #include <AccountManager.h>
#include <XmppClient.h> #include <XmppClient.h>
#include <UUID.h> #include <UUID.h>
#include <FileDownloader.h>
#include "Application.h" #include "Application.h"
#include "Menu.h" #include "Menu.h"
@ -36,6 +37,7 @@
#include "Util.h" #include "Util.h"
#include "InfoView.h" #include "InfoView.h"
#include "ui/MetavoxelEditor.h" #include "ui/MetavoxelEditor.h"
#include "ModelBrowser.h"
Menu* Menu::_instance = NULL; Menu* Menu::_instance = NULL;
@ -692,6 +694,9 @@ void Menu::loginForCurrentDomain() {
void Menu::editPreferences() { void Menu::editPreferences() {
Application* applicationInstance = Application::getInstance(); Application* applicationInstance = Application::getInstance();
ModelBrowser browser;
const QString BROWSE_BUTTON_TEXT = "Browse";
QDialog dialog(applicationInstance->getWindow()); QDialog dialog(applicationInstance->getWindow());
dialog.setWindowTitle("Interface Preferences"); dialog.setWindowTitle("Interface Preferences");
@ -702,17 +707,33 @@ void Menu::editPreferences() {
QFormLayout* form = new QFormLayout(); QFormLayout* form = new QFormLayout();
layout->addLayout(form, 1); layout->addLayout(form, 1);
QHBoxLayout headModelLayout;
QString faceURLString = applicationInstance->getAvatar()->getHead()->getFaceModel().getURL().toString(); QString faceURLString = applicationInstance->getAvatar()->getHead()->getFaceModel().getURL().toString();
QLineEdit* faceURLEdit = new QLineEdit(faceURLString); QLineEdit headURLEdit(faceURLString);
faceURLEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); QPushButton headBrowseButton(BROWSE_BUTTON_TEXT);
faceURLEdit->setPlaceholderText(DEFAULT_HEAD_MODEL_URL.toString()); connect(&headBrowseButton, SIGNAL(clicked()), &browser, SLOT(browseHead()));
form->addRow("Face URL:", faceURLEdit); connect(&browser, SIGNAL(selectedHead(QString)), &headURLEdit, SLOT(setText(QString)));
headURLEdit.setReadOnly(true);
headURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH);
headURLEdit.setPlaceholderText(DEFAULT_HEAD_MODEL_URL.toString());
headModelLayout.addWidget(&headURLEdit);
headModelLayout.addWidget(&headBrowseButton);
form->addRow("Head URL:", &headModelLayout);
QHBoxLayout skeletonModelLayout;
QString skeletonURLString = applicationInstance->getAvatar()->getSkeletonModel().getURL().toString(); QString skeletonURLString = applicationInstance->getAvatar()->getSkeletonModel().getURL().toString();
QLineEdit* skeletonURLEdit = new QLineEdit(skeletonURLString); QLineEdit skeletonURLEdit(skeletonURLString);
skeletonURLEdit->setMinimumWidth(QLINE_MINIMUM_WIDTH); QPushButton SkeletonBrowseButton(BROWSE_BUTTON_TEXT);
skeletonURLEdit->setPlaceholderText(DEFAULT_BODY_MODEL_URL.toString()); connect(&SkeletonBrowseButton, SIGNAL(clicked()), &browser, SLOT(browseSkeleton()));
form->addRow("Skeleton URL:", skeletonURLEdit); connect(&browser, SIGNAL(selectedSkeleton(QString)), &skeletonURLEdit, SLOT(setText(QString)));
skeletonURLEdit.setReadOnly(true);
skeletonURLEdit.setMinimumWidth(QLINE_MINIMUM_WIDTH);
skeletonURLEdit.setPlaceholderText(DEFAULT_BODY_MODEL_URL.toString());
skeletonModelLayout.addWidget(&skeletonURLEdit);
skeletonModelLayout.addWidget(&SkeletonBrowseButton);
form->addRow("Skeleton URL:", &skeletonModelLayout);
QString displayNameString = applicationInstance->getAvatar()->getDisplayName(); QString displayNameString = applicationInstance->getAvatar()->getDisplayName();
QLineEdit* displayNameEdit = new QLineEdit(displayNameString); QLineEdit* displayNameEdit = new QLineEdit(displayNameString);
@ -774,21 +795,17 @@ void Menu::editPreferences() {
int ret = dialog.exec(); int ret = dialog.exec();
if (ret == QDialog::Accepted) { if (ret == QDialog::Accepted) {
QUrl faceModelURL(faceURLEdit->text());
bool shouldDispatchIdentityPacket = false; bool shouldDispatchIdentityPacket = false;
if (faceModelURL.toString() != faceURLString) { if (headURLEdit.text() != faceURLString && !headURLEdit.text().isEmpty()) {
// change the faceModelURL in the profile, it will also update this user's BlendFace // change the faceModelURL in the profile, it will also update this user's BlendFace
applicationInstance->getAvatar()->setFaceModelURL(faceModelURL); applicationInstance->getAvatar()->setFaceModelURL(QUrl(headURLEdit.text()));
shouldDispatchIdentityPacket = true; shouldDispatchIdentityPacket = true;
} }
QUrl skeletonModelURL(skeletonURLEdit->text()); if (skeletonURLEdit.text() != skeletonURLString && !skeletonURLEdit.text().isEmpty()) {
if (skeletonModelURL.toString() != skeletonURLString) {
// change the skeletonModelURL in the profile, it will also update this user's Body // change the skeletonModelURL in the profile, it will also update this user's Body
applicationInstance->getAvatar()->setSkeletonModelURL(skeletonModelURL); applicationInstance->getAvatar()->setSkeletonModelURL(QUrl(skeletonURLEdit.text()));
shouldDispatchIdentityPacket = true; shouldDispatchIdentityPacket = true;
} }