mirror of
https://github.com/overte-org/overte.git
synced 2025-08-04 04:23:33 +02:00
Removing old attachment dialog, updating menu code
This commit is contained in:
parent
2956557c5f
commit
f53aaa1d64
7 changed files with 10 additions and 341 deletions
|
@ -8,6 +8,7 @@ import "attachments"
|
||||||
Window {
|
Window {
|
||||||
id: root
|
id: root
|
||||||
title: "Edit Attachments"
|
title: "Edit Attachments"
|
||||||
|
objectName: "AttachmentsDialog"
|
||||||
width: 600
|
width: 600
|
||||||
height: 600
|
height: 600
|
||||||
resizable: true
|
resizable: true
|
||||||
|
|
|
@ -1845,8 +1845,7 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
if (isShifted && isMeta) {
|
if (isShifted && isMeta) {
|
||||||
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
auto offscreenUi = DependencyManager::get<OffscreenUi>();
|
||||||
offscreenUi->getRootContext()->engine()->clearComponentCache();
|
offscreenUi->getRootContext()->engine()->clearComponentCache();
|
||||||
offscreenUi->load("hifi/dialogs/AttachmentsDialog.qml");
|
OffscreenUi::information("Debugging", "Component cache cleared");
|
||||||
// OffscreenUi::information("Debugging", "Component cache cleared");
|
|
||||||
// placeholder for dialogs being converted to QML.
|
// placeholder for dialogs being converted to QML.
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -70,8 +70,8 @@ Menu::Menu() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// File > Update -- FIXME: needs implementation
|
// File > Update -- FIXME: needs implementation
|
||||||
auto updateAction = addActionToQMenuAndActionHash(fileMenu, "Update");
|
auto action = addActionToQMenuAndActionHash(fileMenu, "Update");
|
||||||
updateAction->setDisabled(true);
|
action->setDisabled(true);
|
||||||
|
|
||||||
// File > Help
|
// File > Help
|
||||||
addActionToQMenuAndActionHash(fileMenu, MenuOption::Help, 0, qApp, SLOT(showHelp()));
|
addActionToQMenuAndActionHash(fileMenu, MenuOption::Help, 0, qApp, SLOT(showHelp()));
|
||||||
|
@ -166,8 +166,11 @@ Menu::Menu() {
|
||||||
QObject* avatar = avatarManager->getMyAvatar();
|
QObject* avatar = avatarManager->getMyAvatar();
|
||||||
|
|
||||||
// Avatar > Attachments...
|
// Avatar > Attachments...
|
||||||
addActionToQMenuAndActionHash(avatarMenu, MenuOption::Attachments, 0,
|
action = addActionToQMenuAndActionHash(avatarMenu, MenuOption::Attachments);
|
||||||
dialogsManager.data(), SLOT(editAttachments()));
|
connect(action, &QAction::triggered, [] {
|
||||||
|
DependencyManager::get<OffscreenUi>()->show(QString("hifi/dialogs/AttachmentsDialog.qml"), "AttachmentsDialog");
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// Avatar > Size
|
// Avatar > Size
|
||||||
MenuWrapper* avatarSizeMenu = avatarMenu->addMenu("Size");
|
MenuWrapper* avatarSizeMenu = avatarMenu->addMenu("Size");
|
||||||
|
@ -285,7 +288,7 @@ Menu::Menu() {
|
||||||
addCheckableActionToQMenuAndActionHash(settingsMenu, "Developer Menus", 0, false, this, SLOT(toggleDeveloperMenus()));
|
addCheckableActionToQMenuAndActionHash(settingsMenu, "Developer Menus", 0, false, this, SLOT(toggleDeveloperMenus()));
|
||||||
|
|
||||||
// Settings > General...
|
// Settings > General...
|
||||||
auto action = addActionToQMenuAndActionHash(settingsMenu, MenuOption::Preferences, Qt::CTRL | Qt::Key_Comma, nullptr, nullptr, QAction::PreferencesRole);
|
action = addActionToQMenuAndActionHash(settingsMenu, MenuOption::Preferences, Qt::CTRL | Qt::Key_Comma, nullptr, nullptr, QAction::PreferencesRole);
|
||||||
connect(action, &QAction::triggered, [] {
|
connect(action, &QAction::triggered, [] {
|
||||||
DependencyManager::get<OffscreenUi>()->toggle(QString("hifi/dialogs/GeneralPreferencesDialog.qml"), "GeneralPreferencesDialog");
|
DependencyManager::get<OffscreenUi>()->toggle(QString("hifi/dialogs/GeneralPreferencesDialog.qml"), "GeneralPreferencesDialog");
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,239 +0,0 @@
|
||||||
//
|
|
||||||
// AttachmentsDialog.cpp
|
|
||||||
// interface/src/ui
|
|
||||||
//
|
|
||||||
// Created by Andrzej Kapolka on 5/4/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 <QComboBox>
|
|
||||||
#include <QDialogButtonBox>
|
|
||||||
#include <QDoubleSpinBox>
|
|
||||||
#include <QFormLayout>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QScrollArea>
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
#include <QCheckBox>
|
|
||||||
|
|
||||||
#include <avatar/AvatarManager.h>
|
|
||||||
#include <avatar/MyAvatar.h>
|
|
||||||
#include <DependencyManager.h>
|
|
||||||
|
|
||||||
#include "AttachmentsDialog.h"
|
|
||||||
#include "ModelsBrowser.h"
|
|
||||||
|
|
||||||
AttachmentsDialog::AttachmentsDialog(QWidget* parent) :
|
|
||||||
QDialog(parent) {
|
|
||||||
|
|
||||||
setWindowTitle("Edit Attachments");
|
|
||||||
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(_attachments = new QVBoxLayout());
|
|
||||||
container->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Preferred);
|
|
||||||
area->setWidget(container);
|
|
||||||
_attachments->addStretch(1);
|
|
||||||
|
|
||||||
foreach (const AttachmentData& data, DependencyManager::get<AvatarManager>()->getMyAvatar()->getAttachmentData()) {
|
|
||||||
addAttachment(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
QPushButton* newAttachment = new QPushButton("New Attachment");
|
|
||||||
connect(newAttachment, SIGNAL(clicked(bool)), SLOT(addAttachment()));
|
|
||||||
layout->addWidget(newAttachment);
|
|
||||||
|
|
||||||
QDialogButtonBox* buttons = new QDialogButtonBox(QDialogButtonBox::Ok);
|
|
||||||
layout->addWidget(buttons);
|
|
||||||
connect(buttons, SIGNAL(accepted()), SLOT(deleteLater()));
|
|
||||||
_ok = buttons->button(QDialogButtonBox::Ok);
|
|
||||||
|
|
||||||
setMinimumSize(600, 600);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentsDialog::setVisible(bool visible) {
|
|
||||||
QDialog::setVisible(visible);
|
|
||||||
|
|
||||||
// un-default the OK button
|
|
||||||
if (visible) {
|
|
||||||
_ok->setDefault(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentsDialog::updateAttachmentData() {
|
|
||||||
QVector<AttachmentData> data;
|
|
||||||
for (int i = 0; i < _attachments->count() - 1; i++) {
|
|
||||||
data.append(static_cast<AttachmentPanel*>(_attachments->itemAt(i)->widget())->getAttachmentData());
|
|
||||||
}
|
|
||||||
DependencyManager::get<AvatarManager>()->getMyAvatar()->setAttachmentData(data);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentsDialog::addAttachment(const AttachmentData& data) {
|
|
||||||
_attachments->insertWidget(_attachments->count() - 1, new AttachmentPanel(this, data));
|
|
||||||
}
|
|
||||||
|
|
||||||
static QDoubleSpinBox* createTranslationBox(AttachmentPanel* panel, float value) {
|
|
||||||
QDoubleSpinBox* box = new QDoubleSpinBox();
|
|
||||||
box->setSingleStep(0.01);
|
|
||||||
box->setMinimum(-FLT_MAX);
|
|
||||||
box->setMaximum(FLT_MAX);
|
|
||||||
box->setValue(value);
|
|
||||||
panel->connect(box, SIGNAL(valueChanged(double)), SLOT(updateAttachmentData()));
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
static QDoubleSpinBox* createRotationBox(AttachmentPanel* panel, float value) {
|
|
||||||
QDoubleSpinBox* box = new QDoubleSpinBox();
|
|
||||||
box->setMinimum(-180.0);
|
|
||||||
box->setMaximum(180.0);
|
|
||||||
box->setWrapping(true);
|
|
||||||
box->setValue(value);
|
|
||||||
panel->connect(box, SIGNAL(valueChanged(double)), SLOT(updateAttachmentData()));
|
|
||||||
return box;
|
|
||||||
}
|
|
||||||
|
|
||||||
AttachmentPanel::AttachmentPanel(AttachmentsDialog* dialog, const AttachmentData& data) :
|
|
||||||
_dialog(dialog),
|
|
||||||
_applying(false) {
|
|
||||||
setFrameStyle(QFrame::StyledPanel);
|
|
||||||
|
|
||||||
QFormLayout* layout = new QFormLayout();
|
|
||||||
layout->setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
|
|
||||||
setLayout(layout);
|
|
||||||
|
|
||||||
QHBoxLayout* urlBox = new QHBoxLayout();
|
|
||||||
layout->addRow("Model URL:", urlBox);
|
|
||||||
urlBox->addWidget(_modelURL = new QLineEdit(data.modelURL.toString()), 1);
|
|
||||||
_modelURL->setText(data.modelURL.toString());
|
|
||||||
connect(_modelURL, SIGNAL(editingFinished()), SLOT(modelURLChanged()));
|
|
||||||
QPushButton* chooseURL = new QPushButton("Choose");
|
|
||||||
urlBox->addWidget(chooseURL);
|
|
||||||
connect(chooseURL, SIGNAL(clicked(bool)), SLOT(chooseModelURL()));
|
|
||||||
|
|
||||||
layout->addRow("Joint:", _jointName = new QComboBox());
|
|
||||||
QSharedPointer<NetworkGeometry> geometry = DependencyManager::get<AvatarManager>()->getMyAvatar()->getSkeletonModel().getGeometry();
|
|
||||||
if (geometry && geometry->isLoaded()) {
|
|
||||||
foreach (const FBXJoint& joint, geometry->getFBXGeometry().joints) {
|
|
||||||
_jointName->addItem(joint.name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_jointName->setCurrentText(data.jointName);
|
|
||||||
connect(_jointName, SIGNAL(currentIndexChanged(int)), SLOT(jointNameChanged()));
|
|
||||||
|
|
||||||
QHBoxLayout* translationBox = new QHBoxLayout();
|
|
||||||
translationBox->addWidget(_translationX = createTranslationBox(this, data.translation.x));
|
|
||||||
translationBox->addWidget(_translationY = createTranslationBox(this, data.translation.y));
|
|
||||||
translationBox->addWidget(_translationZ = createTranslationBox(this, data.translation.z));
|
|
||||||
layout->addRow("Translation:", translationBox);
|
|
||||||
|
|
||||||
QHBoxLayout* rotationBox = new QHBoxLayout();
|
|
||||||
glm::vec3 eulers = glm::degrees(safeEulerAngles(data.rotation));
|
|
||||||
rotationBox->addWidget(_rotationX = createRotationBox(this, eulers.x));
|
|
||||||
rotationBox->addWidget(_rotationY = createRotationBox(this, eulers.y));
|
|
||||||
rotationBox->addWidget(_rotationZ = createRotationBox(this, eulers.z));
|
|
||||||
layout->addRow("Rotation:", rotationBox);
|
|
||||||
|
|
||||||
layout->addRow("Scale:", _scale = new QDoubleSpinBox());
|
|
||||||
_scale->setSingleStep(0.01);
|
|
||||||
_scale->setMaximum(FLT_MAX);
|
|
||||||
_scale->setValue(data.scale);
|
|
||||||
connect(_scale, SIGNAL(valueChanged(double)), SLOT(updateAttachmentData()));
|
|
||||||
|
|
||||||
layout->addRow("Is Soft:", _isSoft = new QCheckBox());
|
|
||||||
_isSoft->setChecked(data.isSoft);
|
|
||||||
connect(_isSoft, SIGNAL(stateChanged(int)), SLOT(updateAttachmentData()));
|
|
||||||
|
|
||||||
QPushButton* remove = new QPushButton("Delete");
|
|
||||||
layout->addRow(remove);
|
|
||||||
connect(remove, SIGNAL(clicked(bool)), SLOT(deleteLater()));
|
|
||||||
dialog->connect(remove, SIGNAL(clicked(bool)), SLOT(updateAttachmentData()), Qt::QueuedConnection);
|
|
||||||
}
|
|
||||||
|
|
||||||
AttachmentData AttachmentPanel::getAttachmentData() const {
|
|
||||||
AttachmentData data;
|
|
||||||
data.modelURL = _modelURL->text();
|
|
||||||
data.jointName = _jointName->currentText();
|
|
||||||
data.translation = glm::vec3(_translationX->value(), _translationY->value(), _translationZ->value());
|
|
||||||
data.rotation = glm::quat(glm::radians(glm::vec3(_rotationX->value(), _rotationY->value(), _rotationZ->value())));
|
|
||||||
data.scale = _scale->value();
|
|
||||||
data.isSoft = _isSoft->isChecked();
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentPanel::chooseModelURL() {
|
|
||||||
ModelsBrowser modelBrowser(FSTReader::ATTACHMENT_MODEL, this);
|
|
||||||
connect(&modelBrowser, SIGNAL(selected(QString)), SLOT(setModelURL(const QString&)));
|
|
||||||
modelBrowser.browse();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentPanel::setModelURL(const QString& url) {
|
|
||||||
_modelURL->setText(url);
|
|
||||||
modelURLChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentPanel::modelURLChanged() {
|
|
||||||
// check for saved attachment data
|
|
||||||
if (_modelURL->text().isEmpty()) {
|
|
||||||
_dialog->updateAttachmentData();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AttachmentData attachment = DependencyManager::get<AvatarManager>()->getMyAvatar()->loadAttachmentData(_modelURL->text());
|
|
||||||
if (attachment.isValid()) {
|
|
||||||
_applying = true;
|
|
||||||
_jointName->setCurrentText(attachment.jointName);
|
|
||||||
applyAttachmentData(attachment);
|
|
||||||
}
|
|
||||||
_dialog->updateAttachmentData();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentPanel::jointNameChanged() {
|
|
||||||
if (_applying) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// check for saved attachment data specific to this joint
|
|
||||||
if (_modelURL->text().isEmpty()) {
|
|
||||||
_dialog->updateAttachmentData();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
AttachmentData attachment = DependencyManager::get<AvatarManager>()->getMyAvatar()->loadAttachmentData(
|
|
||||||
_modelURL->text(), _jointName->currentText());
|
|
||||||
if (attachment.isValid()) {
|
|
||||||
applyAttachmentData(attachment);
|
|
||||||
}
|
|
||||||
updateAttachmentData();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentPanel::updateAttachmentData() {
|
|
||||||
if (_applying) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// save the attachment data under the model URL (if any)
|
|
||||||
if (!_modelURL->text().isEmpty()) {
|
|
||||||
DependencyManager::get<AvatarManager>()->getMyAvatar()->saveAttachmentData(getAttachmentData());
|
|
||||||
}
|
|
||||||
_dialog->updateAttachmentData();
|
|
||||||
}
|
|
||||||
|
|
||||||
void AttachmentPanel::applyAttachmentData(const AttachmentData& attachment) {
|
|
||||||
_applying = true;
|
|
||||||
_translationX->setValue(attachment.translation.x);
|
|
||||||
_translationY->setValue(attachment.translation.y);
|
|
||||||
_translationZ->setValue(attachment.translation.z);
|
|
||||||
glm::vec3 eulers = glm::degrees(safeEulerAngles(attachment.rotation));
|
|
||||||
_rotationX->setValue(eulers.x);
|
|
||||||
_rotationY->setValue(eulers.y);
|
|
||||||
_rotationZ->setValue(eulers.z);
|
|
||||||
_scale->setValue(attachment.scale);
|
|
||||||
_isSoft->setChecked(attachment.isSoft);
|
|
||||||
_applying = false;
|
|
||||||
_dialog->updateAttachmentData();
|
|
||||||
}
|
|
|
@ -1,84 +0,0 @@
|
||||||
//
|
|
||||||
// AttachmentsDialog.h
|
|
||||||
// interface/src/ui
|
|
||||||
//
|
|
||||||
// Created by Andrzej Kapolka on 5/4/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_AttachmentsDialog_h
|
|
||||||
#define hifi_AttachmentsDialog_h
|
|
||||||
|
|
||||||
#include <QDialog>
|
|
||||||
#include <QFrame>
|
|
||||||
|
|
||||||
#include <AvatarData.h>
|
|
||||||
|
|
||||||
class QComboBox;
|
|
||||||
class QDoubleSpinner;
|
|
||||||
class QLineEdit;
|
|
||||||
class QVBoxLayout;
|
|
||||||
|
|
||||||
/// Allows users to edit the avatar attachments.
|
|
||||||
class AttachmentsDialog : public QDialog {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
AttachmentsDialog(QWidget* parent = nullptr);
|
|
||||||
|
|
||||||
virtual void setVisible(bool visible);
|
|
||||||
|
|
||||||
public slots:
|
|
||||||
|
|
||||||
void updateAttachmentData();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void addAttachment(const AttachmentData& data = AttachmentData());
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
QVBoxLayout* _attachments;
|
|
||||||
QPushButton* _ok;
|
|
||||||
};
|
|
||||||
|
|
||||||
/// A panel controlling a single attachment.
|
|
||||||
class AttachmentPanel : public QFrame {
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
AttachmentPanel(AttachmentsDialog* dialog, const AttachmentData& data = AttachmentData());
|
|
||||||
|
|
||||||
AttachmentData getAttachmentData() const;
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
|
|
||||||
void chooseModelURL();
|
|
||||||
void setModelURL(const QString& url);
|
|
||||||
void modelURLChanged();
|
|
||||||
void jointNameChanged();
|
|
||||||
void updateAttachmentData();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
void applyAttachmentData(const AttachmentData& attachment);
|
|
||||||
|
|
||||||
AttachmentsDialog* _dialog;
|
|
||||||
QLineEdit* _modelURL;
|
|
||||||
QComboBox* _jointName;
|
|
||||||
QDoubleSpinBox* _translationX;
|
|
||||||
QDoubleSpinBox* _translationY;
|
|
||||||
QDoubleSpinBox* _translationZ;
|
|
||||||
QDoubleSpinBox* _rotationX;
|
|
||||||
QDoubleSpinBox* _rotationY;
|
|
||||||
QDoubleSpinBox* _rotationZ;
|
|
||||||
QDoubleSpinBox* _scale;
|
|
||||||
QCheckBox* _isSoft;
|
|
||||||
bool _applying;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // hifi_AttachmentsDialog_h
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <PathUtils.h>
|
#include <PathUtils.h>
|
||||||
|
|
||||||
#include "AddressBarDialog.h"
|
#include "AddressBarDialog.h"
|
||||||
#include "AttachmentsDialog.h"
|
|
||||||
#include "BandwidthDialog.h"
|
#include "BandwidthDialog.h"
|
||||||
#include "CachesSizeDialog.h"
|
#include "CachesSizeDialog.h"
|
||||||
#include "DiskCacheEditor.h"
|
#include "DiskCacheEditor.h"
|
||||||
|
@ -91,15 +90,6 @@ void DialogsManager::cachesSizeDialog() {
|
||||||
_cachesSizeDialog->raise();
|
_cachesSizeDialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DialogsManager::editAttachments() {
|
|
||||||
if (!_attachmentsDialog) {
|
|
||||||
maybeCreateDialog(_attachmentsDialog);
|
|
||||||
_attachmentsDialog->show();
|
|
||||||
} else {
|
|
||||||
_attachmentsDialog->close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void DialogsManager::audioStatsDetails() {
|
void DialogsManager::audioStatsDetails() {
|
||||||
if (! _audioStatsDialog) {
|
if (! _audioStatsDialog) {
|
||||||
_audioStatsDialog = new AudioStatsDialog(qApp->getWindow());
|
_audioStatsDialog = new AudioStatsDialog(qApp->getWindow());
|
||||||
|
|
|
@ -48,7 +48,6 @@ public slots:
|
||||||
void showLoginDialog();
|
void showLoginDialog();
|
||||||
void octreeStatsDetails();
|
void octreeStatsDetails();
|
||||||
void cachesSizeDialog();
|
void cachesSizeDialog();
|
||||||
void editAttachments();
|
|
||||||
void audioStatsDetails();
|
void audioStatsDetails();
|
||||||
void bandwidthDetails();
|
void bandwidthDetails();
|
||||||
void lodTools();
|
void lodTools();
|
||||||
|
|
Loading…
Reference in a new issue