diff --git a/core/textdocumentgenerator.cpp b/core/textdocumentgenerator.cpp index b4935d640..a211b872b 100644 --- a/core/textdocumentgenerator.cpp +++ b/core/textdocumentgenerator.cpp @@ -390,11 +390,19 @@ QImage TextDocumentGeneratorPrivate::image( PixmapRequest * request ) QRect rect; rect = QRect( 0, request->pageNumber() * size.height(), size.width(), size.height() ); p.translate( QPoint( 0, request->pageNumber() * size.height() * -1 ) ); + p.setClipRect( rect ); #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING q->userMutex()->lock(); #endif + QAbstractTextDocumentLayout::PaintContext context; + context.palette.setColor( QPalette::Text, Qt::black ); +// FIXME Fix Qt, this doesn't work, we have horrible hacks +// in the generators that return html, remove that code +// if Qt ever gets fixed +// context.palette.setColor( QPalette::Link, Qt::blue ); + context.clip = rect; mDocument->setDefaultFont( mFont ); - mDocument->drawContents( &p, rect ); + mDocument->documentLayout()->draw( &p, context ); #ifdef OKULAR_TEXTDOCUMENT_THREADED_RENDERING q->userMutex()->unlock(); #endif diff --git a/generators/epub/converter.cpp b/generators/epub/converter.cpp index 394d85225..392947ea3 100644 --- a/generators/epub/converter.cpp +++ b/generators/epub/converter.cpp @@ -14,6 +14,7 @@ #include #include #include +#include // Because of the HACK #include #include @@ -286,6 +287,14 @@ QTextDocument* Converter::convert( const QString &fileName ) htmlContent = dom.toString(); } + // HACK BEGIN Get the links without CSS to be blue + // Remove if Qt ever gets fixed and the code in textdocumentgenerator.cpp works + const QPalette orig = qApp->palette(); + QPalette p = orig; + p.setColor(QPalette::Link, Qt::blue); + qApp->setPalette(p); + // HACK END + QTextBlock before; if(firstPage) { // preHtml & postHtml make it possible to have a margin around the content of the page @@ -301,6 +310,9 @@ QTextDocument* Converter::convert( const QString &fileName ) before = _cursor->block(); _cursor->insertHtml(htmlContent); } + // HACK BEGIN + qApp->setPalette(orig); + // HACK END QTextCursor csr(mTextDocument); // a temporary cursor csr.movePosition(QTextCursor::Start); diff --git a/generators/mobipocket/mobidocument.cpp b/generators/mobipocket/mobidocument.cpp index 01b3c03e3..1008e2b38 100644 --- a/generators/mobipocket/mobidocument.cpp +++ b/generators/mobipocket/mobidocument.cpp @@ -13,6 +13,8 @@ #include #include #include +#include // Because of the HACK +#include // Because of the HACK using namespace Mobi; @@ -23,8 +25,23 @@ MobiDocument::MobiDocument(const QString &fileName) : QTextDocument() if (doc->isValid()) { QString text=doc->text(); QString header=text.left(1024); - if (header.contains("") || header.contains("")) setHtml(fixMobiMarkup(text)); - else setPlainText(text); + if (header.contains("") || header.contains("")) { + // HACK BEGIN Get the links without CSS to be blue + // Remove if Qt ever gets fixed and the code in textdocumentgenerator.cpp works + const QPalette orig = qApp->palette(); + QPalette p = orig; + p.setColor(QPalette::Link, Qt::blue); + qApp->setPalette(p); + // HACK END + + setHtml(fixMobiMarkup(text)); + + // HACK BEGIN + qApp->setPalette(orig); + // HACK END + } else { + setPlainText(text); + } } }