[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-09-26 19:38:24
Message-ID: 20100926193824.B96F3AC857 () svn ! kde ! org
[Download RAW message or body]

SVN commit 1180026 by aseigo:

m_wallpaperPackage can be null; as a bonus feature: enable/disable the actions when \
there are no wallpaper items BUG:252311


 M  +33 -8     image.cpp  


--- trunk/KDE/kdebase/workspace/plasma/generic/wallpapers/image/image.cpp \
#1180025:1180026 @@ -105,6 +105,7 @@
         actions.push_back(m_nextWallpaperAction);
         actions.push_back(m_openImageAction);
         setContextualActions(actions);
+        updateWallpaperActions();
     }
 
     m_animation = new QPropertyAnimation(this, "fadeValue");
@@ -196,9 +197,9 @@
         m_uiSlideshow.m_dirlist->setCurrentRow(0);
         updateDirs();
         m_uiSlideshow.m_addDir->setIcon(KIcon("list-add"));
-        connect(m_uiSlideshow.m_addDir, SIGNAL(clicked()), this, \
SLOT(slotAddDir())); +        connect(m_uiSlideshow.m_addDir, SIGNAL(clicked()), \
this, SLOT(addDir()));  m_uiSlideshow.m_removeDir->setIcon(KIcon("list-remove"));
-        connect(m_uiSlideshow.m_removeDir, SIGNAL(clicked()), this, \
SLOT(slotRemoveDir())); +        connect(m_uiSlideshow.m_removeDir, \
SIGNAL(clicked()), this, SLOT(removeDir()));  
         QTime time(0, 0, 0);
         time = time.addSecs(m_delay);
@@ -316,21 +317,28 @@
     }
 }
 
-void Image::slotAddDir()
+void Image::addDir()
 {
     KUrl empty;
-    KDirSelectDialog dialog(empty, true, m_configWidget);
-    if (dialog.exec()) {
-        QString urlDir = dialog.url().path();
+    KDirSelectDialog *dialog = new KDirSelectDialog(empty, true, m_configWidget);
+    connect(dialog, SIGNAL(finished()), this, SLOT(addDirFromSelectionDialog()));
+    dialog->show();
+}
+
+void Image::addDirFromSelectionDialog()
+{
+    KDirSelectDialog *dialog = qobject_cast<KDirSelectDialog *>(sender());
+    if (dialog) {
+        QString urlDir = dialog->url().path();
         if (!urlDir.isEmpty() && m_uiSlideshow.m_dirlist->findItems(urlDir, \
                Qt::MatchExactly).isEmpty()) {
-            m_uiSlideshow.m_dirlist->addItem(dialog.url().path());
+            m_uiSlideshow.m_dirlist->addItem(urlDir);
             updateDirs();
             startSlideshow();
         }
     }
 }
 
-void Image::slotRemoveDir()
+void Image::removeDir()
 {
     int row = m_uiSlideshow.m_dirlist->currentRow();
     if (row != -1) {
@@ -417,6 +425,7 @@
         bool random = m_randomize;
         nextSlide();
         m_randomize = random;
+        updateWallpaperActions();
     } else {
         m_wallpaper = path;
         setSingleImage();
@@ -434,6 +443,7 @@
     m_slideshowBackgrounds.clear();
     m_slideshowBackgrounds = BackgroundListModel::findAllBackgrounds(this, 0, \
m_dirs);  
+    updateWallpaperActions();
     // start slideshow
     if (m_slideshowBackgrounds.isEmpty()) {
         m_pixmap = QPixmap();
@@ -445,6 +455,17 @@
     }
 }
 
+void Image::updateWallpaperActions()
+{
+    if (m_nextWallpaperAction) {
+        m_nextWallpaperAction->setEnabled(!m_slideshowBackgrounds.isEmpty());
+    }
+
+    if (m_openImageAction) {
+        m_openImageAction->setEnabled(!m_slideshowBackgrounds.isEmpty());
+    }
+}
+
 void Image::getNewWallpaper()
 {
     if (!m_newStuffDialog) {
@@ -621,6 +642,10 @@
 
 void Image::openSlide()
 {
+    if (!m_wallpaperPackage) {
+        return;
+    }
+
     // open in image viewer
     KUrl filepath(m_wallpaperPackage->filePath("preferred"));
     kDebug() << "opening file " << filepath.path();


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

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