Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion engine/includes/editor/propertyedit.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class ENGINE_EXPORT PropertyEdit : public QWidget {

QString m_propertyName;

QObject *m_propertyObject;
QObject *m_qObject;

Object *m_object;

Expand Down
5 changes: 3 additions & 2 deletions engine/src/editor/propertyedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ QList<PropertyEdit::UserTypeCallback> PropertyEdit::m_userCallbacks;

PropertyEdit::PropertyEdit(QWidget *parent) :
QWidget(parent),
m_propertyObject(nullptr) {
m_qObject(nullptr),
m_object(nullptr) {

}

Expand All @@ -28,7 +29,7 @@ void PropertyEdit::setEditorHint(const QString &hint) {

void PropertyEdit::setObject(QObject *object, const QString &name) {
m_propertyName = name;
m_propertyObject = object;
m_qObject = object;
}

void PropertyEdit::setObject(Object *object, const QString &name) {
Expand Down
1,243 changes: 574 additions & 669 deletions worldeditor/res/styles/dark/icons/icons.ai

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion worldeditor/res/styles/dark/style.qss
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ QTreeView::indicator:checked:hover {
background-color: #757575;
}
QTreeView::indicator:checked {
image: url(:/Style/styles/dark/icons/close-hover.png);
image: url(:/Style/styles/dark/icons/check.png);
width: 13;
}
QTreeView::indicator:unchecked:hover {
background-color: #757575;
Expand Down
14 changes: 7 additions & 7 deletions worldeditor/src/screens/propertyedit/custom/array/arrayedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ void ArrayEdit::setData(const QVariant &data) {
foreach(auto element, m_editors) {
if(i < m_list.size()) {
element->setVisible(true);
element->setData(i, m_list.at(i), m_propertyName, m_propertyObject);
element->setData(i, m_list.at(i), m_propertyName, m_qObject);

height += element->sizeHint().height();
i++;
Expand All @@ -72,12 +72,12 @@ void ArrayEdit::setData(const QVariant &data) {
void ArrayEdit::setObject(QObject *object, const QString &name) {
PropertyEdit::setObject(object, name);

const QMetaObject *meta = m_propertyObject->metaObject();
const QMetaObject *meta = m_qObject->metaObject();
int index = meta->indexOfProperty(qPrintable(m_propertyName));
if(index > -1) {
QMetaProperty property = meta->property(index);
} else {
index = m_propertyObject->dynamicPropertyNames().indexOf(qPrintable(m_propertyName));
index = m_qObject->dynamicPropertyNames().indexOf(qPrintable(m_propertyName));
if(index > -1) {
m_dynamic = true;
}
Expand All @@ -88,16 +88,16 @@ void ArrayEdit::addOne() {
if(m_list.isEmpty()) {
if(m_dynamic) {
m_list.push_back(QVariant());
m_propertyObject->setProperty(qPrintable(m_propertyName), m_list);
m_qObject->setProperty(qPrintable(m_propertyName), m_list);
} else { // Request object to reset property (add one element)
const QMetaObject *meta = m_propertyObject->metaObject();
const QMetaObject *meta = m_qObject->metaObject();
int index = meta->indexOfProperty(qPrintable(m_propertyName));
if(index > -1) {
QMetaProperty property = meta->property(index);
property.reset(m_propertyObject);
property.reset(m_qObject);
}
}
m_list = m_propertyObject->property(qPrintable(m_propertyName)).toList();
m_list = m_qObject->property(qPrintable(m_propertyName)).toList();
} else {
m_list.push_back(m_list.back());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,19 @@ void Actions::setObject(Object *object, const QString &name) {
void Actions::setObject(QObject *object, const QString &name) {
PropertyEdit::setObject(object, name);

if(m_qObject == nullptr) {
return;
}
const QMetaObject *meta = m_qObject->metaObject();

int index = meta->indexOfProperty("enabled");
if(index > -1) {
m_qProperty = meta->property(index);
}

PropertyEditor *editor = findEditor(parentWidget());
if(editor) {
for(auto it : editor->getActions(m_propertyObject, this)) {
for(auto it : editor->getActions(m_qObject, this)) {
ui->horizontalLayout->addWidget(it);
}
}
Expand All @@ -50,12 +60,16 @@ void Actions::setObject(QObject *object, const QString &name) {
void Actions::onDataChanged(bool value) {
if(m_property.isValid()) {
m_property.write(m_object, value);
} else if(m_qProperty.isValid()) {
m_qProperty.write(m_qObject, value);
}
}

bool Actions::isChecked() const {
if(m_property.isValid()) {
return m_property.read(m_object).toBool();
} else if(m_qProperty.isValid()) {
return m_qProperty.read(m_qObject).toBool();
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

#include <editor/propertyedit.h>

#include <QMetaProperty>

class Object;

class PropertyEditor;
Expand Down Expand Up @@ -34,6 +36,8 @@ public slots:

MetaProperty m_property;

QMetaProperty m_qProperty;

};

#endif // ACTIONS_H
4 changes: 2 additions & 2 deletions worldeditor/src/screens/propertyedit/editors/EnumEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ QVariant EnumEdit::data() const {
}

void EnumEdit::setData(const QVariant &data) {
const QMetaObject *meta = m_propertyObject->metaObject();
const QMetaObject *meta = m_qObject->metaObject();
int index = meta->indexOfProperty(qPrintable(m_propertyName));
QMetaProperty prop = meta->property(index);

Expand All @@ -39,7 +39,7 @@ void EnumEdit::setObject(QObject *object, const QString &name) {

ui->comboBox->clear();

const QMetaObject *meta = m_propertyObject->metaObject();
const QMetaObject *meta = m_qObject->metaObject();
QMetaProperty prop = meta->property(meta->indexOfProperty(qPrintable(name)));

if(prop.isEnumType()) {
Expand Down
10 changes: 0 additions & 10 deletions worldeditor/src/screens/propertyedit/nextmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,6 @@ void NextModel::updateDynamicProperties(Property *parent, Object *propertyObject
dynamicProperties << it.c_str();
}

Property *p = dynamic_cast<Property *>(m_rootItem);
for(int i = 0; i < dynamicProperties.size(); i++) {
QString name(dynamicProperties[i]);
QObject *object = p->findChild<QObject *>(name);
if(object) {
dynamicProperties.removeAll(name);
i = -1;
}
}

// Remove invalid properites and those we don't want to add
for(int i = 0; i < dynamicProperties.size(); i++) {
QString dynProp = dynamicProperties[i];
Expand Down
5 changes: 5 additions & 0 deletions worldeditor/src/screens/propertyedit/property.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ void Property::setPropertyObject(QObject *propertyObject) {
} else if(meta->property(meta->indexOfProperty(qPrintable(objectName()))).isWritable()) {
m_readOnly = false;
}

if(m_root) {
int index = meta->indexOfProperty(gEnabled);
m_checkable = (index > -1);
}
}

void Property::setPropertyObject(Object *propertyObject) {
Expand Down
29 changes: 8 additions & 21 deletions worldeditor/src/screens/propertyedit/propertymodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,26 +160,23 @@ void PropertyModel::addItem(QObject *propertyObject) {
QMetaProperty property = metaObject->property(i);

if(property.isUser(propertyObject)) { // Hide Qt specific properties
empty = false;
if(!QString(property.name()).toLower().contains("enable")) {
empty = false;

Property *p = new Property(property.name(), (propertyItem) ? propertyItem : static_cast<Property *>(m_rootItem), false);
p->setPropertyObject(propertyObject);
Property *p = new Property(property.name(), (propertyItem) ? propertyItem : static_cast<Property *>(m_rootItem), false);
p->setPropertyObject(propertyObject);

int index = metaObject->indexOfClassInfo(property.name());
if(index != -1) {
p->setEditorHints(metaObject->classInfo(index).value());
int index = metaObject->indexOfClassInfo(property.name());
if(index != -1) {
p->setEditorHints(metaObject->classInfo(index).value());
}
}
}
}

if(empty) {
delete propertyItem;
propertyItem = static_cast<Property *>(m_rootItem);
} else {
int i = rowCount();
beginInsertRows(QModelIndex(), i, i + 1);

endInsertRows();
}
}

Expand All @@ -195,16 +192,6 @@ void PropertyModel::updateDynamicProperties(Property *parent, QObject *propertyO
// Get dynamic property names
QList<QByteArray> dynamicProperties = propertyObject->dynamicPropertyNames();

Property *p = dynamic_cast<Property *>(m_rootItem);
for(int i = 0; i < dynamicProperties.size(); i++) {
QByteArray name = dynamicProperties[i];
QObject *object = p->findChild<QObject *>(name);
if(object) {
dynamicProperties.removeAll(name);
i = -1;
}
}

// Remove invalid properites and those we don't want to add
for(int i = 0; i < dynamicProperties.size(); i++) {
QString dynProp = dynamicProperties[i];
Expand Down
Loading