mirror of
https://invent.kde.org/graphics/okular
synced 2024-11-05 18:34:53 +00:00
8bf1a91175
Summary:
This adds a combobox in the print dialog of the non-PDF
generators to allow selecting whether or not to take
print margins into account.
For the PDF case and rasterized printing, new print otions have
been implemented in commit 2e97d58750
already, which adds an additional option to do no scaling at all.
For consistency reasons, the same terms also used for the PDF
case are used in the combobox (i.e. the two of the three that
apply).
This adds a new abstract class 'PrintOptionsWidget' with a
'ignorePrintMargins()' method to indicate whether print margins
should be ignored or not, and a default implementation.
The existing widget for the PDF generator now derives from this
class.
In order to avoid an ABI breakage, the return value of
'Document::printConfigurationWidget' is left as a 'QWidget *'
and a dynamic_cast is done on use.
FilePrinter is adapted to take into account the value set by
'QPrinter::setFullPage()' and the margin options
are now passed accordingly (either the values set in the dialog or '0').
A big thanks to Albert Astals Cid <aacid@kde.org> for showing how
to extend the initial implementation to cover more generators.
Test Plan:
1) Open a PostScript file in Okular (using a document size that matches
a paper size available on the printer used later makes it easier
to see things behave as expected)
2) open print dialog, go to "Print options" and notice that there is a new
"Scale mode" combobox whose value is set to "Fit to printable area"
by default.
3) don't change any options, print to a printer that has hardware margins
Expected result: the document is scaled to the printable area (e.g.
scaled down so that the printer's hardware margins remain empty) as it
has been without this change.
4) Set the value of the "Print Options" -> "Scale mode" combobox to
"Fit to full page" and print again
Expected result: The document is scaled to the full page size, i.e. ignoring
the printer's hardware margins.
5) Try steps 1-4 with other document formats supported by Okular and
observe that they behave the same (except for the PDF case, where
there's a combobox with three options that has been implemented
independent of this change).
Reviewers: #okular, ngraham
Reviewed By: ngraham
Subscribers: fvogt, rkflx, arthurpeters, ltoscano, okular-devel, aacid, ngraham
Tags: #okular
Differential Revision: https://phabricator.kde.org/D10974
64 lines
1.9 KiB
C++
64 lines
1.9 KiB
C++
/***************************************************************************
|
|
* Copyright (C) 2007 by Pino Toscano <pino@kde.org> *
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
***************************************************************************/
|
|
|
|
#ifndef _OKULAR_PRINTINTERFACE_H_
|
|
#define _OKULAR_PRINTINTERFACE_H_
|
|
|
|
#include "../core/okularcore_export.h"
|
|
|
|
#include <QObject>
|
|
|
|
class QWidget;
|
|
|
|
namespace Okular {
|
|
|
|
/**
|
|
* @short Abstract interface for advanced printing control
|
|
*
|
|
* This interface defines an advanced way of interfacing with the print
|
|
* process.
|
|
*
|
|
* How to use it in a custom Generator:
|
|
* @code
|
|
class MyGenerator : public Okular::Generator, public Okular::PrintInterface
|
|
{
|
|
Q_OBJECT
|
|
Q_INTERFACES( Okular::PrintInterface )
|
|
|
|
...
|
|
};
|
|
* @endcode
|
|
* and - of course - implementing its methods.
|
|
*/
|
|
class OKULARCORE_EXPORT PrintInterface
|
|
{
|
|
public:
|
|
/**
|
|
* Destroys the printer interface.
|
|
*/
|
|
virtual ~PrintInterface() {}
|
|
|
|
/**
|
|
* Builds and returns a new printing configuration widget.
|
|
*
|
|
* @note don't keep a pointer to the new constructed widget, as it
|
|
* will be handled elsewhere (in the Okular KPart)
|
|
*
|
|
* @note The returned object should be of a PrintOptionsWidget subclass
|
|
* (which is not officially enforced by the signature for binary
|
|
* compatibility reasons).
|
|
*/
|
|
virtual QWidget* printConfigurationWidget() const = 0;
|
|
};
|
|
|
|
}
|
|
|
|
Q_DECLARE_INTERFACE( Okular::PrintInterface, "org.kde.okular.PrintInterface/0.1" )
|
|
|
|
#endif
|