summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/Palettes/Action/ActionView.cpp
diff options
context:
space:
mode:
authorMiikka Heikkinen <miikka.heikkinen@qt.io>2018-06-20 16:45:33 +0300
committerMiikka Heikkinen <miikka.heikkinen@qt.io>2018-06-21 08:04:19 +0000
commite3424c9e019ca3a252156f2c49752af2afc2feb9 (patch)
treeb61efa2367a89ddd5e668e06315e7b9e1086c201 /src/Authoring/Studio/Palettes/Action/ActionView.cpp
parent9f31ed2729b8555b5f51f72305d9bc096007b835 (diff)
Fix action palette issues
- Always show correct property and value when action is selected - Clear selected action on item change - Use alias for slider type so that it actually works - Initialize sliders to minimum value instead of zero - Don't try to assign invalid value to any property handler during changing of targeted property Task-number: QT3DS-190 Task-number: QT3DS-1944 Change-Id: Iae495996ab743ef92e348109303c1d4ab6fa26b4 Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io> Reviewed-by: Marianne Yrjänä <marianne.yrjana@qt.io> Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
Diffstat (limited to 'src/Authoring/Studio/Palettes/Action/ActionView.cpp')
-rw-r--r--src/Authoring/Studio/Palettes/Action/ActionView.cpp33
1 files changed, 31 insertions, 2 deletions
diff --git a/src/Authoring/Studio/Palettes/Action/ActionView.cpp b/src/Authoring/Studio/Palettes/Action/ActionView.cpp
index 17f7b679..2ec9728e 100644
--- a/src/Authoring/Studio/Palettes/Action/ActionView.cpp
+++ b/src/Authoring/Studio/Palettes/Action/ActionView.cpp
@@ -76,17 +76,20 @@ ActionView::ActionView(const QSize &preferredSize, QWidget *parent)
const auto actionInfo = m_actionsModel->actionInfoAt(m_currentActionIndex);
if (actionInfo.m_Handler == L"Set Property") {
+ setPropertyValueInvalid(true);
m_currentPropertyNameHandle = actionInfo.m_HandlerArgs.at(0);
m_currentPropertyValueHandle = actionInfo.m_HandlerArgs.at(1);
m_propertyModel->setAction(m_actionsModel->actionAt(m_currentActionIndex));
m_propertyModel->setNameHandle(m_currentPropertyNameHandle);
m_propertyModel->setValueHandle(m_currentPropertyValueHandle);
-
+ m_currentPropertyIndex = m_propertyModel->defaultPropertyIndex();
+ Q_EMIT propertyChanged();
Q_EMIT propertyModelChanged();
+ setPropertyValueInvalid(false);
}
});
- m_actionChangedCompressionTimer.setInterval(100);
+ m_actionChangedCompressionTimer.setInterval(20);
m_actionChangedCompressionTimer.setSingleShot(true);
connect(&m_actionChangedCompressionTimer, &QTimer::timeout, this, [this] {
updateHandlerArguments();
@@ -287,6 +290,11 @@ PropertyInfo ActionView::property() const
return m_propertyModel->property(m_currentPropertyIndex);
}
+bool ActionView::isPropertyValueInvalid() const
+{
+ return m_propertyValueInvalid;
+}
+
void ActionView::setCurrentActionIndex(int index)
{
if (index == m_currentActionIndex)
@@ -300,6 +308,7 @@ void ActionView::setCurrentActionIndex(int index)
void ActionView::setCurrentPropertyIndex(int handle, int index)
{
+ setPropertyValueInvalid(true);
// Make sure propertymodel name & value handles are always up-to-date,
// even when index is same as before
m_currentPropertyValueHandle = 0;
@@ -335,6 +344,9 @@ void ActionView::setCurrentPropertyIndex(int handle, int index)
}
Q_EMIT propertyChanged();
+ // Clear the value invalid flag asynchronously as the value doesn't actually change until
+ // backend tells us it does
+ QTimer::singleShot(0, this, &ActionView::clearPropertyValueInvalid);
}
void ActionView::addAction()
@@ -1042,3 +1054,20 @@ void ActionView::updateActionStates()
// Allow paste action even if item is not valid (list of actions is empty)
m_actionPaste->setEnabled(CStudioClipboard::CanPasteAction());
}
+
+// m_propertyValueInvalid flag indicates that property value is changing and
+// may not be valid if queried at the moment. It is used to prevent QML errors
+// about invalid value types when changing property handlers.
+void ActionView::setPropertyValueInvalid(bool invalid)
+{
+ if (invalid != m_propertyValueInvalid) {
+ m_propertyValueInvalid = invalid;
+ Q_EMIT propertyValueInvalidChanged();
+ }
+}
+
+// This is used to set m_propertyValueInvalid to false asynchronously
+void ActionView::clearPropertyValueInvalid()
+{
+ setPropertyValueInvalid(false);
+}