Ticket #716: mythgallery_7638.diff

File mythgallery_7638.diff, 6.1 KB (added by mythtv@…, 18 years ago)
  • singleview.cpp

     
    2626#include <qtimer.h>
    2727#include <qpainter.h>
    2828
     29#include <mythtv/uitypes.h>
    2930#include <mythtv/mythcontext.h>
    3031#include <mythtv/util.h>
    3132
  • gallerysettings.cpp

     
    88#include <qimage.h>
    99
    1010#include "config.h"
     11#include "constants.h"
    1112
    1213// General Settings
    1314
     
    2122    return gc;
    2223};
    2324
     25static 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
    2436static HostCheckBox *MythGalleryThumbnailLocation()
    2537{
    2638    HostCheckBox *gc = new HostCheckBox("GalleryThumbnailLocation");
     
    150162        setUseLabel(false);
    151163
    152164        addChild(MythGalleryDir());
     165        addChild(MythGalleryFileFilter());
     166       
    153167        addChild(MythGalleryThumbnailLocation());
    154168        addChild(MythGalleryImportDirs());
    155169        addChild(MythGalleryMoviePlayerCmd());
  • iconview.cpp

     
    915915    if (!d.exists())
    916916        return;
    917917
    918     d.setNameFilter(MEDIA_FILENAMES);
     918    //JC Skip filenames not in GalleryFileFilter
     919    d.setNameFilter(gContext->GetSetting("GalleryFileFilter"));
     920   
    919921    d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase);
    920922    d.setFilter(QDir::Files | QDir::Dirs | QDir::NoSymLinks  | QDir::Readable);
    921923    d.setMatchAllDirs(true);
  • thumbgenerator.cpp

     
    189189{
    190190    QDir dir(fi.absFilePath());
    191191    dir.setFilter(QDir::Files);
     192   
     193    // JC 091105: skip filenames not in GalleryFileFilter
     194    dir.setNameFilter(gContext->GetSetting("GalleryFileFilter"));
     195    dir.setMatchAllDirs(true);
     196
    192197    const QFileInfoList *list = dir.entryInfoList();
    193198    if (!list)
    194199        return;
     
    196201    QFileInfoListIterator it( *list );
    197202    QFileInfo *f;
    198203
    199     bool found = false;
    200204    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;
    204211        }
    205212        ++it;
    206213    }
    207 
    208     if (found) {
    209         image.load(f->absFilePath());
    210         return;
    211     }
    212     else {
     214    if (true) {
     215   
    213216        // if we didn't find the image yet
    214217        // go into subdirs and keep looking
    215218
     
    233236    }
    234237}
    235238
    236 void ThumbGenerator::loadFile(QImage& image, const QFileInfo& fi)
     239/* JC
     240/  returns true if the thumbnail image was loaded */
     241bool ThumbGenerator::loadFile(QImage& image, const QFileInfo& fi)
    237242{
    238243  if (GalleryUtil::isMovie(fi.filePath()))
    239244  {
    240       bool thumbnailCreated = false;
    241245      QDir tmpDir("/tmp/mythgallery");
    242246      if (! tmpDir.exists())
    243247      {
     
    252256          QString cmd = "cd \"" + tmpDir.absPath()
    253257            + "\"; mplayer -nosound -frames 1 -vo png \"" + fi.absFilePath() +
    254258            "\"";
     259         
    255260          if (myth_system(cmd) == 0)
    256261          {
    257262              QFileInfo thumb(tmpDir.filePath("00000001.png"));
     
    259264              {
    260265                QImage img(thumb.absFilePath());
    261266                image = img;
    262                 thumbnailCreated = true;
     267                return true;
    263268              }
    264269          }
    265270      }
    266       if (! thumbnailCreated)
     271      // Failed to create movie thumbnail
     272      if (true)
    267273      {
    268274        QImage *img = gContext->LoadScaleImage("gallery-moviethumb.png");
    269275        if (img)
     
    274280  }
    275281  else
    276282  {
     283    //JC
     284    //verify we understand it
     285    if (QImage::imageFormat(fi.absFilePath()) != 0)
     286    {
    277287      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    }   
    278300  }
     301  return false;
    279302}
    280303
    281304QString ThumbGenerator::getThumbcacheDir(const QString& inDir)
  • thumbgenerator.h

     
    5959    bool checkGalleryDir(const QFileInfo& fi);
    6060    bool checkGalleryFile(const QFileInfo& fi);
    6161    void loadDir(QImage& image, const QFileInfo& fi);
    62     void loadFile(QImage& image, const QFileInfo& fi);
     62    bool loadFile(QImage& image, const QFileInfo& fi);
    6363   
    6464    bool mkpath(const QString& inPath);
    6565
  • galleryutil.cpp

     
    2525#include "galleryutil.h"
    2626#include "thumbgenerator.h"
    2727
     28#include <mythtv/mythcontext.h>
     29
    2830#ifdef EXIF_SUPPORT
    2931#include <libexif/exif-data.h>
    3032#include <libexif/exif-entry.h>
     
    141143    if (thumbGen)
    142144        thumbGen->getThumbcacheDir(currDir);
    143145
    144     d.setNameFilter(MEDIA_FILENAMES);
     146    // JC Skip filenames not in GalleryFileFilter
     147    d.setNameFilter(gContext->GetSetting("GalleryFileFilter"));
    145148    d.setSorting(QDir::Name | QDir::DirsFirst | QDir::IgnoreCase);
    146149
    147150    d.setMatchAllDirs(true);