fix(editor): properties view setting/unsetting anchored and locked properties erroneously
This commit is contained in:
parent
f6f7a5f151
commit
30d00a7de2
2 changed files with 6 additions and 1 deletions
|
@ -9,7 +9,6 @@
|
||||||
#include <QStyledItemDelegate>
|
#include <QStyledItemDelegate>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTime>
|
#include <QTime>
|
||||||
#include <chrono>
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <qnamespace.h>
|
#include <qnamespace.h>
|
||||||
#include <qtreewidget.h>
|
#include <qtreewidget.h>
|
||||||
|
@ -340,6 +339,8 @@ void PropertiesView::setSelected(std::optional<InstanceRef> instance) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void PropertiesView::propertyChanged(QTreeWidgetItem *item, int column) {
|
void PropertiesView::propertyChanged(QTreeWidgetItem *item, int column) {
|
||||||
|
// Necessary because otherwise this will catch setCheckState from onPropertyUpdated
|
||||||
|
if (ignorePropertyUpdates) return;
|
||||||
if (!item->parent() || (item->parent() && item->parent()->parent()) || currentInstance.expired()) return;
|
if (!item->parent() || (item->parent() && item->parent()->parent()) || currentInstance.expired()) return;
|
||||||
InstanceRef inst = currentInstance.lock();
|
InstanceRef inst = currentInstance.lock();
|
||||||
|
|
||||||
|
@ -396,7 +397,10 @@ void PropertiesView::onPropertyUpdated(InstanceRef inst, std::string property, D
|
||||||
if (item->data(0, Qt::DisplayRole).toString().toStdString() != property) continue;
|
if (item->data(0, Qt::DisplayRole).toString().toStdString() != property) continue;
|
||||||
|
|
||||||
if (meta.type == &Data::Bool::TYPE) {
|
if (meta.type == &Data::Bool::TYPE) {
|
||||||
|
// This is done because otherwise propertyChanged will catch this change erroneously
|
||||||
|
ignorePropertyUpdates = true;
|
||||||
item->setCheckState(1, (bool)currentValue.get<Data::Bool>() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
item->setCheckState(1, (bool)currentValue.get<Data::Bool>() ? Qt::CheckState::Checked : Qt::CheckState::Unchecked);
|
||||||
|
ignorePropertyUpdates = false;
|
||||||
} else if (meta.type == &Color3::TYPE) {
|
} else if (meta.type == &Color3::TYPE) {
|
||||||
Color3 color = currentValue.get<Color3>();
|
Color3 color = currentValue.get<Color3>();
|
||||||
item->setData(1, Qt::DecorationRole, QColor::fromRgbF(color.R(), color.G(), color.B()));
|
item->setData(1, Qt::DecorationRole, QColor::fromRgbF(color.R(), color.G(), color.B()));
|
||||||
|
|
|
@ -11,6 +11,7 @@ namespace Data { class Variant; };
|
||||||
class PropertiesView : public QTreeWidget {
|
class PropertiesView : public QTreeWidget {
|
||||||
Q_DECLARE_PRIVATE(QTreeView)
|
Q_DECLARE_PRIVATE(QTreeView)
|
||||||
|
|
||||||
|
bool ignorePropertyUpdates = false;
|
||||||
InstanceRefWeak currentInstance;
|
InstanceRefWeak currentInstance;
|
||||||
void propertyChanged(QTreeWidgetItem *item, int column);
|
void propertyChanged(QTreeWidgetItem *item, int column);
|
||||||
void activateProperty(QTreeWidgetItem *item, int column);
|
void activateProperty(QTreeWidgetItem *item, int column);
|
||||||
|
|
Loading…
Add table
Reference in a new issue