From e898b4a900a1841beeeb78bea6fb398aefd818c2 Mon Sep 17 00:00:00 2001 From: Andrzej Kapolka Date: Sun, 4 May 2014 17:24:15 -0700 Subject: [PATCH] More attachment bits. --- interface/src/ui/AttachmentsDialog.cpp | 57 +++++++++++++++++++++++++- interface/src/ui/AttachmentsDialog.h | 34 ++++++++++++++- 2 files changed, 88 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/AttachmentsDialog.cpp b/interface/src/ui/AttachmentsDialog.cpp index 319927c492..34c1f251e1 100644 --- a/interface/src/ui/AttachmentsDialog.cpp +++ b/interface/src/ui/AttachmentsDialog.cpp @@ -9,7 +9,11 @@ // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html // +#include #include +#include +#include +#include #include #include @@ -25,6 +29,10 @@ AttachmentsDialog::AttachmentsDialog() : QVBoxLayout* layout = new QVBoxLayout(); setLayout(layout); + foreach (const AttachmentData& data, Application::getInstance()->getAvatar()->getAttachmentData()) { + addAttachment(data); + } + QPushButton* newAttachment = new QPushButton("New Attachment"); connect(newAttachment, SIGNAL(clicked(bool)), SLOT(addAttachment())); layout->addWidget(newAttachment); @@ -34,6 +42,51 @@ AttachmentsDialog::AttachmentsDialog() : connect(buttons, SIGNAL(accepted()), SLOT(deleteLater())); } -void AttachmentsDialog::addAttachment() { - +void AttachmentsDialog::addAttachment(const AttachmentData& data) { + QVBoxLayout* layout = static_cast(this->layout()); + layout->insertWidget(layout->count() - 2, new AttachmentPanel(data)); +} + +AttachmentPanel::AttachmentPanel(const AttachmentData& data) { + QFormLayout* layout = new QFormLayout(); + setLayout(layout); + + QHBoxLayout* urlBox = new QHBoxLayout(); + layout->addRow("Model URL:", urlBox); + urlBox->addWidget(_modelURL = new QLineEdit(data.modelURL.toString()), 1); + QPushButton* chooseURL = new QPushButton("Choose"); + urlBox->addWidget(chooseURL); + connect(chooseURL, SIGNAL(clicked(bool)), SLOT(chooseModelURL())); + + layout->addRow("Joint:", _jointName = new QComboBox()); + + QHBoxLayout* translationBox = new QHBoxLayout(); + translationBox->addWidget(_translationX = new QDoubleSpinBox()); + translationBox->addWidget(_translationY = new QDoubleSpinBox()); + translationBox->addWidget(_translationZ = new QDoubleSpinBox()); + layout->addRow("Translation:", translationBox); + + QHBoxLayout* rotationBox = new QHBoxLayout(); + rotationBox->addWidget(_rotationX = new QDoubleSpinBox()); + rotationBox->addWidget(_rotationY = new QDoubleSpinBox()); + rotationBox->addWidget(_rotationZ = new QDoubleSpinBox()); + layout->addRow("Rotation:", rotationBox); + + layout->addRow("Scale:", _scale = new QDoubleSpinBox()); + _scale->setSingleStep(0.01); + _scale->setMaximum(FLT_MAX); + + QPushButton* remove = new QPushButton("Delete"); + layout->addRow(remove); + connect(remove, SIGNAL(clicked(bool)), SLOT(deleteLater())); +} + +void AttachmentPanel::chooseModelURL() { + ModelsBrowser modelBrowser(ATTACHMENT_MODEL, this); + connect(&modelBrowser, SIGNAL(selected(QString)), SLOT(setModelURL(const QString&))); + modelBrowser.browse(); +} + +void AttachmentPanel::setModelURL(const QString& url) { + _modelURL->setText(url); } diff --git a/interface/src/ui/AttachmentsDialog.h b/interface/src/ui/AttachmentsDialog.h index f6dc3d25b4..e8c173f80a 100644 --- a/interface/src/ui/AttachmentsDialog.h +++ b/interface/src/ui/AttachmentsDialog.h @@ -14,6 +14,12 @@ #include +#include + +class QComboBox; +class QDoubleSpinner; +class QLineEdit; + /// Allows users to edit the avatar attachments. class AttachmentsDialog : public QDialog { Q_OBJECT @@ -24,7 +30,33 @@ public: private slots: - void addAttachment(); + void addAttachment(const AttachmentData& data = AttachmentData()); +}; + +/// A panel controlling a single attachment. +class AttachmentPanel : public QWidget { + Q_OBJECT + +public: + + AttachmentPanel(const AttachmentData& data = AttachmentData()); + +private slots: + + void chooseModelURL(); + void setModelURL(const QString& url); + +private: + + QLineEdit* _modelURL; + QComboBox* _jointName; + QDoubleSpinBox* _translationX; + QDoubleSpinBox* _translationY; + QDoubleSpinBox* _translationZ; + QDoubleSpinBox* _rotationX; + QDoubleSpinBox* _rotationY; + QDoubleSpinBox* _rotationZ; + QDoubleSpinBox* _scale; }; #endif // hifi_AttachmentsDialog_h