diff --git a/src/Lib/Document/CRTPSubDocument.hh b/src/Lib/Document/CRTPSubDocument.hh index 96a2607b12abe7a5299250fe90b955aa9ba75629..169c10961f5aa7ba9c784f18f5e31456d0086c48 100644 --- a/src/Lib/Document/CRTPSubDocument.hh +++ b/src/Lib/Document/CRTPSubDocument.hh @@ -130,10 +130,12 @@ class AssSubDocument final : public CRTPSubDocument<AssDocumentType, AssSubDocum const QStringList &suffixList = Vivy::Utils::assFileSuffix; public: - static std::unique_ptr<AssSubDocument> fromInternal(const QJsonValue &internal) noexcept + static std::unique_ptr<AssSubDocument> fromInternal(const QJsonValue &internal, + const QString &baseAss) noexcept { auto ret = std::unique_ptr<AssSubDocument>(new AssSubDocument()); ret->logDebug() << "Init ASS subdocument from internal"; + ret->filePath = baseAss; try { ret->initFromInternal(internal); // May throw diff --git a/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc b/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc index 96366e4a6ac7b2d7b0a4ddea82b3eb9323014f37..1cd2d3cdd06c76bf03aa097525d6ff5e7c2fddf1 100644 --- a/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc +++ b/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc @@ -18,6 +18,7 @@ AssSubDocument::initFromPath(const QString &path) void AssSubDocument::initFromInternal(const QJsonValue &internal) { + internalAss = true; styles.clear(); lines.clear(); assFactory = new Ass::AssFactory(internal); diff --git a/src/Lib/Document/VivyDocument.cc b/src/Lib/Document/VivyDocument.cc index 8dc4064c017be92d214df16c30e65e9320c3f269..b04f3e41ec00a1459fd39ae1fbfa817abd7c2aca 100644 --- a/src/Lib/Document/VivyDocument.cc +++ b/src/Lib/Document/VivyDocument.cc @@ -80,18 +80,8 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs !video.isUndefined() && !self->loadSubDocument(video.toString(), Capabilities::VideoAble)) throw std::runtime_error("Failed to load video sub document"); - if (QJsonValue internalAssSource = json[KeySubDocuments][KeyInternalAssSource]; - !internalAssSource.isUndefined() && internalAssSource.toBool()) { - // ASS is inside Vivy document - throw std::runtime_error("The internal ASS feature is not supported for now"); - } else if (QJsonValue ass = json[KeySubDocuments][KeySubAss]; !ass.isUndefined()) { - // ASS in its own ASS file - if (!self->loadSubDocument(ass.toString(), Capabilities::AssAble)) - throw std::runtime_error("Failed to load ASS sub document"); - } - /* - * TODO: for now, if there is an internal ass we use it and ignore the SubAss file + * TODO: for now, if there is an internal ass we use it and "ignore" the SubAss file * In the future, both should be loaded to allow the user to switch between the 2 * (e.g. a "reference" ass and the vivy ass) */ @@ -100,7 +90,9 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs // ASS is inside Vivy document if (QJsonValue internalAssSource = json[KeySubDocuments][KeyInternalAssSource]; !internalAssSource.isUndefined() && internalAssSource.isArray()) { - if (!self->loadSubDocument(internalAssSource, Capabilities::AssAble)) { + if (!self->loadSubDocument(internalAssSource, + json[KeySubDocuments][KeySubAss].toString(), + Capabilities::AssAble)) { throw std::runtime_error("Failed to load ASS sub document"); } } @@ -223,7 +215,7 @@ VivyDocument::loadSubDocument(const QString &subName, VivyDocument::Capabilities } bool -VivyDocument::loadSubDocument(const QJsonValue &internalAss, +VivyDocument::loadSubDocument(const QJsonValue &internalAss, const QString &baseAss, VivyDocument::Capabilities asType) noexcept { logDebug() << "ASS sub-doc: Trying to open file internal ASS"; @@ -234,7 +226,7 @@ VivyDocument::loadSubDocument(const QJsonValue &internalAss, assDocument.reset(); } - assDocument = AssSubDocument::fromInternal(internalAss); + assDocument = AssSubDocument::fromInternal(internalAss, baseAss); if (assDocument) addDocumentType(AssAble); } diff --git a/src/Lib/Document/VivyDocument.hh b/src/Lib/Document/VivyDocument.hh index e2f4d25bb9cf61dafe438881ae73cd37228070f2..4582bf0c22f8047cba4d306ecf6751f5230d2772 100644 --- a/src/Lib/Document/VivyDocument.hh +++ b/src/Lib/Document/VivyDocument.hh @@ -83,7 +83,7 @@ public: void save() override; bool loadSubDocument(const QString &) noexcept; bool loadSubDocument(const QString &, Capabilities) noexcept; - bool loadSubDocument(const QJsonValue &, VivyDocument::Capabilities) noexcept; + bool loadSubDocument(const QJsonValue &, const QString &, VivyDocument::Capabilities) noexcept; // Getters std::shared_ptr<AudioSubDocument> getAudioSubDocument() const noexcept;