[Digikam-devel] extragear/graphics/digikam/showfoto

Gilles Caulier caulier.gilles at free.fr
Mon May 15 12:31:23 BST 2006


SVN commit 541016 by cgilles:

digikam from trunk : showfoto and image/x-raw type mime :

- removed x-raw.desktop file in conflict with KDE3.5.2 
- add a rule into Showfoto::slotOpenFile() to detect witch KDE release we use :
 * if KDE >= 3.5.2 --> we use image/x-raw pattern from KDE.
 * if KDE < 3.5.2 --> we construct a new pattern from stcrach.

IMPORTANT : this code have been tested under Mandriva 2006.0 official using KDE 3.4.2. It's untested with KDE > 3.4.2. Please give me a feedback if all is ok to close this file !

CCMAIL: digikam-devel at kde.org
CCBUGS: 121242

 D             mimetypes (directory)  
 M  +28 -7     showfoto.cpp  
 M  +1 -1      showfoto.desktop  


--- trunk/extragear/graphics/digikam/showfoto/showfoto.cpp #541015:541016
@@ -387,16 +387,37 @@
     if (m_currentItem && !promptUserSave(m_currentItem->url()))
         return;
 
-    QString mimetypes = KImageIO::mimeTypes(KImageIO::Reading).join(" ");
+    QString fileformats;
     
-    // Added RAW file format type mimes supported by dcraw program.
-    mimetypes.append (" image/x-raw");
+#if KDE_IS_VERSION(3,5,2)
+    //-- With KDE version >= 3.5.2, "image/x-raw" type mime exist ------------------------------
     
-    KURL::List urls =  KFileDialog::getOpenURLs(m_lastOpenedDirectory.path(),
-                                                mimetypes,
-                                                this,
-                                                i18n("Open Images"));
+    fileformats = KImageIO::mimeTypes(KImageIO::Reading).join(" ");
+#else
+    //-- with KDE version < 3.5.2, we need to add all camera RAW file formats ------------------
+    
+    QStringList patternList = QStringList::split('\n', KImageIO::pattern(KImageIO::Reading));
+    
+    // All Pictures from list must been always the first entry given by KDE API
+    QString allPictures = patternList[0];
+    
+    // Add RAW file format to All Pictures" type mime and remplace current.
+    allPictures.insert(allPictures.find("|"), QString(raw_file_extentions));
+    patternList.remove(patternList[0]);
+    patternList.prepend(allPictures);
+    
+    // Added RAW file formats supported by dcraw program like a type mime. 
+    // Nota: we cannot use here "image/x-raw" type mime from KDE because it 
+    // will be only available for KDE 3.5.2, not before (see file #121242 in B.K.O).
+    patternList.append(QString("\n%1|Camera RAW files").arg(QString(raw_file_extentions)));
+    
+    fileformats = patternList.join("\n");
+#endif
 
+    kdDebug () << "fileformats=" << fileformats << endl;   
+    
+    KURL::List urls =  KFileDialog::getOpenURLs(m_lastOpenedDirectory.path(), fileformats, this, i18n("Open Images"));
+
     if (!urls.isEmpty())
     {
         m_bar->clear();
--- trunk/extragear/graphics/digikam/showfoto/showfoto.desktop #541015:541016
@@ -59,7 +59,7 @@
 Exec=showfoto %i %m -caption "%c" %U
 Icon=showfoto
 Type=Application
-MimeType=image/gif;image/x-xpm;image/x-xbm;image/jpeg;image/png;image/tiff;image/x-bmp;image/x-psd;image/x-eim;image/x-portable-bitmap;image/x-portable-pixmap;image/x-portable-greymap
+MimeType=image/gif;image/x-xpm;image/x-xbm;image/jpeg;image/png;image/tiff;image/x-bmp;image/x-psd;image/x-eim;image/x-portable-bitmap;image/x-portable-pixmap;image/x-portable-greymap;image/x-raw
 Terminal=false
 Categories=Qt;KDE;Graphics;
 DocPath=showfoto/index.html



More information about the Digikam-devel mailing list