diff options
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp')
-rw-r--r-- | src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp | 92 |
1 files changed, 91 insertions, 1 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp index b6037011..5b2a69d9 100644 --- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp +++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp @@ -57,6 +57,13 @@ #include "ProjectFile.h" #include "MaterialRefView.h" #include "BasicObjectsModel.h" +#include "Qt3DSDMSlides.h" +#include "VariantsGroupModel.h" +#include "VariantTagDialog.h" +#include "Views.h" +#include "MainFrm.h" +#include "SlideView.h" +#include "TimelineWidget.h" #include <QtCore/qtimer.h> #include <QtQml/qqmlcontext.h> @@ -68,7 +75,8 @@ InspectorControlView::InspectorControlView(const QSize &preferredSize, QWidget *parent) : QQuickWidget(parent), TabNavigable(), - m_inspectorControlModel(new InspectorControlModel(this)), + m_variantsGroupModel(new VariantsGroupModel(this)), + m_inspectorControlModel(new InspectorControlModel(m_variantsGroupModel, this)), m_meshChooserView(new MeshChooserView(this)), m_instance(0), m_handle(0), @@ -235,6 +243,7 @@ void InspectorControlView::initialize() CStudioPreferences::setQmlContextProperties(rootContext()); rootContext()->setContextProperty(QStringLiteral("_parentView"), this); rootContext()->setContextProperty(QStringLiteral("_inspectorModel"), m_inspectorControlModel); + rootContext()->setContextProperty(QStringLiteral("_variantsGroupModel"), m_variantsGroupModel); rootContext()->setContextProperty(QStringLiteral("_resDir"), StudioUtils::resourceImageUrl()); rootContext()->setContextProperty(QStringLiteral("_tabOrderHandler"), tabOrderHandler()); rootContext()->setContextProperty(QStringLiteral("_mouseHelper"), &m_mouseHelper); @@ -288,6 +297,8 @@ bool InspectorControlView::canLinkProperty(int instance, int handle) const && (type & (OBJTYPE_CUSTOMMATERIAL | OBJTYPE_MATERIAL | OBJTYPE_REFERENCEDMATERIAL))) { return false; } + if (doc->GetStudioSystem()->GetPropertySystem()->GetName(handle) == QStringLiteral("eyeball")) + return false; return doc->GetDocumentReader().CanPropertyBeLinked(instance, handle); } @@ -372,6 +383,17 @@ QString InspectorControlView::titleIcon() const return {}; } +bool InspectorControlView::isEditable(int handle) const +{ + CDoc *doc = g_StudioApp.GetCore()->GetDoc(); + if (doc->GetStudioSystem()->GetSlideSystem()->IsMasterSlide(doc->GetActiveSlide()) + && doc->GetStudioSystem()->GetPropertySystem()->GetName(handle) + == QStringLiteral("eyeball")) { + return false; + } + return true; +} + void InspectorControlView::OnSelectionSet(Q3DStudio::SSelectedValue inSelectable) { updateInspectable(g_StudioApp.GetInspectableFromSelectable(inSelectable)); @@ -394,6 +416,8 @@ void InspectorControlView::setInspectable(CInspectableBase *inInspectable) m_inspectorControlModel->setInspectable(inInspectable); Q_EMIT titleChanged(); + + m_variantsGroupModel->refresh(); } } @@ -434,6 +458,72 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc m_handle = 0; } +// context menu for the variants tags +void InspectorControlView::showTagContextMenu(int x, int y, const QString &group, + const QString &tag) +{ + QMenu theContextMenu; + + auto actionRename = theContextMenu.addAction(QObject::tr("Rename Tag")); + connect(actionRename, &QAction::triggered, this, [&]() { + VariantTagDialog dlg(VariantTagDialog::RenameTag, group, tag); + if (dlg.exec() == QDialog::Accepted) { + g_StudioApp.GetCore()->getProjectFile().renameVariantTag(group, dlg.getNames().first, + dlg.getNames().second); + m_variantsGroupModel->refresh(); + } + }); + + auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Tag")); + connect(actionDelete, &QAction::triggered, this, [&]() { + g_StudioApp.GetCore()->getProjectFile().deleteVariantTag(group, tag); + g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants(); + g_StudioApp.GetViews()->getMainFrame()->getSlideView()->refreshVariants(); + m_variantsGroupModel->refresh(); + }); + + theContextMenu.exec(mapToGlobal({x, y})); +} + +// context menu for the variants groups +void InspectorControlView::showGroupContextMenu(int x, int y, const QString &group) +{ + QMenu theContextMenu; + + ProjectFile &projectFile = g_StudioApp.GetCore()->getProjectFile(); + + auto actionRename = theContextMenu.addAction(QObject::tr("Rename Group")); + connect(actionRename, &QAction::triggered, this, [&]() { + VariantTagDialog dlg(VariantTagDialog::RenameGroup, {}, group); + if (dlg.exec() == QDialog::Accepted) { + projectFile.renameVariantGroup(dlg.getNames().first, dlg.getNames().second); + g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants(); + m_variantsGroupModel->refresh(); + } + }); + + auto actionColor = theContextMenu.addAction(QObject::tr("Change Group Color")); + connect(actionColor, &QAction::triggered, this, [&]() { + const auto variantsDef = g_StudioApp.GetCore()->getProjectFile().variantsDef(); + QColor newColor = this->showColorDialog(variantsDef[group].m_color); + projectFile.changeVariantGroupColor(group, newColor.name()); + // no need to refresh variants in the timeline widget as it references the group color in + // the project file m_variants, and a redraw is triggered upon color selection dialog close. + g_StudioApp.GetViews()->getMainFrame()->getSlideView()->refreshVariants(); + m_variantsGroupModel->refresh(); + }); + + auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Group")); + connect(actionDelete, &QAction::triggered, this, [&]() { + projectFile.deleteVariantGroup(group); + g_StudioApp.GetViews()->getMainFrame()->getTimelineWidget()->refreshVariants(); + g_StudioApp.GetViews()->getMainFrame()->getSlideView()->refreshVariants(); + m_variantsGroupModel->refresh(); + }); + + theContextMenu.exec(mapToGlobal({x, y})); +} + void InspectorControlView::toggleMasterLink() { Q3DStudio::ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(), |