Index: kcolordialog.cpp
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kcolordialog.cpp,v
retrieving revision 1.127
diff -u -r1.127 kcolordialog.cpp
--- kcolordialog.cpp	15 Dec 2004 11:00:29 -0000	1.127
+++ kcolordialog.cpp	23 Apr 2005 22:42:19 -0000
@@ -45,6 +45,7 @@
 #include <qpushbutton.h>
 #include <qspinbox.h>
 #include <qtimer.h>
+#include <qdir.h>
 
 #include <kapplication.h>
 #include <kconfig.h>
@@ -57,6 +58,7 @@
 #include <kseparator.h>
 #include <kpalette.h>
 #include <kimageeffect.h>
+#include <kstandarddirs.h>
 
 #include "kcolordialog.h"
 #include "kcolordrag.h"
@@ -597,6 +599,7 @@
 }
 
 
+#ifndef Q_WS_WIN
 static const char * const *namedColorFilePath( void )
 {
   //
@@ -614,9 +617,54 @@
   };
   return path;
 }
+#endif
 
 
+bool
+KPaletteTable::tryReadNamedColors( const QString& palfname )
+{
+  QFile paletteFile( palfname );
+  if( !paletteFile.open( IO_ReadOnly ) )
+  {
+    return false;
+  }
 
+  QString line;
+  QStringList list;
+  while( paletteFile.readLine( line, 100 ) != -1 )
+  {
+    int red, green, blue;
+    int pos = 0;
+
+    if( sscanf(line.ascii(), "%d %d %d%n", &red, &green, &blue, &pos ) == 3 )
+    {
+      //
+      // Remove duplicates. Every name with a space and every name
+      // that start with "gray".
+      //
+      QString name = line.mid(pos).stripWhiteSpace();
+      if (!name.isEmpty())
+        name[0] = name[0].upper(); //1st letter opper case for mor human-friendly sorting
+      if( name.isEmpty() || name.find(' ') != -1 ||
+        name.find( "gray" ) != -1 ||  name.find( "grey" ) != -1 )
+      {
+        continue;
+      }
+
+      const QColor color ( red, green, blue );
+      if ( color.isValid() )
+      {
+         const QString colorName( i18n("color", name.latin1() ) );
+         list.append( colorName );
+         d->m_namedColorMap[ colorName ] = color;
+      }
+    }
+  }
+
+  list.sort();
+  mNamedColorList->insertStringList( list );
+  return true;
+}
 
 void
 KPaletteTable::readNamedColor( void )
@@ -632,49 +680,19 @@
   // Code somewhat inspired by KPalette.
   //
 
+#ifdef Q_WS_WIN
+  // for win32 we cannot rely on having X11 installed, 
+  // so we're assuming a copy of palette file can be saved
+  // as $KDEDIR/share/config/colors/x11/rgb.txt
+# define WIN32_X11_COLOR_SUBPATH "colors/x11/rgb.txt"
+  QString palfname = ::locate("config", WIN32_X11_COLOR_SUBPATH);
+  if (!palfname.isEmpty())
+    tryReadNamedColors( palfname );
+#else
   const char * const *path = namedColorFilePath();
-  for( int i=0; path[i]; ++i )
-  {
-    QFile paletteFile( path[i] );
-    if( !paletteFile.open( IO_ReadOnly ) )
-    {
-      continue;
-    }
-
-    QString line;
-    QStringList list;
-    while( paletteFile.readLine( line, 100 ) != -1 )
-    {
-      int red, green, blue;
-      int pos = 0;
-
-      if( sscanf(line.ascii(), "%d %d %d%n", &red, &green, &blue, &pos ) == 3 )
-      {
-	//
-	// Remove duplicates. Every name with a space and every name
-	// that start with "gray".
-	//
-	QString name = line.mid(pos).stripWhiteSpace();
-	if( name.isNull() || name.find(' ') != -1 ||
-	    name.find( "gray" ) != -1 ||  name.find( "grey" ) != -1 )
-	{
-	  continue;
-	}
-
-        const QColor color ( red, green, blue );
-        if ( color.isValid() )
-        {
-            const QString colorName( i18n("color", name.latin1() ) );
-            list.append( colorName );
-            d->m_namedColorMap[ colorName ] = color;
-        }
-      }
-    }
-
-    list.sort();
-    mNamedColorList->insertStringList( list );
-    break;
-  }
+  for( int i=0; path[i] && !tryReadNamedColors( QString::fromLatin1(path[i]) ); ++i )
+    ;
+#endif
 
   if( mNamedColorList->count() == 0 )
   {
@@ -699,12 +717,20 @@
       "Unable to read X11 RGB color strings. The following "
       "file location(s) were examined:\n");
 
+#ifdef Q_WS_WIN
+    QStringList list( KGlobal::dirs()->resourceDirs("config") );
+    for( QStringList::ConstIterator it = list.constBegin(); it!=list.constEnd(); ++it )
+    {
+       msg += (QDir::convertSeparators(*it + WIN32_X11_COLOR_SUBPATH) + "\n");
+    }
+#else
     const char * const *path = namedColorFilePath();
     for( int i=0; path[i]; ++i )
     {
       msg += path[i];
       msg += "\n";
     }
+#endif
     KMessageBox::sorry( this, msg );
   }
 }
Index: kcolordialog.h
===================================================================
RCS file: /home/kde/kdelibs/kdeui/kcolordialog.h,v
retrieving revision 1.64
diff -u -r1.64 kcolordialog.h
--- kcolordialog.h	10 Oct 2004 12:41:55 -0000	1.64
+++ kcolordialog.h	23 Apr 2005 22:42:19 -0000
@@ -235,6 +235,7 @@
 private:
 
   virtual void setPalette(const QPalette& p) { QWidget::setPalette(p); }
+  bool tryReadNamedColors( const QString& palfname );
 protected:
   virtual void virtual_hook( int id, void* data );
 private:
