summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
diff options
context:
space:
mode:
authorMahmoud Badri <mahmoud.badri@qt.io>2019-02-11 10:06:28 +0200
committerMahmoud Badri <mahmoud.badri@qt.io>2019-02-11 19:40:36 +0000
commit5884818826458539e9e959947051bd845d6acce4 (patch)
treee41e15fd8ad9ce59bc7ed5dd10c870f130fd7157 /src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
parent89390421091d40b4dd8f34c5419257b3418ab57f (diff)
Implement variants tags inspector work
Implemented features: - UI for the variants tags in the inspector. - adding, renaming, and deleting tags. - adding, renaming, and deleting tag groups. - adding, renaming tags/groups is checked for name uniqueness across project. - deleting tags/groups checked for in-use across the project. - toggling tags state. - tags are synced with the UIA/UIP. - changing group color. - the variants property in saved in the <Graph> part of the UIP. Remaining tasks: - implement import and export. - issue: renaming a selected tag, toggle it unselected till next project load. - issue: update the property after deleting a group that is in-use in the property in the currently open doc but not saved. - thorough test and tweaking. Task-no: QT3DS-2983 Change-Id: Iecbb6c854a00ec75864de5dd0f31f6ca3721c8ec Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp')
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp64
1 files changed, 63 insertions, 1 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
index 69543a12..6252c0ea 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlView.cpp
@@ -58,6 +58,8 @@
#include "MaterialRefView.h"
#include "BasicObjectsModel.h"
#include "Qt3DSDMSlides.h"
+#include "VariantsGroupModel.h"
+#include "VariantTagDialog.h"
#include <QtCore/qtimer.h>
#include <QtQml/qqmlcontext.h>
@@ -69,7 +71,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),
@@ -241,6 +244,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);
@@ -412,6 +416,8 @@ void InspectorControlView::setInspectable(CInspectableBase *inInspectable)
m_inspectorControlModel->setInspectable(inInspectable);
Q_EMIT titleChanged();
+
+ m_variantsGroupModel->refresh();
}
}
@@ -452,6 +458,62 @@ void InspectorControlView::showContextMenu(int x, int y, int handle, int instanc
m_handle = 0;
}
+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);
+ }
+ });
+
+ auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Tag"));
+ connect(actionDelete, &QAction::triggered, this, [&]() {
+ g_StudioApp.GetCore()->getProjectFile().deleteVariantTag(group, tag);
+ });
+
+ theContextMenu.exec(mapToGlobal({x, y}));
+}
+
+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);
+ }
+ });
+
+ auto actionColor = theContextMenu.addAction(QObject::tr("Change Group Color"));
+ connect(actionColor, &QAction::triggered, this, [&]() {
+ const auto variantsDef = g_StudioApp.GetCore()->getProjectFile().variantsDef();
+ for (auto &g : variantsDef) {
+ if (g.m_title == group) {
+ QColor newColor = this->showColorDialog(g.m_color);
+ projectFile.changeVariantGroupColor(group, newColor.name());
+ break;
+ }
+ }
+ });
+
+ auto actionDelete = theContextMenu.addAction(QObject::tr("Delete Group"));
+ connect(actionDelete, &QAction::triggered, this, [&]() {
+ projectFile.deleteVariantGroup(group);
+ });
+
+ theContextMenu.exec(mapToGlobal({x, y}));
+}
+
void InspectorControlView::toggleMasterLink()
{
Q3DStudio::ScopedDocumentEditor editor(*g_StudioApp.GetCore()->GetDoc(),