diff --git a/src/Lib/Ass/Line.cc b/src/Lib/Ass/Line.cc index e8d8476d592b136b3a51f23226acb921aa9c1657..5188678d6740670cc6ff68299fd5a5b8d6f1553f 100644 --- a/src/Lib/Ass/Line.cc +++ b/src/Lib/Ass/Line.cc @@ -177,6 +177,16 @@ Line::getContentAsText() const noexcept return ___contentAsText; } +QString +Line::getLineAsText() const noexcept +{ + return QString::asprintf("%s: %d,%s,%s,", "Dialogue", layer, "0:00:00.00", "0:00:00.00") + + styleProperties.name + + QString::asprintf(",%s,%d,%d,%d,%s,", "", styleProperties.marginL, + styleProperties.marginR, styleProperties.marginV, "karaoke") + + ___contentAsText; +} + void Line::setContent(const QVector<Syl> &syls) noexcept { diff --git a/src/Lib/Ass/Line.hh b/src/Lib/Ass/Line.hh index 55af684747441c235176209e2f8b860ddfdd243d..48dfd1d835996b89a294f600c6d041781989985c 100644 --- a/src/Lib/Ass/Line.hh +++ b/src/Lib/Ass/Line.hh @@ -53,6 +53,7 @@ public: quint64 getStart() const noexcept; quint64 getEnd() const noexcept; QString getContentAsText() const noexcept; + QString getLineAsText() const noexcept; private: void initSylFromString(const QString &) noexcept; diff --git a/src/Lib/Ass/StyleProperties.hh b/src/Lib/Ass/StyleProperties.hh index eb7c04cdeaa10b215ef46a95a80ebe119ebcf5f0..d01680a297640f9f2bbdbbd42a5884ea59584264 100644 --- a/src/Lib/Ass/StyleProperties.hh +++ b/src/Lib/Ass/StyleProperties.hh @@ -8,6 +8,8 @@ namespace Vivy::Ass // Overrides some properties of the Style of an Ass::Line, Ass::Char, Ass::Syl struct StyleProperties final { + QString name{}; + // Colors QColor primaryColor{ Color::defaultValue }, secondaryColor{ Color::defaultValue }, outlineColor{ Color::defaultValue }, backColor{ Color::defaultValue }; diff --git a/src/Lib/Document/CRTPSubDocument.hh b/src/Lib/Document/CRTPSubDocument.hh index 626ea517d86b1e8ad43dc7c00d16d93559d87097..7aea6cf7871c4a7caf0167ac79f998ad16e38de6 100644 --- a/src/Lib/Document/CRTPSubDocument.hh +++ b/src/Lib/Document/CRTPSubDocument.hh @@ -138,6 +138,7 @@ public: QString getElementName() const noexcept; QJsonDocument getProperties() const noexcept; Ass::AssFactory *getFactory() noexcept; + QJsonArray getInternalAss() noexcept; const QVector<Ass::LinePtr> &getLines() const noexcept; const QVector<Ass::StylePtr> &getStyles() const noexcept; diff --git a/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc b/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc index 9ad4624a59de91585fb7c817ff314e8acdd084d1..9f55a6f3a722b98accb463def72b8ba59e1a7af2 100644 --- a/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc +++ b/src/Lib/Document/CRTPSubDocument/AssSubDocument.cc @@ -52,3 +52,15 @@ AssSubDocument::getFactory() noexcept { return assFactory; } + +QJsonArray +AssSubDocument::getInternalAss() noexcept +{ + QJsonArray ret; + + for (int i = 0; i < lines.size(); i++) { + ret.append(lines[i]->getLineAsText()); + } + + return ret; +} diff --git a/src/Lib/Document/VivyDocument.cc b/src/Lib/Document/VivyDocument.cc index e352417277d760a2dfd26b3bf42d0caf6ab4f4bd..baf0113ea79a285a7a690b4ddcd3e874d9f38e8d 100644 --- a/src/Lib/Document/VivyDocument.cc +++ b/src/Lib/Document/VivyDocument.cc @@ -131,12 +131,10 @@ VivyDocument::getSaveJsonDocumentFile() const if (documentType & Capabilities::AssAble) { // ASS is inside Vivy document - if ((assDocument->getFilePath() == getName())) { - subDocumentJson.insert(KeyInternalAssSource, true); - throw std::runtime_error("Unsupported save of internal ASS for now"); - } + if ((assDocument->getFilePath() == getName())) + subDocumentJson.insert(KeyInternalAssSource, assDocument->getInternalAss()); - // ASS is ints own ASS file + // ASS is in its own ASS file else subDocumentJson.insert(KeySubAss, assDocument->getFilePath()); }