Index: trunk/src/gui/itemviews/qfileiconprovider.cpp
===================================================================
--- trunk/src/gui/itemviews/qfileiconprovider.cpp	(revision 641)
+++ trunk/src/gui/itemviews/qfileiconprovider.cpp	(revision 642)
@@ -99,4 +99,6 @@
 #ifdef Q_WS_WIN
     QIcon getWinIcon(const QFileInfo &fi) const;
+#elif defined(Q_WS_PM)
+    QIcon getPmIcon(const QFileInfo &fi) const;
 #elif defined(Q_WS_MAC)
     QIcon getMacIcon(const QFileInfo &fi) const;
@@ -319,4 +321,50 @@
 }
 
+#elif defined(Q_WS_PM)
+QIcon QFileIconProviderPrivate::getPmIcon(const QFileInfo &fileInfo) const
+{
+    QIcon retIcon;
+
+    if (fileInfo.isRoot()) {
+        // Unfortunately, WinLoadFileIcon() returns a regular folder icon for
+        // paths like "C:\" (and nothing for "C:") instead of a drive icon.
+        // Getting the latter involves calling WPS object methods so we leave it
+        // out for now and let the stock Qt drive-specific icons be used instead.
+        return retIcon;
+    }
+
+    QByteArray path = QDir::toNativeSeparators(
+        QDir::cleanPath(fileInfo.absoluteFilePath())).toLocal8Bit();
+    HPOINTER hicon = WinLoadFileIcon(path, FALSE);
+    if (hicon != NULLHANDLE) {
+        // we're requesting the system (shared) icon handle which should be
+        // always the same for the given file until the icon is changed, so use
+        // the bitmap handles as a key in the pixmap cache
+        QString key = QString(QLatin1String("qt_hicon_%1")).arg(hicon);
+        QString keyMini = key + QLatin1String("_m");
+        QPixmap pixmap;
+        QPixmapCache::find(key, pixmap);
+        if (!pixmap.isNull()) {
+            retIcon.addPixmap(pixmap);
+            QPixmapCache::find(keyMini, pixmap);
+            if (!pixmap.isNull())
+                retIcon.addPixmap(pixmap);
+        } else {
+            QPixmap mini;
+            retIcon = QPixmap::fromPmHPOINTER(hicon, &pixmap, &mini);
+            if (!retIcon.isNull()) {
+                // store pixmaps in the cache
+                Q_ASSERT(!pixmap.isNull() || !mini.isNull());
+                if (!pixmap.isNull())
+                    QPixmapCache::insert(key, pixmap);
+                if (!mini.isNull())
+                    QPixmapCache::insert(keyMini, mini);
+            }
+        }
+    }
+
+    return retIcon;
+}
+
 #elif defined(Q_WS_MAC)
 QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const
@@ -410,4 +458,10 @@
     if (!icon.isNull())
         return icon;
+#elif defined Q_WS_PM
+    if (QApplication::desktopSettingsAware()) {
+        QIcon icon= d->getPmIcon(info);
+        if (!icon.isNull())
+            return icon;
+    }
 #endif
     if (info.isRoot())
Index: trunk/src/gui/styles/qcommonstyle.cpp
===================================================================
--- trunk/src/gui/styles/qcommonstyle.cpp	(revision 641)
+++ trunk/src/gui/styles/qcommonstyle.cpp	(revision 642)
@@ -89,4 +89,8 @@
 #endif
 
+#ifdef Q_WS_PM
+#   include <qt_os2.h>
+#endif
+
 QT_BEGIN_NAMESPACE
 
@@ -3038,5 +3042,5 @@
         if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) {
             if (tbopt->features & QStyleOptionToolBar::Movable) {
-                ///we need to access the widget here because the style option doesn't 
+                ///we need to access the widget here because the style option doesn't
                 //have all the information we need (ie. the layout's margin)
                 const QToolBar *tb = qobject_cast<const QToolBar*>(widget);
@@ -4668,8 +4672,19 @@
         break;
 
+#ifdef Q_WS_PM
+    case PM_ButtonIconSize:
+        ret = int(QStyleHelper::dpiScaled(16.));
+    case PM_SmallIconSize:
+        if (QApplication::desktopSettingsAware())
+            ret = WinQuerySysValue(HWND_DESKTOP, SV_CXICON) / 2;
+        else
+            ret = int(QStyleHelper::dpiScaled(16.));
+        break;
+#else
     case PM_ButtonIconSize:
     case PM_SmallIconSize:
         ret = int(QStyleHelper::dpiScaled(16.));
         break;
+#endif
     case PM_IconViewIconSize:
         ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget);
@@ -4677,5 +4692,12 @@
 
     case PM_LargeIconSize:
+#ifdef Q_WS_PM
+        if (QApplication::desktopSettingsAware())
+            ret = WinQuerySysValue(HWND_DESKTOP, SV_CXICON);
+        else
+            ret = int(QStyleHelper::dpiScaled(32.));
+#else
         ret = int(QStyleHelper::dpiScaled(32.));
+#endif
         break;
 
@@ -5954,4 +5976,76 @@
         break;
     }
