Changeset View
Changeset View
Standalone View
Standalone View
generators/epub/converter.cpp
Show First 20 Lines • Show All 314 Lines • ▼ Show 20 Line(s) | 213 | do{ | |||
---|---|---|---|---|---|
315 | } else { | 315 | } else { | ||
316 | before = _cursor->block(); | 316 | before = _cursor->block(); | ||
317 | _cursor->insertHtml(htmlContent); | 317 | _cursor->insertHtml(htmlContent); | ||
318 | } | 318 | } | ||
319 | // HACK BEGIN | 319 | // HACK BEGIN | ||
320 | qApp->setPalette(orig); | 320 | qApp->setPalette(orig); | ||
321 | // HACK END | 321 | // HACK END | ||
322 | 322 | | |||
323 | QTextCursor csr(mTextDocument); // a temporary cursor | 323 | QTextCursor csr(before); // a temporary cursor pointing at the begin of the last inserted block | ||
324 | csr.movePosition(QTextCursor::Start); | | |||
325 | int index = 0; | 324 | int index = 0; | ||
326 | while( !(csr = mTextDocument->find(QStringLiteral("<video></video>"),csr)).isNull() ) { | 325 | | ||
326 | while( !movieAnnots.isEmpty() && !(csr = mTextDocument->find(QStringLiteral("<video></video>"),csr)).isNull() ) { | ||||
327 | const int posStart = csr.position(); | 327 | const int posStart = csr.position(); | ||
328 | const QPoint startPoint = calculateXYPosition(mTextDocument, posStart); | 328 | const QPoint startPoint = calculateXYPosition(mTextDocument, posStart); | ||
329 | QImage img(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/okular-epub-movie.png"))); | 329 | QImage img(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/okular-epub-movie.png"))); | ||
330 | img = img.scaled(videoSize); | 330 | img = img.scaled(videoSize); | ||
331 | csr.insertImage(img); | 331 | csr.insertImage(img); | ||
332 | const int posEnd = csr.position(); | 332 | const int posEnd = csr.position(); | ||
333 | const QRect videoRect(startPoint,videoSize); | 333 | const QRect videoRect(startPoint,videoSize); | ||
334 | movieAnnots[index]->setBoundingRectangle(Okular::NormalizedRect(videoRect,mTextDocument->pageSize().width(), mTextDocument->pageSize().height())); | 334 | movieAnnots[index]->setBoundingRectangle(Okular::NormalizedRect(videoRect,mTextDocument->pageSize().width(), mTextDocument->pageSize().height())); | ||
335 | emit addAnnotation(movieAnnots[index++],posStart,posEnd); | 335 | emit addAnnotation(movieAnnots[index++],posStart,posEnd); | ||
336 | csr.movePosition(QTextCursor::NextWord); | 336 | csr.movePosition(QTextCursor::NextWord); | ||
337 | } | 337 | } | ||
338 | 338 | | |||
339 | csr.movePosition(QTextCursor::Start); | 339 | csr = QTextCursor(before); | ||
340 | index = 0; | 340 | index = 0; | ||
341 | const QString keyToSearch(QStringLiteral("<audio></audio>")); | 341 | const QString keyToSearch(QStringLiteral("<audio></audio>")); | ||
342 | while( !(csr = mTextDocument->find(keyToSearch, csr)).isNull() ) { | 342 | while( !soundActions.isEmpty() && !(csr = mTextDocument->find(keyToSearch, csr)).isNull() ) { | ||
343 | const int posStart = csr.position() - keyToSearch.size(); | 343 | const int posStart = csr.position() - keyToSearch.size(); | ||
344 | const QImage img(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/okular-epub-sound-icon.png"))); | 344 | const QImage img(QStandardPaths::locate(QStandardPaths::GenericDataLocation, QStringLiteral("okular/pics/okular-epub-sound-icon.png"))); | ||
345 | csr.insertImage(img); | 345 | csr.insertImage(img); | ||
346 | const int posEnd = csr.position(); | 346 | const int posEnd = csr.position(); | ||
347 | qDebug() << posStart << posEnd;; | 347 | qDebug() << posStart << posEnd;; | ||
348 | emit addAction(soundActions[index++],posStart,posEnd); | 348 | emit addAction(soundActions[index++],posStart,posEnd); | ||
349 | csr.movePosition(QTextCursor::NextWord); | 349 | csr.movePosition(QTextCursor::NextWord); | ||
350 | } | 350 | } | ||
▲ Show 20 Lines • Show All 114 Lines • Show Last 20 Lines |