- Timestamp:
- Mar 6, 2010, 12:32:46 AM (15 years ago)
- Location:
- trunk/src/gui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/gui/itemviews/qfileiconprovider.cpp
r620 r642 99 99 #ifdef Q_WS_WIN 100 100 QIcon getWinIcon(const QFileInfo &fi) const; 101 #elif defined(Q_WS_PM) 102 QIcon getPmIcon(const QFileInfo &fi) const; 101 103 #elif defined(Q_WS_MAC) 102 104 QIcon getMacIcon(const QFileInfo &fi) const; … … 319 321 } 320 322 323 #elif defined(Q_WS_PM) 324 QIcon QFileIconProviderPrivate::getPmIcon(const QFileInfo &fileInfo) const 325 { 326 QIcon retIcon; 327 328 if (fileInfo.isRoot()) { 329 // Unfortunately, WinLoadFileIcon() returns a regular folder icon for 330 // paths like "C:\" (and nothing for "C:") instead of a drive icon. 331 // Getting the latter involves calling WPS object methods so we leave it 332 // out for now and let the stock Qt drive-specific icons be used instead. 333 return retIcon; 334 } 335 336 QByteArray path = QDir::toNativeSeparators( 337 QDir::cleanPath(fileInfo.absoluteFilePath())).toLocal8Bit(); 338 HPOINTER hicon = WinLoadFileIcon(path, FALSE); 339 if (hicon != NULLHANDLE) { 340 // we're requesting the system (shared) icon handle which should be 341 // always the same for the given file until the icon is changed, so use 342 // the bitmap handles as a key in the pixmap cache 343 QString key = QString(QLatin1String("qt_hicon_%1")).arg(hicon); 344 QString keyMini = key + QLatin1String("_m"); 345 QPixmap pixmap; 346 QPixmapCache::find(key, pixmap); 347 if (!pixmap.isNull()) { 348 retIcon.addPixmap(pixmap); 349 QPixmapCache::find(keyMini, pixmap); 350 if (!pixmap.isNull()) 351 retIcon.addPixmap(pixmap); 352 } else { 353 QPixmap mini; 354 retIcon = QPixmap::fromPmHPOINTER(hicon, &pixmap, &mini); 355 if (!retIcon.isNull()) { 356 // store pixmaps in the cache 357 Q_ASSERT(!pixmap.isNull() || !mini.isNull()); 358 if (!pixmap.isNull()) 359 QPixmapCache::insert(key, pixmap); 360 if (!mini.isNull()) 361 QPixmapCache::insert(keyMini, mini); 362 } 363 } 364 } 365 366 return retIcon; 367 } 368 321 369 #elif defined(Q_WS_MAC) 322 370 QIcon QFileIconProviderPrivate::getMacIcon(const QFileInfo &fi) const … … 410 458 if (!icon.isNull()) 411 459 return icon; 460 #elif defined Q_WS_PM 461 if (QApplication::desktopSettingsAware()) { 462 QIcon icon= d->getPmIcon(info); 463 if (!icon.isNull()) 464 return icon; 465 } 412 466 #endif 413 467 if (info.isRoot()) -
trunk/src/gui/styles/qcommonstyle.cpp
r561 r642 89 89 #endif 90 90 91 #ifdef Q_WS_PM 92 # include <qt_os2.h> 93 #endif 94 91 95 QT_BEGIN_NAMESPACE 92 96 … … 3038 3042 if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { 3039 3043 if (tbopt->features & QStyleOptionToolBar::Movable) { 3040 ///we need to access the widget here because the style option doesn't 3044 ///we need to access the widget here because the style option doesn't 3041 3045 //have all the information we need (ie. the layout's margin) 3042 3046 const QToolBar *tb = qobject_cast<const QToolBar*>(widget); … … 4668 4672 break; 4669 4673 4674 #ifdef Q_WS_PM 4675 case PM_ButtonIconSize: 4676 ret = int(QStyleHelper::dpiScaled(16.)); 4677 case PM_SmallIconSize: 4678 if (QApplication::desktopSettingsAware()) 4679 ret = WinQuerySysValue(HWND_DESKTOP, SV_CXICON) / 2; 4680 else 4681 ret = int(QStyleHelper::dpiScaled(16.)); 4682 break; 4683 #else 4670 4684 case PM_ButtonIconSize: 4671 4685 case PM_SmallIconSize: 4672 4686 ret = int(QStyleHelper::dpiScaled(16.)); 4673 4687 break; 4688 #endif 4674 4689 case PM_IconViewIconSize: 4675 4690 ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); … … 4677 4692 4678 4693 case PM_LargeIconSize: 4694 #ifdef Q_WS_PM 4695 if (QApplication::desktopSettingsAware()) 4696 ret = WinQuerySysValue(HWND_DESKTOP, SV_CXICON); 4697 else 4698 ret = int(QStyleHelper::dpiScaled(32.)); 4699 #else 4679 4700 ret = int(QStyleHelper::dpiScaled(32.)); 4701 #endif 4680 4702 break; 4681 4703 … … 5954 5976 break; 5955 5977 } 5978 #if defined(Q_WS_PM) 5979 if (QApplication::desktopSettingsAware() && !icon.isNull()) { 5980 // make sure the file dialog related icons have a size not smaller than 5981 // the system icon size by centering them (this makes sure the 5982 // corresponding items are aligned with file items with system icons) 5983 switch (standardIcon) { 5984 case SP_DriveCDIcon: 5985 case SP_DriveDVDIcon: 5986 case SP_DriveNetIcon: 5987 case SP_DriveHDIcon: 5988 case SP_DriveFDIcon: 5989 case SP_FileIcon: 5990 case SP_FileLinkIcon: 5991 case SP_DirLinkIcon: 5992 case SP_DirClosedIcon: 5993 case SP_DesktopIcon: 5994 case SP_ComputerIcon: 5995 case SP_DirOpenIcon: 5996 case SP_FileDialogNewFolder: 5997 case SP_DirHomeIcon: 5998 case SP_TrashIcon: { 5999 static QIcon::Mode modes[] = { QIcon::Normal, QIcon::Active, 6000 QIcon::Disabled, QIcon::Selected }; 6001 static QIcon::State states[] = { QIcon::Off, QIcon::On }; 6002 int small = pixelMetric(PM_SmallIconSize); 6003 int large = pixelMetric(PM_LargeIconSize); 6004 for (size_t m = 0; m < sizeof(modes)/sizeof(modes[0]); ++m) { 6005 for (size_t s = 0; s < sizeof(states)/sizeof(states[0]); ++s) { 6006 QIcon::Mode mm = modes[m]; 6007 QIcon::State ss = states[s]; 6008 QList<QSize> sizes = icon.availableSizes(mm, ss); 6009 QSize smallSz, largeSz; 6010 foreach(const QSize &asz, sizes) { 6011 if (asz.width() < small) 6012 smallSz = asz; 6013 else if (asz.width() < large) 6014 largeSz = asz; 6015 else 6016 break; 6017 } 6018 if (smallSz.isValid()) { 6019 QPixmap pixmap = icon.pixmap(smallSz, mm, ss); 6020 QPixmap centered(small, small); 6021 centered.fill(Qt::transparent); 6022 QPainter painter(¢ered); 6023 int x = (small - pixmap.width()) / 2; 6024 int y = (small - pixmap.height()) / 2; 6025 painter.drawPixmap(x, y, pixmap); 6026 painter.end(); 6027 icon.addPixmap(centered, mm, ss); 6028 } 6029 if (largeSz.isValid()) { 6030 QPixmap pixmap = icon.pixmap(largeSz, mm, ss); 6031 QPixmap centered(large, large); 6032 centered.fill(Qt::transparent); 6033 QPainter painter(¢ered); 6034 int x = (large - pixmap.width()) / 2; 6035 int y = (large - pixmap.height()) / 2; 6036 painter.drawPixmap(x, y, pixmap); 6037 painter.end(); 6038 icon.addPixmap(centered, mm, ss); 6039 } 6040 6041 } 6042 } 6043 break; 6044 } 6045 default: 6046 break; 6047 } 6048 } 6049 #endif 5956 6050 return icon; 5957 6051 } -
trunk/src/gui/styles/qwindowsstyle.cpp
r561 r642 438 438 439 439 case PM_SmallIconSize: 440 #if defined(Q_WS_PM) 441 if (QApplication::desktopSettingsAware()) 442 return QCommonStyle::pixelMetric(pm, opt, widget); 443 #endif 440 444 ret = int(QStyleHelper::dpiScaled(16.)); 441 445 break; 442 446 443 447 case PM_LargeIconSize: 448 #if defined(Q_WS_PM) 449 if (QApplication::desktopSettingsAware()) 450 return QCommonStyle::pixelMetric(pm, opt, widget); 451 #endif 444 452 ret = int(QStyleHelper::dpiScaled(32.)); 445 453 break; … … 1390 1398 QPixmap pixmap; 1391 1399 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("$qt_ia-") + QLatin1String(metaObject()->className()), opt, QSize(size, size)) 1392 + QLatin1Char('-') + QString::number(pe); 1400 + QLatin1Char('-') + QString::number(pe); 1393 1401 if (!QPixmapCache::find(pixmapName, pixmap)) { 1394 1402 int border = size/5;
Note:
See TracChangeset
for help on using the changeset viewer.