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