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

List:       kde-panel-devel
Subject:    Re: Review Request: Add fade effect to wallpaper plugin.
From:       Matthew Dawson <matthewjd () gmail ! com>
Date:       2009-02-26 21:52:20
Message-ID: 200902261652.24814.matthewjd () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


Hello,

Unfortunately, reviewboard is not accepting this updated diff, so I'm posting it \
here.  I'm not sure why I thought it didn't work with single images, but it does now. \
It also works in the configuration dialog box :).

Matthew

On Thursday 26 February 2009 16:02:31 Artur de Souza (MoRpHeUz) wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviewboard.kde.org/r/195/#review287
> -----------------------------------------------------------
> 
> 
> Hmm...the idea is pretty nice. Why it doesn't work for single images wallpapers \
> (just slideshow) ? Hehe, and this is the typical feature that is trivial to do with \
> Qt Kinetic ;) 
> Cheers
> 
> - Artur
> 
> 
> On 2009-02-26 12:24:44, Matthew Dawson wrote:
> > 
> > -----------------------------------------------------------
> > This is an automatically generated e-mail. To reply, visit:
> > http://reviewboard.kde.org/r/195/
> > -----------------------------------------------------------
> > 
> > (Updated 2009-02-26 12:24:44)
> > 
> > 
> > Review request for Plasma.
> > 
> > 
> > Summary
> > -------
> > 
> > This patch makes the wallpaper plugin fade out the old wallpaper when it changes. \
> > Currently the effect only works when in slideshow mode. 
> > Video Demo:
> > http://mjdsystems.ca/fadedemo.ogv
> > 
> > 
> > This addresses bug 168731.
> > https://bugs.kde.org/show_bug.cgi?id=168731
> > 
> > 
> > Diffs
> > -----
> > 
> > /trunk/KDE/kdebase/workspace/plasma/wallpapers/image/image.h 932504 
> > /trunk/KDE/kdebase/workspace/plasma/wallpapers/image/image.cpp 932504 
> > 
> > Diff: http://reviewboard.kde.org/r/195/diff
> > 
> > 
> > Testing
> > -------
> > 
> > Locally in Xephyr.
> > 
> > 
> > Thanks,
> > 
> > Matthew
> > 
> > 
> 
> 


["wallpaper2.diff" (text/x-diff)]

Index: workspace/plasma/wallpapers/image/image.cpp
===================================================================
--- workspace/plasma/wallpapers/image/image.cpp	(revision 932504)
+++ workspace/plasma/wallpapers/image/image.cpp	(working copy)
@@ -32,15 +32,20 @@
 
 Image::Image(QObject *parent, const QVariantList &args)
     : Plasma::Wallpaper(parent, args),
+      m_fadeTimeLine(1500),
       m_currentSlide(-1),
       m_model(0),
       m_dialog(0),
       m_rendererToken(-1),
       m_randomize(true)
 {
+    //Start at frame 1 otherwise their is a nasty black flicker.
+    m_fadeTimeLine.setFrameRange(1, 255);
+
     qRegisterMetaType<QImage>("QImage");
     connect(&m_renderer, SIGNAL(done(int, QImage)), this, SLOT(updateBackground(int, QImage)));
     connect(&m_timer, SIGNAL(timeout()), this, SLOT(nextSlide()));
+    connect(&m_fadeTimeLine, SIGNAL(frameChanged(int)), this, SLOT(updateFadedImage(int)));
 }
 
 Image::~Image()
@@ -233,6 +238,12 @@
     // bitmapBackground already has the size of the viewport)
     painter->drawPixmap(exposedRect, m_pixmap, exposedRect);
 
+    if(m_fadeTimeLine.state() == QTimeLine::Running && !m_oldFadedPixmap.isNull()){
+        // Put old faded image on top.
+        painter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
+        painter->drawPixmap(exposedRect, m_oldFadedPixmap, exposedRect);
+    }
+
     // restore transformation and composition mode
     painter->restore();
 }
@@ -525,9 +536,19 @@
 
 void Image::updateBackground(int token, const QImage &img)
 {
+
     if (m_rendererToken == token) {
+
+        m_oldPixmap = m_pixmap;
+        if(m_oldPixmap.isNull()){
+            m_oldPixmap = QPixmap(img.size());
+            m_oldPixmap.fill(m_color);
+        }
+        m_oldFadedPixmap = m_oldPixmap;
+
         m_pixmap = QPixmap::fromImage(img);
-        emit update(boundingRect());
+
+        m_fadeTimeLine.start();
         suspendStartup(false);
     }
 }
@@ -555,4 +576,22 @@
     }
 }
 
+void Image::updateFadedImage(int frame){
+   
+    //Create the faded image.
+    m_oldFadedPixmap.fill(Qt::transparent);
+
+    QPainter p;
+    p.begin(&m_oldFadedPixmap);
+    p.drawPixmap(0, 0, m_oldPixmap);
+
+    p.setCompositionMode(QPainter::CompositionMode_DestinationIn);  
+    p.fillRect(m_oldFadedPixmap.rect(), QColor(0, 0, 0, 255-frame));//255*((150 - frame)/150)));
+
+    p.end();
+
+    emit update(boundingRect());
+
+}
+
 #include "image.moc"
Index: workspace/plasma/wallpapers/image/image.h
===================================================================
--- workspace/plasma/wallpapers/image/image.h	(revision 932504)
+++ workspace/plasma/wallpapers/image/image.h	(working copy)
@@ -12,6 +12,7 @@
 #define IMAGE_HEADER
 
 #include <QTimer>
+#include <QTimeLine>
 #include <QPixmap>
 #include <QStringList>
 #include <Plasma/Wallpaper>
@@ -49,6 +50,7 @@
         void showFileDialog();
         void updateScreenshot(QPersistentModelIndex index);
         void removeBackground(const QString &path);
+        void updateFadedImage(int frame);
 
     protected:
         void init(const KConfigGroup &config);
@@ -76,6 +78,9 @@
         QList<Background *> m_slideshowBackgrounds;
         QTimer m_timer;
         QPixmap m_pixmap;
+        QPixmap m_oldPixmap;
+        QPixmap m_oldFadedPixmap;
+        QTimeLine m_fadeTimeLine;
         int m_currentSlide;
         qreal m_ratio;
         BackgroundListModel *m_model;

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

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


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

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