|
|
|
|
@ -21,6 +21,7 @@ |
|
|
|
|
|
|
|
|
|
#include <core/action.h> |
|
|
|
|
#include <core/movie.h> |
|
|
|
|
#include <core/sound.h> |
|
|
|
|
#include <core/annotations.h> |
|
|
|
|
|
|
|
|
|
using namespace Epub; |
|
|
|
|
@ -197,9 +198,12 @@ QTextDocument* Converter::convert( const QString &fileName ) |
|
|
|
|
// if the background color of the document is non-white it will be handled by QTextDocument::setHtml()
|
|
|
|
|
bool firstPage = true; |
|
|
|
|
QVector<Okular::MovieAnnotation *> movieAnnots; |
|
|
|
|
QVector<Okular::SoundAction *> soundActions; |
|
|
|
|
const QSize videoSize(320, 240); |
|
|
|
|
do{ |
|
|
|
|
movieAnnots.clear(); |
|
|
|
|
soundActions.clear(); |
|
|
|
|
|
|
|
|
|
if(epub_it_get_curr(it)) { |
|
|
|
|
const QString link = QString::fromUtf8(epub_it_get_curr_url(it)); |
|
|
|
|
mTextDocument->setCurrentSubDocument(link); |
|
|
|
|
@ -257,11 +261,28 @@ QTextDocument* Converter::convert( const QString &fileName ) |
|
|
|
|
movieAnnots.push_back(annot); |
|
|
|
|
QDomDocument tempDoc; |
|
|
|
|
tempDoc.setContent(QString("<pre><video></video></pre>")); |
|
|
|
|
qDebug() << "replacing"; |
|
|
|
|
videoTags.at(i).parentNode().replaceChild(tempDoc.documentElement(),videoTags.at(i)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//handle embedded audio
|
|
|
|
|
QDomNodeList audioTags = dom.elementsByTagName("audio"); |
|
|
|
|
if(!audioTags.isEmpty()) { |
|
|
|
|
for (int i = 0; i < audioTags.size(); ++i) { |
|
|
|
|
QString lnk = audioTags.at(i).toElement().attribute("src"); |
|
|
|
|
|
|
|
|
|
Okular::Sound *sound = new Okular::Sound(mTextDocument->loadResource( |
|
|
|
|
EpubDocument::AudioResource, QUrl(lnk)).toByteArray()); |
|
|
|
|
|
|
|
|
|
Okular::SoundAction *soundAction = new Okular::SoundAction(1.0,true,true,false,sound); |
|
|
|
|
soundActions.push_back(soundAction); |
|
|
|
|
|
|
|
|
|
QDomDocument tempDoc; |
|
|
|
|
tempDoc.setContent(QString("<pre><audio></audio></pre>")); |
|
|
|
|
audioTags.at(i).parentNode().replaceChild(tempDoc.documentElement(),audioTags.at(i)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
htmlContent = dom.toString(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -297,6 +318,19 @@ QTextDocument* Converter::convert( const QString &fileName ) |
|
|
|
|
csr.movePosition(QTextCursor::NextWord); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
csr.movePosition(QTextCursor::Start); |
|
|
|
|
index = 0; |
|
|
|
|
const QString keyToSearch("<audio></audio>"); |
|
|
|
|
while( !(csr = mTextDocument->find(keyToSearch, csr)).isNull() ) { |
|
|
|
|
const int posStart = csr.position() - keyToSearch.size(); |
|
|
|
|
const QImage img(KStandardDirs::locate("data", "okular/pics/okular-epub-sound-icon.png")); |
|
|
|
|
csr.insertImage(img); |
|
|
|
|
const int posEnd = csr.position(); |
|
|
|
|
qDebug() << posStart << posEnd;; |
|
|
|
|
emit addAction(soundActions[index++],posStart,posEnd); |
|
|
|
|
csr.movePosition(QTextCursor::NextWord); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
mSectionMap.insert(link, before); |
|
|
|
|
|
|
|
|
|
_handle_anchors(before, link); |
|
|
|
|
|