Ticket #716: mythgallery_7638.diff
File mythgallery_7638.diff, 6.1 KB (added by , 18 years ago) |
---|
-
singleview.cpp
26 26 #include <qtimer.h> 27 27 #include <qpainter.h> 28 28 29 #include <mythtv/uitypes.h> 29 30 #include <mythtv/mythcontext.h> 30 31 #include <mythtv/util.h> 31 32 -
gallerysettings.cpp
8 8 #include <qimage.h> 9 9 10 10 #include "config.h" 11 #include "constants.h" 11 12 12 13 // General Settings 13 14 … … 21 22 return gc; 22 23 }; 23 24 25 static HostLineEdit *MythGalleryFileFilter() 26 { 27 HostLineEdit *gc = new HostLineEdit("GalleryFileFilter"); 28 gc->setLabel(QObject::tr("Filename Filter")); 29 gc->setValue(MEDIA_FILENAMES); 30 gc->setHelpText(QObject::tr("Exclude images not matching filter. " 31 "Use semicolon or space as separator. Search is case sensitive. Example: HI_*;LOW_*;[0-9]*;*.tiff")); 32 return gc; 33 }; 34 35 24 36 static HostCheckBox *MythGalleryThumbnailLocation() 25 37 { 26 38 HostCheckBox *gc = new HostCheckBox("GalleryThumbnailLocation"); … … 150 162 setUseLabel(false); 151 163 152 164 addChild(MythGalleryDir()); 165 addChild(MythGalleryFileFilter()); 166 153 167 addChild(MythGalleryThumbnailLocation()); 154 168 addChild(MythGalleryImportDirs()); 155 169 addChild(MythGalleryMoviePlayerCmd()); -
iconview.cpp
915 915 if (!d.exists()) 916 916 return; 917 917 918 d.setNameFilter(MEDIA_FILENAMES); 918 //JC Skip filenames not in GalleryFileFilter 919 d.setNameFilter(gContext->GetSetting("GalleryFileFilter")); 920 919 921 d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase); 920 922 d.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks | QDir::Readable); 921 923 d.setMatchAllDirs(true); -
thumbgenerator.cpp
189 189 { 190 190 QDir dir(fi.absFilePath()); 191 191 dir.setFilter(QDir::Files); 192 193 // JC 091105: skip filenames not in GalleryFileFilter 194 dir.setNameFilter(gContext->GetSetting("GalleryFileFilter")); 195 dir.setMatchAllDirs(true); 196 192 197 const QFileInfoList *list = dir.entryInfoList(); 193 198 if (!list) 194 199 return; … … 196 201 QFileInfoListIterator it( *list ); 197 202 QFileInfo *f; 198 203 199 bool found = false;200 204 while ( (f = it.current()) != 0 ) { 201 if (QImage::imageFormat(f->absFilePath()) != 0) { 202 found = true; 203 break; 205 // let loadFile() to make this stuff so we can get thumbnails for folders containting just videos 206 QImage img; 207 if (loadFile(img,*f)) 208 { 209 image = img; 210 return; 204 211 } 205 212 ++it; 206 213 } 207 208 if (found) { 209 image.load(f->absFilePath()); 210 return; 211 } 212 else { 214 if (true) { 215 213 216 // if we didn't find the image yet 214 217 // go into subdirs and keep looking 215 218 … … 233 236 } 234 237 } 235 238 236 void ThumbGenerator::loadFile(QImage& image, const QFileInfo& fi) 239 /* JC 240 / returns true if the thumbnail image was loaded */ 241 bool ThumbGenerator::loadFile(QImage& image, const QFileInfo& fi) 237 242 { 238 243 if (GalleryUtil::isMovie(fi.filePath())) 239 244 { 240 bool thumbnailCreated = false;241 245 QDir tmpDir("/tmp/mythgallery"); 242 246 if (! tmpDir.exists()) 243 247 { … … 252 256 QString cmd = "cd \"" + tmpDir.absPath() 253 257 + "\"; mplayer -nosound -frames 1 -vo png \"" + fi.absFilePath() + 254 258 "\""; 259 255 260 if (myth_system(cmd) == 0) 256 261 { 257 262 QFileInfo thumb(tmpDir.filePath("00000001.png")); … … 259 264 { 260 265 QImage img(thumb.absFilePath()); 261 266 image = img; 262 thumbnailCreated =true;267 return true; 263 268 } 264 269 } 265 270 } 266 if (! thumbnailCreated) 271 // Failed to create movie thumbnail 272 if (true) 267 273 { 268 274 QImage *img = gContext->LoadScaleImage("gallery-moviethumb.png"); 269 275 if (img) … … 274 280 } 275 281 else 276 282 { 283 //JC 284 //verify we understand it 285 if (QImage::imageFormat(fi.absFilePath()) != 0) 286 { 277 287 image.load(fi.absFilePath()); 288 return true; 289 } 290 else 291 { 292 // should exist a gallery-unknownformat.png 293 std::cerr << "file " << fi.absFilePath() << " format undestod:" << QImage::imageFormat(fi.absFilePath()) << std::cerr; 294 QImage *img = gContext->LoadScaleImage("gallery-moviethumb.png"); 295 if (img) 296 { 297 image = *img; 298 } 299 } 278 300 } 301 return false; 279 302 } 280 303 281 304 QString ThumbGenerator::getThumbcacheDir(const QString& inDir) -
thumbgenerator.h
59 59 bool checkGalleryDir(const QFileInfo& fi); 60 60 bool checkGalleryFile(const QFileInfo& fi); 61 61 void loadDir(QImage& image, const QFileInfo& fi); 62 voidloadFile(QImage& image, const QFileInfo& fi);62 bool loadFile(QImage& image, const QFileInfo& fi); 63 63 64 64 bool mkpath(const QString& inPath); 65 65 -
galleryutil.cpp
25 25 #include "galleryutil.h" 26 26 #include "thumbgenerator.h" 27 27 28 #include <mythtv/mythcontext.h> 29 28 30 #ifdef EXIF_SUPPORT 29 31 #include <libexif/exif-data.h> 30 32 #include <libexif/exif-entry.h> … … 141 143 if (thumbGen) 142 144 thumbGen->getThumbcacheDir(currDir); 143 145 144 d.setNameFilter(MEDIA_FILENAMES); 146 // JC Skip filenames not in GalleryFileFilter 147 d.setNameFilter(gContext->GetSetting("GalleryFileFilter")); 145 148 d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase); 146 149 147 150 d.setMatchAllDirs(true);