From cce967df944300130b69f9ab6e2aa40a9c5c49d9 Mon Sep 17 00:00:00 2001 From: "Anthony J. Thibault" Date: Wed, 11 Nov 2015 12:14:56 -0800 Subject: [PATCH] Removed AnimationsDialog --- interface/src/Menu.cpp | 2 - interface/src/ui/AnimationsDialog.cpp | 210 -------------------------- interface/src/ui/AnimationsDialog.h | 87 ----------- interface/src/ui/DialogsManager.cpp | 10 -- interface/src/ui/DialogsManager.h | 1 - 5 files changed, 310 deletions(-) delete mode 100644 interface/src/ui/AnimationsDialog.cpp delete mode 100644 interface/src/ui/AnimationsDialog.h diff --git a/interface/src/Menu.cpp b/interface/src/Menu.cpp index 24033325f6..a8af92bafe 100644 --- a/interface/src/Menu.cpp +++ b/interface/src/Menu.cpp @@ -145,8 +145,6 @@ Menu::Menu() { addActionToQMenuAndActionHash(editMenu, MenuOption::Attachments, 0, dialogsManager.data(), SLOT(editAttachments())); - addActionToQMenuAndActionHash(editMenu, MenuOption::Animations, 0, - dialogsManager.data(), SLOT(editAnimations())); MenuWrapper* toolsMenu = addMenu("Tools"); addActionToQMenuAndActionHash(toolsMenu, MenuOption::ScriptEditor, Qt::ALT | Qt::Key_S, diff --git a/interface/src/ui/AnimationsDialog.cpp b/interface/src/ui/AnimationsDialog.cpp deleted file mode 100644 index 5960ffc1fa..0000000000 --- a/interface/src/ui/AnimationsDialog.cpp +++ /dev/null @@ -1,210 +0,0 @@ -// -// AnimationsDialog.cpp -// interface/src/ui -// -// Created by Andrzej Kapolka on 5/19/14. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "avatar/AvatarManager.h" - -#include "AnimationsDialog.h" - -AnimationsDialog::AnimationsDialog(QWidget* parent) : - QDialog(parent) -{ - setWindowTitle("Edit Animations"); - setAttribute(Qt::WA_DeleteOnClose); - - QVBoxLayout* layout = new QVBoxLayout(); - setLayout(layout); - - QScrollArea* area = new QScrollArea(); - layout->addWidget(area); - area->setWidgetResizable(true); - QWidget* container = new QWidget(); - container->setLayout(_animations = new QVBoxLayout()); - container->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred); - area->setWidget(container); - _animations->addStretch(1); - - MyAvatar* myAvatar = DependencyManager::get()->getMyAvatar(); - foreach (const AnimationHandlePointer& handle, myAvatar->getAnimationHandles()) { - _animations->insertWidget(_animations->count() - 1, new AnimationPanel(this, handle)); - } - - QPushButton* newAnimation = new QPushButton("New Animation"); - connect(newAnimation, SIGNAL(clicked(bool)), SLOT(addAnimation())); - layout->addWidget(newAnimation); - - QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok); - layout->addWidget(buttons); - connect(buttons, SIGNAL(accepted()), SLOT(deleteLater())); - _ok = buttons->button(QDialogButtonBox::Ok); - - setMinimumSize(600, 600); -} - -void AnimationsDialog::setVisible(bool visible) { - QDialog::setVisible(visible); - - // un-default the OK button - if (visible) { - _ok->setDefault(false); - } -} - -void AnimationsDialog::addAnimation() { - _animations->insertWidget(_animations->count() - 1, new AnimationPanel(this, - DependencyManager::get()->getMyAvatar()->addAnimationHandle())); -} - -Setting::Handle AnimationPanel::_animationDirectory("animation_directory", QString()); - -AnimationPanel::AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePointer& handle) : - _dialog(dialog), - _handle(handle), - _applying(false) { - setFrameStyle(QFrame::StyledPanel); - - QFormLayout* layout = new QFormLayout(); - layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow); - setLayout(layout); - - layout->addRow("Role:", _role = new QComboBox()); - _role->addItem("idle"); - _role->addItem("sit"); - _role->setEditable(true); - _role->setCurrentText(handle->getRole()); - connect(_role, SIGNAL(currentTextChanged(const QString&)), SLOT(updateHandle())); - - QHBoxLayout* urlBox = new QHBoxLayout(); - layout->addRow("URL:", urlBox); - urlBox->addWidget(_url = new QLineEdit(handle->getURL().toString()), 1); - connect(_url, SIGNAL(editingFinished()), SLOT(updateHandle())); - QPushButton* chooseURL = new QPushButton("Choose"); - urlBox->addWidget(chooseURL); - connect(chooseURL, SIGNAL(clicked(bool)), SLOT(chooseURL())); - - layout->addRow("FPS:", _fps = new QDoubleSpinBox()); - _fps->setSingleStep(0.01); - _fps->setMinimum(-FLT_MAX); - _fps->setMaximum(FLT_MAX); - _fps->setValue(handle->getFPS()); - connect(_fps, SIGNAL(valueChanged(double)), SLOT(updateHandle())); - - layout->addRow("Priority:", _priority = new QDoubleSpinBox()); - _priority->setSingleStep(0.01); - _priority->setMinimum(-FLT_MAX); - _priority->setMaximum(FLT_MAX); - _priority->setValue(handle->getPriority()); - connect(_priority, SIGNAL(valueChanged(double)), SLOT(updateHandle())); - - QHBoxLayout* maskedJointBox = new QHBoxLayout(); - layout->addRow("Masked Joints:", maskedJointBox); - maskedJointBox->addWidget(_maskedJoints = new QLineEdit(handle->getMaskedJoints().join(", ")), 1); - connect(_maskedJoints, SIGNAL(editingFinished()), SLOT(updateHandle())); - maskedJointBox->addWidget(_chooseMaskedJoints = new QPushButton("Choose")); - connect(_chooseMaskedJoints, SIGNAL(clicked(bool)), SLOT(chooseMaskedJoints())); - - layout->addRow("Loop:", _loop = new QCheckBox()); - _loop->setChecked(handle->getLoop()); - connect(_loop, SIGNAL(toggled(bool)), SLOT(updateHandle())); - - layout->addRow("Hold:", _hold = new QCheckBox()); - _hold->setChecked(handle->getHold()); - connect(_hold, SIGNAL(toggled(bool)), SLOT(updateHandle())); - - layout->addRow("Start Automatically:", _startAutomatically = new QCheckBox()); - _startAutomatically->setChecked(handle->getStartAutomatically()); - connect(_startAutomatically, SIGNAL(toggled(bool)), SLOT(updateHandle())); - - layout->addRow("First Frame:", _firstFrame = new QDoubleSpinBox()); - _firstFrame->setSingleStep(0.01); - _firstFrame->setMaximum(INT_MAX); - _firstFrame->setValue(handle->getFirstFrame()); - connect(_firstFrame, SIGNAL(valueChanged(double)), SLOT(updateHandle())); - - layout->addRow("Last Frame:", _lastFrame = new QDoubleSpinBox()); - _lastFrame->setSingleStep(0.01); - _lastFrame->setMaximum(INT_MAX); - _lastFrame->setValue(handle->getLastFrame()); - connect(_lastFrame, SIGNAL(valueChanged(double)), SLOT(updateHandle())); - - QHBoxLayout* buttons = new QHBoxLayout(); - layout->addRow(buttons); - buttons->addWidget(_start = new QPushButton("Start")); - _handle->connect(_start, SIGNAL(clicked(bool)), SLOT(start())); - buttons->addWidget(_stop = new QPushButton("Stop")); - _handle->connect(_stop, SIGNAL(clicked(bool)), SLOT(stop())); - QPushButton* remove = new QPushButton("Delete"); - buttons->addWidget(remove); - connect(remove, SIGNAL(clicked(bool)), SLOT(removeHandle())); - - _stop->connect(_handle.get(), SIGNAL(runningChanged(bool)), SLOT(setEnabled(bool))); - _stop->setEnabled(_handle->isRunning()); -} - -void AnimationPanel::chooseURL() { - QString filename = QFileDialog::getOpenFileName(this, "Choose Animation", - _animationDirectory.get(), "Animation files (*.fbx)"); - if (filename.isEmpty()) { - return; - } - _animationDirectory.set(QFileInfo(filename).path()); - _url->setText(QUrl::fromLocalFile(filename).toString()); - emit _url->editingFinished(); -} - -void AnimationPanel::chooseMaskedJoints() { - QMenu menu; - QStringList maskedJoints = _handle->getMaskedJoints(); - foreach (const QString& jointName, DependencyManager::get()->getMyAvatar()->getJointNames()) { - QAction* action = menu.addAction(jointName); - action->setCheckable(true); - action->setChecked(maskedJoints.contains(jointName)); - } - QAction* action = menu.exec(_chooseMaskedJoints->mapToGlobal(QPoint(0, 0))); - if (action) { - if (action->isChecked()) { - maskedJoints.append(action->text()); - } else { - maskedJoints.removeOne(action->text()); - } - _handle->setMaskedJoints(maskedJoints); - _maskedJoints->setText(maskedJoints.join(", ")); - } -} - -void AnimationPanel::updateHandle() { - _handle->setRole(_role->currentText()); - _handle->setURL(_url->text()); - _handle->setFPS(_fps->value()); - _handle->setPriority(_priority->value()); - _handle->setLoop(_loop->isChecked()); - _handle->setHold(_hold->isChecked()); - _handle->setStartAutomatically(_startAutomatically->isChecked()); - _handle->setFirstFrame(_firstFrame->value()); - _handle->setLastFrame(_lastFrame->value()); - _handle->setMaskedJoints(_maskedJoints->text().split(QRegExp("\\s*,\\s*"))); -} - -void AnimationPanel::removeHandle() { - DependencyManager::get()->getMyAvatar()->removeAnimationHandle(_handle); - deleteLater(); -} diff --git a/interface/src/ui/AnimationsDialog.h b/interface/src/ui/AnimationsDialog.h deleted file mode 100644 index ace13b6859..0000000000 --- a/interface/src/ui/AnimationsDialog.h +++ /dev/null @@ -1,87 +0,0 @@ -// -// AnimationsDialog.h -// interface/src/ui -// -// Created by Andrzej Kapolka on 5/19/14. -// Copyright 2014 High Fidelity, Inc. -// -// Distributed under the Apache License, Version 2.0. -// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html -// - -#ifndef hifi_AnimationsDialog_h -#define hifi_AnimationsDialog_h - -#include -#include -#include - -#include - -#include "avatar/MyAvatar.h" - -class QCheckBox; -class QComboBox; -class QDoubleSpinner; -class QLineEdit; -class QPushButton; -class QVBoxLayout; - -/// Allows users to edit the avatar animations. -class AnimationsDialog : public QDialog { - Q_OBJECT - -public: - - AnimationsDialog(QWidget* parent = nullptr); - - virtual void setVisible(bool visible); - -private slots: - - void addAnimation(); - -private: - - QVBoxLayout* _animations = nullptr; - QPushButton* _ok = nullptr; -}; - -/// A panel controlling a single animation. -class AnimationPanel : public QFrame { - Q_OBJECT - -public: - - AnimationPanel(AnimationsDialog* dialog, const AnimationHandlePointer& handle); - -private slots: - - void chooseURL(); - void chooseMaskedJoints(); - void updateHandle(); - void removeHandle(); - -private: - - AnimationsDialog* _dialog = nullptr; - AnimationHandlePointer _handle; - QComboBox* _role = nullptr; - QLineEdit* _url = nullptr; - QDoubleSpinBox* _fps = nullptr; - QDoubleSpinBox* _priority = nullptr; - QCheckBox* _loop = nullptr; - QCheckBox* _hold = nullptr; - QCheckBox* _startAutomatically = nullptr; - QDoubleSpinBox* _firstFrame = nullptr; - QDoubleSpinBox* _lastFrame = nullptr; - QLineEdit* _maskedJoints = nullptr; - QPushButton* _chooseMaskedJoints = nullptr; - QPushButton* _start = nullptr; - QPushButton* _stop = nullptr; - bool _applying; - - static Setting::Handle _animationDirectory; -}; - -#endif // hifi_AnimationsDialog_h diff --git a/interface/src/ui/DialogsManager.cpp b/interface/src/ui/DialogsManager.cpp index 00bc95b5fa..1acbf3a595 100644 --- a/interface/src/ui/DialogsManager.cpp +++ b/interface/src/ui/DialogsManager.cpp @@ -19,7 +19,6 @@ #include #include "AddressBarDialog.h" -#include "AnimationsDialog.h" #include "AttachmentsDialog.h" #include "BandwidthDialog.h" #include "CachesSizeDialog.h" @@ -110,15 +109,6 @@ void DialogsManager::editAttachments() { } } -void DialogsManager::editAnimations() { - if (!_animationsDialog) { - maybeCreateDialog(_animationsDialog); - _animationsDialog->show(); - } else { - _animationsDialog->close(); - } -} - void DialogsManager::audioStatsDetails() { if (! _audioStatsDialog) { _audioStatsDialog = new AudioStatsDialog(qApp->getWindow()); diff --git a/interface/src/ui/DialogsManager.h b/interface/src/ui/DialogsManager.h index 133fe459d0..f6ad1d6f98 100644 --- a/interface/src/ui/DialogsManager.h +++ b/interface/src/ui/DialogsManager.h @@ -52,7 +52,6 @@ public slots: void cachesSizeDialog(); void editPreferences(); void editAttachments(); - void editAnimations(); void audioStatsDetails(); void bandwidthDetails(); void lodTools();