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

List:       kde-commits
Subject:    KDE/kdebase/workspace/plasma/generic/wallpapers/image
From:       Aaron J. Seigo <aseigo () kde ! org>
Date:       2010-12-15 7:17:22
Message-ID: 20101215071722.70885AC8A8 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1206644 by aseigo:

if the wallpaper file changes on disk, reload it. together with the cache \
modification time checking, this should catch all instances of "changing the \
wallpaper" (at least, i tested both the "plasma isn't running" and the "plasma is \
running" cases) CCMAIL:wstephenson@kde.org


 M  +19 -3     image.cpp  
 M  +3 -0      image.h  


--- trunk/KDE/kdebase/workspace/plasma/generic/wallpapers/image/image.cpp \
#1206643:1206644 @@ -39,6 +39,7 @@
 
 Image::Image(QObject *parent, const QVariantList &args)
     : Plasma::Wallpaper(parent, args),
+      m_fileWatch(new KDirWatch(this)),
       m_configWidget(0),
       m_wallpaperPackage(0),
       m_currentSlide(-1),
@@ -53,6 +54,8 @@
     connect(this, SIGNAL(renderCompleted(QImage)), this, \
                SLOT(updateBackground(QImage)));
     connect(this, SIGNAL(urlDropped(KUrl)), this, SLOT(setWallpaper(KUrl)));
     connect(&m_timer, SIGNAL(timeout()), this, SLOT(nextSlide()));
+    connect(m_fileWatch, SIGNAL(dirty(QString)), this, \
SLOT(imageFileAltered(QString))); +    connect(m_fileWatch, SIGNAL(created(QString)), \
this, SLOT(imageFileAltered(QString)));  }
 
 Image::~Image()
@@ -420,8 +423,8 @@
         if (img.isEmpty()) {
             img = m_wallpaper;
         }
+    } else {
     //if it's not an absolute path, check if it's just a wallpaper name
-    } else {
         const QString path = KStandardDirs::locate("wallpaper", m_wallpaper + \
"/metadata.desktop");  
         if (!path.isEmpty()) {
@@ -433,7 +436,6 @@
         }
     }
 
-
     if (!m_size.isEmpty()) {
         renderWallpaper(img);
     }
@@ -544,7 +546,7 @@
         return;
     }
 
-    if (b->structure()->contentsPrefix().isEmpty()) {
+    if (b->structure()->contentsPrefixPaths().isEmpty()) {
         // it's not a full package, but a single paper
         m_wallpaper = b->filePath("preferred");
     } else {
@@ -699,6 +701,10 @@
 
 void Image::renderWallpaper(const QString& image)
 {
+    if (!m_img.isEmpty()) {
+        m_fileWatch->removeFile(m_img);
+    }
+
     if (!image.isEmpty()) {
         m_img = image;
     }
@@ -707,9 +713,19 @@
         return;
     }
 
+    m_fileWatch->addFile(m_img);
     render(m_img, m_size, m_resizeMethod, m_color);
 }
 
+void Image::imageFileAltered(const QString &path)
+{
+    if (path == m_img) {
+        renderWallpaper(path);
+    } else {
+        // somehow this got added to the dirwatch, but we don't care about it \
anymore +        m_fileWatch->removeFile(path);
+    }
+}
 void Image::updateBackground(const QImage &img)
 {
     m_oldPixmap = m_pixmap;
--- trunk/KDE/kdebase/workspace/plasma/generic/wallpapers/image/image.h \
#1206643:1206644 @@ -23,6 +23,7 @@
 
 class QPropertyAnimation;
 
+class KDirWatch;
 class KFileDialog;
 class KJob;
 
@@ -81,6 +82,7 @@
         void addDirFromSelectionDialog();
         void systemCheckBoxToggled(bool);
         void downloadedCheckBoxToggled(bool);
+        void imageFileAltered(const QString &path);
 
     protected:
         void init(const KConfigGroup &config);
@@ -100,6 +102,7 @@
         QString m_wallpaper;
         QColor m_color;
         QStringList m_usersWallpapers;
+        KDirWatch *m_fileWatch;
 
         QWidget* m_configWidget;
         Ui::ImageConfig m_uiImage;


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

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