Commit 070285e0 authored by John Layt's avatar John Layt

Port from KPrinter to QPrinter, remove dependency on KDE4_KDEPRINT_LIBS.

*** Note this is not a complete port, most of the generators use the 
printFiles method which Qt 4.3 does not support, these have simply
been commented out until we find a solution.  At least it removes
the dependency so we can remove from kdelibs.

svn path=/trunk/KDE/kdegraphics/okular/; revision=725660
parent c68ae02d
......@@ -86,7 +86,7 @@ IF(APPLE)
SET(OKULAR_IOKIT "-framework IOKit" CACHE STRING "Apple IOKit framework")
ENDIF(APPLE)
target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_KDEPRINT_LIBRARY} ${KDE4_PHONON_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
target_link_libraries(okularcore ${OKULAR_IOKIT} ${KDE4_KIO_LIBS} ${KDE4_KUTILS_LIBS} ${KDE4_PHONON_LIBRARY} ${MATH_LIB} ${KDE4_THREADWEAVER_LIBRARY} )
set_target_properties(okularcore PROPERTIES VERSION 1.0.0 SOVERSION 1 )
......
......@@ -22,6 +22,7 @@
#include <QtCore/QTimer>
#include <QtGui/QApplication>
#include <QtGui/QLabel>
#include <QtGui/QPrinter>
#include <kaboutdata.h>
#include <kauthorized.h>
......@@ -2406,12 +2407,12 @@ void Document::processSourceReference( const SourceReference * ref )
QProcess::startDetached( p );
}
bool Document::print( KPrinter &printer )
bool Document::print( QPrinter &printer )
{
return d->m_generator ? d->m_generator->print( printer ) : false;
}
KPrintDialogPage* Document::printConfigurationWidget() const
QWidget* Document::printConfigurationWidget() const
{
if ( d->m_generator )
{
......
......@@ -23,12 +23,11 @@
#include <kmimetype.h>
class QPrinter;
class KComponentData;
class KBookmark;
class KConfigDialog;
class KXMLGUIClient;
class KPrinter;
class KPrintDialogPage;
class KUrl;
namespace Okular {
......@@ -456,13 +455,13 @@ class OKULAR_EXPORT Document : public QObject
/**
* Prints the document to the given @p printer.
*/
bool print( KPrinter &printer );
bool print( QPrinter &printer );
/**
* Returns a custom printer configuration page or 0 if no
* custom printer configuration page is available.
*/
KPrintDialogPage* printConfigurationWidget() const;
QWidget* printConfigurationWidget() const;
/**
* Fill the KConfigDialog @p dialog with the setting pages of the
......
......@@ -11,6 +11,7 @@
#include "generator_p.h"
#include <qeventloop.h>
#include <QtGui/QPrinter>
#include <kaboutdata.h>
#include <kcomponentdata.h>
......@@ -289,7 +290,7 @@ void Generator::pageSizeChanged( const PageSize &, const PageSize & )
{
}
bool Generator::print( KPrinter& )
bool Generator::print( QPrinter& )
{
return false;
}
......
......@@ -32,10 +32,10 @@
}
class QMutex;
class QPrinter;
class KAboutData;
class KComponentData;
class KIcon;
class KPrinter;
namespace Okular {
......@@ -330,7 +330,7 @@ class OKULAR_EXPORT Generator : public QObject
/**
* This method is called to print the document to the given @p printer.
*/
virtual bool print( KPrinter &printer );
virtual bool print( QPrinter &printer );
/**
* This method returns the meta data of the given @p key with the given @p option
......
......@@ -16,8 +16,7 @@
#include <QtCore/QVector>
#include <QtGui/QPainter>
#include <QtGui/QPixmap>
#include <kprinter.h>
#include <QtGui/QPrinter>
#include <okular/core/action.h>
#include <okular/core/annotations.h>
......@@ -315,7 +314,7 @@ Okular::TextPage* TextDocumentGenerator::textPage( Okular::Page * page )
return d->createTextPage( page->number() );
}
bool TextDocumentGenerator::print( KPrinter& printer )
bool TextDocumentGenerator::print( QPrinter& printer )
{
Q_D( TextDocumentGenerator );
if ( !d->mDocument )
......
......@@ -135,8 +135,8 @@ class OKULAR_EXPORT TextDocumentGenerator : public Generator
bool canGeneratePixmap() const;
void generatePixmap( Okular::PixmapRequest * request );
// [INHERITED] print document using already configured kprinter
bool print( KPrinter& printer );
// [INHERITED] print document using already configured QPrinter
bool print( QPrinter& printer );
// [INHERITED] text exporting
Okular::ExportFormat::List exportFormats() const;
......
......@@ -10,8 +10,7 @@
#include "generator_comicbook.h"
#include <QtGui/QPainter>
#include <kprinter.h>
#include <QtGui/QPrinter>
#include <okular/core/page.h>
......@@ -67,14 +66,17 @@ QImage ComicBookGenerator::image( Okular::PixmapRequest * request )
return image.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
}
bool ComicBookGenerator::print( KPrinter& printer )
bool ComicBookGenerator::print( QPrinter& printer )
{
QPainter p( &printer );
for ( int i = 0; i < mDocument.pages(); ++i ) {
QImage image = mDocument.pageImage( i );
uint left, top, right, bottom;
printer.margins( &left, &top, &right, &bottom );
left = printer.paperRect().left() - printer.pageRect().left();
top = printer.paperRect().top() - printer.pageRect().top();
right = printer.paperRect().right() - printer.pageRect().right();
bottom = printer.paperRect().bottom() - printer.pageRect().bottom();
int pageWidth = printer.width() - right;
int pageHeight = printer.height() - bottom;
......
......@@ -26,7 +26,7 @@ class ComicBookGenerator : public Okular::Generator
bool loadDocument( const QString & fileName, QVector<Okular::Page*> & pagesVector );
// [INHERITED] print document using already configured kprinter
bool print( KPrinter& printer );
bool print( QPrinter& printer );
protected:
bool doCloseDocument();
......
......@@ -15,7 +15,7 @@ set(okularGenerator_djvu_SRCS
kde4_add_plugin(okularGenerator_djvu WITH_PREFIX ${okularGenerator_djvu_SRCS})
target_link_libraries(okularGenerator_djvu okularcore ${DJVULIBRE_LIBRARY} ${KDE4_KDEPRINT_LIBS} ${KDE4_KDEUI_LIBS} ${KDE4_KDEPRINT_LIBRARY} )
target_link_libraries(okularGenerator_djvu okularcore ${DJVULIBRE_LIBRARY} ${KDE4_KDEUI_LIBS} )
install(TARGETS okularGenerator_djvu DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -22,10 +22,11 @@
#include <qpixmap.h>
#include <qstring.h>
#include <quuid.h>
#include <QtGui/QPrinter>
#include <kaboutdata.h>
#include <kdebug.h>
#include <klocale.h>
#include <kprinter.h>
#include <ktemporaryfile.h>
static void recurseCreateTOC( QDomDocument &maindoc, QDomNode &parent, QDomNode &parentDestination )
......@@ -182,8 +183,10 @@ const Okular::DocumentSynopsis * DjVuGenerator::generateDocumentSynopsis()
return m_docSyn;
}
bool DjVuGenerator::print( KPrinter& printer )
bool DjVuGenerator::print( QPrinter& printer )
{
/* This printing method unsupported in QPrinter, looking for alternative.
QList<int> pageList;
if ( !printer.previewOnly() )
pageList = printer.pageList();
......@@ -204,6 +207,7 @@ bool DjVuGenerator::print( KPrinter& printer )
{
return printer.printFiles( QStringList( tf.fileName() ), false );
}
*/
return false;
}
......
......@@ -34,7 +34,7 @@ class DjVuGenerator : public Okular::Generator
const Okular::DocumentSynopsis * generateDocumentSynopsis();
// printing
bool print( KPrinter& printer );
bool print( QPrinter& printer );
QVariant metaData( const QString & key, const QVariant & option ) const;
......
......@@ -49,7 +49,7 @@ set(okularGenerator_dvi_SRCS
kde4_add_plugin(okularGenerator_dvi WITH_PREFIX ${okularGenerator_dvi_SRCS})
target_link_libraries(okularGenerator_dvi okularcore ${KDE4_KDEPRINT_LIBS} ${MATH_LIB} ${QT_QT3SUPPORT_LIBRARY})
target_link_libraries(okularGenerator_dvi okularcore ${KDE4_KIO_LIBS} ${MATH_LIB} ${QT_QT3SUPPORT_LIBRARY})
if (FREETYPE_FOUND)
target_link_libraries(okularGenerator_dvi ${FREETYPE_LIBRARIES})
endif (FREETYPE_FOUND)
......
......@@ -766,7 +766,7 @@ void dviRenderer::exportPDF()
}
void dviRenderer::exportPS(const QString& fname, const QStringList& options, KPrinter* printer)
void dviRenderer::exportPS(const QString& fname, const QStringList& options, QPrinter* printer)
{
Q_UNUSED( fname );
Q_UNUSED( options );
......
......@@ -40,7 +40,7 @@ class dvifile;
class dviRenderer;
class ghostscript_interface;
//class infoDialog;
class KPrinter;
class QPrinter;
class KProgressDialog;
class PreBookmark;
class TeXFontDefinition;
......@@ -153,7 +153,7 @@ public:
// void editor_finished(const DVISourceEditor*);
public slots:
void exportPS(const QString& fname = QString(), const QStringList& options = QStringList(), KPrinter* printer = 0);
void exportPS(const QString& fname = QString(), const QStringList& options = QStringList(), QPrinter* printer = 0);
void exportPDF();
// void showInfo();
......
......@@ -28,12 +28,12 @@
#include <kfiledialog.h>
#include <klocale.h>
#include <kmessagebox.h>
#include <kprinter.h>
#include <kprocess.h>
#include <QFileInfo>
#include <QLabel>
#include <QTemporaryFile>
#include <QtGui/QPrinter>
#include <cassert>
......@@ -309,7 +309,7 @@ DVIExportToPS::DVIExportToPS(dviRenderer& parent,
QWidget* parent_widget,
const QString& output_name,
const QStringList& options,
KPrinter* printer)
QPrinter* printer)
: DVIExport(parent, parent_widget),
printer_(printer)
{
......@@ -479,7 +479,8 @@ void DVIExportToPS::finished_impl(int exit_code)
if (printer_ && !output_name_.isEmpty()) {
const QFileInfo output(output_name_);
if (output.exists() && output.isReadable())
printer_->printFiles(QStringList(output_name_), true);
//Unsupported in Qt
//printer_->printFiles(QStringList(output_name_), true);
}
#ifndef DVIEXPORT_USE_QPROCESS
......
......@@ -26,7 +26,7 @@
class dviRenderer;
class fontProgressDialog;
class KPrinter;
class QPrinter;
class KProcess;
class QStringList;
......@@ -132,14 +132,14 @@ public:
QWidget* parent_widget,
const QString& output_name,
const QStringList& options,
KPrinter* printer);
QPrinter* printer);
private:
virtual void abort_process_impl();
//virtual void finished_impl(int exit_code);
virtual void finished_impl();
KPrinter* printer_;
QPrinter* printer_;
QString output_name_;
QString tmpfile_name_;
};
......
......@@ -15,7 +15,7 @@ set(okularGenerator_fb_PART_SRCS
kde4_add_plugin(okularGenerator_fb WITH_PREFIX ${okularGenerator_fb_PART_SRCS})
target_link_libraries(okularGenerator_fb ${POPPLER_LIBRARY} okularcore ${KDE4_KDEPRINT_LIBS} ${MATH_LIB} )
target_link_libraries(okularGenerator_fb ${POPPLER_LIBRARY} okularcore ${KDE4_KIO_LIBS} ${MATH_LIB} )
install(TARGETS okularGenerator_fb DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -29,7 +29,7 @@ kde4_add_kcfg_files(okularGenerator_ghostview_SRCS conf/gssettings.kcfgc )
kde4_add_plugin(okularGenerator_ghostview WITH_PREFIX ${okularGenerator_ghostview_SRCS})
target_link_libraries(okularGenerator_ghostview ${KDE4_KDECORE_LIBS} okularcore ${LIBGS_LIBRARY} ${KDE4_KDEUI_LIBRARY} ${KDE4_KDEPRINT_LIBRARY} ${KDE4_KDE3SUPPORT_LIBRARY} )
target_link_libraries(okularGenerator_ghostview ${KDE4_KIO_LIBS} okularcore ${LIBGS_LIBRARY} ${KDE4_KDEUI_LIBRARY} ${KDE4_KDE3SUPPORT_LIBRARY} )
install(TARGETS okularGenerator_ghostview DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -14,6 +14,7 @@
#include <qpixmap.h>
#include <qsize.h>
#include <qtoolbox.h>
#include <QtGui/QPrinter>
#include <kactioncollection.h>
#include <kconfigdialog.h>
......@@ -21,7 +22,6 @@
#include <kicon.h>
#include <klocale.h>
#include <kmimetype.h>
#include <kprinter.h>
#include <ktemporaryfile.h>
#include <okular/core/page.h>
......@@ -141,8 +141,10 @@ int GSGenerator::angle( CDSC_ORIENTATION_ENUM orientation ) const
return angle;
}
bool GSGenerator::print( KPrinter& printer )
bool GSGenerator::print( QPrinter& printer )
{
/* This printing method unsupported in QPrinter, looking for alternative.
KTemporaryFile tf;
tf.setSuffix( ".ps" );
if ( tf.open() )
......@@ -155,6 +157,7 @@ bool GSGenerator::print( KPrinter& printer )
tf.close();
return result;
}
*/
return false;
}
......
......@@ -48,7 +48,7 @@ class GSGenerator : public Okular::Generator, public Okular::ConfigInterface, pu
void freeGui();
// print document using already configured kprinter
bool print( KPrinter& /*printer*/ );
bool print( QPrinter& /*printer*/ );
QString fileName() const;
bool reparseConfig();
......
......@@ -14,13 +14,13 @@
#include <QtCore/QBuffer>
#include <QtGui/QImageReader>
#include <QtGui/QPainter>
#include <QtGui/QPrinter>
#include <kaboutdata.h>
#include <kaction.h>
#include <kactioncollection.h>
#include <kicon.h>
#include <klocale.h>
#include <kprinter.h>
#include <okular/core/page.h>
......@@ -118,12 +118,15 @@ QImage KIMGIOGenerator::image( Okular::PixmapRequest * request )
return m_img.scaled( width, height, Qt::IgnoreAspectRatio, Qt::SmoothTransformation );
}
bool KIMGIOGenerator::print( KPrinter& printer )
bool KIMGIOGenerator::print( QPrinter& printer )
{
QPainter p( &printer );
uint left, top, right, bottom;
printer.margins( &left, &top, &right, &bottom );
left = printer.paperRect().left() - printer.pageRect().left();
top = printer.paperRect().top() - printer.pageRect().top();
right = printer.paperRect().right() - printer.pageRect().right();
bottom = printer.paperRect().bottom() - printer.pageRect().bottom();
int pageWidth = printer.width() - right;
int pageHeight = printer.height() - bottom;
......
......@@ -28,7 +28,7 @@ class KIMGIOGenerator : public Okular::Generator, public Okular::GuiInterface
bool loadDocumentFromData( const QByteArray & fileData, QVector<Okular::Page*> & pagesVector );
// [INHERITED] print document using already configured kprinter
bool print( KPrinter& printer );
bool print( QPrinter& printer );
protected:
bool doCloseDocument();
......
......@@ -18,7 +18,7 @@ set(okularGenerator_ooo_PART_SRCS
kde4_add_plugin(okularGenerator_ooo WITH_PREFIX ${okularGenerator_ooo_PART_SRCS})
target_link_libraries(okularGenerator_ooo ${POPPLER_LIBRARY} okularcore ${KDE4_KDEPRINT_LIBS} ${MATH_LIB} )
target_link_libraries(okularGenerator_ooo ${POPPLER_LIBRARY} okularcore ${KDE4_KIO_LIBS} ${MATH_LIB} )
install(TARGETS okularGenerator_ooo DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -22,7 +22,7 @@ set(okularGenerator_plucker_SRCS
kde4_add_plugin(okularGenerator_plucker WITH_PREFIX ${okularGenerator_plucker_SRCS} ${qunpluck_SRCS})
target_link_libraries(okularGenerator_plucker okularcore ${KDE4_KDEPRINT_LIBS} ${MATH_LIB} ${JPEG_LIBRARY} )
target_link_libraries(okularGenerator_plucker okularcore ${KDE4_KIO_LIBS} ${MATH_LIB} ${JPEG_LIBRARY} )
install(TARGETS okularGenerator_plucker DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -12,6 +12,7 @@
#include <QtCore/QFile>
#include <QtGui/QAbstractTextDocumentLayout>
#include <QtGui/QPainter>
#include <QtGui/QPrinter>
#include <QtGui/QTextDocument>
#include <klocale.h>
......@@ -185,7 +186,7 @@ bool PluckerGenerator::exportTo( const QString &fileName, const Okular::ExportFo
return false;
}
bool PluckerGenerator::print( KPrinter& )
bool PluckerGenerator::print( QPrinter& )
{
/*
for ( int i = 0; i < mPages.count(); ++i )
......
......@@ -41,7 +41,7 @@ class PluckerGenerator : public Okular::Generator
bool exportTo( const QString &fileName, const Okular::ExportFormat &format );
// [INHERITED] print document using already configured kprinter
bool print( KPrinter& printer );
bool print( QPrinter& printer );
protected:
bool doCloseDocument();
......
......@@ -43,7 +43,7 @@ endif (HAVE_POPPLER_0_6)
kde4_add_plugin(okularGenerator_poppler WITH_PREFIX ${okularGenerator_poppler_PART_SRCS})
target_link_libraries(okularGenerator_poppler ${POPPLER_LIBRARY} okularcore ${KDE4_KDEPRINT_LIBS} m )
target_link_libraries(okularGenerator_poppler ${POPPLER_LIBRARY} okularcore ${KDE4_KIO_LIBS} m )
install(TARGETS okularGenerator_poppler DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -19,15 +19,15 @@
#include <qmutex.h>
#include <qregexp.h>
#include <qtextstream.h>
#include <QtGui/QPrinter>
#include <klocale.h>
#include <kmessagebox.h>
#include <kpassworddialog.h>
#include <kwallet.h>
#include <kprinter.h>
#include <ktemporaryfile.h>
#include <kdebug.h>
#include <kglobal.h>
#include <kdeprint/kprintdialogpage.h>
#include <okular/core/action.h>
#include <okular/core/page.h>
......@@ -91,12 +91,12 @@ class PDFEmbeddedFile : public Okular::EmbeddedFile
Poppler::EmbeddedFile *ef;
};
class PDFOptionsPage : public KPrintDialogPage
class PDFOptionsPage : public QWidget
{
public:
PDFOptionsPage()
{
setTitle( i18n( "PDF Options" ) );
setWindowTitle( i18n( "PDF Options" ) );
QVBoxLayout *layout = new QVBoxLayout(this);
m_forceRaster = new QCheckBox(i18n("Force rasterization"), this);
m_forceRaster->setToolTip(i18n("Rasterize into an image before printing"));
......@@ -828,8 +828,9 @@ Okular::TextPage* PDFGenerator::textPage( Okular::Page *page )
return tp;
}
bool PDFGenerator::print( KPrinter& printer )
bool PDFGenerator::print( QPrinter& printer )
{
/* This printing method unsupported in QPrinter, looking for alternative.
int width, height;
// PageSize is a CUPS artificially created setting
QString ps = printer.option( "PageSize" );
......@@ -940,6 +941,7 @@ bool PDFGenerator::print( KPrinter& printer )
userMutex()->unlock();
return false;
}
*/
return false;
}
......@@ -1499,7 +1501,7 @@ void PDFGenerator::loadPdfSync( const QString & filePath, QVector<Okular::Page*>
pagesVector[i]->setSourceReferences( refRects.at(i) );
}
KPrintDialogPage* PDFGenerator::printConfigurationWidget() const
QWidget* PDFGenerator::printConfigurationWidget() const
{
#ifdef HAVE_POPPLER_0_6
return new PDFOptionsPage();
......
......@@ -71,7 +71,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
void generatePixmap( Okular::PixmapRequest * request );
// [INHERITED] print page using an already configured kprinter
bool print( KPrinter& printer );
bool print( QPrinter& printer );
// [INHERITED] reply to some metadata requests
QVariant metaData( const QString & key, const QVariant & option ) const;
......@@ -85,7 +85,7 @@ class PDFGenerator : public Okular::Generator, public Okular::ConfigInterface, p
bool exportTo( const QString &fileName, const Okular::ExportFormat &format );
// [INHERITED] print interface
KPrintDialogPage* printConfigurationWidget() const;
QWidget* printConfigurationWidget() const;
protected:
bool doCloseDocument();
......
......@@ -13,7 +13,7 @@ set(okularGenerator_tiff_SRCS
kde4_add_plugin(okularGenerator_tiff WITH_PREFIX ${okularGenerator_tiff_SRCS})
target_link_libraries(okularGenerator_tiff okularcore ${TIFF_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KDEPRINT_LIBS} )
target_link_libraries(okularGenerator_tiff okularcore ${TIFF_LIBRARIES} ${KDE4_KDEUI_LIBS} ${KDE4_KIO_LIBS} )
install(TARGETS okularGenerator_tiff DESTINATION ${PLUGIN_INSTALL_DIR})
......
......@@ -14,10 +14,11 @@
#include <qimage.h>
#include <qlist.h>
#include <qpainter.h>
#include <QtGui/QPrinter>
#include <kaboutdata.h>
#include <kglobal.h>
#include <klocale.h>
#include <kprinter.h>
#include <okular/core/document.h>
#include <okular/core/page.h>
......@@ -210,7 +211,7 @@ void TIFFGenerator::loadPages( QVector<Okular::Page*> & pagesVector )
}
}
bool TIFFGenerator::print( KPrinter& printer )
bool TIFFGenerator::print( QPrinter& printer )
{
uint32 width = 0;
uint32 height = 0;
......
......@@ -23,7 +23,7 @@ class TIFFGenerator : public Okular::Generator
const Okular::DocumentInfo * generateDocumentInfo();
bool print( KPrinter& printer );
bool print( QPrinter& printer );
protected:
bool doCloseDocument();
......
......@@ -14,7 +14,7 @@
#include <QtCore/QObject>
class KPrintDialogPage;