mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
kutils: remove kprintutils library
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
0c830ac352
commit
8a3d460af6
6 changed files with 0 additions and 284 deletions
|
@ -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
|
||||
|
|
|
@ -248,7 +248,6 @@ install(
|
|||
KPluginSelector
|
||||
KPopupFrame
|
||||
KPreviewWidgetBase
|
||||
KPrintPreview
|
||||
KProcess
|
||||
KProgressDialog
|
||||
KPropertiesDialog
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
#include "../kprintpreview.h"
|
|
@ -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}
|
||||
)
|
||||
|
|
|
@ -1,174 +0,0 @@
|
|||
/*
|
||||
* This file is part of the KDE libraries
|
||||
* Copyright (c) 2007 Alex Merry <alex.merry@kdemail.net>
|
||||
*
|
||||
* 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 <QtCore/QFile>
|
||||
#include <QtGui/QLabel>
|
||||
#include <QtGui/QPrinter>
|
||||
#include <QtGui/qevent.h>
|
||||
|
||||
#include <kmimetypetrader.h>
|
||||
#include <kparts/part.h>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
#include <kservice.h>
|
||||
#include <ktempdir.h>
|
||||
#include <kdebug.h>
|
||||
|
||||
|
||||
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<KParts::ReadOnlyPart>(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"
|
||||
|
||||
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* This file is part of the KDE libraries
|
||||
* Copyright (c) 2007 Alex Merry <alex.merry@kdemail.net>
|
||||
*
|
||||
* 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 <QPrinter>
|
||||
#include <kprintutils_export.h>
|
||||
#include <kdialog.h>
|
||||
|
||||
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
|
||||
|
Loading…
Add table
Reference in a new issue