diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/debian/bzr-builder.manifest tiled-daily-0+git20160530~19~ubuntu15.10.1/debian/bzr-builder.manifest --- tiled-daily-0+git20160525~19~ubuntu15.10.1/debian/bzr-builder.manifest 2016-05-25 23:48:40.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/debian/bzr-builder.manifest 2016-05-30 17:22:19.000000000 +0000 @@ -1,3 +1,3 @@ -# bzr-builder format 0.3 deb-version 0+git20160525~19 -lp:tiled revid:git-v1:45baf118d1a114cbdfc21073a703cceda70e097a +# bzr-builder format 0.3 deb-version 0+git20160530~19 +lp:tiled revid:git-v1:bfdc7f0561e6b7bc7703bb6d51e26d5d19426bc1 merge packaging lp:~mapeditor.org/+junk/packaging revid:bjorn@lindeijer.nl-20160228192730-jr37st1ye55ochnk diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/debian/changelog tiled-daily-0+git20160530~19~ubuntu15.10.1/debian/changelog --- tiled-daily-0+git20160525~19~ubuntu15.10.1/debian/changelog 2016-05-25 23:48:40.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/debian/changelog 2016-05-30 17:22:19.000000000 +0000 @@ -1,6 +1,6 @@ -tiled-daily (0+git20160525~19~ubuntu15.10.1) wily; urgency=low +tiled-daily (0+git20160530~19~ubuntu15.10.1) wily; urgency=low * Auto build. - -- Launchpad Package Builder Wed, 25 May 2016 23:48:40 +0000 + -- Launchpad Package Builder Mon, 30 May 2016 17:22:19 +0000 diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/.pc/.quilt_patches tiled-daily-0+git20160530~19~ubuntu15.10.1/.pc/.quilt_patches --- tiled-daily-0+git20160525~19~ubuntu15.10.1/.pc/.quilt_patches 2016-05-25 23:48:41.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/.pc/.quilt_patches 2016-05-30 17:22:19.000000000 +0000 @@ -1 +1 @@ -/home/buildd/build-RECIPEBRANCHBUILD-1146099/chroot-autobuild/home/buildd/work/tree/tiled-daily-0+git20160525~19~ubuntu15.10.1/debian/patches +/home/buildd/build-RECIPEBRANCHBUILD-1148890/chroot-autobuild/home/buildd/work/tree/tiled-daily-0+git20160530~19~ubuntu15.10.1/debian/patches diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/.pc/.quilt_series tiled-daily-0+git20160530~19~ubuntu15.10.1/.pc/.quilt_series --- tiled-daily-0+git20160525~19~ubuntu15.10.1/.pc/.quilt_series 2016-05-25 23:48:41.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/.pc/.quilt_series 2016-05-30 17:22:19.000000000 +0000 @@ -1 +1 @@ -/home/buildd/build-RECIPEBRANCHBUILD-1146099/chroot-autobuild/home/buildd/work/tree/tiled-daily-0+git20160525~19~ubuntu15.10.1/debian/patches/series +/home/buildd/build-RECIPEBRANCHBUILD-1148890/chroot-autobuild/home/buildd/work/tree/tiled-daily-0+git20160530~19~ubuntu15.10.1/debian/patches/series diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/mapreader.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/mapreader.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/mapreader.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/mapreader.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -945,9 +945,12 @@ QVariant variant(propertyValue); if (!propertyType.isEmpty()) { - QVariant::Type type = nameToType(propertyType); - if (type != QVariant::Invalid) - variant.convert(nameToType(propertyType)); + int type = nameToType(propertyType); + + if (type == filePathTypeId()) + variant = p->resolveReference(variant.toString(), mPath); + + variant = fromExportValue(variant, type); } properties->insert(propertyName, variant); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/maptovariantconverter.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/maptovariantconverter.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/maptovariantconverter.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/maptovariantconverter.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -231,8 +231,14 @@ Properties::const_iterator it = properties.constBegin(); Properties::const_iterator it_end = properties.constEnd(); - for (; it != it_end; ++it) - variantMap[it.key()] = toExportValue(it.value()); + for (; it != it_end; ++it) { + QVariant value = toExportValue(it.value()); + + if (it.value().userType() == filePathTypeId()) + value = mMapDir.relativeFilePath(value.toString()); + + variantMap[it.key()] = value; + } return variantMap; } @@ -244,7 +250,7 @@ Properties::const_iterator it = properties.constBegin(); Properties::const_iterator it_end = properties.constEnd(); for (; it != it_end; ++it) - variantMap[it.key()] = typeToName(it.value().type()); + variantMap[it.key()] = typeToName(it.value().userType()); return variantMap; } @@ -403,8 +409,14 @@ Properties::const_iterator it = properties.constBegin(); Properties::const_iterator it_end = properties.constEnd(); for (; it != it_end; ++it) { - propertiesMap[it.key()] = toExportValue(it.value()); - propertyTypesMap[it.key()] = typeToName(it.value().type()); + int type = it.value().userType(); + QVariant value = toExportValue(it.value()); + + if (type == filePathTypeId()) + value = mMapDir.relativeFilePath(value.toString()); + + propertiesMap[it.key()] = value; + propertyTypesMap[it.key()] = typeToName(type); } variantMap[QLatin1String("properties")] = propertiesMap; diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/mapwriter.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/mapwriter.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/mapwriter.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/mapwriter.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -634,11 +634,16 @@ w.writeStartElement(QLatin1String("property")); w.writeAttribute(QLatin1String("name"), it.key()); - QString typeName = typeToName(it.value().type()); + int type = it.value().userType(); + QString typeName = typeToName(type); if (typeName != QLatin1String("string")) w.writeAttribute(QLatin1String("type"), typeName); - const QString &value = toExportValue(it.value()).toString(); + QString value = toExportValue(it.value()).toString(); + + if (type == filePathTypeId() && !mUseAbsolutePaths) + value = mMapDir.relativeFilePath(value); + if (value.contains(QLatin1Char('\n'))) w.writeCharacters(value); else diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/properties.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/properties.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/properties.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/properties.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -62,7 +62,7 @@ ++mAggregatedCount; } -QString typeToName(QVariant::Type type) +QString typeToName(int type) { switch (type) { case QVariant::String: @@ -72,11 +72,13 @@ case QVariant::Color: return QStringLiteral("color"); default: - return QLatin1String(QVariant::typeToName(type)); + if (type == filePathTypeId()) + return QStringLiteral("file"); } + return QLatin1String(QVariant::typeToName(type)); } -QVariant::Type nameToType(const QString &name) +int nameToType(const QString &name) { if (name == QLatin1String("string")) return QVariant::String; @@ -84,6 +86,8 @@ return QVariant::Double; if (name == QLatin1String("color")) return QVariant::Color; + if (name == QLatin1String("file")) + return filePathTypeId(); return QVariant::nameToType(name.toLatin1().constData()); } @@ -102,12 +106,35 @@ QVariant toExportValue(const QVariant &value) { - switch (value.type()) { - case QVariant::Color: + int type = value.userType(); + + if (type == QVariant::Color) return colorToString(value.value()); - default: + if (type == filePathTypeId()) + return value.value().absolutePath; + + return value; +} + +int filePathTypeId() +{ + return qMetaTypeId(); +} + +QVariant fromExportValue(const QVariant &value, int type) +{ + if (type == QVariant::Invalid) return value; - } + + if (value.userType() == type) + return value; + + if (type == filePathTypeId()) + return QVariant::fromValue(FilePath { value.toString() }); + + QVariant variant(value); + variant.convert(type); + return variant; } } // namespace Tiled diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/properties.h tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/properties.h --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/properties.h 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/properties.h 2016-05-30 17:22:14.000000000 +0000 @@ -37,6 +37,10 @@ namespace Tiled { +struct FilePath { + QString absolutePath; +}; + /** * Collection of properties and their values. */ @@ -98,11 +102,16 @@ }; -TILEDSHARED_EXPORT QString typeToName(QVariant::Type); -TILEDSHARED_EXPORT QVariant::Type nameToType(const QString &name); +TILEDSHARED_EXPORT int filePathTypeId(); + +TILEDSHARED_EXPORT QString typeToName(int type); +TILEDSHARED_EXPORT int nameToType(const QString &name); TILEDSHARED_EXPORT QVariant toExportValue(const QVariant &value); +TILEDSHARED_EXPORT QVariant fromExportValue(const QVariant &value, int type); } // namespace Tiled +Q_DECLARE_METATYPE(Tiled::FilePath) + #endif // PROPERTIES_H diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/varianttomapconverter.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/varianttomapconverter.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/libtiled/varianttomapconverter.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/libtiled/varianttomapconverter.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -26,6 +26,7 @@ #include "mapobject.h" #include "objectgroup.h" #include "properties.h" +#include "terrain.h" #include "tile.h" #include "tilelayer.h" #include "tileset.h" @@ -141,12 +142,17 @@ QVariantMap::const_iterator it = propertiesMap.constBegin(); QVariantMap::const_iterator it_end = propertiesMap.constEnd(); for (; it != it_end; ++it) { - QVariant::Type type = nameToType(propertyTypesMap.value(it.key()).toString()); + int type = nameToType(propertyTypesMap.value(it.key()).toString()); if (type == QVariant::Invalid) type = QVariant::String; QVariant value = it.value(); - value.convert(type); + + if (type == filePathTypeId()) + value = resolvePath(mMapDir, value); + + value = fromExportValue(value, type); + properties[it.key()] = value; } @@ -222,8 +228,9 @@ QVariantList terrainsVariantList = variantMap[QLatin1String("terrains")].toList(); for (int i = 0; i < terrainsVariantList.count(); ++i) { QVariantMap terrainMap = terrainsVariantList[i].toMap(); - tileset->addTerrain(terrainMap[QLatin1String("name")].toString(), - terrainMap[QLatin1String("tile")].toInt()); + Terrain *terrain = tileset->addTerrain(terrainMap[QLatin1String("name")].toString(), + terrainMap[QLatin1String("tile")].toInt()); + terrain->setProperties(extractProperties(terrainMap)); } // Read tile terrain and external image information diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/plugins/lua/luaplugin.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/plugins/lua/luaplugin.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/plugins/lua/luaplugin.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/plugins/lua/luaplugin.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -173,8 +173,14 @@ Properties::const_iterator it = properties.constBegin(); Properties::const_iterator it_end = properties.constEnd(); - for (; it != it_end; ++it) - writer.writeQuotedKeyAndValue(it.key(), toExportValue(it.value())); + for (; it != it_end; ++it) { + QVariant value = toExportValue(it.value()); + + if (it.value().userType() == filePathTypeId()) + value = mMapDir.relativeFilePath(value.toString()); + + writer.writeQuotedKeyAndValue(it.key(), value); + } writer.writeEndTable(); } @@ -384,6 +390,8 @@ writer.writeKeyAndValue("offsetx", offset.x()); writer.writeKeyAndValue("offsety", offset.y()); + writer.writeKeyAndValue("draworder", drawOrderToString(objectGroup->drawOrder())); + writeProperties(writer, objectGroup->properties()); writer.writeStartTable("objects"); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/addpropertydialog.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/addpropertydialog.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/addpropertydialog.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/addpropertydialog.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -44,11 +44,12 @@ QString stringType = typeToName(QVariant::String); // Add possible types from QVariant - mUi->typeBox->addItem(typeToName(QVariant::Bool)); - mUi->typeBox->addItem(typeToName(QVariant::Color)); - mUi->typeBox->addItem(typeToName(QVariant::Double)); - mUi->typeBox->addItem(typeToName(QVariant::Int)); - mUi->typeBox->addItem(stringType); + mUi->typeBox->addItem(typeToName(QVariant::Bool), false); + mUi->typeBox->addItem(typeToName(QVariant::Color), QColor()); + mUi->typeBox->addItem(typeToName(QVariant::Double), 0.0); + mUi->typeBox->addItem(typeToName(filePathTypeId()), QVariant::fromValue(FilePath())); + mUi->typeBox->addItem(typeToName(QVariant::Int), 0); + mUi->typeBox->addItem(stringType, QString()); mUi->buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false); @@ -75,10 +76,14 @@ return mUi->name->text(); } -QVariant::Type AddPropertyDialog::propertyType() const +QVariant AddPropertyDialog::propertyValue() const { - QString typeText = mUi->typeBox->currentText(); - return nameToType(typeText); +#if QT_VERSION >= 0x050200 + return mUi->typeBox->currentData(); +#else + const int currentIndex = mUi->typeBox->currentIndex(); + return mUi->typeBox->itemData(currentIndex); +#endif } void AddPropertyDialog::nameChanged(const QString &text) diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/addpropertydialog.h tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/addpropertydialog.h --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/addpropertydialog.h 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/addpropertydialog.h 2016-05-30 17:22:14.000000000 +0000 @@ -38,7 +38,7 @@ ~AddPropertyDialog(); QString propertyName() const; - QVariant::Type propertyType() const; + QVariant propertyValue() const; private slots: void nameChanged(const QString &text); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/objecttypes.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/objecttypes.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/objecttypes.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/objecttypes.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -62,7 +62,7 @@ it.next(); writer.writeStartElement(QLatin1String("property")); writer.writeAttribute(QLatin1String("name"), it.key()); - writer.writeAttribute(QLatin1String("type"), typeToName(it.value().type())); + writer.writeAttribute(QLatin1String("type"), typeToName(it.value().userType())); if (!it.value().isNull()) writer.writeAttribute(QLatin1String("default"), it.value().toString()); @@ -148,7 +148,7 @@ QVariant defaultValue(atts.value(QLatin1String("default")).toString()); if (!typeName.isEmpty()) { - QVariant::Type type = nameToType(typeName); + int type = nameToType(typeName); if (type != QVariant::Invalid) defaultValue.convert(type); } diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/objecttypeseditor.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/objecttypeseditor.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/objecttypeseditor.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/objecttypeseditor.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -445,7 +445,7 @@ const QString &name = it.key(); const AggregatedPropertyData &data = it.value(); - QtVariantProperty *property = createProperty(data.value().type(), name); + QtVariantProperty *property = createProperty(data.value().userType(), name); property->setValue(data.value()); bool everywhere = data.presenceCount() == selectedRows.size(); @@ -490,7 +490,7 @@ { AddPropertyDialog dialog(window()); if (dialog.exec() == AddPropertyDialog::Accepted) - addProperty(dialog.propertyName(), QVariant(dialog.propertyType())); + addProperty(dialog.propertyName(), QVariant(dialog.propertyValue())); } void ObjectTypesEditor::addProperty(const QString &name, const QVariant &value) diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertiesdock.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertiesdock.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertiesdock.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertiesdock.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -213,10 +213,10 @@ { AddPropertyDialog dialog(mPropertyBrowser); if (dialog.exec() == AddPropertyDialog::Accepted) - addProperty(dialog.propertyName(), dialog.propertyType()); + addProperty(dialog.propertyName(), dialog.propertyValue()); } -void PropertiesDock::addProperty(const QString &name, QVariant::Type type) +void PropertiesDock::addProperty(const QString &name, const QVariant &value) { if (name.isEmpty()) return; @@ -228,7 +228,7 @@ QUndoStack *undoStack = mMapDocument->undoStack(); undoStack->push(new SetProperty(mMapDocument, mMapDocument->currentObjects(), - name, QVariant(type))); + name, value)); } mPropertyBrowser->editCustomProperty(name); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertiesdock.h tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertiesdock.h --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertiesdock.h 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertiesdock.h 2016-05-30 17:22:14.000000000 +0000 @@ -60,7 +60,7 @@ void tilesetFileNameChanged(Tileset *tileset); void addProperty(); - void addProperty(const QString &name, QVariant::Type type); + void addProperty(const QString &name, const QVariant &value); void removeProperty(); void renameProperty(); void renameProperty(const QString &name); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertybrowser.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertybrowser.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertybrowser.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertybrowser.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -295,11 +295,9 @@ mUpdating = true; QVariant value = object->property(name); - QtVariantProperty *property = mVariantManager->addProperty(value.type(), name); + QtVariantProperty *property = createProperty(CustomProperty, value.userType(), name); property->setValue(value); mCustomPropertiesGroup->insertSubProperty(property, precedingProperty); - mPropertyToId.insert(property, CustomProperty); - mNameToProperty.insert(name, property); // Collapse custom color properties, to save space if (value.type() == QVariant::Color) @@ -416,53 +414,53 @@ QtProperty *groupProperty = mGroupManager->addProperty(tr("Map")); QtVariantProperty *orientationProperty = - createProperty(OrientationProperty, - QtVariantPropertyManager::enumTypeId(), - tr("Orientation"), - groupProperty); + addProperty(OrientationProperty, + QtVariantPropertyManager::enumTypeId(), + tr("Orientation"), + groupProperty); orientationProperty->setAttribute(QLatin1String("enumNames"), mOrientationNames); - createProperty(WidthProperty, QVariant::Int, tr("Width"), groupProperty)->setEnabled(false); - createProperty(HeightProperty, QVariant::Int, tr("Height"), groupProperty)->setEnabled(false); - createProperty(TileWidthProperty, QVariant::Int, tr("Tile Width"), groupProperty); - createProperty(TileHeightProperty, QVariant::Int, tr("Tile Height"), groupProperty); + addProperty(WidthProperty, QVariant::Int, tr("Width"), groupProperty)->setEnabled(false); + addProperty(HeightProperty, QVariant::Int, tr("Height"), groupProperty)->setEnabled(false); + addProperty(TileWidthProperty, QVariant::Int, tr("Tile Width"), groupProperty); + addProperty(TileHeightProperty, QVariant::Int, tr("Tile Height"), groupProperty); - createProperty(HexSideLengthProperty, QVariant::Int, tr("Tile Side Length (Hex)"), groupProperty); + addProperty(HexSideLengthProperty, QVariant::Int, tr("Tile Side Length (Hex)"), groupProperty); QtVariantProperty *staggerAxisProperty = - createProperty(StaggerAxisProperty, - QtVariantPropertyManager::enumTypeId(), - tr("Stagger Axis"), - groupProperty); + addProperty(StaggerAxisProperty, + QtVariantPropertyManager::enumTypeId(), + tr("Stagger Axis"), + groupProperty); staggerAxisProperty->setAttribute(QLatin1String("enumNames"), mStaggerAxisNames); QtVariantProperty *staggerIndexProperty = - createProperty(StaggerIndexProperty, - QtVariantPropertyManager::enumTypeId(), - tr("Stagger Index"), - groupProperty); + addProperty(StaggerIndexProperty, + QtVariantPropertyManager::enumTypeId(), + tr("Stagger Index"), + groupProperty); staggerIndexProperty->setAttribute(QLatin1String("enumNames"), mStaggerIndexNames); QtVariantProperty *layerFormatProperty = - createProperty(LayerFormatProperty, - QtVariantPropertyManager::enumTypeId(), - tr("Tile Layer Format"), - groupProperty); + addProperty(LayerFormatProperty, + QtVariantPropertyManager::enumTypeId(), + tr("Tile Layer Format"), + groupProperty); layerFormatProperty->setAttribute(QLatin1String("enumNames"), mLayerFormatNames); QtVariantProperty *renderOrderProperty = - createProperty(RenderOrderProperty, - QtVariantPropertyManager::enumTypeId(), - tr("Tile Render Order"), - groupProperty); + addProperty(RenderOrderProperty, + QtVariantPropertyManager::enumTypeId(), + tr("Tile Render Order"), + groupProperty); renderOrderProperty->setAttribute(QLatin1String("enumNames"), mRenderOrderNames); - createProperty(ColorProperty, QVariant::Color, tr("Background Color"), groupProperty); + addProperty(ColorProperty, QVariant::Color, tr("Background Color"), groupProperty); addProperty(groupProperty); } @@ -479,23 +477,23 @@ // DEFAULT MAP OBJECT PROPERTIES QtProperty *groupProperty = mGroupManager->addProperty(tr("Object")); - createProperty(IdProperty, QVariant::Int, tr("ID"), groupProperty)->setEnabled(false); - createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty); + addProperty(IdProperty, QVariant::Int, tr("ID"), groupProperty)->setEnabled(false); + addProperty(NameProperty, QVariant::String, tr("Name"), groupProperty); QtVariantProperty *typeProperty = - createProperty(TypeProperty, QVariant::String, tr("Type"), groupProperty); + addProperty(TypeProperty, QVariant::String, tr("Type"), groupProperty); typeProperty->setAttribute(QLatin1String("suggestions"), objectTypeNames()); - createProperty(VisibleProperty, QVariant::Bool, tr("Visible"), groupProperty); - createProperty(XProperty, QVariant::Double, tr("X"), groupProperty); - createProperty(YProperty, QVariant::Double, tr("Y"), groupProperty); - createProperty(WidthProperty, QVariant::Double, tr("Width"), groupProperty); - createProperty(HeightProperty, QVariant::Double, tr("Height"), groupProperty); - createProperty(RotationProperty, QVariant::Double, tr("Rotation"), groupProperty); + addProperty(VisibleProperty, QVariant::Bool, tr("Visible"), groupProperty); + addProperty(XProperty, QVariant::Double, tr("X"), groupProperty); + addProperty(YProperty, QVariant::Double, tr("Y"), groupProperty); + addProperty(WidthProperty, QVariant::Double, tr("Width"), groupProperty); + addProperty(HeightProperty, QVariant::Double, tr("Height"), groupProperty); + addProperty(RotationProperty, QVariant::Double, tr("Rotation"), groupProperty); if (!static_cast(mObject)->cell().isEmpty()) { QtVariantProperty *flippingProperty = - createProperty(FlippingProperty, VariantPropertyManager::flagTypeId(), + addProperty(FlippingProperty, VariantPropertyManager::flagTypeId(), tr("Flipping"), groupProperty); flippingProperty->setAttribute(QLatin1String("flagNames"), mFlippingFlagNames); @@ -506,11 +504,11 @@ void PropertyBrowser::addLayerProperties(QtProperty *parent) { - createProperty(NameProperty, QVariant::String, tr("Name"), parent); - createProperty(VisibleProperty, QVariant::Bool, tr("Visible"), parent); + addProperty(NameProperty, QVariant::String, tr("Name"), parent); + addProperty(VisibleProperty, QVariant::Bool, tr("Visible"), parent); QtVariantProperty *opacityProperty = - createProperty(OpacityProperty, QVariant::Double, tr("Opacity"), parent); + addProperty(OpacityProperty, QVariant::Double, tr("Opacity"), parent); opacityProperty->setAttribute(QLatin1String("minimum"), 0.0); opacityProperty->setAttribute(QLatin1String("maximum"), 1.0); opacityProperty->setAttribute(QLatin1String("singleStep"), 0.1); @@ -520,8 +518,8 @@ { QtProperty *groupProperty = mGroupManager->addProperty(tr("Tile Layer")); addLayerProperties(groupProperty); - createProperty(OffsetXProperty, QVariant::Double, tr("Horizontal Offset"), groupProperty); - createProperty(OffsetYProperty, QVariant::Double, tr("Vertical Offset"), groupProperty); + addProperty(OffsetXProperty, QVariant::Double, tr("Horizontal Offset"), groupProperty); + addProperty(OffsetYProperty, QVariant::Double, tr("Vertical Offset"), groupProperty); addProperty(groupProperty); } @@ -529,16 +527,16 @@ { QtProperty *groupProperty = mGroupManager->addProperty(tr("Object Layer")); addLayerProperties(groupProperty); - createProperty(OffsetXProperty, QVariant::Double, tr("Horizontal Offset"), groupProperty); - createProperty(OffsetYProperty, QVariant::Double, tr("Vertical Offset"), groupProperty); + addProperty(OffsetXProperty, QVariant::Double, tr("Horizontal Offset"), groupProperty); + addProperty(OffsetYProperty, QVariant::Double, tr("Vertical Offset"), groupProperty); - createProperty(ColorProperty, QVariant::Color, tr("Color"), groupProperty); + addProperty(ColorProperty, QVariant::Color, tr("Color"), groupProperty); QtVariantProperty *drawOrderProperty = - createProperty(DrawOrderProperty, - QtVariantPropertyManager::enumTypeId(), - tr("Drawing Order"), - groupProperty); + addProperty(DrawOrderProperty, + QtVariantPropertyManager::enumTypeId(), + tr("Drawing Order"), + groupProperty); drawOrderProperty->setAttribute(QLatin1String("enumNames"), mDrawOrderNames); @@ -550,16 +548,16 @@ QtProperty *groupProperty = mGroupManager->addProperty(tr("Image Layer")); addLayerProperties(groupProperty); - QtVariantProperty *imageSourceProperty = createProperty(ImageSourceProperty, - VariantPropertyManager::filePathTypeId(), - tr("Image"), groupProperty); + QtVariantProperty *imageSourceProperty = addProperty(ImageSourceProperty, + filePathTypeId(), + tr("Image"), groupProperty); imageSourceProperty->setAttribute(QLatin1String("filter"), Utils::readableImageFormatsFilter()); - createProperty(ColorProperty, QVariant::Color, tr("Transparent Color"), groupProperty); - createProperty(OffsetXProperty, QVariant::Double, tr("Horizontal Offset"), groupProperty); - createProperty(OffsetYProperty, QVariant::Double, tr("Vertical Offset"), groupProperty); + addProperty(ColorProperty, QVariant::Color, tr("Transparent Color"), groupProperty); + addProperty(OffsetXProperty, QVariant::Double, tr("Horizontal Offset"), groupProperty); + addProperty(OffsetYProperty, QVariant::Double, tr("Vertical Offset"), groupProperty); addProperty(groupProperty); } @@ -570,7 +568,7 @@ QtProperty *groupProperty = mGroupManager->addProperty(tr("Tileset")); if (tileset->isExternal()) { - auto property = createProperty(FileNameProperty, VariantPropertyManager::filePathTypeId(), tr("Filename"), groupProperty); + auto property = addProperty(FileNameProperty, filePathTypeId(), tr("Filename"), groupProperty); QString filter = QCoreApplication::translate("MainWindow", "All Files (*)"); filter += QLatin1String(";;"); @@ -580,23 +578,23 @@ property->setAttribute(QStringLiteral("filter"), helper.filter()); } - createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty); - createProperty(TileOffsetProperty, QVariant::Point, tr("Drawing Offset"), groupProperty); + addProperty(NameProperty, QVariant::String, tr("Name"), groupProperty); + addProperty(TileOffsetProperty, QVariant::Point, tr("Drawing Offset"), groupProperty); - QtVariantProperty *columnsProperty = createProperty(ColumnCountProperty, QVariant::Int, tr("Columns"), groupProperty); + QtVariantProperty *columnsProperty = addProperty(ColumnCountProperty, QVariant::Int, tr("Columns"), groupProperty); columnsProperty->setAttribute(QLatin1String("minimum"), 1); // Next properties we should add only for non 'Collection of Images' tilesets if (!tileset->isCollection()) { QtVariantProperty *parametersProperty = - createProperty(TilesetImageParametersProperty, VariantPropertyManager::tilesetParametersTypeId(), tr("Image"), groupProperty); + addProperty(TilesetImageParametersProperty, VariantPropertyManager::tilesetParametersTypeId(), tr("Image"), groupProperty); - QtVariantProperty *imageSourceProperty = createProperty(ImageSourceProperty, QVariant::String, tr("Source"), parametersProperty); - QtVariantProperty *tileWidthProperty = createProperty(TileWidthProperty, QVariant::Int, tr("Tile Width"), parametersProperty); - QtVariantProperty *tileHeightProperty = createProperty(TileHeightProperty, QVariant::Int, tr("Tile Height"), parametersProperty); - QtVariantProperty *marginProperty = createProperty(MarginProperty, QVariant::Int, tr("Margin"), parametersProperty); - QtVariantProperty *spacingProperty = createProperty(SpacingProperty, QVariant::Int, tr("Spacing"), parametersProperty); - QtVariantProperty *colorProperty = createProperty(ColorProperty, QVariant::Color, tr("Transparent Color"), parametersProperty); + QtVariantProperty *imageSourceProperty = addProperty(ImageSourceProperty, QVariant::String, tr("Source"), parametersProperty); + QtVariantProperty *tileWidthProperty = addProperty(TileWidthProperty, QVariant::Int, tr("Tile Width"), parametersProperty); + QtVariantProperty *tileHeightProperty = addProperty(TileHeightProperty, QVariant::Int, tr("Tile Height"), parametersProperty); + QtVariantProperty *marginProperty = addProperty(MarginProperty, QVariant::Int, tr("Margin"), parametersProperty); + QtVariantProperty *spacingProperty = addProperty(SpacingProperty, QVariant::Int, tr("Spacing"), parametersProperty); + QtVariantProperty *colorProperty = addProperty(ColorProperty, QVariant::Color, tr("Transparent Color"), parametersProperty); // These properties can't be directly edited. To change the parameters, // the TilesetParametersEdit is used. @@ -613,22 +611,22 @@ void PropertyBrowser::addTileProperties() { QtProperty *groupProperty = mGroupManager->addProperty(tr("Tile")); - createProperty(IdProperty, QVariant::Int, tr("ID"), groupProperty)->setEnabled(false); - createProperty(WidthProperty, QVariant::Int, tr("Width"), groupProperty)->setEnabled(false); - createProperty(HeightProperty, QVariant::Int, tr("Height"), groupProperty)->setEnabled(false); - - QtVariantProperty *probabilityProperty = createProperty(TileProbabilityProperty, - QVariant::Double, - tr("Probability"), - groupProperty); + addProperty(IdProperty, QVariant::Int, tr("ID"), groupProperty)->setEnabled(false); + addProperty(WidthProperty, QVariant::Int, tr("Width"), groupProperty)->setEnabled(false); + addProperty(HeightProperty, QVariant::Int, tr("Height"), groupProperty)->setEnabled(false); + + QtVariantProperty *probabilityProperty = addProperty(TileProbabilityProperty, + QVariant::Double, + tr("Probability"), + groupProperty); probabilityProperty->setAttribute(QLatin1String("decimals"), 3); probabilityProperty->setToolTip(tr("Relative chance this tile will be picked")); const Tile *tile = static_cast(mObject); if (!tile->imageSource().isEmpty()) { - QtVariantProperty *imageSourceProperty = createProperty(ImageSourceProperty, - VariantPropertyManager::filePathTypeId(), - tr("Image"), groupProperty); + QtVariantProperty *imageSourceProperty = addProperty(ImageSourceProperty, + filePathTypeId(), + tr("Image"), groupProperty); imageSourceProperty->setAttribute(QLatin1String("filter"), Utils::readableImageFormatsFilter()); @@ -640,7 +638,7 @@ void PropertyBrowser::addTerrainProperties() { QtProperty *groupProperty = mGroupManager->addProperty(tr("Terrain")); - createProperty(NameProperty, QVariant::String, tr("Name"), groupProperty); + addProperty(NameProperty, QVariant::String, tr("Name"), groupProperty); addProperty(groupProperty); } @@ -871,12 +869,12 @@ switch (id) { case ImageSourceProperty: { - const QString imageSource = val.toString(); + const FilePath imageSource = val.value(); const QColor &color = imageLayer->transparentColor(); undoStack->push(new ChangeImageLayerProperties(mMapDocument, imageLayer, color, - imageSource)); + imageSource.absolutePath)); break; } case ColorProperty: { @@ -900,9 +898,9 @@ switch (id) { case FileNameProperty: { - QString fileName = val.toString(); + FilePath filePath = val.value(); QString error; - SharedTileset newTileset = Tiled::readTileset(fileName, &error); + SharedTileset newTileset = Tiled::readTileset(filePath.absolutePath, &error); if (!newTileset) { QMessageBox::critical(window(), tr("Error Reading Tileset"), error); return; @@ -945,10 +943,12 @@ mMapDocument->selectedTiles(), val.toFloat())); break; - case ImageSourceProperty: + case ImageSourceProperty: { + const FilePath filePath = val.value(); undoStack->push(new ChangeTileImageSource(mMapDocument, - tile, val.toString())); + tile, filePath.absolutePath)); break; + } default: break; } @@ -967,9 +967,11 @@ } } +/** + * @warning This function does not add the property to the view. + */ QtVariantProperty *PropertyBrowser::createProperty(PropertyId id, int type, - const QString &name, - QtProperty *parent) + const QString &name) { QtVariantProperty *property = mVariantManager->addProperty(type, name); if (!property) { @@ -982,15 +984,28 @@ if (type == QVariant::String && id == CustomProperty) property->setAttribute(QLatin1String("multiline"), true); - parent->addSubProperty(property); mPropertyToId.insert(property, id); if (id != CustomProperty) { Q_ASSERT(!mIdToProperty.contains(id)); mIdToProperty.insert(id, property); } else { + Q_ASSERT(!mNameToProperty.contains(name)); mNameToProperty.insert(name, property); + } + + return property; +} + +QtVariantProperty *PropertyBrowser::addProperty(PropertyId id, int type, + const QString &name, + QtProperty *parent) +{ + QtVariantProperty *property = createProperty(id, type, name); + parent->addSubProperty(property); + + if (id == CustomProperty) { // Collapse custom color properties, to save space if (type == QVariant::Color) setExpanded(items(property).first(), false); @@ -1111,7 +1126,7 @@ } case Layer::ImageLayerType: const ImageLayer *imageLayer = static_cast(layer); - mIdToProperty[ImageSourceProperty]->setValue(imageLayer->imageSource()); + mIdToProperty[ImageSourceProperty]->setValue(QVariant::fromValue(FilePath { imageLayer->imageSource() })); mIdToProperty[ColorProperty]->setValue(imageLayer->transparentColor()); break; } @@ -1122,7 +1137,7 @@ const bool external = tileset->isExternal(); if (QtVariantProperty *fileNameProperty = mIdToProperty.value(FileNameProperty)) - fileNameProperty->setValue(tileset->fileName()); + fileNameProperty->setValue(QVariant::fromValue(FilePath { tileset->fileName() })); mIdToProperty[NameProperty]->setValue(tileset->name()); mIdToProperty[TileOffsetProperty]->setValue(tileset->tileOffset()); @@ -1136,7 +1151,7 @@ EmbeddedTileset embeddedTileset(mMapDocument, tileset); mIdToProperty[TilesetImageParametersProperty]->setValue(QVariant::fromValue(embeddedTileset)); - mIdToProperty[ImageSourceProperty]->setValue(tileset->imageSource()); + mIdToProperty[ImageSourceProperty]->setValue(QVariant::fromValue(FilePath { tileset->imageSource() })); mIdToProperty[TileWidthProperty]->setValue(tileset->tileWidth()); mIdToProperty[TileHeightProperty]->setValue(tileset->tileHeight()); mIdToProperty[MarginProperty]->setValue(tileset->margin()); @@ -1214,10 +1229,10 @@ while (it.hasNext()) { it.next(); - QtVariantProperty *property = createProperty(CustomProperty, - it.value().type(), - it.key(), - mCustomPropertiesGroup); + QtVariantProperty *property = addProperty(CustomProperty, + it.value().userType(), + it.key(), + mCustomPropertiesGroup); property->setValue(it.value()); updatePropertyColor(it.key()); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertybrowser.h tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertybrowser.h --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/propertybrowser.h 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/propertybrowser.h 2016-05-30 17:22:14.000000000 +0000 @@ -166,8 +166,13 @@ QtVariantProperty *createProperty(PropertyId id, int type, - const QString &name, - QtProperty *parent); + const QString &name); + + using QtTreePropertyBrowser::addProperty; + QtVariantProperty *addProperty(PropertyId id, + int type, + const QString &name, + QtProperty *parent); void addProperties(); void removeProperties(); diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/varianteditorfactory.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/varianteditorfactory.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/varianteditorfactory.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/varianteditorfactory.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -99,15 +99,16 @@ { const int type = manager->propertyType(property); - if (type == VariantPropertyManager::filePathTypeId()) { + if (type == filePathTypeId()) { FileEdit *editor = new FileEdit(parent); - editor->setFilePath(manager->value(property).toString()); + FilePath filePath = manager->value(property).value(); + editor->setFilePath(filePath.absolutePath); editor->setFilter(manager->attributeValue(property, QLatin1String("filter")).toString()); mCreatedFileEdits[property].append(editor); mFileEditToProperty[editor] = property; - connect(editor, SIGNAL(filePathChanged(const QString &)), - this, SLOT(fileEditFilePathChanged(const QString &))); + connect(editor, &FileEdit::filePathChanged, + this, &VariantEditorFactory::fileEditFilePathChanged); connect(editor, SIGNAL(destroyed(QObject *)), this, SLOT(slotEditorDestroyed(QObject *))); @@ -181,8 +182,10 @@ const QVariant &value) { if (mCreatedFileEdits.contains(property)) { - for (FileEdit *edit : mCreatedFileEdits[property]) - edit->setFilePath(value.toString()); + for (FileEdit *edit : mCreatedFileEdits[property]) { + FilePath filePath = value.value(); + edit->setFilePath(filePath.absolutePath); + } } else if (mCreatedTilesetEdits.contains(property)) { for (TilesetParametersEdit *edit : mCreatedTilesetEdits[property]) @@ -216,7 +219,7 @@ QtVariantPropertyManager *manager = propertyManager(property); if (!manager) return; - manager->setValue(property, value); + manager->setValue(property, QVariant::fromValue(FilePath { value })); } } diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/variantpropertymanager.cpp tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/variantpropertymanager.cpp --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/variantpropertymanager.cpp 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/variantpropertymanager.cpp 2016-05-30 17:22:14.000000000 +0000 @@ -29,7 +29,6 @@ namespace Tiled { namespace Internal { -class FilePathPropertyType {}; class TilesetParametersPropertyType {}; } // namespace Tiled @@ -37,7 +36,6 @@ // Needs to be up here rather than at the bottom of the file to make a // static_assert in qMetaTypeId work (as of C++11) -Q_DECLARE_METATYPE(Tiled::Internal::FilePathPropertyType) Q_DECLARE_METATYPE(Tiled::Internal::TilesetParametersPropertyType) @@ -117,11 +115,6 @@ return QtVariantPropertyManager::attributeValue(property, attribute); } -int VariantPropertyManager::filePathTypeId() -{ - return qMetaTypeId(); -} - int VariantPropertyManager::tilesetParametersTypeId() { return qMetaTypeId(); @@ -133,8 +126,10 @@ QVariant value = mValues[property].value; int typeId = propertyType(property); - if (typeId == filePathTypeId()) - return QFileInfo(value.toString()).fileName(); + if (typeId == filePathTypeId()) { + FilePath filePath = value.value(); + return QFileInfo(filePath.absolutePath).fileName(); + } if (typeId == tilesetParametersTypeId()) { EmbeddedTileset embeddedTileset = value.value(); @@ -162,7 +157,7 @@ int typeId = propertyType(property); if (typeId == filePathTypeId()) - filePath = value.toString(); + filePath = value.value().absolutePath; if (typeId == tilesetParametersTypeId()) { EmbeddedTileset embeddedTileset = value.value(); @@ -170,9 +165,8 @@ filePath = embeddedTileset.tileset()->imageSource(); } - // This assumes the file path is an image reference, which is currently - // always the case, but it won't be when external tileset references - // are added to the property browser. + // TODO: This assumes the file path is an image reference. It should be + // replaced with a more generic icon. if (filePath.isEmpty() || !QFile::exists(filePath)) return QIcon::fromTheme(QLatin1String("image-missing"), mImageMissingIcon); else diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/variantpropertymanager.h tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/variantpropertymanager.h --- tiled-daily-0+git20160525~19~ubuntu15.10.1/src/tiled/variantpropertymanager.h 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/src/tiled/variantpropertymanager.h 2016-05-30 17:22:14.000000000 +0000 @@ -49,7 +49,6 @@ QVariant attributeValue(const QtProperty *property, const QString &attribute) const override; - static int filePathTypeId(); static int tilesetParametersTypeId(); public slots: diff -Nru tiled-daily-0+git20160525~19~ubuntu15.10.1/translations/tiled_nl.ts tiled-daily-0+git20160530~19~ubuntu15.10.1/translations/tiled_nl.ts --- tiled-daily-0+git20160525~19~ubuntu15.10.1/translations/tiled_nl.ts 2016-05-25 23:48:34.000000000 +0000 +++ tiled-daily-0+git20160530~19~ubuntu15.10.1/translations/tiled_nl.ts 2016-05-30 17:22:14.000000000 +0000 @@ -2250,7 +2250,7 @@ F - V + F @@ -2596,7 +2596,7 @@ E - W + E @@ -2718,7 +2718,7 @@ W - + W @@ -3877,7 +3877,7 @@ B - S + B