Fixed changing tile properties in tileset editor · mapeditor/tiled@6541dac (original) (raw)
`@@ -167,8 +167,6 @@ void PropertyBrowser::setDocument(Document *document)
`
167
167
``
168
168
`connect(mapDocument, &MapDocument::selectedObjectsChanged,
`
169
169
`this, &PropertyBrowser::selectedObjectsChanged);
`
170
``
`-
connect(mapDocument, &MapDocument::selectedTilesChanged,
`
171
``
`-
this, &PropertyBrowser::selectedTilesChanged);
`
172
170
` }
`
173
171
``
174
172
`if (tilesetDocument) {
`
`@@ -189,14 +187,17 @@ void PropertyBrowser::setDocument(Document *document)
`
189
187
``
190
188
`if (document) {
`
191
189
`// For custom properties:
`
192
``
`-
connect(mapDocument, &Document::propertyAdded,
`
``
190
`+
connect(document, &Document::propertyAdded,
`
193
191
`this, &PropertyBrowser::propertyAdded);
`
194
``
`-
connect(mapDocument, &Document::propertyRemoved,
`
``
192
`+
connect(document, &Document::propertyRemoved,
`
195
193
`this, &PropertyBrowser::propertyRemoved);
`
196
``
`-
connect(mapDocument, &Document::propertyChanged,
`
``
194
`+
connect(document, &Document::propertyChanged,
`
197
195
`this, &PropertyBrowser::propertyChanged);
`
198
``
`-
connect(mapDocument, &Document::propertiesChanged,
`
``
196
`+
connect(document, &Document::propertiesChanged,
`
199
197
`this, &PropertyBrowser::propertiesChanged);
`
``
198
+
``
199
`+
connect(document, &Document::selectedTilesChanged,
`
``
200
`+
this, &PropertyBrowser::selectedTilesChanged);
`
200
201
` }
`
201
202
`}
`
202
203
``
`@@ -264,18 +265,8 @@ void PropertyBrowser::imageLayerChanged(ImageLayer *imageLayer)
`
264
265
``
265
266
`void PropertyBrowser::tilesetChanged(Tileset *tileset)
`
266
267
`{
`
267
``
`-
if (mObject != tileset)
`
268
``
`-
return;
`
269
``
-
270
``
`-
bool isExternal = tileset->isExternal();
`
271
``
`-
bool wasExternal = mIdToProperty.contains(FileNameProperty);
`
272
``
-
273
``
`-
if (isExternal == wasExternal) {
`
``
268
`+
if (mObject == tileset)
`
274
269
`updateProperties();
`
275
``
`-
} else {
`
276
``
`-
removeProperties();
`
277
``
`-
addProperties();
`
278
``
`-
}
`
279
270
`}
`
280
271
``
281
272
`void PropertyBrowser::tileChanged(Tile *tile)
`
`@@ -580,7 +571,7 @@ void PropertyBrowser::addTilesetProperties()
`
580
571
``
581
572
` QtProperty *groupProperty = mGroupManager->addProperty(tr("Tileset"));
`
582
573
``
583
``
`-
if (tileset->isExternal()) {
`
``
574
`+
if (mMapDocument) {
`
584
575
`auto property = createProperty(FileNameProperty, VariantPropertyManager::filePathTypeId(), tr("Filename"), groupProperty);
`
585
576
``
586
577
` QString filter = QCoreApplication::translate("MainWindow", "All Files (*)");
`
`@@ -591,8 +582,11 @@ void PropertyBrowser::addTilesetProperties()
`
591
582
` property->setAttribute(QStringLiteral("filter"), helper.filter());
`
592
583
` }
`
593
584
``
594
``
`-
createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty);
`
595
``
`-
createProperty(TileOffsetProperty, QVariant::Point, tr("Drawing Offset"), groupProperty);
`
``
585
`+
QtVariantProperty *nameProperty = createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty);
`
``
586
`+
nameProperty->setEnabled(mTilesetDocument);
`
``
587
+
``
588
`+
QtVariantProperty *tileOffsetProperty = createProperty(TileOffsetProperty, QVariant::Point, tr("Drawing Offset"), groupProperty);
`
``
589
`+
tileOffsetProperty->setEnabled(mTilesetDocument);
`
596
590
``
597
591
` QtVariantProperty *columnsProperty = createProperty(ColumnCountProperty, QVariant::Int, tr("Columns"), groupProperty);
`
598
592
` columnsProperty->setAttribute(QLatin1String("minimum"), 1);
`
`@@ -602,6 +596,8 @@ void PropertyBrowser::addTilesetProperties()
`
602
596
` QtVariantProperty *parametersProperty =
`
603
597
`createProperty(TilesetImageParametersProperty, VariantPropertyManager::tilesetParametersTypeId(), tr("Image"), groupProperty);
`
604
598
``
``
599
`+
parametersProperty->setEnabled(mTilesetDocument);
`
``
600
+
605
601
` QtVariantProperty *imageSourceProperty = createProperty(ImageSourceProperty, QVariant::String, tr("Source"), parametersProperty);
`
606
602
` QtVariantProperty *tileWidthProperty = createProperty(TileWidthProperty, QVariant::Int, tr("Tile Width"), parametersProperty);
`
607
603
` QtVariantProperty *tileHeightProperty = createProperty(TileHeightProperty, QVariant::Int, tr("Tile Height"), parametersProperty);
`
`@@ -634,6 +630,7 @@ void PropertyBrowser::addTileProperties()
`
634
630
` groupProperty);
`
635
631
` probabilityProperty->setAttribute(QLatin1String("decimals"), 3);
`
636
632
` probabilityProperty->setToolTip(tr("Relative chance this tile will be picked"));
`
``
633
`+
probabilityProperty->setEnabled(mTilesetDocument);
`
637
634
``
638
635
`const Tile *tile = static_cast<const Tile*>(mObject);
`
639
636
`if (!tile->imageSource().isEmpty()) {
`
`@@ -643,6 +640,7 @@ void PropertyBrowser::addTileProperties()
`
643
640
``
644
641
` imageSourceProperty->setAttribute(QLatin1String("filter"),
`
645
642
`Utils::readableImageFormatsFilter());
`
``
643
`+
imageSourceProperty->setEnabled(mTilesetDocument);
`
646
644
` }
`
647
645
``
648
646
`addProperty(groupProperty);
`
`@@ -651,7 +649,8 @@ void PropertyBrowser::addTileProperties()
`
651
649
`void PropertyBrowser::addTerrainProperties()
`
652
650
`{
`
653
651
` QtProperty *groupProperty = mGroupManager->addProperty(tr("Terrain"));
`
654
``
`-
createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty);
`
``
652
`+
QtVariantProperty *nameProperty = createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty);
`
``
653
`+
nameProperty->setEnabled(mTilesetDocument);
`
655
654
`addProperty(groupProperty);
`
656
655
`}
`
657
656
``
`@@ -1125,18 +1124,14 @@ void PropertyBrowser::updateProperties()
`
1125
1124
` }
`
1126
1125
`case Object::TilesetType: {
`
1127
1126
` Tileset *tileset = static_cast<Tileset*>(mObject);
`
1128
``
`-
const bool external = tileset->isExternal();
`
1129
1127
``
1130
1128
`if (QtVariantProperty *fileNameProperty = mIdToProperty.value(FileNameProperty))
`
1131
1129
` fileNameProperty->setValue(tileset->fileName());
`
1132
1130
``
1133
1131
`mIdToProperty[NameProperty]->setValue(tileset->name());
`
1134
1132
`mIdToProperty[TileOffsetProperty]->setValue(tileset->tileOffset());
`
1135
1133
`mIdToProperty[ColumnCountProperty]->setValue(tileset->columnCount());
`
1136
``
-
1137
``
`-
mIdToProperty[NameProperty]->setEnabled(!external);
`
1138
``
`-
mIdToProperty[TileOffsetProperty]->setEnabled(!external);
`
1139
``
`-
mIdToProperty[ColumnCountProperty]->setEnabled(!external && tileset->isCollection());
`
``
1134
`+
mIdToProperty[ColumnCountProperty]->setEnabled(mTilesetDocument && tileset->isCollection());
`
1140
1135
``
1141
1136
`if (!tileset->isCollection()) {
`
1142
1137
`// todo: Consider when to set the TilesetDocument on the parameters edit
`
`@@ -1149,8 +1144,6 @@ void PropertyBrowser::updateProperties()
`
1149
1144
`mIdToProperty[MarginProperty]->setValue(tileset->margin());
`
1150
1145
`mIdToProperty[SpacingProperty]->setValue(tileset->tileSpacing());
`
1151
1146
`mIdToProperty[ColorProperty]->setValue(tileset->transparentColor());
`
1152
``
-
1153
``
`-
mIdToProperty[TilesetImageParametersProperty]->setEnabled(!external);
`
1154
1147
` }
`
1155
1148
`break;
`
1156
1149
` }
`
`@@ -1243,7 +1236,7 @@ void PropertyBrowser::updatePropertyColor(const QString &name)
`
1243
1236
` QString propertyName = property->propertyName();
`
1244
1237
` QString propertyValue = property->valueText();
`
1245
1238
``
1246
``
`-
const auto &objects = mMapDocument->currentObjects();
`
``
1239
`+
const auto &objects = mDocument->currentObjects();
`
1247
1240
``
1248
1241
`// If one of the objects doesn't have this property then gray out the name and value.
`
1249
1242
`for (Object *obj : objects) {
`