Enable Current Page option in Okular print dialog if running Qt >= 4.7

Changed exported api so cc: to bindings.
CCMAIL: kde-bindings@kde.org

CCBUG: 194586


svn path=/trunk/KDE/kdegraphics/okular/; revision=1134379
This commit is contained in:
John Layt 2010-06-04 08:25:25 +00:00
parent 95212a30b4
commit b30305b668
10 changed files with 26 additions and 4 deletions

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2007 by John Layt <john@layt.net> *
* Copyright (C) 2007,2010 by John Layt <john@layt.net> *
* *
* FilePrinterPreview based on KPrintPreview (originally LGPL) *
* Copyright (c) 2007 Alex Merry <huntedhacker@tiscali.co.uk> *
@ -145,7 +145,8 @@ int FilePrinter::doPrintFiles( QPrinter &printer, QStringList fileList, FileDele
return ret;
}
QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage, const QList<int> &selectedPageList )
QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage,
int currentPage, const QList<int> &selectedPageList )
{
if ( printer.printRange() == QPrinter::Selection) {
return selectedPageList;
@ -157,6 +158,11 @@ QList<int> FilePrinter::pageList( QPrinter &printer, int lastPage, const QList<i
if ( printer.printRange() == QPrinter::PageRange ) {
startPage = printer.fromPage();
endPage = printer.toPage();
#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
} else if ( printer.printRange() == QPrinter::CurrentPage) {
startPage = currentPage;
endPage = currentPage;
#endif
} else { //AllPages
startPage = 1;
endPage = lastPage;

View File

@ -1,5 +1,5 @@
/***************************************************************************
* Copyright (C) 2007 by John Layt <john@layt.net> *
* Copyright (C) 2007, 2010 by John Layt <john@layt.net> *
* *
* 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 *
@ -105,7 +105,8 @@ public:
* @param selectedPageList list of pages to use if Selection option is selected
* @returns Returns list of pages to print
*/
static QList<int> pageList( QPrinter &printer, int lastPage, const QList<int> &selectedPageList );
static QList<int> pageList( QPrinter &printer, int lastPage,
int currentPage, const QList<int> &selectedPageList );
/** Return the range of pages selected by the user in the Print Dialog
*

View File

@ -95,6 +95,7 @@ bool ComicBookGenerator::print( QPrinter& printer )
QPainter p( &printer );
QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
for ( int i = 0; i < pageList.count(); ++i ) {

View File

@ -209,6 +209,7 @@ bool DjVuGenerator::print( QPrinter& printer )
QMutexLocker locker( userMutex() );
QList<int> pageList = Okular::FilePrinter::pageList( printer, m_djvu->pages().count(),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
if ( m_djvu->exportAsPostScript( &tf, pageList ) )

View File

@ -553,6 +553,7 @@ bool DviGenerator::print( QPrinter& printer )
QList<int> pageList = Okular::FilePrinter::pageList( printer,
m_dviRenderer->totalPages(),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
QString pages;
QStringList printOptions;

View File

@ -894,6 +894,7 @@ bool PDFGenerator::print( QPrinter& printer )
// Generate the list of pages to be printed as selected in the print dialog
QList<int> pageList = Okular::FilePrinter::pageList( printer, pdfdoc->numPages(),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
// TODO rotation

View File

@ -111,6 +111,7 @@ bool GSGenerator::print( QPrinter& printer )
// Get list of pages to print
QList<int> pageList = Okular::FilePrinter::pageList( printer,
spectre_document_get_n_pages( m_internalDocument ),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
// Default to Postscript export, but if printing to PDF use that instead

View File

@ -386,6 +386,7 @@ bool TIFFGenerator::print( QPrinter& printer )
QPainter p( &printer );
QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
for ( tdir_t i = 0; i < pageList.count(); ++i )

View File

@ -2186,6 +2186,7 @@ bool XpsGenerator::exportTo( const QString &fileName, const Okular::ExportFormat
bool XpsGenerator::print( QPrinter &printer )
{
QList<int> pageList = Okular::FilePrinter::pageList( printer, document()->pages(),
document()->currentPage() + 1,
document()->bookmarkedPageList() );
QPainter painter( &printer );

View File

@ -1948,6 +1948,14 @@ void Part::slotPrint()
printDialog->setEnabledOptions( printDialog->enabledOptions() ^ QAbstractPrintDialog::PrintToFile );
}
#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
// Enable the Current Page option in the dialog.
if ( m_document->pages() > 1 && currentPage() > 0 )
{
printDialog->setOption( QAbstractPrintDialog::PrintCurrentPage );
}
#endif
if ( printDialog->exec() )
doPrint( printer );
delete printDialog;