New properties framework by bjorn · Pull Request #4045 · mapeditor/tiled (original) (raw)

bjorn

@bjorn

The new property editor will be based on a widget hierarchy instead of a QTreeView. This will allow better customization and direct widget interaction.

This first step implements various property edit widgets which are instantiated based on the type of QVariant values.

@bjorn

It adjusts the layout based on its width.

Also made a few other visual tweaks.

@bjorn

Introduced Property class and changed from using editor factories to having the property itself create its widget.

@bjorn

I'm not entirely convinced it was a good idea to put the "createEditor" function on the Property. It makes it easy to do custom widgets for a property, but annoying to have it use a type-based editor.

@bjorn

@bjorn

@bjorn

@bjorn

This property uses an editable combo box with the valid classes set up for the given object type.

@bjorn

Still needs special handling for:

@bjorn

Some details remain to be done:

@bjorn

Added support for editing QUrl values using UrlEditorFactory that creates a FileEdit.

@bjorn

Also in this change:

A few things remain to be done:

@bjorn

Now all built-in properties are present, apart from some loose ends.

@bjorn

Instead there are now typed Property subclasses similar to the generic GetSetProperty.

@bjorn

Use a special property that creates a name edit as label and a type combo box as editor, instead of a modal Add Property dialog.

VariantEditorView::focusProperty now makes sure that the focused property widget is visible.

The "add value" property is automatically removed when it loses focus. To achieve this, each property now gets its own parent widget rather than just having its widgets added to a nested horizontal layout. This way, we can check whether the focus remains within the same parent widget.

The Add button has Qt::StrongFocus policy now, otherwise the focus would be lost to the properties view when clicking it.

@bjorn

When changed by other means (scripting, undo/redo, Layers view), the name wasn't updating due to a missing valueChanged call.

@bjorn

@bjorn

We don't really need to put it in a QWidget with a vertical layout.

@bjorn

@bjorn

As part of implementing this, the VariantEditor and VariantEditorView have been merged into a single PropertiesView class.

ToDo:

@bjorn

To match the rename in the last commit.

The term "VariantEditor" referred to the initial approach of using QVariant for all properties. Now "PropertiesView" is more appropriate, since it is a view based on the type-agnostic "Property" hierarchy.

@bjorn

Now they both scale vertically to cover the minimum size of both.

@bjorn

Better to not touch the clipboard at all in this case.

@bjorn

When pasting custom properties, we now make sure that the Custom Properties group is expanded and select the pasted properties for some additional feedback. Also focus the first pasted property, which makes sure at least one of them is visible.

@bjorn

This change also disables Enter for opening the combo box popup, fixing the rather broken behavior (at least on Linux) that pressing Enter to select a type will immediately re-open the popup. That only applies to combo boxes in the Properties view, though.

@bjorn

This makes the property-specific actions like "Go to Object" and "Open Containing Folder" available again, as well as the Cut, Copy and Paste actions.

For now, the Custom Types Editor has no context menu anymore...

Property widgets are now removed before their property is deleted to avoid a crash when right-clicking the AddValueProperty, since that caused the focus to be lost and thus the removal of the property while at the same time triggering a context menu for it.

@bjorn

The QCommonStyle always uses the WindowText role when rendering a checkbox label, so change the palette so that is picks up the HighlightedText role when the property is selected.

@bjorn

The tab order follows the widget creation order, which is not what we want when properties are inserted between other properties. Hence we now explicitly set the tab order in this case.

We can't just call QWidget::setTabOrder on the row widgets unfortunately, because the call does nothing when called with widgets that have Qt::NoFocus policy.

Calling QWidget::setTabOrder only on the inserted sequence led to other issues, which led me to the solution of setting the tab order for all property widgets to match the order in the layout. To avoid too much repeated work when multiple properties are inserted, the fixTabOrder call is scheduled using QMetaObject::invokeMethod.

@bjorn

@bjorn

Instead of a using the disabled state for properties that are not set on the current object, inherited values now feature a Reset button and have their name displayed in bold when they have been overridden. This makes inherited properties directly editable, matching the behavior for class members.

To avoid confusion, properties from other selected objects are no longer displayed (this reverts 8cc0374).

@bjorn

This adds the feature originally implemented in 8434f5e to the new Properties view.

@bjorn

To make inherited properties easier to distinguish from explicitly set properties, their labels are now dimmed (by disabling them). This is done recursively for any class members.

@bjorn

@bjorn

To avoid synchronizing the value for all selected objects.

@bjorn

Now it is possible to enter the hex value (or CSS color name) to set a color's value.

@bjorn bjorn deleted the new-properties-framework branch

January 12, 2025 12:13

@bjorn bjorn mentioned this pull request

Jan 22, 2025

4 tasks

@bjorn bjorn mentioned this pull request

Feb 21, 2026

This was referenced

Mar 11, 2026

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})