diff --git a/cmake/modules/FindKDE4Internal.cmake b/cmake/modules/FindKDE4Internal.cmake index f60e68c9..008ba536 100644 --- a/cmake/modules/FindKDE4Internal.cmake +++ b/cmake/modules/FindKDE4Internal.cmake @@ -51,7 +51,6 @@ # KDE4_KEMOTICONS_LIBS - the kemoticons library and all depending libraries # KDE4_KIDLETIME_LIBS - the kidletime library and all depending libraries # KDE4_KCMUTILS_LIBS - the kcmutils library and all depending libraries -# KDE4_KPRINTUTILS_LIBS - the kprintutils library and all depending libraries # KDE4_KFILE_LIBS - the kfile library and all depending libraries # KDE4_KDNSSD_LIBS - the kdnssd library and all depending libraries # KDE4_KPTY_LIBS - the kpty library and all depending libraries @@ -296,7 +295,6 @@ set(_kde_libraries kio knotifyconfig kparts - kprintutils kpty ktexteditor plasma diff --git a/includes/CMakeLists.txt b/includes/CMakeLists.txt index e46a6504..f25f681d 100644 --- a/includes/CMakeLists.txt +++ b/includes/CMakeLists.txt @@ -248,7 +248,6 @@ install( KPluginSelector KPopupFrame KPreviewWidgetBase - KPrintPreview KProcess KProgressDialog KPropertiesDialog diff --git a/includes/KPrintPreview b/includes/KPrintPreview deleted file mode 100644 index a226f123..00000000 --- a/includes/KPrintPreview +++ /dev/null @@ -1 +0,0 @@ -#include "../kprintpreview.h" diff --git a/kutils/CMakeLists.txt b/kutils/CMakeLists.txt index f39dd6cd..3f1740db 100644 --- a/kutils/CMakeLists.txt +++ b/kutils/CMakeLists.txt @@ -182,34 +182,3 @@ install( EXPORT kdelibsLibraryTargets ${INSTALL_TARGETS_DEFAULT_ARGS} ) - -########### kprintutils ############### - -add_library(kprintutils ${LIBRARY_TYPE} kprintpreview.cpp) - -target_link_libraries(kprintutils PUBLIC - ${KDE4_KDECORE_LIBS} - ${KDE4_KDEUI_LIBS} - ${KDE4_KPARTS_LIBS} -) - -set_target_properties(kprintutils PROPERTIES - VERSION ${GENERIC_LIB_VERSION} - SOVERSION ${GENERIC_LIB_SOVERSION} -) - -generate_export_header(kprintutils) - -install( - FILES - ${CMAKE_CURRENT_BINARY_DIR}/kprintutils_export.h - kprintpreview.h - DESTINATION ${KDE4_INCLUDE_INSTALL_DIR} - COMPONENT Devel -) - -install( - TARGETS kprintutils - EXPORT kdelibsLibraryTargets - ${INSTALL_TARGETS_DEFAULT_ARGS} -) diff --git a/kutils/kprintpreview.cpp b/kutils/kprintpreview.cpp deleted file mode 100644 index 4239ee6d..00000000 --- a/kutils/kprintpreview.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2007 Alex Merry - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#include "kprintpreview.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -class KPrintPreviewPrivate -{ -public: - KPrintPreviewPrivate(KPrintPreview *host, QPrinter * _printer) - : q(host) - , printer(_printer) - , mainWidget(new QWidget(host)) - , previewPart(0) - , failMessage(0) - { - if ( tempdir.exists() ) { - filename = tempdir.name() + "print_preview.pdf"; - } else { - // XXX: not portable! - kWarning() << "Failed to create temporary directory"; - filename = "/dev/null"; - } - } - - void getPart(); - bool doPreview(); - void fail(); - - KPrintPreview *q; - - QPrinter *printer; - QWidget *mainWidget; - - KTempDir tempdir; - QString filename; - - KParts::ReadOnlyPart *previewPart; - QWidget *failMessage; -}; - -void KPrintPreviewPrivate::getPart() -{ - if (previewPart) { - kDebug(500) << "already got a part"; - return; - } - kDebug(500) << "querying trader for application/pdf service"; - - KPluginFactory *factory(0); - const KService::List offers = - KMimeTypeTrader::self()->query("application/pdf", "KParts/ReadOnlyPart"); - - KService::List::ConstIterator it = offers.begin(); - while (!factory && it != offers.end()) { - KPluginLoader loader(**it); - factory = loader.factory(); - if (!factory) { - kDebug(500) << "Loading failed:" << loader.errorString(); - } - ++it; - } - if (factory) { - kDebug(500) << "Trying to create a part"; - previewPart = factory->create(q, (QVariantList() << "Print/Preview")); - if (!previewPart) { - kDebug(500) << "Part creation failed"; - } - } -} - -bool KPrintPreviewPrivate::doPreview() -{ - if (!QFile::exists(filename)) { - kWarning() << "Nothing was produced to be previewed"; - return false; - } - - getPart(); - if (!previewPart) { - //TODO: error dialog - kWarning() << "Could not find a PDF viewer for the preview dialog"; - fail(); - return false; - } else { - q->setMainWidget(previewPart->widget()); - return previewPart->openUrl(filename); - } -} - -void KPrintPreviewPrivate::fail() -{ - if (!failMessage) { - failMessage = new QLabel(i18n("Could not load print preview part"), q); - } - q->setMainWidget(failMessage); -} - - - - -KPrintPreview::KPrintPreview(QPrinter *printer, QWidget *parent) - : KDialog(parent) - , d(new KPrintPreviewPrivate(this, printer)) -{ - kDebug(500) << "kdeprint: creating preview dialog"; - - //There is no printing on wince - // Set up the dialog - setCaption(i18n("Print Preview")); - setButtons(KDialog::Close); - - // Set up the printer - kDebug(500) << "Will print to" << d->filename; - printer->setOutputFileName(d->filename); - - setInitialSize(QSize(600, 500)); -} - -KPrintPreview::~KPrintPreview() -{ - delete d; -} - -void KPrintPreview::showEvent(QShowEvent *event) -{ - if (!event->spontaneous()) { - // being shown for the first time - if (!d->doPreview()) { - event->accept(); - return; - } - } - KDialog::showEvent(event); -} - -bool KPrintPreview::isAvailable() -{ - return !KMimeTypeTrader::self()->query("application/pdf", "KParts/ReadOnlyPart").isEmpty(); -} - -#include "moc_kprintpreview.cpp" - - - diff --git a/kutils/kprintpreview.h b/kutils/kprintpreview.h deleted file mode 100644 index 7913a42f..00000000 --- a/kutils/kprintpreview.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of the KDE libraries - * Copyright (c) 2007 Alex Merry - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License version 2 as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public License - * along with this library; see the file COPYING.LIB. If not, write to - * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - * Boston, MA 02110-1301, USA. - **/ - -#ifndef KPRINTPREVIEW_H -#define KPRINTPREVIEW_H - -#include -#include -#include - -class KPrintPreviewPrivate; - -/** - * KPrintPreview provides a print preview dialog. - * - * Use it like this: - * - * @code - * QPrinter printer; - * KPrintPreview preview(&printer); - * doPrint(printer); // draws to the QPrinter - * preview.exec(); - * @endcode - */ -class KPRINTUTILS_EXPORT KPrintPreview : public KDialog -{ - Q_OBJECT - -public: - /** - * Create a KPrintPreview object. - * - * This will change the settings on the QPrinter, so you - * should not re-use the QPrinter object for printing - * normally. - * - * @param printer pointer to a QPrinter to configure for - * print preview - * @param parent pointer to the parent widget for the dialog - */ - explicit KPrintPreview(QPrinter *printer, QWidget *parent = 0); - virtual ~KPrintPreview(); - - /** - * Returns true if the print preview system is available - * @since KDE 4.5 - */ - static bool isAvailable(); - -protected: - void showEvent(QShowEvent *event); - -private: - KPrintPreviewPrivate * const d; -}; - - -#endif // KPRINTPREVIEW_H -