The format version in one place and the layer context menu (12.10a)
This commit is contained in:
1 parent
9ac3b1b81c
commit
fc076de71d
15 files changed
+700
-63
No files matched your search
@@ -62,7 +62,7 @@ void validate(const ProjectManifest &manifest)
|
||||
{
|
||||
if (manifest.format != QLatin1String("com.compositor.project"))
|
||||
throw ProjectError(ProjectError::Kind::invalid);
|
||||
if (manifest.version < 1 || manifest.version > 9)
|
||||
if (!ProjectManifest::supports(manifest.version))
|
||||
throw ProjectError::unsupportedVersion(manifest.version);
|
||||
if (manifest.colorSpace != QLatin1String("sRGB"))
|
||||
throw ProjectError(ProjectError::Kind::invalid);
|
||||
@@ -256,7 +256,10 @@ ProjectError::ProjectError(Kind kind) : ProjectError(kind, std::nullopt, descrip
|
||||
ProjectError ProjectError::unsupportedVersion(qint64 version)
|
||||
{
|
||||
return ProjectError(Kind::version, version,
|
||||
QStringLiteral("This project uses format version %1. This app supports versions 1–9.").arg(version));
|
||||
QStringLiteral("This project uses format version %1. This app supports versions %2–%3.")
|
||||
.arg(version)
|
||||
.arg(ProjectManifest::supported.first)
|
||||
.arg(ProjectManifest::supported.second));
|
||||
}
|
||||
|
||||
ProjectError::ProjectError(Kind kind, std::optional<qint64> version, const QString &description)
|
||||
@@ -332,7 +335,7 @@ ProjectSnapshot ProjectStore::load(const QString &path)
|
||||
const auto [format, version] = ProjectManifest::header(metadata);
|
||||
if (format != QLatin1String("com.compositor.project"))
|
||||
throw ProjectError(ProjectError::Kind::invalid);
|
||||
if (version < 1 || version > 9)
|
||||
if (!ProjectManifest::supports(version))
|
||||
throw ProjectError::unsupportedVersion(version);
|
||||
const ProjectManifest manifest = ProjectManifest::decoded(metadata);
|
||||
validate(manifest);
|
||||
|
||||
@@ -50,9 +50,13 @@ struct ProjectLayerRecord {
|
||||
QString uuidString(const QUuid &id);
|
||||
|
||||
struct ProjectManifest {
|
||||
// Swift's current and supported: what saves write, what loads accept.
|
||||
static constexpr qint64 current = 9;
|
||||
static constexpr std::pair<qint64, qint64> supported{1, current};
|
||||
static bool supports(qint64 version) { return version >= supported.first && version <= supported.second; }
|
||||
QString format = QStringLiteral("com.compositor.project");
|
||||
// Swift's Int: a wild number must reach validation whole.
|
||||
qint64 version = 9;
|
||||
qint64 version = current;
|
||||
QString colorSpace = QStringLiteral("sRGB");
|
||||
// Version-1 projects carry none: 72 pixels per inch.
|
||||
std::optional<double> resolution = std::nullopt;
|
||||
|
||||
Reference in new issue
Block a user