| 1 | Index: mythgallery/glsingleview.cpp
|
|---|
| 2 | ===================================================================
|
|---|
| 3 | --- mythgallery/glsingleview.cpp (revision 6792)
|
|---|
| 4 | +++ mythgallery/glsingleview.cpp (working copy)
|
|---|
| 5 | @@ -78,12 +78,17 @@
|
|---|
| 6 | // --------------------------------------------------------------------
|
|---|
| 7 |
|
|---|
| 8 | // remove all dirs from m_itemList;
|
|---|
| 9 | + bool recurse = gContext->GetNumSetting("GalleryRecursiveSlideshow", 0);
|
|---|
| 10 | +
|
|---|
| 11 | m_itemList.setAutoDelete(false);
|
|---|
| 12 | ThumbItem* item = m_itemList.first();
|
|---|
| 13 | while (item) {
|
|---|
| 14 | ThumbItem* next = m_itemList.next();
|
|---|
| 15 | - if (item->isDir)
|
|---|
| 16 | + if (item->isDir) {
|
|---|
| 17 | + if (recurse)
|
|---|
| 18 | + GalleryUtil::loadDirectory(m_itemList, item->path, recurse, NULL, NULL);
|
|---|
| 19 | m_itemList.remove(item);
|
|---|
| 20 | + }
|
|---|
| 21 | item = next;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | Index: mythgallery/galleryutil.h
|
|---|
| 25 | ===================================================================
|
|---|
| 26 | --- mythgallery/galleryutil.h (revision 6792)
|
|---|
| 27 | +++ mythgallery/galleryutil.h (working copy)
|
|---|
| 28 | @@ -19,14 +19,19 @@
|
|---|
| 29 | #ifndef EXIFUTIL_H
|
|---|
| 30 | #define EXIFUTIL_H
|
|---|
| 31 |
|
|---|
| 32 | +#include "iconview.h"
|
|---|
| 33 | +
|
|---|
| 34 | class GalleryUtil
|
|---|
| 35 | {
|
|---|
| 36 |
|
|---|
| 37 | public:
|
|---|
| 38 | static bool isImage(const char* filePath);
|
|---|
| 39 | static bool isMovie(const char* filePath);
|
|---|
| 40 | static long getNaturalRotation(const char* filePath);
|
|---|
| 41 |
|
|---|
| 42 | + static bool loadDirectory(ThumbList& itemList,
|
|---|
| 43 | + const QString& dir, bool recurse,
|
|---|
| 44 | + ThumbDict *itemDict, ThumbGenerator* thumbGen);
|
|---|
| 45 | };
|
|---|
| 46 |
|
|---|
| 47 | #endif /* EXIFUTIL_H */
|
|---|
| 48 | Index: mythgallery/singleview.cpp
|
|---|
| 49 | ===================================================================
|
|---|
| 50 | --- mythgallery/singleview.cpp (revision 6792)
|
|---|
| 51 | +++ mythgallery/singleview.cpp (working copy)
|
|---|
| 52 | @@ -41,12 +41,17 @@
|
|---|
| 53 | // --------------------------------------------------------------------
|
|---|
| 54 |
|
|---|
| 55 | // remove all dirs from m_itemList;
|
|---|
| 56 | + bool recurse = gContext->GetNumSetting("GalleryRecursiveSlideshow", 0);
|
|---|
| 57 | +
|
|---|
| 58 | m_itemList.setAutoDelete(false);
|
|---|
| 59 | ThumbItem* item = m_itemList.first();
|
|---|
| 60 | while (item) {
|
|---|
| 61 | ThumbItem* next = m_itemList.next();
|
|---|
| 62 | - if (item->isDir)
|
|---|
| 63 | + if (item->isDir) {
|
|---|
| 64 | + if (recurse)
|
|---|
| 65 | + GalleryUtil::loadDirectory(m_itemList, item->path, recurse, NULL, NULL);
|
|---|
| 66 | m_itemList.remove(item);
|
|---|
| 67 | + }
|
|---|
| 68 | item = next;
|
|---|
| 69 | }
|
|---|
| 70 |
|
|---|
| 71 | Index: mythgallery/gallerysettings.cpp
|
|---|
| 72 | ===================================================================
|
|---|
| 73 | --- mythgallery/gallerysettings.cpp (revision 6792)
|
|---|
| 74 | +++ mythgallery/gallerysettings.cpp (working copy)
|
|---|
| 75 | @@ -129,6 +129,14 @@
|
|---|
| 76 | return gc;
|
|---|
| 77 | };
|
|---|
| 78 |
|
|---|
| 79 | +static HostCheckBox *SlideshowRecursive()
|
|---|
| 80 | +{
|
|---|
| 81 | + HostCheckBox *gc = new HostCheckBox("GalleryRecursiveSlideshow");
|
|---|
| 82 | + gc->setLabel(QObject::tr("Recurse into directories"));
|
|---|
| 83 | + gc->setHelpText(QObject::tr("Check this to let the slideshow recurse into "
|
|---|
| 84 | + "sub-directories."));
|
|---|
| 85 | + return gc;
|
|---|
| 86 | +};
|
|---|
| 87 |
|
|---|
| 88 | class GalleryConfigurationGroup: public VerticalConfigurationGroup,
|
|---|
| 89 | public TriggeredConfigurationGroup {
|
|---|
| 90 | @@ -170,7 +178,7 @@
|
|---|
| 91 |
|
|---|
| 92 |
|
|---|
| 93 | addChild(SlideshowDelay());
|
|---|
| 94 | -
|
|---|
| 95 | + addChild(SlideshowRecursive());
|
|---|
| 96 | }
|
|---|
| 97 |
|
|---|
| 98 | };
|
|---|
| 99 | Index: mythgallery/iconview.cpp
|
|---|
| 100 | ===================================================================
|
|---|
| 101 | --- mythgallery/iconview.cpp (revision 6792)
|
|---|
| 102 | +++ mythgallery/iconview.cpp (working copy)
|
|---|
| 103 | @@ -596,57 +596,7 @@
|
|---|
| 104 | m_lastCol = 0;
|
|---|
| 105 | m_topRow = 0;
|
|---|
| 106 |
|
|---|
| 107 | - const QFileInfoList* gList = d.entryInfoList("serial*.dat", QDir::Files);
|
|---|
| 108 | - if (gList)
|
|---|
| 109 | - m_isGallery = (gList->count() != 0);
|
|---|
| 110 | - else
|
|---|
| 111 | - m_isGallery = false;
|
|---|
| 112 | -
|
|---|
| 113 | - // Create .thumbcache dir if neccesary
|
|---|
| 114 | - m_thumbGen->getThumbcacheDir(m_currDir);
|
|---|
| 115 | -
|
|---|
| 116 | - d.setNameFilter(MEDIA_FILENAMES);
|
|---|
| 117 | - d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase);
|
|---|
| 118 | -
|
|---|
| 119 | - d.setMatchAllDirs(true);
|
|---|
| 120 | - const QFileInfoList *list = d.entryInfoList();
|
|---|
| 121 | - if (!list)
|
|---|
| 122 | - return;
|
|---|
| 123 | -
|
|---|
| 124 | - QFileInfoListIterator it(*list);
|
|---|
| 125 | - QFileInfo *fi;
|
|---|
| 126 | -
|
|---|
| 127 | - m_thumbGen->cancel();
|
|---|
| 128 | - m_thumbGen->setDirectory(m_currDir, m_isGallery);
|
|---|
| 129 | -
|
|---|
| 130 | - while ((fi = it.current()) != 0)
|
|---|
| 131 | - {
|
|---|
| 132 | - ++it;
|
|---|
| 133 | - if (fi->fileName() == "." || fi->fileName() == "..")
|
|---|
| 134 | - continue;
|
|---|
| 135 | -
|
|---|
| 136 | - // remove these already-resized pictures.
|
|---|
| 137 | - if (m_isGallery && (
|
|---|
| 138 | - (fi->fileName().find(".thumb.") > 0) ||
|
|---|
| 139 | - (fi->fileName().find(".sized.") > 0) ||
|
|---|
| 140 | - (fi->fileName().find(".highlight.") > 0)))
|
|---|
| 141 | - continue;
|
|---|
| 142 | -
|
|---|
| 143 | - ThumbItem* item = new ThumbItem;
|
|---|
| 144 | - item->name = fi->fileName();
|
|---|
| 145 | - item->path = QDir::cleanDirPath(fi->absFilePath());
|
|---|
| 146 | - item->isDir = fi->isDir();
|
|---|
| 147 | -
|
|---|
| 148 | - m_itemList.append(item);
|
|---|
| 149 | - m_itemDict.insert(item->name, item);
|
|---|
| 150 | - m_thumbGen->addFile(item->name);
|
|---|
| 151 | - }
|
|---|
| 152 | -
|
|---|
| 153 | - if (!m_thumbGen->running())
|
|---|
| 154 | - {
|
|---|
| 155 | - m_thumbGen->start();
|
|---|
| 156 | - }
|
|---|
| 157 | -
|
|---|
| 158 | + m_isGallery = GalleryUtil::loadDirectory(m_itemList, dir, false, &m_itemDict, m_thumbGen);;
|
|---|
| 159 | m_lastRow = QMAX((int)ceilf((float)m_itemList.count()/(float)m_nCols)-1,0);
|
|---|
| 160 | m_lastCol = QMAX(m_itemList.count()-m_lastRow*m_nCols-1,0);
|
|---|
| 161 | }
|
|---|
| 162 | @@ -827,7 +777,8 @@
|
|---|
| 163 | {
|
|---|
| 164 | ThumbItem* item = m_itemList.at(m_currRow * m_nCols +
|
|---|
| 165 | m_currCol);
|
|---|
| 166 | - if (!item || item->isDir)
|
|---|
| 167 | + bool recurse = gContext->GetNumSetting("GalleryRecursiveSlideshow", 0);
|
|---|
| 168 | + if (!item || (item->isDir && !recurse))
|
|---|
| 169 | return;
|
|---|
| 170 |
|
|---|
| 171 | int pos = m_currRow * m_nCols + m_currCol;
|
|---|
| 172 | @@ -857,7 +808,8 @@
|
|---|
| 173 | {
|
|---|
| 174 | ThumbItem* item = m_itemList.at(m_currRow * m_nCols +
|
|---|
| 175 | m_currCol);
|
|---|
| 176 | - if (!item || item->isDir)
|
|---|
| 177 | + bool recurse = gContext->GetNumSetting("GalleryRecursiveSlideshow", 0);
|
|---|
| 178 | + if (!item || (item->isDir && !recurse))
|
|---|
| 179 | return;
|
|---|
| 180 |
|
|---|
| 181 | int pos = m_currRow * m_nCols + m_currCol;
|
|---|
| 182 | Index: mythgallery/iconview.h
|
|---|
| 183 | ===================================================================
|
|---|
| 184 | --- mythgallery/iconview.h (revision 6792)
|
|---|
| 185 | +++ mythgallery/iconview.h (working copy)
|
|---|
| 186 | @@ -58,6 +58,7 @@
|
|---|
| 187 | };
|
|---|
| 188 |
|
|---|
| 189 | typedef QPtrList<ThumbItem> ThumbList;
|
|---|
| 190 | +typedef QDict<ThumbItem> ThumbDict;
|
|---|
| 191 |
|
|---|
| 192 | class IconView : public MythDialog
|
|---|
| 193 | {
|
|---|
| 194 | Index: mythgallery/galleryutil.cpp
|
|---|
| 195 | ===================================================================
|
|---|
| 196 | --- mythgallery/galleryutil.cpp (revision 6792)
|
|---|
| 197 | +++ mythgallery/galleryutil.cpp (working copy)
|
|---|
| 198 | @@ -18,10 +18,12 @@
|
|---|
| 199 |
|
|---|
| 200 | #include <iostream>
|
|---|
| 201 | #include <qfileinfo.h>
|
|---|
| 202 | +#include <qdir.h>
|
|---|
| 203 |
|
|---|
| 204 | #include "config.h"
|
|---|
| 205 | #include "constants.h"
|
|---|
| 206 | #include "galleryutil.h"
|
|---|
| 207 | +#include "thumbgenerator.h"
|
|---|
| 208 |
|
|---|
| 209 | #ifdef EXIF_SUPPORT
|
|---|
| 210 | #include <libexif/exif-data.h>
|
|---|
| 211 | @@ -32,13 +34,13 @@
|
|---|
| 212 | bool GalleryUtil::isImage(const char* filePath)
|
|---|
| 213 | {
|
|---|
| 214 | QFileInfo fi(filePath);
|
|---|
| 215 | - return IMAGE_FILENAMES.find(fi.extension()) != -1;
|
|---|
| 216 | + return !fi.isDir() && IMAGE_FILENAMES.find(fi.extension()) != -1;
|
|---|
| 217 | }
|
|---|
| 218 |
|
|---|
| 219 | bool GalleryUtil::isMovie(const char* filePath)
|
|---|
| 220 | {
|
|---|
| 221 | QFileInfo fi(filePath);
|
|---|
| 222 | - return MOVIE_FILENAMES.find(fi.extension()) != -1;
|
|---|
| 223 | + return !fi.isDir() && MOVIE_FILENAMES.find(fi.extension()) != -1;
|
|---|
| 224 | }
|
|---|
| 225 |
|
|---|
| 226 | long GalleryUtil::getNaturalRotation(const char* filePath)
|
|---|
| 227 | @@ -119,3 +121,79 @@
|
|---|
| 228 |
|
|---|
| 229 | return rotateAngle;
|
|---|
| 230 | }
|
|---|
| 231 | +
|
|---|
| 232 | +bool GalleryUtil::loadDirectory(ThumbList& itemList,
|
|---|
| 233 | + const QString& dir, bool recurse,
|
|---|
| 234 | + ThumbDict *itemDict, ThumbGenerator* thumbGen)
|
|---|
| 235 | +{
|
|---|
| 236 | + QDir d(dir);
|
|---|
| 237 | + QString currDir = d.absPath();
|
|---|
| 238 | +
|
|---|
| 239 | + bool isGallery;
|
|---|
| 240 | + const QFileInfoList* gList = d.entryInfoList("serial*.dat", QDir::Files);
|
|---|
| 241 | + if (gList)
|
|---|
| 242 | + isGallery = (gList->count() != 0);
|
|---|
| 243 | + else
|
|---|
| 244 | + isGallery = false;
|
|---|
| 245 | +
|
|---|
| 246 | + // Create .thumbcache dir if neccesary
|
|---|
| 247 | + if(thumbGen)
|
|---|
| 248 | + thumbGen->getThumbcacheDir(currDir);
|
|---|
| 249 | +
|
|---|
| 250 | + d.setNameFilter(MEDIA_FILENAMES);
|
|---|
| 251 | + d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase);
|
|---|
| 252 | +
|
|---|
| 253 | + d.setMatchAllDirs(true);
|
|---|
| 254 | + const QFileInfoList *list = d.entryInfoList();
|
|---|
| 255 | + if (!list)
|
|---|
| 256 | + return false;
|
|---|
| 257 | +
|
|---|
| 258 | + QFileInfoListIterator it(*list);
|
|---|
| 259 | + QFileInfo *fi;
|
|---|
| 260 | +
|
|---|
| 261 | + if(thumbGen) {
|
|---|
| 262 | + thumbGen->cancel();
|
|---|
| 263 | + thumbGen->setDirectory(currDir, isGallery);
|
|---|
| 264 | + }
|
|---|
| 265 | +
|
|---|
| 266 | + while ((fi = it.current()) != 0)
|
|---|
| 267 | + {
|
|---|
| 268 | + ++it;
|
|---|
| 269 | + if (fi->fileName() == "." || fi->fileName() == "..")
|
|---|
| 270 | + continue;
|
|---|
| 271 | +
|
|---|
| 272 | + // remove these already-resized pictures.
|
|---|
| 273 | + if (isGallery && (
|
|---|
| 274 | + (fi->fileName().find(".thumb.") > 0) ||
|
|---|
| 275 | + (fi->fileName().find(".sized.") > 0) ||
|
|---|
| 276 | + (fi->fileName().find(".highlight.") > 0)))
|
|---|
| 277 | + continue;
|
|---|
| 278 | +
|
|---|
| 279 | + if(fi->isDir() && recurse) {
|
|---|
| 280 | + GalleryUtil::loadDirectory(itemList,
|
|---|
| 281 | + QDir::cleanDirPath(fi->absFilePath()), true,
|
|---|
| 282 | + itemDict, thumbGen);
|
|---|
| 283 | + }
|
|---|
| 284 | + else {
|
|---|
| 285 | + ThumbItem* item = new ThumbItem;
|
|---|
| 286 | + item->name = fi->fileName();
|
|---|
| 287 | + item->path = QDir::cleanDirPath(fi->absFilePath());
|
|---|
| 288 | + item->isDir = fi->isDir();
|
|---|
| 289 | +
|
|---|
| 290 | + itemList.append(item);
|
|---|
| 291 | +
|
|---|
| 292 | + if(itemDict)
|
|---|
| 293 | + itemDict->insert(item->name, item);
|
|---|
| 294 | +
|
|---|
| 295 | + if(thumbGen)
|
|---|
| 296 | + thumbGen->addFile(item->name);
|
|---|
| 297 | + }
|
|---|
| 298 | + }
|
|---|
| 299 | +
|
|---|
| 300 | + if (thumbGen && !thumbGen->running())
|
|---|
| 301 | + {
|
|---|
| 302 | + thumbGen->start();
|
|---|
| 303 | + }
|
|---|
| 304 | +
|
|---|
| 305 | + return isGallery;
|
|---|
| 306 | +}
|
|---|