mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-12 20:51:17 +00:00
Merge remote-tracking branch 'origin/KDE/4.13'
This commit is contained in:
commit
d175d829f2
|
@ -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
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <QtGui/QTextFrame>
|
||||
#include <QTextDocumentFragment>
|
||||
#include <QFileInfo>
|
||||
#include <QApplication> // Because of the HACK
|
||||
|
||||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
|
@ -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);
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#include <QtCore/QFile>
|
||||
#include <QtCore/QRegExp>
|
||||
#include <kdebug.h>
|
||||
#include <QApplication> // Because of the HACK
|
||||
#include <QPalette> // 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("<html>") || header.contains("<HTML>")) setHtml(fixMobiMarkup(text));
|
||||
else setPlainText(text);
|
||||
if (header.contains("<html>") || header.contains("<HTML>")) {
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue