2018-09-21 07:10:18 +00:00
|
|
|
#include <QHBoxLayout>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QPushButton>
|
|
|
|
#include "posemanagewidget.h"
|
|
|
|
#include "theme.h"
|
|
|
|
#include "poseeditwidget.h"
|
2018-10-02 04:59:30 +00:00
|
|
|
#include "infolabel.h"
|
2018-09-21 07:10:18 +00:00
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
PoseManageWidget::PoseManageWidget(const Document *document, QWidget *parent) :
|
2018-09-21 07:10:18 +00:00
|
|
|
QWidget(parent),
|
|
|
|
m_document(document)
|
|
|
|
{
|
|
|
|
QPushButton *addPoseButton = new QPushButton(Theme::awesome()->icon(fa::plus), tr("Add Pose..."));
|
2018-10-02 04:59:30 +00:00
|
|
|
addPoseButton->hide();
|
2018-09-21 07:10:18 +00:00
|
|
|
connect(addPoseButton, &QPushButton::clicked, this, &PoseManageWidget::showAddPoseDialog);
|
2019-06-06 14:18:48 +00:00
|
|
|
|
2018-09-21 07:10:18 +00:00
|
|
|
QHBoxLayout *toolsLayout = new QHBoxLayout;
|
|
|
|
toolsLayout->addWidget(addPoseButton);
|
|
|
|
|
|
|
|
m_poseListWidget = new PoseListWidget(document);
|
|
|
|
connect(m_poseListWidget, &PoseListWidget::modifyPose, this, &PoseManageWidget::showPoseDialog);
|
|
|
|
|
2018-10-02 04:59:30 +00:00
|
|
|
InfoLabel *infoLabel = new InfoLabel;
|
2018-11-09 03:20:48 +00:00
|
|
|
infoLabel->hide();
|
2018-10-02 04:59:30 +00:00
|
|
|
|
2018-10-21 23:56:56 +00:00
|
|
|
auto refreshInfoLabel = [=]() {
|
2018-10-02 04:59:30 +00:00
|
|
|
if (m_document->currentRigSucceed()) {
|
2018-11-06 16:26:19 +00:00
|
|
|
if (m_document->rigType == RigType::Animal) {
|
2018-11-05 15:47:21 +00:00
|
|
|
infoLabel->setText("");
|
|
|
|
infoLabel->hide();
|
|
|
|
addPoseButton->show();
|
|
|
|
} else {
|
|
|
|
infoLabel->setText(tr("Pose editor doesn't support this rig type yet: ") + RigTypeToDispName(m_document->rigType));
|
|
|
|
infoLabel->show();
|
|
|
|
addPoseButton->hide();
|
|
|
|
}
|
2018-10-02 04:59:30 +00:00
|
|
|
} else {
|
2018-11-05 15:47:21 +00:00
|
|
|
infoLabel->setText(tr("Missing Rig"));
|
2018-10-02 04:59:30 +00:00
|
|
|
infoLabel->show();
|
|
|
|
addPoseButton->hide();
|
|
|
|
}
|
2018-10-21 23:56:56 +00:00
|
|
|
};
|
|
|
|
|
2018-10-25 00:19:38 +00:00
|
|
|
connect(m_document, &Document::resultRigChanged, this, refreshInfoLabel);
|
|
|
|
connect(m_document, &Document::cleanup, this, refreshInfoLabel);
|
2018-10-02 04:59:30 +00:00
|
|
|
|
2018-09-21 07:10:18 +00:00
|
|
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
2018-10-02 04:59:30 +00:00
|
|
|
mainLayout->addWidget(infoLabel);
|
2018-09-21 07:10:18 +00:00
|
|
|
mainLayout->addLayout(toolsLayout);
|
|
|
|
mainLayout->addWidget(m_poseListWidget);
|
|
|
|
|
|
|
|
setLayout(mainLayout);
|
|
|
|
}
|
|
|
|
|
|
|
|
PoseListWidget *PoseManageWidget::poseListWidget()
|
|
|
|
{
|
|
|
|
return m_poseListWidget;
|
|
|
|
}
|
|
|
|
|
|
|
|
QSize PoseManageWidget::sizeHint() const
|
|
|
|
{
|
|
|
|
return QSize(Theme::sidebarPreferredWidth, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void PoseManageWidget::showAddPoseDialog()
|
|
|
|
{
|
|
|
|
showPoseDialog(QUuid());
|
|
|
|
}
|
|
|
|
|
|
|
|
void PoseManageWidget::showPoseDialog(QUuid poseId)
|
|
|
|
{
|
|
|
|
PoseEditWidget *poseEditWidget = new PoseEditWidget(m_document);
|
|
|
|
poseEditWidget->setAttribute(Qt::WA_DeleteOnClose);
|
|
|
|
if (!poseId.isNull()) {
|
2018-10-25 00:19:38 +00:00
|
|
|
const Pose *pose = m_document->findPose(poseId);
|
2018-09-21 07:10:18 +00:00
|
|
|
if (nullptr != pose) {
|
|
|
|
poseEditWidget->setEditPoseId(poseId);
|
|
|
|
poseEditWidget->setEditPoseName(pose->name);
|
2018-11-09 03:20:48 +00:00
|
|
|
poseEditWidget->setEditPoseFrames(pose->frames);
|
|
|
|
poseEditWidget->setEditPoseTurnaroundImageId(pose->turnaroundImageId);
|
2019-06-19 12:57:38 +00:00
|
|
|
poseEditWidget->setEditPoseYtranslationScale(pose->yTranslationScale);
|
2018-09-21 07:10:18 +00:00
|
|
|
poseEditWidget->clearUnsaveState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
poseEditWidget->show();
|
|
|
|
connect(poseEditWidget, &QDialog::destroyed, [=]() {
|
|
|
|
emit unregisterDialog((QWidget *)poseEditWidget);
|
|
|
|
});
|
|
|
|
emit registerDialog((QWidget *)poseEditWidget);
|
|
|
|
}
|