diff -Nauw orig/gallerysettings.cpp mythgallery/gallerysettings.cpp --- orig/gallerysettings.cpp Fri Jan 16 18:57:47 2004 +++ mythgallery/gallerysettings.cpp Thu May 6 21:18:33 2004 @@ -119,6 +119,29 @@ }; }; +class SlideshowSubdirs: public CheckBoxSetting, public GlobalSetting { +public: + SlideshowSubdirs(): + GlobalSetting("SlideshowSubdirs") { + setLabel(QObject::tr("Slideshow Recurses into Subdirectories")); + setValue(false); + setHelpText(QObject::tr("If set, the Slideshow will also include subfolders from the " + "point at which the slideshow is started. ")); + }; +}; + +class SlideshowRandomise: public CheckBoxSetting, public GlobalSetting { +public: + SlideshowRandomise(): + GlobalSetting("SlideshowRandomise") { + setLabel(QObject::tr("Shuffle pictures during slideshow")); + setValue(false); + setHelpText(QObject::tr("If set, the slideshow will shuffle pictures " + "into a random order and the step through them. ")); + }; +}; + + class GalleryConfigurationGroup: public VerticalConfigurationGroup, public TriggeredConfigurationGroup { @@ -159,6 +182,8 @@ addChild(new SlideshowDelay()); + addChild(new SlideshowSubdirs()); + addChild(new SlideshowRandomise()); } diff -Nauw orig/iconview.cpp mythgallery/iconview.cpp --- orig/iconview.cpp Sun Jan 18 12:59:22 2004 +++ mythgallery/iconview.cpp Thu May 6 21:17:12 2004 @@ -47,6 +47,7 @@ m_inMenu = false; m_itemList.setAutoDelete(true); + m_itemListwithSubdirs.setAutoDelete(true); m_itemDict.setAutoDelete(false); setNoErase(); @@ -294,7 +295,7 @@ break; } - if (item->isDir) { + if ((item->isDir) && (action == "SELECT")) { loadDirectory(item->path); handled = true; } @@ -303,12 +304,13 @@ handled = true; bool slideShow = (action == "PLAY"); + int recurseSubdirs = gContext->GetNumSetting("SlideshowSubdirs", 0); #ifdef OPENGL_SUPPORT int useOpenGL = gContext->GetNumSetting("SlideshowUseOpenGL"); if (useOpenGL) { if (QGLFormat::hasOpenGL()) { - GLSDialog gv(m_db, m_itemList, pos, slideShow, + GLSDialog gv(m_db, (slideShow && recurseSubdirs) ? m_itemListwithSubdirs : m_itemList, pos, slideShow, gContext->GetMainWindow()); gv.exec(); } @@ -321,7 +323,7 @@ else #endif { - SingleView sv(m_db, m_itemList, pos, slideShow, + SingleView sv(m_db, (slideShow && recurseSubdirs) ? m_itemListwithSubdirs : m_itemList, pos, slideShow, gContext->GetMainWindow()); sv.exec(); } @@ -546,14 +548,17 @@ } } -void IconView::loadDirectory(const QString& dir) +void IconView::loadDirectory(const QString& dir, bool isSubdir) { QDir d(dir); if (!d.exists()) return; + if (!isSubdir) + { m_currDir = d.absPath(); m_itemList.clear(); + m_itemListwithSubdirs.clear(); m_itemDict.clear(); m_currRow = 0; @@ -571,6 +576,7 @@ QFileInfo cdir(d.absPath() + "/.thumbcache"); if (!cdir.exists()) d.mkdir(".thumbcache"); + } d.setNameFilter("*.jpg *.JPG *.jpeg *.JPEG *.png *.PNG *.tiff *.TIFF " "*.tif *.TIF *.bmp *.BMP *.gif *.GIF *.ppm *.PPM"); @@ -584,8 +590,11 @@ QFileInfoListIterator it(*list); QFileInfo *fi; + if (!isSubdir) + { m_thumbGen->cancel(); m_thumbGen->setDirectory(m_currDir, m_isGallery); + } while ((fi = it.current()) != 0) { @@ -600,6 +609,8 @@ (fi->fileName().find(".highlight.") > 0))) continue; + if (!isSubdir) + { ThumbItem* item = new ThumbItem; item->name = fi->fileName(); item->path = QDir::cleanDirPath(fi->absFilePath()); @@ -609,10 +620,25 @@ m_itemDict.insert(item->name, item); m_thumbGen->addFile(item->name); } + if (fi->isDir()) + loadDirectory(QDir::cleanDirPath(fi->absFilePath()), true); + else + { + ThumbItem* item = new ThumbItem; + item->name = fi->fileName(); + item->path = QDir::cleanDirPath(fi->absFilePath()); + item->isDir = fi->isDir(); + + m_itemListwithSubdirs.append(item); + } + } + if (!isSubdir) + { m_lastRow = QMAX((int)ceilf((float)m_itemList.count()/(float)m_nCols)-1,0); m_lastCol = QMAX(m_itemList.count()-m_lastRow*m_nCols-1,0); } +} void IconView::loadThumbnail(ThumbItem *item) { @@ -809,16 +835,17 @@ { ThumbItem* item = m_itemList.at(m_currRow * m_nCols + m_currCol); - if (!item || item->isDir) + if (!item) return; int pos = m_currRow * m_nCols + m_currCol; + int recurseSubdirs = gContext->GetNumSetting("SlideshowSubdirs", 0); #ifdef OPENGL_SUPPORT int useOpenGL = gContext->GetNumSetting("SlideshowUseOpenGL"); if (useOpenGL) { if (QGLFormat::hasOpenGL()) { - GLSDialog gv(m_db, m_itemList, pos, true, + GLSDialog gv(m_db, recurseSubdirs ? m_itemListwithSubdirs : m_itemList, pos, true, gContext->GetMainWindow()); gv.exec(); } @@ -831,7 +858,7 @@ else #endif { - SingleView sv(m_db, m_itemList, pos, true, + SingleView sv(m_db, recurseSubdirs ? m_itemListwithSubdirs : m_itemList, pos, true, gContext->GetMainWindow()); sv.exec(); } diff -Nauw orig/iconview.h mythgallery/iconview.h --- orig/iconview.h Sat Jan 17 18:10:22 2004 +++ mythgallery/iconview.h Sat Apr 17 22:53:33 2004 @@ -81,7 +81,7 @@ private: void loadTheme(); - void loadDirectory(const QString& dir); + void loadDirectory(const QString& dir, bool isSubdir=false); void updateMenu(); void updateText(); @@ -103,6 +103,7 @@ QSqlDatabase* m_db; QPtrList m_itemList; + QPtrList m_itemListwithSubdirs; QDict m_itemDict; QString m_galleryDir; diff -Nauw orig/singleview.cpp mythgallery/singleview.cpp --- orig/singleview.cpp Mon Jan 26 19:38:45 2004 +++ mythgallery/singleview.cpp Thu May 6 21:15:03 2004 @@ -49,6 +49,19 @@ item = next; } + // Shuffle pictures if this is a slideshow + if (slideShow && (gContext->GetNumSetting("SlideshowRandomise", 0))) + { + // Take out each item and reinsert randomly - is this a good algorithm? Not sure. + int total = m_itemList.count(); + for (int c=0; c