[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdebase/apps
From:       David Faure <faure () kde ! org>
Date:       2009-02-23 10:42:01
Message-ID: 1235385721.664395.6888.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 930394 by dfaure:

Allow users to change mimetype icons if they use shared-mime-info >= 0.40
BUG: 158895


 M  +1 -0      konqueror/settings/filetypes/CMakeLists.txt  
 M  +23 -22    konqueror/settings/filetypes/filetypedetails.cpp  
 M  +3 -6      konqueror/settings/filetypes/filetypedetails.h  
 D             konqueror/settings/filetypes/filetypes-config.h  
 M  +7 -8      konqueror/settings/filetypes/mimetypedata.cpp  
 M  +0 -1      konqueror/settings/filetypes/mimetypedata.h  
 M  +7 -10     konqueror/settings/filetypes/mimetypewriter.cpp  
 A             konqueror/settings/filetypes/sharedmimeinfoversion.cpp   [License: GPL \
(v2/3+eV)]  A             konqueror/settings/filetypes/sharedmimeinfoversion.h   \
[License: GPL (v2/3+eV)]  M  +6 -1      \
konqueror/settings/filetypes/tests/CMakeLists.txt    M  +1 -1      \
nsplugins/CMakeLists.txt    M  +1 -1      nsplugins/pluginscan.cpp  


--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/CMakeLists.txt #930393:930394
@@ -10,6 +10,7 @@
  mimetypewriter.cpp
  newtypedlg.cpp
  kserviceselectdlg.cpp
+ sharedmimeinfoversion.cpp
 )
 
 ########### next target ###############
--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/filetypedetails.cpp \
#930393:930394 @@ -19,6 +19,7 @@
 
 // Own
 #include "filetypedetails.h"
+#include "sharedmimeinfoversion.h"
 
 // Qt
 #include <QtGui/QBoxLayout>
@@ -65,19 +66,24 @@
   hBox->setSpacing(KDialog::spacingHint());
   firstLayout->addLayout(hBox);
 
-#if ENABLE_CHANGING_ICON
-  iconButton = new KIconButton(firstWidget);
-  iconButton->setIconType(KIconLoader::Desktop, KIconLoader::MimeType);
-  connect(iconButton, SIGNAL(iconChanged(QString)), SLOT(updateIcon(QString)));
-  iconButton->setWhatsThis( i18n("This button displays the icon associated"
-                                 " with the selected file type. Click on it to \
                choose a different icon.") );
-#else
-  iconButton = new QLabel(firstWidget);
-#endif
+    if (SharedMimeInfoVersion::supportsIcon()) {
+        iconButton = new KIconButton(firstWidget);
+        iconButton->setIconType(KIconLoader::Desktop, KIconLoader::MimeType);
+        connect(iconButton, SIGNAL(iconChanged(QString)), \
SLOT(updateIcon(QString))); +        iconButton->setWhatsThis( i18n("This button \
displays the icon associated" +                                       " with the \
selected file type. Click on it to choose a different icon.") ); +        \
iconButton->setFixedSize(70, 70); +        iconLabel = 0;
+        hBox->addWidget(iconButton);
+    } else {
+        iconButton = 0;
+        iconLabel = new QLabel(firstWidget);
+        iconLabel->setWhatsThis( i18n("This is the icon associated with the selected \
file type. " +                                      "Choosing a different icon \
requires shared-mime-info to be at least version 0.40.") ); +        \
iconLabel->setFixedSize(70, 70); +        hBox->addWidget(iconLabel);
+    }
 
-  iconButton->setFixedSize(70, 70);
-  hBox->addWidget(iconButton);
-
   QGroupBox *gb = new QGroupBox(i18n("Filename Patterns"), firstWidget);
   hBox->addWidget(gb);
 
@@ -120,7 +126,7 @@
   vbox->addStretch(1);
 
   gb->setFixedHeight(gb->minimumSizeHint().height());
