Skip to content
Extraits de code Groupes Projets
Valider 0e1eba18 rédigé par Elliu's avatar Elliu
Parcourir les fichiers

Properly keep SubAss key on save even if have a internal ass

parent 5259947b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #3212 réussi
...@@ -130,10 +130,12 @@ class AssSubDocument final : public CRTPSubDocument<AssDocumentType, AssSubDocum ...@@ -130,10 +130,12 @@ class AssSubDocument final : public CRTPSubDocument<AssDocumentType, AssSubDocum
const QStringList &suffixList = Vivy::Utils::assFileSuffix; const QStringList &suffixList = Vivy::Utils::assFileSuffix;
public: 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()); auto ret = std::unique_ptr<AssSubDocument>(new AssSubDocument());
ret->logDebug() << "Init ASS subdocument from internal"; ret->logDebug() << "Init ASS subdocument from internal";
ret->filePath = baseAss;
try { try {
ret->initFromInternal(internal); // May throw ret->initFromInternal(internal); // May throw
......
...@@ -18,6 +18,7 @@ AssSubDocument::initFromPath(const QString &path) ...@@ -18,6 +18,7 @@ AssSubDocument::initFromPath(const QString &path)
void void
AssSubDocument::initFromInternal(const QJsonValue &internal) AssSubDocument::initFromInternal(const QJsonValue &internal)
{ {
internalAss = true;
styles.clear(); styles.clear();
lines.clear(); lines.clear();
assFactory = new Ass::AssFactory(internal); assFactory = new Ass::AssFactory(internal);
......
...@@ -80,18 +80,8 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs ...@@ -80,18 +80,8 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs
!video.isUndefined() && !self->loadSubDocument(video.toString(), Capabilities::VideoAble)) !video.isUndefined() && !self->loadSubDocument(video.toString(), Capabilities::VideoAble))
throw std::runtime_error("Failed to load video sub document"); 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 * 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) * (e.g. a "reference" ass and the vivy ass)
*/ */
...@@ -100,7 +90,9 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs ...@@ -100,7 +90,9 @@ VivyDocument::loadSaveJsonDocumentFile_ALPHA(VivyDocument *const self, const QJs
// ASS is inside Vivy document // ASS is inside Vivy document
if (QJsonValue internalAssSource = json[KeySubDocuments][KeyInternalAssSource]; if (QJsonValue internalAssSource = json[KeySubDocuments][KeyInternalAssSource];
!internalAssSource.isUndefined() && internalAssSource.isArray()) { !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"); throw std::runtime_error("Failed to load ASS sub document");
} }
} }
...@@ -223,7 +215,7 @@ VivyDocument::loadSubDocument(const QString &subName, VivyDocument::Capabilities ...@@ -223,7 +215,7 @@ VivyDocument::loadSubDocument(const QString &subName, VivyDocument::Capabilities
} }
bool bool
VivyDocument::loadSubDocument(const QJsonValue &internalAss, VivyDocument::loadSubDocument(const QJsonValue &internalAss, const QString &baseAss,
VivyDocument::Capabilities asType) noexcept VivyDocument::Capabilities asType) noexcept
{ {
logDebug() << "ASS sub-doc: Trying to open file internal ASS"; logDebug() << "ASS sub-doc: Trying to open file internal ASS";
...@@ -234,7 +226,7 @@ VivyDocument::loadSubDocument(const QJsonValue &internalAss, ...@@ -234,7 +226,7 @@ VivyDocument::loadSubDocument(const QJsonValue &internalAss,
assDocument.reset(); assDocument.reset();
} }
assDocument = AssSubDocument::fromInternal(internalAss); assDocument = AssSubDocument::fromInternal(internalAss, baseAss);
if (assDocument) if (assDocument)
addDocumentType(AssAble); addDocumentType(AssAble);
} }
......
...@@ -83,7 +83,7 @@ public: ...@@ -83,7 +83,7 @@ public:
void save() override; void save() override;
bool loadSubDocument(const QString &) noexcept; bool loadSubDocument(const QString &) noexcept;
bool loadSubDocument(const QString &, Capabilities) noexcept; bool loadSubDocument(const QString &, Capabilities) noexcept;
bool loadSubDocument(const QJsonValue &, VivyDocument::Capabilities) noexcept; bool loadSubDocument(const QJsonValue &, const QString &, VivyDocument::Capabilities) noexcept;
// Getters // Getters
std::shared_ptr<AudioSubDocument> getAudioSubDocument() const noexcept; std::shared_ptr<AudioSubDocument> getAudioSubDocument() const noexcept;
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter