Bug 194586 - add option to print current page in print dialog
Summary: add option to print current page in print dialog
Status: RESOLVED FIXED
Alias: None
Product: kdelibs
Classification: Frameworks and Libraries
Component: print-dialog (show other bugs)
Version: unspecified
Platform: unspecified Linux
: NOR wishlist
Target Milestone: ---
Assignee: John Layt
URL:
Keywords:
: 208990 214306 219988 240633 (view as bug list)
Depends on:
Blocks:
 
Reported: 2009-05-29 20:23 UTC by Luiz Angelo De Luca
Modified: 2012-04-10 14:38 UTC (History)
6 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luiz Angelo De Luca 2009-05-29 20:23:46 UTC
Version:           0.8.80 (using 4.2.86 (KDE 4.2.86 (KDE 4.3 >= 20090514)) "release 126", KDE:KDE4:Factory:Desktop / openSUSE_11.1)
Compiler:          gcc
OS:                Linux (x86_64) release 2.6.27.21-0.1-default

I can print all the pages or a specific range but not the current one.
I suggest that a third option is added, "print current page", and maybe also
include which one is the current page:


* print current page: page 45
Comment 2 Luiz Angelo De Luca 2009-05-29 21:20:21 UTC
I see... Should I keep this bug open?
Comment 3 John Layt 2009-07-09 11:58:04 UTC
I'm working on this one
Comment 4 Pino Toscano 2009-11-14 19:32:40 UTC
*** Bug 208990 has been marked as a duplicate of this bug. ***
Comment 5 Pino Toscano 2009-11-14 19:32:54 UTC
*** Bug 214306 has been marked as a duplicate of this bug. ***
Comment 6 Christoph Feck 2009-12-26 02:41:46 UTC
*** Bug 219988 has been marked as a duplicate of this bug. ***
Comment 7 John Layt 2010-03-04 16:18:38 UTC
This feature has been merged into Qt for release 4.7.  Once that becomes available, each app will need to be updated to enable the option.  This will hopefully be possible for KDE 4.5.
Comment 8 ralfgesellensetter 2010-03-04 19:32:38 UTC
I see, Qt is missing this feature as I understand it.

Could you possibly suggest a code snippet based on 
preprocessor settings that can already added now, 
so it would be enabled as soon as possible?

I mean something like

#ifdefined QT4.7
...
#endif

Regards
Ralf
Comment 9 John Layt 2010-03-05 10:19:31 UTC
Yep, sure can.

Just after you create the print dialog using KdePrint::createPrintDialog(), do something like:

#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
    dialog->setOption(QAbstractPrintDialog::PrintCurrentPage);
#endif

Then once you are reading back the results from the print dialog you will be checking the QPrinter::printRange() setting to see whether to print QPrinter::AllPages or QPrinter::PageRange or QPrinter::Selection, you now need to check for QPrinter::CurrentPage as well, something like this:

#if QT_VERSION >= KDE_MAKE_VERSION(4,7,0)
    if (printer->printRange() == QPrinter::CurrentPage) {
        myPrintPageRoutine(m_myCurrentPageNumber);
    }
#endif

Hope that helps.  Once we have a firm release date for Qt 4.7 and know what the KDE 4.5 dependency policy is going to be, I'll look at whether to do this across all the major KDE apps.
Comment 10 ralfgesellensetter 2010-03-13 15:09:57 UTC
Hey John,

thank you very much, I hope that developers C&P your snippet!
That would make their dialoges "KDE 4.7 ready" ;)

As the actual version number seems not to be fixed yet, it might be wiser to define a macro like #define __QT_READY_TO_PRINT_CURRENT_PAGE__ in a central place to be used globally. Then it is easier to change the condition in one central place the version needed changes to 4.6 or 4.8.

Apart from this, I can't imagine that a workaround would be that hard till then: PseudoCode:
If the "PrintCurrentPage" button is hit:
 -setPageRange(getCurrentpage(),getCurrentpage()) + Commit.
Comment 11 John Layt 2010-03-13 18:30:07 UTC
This is definitely in Qt 4.7, its now available in the official Gitorious 4.7 branch, so that's what we need to check for.  Don't be fooled by the "KDE_MAKE_VERSION(4,7,0)" macro name, that's just a KDE provided macro to create a version number, not the KDE version number itself.  It's the "QT_VERSION >=" part that holds the Qt version number that we need to compare.

Whichever version of KDE officially depends on Qt 4.7 will bea able to have the ifdef's removed.
Comment 12 Pino Toscano 2010-06-03 20:07:35 UTC
*** Bug 240633 has been marked as a duplicate of this bug. ***
Comment 13 Pino Toscano 2010-06-03 20:10:11 UTC
John? What about adding the needed code in kdeui, please?
Comment 14 John Layt 2010-06-03 22:39:03 UTC
Thanks for the reminder Pino.  

