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

List:       kde-devel
Subject:    Re: [PATCH] Make kslideshow.kss work again
From:       Arno <arno () disconnect ! de>
Date:       2008-05-02 13:54:26
Message-ID: 200805021554.27126.arno () disconnect ! de
[Download RAW message or body]

Hello,

On Friday 02 May 2008 13:11:47 Oswald Buddenhagen wrote:
> > When I let the QPainter draw the QPolygon, it only outlines it, but
> > doesn't fill it.
>
> i'd venture the guess that something is wrong with the brush. maybe use
> setTexture instead of setPixmap (which is qt3 support anyway).

Well, I was thinking way too complex. I didn't see the wood for the trees 
here, but I got it. Thanks for the hint :)

I revised the patch and split it up as you requested:
1. make it work again
2. fix headers
3. remove bitBlt

They should be applied in that order.

-- 
Regards,

Arno.

["slideshow.cpp.make.it.work.again.patch" (text/x-diff)]

--- slideshow.cpp.old	2008-05-01 13:13:07.631248708 +0200
+++ slideshow.cpp	2008-05-02 14:45:00.323493526 +0200
@@ -119,6 +119,7 @@
   {
     mGeoList.append(mScreenGeo(width(), height(), 0, 0));
   }
+  setAttribute(Qt::WA_NoSystemBackground);
   createNextScreen();
 }
 
