Changeset 642 for trunk/src/gui/styles/qcommonstyle.cpp
- Timestamp:
- Mar 6, 2010, 12:32:46 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 }
Note:
See TracChangeset
for help on using the changeset viewer.