diff --git a/kpdf/Makefile.am b/kpdf/Makefile.am index b00ed4227..067a73261 100644 --- a/kpdf/Makefile.am +++ b/kpdf/Makefile.am @@ -45,7 +45,7 @@ kde_module_LTLIBRARIES = libkpdfpart.la # the Part's source, library search path, and link libraries libkpdfpart_la_SOURCES = kpdf_part.cpp kpdf_pagewidget.cc libkpdfpart_la_LDFLAGS = -module $(KDE_PLUGIN) $(all_libraries) -libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) +libkpdfpart_la_LIBADD = ../xpdf/libxpdf.la $(LIB_KPARTS) $(LIB_KFILE) $(LIB_KDEPRINT) # this is where the desktop file will go partdesktopdir = $(kde_servicesdir) diff --git a/kpdf/kpdf_part.cpp b/kpdf/kpdf_part.cpp index 31ac1cef1..0713bef7b 100644 --- a/kpdf/kpdf_part.cpp +++ b/kpdf/kpdf_part.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -31,8 +32,9 @@ Part::Part(QWidget *parentWidget, const char *widgetName, const QStringList & /*args*/ ) : KParts::ReadOnlyPart(parent, name), m_pagePixmap(1, 1), + m_doc(0), m_currentPage(0), - m_zoomMode(FitWidth), + m_zoomMode(FixedFactor), m_zoomFactor(1.0) { globalParams = new GlobalParams(""); @@ -60,6 +62,7 @@ Part::Part(QWidget *parentWidget, const char *widgetName, // create our actions KStdAction::open (this, SLOT(fileOpen()), actionCollection()); KStdAction::saveAs(this, SLOT(fileSaveAs()), actionCollection()); + KStdAction::print (this, SLOT(filePrint()), actionCollection()); KStdAction::prior (this, SLOT(displayPreviousPage()), actionCollection(), "previous_page"); KStdAction::next (this, SLOT(displayNextPage()), @@ -90,6 +93,15 @@ Part::createAboutData() return aboutData; } + bool +Part::closeURL() +{ + delete m_doc; + m_doc = 0; + + return KParts::ReadOnlyPart::closeURL(); +} + bool Part::openFile() { @@ -277,6 +289,36 @@ Part::fileSaveAs() */ } + void +Part::filePrint() +{ + if (m_doc == 0) + return; + + KPrinter printer; + + printer.setPageSelection(KPrinter::ApplicationSide); + printer.setCurrentPage(m_currentPage); + printer.setMinMax(1, m_doc->getNumPages()); + + if (printer.setup(widget())) + { + /* + KTempFile tf(QString::null, ".ps"); + if (tf.status() == 0) + { + savePages(tf.name(), printer.pageList()); + printer.printFiles(QStringList( tf.name() ), true); + } + else + { + // TODO: Proper error handling + ; + } + */ + } +} + void Part::displayNextPage() { @@ -301,7 +343,7 @@ Part::setFixedZoomFactor(float zoomFactor) Part::executeAction(LinkAction* action) { if (action == 0) - return; + return; LinkActionKind kind = action->getKind(); diff --git a/kpdf/kpdf_part.h b/kpdf/kpdf_part.h index 5321e2e71..42dc9e7f6 100644 --- a/kpdf/kpdf_part.h +++ b/kpdf/kpdf_part.h @@ -79,6 +79,8 @@ namespace KPDF static KAboutData* createAboutData(); + bool closeURL(); + void displayPage(int pageNumber, float zoomFactor = 1.0); void displayDestination(LinkDest*); @@ -91,6 +93,7 @@ namespace KPDF protected slots: void fileOpen(); void fileSaveAs(); + void filePrint(); void displayNextPage(); void displayPreviousPage(); @@ -108,7 +111,6 @@ namespace KPDF int m_currentPage; - // Zoom settings ZoomMode m_zoomMode; float m_zoomFactor; diff --git a/kpdf/kpdf_part.rc b/kpdf/kpdf_part.rc index 7b2ed4b98..570d0285f 100644 --- a/kpdf/kpdf_part.rc +++ b/kpdf/kpdf_part.rc @@ -5,6 +5,8 @@ + +