Changeset 2aaaec7


Ignore:
Timestamp:
07/15/14 09:17:54 (10 months ago)
Author:
Ken Moore <ken@…>
Branches:
master, releng/10.0.3, releng/10.1, releng/10.1.1, releng/10.1.2
Children:
47e93bde
Parents:
25321deb
Message:

Fix up the mimetype detection routines in libLumina and add a new findMimeIcon function as well.

Location:
lumina/libLumina
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • lumina/libLumina/LuminaXDG.cpp

    r32d3dd2 r2aaaec7  
    281281        QDir::setSearchPaths("fallbackicons", QStringList() << getChildIconDirs(base+"hicolor") << getChildIconDirs(base+"oxygen") );  
    282282      } 
    283       ico = QIcon("fallbackicons:"+iconName+".png"); 
     283      if(QFile::exists("fallbackicons:"+iconName+".png")){ 
     284        ico = QIcon("fallbackicons:"+iconName+".png"); 
     285      } 
    284286    } 
    285287  } 
    286288  //Use the fallback icon if necessary 
    287   if(ico.isNull()){ 
    288     ico = QIcon(fallback);         
     289  if(ico.isNull() && !fallback.isEmpty()){ 
     290    ico = LXDG::findIcon(fallback,"");     
    289291  } 
    290292  //Return the icon 
     
    322324} 
    323325 
     326QIcon LXDG::findMimeIcon(QString extension){ 
     327  QIcon ico; 
     328  QString mime = LXDG::findAppMimeForFile(extension); 
     329  if(mime.isEmpty()){ mime = LXDG::findAppMimeForFile(extension.toLower()); } 
     330  mime.replace("/","-"); //translate to icon mime name 
     331  ico = LXDG::findIcon(mime, "unknown"); //use the "unknown" mimetype icon as fallback   
     332  if(ico.isNull()){ ico = LXDG::findIcon("unknown",""); } 
     333  return ico; 
     334} 
     335 
    324336QString LXDG::findAppMimeForFile(QString extension){ 
    325337  QString out; 
     
    329341    if(QFile::exists(dirs[i]+"/globs2")){ 
    330342      QStringList mimes = LXDG::loadMimeFileGlobs2(dirs[i]+"/globs2"); 
    331       mimes.filter(":*."+extension); 
     343      mimes = mimes.filter(":*."+extension); 
    332344      for(int m=0; m<mimes.length(); m++){ 
    333         if( mimes[m].section(":",2,2,QString::SectionSkipEmpty) == QString(":*."+extension) ){ 
    334345          QString mime = mimes[m].section(":",1,1,QString::SectionSkipEmpty); 
    335           if(mime.startsWith("application/") && (mimes[m].section(":",0,0,QString::SectionSkipEmpty).toInt() > weight) ){ 
    336             out = mime;    
     346          if(mimes[m].section(":",0,0,QString::SectionSkipEmpty).toInt() > weight ){ 
     347            out = mime; 
    337348          } 
    338         } 
    339349      } 
    340350    } 
  • lumina/libLumina/LuminaXDG.h

    r164b720 r2aaaec7  
    7777        //List all the mime-type directories 
    7878        static QStringList systemMimeDirs(); 
     79        //Find the mime-type icon for a particular file extension 
     80        static QIcon findMimeIcon(QString extension); 
    7981        //Find the mime-type of a particular file extension 
    8082        static QString findAppMimeForFile(QString extension); 
Note: See TracChangeset for help on using the changeset viewer.