summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio
diff options
context:
space:
mode:
authorJere Tuliniemi <jere.tuliniemi@qt.io>2018-11-01 12:39:07 +0200
committerJere Tuliniemi <jere.tuliniemi@qt.io>2018-11-08 09:23:39 +0000
commitd83485316ebadece66fe2c520c77e509a2a1b10a (patch)
tree8b4b3384d89e56c0f3892687728beb50b9222aa6 /src/Authoring/Studio
parentadc998bde6e9ec4ac67656b853387a42ea9c1d7f (diff)
Prevent "MaterialContainer" as a user-entered name
This name is only disabled for immediate children of the Scene object. Task-number: QT3DS-2108 Change-Id: Id57be2f9f8a78ac1ca21ebcc2199cfcaae8851ee Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io> Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
Diffstat (limited to 'src/Authoring/Studio')
-rw-r--r--src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp16
-rw-r--r--src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp16
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.cpp14
-rw-r--r--src/Authoring/Studio/Workspace/Dialogs.h2
4 files changed, 47 insertions, 1 deletions
diff --git a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
index f7ba6e8e..ffb80aab 100644
--- a/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
+++ b/src/Authoring/Studio/Palettes/Inspector/InspectorControlModel.cpp
@@ -1559,7 +1559,8 @@ void InspectorControlModel::setRenderableValue(long instance, int handle, const
void InspectorControlModel::setPropertyValue(long instance, int handle, const QVariant &value,
bool commit)
{
- const auto studio = g_StudioApp.GetCore()->GetDoc()->GetStudioSystem();
+ const auto doc = g_StudioApp.GetCore()->GetDoc();
+ const auto studio = doc->GetStudioSystem();
const auto bridge = studio->GetClientDataModelBridge();
// Name property needs special handling
if (handle == bridge->GetNameProperty()) {
@@ -1575,6 +1576,19 @@ void InspectorControlModel::setPropertyValue(long instance, int handle, const QV
Q3DStudio::CString newName = Q3DStudio::CString::fromQString(value.toString());
if (!newName.IsEmpty()) {
qt3dsdm::Qt3DSDMInstanceHandle parentInstance = bridge->GetParentInstance(instance);
+
+ if (parentInstance == doc->GetSceneInstance()
+ && newName.toQString() == bridge->getMaterialContainerName()) {
+ QString theTitle = QObject::tr("Rename Object Error");
+ QString theString = bridge->getMaterialContainerName()
+ + QObject::tr(" is a reserved name.");
+ // Display error message box asynchronously so focus loss won't trigger setting
+ // the name again
+ g_StudioApp.GetDialogs()->asyncDisplayMessageBox(theTitle, theString,
+ Qt3DSMessageBox::ICON_ERROR);
+ return;
+ }
+
if (!bridge->CheckNameUnique(parentInstance, instance, newName)) {
QString origNewName = newName.toQString();
newName = bridge->GetUniqueChildName(parentInstance, instance, newName);
diff --git a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
index 8401a523..e8b48a4d 100644
--- a/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
+++ b/src/Authoring/Studio/Palettes/Timeline/Bindings/Qt3DSDMTimelineItemBinding.cpp
@@ -363,6 +363,22 @@ void Qt3DSDMTimelineItemBinding::SetName(const Q3DStudio::CString &inName)
}
CClientDataModelBridge *theBridge = m_StudioSystem->GetClientDataModelBridge();
+ const auto doc = g_StudioApp.GetCore()->GetDoc();
+
+ // Display warning if the name and path are the same as the material container
+ if (theBridge->GetParentInstance(m_DataHandle) == doc->GetSceneInstance()
+ && inName.toQString() == theBridge->getMaterialContainerName()) {
+ QString theTitle = QObject::tr("Rename Object Error");
+ QString theString = theBridge->getMaterialContainerName()
+ + QObject::tr(" is a reserved name.");
+ g_StudioApp.GetDialogs()->DisplayMessageBox(theTitle, theString,
+ Qt3DSMessageBox::ICON_ERROR, false);
+ // The timeline still shows the new name so refresh the name property
+ m_StudioSystem->GetFullSystemSignalSender()->SendInstancePropertyValue(
+ m_DataHandle, theBridge->GetNameProperty());
+ return;
+ }
+
// Display warning if we had to modify the user-given name to make it unique
if (!theBridge->CheckNameUnique(theBridge->GetParentInstance(m_DataHandle),
m_DataHandle, inName)) {
diff --git a/src/Authoring/Studio/Workspace/Dialogs.cpp b/src/Authoring/Studio/Workspace/Dialogs.cpp
index 3bb610b4..f6520904 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.cpp
+++ b/src/Authoring/Studio/Workspace/Dialogs.cpp
@@ -644,6 +644,20 @@ CDialogs::DisplayMessageBox(const QString &inTitle, const QString &inText,
return theUserChoice;
}
+void CDialogs::asyncDisplayMessageBox(const QString &title, const QString &text,
+ Qt3DSMessageBox::EMessageBoxIcon icon, QWidget *parent)
+{
+ if (m_ShowGUI) {
+ if (parent == nullptr)
+ parent = g_StudioApp.m_pMainWnd;
+ QTimer::singleShot(0, [title, text, icon, parent]() {
+ Qt3DSMessageBox::Show(title, text, icon, false, parent);
+ });
+ } else {
+ qCDebug(qt3ds::TRACE_INFO) << title << ": " << text;
+ }
+}
+
int CDialogs::DisplayChoiceBox(const QString &inTitle, const QString &inText, int inIcon)
{
if (m_ShowGUI) {
diff --git a/src/Authoring/Studio/Workspace/Dialogs.h b/src/Authoring/Studio/Workspace/Dialogs.h
index 97ed22d6..987ccc95 100644
--- a/src/Authoring/Studio/Workspace/Dialogs.h
+++ b/src/Authoring/Studio/Workspace/Dialogs.h
@@ -146,6 +146,8 @@ public:
Qt3DSMessageBox::EMessageBoxIcon inIcon,
bool inShowCancel,
QWidget *parent = nullptr);
+ void asyncDisplayMessageBox(const QString &title, const QString &text,
+ Qt3DSMessageBox::EMessageBoxIcon icon, QWidget *parent = nullptr);
int displayOverrideAssetBox(const QString &assetPath);
int DisplayChoiceBox(const QString &inTitle, const QString &inText, int inIcon);
void DisplayKnownErrorDialog(const QString &inErrorText);