@@ -693,6 +694,13 @@
 //-----------------------------------------------------------------------------
 void kSlideShowSaver::slotTimeout()
 {
+  update();
+}
+
+
+//-----------------------------------------------------------------------------
+void kSlideShowSaver::paintEvent(QPaintEvent *)
+{
   int tmout = -1;
   int i;
 

["slideshow.h.make.it.work.again.patch" (text/x-diff)]

--- slideshow.h.old	2008-05-01 13:13:16.633547111 +0200
+++ slideshow.h	2008-05-02 14:45:18.420095405 +0200
@@ -89,6 +89,7 @@
   /** Init mPainter with next-screen's pixmap and call
       mPainter.begin(&mWidget) */
   void startPainter(Qt::PenStyle penStyle=Qt::NoPen);
+  void paintEvent(QPaintEvent *);
 
 protected:
   struct mScreenGeo {

["slideshow.h.remove.bitBlt.calls.patch" (text/x-diff)]

--- slideshow.h.old	2008-05-02 14:59:01.038184296 +0200
+++ slideshow.h	2008-05-02 15:37:33.611762847 +0200
@@ -86,9 +86,6 @@
   int effectMultiCircleOut(bool doInit);
 
 protected:
-  /** Init mPainter with next-screen's pixmap and call
-      mPainter.begin(&mWidget) */
-  void startPainter(Qt::PenStyle penStyle=Qt::NoPen);
   void paintEvent(QPaintEvent *);
 
 protected:

["slideshow.cpp.header.fix.patch" (text/x-diff)]

--- slideshow.cpp.old	2008-05-02 14:53:41.769250365 +0200
+++ slideshow.cpp	2008-05-02 14:52:17.588426049 +0200
@@ -10,15 +10,15 @@
  */
 
 
-#include <qdir.h>
-#include <qcolor.h>
-#include <qlabel.h>
-#include <qlayout.h>
-#include <qfile.h>
-#include <qcheckbox.h>
-#include <qcombobox.h>
-#include <qspinbox.h>
-#include <qdesktopwidget.h>
+#include <QDir>
+#include <QColor>
+#include <QLabel>
+#include <QLayout>
+#include <QFile>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QSpinBox>
+#include <QDesktopWidget>
 #include <QImage>
 #include <QPixmap>
 #include <QPolygon>

["slideshow.h.header.fix.patch" (text/x-diff)]

--- slideshow.h.old	2008-05-02 14:55:06.563089635 +0200
+++ slideshow.h	2008-05-02 14:51:19.110159718 +0200
@@ -7,11 +7,11 @@
 #ifndef SLIDESHOW_H
 #define SLIDESHOW_H
 
-#include <qtimer.h>
-#include <qstringlist.h>
-#include <qpixmap.h>
-#include <qpainter.h>
-#include <qimage.h>
+#include <QTimer>
+#include <QStringList>
+#include <QPixmap>
+#include <QPainter>
+#include <QImage>
 
 #include <kscreensaver.h>
 #include <kdialog.h>

["slideshow.cpp.remove.bitBlt.calls.patch" (text/x-diff)]

--- slideshow.cpp.old	2008-05-02 14:58:43.101794130 +0200
+++ slideshow.cpp	2008-05-02 15:34:57.965101732 +0200
@@ -195,7 +195,6 @@
 
   if (aInit)
   {
-    startPainter();
     mw = width();
     mh = height();
     mx = mw;
@@ -212,11 +211,17 @@
 
   if (mAlpha < 0)
   {
-    mPainter.end();
     showNextScreen();
     return -1;
   }
 
+  QPainter p(this);
+  QBrush brush;
+  brush.setTexture(mNextScreen);
+  QPen pen(Qt::NoPen);
+  p.setBrush(brush);
+  p.setPen(pen);
+
   for (alpha=mAlpha, i=mi; i>=0; i--, alpha+=mfd)
   {
     x = (mw>>1) + (int)(mfy * cos(-alpha));
@@ -228,7 +233,7 @@
     pa.setPoint(1, x, y);
     pa.setPoint(2, mx, my);
 
-    mPainter.drawPolygon(pa);
+    p.drawPolygon(pa);
   }
   mAlpha -= mfx;
 
@@ -241,7 +246,6 @@
 {
   if (aInit)
   {
-    startPainter();
     mw = width();
     mh = height();
     mix = mw / 8;
@@ -260,7 +264,6 @@
 
   if (mi==0 && mx0>=mx1)
   {
-    mPainter.end();
     showNextScreen();
     return -1;
   }
@@ -294,7 +297,8 @@
     my0 += miy;
   }
 
-  bitBlt(this, mx, my, &mNextScreen, mx, my, mix, miy);
+  QPainter p(this);
+  p.drawPixmap(mx, my, mNextScreen, mx, my, mix, miy);
 
   mx += mdx;
   my += mdy;
@@ -324,14 +328,15 @@
   }
 
   done = true;
+
+  QPainter p(this);
   for (i=0,x=0; i<mix; i++,x+=mdx)
   {
     y = mIntArray[i];
     if (y >= mh) continue;
     done = false;
     if ((KRandom::random()&15) < 6) continue;
-    bitBlt(this, x, y+mdy, this, x, y, mdx, mh-y-mdy);
-    bitBlt(this, x, y, &mNextScreen, x, y, mdx, mdy);
+    p.drawPixmap(x, y, mNextScreen, x, y, mdx, mdy);
     mIntArray[i] += mdy;
   }
 
@@ -354,7 +359,6 @@
 
   if (aInit)
   {
-    startPainter();
     mw = width();
     mh = height();
     mx = mw;
@@ -368,7 +372,6 @@
 
   if (mAlpha < 0)
   {
-    mPainter.end();
     showNextScreen();
     return -1;
   }
@@ -382,7 +385,14 @@
   pa.setPoint(1, x, y);
   pa.setPoint(2, mx, my);
 
-  mPainter.drawPolygon(pa);
+  QBrush brush;
+  brush.setTexture(mNextScreen);
+  QPen pen(Qt::NoPen);
+  QPainter p(this);
+  p.setBrush(brush);
+  p.setPen(pen);
+
+  p.drawPolygon(pa);
 
   return 20;
 }
@@ -406,6 +416,7 @@
     my  = (mSubType==3 ? 0 : mh);
   }
 
+  QPainter p(this);
   if (mSubType==0 || mSubType==1)
   {
     // horizontal sweep
@@ -416,7 +427,7 @@
     }
     for (w=2,i=4,x=mx; i>0; i--, w<<=1, x-=mdx)
     {
-      bitBlt(this, x, 0, &mNextScreen, x, 0, w, mh);
+      p.drawPixmap(x, 0, mNextScreen, x, 0, w, mh);
     }
     mx += mdx;
   }
@@ -430,7 +441,7 @@
     }
     for (h=2,i=4,y=my; i>0; i--, h<<=1, y-=mdy)
     {
-      bitBlt(this, 0, y, &mNextScreen, 0, y, mw, h);
+      p.drawPixmap(0, y, mNextScreen, 0, y, mw, h);
     }
     my += mdy;
   }
@@ -446,7 +457,6 @@
 
   if (aInit)
   {
-    startPainter();
     mAlpha = M_PI * 2;
     mw = width();
     mh = height();
@@ -455,7 +465,6 @@
 
   if (mi <= 0)
   {
-    mPainter.end();
     showNextScreen();
     return -1;
   }
@@ -464,7 +473,14 @@
   my = KRandom::random() % mh;
   r = (KRandom::random() % 200) + 50;
 
-  mPainter.drawEllipse(mx-r, my-r, r, r);
+  QBrush brush;
+  brush.setTexture(mNextScreen);
+  QPen pen(Qt::NoPen);
+  QPainter p(this);
+  p.setBrush(brush);
+  p.setPen(pen);
+  p.drawEllipse(mx-r, my-r, r, r);
+
   mi--;
 
   return 10;
@@ -482,11 +498,12 @@
   h = height() >> fact;
   sz = 1 << fact;
 
+  QPainter p(this);
   for (i = (w*h)<<1; i > 0; i--)
   {
     x = (KRandom::random() % w) << fact;
     y = (KRandom::random() % h) << fact;
-    bitBlt(this, x, y, &mNextScreen, x, y, sz, sz);
+    p.drawPixmap(x, y, mNextScreen, x, y, sz, sz);
   }
   showNextScreen();
 
@@ -518,8 +535,11 @@
     return -1;
   }
 
