[prev in list] [next in list] [prev in thread] [next in thread] 

List:       koffice-devel
Subject:    Re: KoPrintingDialog
From:       Stefan Nikolaus <stefan.nikolaus () kdemail ! net>
Date:       2008-05-31 12:50:59
Message-ID: 200805311451.02501.stefan.nikolaus () kdemail ! net
[Download RAW message or body]

[Attachment #2 (multipart/signed)]


On Saturday, 31. May 2008 14:26:41 Thomas Zander wrote:
> On Saturday 31. May 2008 12:00:15 Stefan Nikolaus wrote:
> > Okay, one more thing: the painter saving/restoring looks odd. I do not
> > understand that behavior. Attached my proposal how it should work.
>
> The odd thing is that we have hooks and thus have to save / restore in
> different methods.
> Taking into account stopping and restarting.

Restarting? I can only see stopping.

> Your patch would break saving/restoring around the preparePage call. So
> this 'weirdness' has to be kept I'm afraid.

I've modified the patch a bit and commited some time ago. Is that patch okay? 
After one page was prepared and printed it returns to the same painter state. 
This was not done before.


SVN commit 814840 by nikolaus:

Paint the shapes after KoPrintDialog::printPage(int, QPainter&) has been 
called.

Save the painter states before and after page preparation and restore them 
appropriately.


 M  +8 -10     KoPrintingDialog.cpp  


--- trunk/koffice/libs/guiutils/KoPrintingDialog.cpp #814839:814840
@@ -67,19 +67,16 @@
     void preparePage(const QVariant &page) {
         const int pageNumber = page.toInt();
         KoUpdater updater = updaters.at(index-1);
-        const bool doSave = painter == 0;
-        if (painter)
-            painter->save();
+        if (!painter)
+            painter = new QPainter(printer);
+        painter->save(); // state before page preparation
         if(! stop)
             parent->preparePage(pageNumber);
         updater.setProgress(45);
         if (index > 1)
             printer->newPage();
         updater.setProgress(55);
-        if (painter == 0)
-            painter = new QPainter(printer);
-        if (doSave)
-            painter->save(); // make sure we saved to match the restore later 
on.
+        painter->save(); // state after page preparation
 
         QList<KoShape*> shapes = parent->shapesOnPage(pageNumber);
         if (shapes.isEmpty()) {
@@ -107,12 +104,13 @@
     }
 
     void printPage(const QVariant &page) {
-        if(! stop)
-            shapeManager->paint( *painter, zoomer, true );
-        painter->restore(); // matching the one in preparePage above
+        painter->restore(); // state after page preparation
         painter->save();
         parent->printPage(page.toInt(), *painter);
         painter->restore();
+        if (!stop)
+            shapeManager->paint(*painter, zoomer, true);
+        painter->restore(); // state before page preparation
 
         if(!stop && index < pages.count()) {
             pageNumber->setText(i18n("Printing page %1", 
QString::number(pages[index])));
-- 
Regards,
Stefan

["signature.asc" (application/pgp-signature)]

_______________________________________________
koffice-devel mailing list
koffice-devel@kde.org
https://mail.kde.org/mailman/listinfo/koffice-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic