[Digikam-devel] extragear/graphics/digikam/utilities/imageeditor/canvas

Francisco J. Cruz fj.cruz at supercable.es
Wed May 31 11:58:53 BST 2006


SVN commit 546901 by fjcruz:

A info message is showed if icc profiles path is not valid anymore.

Gilles, if it's right for you, can you remove from TODO list? or drop me a mail and i'll do it.

CCMAIL: caulier.gilles at kdemail.net , Digikam-devel at kde.org

 M  +62 -52    dimginterface.cpp  


--- trunk/extragear/graphics/digikam/utilities/imageeditor/canvas/dimginterface.cpp #546900:546901
@@ -42,6 +42,7 @@
 
 #include <kdebug.h>
 #include <kcursor.h>
+#include <kmessagebox.h>
 
 // Local includes.
 
@@ -303,75 +304,42 @@
 
         if (d->cmSettings->enableCMSetting && enableICC)
         {
-            if (d->cmSettings->askOrApplySetting)
+            if (QFile::exists(d->cmSettings->workspaceSetting) && QFile::exists(d->cmSettings->inputSetting))
             {
-                apply = true;
-            }
-            else
-            {
-                apply = false;
-            }
-    
-            IccTransform trans;
-    
-            // First possibility: image has no embedded profile
-            if(d->image.getICCProfil().isNull())
-            {
-                // Ask or apply?
-                if (apply)
+                if (d->cmSettings->askOrApplySetting)
                 {
-                    if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
-                    trans.setProfiles( QFile::encodeName(d->cmSettings->inputSetting),
-                                       QFile::encodeName(d->cmSettings->workspaceSetting));
-                    trans.apply( d->image );
-                    d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
-                    if (d->parent) d->parent->unsetCursor();
+                    apply = true;
                 }
                 else
                 {
-                    // To repaint image in canvas before to ask about to apply ICC profile.
-                    emit signalImageLoaded(d->filename, valRet);
-                    
-                    DImg preview = d->image.smoothScale(240, 180, QSize::ScaleMin);
-                    trans.setProfiles(QFile::encodeName(d->cmSettings->inputSetting),
-                                      QFile::encodeName(d->cmSettings->workspaceSetting));
-                    ColorCorrectionDlg dlg(d->parent, &preview, &trans, fileName);
-                    
-                    if (dlg.exec() == QDialog::Accepted)
+                    apply = false;
+                }
+    
+                IccTransform trans;
+    
+                // First possibility: image has no embedded profile
+                if(d->image.getICCProfil().isNull())
+                {
+                    // Ask or apply?
+                    if (apply)
                     {
                         if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
+                        trans.setProfiles( QFile::encodeName(d->cmSettings->inputSetting),
+                                        QFile::encodeName(d->cmSettings->workspaceSetting));
                         trans.apply( d->image );
                         d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
                         if (d->parent) d->parent->unsetCursor();
                     }
-                }
-            }
-            // Second possibility: image has an embedded profile
-            else
-            {
-                trans.getEmbeddedProfile( d->image );
-                
-                if (apply)
-                {
-                    if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
-                    trans.setProfiles(QFile::encodeName(d->cmSettings->workspaceSetting));
-                    trans.apply( d->image );
-                    if (d->parent) d->parent->unsetCursor();
-               }
-                else
-                {
-                    if (trans.getEmbeddedProfileDescriptor()
-                        != trans.getProfileDescription( d->cmSettings->workspaceSetting ))
+                    else
                     {
-                        kdDebug() << "Embedded profile: " << trans.getEmbeddedProfileDescriptor() << endl;
-
                         // To repaint image in canvas before to ask about to apply ICC profile.
                         emit signalImageLoaded(d->filename, valRet);
     
                         DImg preview = d->image.smoothScale(240, 180, QSize::ScaleMin);
-                        trans.setProfiles(QFile::encodeName(d->cmSettings->workspaceSetting));
+                        trans.setProfiles(QFile::encodeName(d->cmSettings->inputSetting),
+                                        QFile::encodeName(d->cmSettings->workspaceSetting));
                         ColorCorrectionDlg dlg(d->parent, &preview, &trans, fileName);
-                    
+    
                         if (dlg.exec() == QDialog::Accepted)
                         {
                             if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
@@ -381,7 +349,49 @@
                         }
                     }
                 }
+                // Second possibility: image has an embedded profile
+                else
+                {
+                    trans.getEmbeddedProfile( d->image );
+    
+                    if (apply)
+                    {
+                        if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
+                        trans.setProfiles(QFile::encodeName(d->cmSettings->workspaceSetting));
+                        trans.apply( d->image );
+                        if (d->parent) d->parent->unsetCursor();
+                }
+                    else
+                    {
+                        if (trans.getEmbeddedProfileDescriptor()
+                            != trans.getProfileDescription( d->cmSettings->workspaceSetting ))
+                        {
+                            kdDebug() << "Embedded profile: " << trans.getEmbeddedProfileDescriptor() << endl;
+    
+                            // To repaint image in canvas before to ask about to apply ICC profile.
+                            emit signalImageLoaded(d->filename, valRet);
+    
+                            DImg preview = d->image.smoothScale(240, 180, QSize::ScaleMin);
+                            trans.setProfiles(QFile::encodeName(d->cmSettings->workspaceSetting));
+                            ColorCorrectionDlg dlg(d->parent, &preview, &trans, fileName);
+    
+                            if (dlg.exec() == QDialog::Accepted)
+                            {
+                                if (d->parent) d->parent->setCursor( KCursor::waitCursor() );
+                                trans.apply( d->image );
+                                d->image.getICCProfilFromFile(QFile::encodeName(d->cmSettings->workspaceSetting));
+                                if (d->parent) d->parent->unsetCursor();
+                            }
+                        }
+                    }
+                }
             }
+            else
+            {
+                QString message = i18n("ICC profiles path seems to be invalid. No transform will be done.\n \
+                                        Please solve it in digiKam setup.");
+                KMessageBox::information(d->parent, message);
+            }
         }
     }
     else



More information about the Digikam-devel mailing list