-  bitBlt(this, mx, my, &mNextScreen, mx, my,
-	 mw - (mx<<1), mh - (my<<1));
+  if((mw - (mx<<1) == 0) && (mh - (my<<1) == 0))
+    return 1;
+
+  QPainter p(this);
+  p.drawPixmap(mx, my, mNextScreen, mx, my, mw - (mx<<1), mh - (my<<1));
 
   return 20;
 }
@@ -555,12 +575,11 @@
   miy = miy ? 0 : mdy;
   my  = my ? 0 : mdy;
 
+  QPainter p(this);
   for (y=0; y<mw; y+=(mdy<<1))
   {
-    bitBlt(this, mix, y+miy, &mNextScreen, mix, y+miy,
-	   mdx, mdy);
-    bitBlt(this, mx, y+my, &mNextScreen, mx, y+my,
-	   mdx, mdy);
+    p.drawPixmap(mix, y+miy, mNextScreen, mix, y+miy, mdx, mdy);
+    p.drawPixmap(mx, y+my, mNextScreen, mx, y+my, mdx, mdy);
   }
 
   return mwait;
@@ -597,21 +616,25 @@
   y1 = mh - my;
   mi++;
 
+  if((mx==0) && (my==0))
+    return 1; // otherwise drawPixmap draws the bottom-right of mNextScreen
+
+  QPainter p(this);
   if (mSubType)
   {
     // moving image edges
-    bitBlt(this,  0,  0, &mNextScreen, mix-mx, miy-my, mx, my);
-    bitBlt(this, x1,  0, &mNextScreen, mix, miy-my, mx, my);
-    bitBlt(this,  0, y1, &mNextScreen, mix-mx, miy, mx, my);
-    bitBlt(this, x1, y1, &mNextScreen, mix, miy, mx, my);
+    p.drawPixmap(0, 0, mNextScreen, mix-mx, miy-my, mx, my);
+    p.drawPixmap(x1, 0, mNextScreen, mix, miy-my, mx, my);
+    p.drawPixmap(0, y1, mNextScreen, mix-mx, miy, mx, my);
+    p.drawPixmap(x1, y1, mNextScreen, mix, miy, mx, my);
   }
   else
   {
     // fixed image edges
-    bitBlt(this,  0,  0, &mNextScreen,  0,  0, mx, my);
-    bitBlt(this, x1,  0, &mNextScreen, x1,  0, mx, my);
-    bitBlt(this,  0, y1, &mNextScreen,  0, y1, mx, my);
-    bitBlt(this, x1, y1, &mNextScreen, x1, y1, mx, my);
+    p.drawPixmap(0, 0, mNextScreen,  0,  0, mx, my);
+    p.drawPixmap(x1, 0, mNextScreen, x1,  0, mx, my);
+    p.drawPixmap(0, y1, mNextScreen,  0, y1, mx, my);
+    p.drawPixmap(x1, y1, mNextScreen, x1, y1, mx, my);
   }
   return 20;
 }
@@ -632,9 +655,10 @@
 
   if (iyPos[mi] < 0) return -1;
 
+  QPainter p(this);
   for (y=iyPos[mi]; y<mh; y+=8)
   {
-    bitBlt(this, 0, y, &mNextScreen, 0, y, mw, 1);
+    p.drawPixmap(0, y, mNextScreen, 0, y, mw, 1);
   }
 
   mi++;
@@ -658,9 +682,10 @@
 
   if (ixPos[mi] < 0) return -1;
 
+  QPainter p(this);
   for (x=ixPos[mi]; x<mw; x+=8)
   {
-    bitBlt(this, x, 0, &mNextScreen, x, 0, 1, mh);
+    p.drawPixmap(x, 0, mNextScreen, x, 0, 1, mh);
   }
 
   mi++;
@@ -670,18 +695,6 @@
 
 
 //-----------------------------------------------------------------------------
-void kSlideShowSaver::startPainter(Qt::PenStyle aPen)
-{
-  QBrush brush;
-  brush.setPixmap(mNextScreen);
-  if (mPainter.isActive()) mPainter.end();
-  mPainter.begin(this);
-  mPainter.setBrush(brush);
-  mPainter.setPen(aPen);
-}
-
-
-//-----------------------------------------------------------------------------
 void kSlideShowSaver::restart()
 {
   mEffectRunning = false;
@@ -732,8 +745,8 @@
 //----------------------------------------------------------------------------
 void kSlideShowSaver::showNextScreen()
 {
-  bitBlt(this, 0, 0, &mNextScreen, 0, 0,
-	 mNextScreen.width(), mNextScreen.height());
+  QPainter p(this);
+  p.drawPixmap(0, 0, mNextScreen, 0, 0, mNextScreen.width(), mNextScreen.height());
 }
 
 


>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<


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

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