+#if defined(Q_WS_PM)
+    if (QApplication::desktopSettingsAware() && !icon.isNull()) {
+        // make sure the file dialog related icons have a size not smaller than
+        // the system icon size by centering them (this makes sure the
+        // corresponding items are aligned with file items with system icons)
+        switch (standardIcon) {
+        case SP_DriveCDIcon:
+        case SP_DriveDVDIcon:
+        case SP_DriveNetIcon:
+        case SP_DriveHDIcon:
+        case SP_DriveFDIcon:
+        case SP_FileIcon:
+        case SP_FileLinkIcon:
+        case SP_DirLinkIcon:
+        case SP_DirClosedIcon:
+        case SP_DesktopIcon:
+        case SP_ComputerIcon:
+        case SP_DirOpenIcon:
+        case SP_FileDialogNewFolder:
+        case SP_DirHomeIcon:
+        case SP_TrashIcon: {
+            static QIcon::Mode modes[] = { QIcon::Normal, QIcon::Active,
+                                           QIcon::Disabled, QIcon::Selected };
+            static QIcon::State states[] = { QIcon::Off, QIcon::On };
+            int small = pixelMetric(PM_SmallIconSize);
+            int large = pixelMetric(PM_LargeIconSize);
+            for (size_t m = 0; m < sizeof(modes)/sizeof(modes[0]); ++m) {
+                for (size_t s = 0; s < sizeof(states)/sizeof(states[0]); ++s) {
+                    QIcon::Mode mm = modes[m];
+                    QIcon::State ss = states[s];
+                    QList<QSize> sizes = icon.availableSizes(mm, ss);
+                    QSize smallSz, largeSz;
+                    foreach(const QSize &asz, sizes) {
+                        if (asz.width() < small)
+                            smallSz = asz;
+                        else if (asz.width() < large)
+                            largeSz = asz;
+                        else
+                            break;
+                    }
+                    if (smallSz.isValid()) {
+                        QPixmap pixmap = icon.pixmap(smallSz, mm, ss);
+                        QPixmap centered(small, small);
+                        centered.fill(Qt::transparent);
+                        QPainter painter(&centered);
+                        int x = (small - pixmap.width()) / 2;
+                        int y = (small - pixmap.height()) / 2;
+                        painter.drawPixmap(x, y, pixmap);
+                        painter.end();
+                        icon.addPixmap(centered, mm, ss);
+                    }
+                    if (largeSz.isValid()) {
+                        QPixmap pixmap = icon.pixmap(largeSz, mm, ss);
+                        QPixmap centered(large, large);
+                        centered.fill(Qt::transparent);
+                        QPainter painter(&centered);
+                        int x = (large - pixmap.width()) / 2;
+                        int y = (large - pixmap.height()) / 2;
+                        painter.drawPixmap(x, y, pixmap);
+                        painter.end();
+                        icon.addPixmap(centered, mm, ss);
+                    }
+
+                }
+            }
+            break;
+        }
+        default:
+            break;
+        }
+    }
+#endif
     return icon;
 }
Index: trunk/src/gui/styles/qwindowsstyle.cpp
===================================================================
--- trunk/src/gui/styles/qwindowsstyle.cpp	(revision 641)
+++ trunk/src/gui/styles/qwindowsstyle.cpp	(revision 642)
@@ -438,8 +438,16 @@
 
     case PM_SmallIconSize:
+#if defined(Q_WS_PM)
+        if (QApplication::desktopSettingsAware())
+            return QCommonStyle::pixelMetric(pm, opt, widget);
+#endif
         ret = int(QStyleHelper::dpiScaled(16.));
         break;
 
     case PM_LargeIconSize:
+#if defined(Q_WS_PM)
+        if (QApplication::desktopSettingsAware())
+            return QCommonStyle::pixelMetric(pm, opt, widget);
+#endif
         ret = int(QStyleHelper::dpiScaled(32.));
         break;
@@ -1390,5 +1398,5 @@
             QPixmap pixmap;
             QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size))
-                  + QLatin1Char('-') + QString::number(pe);                               
+                  + QLatin1Char('-') + QString::number(pe);
             if (!QPixmapCache::find(pixmapName, pixmap)) {
                 int border = size/5;