-  
+
   description = new KLineEdit(firstWidget);
   description->setClearButtonShown(true);
   connect(description, SIGNAL(textChanged(const QString &)),
@@ -193,7 +199,6 @@
 
 void FileTypeDetails::updateIcon(const QString &icon)
 {
-#if ENABLE_CHANGING_ICON
   if (!m_mimeTypeData)
     return;
 
@@ -203,9 +208,6 @@
       m_item->setIcon(icon);
 
   emit changed(true);
-#else
-  Q_UNUSED(icon)
-#endif
 }
 
 void FileTypeDetails::updateDescription(const QString &desc)
@@ -338,11 +340,10 @@
   m_item = item; // can be 0
   Q_ASSERT(mimeTypeData);
   m_mimeTypeLabel->setText(i18n("File type %1", mimeTypeData->name()));
-#if ENABLE_CHANGING_ICON
-  iconButton->setIcon(mimeTypeData->icon());
-#else
-  iconButton->setPixmap(DesktopIcon(mimeTypeData->icon()));
-#endif
+  if (iconButton)
+      iconButton->setIcon(mimeTypeData->icon());
+  else
+      iconLabel->setPixmap(DesktopIcon(mimeTypeData->icon()));
   description->setText(mimeTypeData->comment());
   m_rbGroupSettings->setText( i18n("Use settings for '%1' group", \
mimeTypeData->majorType() ) );  extensionLB->clear();
--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/filetypedetails.h \
#930393:930394 @@ -21,7 +21,6 @@
 #define FILETYPEDETAILS_H
 
 #include <QtGui/QTabWidget>
-#include "filetypes-config.h"
 
 class KIconButton;
 class MimeTypeData;
@@ -84,12 +83,10 @@
 
     QTabWidget* m_tabWidget;
 
-  // First tab - General
-#if ENABLE_CHANGING_ICON
+    // First tab - General
     KIconButton* iconButton;
-#else
-    QLabel *iconButton;
-#endif
+    QLabel* iconLabel; // if icon cannot be changed
+
   QListWidget *extensionLB;
   KPushButton *addExtButton, *removeExtButton;
   KLineEdit *description;
--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/mimetypedata.cpp \
#930393:930394 @@ -19,6 +19,7 @@
 */
 
 #include "mimetypedata.h"
+#include "sharedmimeinfoversion.h"
 #include <kprotocolmanager.h>
 #include "mimetypewriter.h"
 #include <kdebug.h>
@@ -82,9 +83,7 @@
 void MimeTypeData::initFromKMimeType()
 {
     m_comment = m_mimetype->comment();
-#if ENABLE_CHANGING_ICON
     m_userSpecifiedIcon = m_mimetype->userSpecifiedIconName();
-#endif
     setPatterns(m_mimetype->patterns());
     m_autoEmbed = readAutoEmbed();
 }
@@ -211,12 +210,10 @@
         kDebug() << "Mimetype Comment Dirty: old=" << m_mimetype->comment() << \
"m_comment=" << m_comment;  return true;
     }
-#if ENABLE_CHANGING_ICON
     if (m_mimetype->userSpecifiedIconName() != m_userSpecifiedIcon) {
         kDebug() << "Mimetype Icon Dirty: old=" << m_mimetype->iconName() << \
"m_userSpecifiedIcon=" << m_userSpecifiedIcon;  return true;
     }
-#endif
 
     QStringList storedPatterns = m_mimetype->patterns();
     storedPatterns.sort(); // see ctor