This cannot be globally enabled in kdeui as not all apps need it or can use it.  An app needs to:
* Have document pages
* Know what its current page is
* Know what to do when told to print the current page

So it can only be enabled at the app level.

The only SC app I can think of is Okular, and some apps in KOffice.  We can't do KHtmlPart or KatePart as they have no idea what page they are on until they have printed the document, their authors would need to make major changes to know page breaks in advance (and how would Konqi then know what the current page is?).  Any other suggestions?

I'll do Okular, and let the KOffice guys know they now have the option.
Comment 15 John Layt 2010-06-04 10:19:11 UTC
SVN commit 1134379 by jlayt:

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



 M  +8 -2      core/fileprinter.cpp  
 M  +3 -2      core/fileprinter.h  
 M  +1 -0      generators/comicbook/generator_comicbook.cpp  
 M  +1 -0      generators/djvu/generator_djvu.cpp  
 M  +1 -0      generators/dvi/generator_dvi.cpp  
 M  +1 -0      generators/poppler/generator_pdf.cpp  
 M  +1 -0      generators/spectre/generator_ghostview.cpp  
 M  +1 -0      generators/tiff/generator_tiff.cpp  
 M  +1 -0      generators/xps/generator_xps.cpp  
 M  +8 -0      part.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1134379
Comment 16 John Layt 2010-06-04 20:57:49 UTC
SVN commit 1134631 by jlayt:

Whoops!  Didn't relise we had an API/BIC guarantee on Okular.  Restore previous
API and make it call the new API.

CCMAIL: kde-bindings@kde.org
CCMAIL: aacid@kde.org
CCBUG: 194586



 M  +5 -0      fileprinter.cpp  
 M  +10 -0     fileprinter.h  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1134631
Comment 17 Peter Flynn 2010-06-06 22:41:14 UTC
(In reply to comment #14)
[...]
> The only SC app I can think of is Okular, and some apps in KOffice.  We can't
> do KHtmlPart or KatePart as they have no idea what page they are on until they
> have printed the document, their authors would need to make major changes to
> know page breaks in advance (and how would Konqi then know what the current
> page is?).  Any other suggestions?

The most important in unpaged documents (eg web pages) is for users to be able to restrict printing to the first page (eg airline confirmation, so that you don't need to bother printing the remaining 5-6 pages of dense legal blurb every time you fly :-)  Users may be able to select Page 1 in the regular page selector, but adding an obvious "Print current page only" button would be a major enhancement.

> I'll do Okular, and let the KOffice guys know they now have the option.

Excellent news, thanks very much. It is a critical function for anyone doing document development, typesetting, etc (which is why I'm still using kpdf and kdvi :-)
Comment 18 John Layt 2010-06-07 18:55:56 UTC
For unpaged docs defaulting Current Page to page 1 might be a bit misleading to users if it's a long document and they have scrolled to the middle or very end, they would expect what's currently displayed in the scroll view to be printed.  However since 4.4 you can choose the page range in web an text docuemnts if you are using CUPS for printing (i.e. 99% likely), and the dialog defaults the print range to pages 1 to 1, so it is just a single click like Current Page would be.  For any other page of the document it's a case of good guessing or using the print preview first.
Comment 19 davidblunkett 2010-10-24 17:41:01 UTC
Okular also needs additional functionality in the print page range as per acroread where you can print pages: 1,4,7,11-20,75 etc all in one go.  Since I had to got through the print dialogue 3 time to print page 74, 77 and 79 I can testify this is a feature sorely missed!
Comment 20 ralfgesellensetter 2010-11-02 20:37:43 UTC
@david: this was also possible with kpdf under KDE 3.x

I am a teacher and used it a lot when I printed pages half size (2 on 1 page)
to save paper (ecology!). I just entered "1,1" as page range, and then enabled the option "2 pages on 1" for the printer.

Nowadays, it is a long and weary workflow, whenever I want to save paper:

I open PDF with open office draw, and then I copy the page, export to PDF (because Openoffice cannot use the "2 on 1" option), go back to okular then and print 2 on 1...
Comment 21 davidblunkett 2010-11-03 09:37:35 UTC
Acroread manages the "which page is it" problem by providing a small preview window in the print dialog which shows the current print page and the orientation etc.  This is a very nice feature that okular should aspire to.
Comment 22 Luiz Angelo De Luca 2012-04-10 14:38:36 UTC
As the original request is already provided in current kde relases, I'll close it