@@ -286,11 +283,13 @@
     if (isMimeTypeDirty()) {
         MimeTypeWriter mimeTypeWriter(name());
         mimeTypeWriter.setComment(m_comment);
-#if ENABLE_CHANGING_ICON
-        if (!m_userSpecifiedIcon.isEmpty()) {
-            mimeTypeWriter.setIconName(m_userSpecifiedIcon);
+        if (SharedMimeInfoVersion::supportsIcon()) {
+            // Very important: don't write <icon> if shared-mime-info doesn't \
support it, +            // it would abort on it!
+            if (!m_userSpecifiedIcon.isEmpty()) {
+                mimeTypeWriter.setIconName(m_userSpecifiedIcon);
+            }
         }
-#endif
         mimeTypeWriter.setPatterns(m_patterns);
         if (!mimeTypeWriter.write())
             return false;
--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/mimetypedata.h #930393:930394
@@ -22,7 +22,6 @@
 #define MIMETYPEDATA_H
 
 #include <kmimetype.h>
-#include "filetypes-config.h"
 
 /**
  * This is a non-gui (data) class, that represents a mimetype.
--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/mimetypewriter.cpp \
#930393:930394 @@ -19,7 +19,7 @@
 */
 
 #include "mimetypewriter.h"
-#include "filetypes-config.h"
+#include "sharedmimeinfoversion.h"
 
 #include <kdebug.h>
 #include <kprocess.h>
@@ -100,15 +100,12 @@
     }
 
     if (!d->m_iconName.isEmpty()) {
-        // User-specified icon name; requires update-mime-database >= 0.24 at least
-        // Otherwise update-mime-database fails with an error about an unknown \
                attribute!
-#if ENABLE_CHANGING_ICON
-        // TODO re-enable once update-mime-database is fixed
-        // and either we require a version with the fix or we have a check on the \
                version number
-        writer.writeStartElement(nsUri, "icon");
-        writer.writeAttribute("name", d->m_iconName);
-        writer.writeEndElement(); // icon
-#endif
+        // User-specified icon name
+        if (SharedMimeInfoVersion::supportsIcon()) {
+            writer.writeStartElement(nsUri, "icon");
+            writer.writeAttribute("name", d->m_iconName);
+            writer.writeEndElement(); // icon
+        }
     }
 
     foreach(const QString& pattern, d->m_patterns) {
--- trunk/KDE/kdebase/apps/konqueror/settings/filetypes/tests/CMakeLists.txt \
#930393:930394 @@ -3,6 +3,11 @@
 
 ########### filetypestest ###############
 
-kde4_add_unit_test(filetypestest TEST filetypestest.cpp ../mimetypedata.cpp \
../mimetypewriter.cpp) +kde4_add_unit_test(filetypestest TEST 
+ filetypestest.cpp
+ ../mimetypedata.cpp
+ ../mimetypewriter.cpp
+ ../sharedmimeinfoversion.cpp
+)
 target_link_libraries(filetypestest ${KDE4_KDECORE_LIBS} ${KDE4_KIO_LIBRARY} \
                ${KDE4_KDEUI_LIBRARIES}
                       ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTTEST_LIBRARY})
--- trunk/KDE/kdebase/apps/nsplugins/CMakeLists.txt #930393:930394
@@ -52,7 +52,7 @@
 
   ########### nspluginscan ###############
 
-  set(nspluginscan_SRCS pluginscan.cpp plugin_paths.cpp \
../konqueror/settings/filetypes/mimetypewriter.cpp) +  set(nspluginscan_SRCS \
pluginscan.cpp plugin_paths.cpp ../konqueror/settings/filetypes/mimetypewriter.cpp \
../konqueror/settings/filetypes/sharedmimeinfoversion.cpp)  
   include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../konqueror/settings/filetypes/)
 
--- trunk/KDE/kdebase/apps/nsplugins/pluginscan.cpp #930393:930394
@@ -575,7 +575,7 @@
     }
 
     // read in the plugins mime information
-    kDebug(1433) << "Scanning directories";
+    kDebug(1433) << "Scanning directories" << searchPaths;
     int count = searchPaths.count();
     int i = 0;
     for ( QStringList::const_iterator it = searchPaths.constBegin();


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic