Changeset 561 for trunk/src/gui/styles/qcommonstyle.cpp
- Timestamp:
- Feb 11, 2010, 11:19:06 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to (toggle deleted branches)
/branches/vendor/nokia/qt/4.6.1 merged eligible /branches/vendor/nokia/qt/current merged eligible /branches/vendor/trolltech/qt/current 3-149
-
Property svn:mergeinfo
set to (toggle deleted branches)
-
trunk/src/gui/styles/qcommonstyle.cpp
r2 r561 2 2 ** 3 3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). 4 ** Contact: Qt Software Information (qt-info@nokia.com) 4 ** All rights reserved. 5 ** Contact: Nokia Corporation (qt-info@nokia.com) 5 6 ** 6 7 ** This file is part of the QtGui module of the Qt Toolkit. … … 21 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 22 23 ** 23 ** In addition, as a special exception, Nokia gives you certain 24 ** additional rights. These rights are described in the Nokia Qt LGPL 25 ** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this 26 ** package. 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 27 ** 28 28 ** GNU General Public License Usage … … 34 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 35 ** 36 ** If you are unsure which license is appropriate for your use, please37 ** contact the sales department at qt-sales@nokia.com.36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 38 38 ** $QT_END_LICENSE$ 39 39 ** … … 64 64 #include <qtoolbutton.h> 65 65 #include <qrubberband.h> 66 #include <private/qapplication_p.h>67 66 #include <private/qcommonstylepixmaps_p.h> 68 67 #include <private/qmath_p.h> 68 #include <private/qstylehelper_p.h> 69 69 #include <qdebug.h> 70 70 #include <qtextformat.h> … … 75 75 #include <qsettings.h> 76 76 #include <qpixmapcache.h> 77 #include <private/qguiplatformplugin_p.h> 77 78 78 79 #include <limits.h> … … 84 85 #ifdef Q_WS_X11 85 86 # include <private/qt_x11_p.h> 87 #elif defined(Q_WS_MAC) 88 # include <private/qt_cocoa_helpers_mac_p.h> 86 89 #endif 87 90 … … 125 128 126 129 /*! 127 \overload 128 129 Destroys the style 130 Destroys the style. 130 131 */ 131 132 QCommonStyle::~QCommonStyle() … … 155 156 break; 156 157 case PE_IndicatorViewItemCheck: 157 drawPrimitive(PE_IndicatorCheckBox, opt, p, widget);158 proxy()->drawPrimitive(PE_IndicatorCheckBox, opt, p, widget); 158 159 break; 159 160 case PE_IndicatorCheckBox: … … 505 506 } 506 507 507 int size = p ixelMetric(QStyle::PM_SmallIconSize);508 int size = proxy()->pixelMetric(QStyle::PM_SmallIconSize); 508 509 QIcon::Mode mode = opt->state & State_Enabled ? 509 510 (opt->state & State_Raised ? QIcon::Active : QIcon::Normal) … … 516 517 QIcon::State state = opt->state & State_Sunken ? QIcon::On : QIcon::Off; 517 518 QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(size, mode, state); 518 drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap);519 proxy()->drawItemPixmap(p, opt->rect, Qt::AlignCenter, pixmap); 519 520 break; 520 521 } … … 525 526 break; 526 527 case PE_FrameLineEdit: 527 drawPrimitive(PE_Frame, opt, p, widget);528 proxy()->drawPrimitive(PE_Frame, opt, p, widget); 528 529 break; 529 530 #ifndef QT_NO_GROUPBOX … … 550 551 int lw = frame->lineWidth; 551 552 if (lw <= 0) 552 lw = p ixelMetric(PM_DockWidgetFrameWidth);553 lw = proxy()->pixelMetric(PM_DockWidgetFrameWidth); 553 554 554 555 qDrawShadePanel(p, frame->rect, frame->palette, false, lw); … … 562 563 if (opt->state & State_Horizontal) { 563 564 int x = opt->rect.width() / 3; 564 if ( QApplication::layoutDirection()== Qt::RightToLeft)565 if (opt->direction == Qt::RightToLeft) 565 566 x -= 2; 566 567 if (opt->rect.height() > 4) { … … 582 583 break; 583 584 case PE_Q3DockWindowSeparator: 584 drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget);585 proxy()->drawPrimitive(PE_IndicatorToolBarSeparator, opt, p, widget); 585 586 break; 586 587 case PE_IndicatorToolBarSeparator: … … 602 603 case PE_IndicatorSpinMinus: { 603 604 QRect r = opt->rect; 604 int fw = p ixelMetric(PM_DefaultFrameWidth, opt, widget);605 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); 605 606 QRect br = r.adjusted(fw, fw, -fw, -fw); 606 607 … … 619 620 case PE_IndicatorSpinDown: { 620 621 QRect r = opt->rect; 621 int fw = p ixelMetric(PM_DefaultFrameWidth, opt, widget);622 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); 622 623 // QRect br = r.adjusted(fw, fw, -fw, -fw); 623 624 int x = r.x(), y = r.y(), w = r.width(), h = r.height(); … … 644 645 int bsy = 0; 645 646 if (opt->state & State_Sunken) { 646 bsx = p ixelMetric(PM_ButtonShiftHorizontal);647 bsy = p ixelMetric(PM_ButtonShiftVertical);647 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); 648 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); 648 649 } 649 650 p->save(); … … 694 695 695 696 if (panel->lineWidth > 0) 696 drawPrimitive(PE_FrameLineEdit, panel, p, widget);697 proxy()->drawPrimitive(PE_FrameLineEdit, panel, p, widget); 697 698 } 698 699 break; … … 766 767 cg = QPalette::Inactive; 767 768 768 if ((vopt->state & QStyle::State_Selected) && styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget))769 if ((vopt->state & QStyle::State_Selected) && proxy()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, opt, widget)) 769 770 p->fillRect(vopt->rect, vopt->palette.brush(cg, QPalette::Highlight)); 770 771 else if (vopt->features & QStyleOptionViewItemV2::Alternate) … … 835 836 #endif // QT_NO_TOOLBUTTON 836 837 837 838 839 #ifdef Q_WS_X11 // These functions are used to parse the X11 freedesktop icon spec840 841 void QCommonStylePrivate::lookupIconTheme() const842 {843 if (!themeName.isEmpty())844 return;845 846 QString dataDirs = QString::fromLocal8Bit(getenv("XDG_DATA_DIRS"));847 if (dataDirs.isEmpty())848 dataDirs = QLatin1String("/usr/local/share/:/usr/share/");849 dataDirs += QLatin1Char(':') + QApplicationPrivate::kdeHome() + QLatin1String("/share");850 dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));851 QStringList kdeDirs = QString::fromLocal8Bit(getenv("KDEDIRS")).split(QLatin1Char(':'));852 foreach (const QString &dirName, kdeDirs)853 dataDirs.append(QLatin1String(":") + dirName + QLatin1String("/share"));854 iconDirs = dataDirs.split(QLatin1Char(':'));855 856 QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));857 QDir dir(fileInfo.canonicalFilePath());858 int kdeVersion = qgetenv("KDE_SESSION_VERSION").toInt();859 QString kdeDefault = kdeVersion >= 4 ? QString::fromLatin1("oxygen") : QString::fromLatin1("crystalsvg");860 QString defaultTheme = fileInfo.exists() ? dir.dirName() : kdeDefault;861 QSettings settings(QApplicationPrivate::kdeHome() +862 QLatin1String("/share/config/kdeglobals"), QSettings::IniFormat);863 settings.beginGroup(QLatin1String("Icons"));864 themeName = settings.value(QLatin1String("Theme"), defaultTheme).toString();865 }866 867 QIconTheme QCommonStylePrivate::parseIndexFile(const QString &themeName) const868 {869 Q_Q(const QCommonStyle);870 QIconTheme theme;871 QFile themeIndex;872 QStringList parents;873 QHash <int, QString> dirList;874 875 for ( int i = 0 ; i < iconDirs.size() && !themeIndex.exists() ; ++i) {876 QString contentDir = QLatin1String(iconDirs[i].startsWith(QDir::homePath()) ?877 "/.icons/" : "/icons/");878 themeIndex.setFileName(iconDirs[i] + contentDir +879 themeName + QLatin1String("/index.theme"));880 }881 882 if (themeIndex.open(QIODevice::ReadOnly | QIODevice::Text)) {883 884 QTextStream in(&themeIndex);885 886 while (!in.atEnd()) {887 888 QString line = in.readLine();889 890 if (line.startsWith(QLatin1String("Inherits="))) {891 line = line.right(line.length() - 9);892 parents = line.split(QLatin1Char(','));893 }894 895 if (line.startsWith(QLatin1String("["))) {896 line = line.trimmed();897 line.chop(1);898 QString dirName = line.right(line.length() - 1);899 if (!in.atEnd()) {900 line = in.readLine();901 int size;902 if (line.startsWith(QLatin1String("Size="))) {903 size = line.right(line.length() - 5).toInt();904 if (size)905 dirList.insertMulti(size, dirName);906 }907 }908 }909 }910 }911 912 if (q->inherits("QPlastiqueStyle")) {913 QFileInfo fileInfo(QLatin1String("/usr/share/icons/default.kde"));914 QDir dir(fileInfo.canonicalFilePath());915 QString defaultKDETheme = dir.exists() ? dir.dirName() : QString::fromLatin1("crystalsvg");916 if (!parents.contains(defaultKDETheme) && themeName != defaultKDETheme)917 parents.append(defaultKDETheme);918 } else if (parents.isEmpty() && themeName != QLatin1String("hicolor")) {919 parents.append(QLatin1String("hicolor"));920 }921 theme = QIconTheme(dirList, parents);922 return theme;923 }924 925 QPixmap QCommonStylePrivate::findIconHelper(int size,926 const QString &themeName,927 const QString &iconName,928 QStringList &visited) const929 {930 QPixmap pixmap;931 932 if (!themeName.isEmpty()) {933 934 visited << themeName;935 QIconTheme theme = themeList.value(themeName);936 937 if (!theme.isValid()) {938 theme = parseIndexFile(themeName);939 themeList.insert(themeName, theme);940 }941 942 if (!theme.isValid())943 return QPixmap();944 945 QList <QString> subDirs = theme.dirList().values(size);946 947 for ( int i = 0 ; i < iconDirs.size() ; ++i) {948 for ( int j = 0 ; j < subDirs.size() ; ++j) {949 QString contentDir = (iconDirs[i].startsWith(QDir::homePath())) ?950 QLatin1String("/.icons/") : QLatin1String("/icons/");951 QString fileName = iconDirs[i] + contentDir + themeName + QLatin1Char('/') + subDirs[j] + QLatin1Char('/') + iconName;952 QFile file(fileName);953 if (file.exists())954 pixmap.load(fileName);955 if (!pixmap.isNull())956 break;957 }958 }959 960 if (pixmap.isNull()) {961 QStringList parents = theme.parents();962 //search recursively through inherited themes963 for (int i = 0 ; pixmap.isNull() && i < parents.size() ; ++i) {964 QString parentTheme = parents[i].trimmed();965 if (!visited.contains(parentTheme)) //guard against endless recursion966 pixmap = findIconHelper(size, parentTheme, iconName, visited);967 }968 }969 }970 return pixmap;971 }972 973 QPixmap QCommonStylePrivate::findIcon(int size, const QString &name) const974 {975 QPixmap pixmap;976 QString pixmapName = QLatin1String("$qt") + name + QString::number(size);977 978 if (QPixmapCache::find(pixmapName, pixmap))979 return pixmap;980 981 if (!themeName.isEmpty()) {982 QStringList visited;983 pixmap = findIconHelper(size, themeName, name, visited);984 }985 QPixmapCache::insert(pixmapName, pixmap);986 return pixmap;987 }988 989 QIcon QCommonStylePrivate::createIcon(const QString &name) const990 {991 QIcon icon;992 icon.addPixmap(findIcon(16, name));993 icon.addPixmap(findIcon(24, name));994 icon.addPixmap(findIcon(32, name));995 return icon;996 }997 998 #endif //Q_WS_X11999 1000 838 #ifndef QT_NO_ITEMVIEWS 1001 1002 839 1003 840 QSize QCommonStylePrivate::viewItemSize(const QStyleOptionViewItemV4 *option, int role) const … … 1048 885 } 1049 886 textLayout.endLayout(); 1050 const QSize size = QSizeF(widthUsed, height).toSize();887 const QSize size(qCeil(widthUsed), qCeil(height)); 1051 888 return QSize(size.width() + 2 * textMargin, size.height()); 1052 889 } … … 1153 990 } 1154 991 1155 /* Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore 1156 opt->rect and return rectangles in infinite space */ 992 /*! \internal 993 compute the position for the different component of an item (pixmap, text, checkbox) 994 995 Set sizehint to false to layout the elements inside opt->rect. Set sizehint to true to ignore 996 opt->rect and return rectangles in infinite space 997 998 Code duplicated in QItemDelegate::doLayout 999 */ 1157 1000 void QCommonStylePrivate::viewItemLayout(const QStyleOptionViewItemV4 *opt, QRect *checkRect, 1158 1001 QRect *pixmapRect, QRect *textRect, bool sizehint) const … … 1175 1018 int w, h; 1176 1019 1177 if (textRect->height() == 0 && !hasPixmap) 1020 if (textRect->height() == 0 && (!hasPixmap || !sizehint)) { 1021 //if there is no text, we still want to have a decent height for the item sizeHint and the editor size 1178 1022 textRect->setHeight(opt->fontMetrics.height()); 1023 } 1179 1024 1180 1025 QSize pm(0, 0); … … 1280 1125 #endif // QT_NO_ITEMVIEWS 1281 1126 1127 1128 #ifndef QT_NO_TABBAR 1129 /*! \internal 1130 Compute the textRect and the pixmapRect from the opt rect 1131 1132 Uses the same computation than in QTabBar::tabSizeHint 1133 */ 1134 void QCommonStylePrivate::tabLayout(const QStyleOptionTabV3 *opt, const QWidget *widget, QRect *textRect, QRect *iconRect) const 1135 { 1136 Q_ASSERT(textRect); 1137 Q_ASSERT(iconRect); 1138 QRect tr = opt->rect; 1139 bool verticalTabs = opt->shape == QTabBar::RoundedEast 1140 || opt->shape == QTabBar::RoundedWest 1141 || opt->shape == QTabBar::TriangularEast 1142 || opt->shape == QTabBar::TriangularWest; 1143 if (verticalTabs) 1144 tr.setRect(0, 0, tr.height(), tr.width()); //0, 0 as we will have a translate transform 1145 1146 int verticalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftVertical, opt, widget); 1147 int horizontalShift = proxyStyle->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, opt, widget); 1148 int hpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; 1149 int vpadding = proxyStyle->pixelMetric(QStyle::PM_TabBarTabVSpace, opt, widget) / 2; 1150 if (opt->shape == QTabBar::RoundedSouth || opt->shape == QTabBar::TriangularSouth) 1151 verticalShift = -verticalShift; 1152 tr.adjust(hpadding, vpadding, horizontalShift - hpadding, verticalShift - vpadding); 1153 bool selected = opt->state & QStyle::State_Selected; 1154 if (selected) { 1155 tr.setBottom(tr.bottom() - verticalShift); 1156 tr.setRight(tr.right() - horizontalShift); 1157 } 1158 1159 // left widget 1160 if (!opt->leftButtonSize.isEmpty()) { 1161 tr.setLeft(tr.left() + 4 + 1162 (verticalTabs ? opt->leftButtonSize.height() : opt->leftButtonSize.width())); 1163 } 1164 // right widget 1165 if (!opt->rightButtonSize.isEmpty()) { 1166 tr.setRight(tr.right() - 4 - 1167 (verticalTabs ? opt->rightButtonSize.height() : opt->rightButtonSize.width())); 1168 } 1169 1170 // icon 1171 if (!opt->icon.isNull()) { 1172 QSize iconSize = opt->iconSize; 1173 if (!iconSize.isValid()) { 1174 int iconExtent = proxyStyle->pixelMetric(QStyle::PM_SmallIconSize); 1175 iconSize = QSize(iconExtent, iconExtent); 1176 } 1177 QSize tabIconSize = opt->icon.actualSize(iconSize, 1178 (opt->state & QStyle::State_Enabled) ? QIcon::Normal : QIcon::Disabled, 1179 (opt->state & QStyle::State_Selected) ? QIcon::On : QIcon::Off ); 1180 1181 *iconRect = QRect(tr.left(), tr.center().y() - tabIconSize.height() / 2, 1182 tabIconSize.width(), tabIconSize .height()); 1183 if (!verticalTabs) 1184 *iconRect = proxyStyle->visualRect(opt->direction, opt->rect, *iconRect); 1185 tr.setLeft(tr.left() + tabIconSize.width() + 4); 1186 } 1187 1188 if (!verticalTabs) 1189 tr = proxyStyle->visualRect(opt->direction, opt->rect, tr); 1190 1191 *textRect = tr; 1192 } 1193 #endif //QT_NO_TABBAR 1194 1195 1282 1196 /*! 1283 1197 \reimp … … 1291 1205 case CE_PushButton: 1292 1206 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 1293 drawControl(CE_PushButtonBevel, btn, p, widget);1207 proxy()->drawControl(CE_PushButtonBevel, btn, p, widget); 1294 1208 QStyleOptionButton subopt = *btn; 1295 1209 subopt.rect = subElementRect(SE_PushButtonContents, btn, widget); 1296 drawControl(CE_PushButtonLabel, &subopt, p, widget);1210 proxy()->drawControl(CE_PushButtonLabel, &subopt, p, widget); 1297 1211 if (btn->state & State_HasFocus) { 1298 1212 QStyleOptionFocusRect fropt; 1299 1213 fropt.QStyleOption::operator=(*btn); 1300 1214 fropt.rect = subElementRect(SE_PushButtonFocusRect, btn, widget); 1301 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);1215 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 1302 1216 } 1303 1217 } … … 1306 1220 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 1307 1221 QRect br = btn->rect; 1308 int dbi = p ixelMetric(PM_ButtonDefaultIndicator, btn, widget);1222 int dbi = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 1309 1223 if (btn->features & QStyleOptionButton::DefaultButton) 1310 drawPrimitive(PE_FrameDefaultButton, opt, p, widget);1224 proxy()->drawPrimitive(PE_FrameDefaultButton, opt, p, widget); 1311 1225 if (btn->features & QStyleOptionButton::AutoDefaultButton) 1312 1226 br.setCoords(br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi); … … 1316 1230 QStyleOptionButton tmpBtn = *btn; 1317 1231 tmpBtn.rect = br; 1318 drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget);1232 proxy()->drawPrimitive(PE_PanelButtonCommand, &tmpBtn, p, widget); 1319 1233 } 1320 1234 if (btn->features & QStyleOptionButton::HasMenu) { 1321 int mbi = p ixelMetric(PM_MenuButtonIndicator, btn, widget);1235 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, btn, widget); 1322 1236 QRect ir = btn->rect; 1323 1237 QStyleOptionButton newBtn = *btn; 1324 1238 newBtn.rect = QRect(ir.right() - mbi + 2, ir.height()/2 - mbi/2 + 3, mbi - 6, mbi - 6); 1325 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);1239 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 1326 1240 } 1327 1241 } … … 1331 1245 QRect textRect = button->rect; 1332 1246 uint tf = Qt::AlignVCenter | Qt::TextShowMnemonic; 1333 if (! styleHint(SH_UnderlineShortcut, button, widget))1247 if (!proxy()->styleHint(SH_UnderlineShortcut, button, widget)) 1334 1248 tf |= Qt::TextHideMnemonic; 1335 1249 … … 1366 1280 1367 1281 if (button->state & (State_On | State_Sunken)) 1368 iconRect.translate(p ixelMetric(PM_ButtonShiftHorizontal, opt, widget),1369 p ixelMetric(PM_ButtonShiftVertical, opt, widget));1282 iconRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), 1283 proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget)); 1370 1284 p->drawPixmap(iconRect, pixmap); 1371 1285 } else { … … 1373 1287 } 1374 1288 if (button->state & (State_On | State_Sunken)) 1375 textRect.translate(p ixelMetric(PM_ButtonShiftHorizontal, opt, widget),1376 p ixelMetric(PM_ButtonShiftVertical, opt, widget));1289 textRect.translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, opt, widget), 1290 proxy()->pixelMetric(PM_ButtonShiftVertical, opt, widget)); 1377 1291 1378 1292 if (button->features & QStyleOptionButton::HasMenu) { 1379 int indicatorSize = p ixelMetric(PM_MenuButtonIndicator, button, widget);1293 int indicatorSize = proxy()->pixelMetric(PM_MenuButtonIndicator, button, widget); 1380 1294 if (button->direction == Qt::LeftToRight) 1381 1295 textRect = textRect.adjusted(0, 0, -indicatorSize, 0); … … 1383 1297 textRect = textRect.adjusted(indicatorSize, 0, 0, 0); 1384 1298 } 1385 drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled),1299 proxy()->drawItemText(p, textRect, tf, button->palette, (button->state & State_Enabled), 1386 1300 button->text, QPalette::ButtonText); 1387 1301 } … … 1394 1308 subopt.rect = subElementRect(isRadio ? SE_RadioButtonIndicator 1395 1309 : SE_CheckBoxIndicator, btn, widget); 1396 drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox,1310 proxy()->drawPrimitive(isRadio ? PE_IndicatorRadioButton : PE_IndicatorCheckBox, 1397 1311 &subopt, p, widget); 1398 1312 subopt.rect = subElementRect(isRadio ? SE_RadioButtonContents 1399 1313 : SE_CheckBoxContents, btn, widget); 1400 drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget);1314 proxy()->drawControl(isRadio ? CE_RadioButtonLabel : CE_CheckBoxLabel, &subopt, p, widget); 1401 1315 if (btn->state & State_HasFocus) { 1402 1316 QStyleOptionFocusRect fropt; … … 1404 1318 fropt.rect = subElementRect(isRadio ? SE_RadioButtonFocusRect 1405 1319 : SE_CheckBoxFocusRect, btn, widget); 1406 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);1320 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 1407 1321 } 1408 1322 } … … 1413 1327 uint alignment = visualAlignment(btn->direction, Qt::AlignLeft | Qt::AlignVCenter); 1414 1328 1415 if (! styleHint(SH_UnderlineShortcut, btn, widget))1329 if (!proxy()->styleHint(SH_UnderlineShortcut, btn, widget)) 1416 1330 alignment |= Qt::TextHideMnemonic; 1417 1331 QPixmap pix; … … 1419 1333 if (!btn->icon.isNull()) { 1420 1334 pix = btn->icon.pixmap(btn->iconSize, btn->state & State_Enabled ? QIcon::Normal : QIcon::Disabled); 1421 drawItemPixmap(p, btn->rect, alignment, pix);1335 proxy()->drawItemPixmap(p, btn->rect, alignment, pix); 1422 1336 if (btn->direction == Qt::RightToLeft) 1423 1337 textRect.setRight(textRect.right() - btn->iconSize.width() - 4); … … 1426 1340 } 1427 1341 if (!btn->text.isEmpty()){ 1428 drawItemText(p, textRect, alignment | Qt::TextShowMnemonic,1342 proxy()->drawItemText(p, textRect, alignment | Qt::TextShowMnemonic, 1429 1343 btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText); 1430 1344 } … … 1436 1350 QStyleOption arrowOpt = *opt; 1437 1351 arrowOpt.state |= State_Enabled; 1438 drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp),1352 proxy()->drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp), 1439 1353 &arrowOpt, p, widget); 1440 1354 break; } … … 1458 1372 uint alignment = Qt::AlignCenter | Qt::TextShowMnemonic | Qt::TextDontClip 1459 1373 | Qt::TextSingleLine; 1460 if (! styleHint(SH_UnderlineShortcut, mbi, widget))1374 if (!proxy()->styleHint(SH_UnderlineShortcut, mbi, widget)) 1461 1375 alignment |= Qt::TextHideMnemonic; 1462 QPixmap pix = mbi->icon.pixmap(p ixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);1376 QPixmap pix = mbi->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (mbi->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); 1463 1377 if (!pix.isNull()) 1464 drawItemPixmap(p,mbi->rect, alignment, pix);1378 proxy()->drawItemPixmap(p,mbi->rect, alignment, pix); 1465 1379 else 1466 drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled,1380 proxy()->drawItemText(p, mbi->rect, alignment, mbi->palette, mbi->state & State_Enabled, 1467 1381 mbi->text, QPalette::ButtonText); 1468 1382 } … … 1479 1393 QStyleOptionProgressBarV2 subopt = *pb; 1480 1394 subopt.rect = subElementRect(SE_ProgressBarGroove, pb, widget); 1481 drawControl(CE_ProgressBarGroove, &subopt, p, widget);1395 proxy()->drawControl(CE_ProgressBarGroove, &subopt, p, widget); 1482 1396 subopt.rect = subElementRect(SE_ProgressBarContents, pb, widget); 1483 drawControl(CE_ProgressBarContents, &subopt, p, widget);1397 proxy()->drawControl(CE_ProgressBarContents, &subopt, p, widget); 1484 1398 if (pb->textVisible) { 1485 1399 subopt.rect = subElementRect(SE_ProgressBarLabel, pb, widget); 1486 drawControl(CE_ProgressBarLabel, &subopt, p, widget);1400 proxy()->drawControl(CE_ProgressBarLabel, &subopt, p, widget); 1487 1401 } 1488 1402 } … … 1510 1424 QPalette shadowPalette = pb->palette; 1511 1425 shadowPalette.setColor(textRole, shadowColor); 1512 drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette,1426 proxy()->drawItemText(p, shadowRect, Qt::AlignCenter | Qt::TextSingleLine, shadowPalette, 1513 1427 pb->state & State_Enabled, pb->text, textRole); 1514 1428 } 1515 drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette,1429 proxy()->drawItemText(p, pb->rect, Qt::AlignCenter | Qt::TextSingleLine, pb->palette, 1516 1430 pb->state & State_Enabled, pb->text, textRole); 1517 1431 } … … 1560 1474 p->drawLine(x, rect.y(), x, rect.height()); 1561 1475 } else { 1562 const int unit_width = p ixelMetric(PM_ProgressBarChunkWidth, pb, widget);1476 const int unit_width = proxy()->pixelMetric(PM_ProgressBarChunkWidth, pb, widget); 1563 1477 if (!unit_width) 1564 1478 return; … … 1602 1516 pbBits.rect.setRect(x0 + x, myY, unit_width, myHeight); 1603 1517 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); 1604 drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);1518 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); 1605 1519 x += reverse ? -unit_width : unit_width; 1606 1520 } … … 1613 1527 pbBits.rect.setRect(offset, myY, pixels_left, myHeight); 1614 1528 pbBits.rect = m.mapRect(QRectF(pbBits.rect)).toRect(); 1615 drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget);1529 proxy()->drawPrimitive(PE_IndicatorProgressChunk, &pbBits, p, widget); 1616 1530 } 1617 1531 } … … 1624 1538 if (!header->icon.isNull()) { 1625 1539 QPixmap pixmap 1626 = header->icon.pixmap(p ixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled);1540 = header->icon.pixmap(proxy()->pixelMetric(PM_SmallIconSize), (header->state & State_Enabled) ? QIcon::Normal : QIcon::Disabled); 1627 1541 int pixw = pixmap.width(); 1628 1542 … … 1641 1555 p->setFont(fnt); 1642 1556 } 1643 drawItemText(p, rect, header->textAlignment, header->palette,1557 proxy()->drawItemText(p, rect, header->textAlignment, header->palette, 1644 1558 (header->state & State_Enabled), header->text, QPalette::ButtonText); 1645 1559 } … … 1653 1567 int shiftY = 0; 1654 1568 if (toolbutton->state & (State_Sunken | State_On)) { 1655 shiftX = p ixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget);1656 shiftY = p ixelMetric(PM_ButtonShiftVertical, toolbutton, widget);1569 shiftX = proxy()->pixelMetric(PM_ButtonShiftHorizontal, toolbutton, widget); 1570 shiftY = proxy()->pixelMetric(PM_ButtonShiftVertical, toolbutton, widget); 1657 1571 } 1658 1572 // Arrow type always overrules and is always shown … … 1661 1575 || toolbutton->toolButtonStyle == Qt::ToolButtonTextOnly) { 1662 1576 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; 1663 if (! styleHint(SH_UnderlineShortcut, opt, widget))1577 if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) 1664 1578 alignment |= Qt::TextHideMnemonic; 1665 1579 rect.translate(shiftX, shiftY); 1666 drawItemText(p, rect, alignment, toolbutton->palette, 1580 p->setFont(toolbutton->font); 1581 proxy()->drawItemText(p, rect, alignment, toolbutton->palette, 1667 1582 opt->state & State_Enabled, toolbutton->text, 1668 1583 QPalette::ButtonText); … … 1689 1604 tr = rect; 1690 1605 int alignment = Qt::TextShowMnemonic; 1691 if (! styleHint(SH_UnderlineShortcut, opt, widget))1606 if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) 1692 1607 alignment |= Qt::TextHideMnemonic; 1693 1608 1694 1609 if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) { 1695 1610 pr.setHeight(pmSize.height() + 6); 1696 tr.adjust(0, pr.height() , 0, -3);1611 tr.adjust(0, pr.height() - 1, 0, -3); 1697 1612 pr.translate(shiftX, shiftY); 1698 1613 if (!hasArrow) { 1699 drawItemPixmap(p, pr, Qt::AlignCenter, pm);1614 proxy()->drawItemPixmap(p, pr, Qt::AlignCenter, pm); 1700 1615 } else { 1701 1616 drawArrow(this, toolbutton, pr, p, widget); … … 1707 1622 pr.translate(shiftX, shiftY); 1708 1623 if (!hasArrow) { 1709 drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm);1624 proxy()->drawItemPixmap(p, QStyle::visualRect(opt->direction, rect, pr), Qt::AlignCenter, pm); 1710 1625 } else { 1711 1626 drawArrow(this, toolbutton, pr, p, widget); … … 1714 1629 } 1715 1630 tr.translate(shiftX, shiftY); 1716 drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette,1631 proxy()->drawItemText(p, QStyle::visualRect(opt->direction, rect, tr), alignment, toolbutton->palette, 1717 1632 toolbutton->state & State_Enabled, toolbutton->text, 1718 1633 QPalette::ButtonText); … … 1722 1637 drawArrow(this, toolbutton, rect, p, widget); 1723 1638 } else { 1724 drawItemPixmap(p, rect, Qt::AlignCenter, pm);1639 proxy()->drawItemPixmap(p, rect, Qt::AlignCenter, pm); 1725 1640 } 1726 1641 } … … 1732 1647 case CE_ToolBoxTab: 1733 1648 if (const QStyleOptionToolBox *tb = qstyleoption_cast<const QStyleOptionToolBox *>(opt)) { 1734 drawControl(CE_ToolBoxTabShape, tb, p, widget);1735 drawControl(CE_ToolBoxTabLabel, tb, p, widget);1649 proxy()->drawControl(CE_ToolBoxTabShape, tb, p, widget); 1650 proxy()->drawControl(CE_ToolBoxTabLabel, tb, p, widget); 1736 1651 } 1737 1652 break; … … 1779 1694 case CE_TabBarTab: 1780 1695 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 1781 drawControl(CE_TabBarTabShape, tab, p, widget);1782 drawControl(CE_TabBarTabLabel, tab, p, widget);1696 proxy()->drawControl(CE_TabBarTabShape, tab, p, widget); 1697 proxy()->drawControl(CE_TabBarTabLabel, tab, p, widget); 1783 1698 } 1784 1699 break; … … 1790 1705 bool selected = tab->state & State_Selected; 1791 1706 bool onlyOne = tab->position == QStyleOptionTab::OnlyOneTab; 1792 int tabOverlap = onlyOne ? 0 : p ixelMetric(PM_TabBarTabOverlap, opt, widget);1707 int tabOverlap = onlyOne ? 0 : proxy()->pixelMetric(PM_TabBarTabOverlap, opt, widget); 1793 1708 1794 1709 if (!selected) { … … 1894 1809 bool enabled = tb->state & State_Enabled; 1895 1810 bool selected = tb->state & State_Selected; 1896 QPixmap pm = tb->icon.pixmap(p ixelMetric(QStyle::PM_SmallIconSize, tb, widget),1811 QPixmap pm = tb->icon.pixmap(proxy()->pixelMetric(QStyle::PM_SmallIconSize, tb, widget), 1897 1812 enabled ? QIcon::Normal : QIcon::Disabled); 1898 1813 … … 1910 1825 } 1911 1826 1912 if (selected && styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb, widget)) {1827 if (selected && proxy()->styleHint(QStyle::SH_ToolBox_SelectedPageTitleBold, tb, widget)) { 1913 1828 QFont f(p->font()); 1914 1829 f.setBold(true); … … 1922 1837 1923 1838 int alignment = Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic; 1924 if (! styleHint(QStyle::SH_UnderlineShortcut, tb, widget))1839 if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, tb, widget)) 1925 1840 alignment |= Qt::TextHideMnemonic; 1926 drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText);1841 proxy()->drawItemText(p, tr, alignment, tb->palette, enabled, txt, QPalette::ButtonText); 1927 1842 1928 1843 if (!txt.isEmpty() && opt->state & State_HasFocus) { … … 1931 1846 opt.palette = tb->palette; 1932 1847 opt.state = QStyle::State_None; 1933 drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, widget);1848 proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &opt, p, widget); 1934 1849 } 1935 1850 } … … 1937 1852 case CE_TabBarTabLabel: 1938 1853 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 1939 // ### consider merging this with SE_TabBarTabText1940 1854 QStyleOptionTabV3 tabV2(*tab); 1941 1855 QRect tr = tabV2.rect; … … 1946 1860 1947 1861 int alignment = Qt::AlignCenter | Qt::TextShowMnemonic; 1948 if (! styleHint(SH_UnderlineShortcut, opt, widget))1862 if (!proxy()->styleHint(SH_UnderlineShortcut, opt, widget)) 1949 1863 alignment |= Qt::TextHideMnemonic; 1950 1864 … … 1961 1875 newRot = -90; 1962 1876 } 1963 tr.setRect(0, 0, tr.height(), tr.width()); 1964 QTransform m; 1965 m.translate(newX, newY); 1877 QTransform m = QTransform::fromTranslate(newX, newY); 1966 1878 m.rotate(newRot); 1967 1879 p->setTransform(m, true); 1968 1880 } 1969 tr = subElementRect(SE_TabBarTabText, opt, widget); 1881 QRect iconRect; 1882 d->tabLayout(&tabV2, widget, &tr, &iconRect); 1883 tr = proxy()->subElementRect(SE_TabBarTabText, opt, widget); //we compute tr twice because the style may override subElementRect 1970 1884 1971 1885 if (!tabV2.icon.isNull()) { 1972 QSize iconSize = tabV2.iconSize; 1973 if (!iconSize.isValid()) { 1974 int iconExtent = pixelMetric(PM_SmallIconSize); 1975 iconSize = QSize(iconExtent, iconExtent); 1976 } 1977 QSize tabIconSize = tabV2.icon.actualSize(iconSize, 1978 (tabV2.state & State_Enabled) ? QIcon::Normal 1979 : QIcon::Disabled); 1980 QPixmap tabIcon = tabV2.icon.pixmap(iconSize, 1886 QPixmap tabIcon = tabV2.icon.pixmap(tabV2.iconSize, 1981 1887 (tabV2.state & State_Enabled) ? QIcon::Normal 1982 : QIcon::Disabled); 1983 1984 int offset = 4; 1985 int left = opt->rect.left(); 1986 if (tabV2.leftButtonSize.isEmpty()) 1987 offset += 2; 1988 else 1989 left += tabV2.leftButtonSize.width() + (6 + 2) + 2; 1990 QRect iconRect = QRect(left + offset, tr.center().y() - tabIcon.height() / 2, 1991 tabIconSize.width(), tabIconSize.height()); 1992 if (!verticalTabs) 1993 iconRect = visualRect(opt->direction, opt->rect, iconRect); 1888 : QIcon::Disabled, 1889 (tabV2.state & State_Selected) ? QIcon::On 1890 : QIcon::Off); 1994 1891 p->drawPixmap(iconRect.x(), iconRect.y(), tabIcon); 1995 1892 } 1996 1893 1997 drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText);1894 proxy()->drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText); 1998 1895 if (verticalTabs) 1999 1896 p->restore(); … … 2106 2003 QRect r = opt->rect; 2107 2004 QStyleHintReturnMask mask; 2108 if ( styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))2005 if (proxy()->styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask)) 2109 2006 p->setClipRegion(mask.region); 2110 2007 p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap); … … 2144 2041 2145 2042 const int indent = p->fontMetrics().descent(); 2146 drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1),2043 proxy()->drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1), 2147 2044 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, 2148 2045 dwOpt->state & State_Enabled, dwOpt->title, … … 2159 2056 QRegion clipRegion = p->clipRegion(); 2160 2057 p->setClipRect(opt->rect); 2161 drawControl(CE_HeaderSection, header, p, widget);2058 proxy()->drawControl(CE_HeaderSection, header, p, widget); 2162 2059 QStyleOptionHeader subopt = *header; 2163 2060 subopt.rect = subElementRect(SE_HeaderLabel, header, widget); 2164 2061 if (subopt.rect.isValid()) 2165 drawControl(CE_HeaderLabel, &subopt, p, widget);2062 proxy()->drawControl(CE_HeaderLabel, &subopt, p, widget); 2166 2063 if (header->sortIndicator != QStyleOptionHeader::None) { 2167 2064 subopt.rect = subElementRect(SE_HeaderArrow, opt, widget); 2168 drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p, widget);2065 proxy()->drawPrimitive(PE_IndicatorHeaderArrow, &subopt, p, widget); 2169 2066 } 2170 2067 p->setClipRegion(clipRegion); … … 2185 2082 case CE_ComboBoxLabel: 2186 2083 if (const QStyleOptionComboBox *cb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 2187 QRect editRect = subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget);2084 QRect editRect = proxy()->subControlRect(CC_ComboBox, cb, SC_ComboBoxEditField, widget); 2188 2085 p->save(); 2189 2086 p->setClipRect(editRect); … … 2199 2096 if (cb->editable) 2200 2097 p->fillRect(iconRect, opt->palette.brush(QPalette::Base)); 2201 drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);2098 proxy()->drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap); 2202 2099 2203 2100 if (cb->direction == Qt::RightToLeft) … … 2207 2104 } 2208 2105 if (!cb->currentText.isEmpty() && !cb->editable) { 2209 drawItemText(p, editRect.adjusted(1, 0, -1, 0),2106 proxy()->drawItemText(p, editRect.adjusted(1, 0, -1, 0), 2210 2107 visualAlignment(cb->direction, Qt::AlignLeft | Qt::AlignVCenter), 2211 2108 cb->palette, cb->state & State_Enabled, cb->currentText); … … 2223 2120 frame.lineWidth = toolBar->lineWidth; 2224 2121 frame.midLineWidth = toolBar->midLineWidth; 2225 drawPrimitive(PE_PanelToolBar, opt, p, widget);2122 proxy()->drawPrimitive(PE_PanelToolBar, opt, p, widget); 2226 2123 2227 2124 if (widget && qobject_cast<QToolBar *>(widget->parentWidget())) … … 2265 2162 2266 2163 // draw the background 2267 drawPrimitive(PE_PanelItemViewItem, opt, p, widget);2164 proxy()->drawPrimitive(PE_PanelItemViewItem, opt, p, widget); 2268 2165 2269 2166 // draw the check mark 2270 if ( checkRect.isValid()) {2167 if (vopt->features & QStyleOptionViewItemV2::HasCheckIndicator) { 2271 2168 QStyleOptionViewItemV4 option(*vopt); 2272 2169 option.rect = checkRect; … … 2284 2181 break; 2285 2182 } 2286 drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget);2183 proxy()->drawPrimitive(QStyle::PE_IndicatorViewItemCheck, &option, p, widget); 2287 2184 } 2288 2185 … … 2327 2224 o.backgroundColor = vopt->palette.color(cg, (vopt->state & QStyle::State_Selected) 2328 2225 ? QPalette::Highlight : QPalette::Window); 2329 drawPrimitive(QStyle::PE_FrameFocusRect, &o, p, widget);2226 proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &o, p, widget); 2330 2227 } 2331 2228 … … 2366 2263 widget->style()->drawPrimitive(QStyle::PE_Frame, opt, p, widget); 2367 2264 } else { 2368 drawPrimitive(QStyle::PE_Frame, opt, p, widget);2265 proxy()->drawPrimitive(QStyle::PE_Frame, opt, p, widget); 2369 2266 } 2370 2267 break; … … 2424 2321 if (const QStyleOptionButton *btn = qstyleoption_cast<const QStyleOptionButton *>(opt)) { 2425 2322 int dx1, dx2; 2426 dx1 = p ixelMetric(PM_DefaultFrameWidth, btn, widget);2323 dx1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget); 2427 2324 if (btn->features & QStyleOptionButton::AutoDefaultButton) 2428 dx1 += p ixelMetric(PM_ButtonDefaultIndicator, btn, widget);2325 dx1 += proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 2429 2326 dx2 = dx1 * 2; 2430 2327 r.setRect(opt->rect.x() + dx1, opt->rect.y() + dx1, opt->rect.width() - dx2, … … 2437 2334 int dbw1 = 0, dbw2 = 0; 2438 2335 if (btn->features & QStyleOptionButton::AutoDefaultButton){ 2439 dbw1 = p ixelMetric(PM_ButtonDefaultIndicator, btn, widget);2336 dbw1 = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget); 2440 2337 dbw2 = dbw1 * 2; 2441 2338 } 2442 2339 2443 int dfw1 = p ixelMetric(PM_DefaultFrameWidth, btn, widget) + 1,2340 int dfw1 = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) + 1, 2444 2341 dfw2 = dfw1 * 2; 2445 2342 … … 2451 2348 case SE_CheckBoxIndicator: 2452 2349 { 2453 int h = p ixelMetric(PM_IndicatorHeight, opt, widget);2350 int h = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); 2454 2351 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), 2455 p ixelMetric(PM_IndicatorWidth, opt, widget), h);2352 proxy()->pixelMetric(PM_IndicatorWidth, opt, widget), h); 2456 2353 r = visualRect(opt->direction, opt->rect, r); 2457 2354 } … … 2463 2360 QRect ir = visualRect(opt->direction, opt->rect, 2464 2361 subElementRect(SE_CheckBoxIndicator, opt, widget)); 2465 int spacing = p ixelMetric(PM_CheckBoxLabelSpacing, opt, widget);2362 int spacing = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget); 2466 2363 r.setRect(ir.right() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, 2467 2364 opt->rect.height()); … … 2503 2400 case SE_RadioButtonIndicator: 2504 2401 { 2505 int h = p ixelMetric(PM_ExclusiveIndicatorHeight, opt, widget);2402 int h = proxy()->pixelMetric(PM_ExclusiveIndicatorHeight, opt, widget); 2506 2403 r.setRect(opt->rect.x(), opt->rect.y() + ((opt->rect.height() - h) / 2), 2507 p ixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h);2404 proxy()->pixelMetric(PM_ExclusiveIndicatorWidth, opt, widget), h); 2508 2405 r = visualRect(opt->direction, opt->rect, r); 2509 2406 } … … 2514 2411 QRect ir = visualRect(opt->direction, opt->rect, 2515 2412 subElementRect(SE_RadioButtonIndicator, opt, widget)); 2516 int spacing = p ixelMetric(PM_RadioButtonLabelSpacing, opt, widget);2413 int spacing = proxy()->pixelMetric(PM_RadioButtonLabelSpacing, opt, widget); 2517 2414 r.setRect(ir.left() + ir.width() + spacing, opt->rect.y(), opt->rect.width() - ir.width() - spacing, 2518 2415 opt->rect.height()); … … 2551 2448 case SE_SliderFocusRect: 2552 2449 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 2553 int tickOffset = p ixelMetric(PM_SliderTickmarkOffset, slider, widget);2554 int thickness = p ixelMetric(PM_SliderControlThickness, slider, widget);2450 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); 2451 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); 2555 2452 if (slider->orientation == Qt::Horizontal) 2556 2453 r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2); … … 2623 2520 #endif // QT_NO_TOOLBOX 2624 2521 case SE_HeaderLabel: { 2625 int margin = p ixelMetric(QStyle::PM_HeaderMargin, opt, widget);2522 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); 2626 2523 r.setRect(opt->rect.x() + margin, opt->rect.y() + margin, 2627 2524 opt->rect.width() - margin * 2, opt->rect.height() - margin * 2); … … 2643 2540 int x = opt->rect.x(); 2644 2541 int y = opt->rect.y(); 2645 int margin = p ixelMetric(QStyle::PM_HeaderMargin, opt, widget);2542 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, widget); 2646 2543 2647 2544 if (opt->state & State_Horizontal) { … … 2679 2576 - twf->leftCornerWidgetSize.width() 2680 2577 - twf->rightCornerWidgetSize.width())); 2681 switch ( styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {2578 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { 2682 2579 default: 2683 2580 case Qt::AlignLeft: … … 2701 2598 - twf->leftCornerWidgetSize.width() 2702 2599 - twf->rightCornerWidgetSize.width())); 2703 switch ( styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {2600 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { 2704 2601 default: 2705 2602 case Qt::AlignLeft: … … 2726 2623 - twf->leftCornerWidgetSize.height() 2727 2624 - twf->rightCornerWidgetSize.height())); 2728 switch ( styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {2625 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { 2729 2626 default: 2730 2627 case Qt::AlignLeft: … … 2748 2645 - twf->leftCornerWidgetSize.height() 2749 2646 - twf->rightCornerWidgetSize.height())); 2750 switch ( styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) {2647 switch (proxy()->styleHint(SH_TabBar_Alignment, twf, widget) & alingMask) { 2751 2648 default: 2752 2649 case Qt::AlignLeft: … … 2770 2667 QStyleOptionTab tabopt; 2771 2668 tabopt.shape = twf->shape; 2772 int overlap = p ixelMetric(PM_TabBarBaseOverlap, &tabopt, widget);2669 int overlap = proxy()->pixelMetric(PM_TabBarBaseOverlap, &tabopt, widget); 2773 2670 if (twf->lineWidth == 0) 2774 2671 overlap = 0; … … 2838 2735 break; 2839 2736 case SE_TabBarTabText: 2840 // ### consider merging this with CE_TabBarTabLabel2841 2737 if (const QStyleOptionTab *tab = qstyleoption_cast<const QStyleOptionTab *>(opt)) { 2842 QStyleOptionTabV3 tabV2(*tab); 2843 QRect tr = tabV2.rect; 2844 bool verticalTabs = tabV2.shape == QTabBar::RoundedEast 2845 || tabV2.shape == QTabBar::RoundedWest 2846 || tabV2.shape == QTabBar::TriangularEast 2847 || tabV2.shape == QTabBar::TriangularWest; 2848 if (verticalTabs) 2849 tr.setRect(0, 0, tr.height(), tr.width()); 2850 int verticalShift = pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); 2851 int horizontalShift = pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); 2852 if (tabV2.shape == QTabBar::RoundedSouth || tabV2.shape == QTabBar::TriangularSouth) 2853 verticalShift = -verticalShift; 2854 tr.adjust(0, 0, horizontalShift, verticalShift); 2855 bool selected = tabV2.state & State_Selected; 2856 if (selected) { 2857 tr.setBottom(tr.bottom() - verticalShift); 2858 tr.setRight(tr.right() - horizontalShift); 2859 } 2860 2861 // left widget 2862 if (!tabV2.leftButtonSize.isEmpty()) { 2863 tr.setLeft(tr.left() + 6 + 2 + 2864 (verticalTabs ? tabV2.leftButtonSize.height() : tabV2.leftButtonSize.width())); 2865 } 2866 2867 // icon 2868 if (!tabV2.icon.isNull()) { 2869 QSize iconSize = tabV2.iconSize; 2870 if (!iconSize.isValid()) { 2871 int iconExtent = pixelMetric(PM_SmallIconSize); 2872 iconSize = QSize(iconExtent, iconExtent); 2873 } 2874 QSize tabIconSize = tabV2.icon.actualSize(iconSize, 2875 (tabV2.state & State_Enabled) ? QIcon::Normal 2876 : QIcon::Disabled); 2877 int offset = 4; 2878 if (tabV2.leftButtonSize.isEmpty()) 2879 offset += 2; 2880 2881 QRect iconRect = QRect(tr.left() + offset, tr.center().y() - tabIconSize.height() / 2, 2882 tabIconSize.width(), tabIconSize .height()); 2883 if (!verticalTabs) 2884 iconRect = visualRect(opt->direction, opt->rect, iconRect); 2885 tr.setLeft(tr.left() + tabIconSize.width() + offset + 2); 2886 } 2887 2888 // right widget 2889 if (!tabV2.rightButtonSize.isEmpty()) { 2890 tr.setRight(tr.right() - 6 - 2 - 2891 (verticalTabs ? tabV2.rightButtonSize.height() : tabV2.rightButtonSize.width())); 2892 } 2893 2894 if (!verticalTabs) 2895 tr = visualRect(opt->direction, opt->rect, tr); 2896 r = tr; 2738 QStyleOptionTabV3 tabV3(*tab); 2739 QRect dummyIconRect; 2740 d->tabLayout(&tabV3, widget, &r, &dummyIconRect); 2897 2741 } 2898 2742 break; … … 2901 2745 if (const QStyleOptionTabV3 *tab = qstyleoption_cast<const QStyleOptionTabV3 *>(opt)) { 2902 2746 bool selected = tab->state & State_Selected; 2903 int verticalShift = pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); 2904 int horizontalShift = pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); 2747 int verticalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftVertical, tab, widget); 2748 int horizontalShift = proxy()->pixelMetric(QStyle::PM_TabBarTabShiftHorizontal, tab, widget); 2749 int hpadding = proxy()->pixelMetric(QStyle::PM_TabBarTabHSpace, opt, widget) / 2; 2750 hpadding = qMax(hpadding, 4); //workaround KStyle returning 0 because they workaround an old bug in Qt 2905 2751 2906 2752 bool verticalTabs = tab->shape == QTabBar::RoundedEast … … 2917 2763 verticalShift *= -1; 2918 2764 } 2765 if (tab->shape == QTabBar::RoundedWest || tab->shape == QTabBar::TriangularWest) 2766 horizontalShift = -horizontalShift; 2767 2919 2768 tr.adjust(0, 0, horizontalShift, verticalShift); 2920 2769 if (selected) … … 2927 2776 int w = size.width(); 2928 2777 int h = size.height(); 2929 int midHeight = static_cast<int>( ceil(float(tr.height() - h) / 2));2778 int midHeight = static_cast<int>(qCeil(float(tr.height() - h) / 2)); 2930 2779 int midWidth = ((tr.width() - w) / 2); 2931 2780 … … 2942 2791 default: 2943 2792 if (sr == SE_TabBarTabLeftButton) 2944 r = QRect( 6 + tab->rect.x(), midHeight, w, h);2793 r = QRect(tab->rect.x() + hpadding, midHeight, w, h); 2945 2794 else 2946 r = QRect(tab->rect.right() - 6 - w, midHeight, w, h);2795 r = QRect(tab->rect.right() - w - hpadding, midHeight, w, h); 2947 2796 r = visualRect(tab->direction, tab->rect, r); 2948 2797 } 2949 2798 if (verticalTabs) { 2950 2799 if (atTheTop) 2951 r = QRect(midWidth, tr.y() + tab->rect.height() - 6- h, w, h);2800 r = QRect(midWidth, tr.y() + tab->rect.height() - hpadding - h, w, h); 2952 2801 else 2953 r = QRect(midWidth, tr.y() + 6, w, h);2802 r = QRect(midWidth, tr.y() + hpadding, w, h); 2954 2803 } 2955 2804 } … … 2991 2840 case SE_FrameContents: 2992 2841 if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) { 2993 int fw = p ixelMetric(PM_DefaultFrameWidth, f, widget);2842 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, f, widget); 2994 2843 r = opt->rect.adjusted(fw, fw, -fw, -fw); 2995 2844 r = visualRect(opt->direction, opt->rect, r); … … 3058 2907 case SE_DockWidgetTitleBarText: 3059 2908 case SE_DockWidgetIcon: { 3060 int iconSize = p ixelMetric(PM_SmallIconSize, opt, widget);3061 int buttonMargin = p ixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget);3062 int margin = p ixelMetric(QStyle::PM_DockWidgetTitleMargin, opt, widget);2909 int iconSize = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); 2910 int buttonMargin = proxy()->pixelMetric(PM_DockWidgetTitleBarButtonMargin, opt, widget); 2911 int margin = proxy()->pixelMetric(QStyle::PM_DockWidgetTitleMargin, opt, widget); 3063 2912 QRect rect = opt->rect; 3064 2913 … … 3125 2974 icon = dw->windowIcon(); 3126 2975 if (!icon.isNull() 3127 && icon.cacheKey() != qApp->windowIcon().cacheKey()) {2976 && icon.cacheKey() != QApplication::windowIcon().cacheKey()) { 3128 2977 QSize sz = icon.actualSize(QSize(r.height(), r.height())); 3129 2978 if (verticalTitleBar) … … 3170 3019 if (!d->isViewItemCached(*vopt)) { 3171 3020 d->viewItemLayout(vopt, &d->checkRect, &d->decorationRect, &d->displayRect, false); 3172 if (d->cachedOption) 3021 if (d->cachedOption) { 3173 3022 delete d->cachedOption; 3023 d->cachedOption = 0; 3024 } 3174 3025 d->cachedOption = new QStyleOptionViewItemV4(*vopt); 3175 3026 } … … 3183 3034 break; 3184 3035 #endif //QT_NO_ITEMVIEWS 3036 #ifndef QT_NO_TOOLBAR 3037 case SE_ToolBarHandle: 3038 if (const QStyleOptionToolBar *tbopt = qstyleoption_cast<const QStyleOptionToolBar *>(opt)) { 3039 if (tbopt->features & QStyleOptionToolBar::Movable) { 3040 ///we need to access the widget here because the style option doesn't 3041 //have all the information we need (ie. the layout's margin) 3042 const QToolBar *tb = qobject_cast<const QToolBar*>(widget); 3043 const int margin = tb && tb->layout() ? tb->layout()->margin() : 2; 3044 const int handleExtent = pixelMetric(QStyle::PM_ToolBarHandleExtent, opt, tb); 3045 if (tbopt->state & QStyle::State_Horizontal) { 3046 r = QRect(margin, margin, handleExtent, tbopt->rect.height() - 2*margin); 3047 r = QStyle::visualRect(tbopt->direction, tbopt->rect, r); 3048 } else { 3049 r = QRect(margin, margin, tbopt->rect.width() - 2*margin, handleExtent); 3050 } 3051 } 3052 } 3053 break; 3054 #endif //QT_NO_TOOLBAR 3185 3055 default: 3186 3056 break; … … 3190 3060 3191 3061 #ifndef QT_NO_DIAL 3192 static qreal angle(const QPointF &p1, const QPointF &p2)3193 {3194 static const qreal rad_factor = 180 / Q_PI;3195 qreal _angle = 0;3196 3197 if (p1.x() == p2.x()) {3198 if (p1.y() < p2.y())3199 _angle = 270;3200 else3201 _angle = 90;3202 } else {3203 qreal x1, x2, y1, y2;3204 3205 if (p1.x() <= p2.x()) {3206 x1 = p1.x(); y1 = p1.y();3207 x2 = p2.x(); y2 = p2.y();3208 } else {3209 x2 = p1.x(); y2 = p1.y();3210 x1 = p2.x(); y1 = p2.y();3211 }3212 3213 qreal m = -(y2 - y1) / (x2 - x1);3214 _angle = atan(m) * rad_factor;3215 3216 if (p1.x() < p2.x())3217 _angle = 180 - _angle;3218 else3219 _angle = -_angle;3220 }3221 return _angle;3222 }3223 3224 static int calcBigLineSize(int radius)3225 {3226 int bigLineSize = radius / 6;3227 if (bigLineSize < 4)3228 bigLineSize = 4;3229 if (bigLineSize > radius / 2)3230 bigLineSize = radius / 2;3231 return bigLineSize;3232 }3233 3062 3234 3063 static QPolygonF calcArrow(const QStyleOptionSlider *dial, qreal &a) … … 3251 3080 int yc = height / 2; 3252 3081 3253 int len = r - calcBigLineSize(r) - 5;3082 int len = r - QStyleHelper::calcBigLineSize(r) - 5; 3254 3083 if (len < 5) 3255 3084 len = 5; … … 3266 3095 } 3267 3096 3268 static QPolygonF calcLines(const QStyleOptionSlider *dial, const QWidget *)3269 {3270 QPolygonF poly;3271 int width = dial->rect.width();3272 int height = dial->rect.height();3273 qreal r = qMin(width, height) / 2;3274 int bigLineSize = calcBigLineSize(int(r));3275 3276 qreal xc = width / 2;3277 qreal yc = height / 2;3278 int ns = dial->tickInterval;3279 int notches = (dial->maximum + ns - 1 - dial->minimum) / ns;3280 if (notches <= 0)3281 return poly;3282 if (dial->maximum < dial->minimum3283 || dial->maximum - dial->minimum > 1000) {3284 int maximum = dial->minimum + 1000;3285 notches = (maximum + ns - 1 - dial->minimum) / ns;3286 }3287 3288 poly.resize(2 + 2 * notches);3289 int smallLineSize = bigLineSize / 2;3290 for (int i = 0; i <= notches; ++i) {3291 qreal angle = dial->dialWrapping ? Q_PI * 3 / 2 - i * 2 * Q_PI / notches3292 : (Q_PI * 8 - i * 10 * Q_PI / notches) / 6;3293 qreal s = qSin(angle);3294 qreal c = qCos(angle);3295 if (i == 0 || (((ns * i) % (dial->pageStep ? dial->pageStep : 1)) == 0)) {3296 poly[2 * i] = QPointF(xc + (r - bigLineSize) * c,3297 yc - (r - bigLineSize) * s);3298 poly[2 * i + 1] = QPointF(xc + r * c, yc - r * s);3299 } else {3300 poly[2 * i] = QPointF(xc + (r - 1 - smallLineSize) * c,3301 yc - (r - 1 - smallLineSize) * s);3302 poly[2 * i + 1] = QPointF(xc + (r - 1) * c, yc -(r - 1) * s);3303 }3304 }3305 return poly;3306 }3307 3097 #endif // QT_NO_DIAL 3308 3098 … … 3318 3108 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 3319 3109 if (slider->subControls == SC_SliderTickmarks) { 3320 int tickOffset = p ixelMetric(PM_SliderTickmarkOffset, slider, widget);3110 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); 3321 3111 int ticks = slider->tickPosition; 3322 int thickness = p ixelMetric(PM_SliderControlThickness, slider, widget);3323 int len = p ixelMetric(PM_SliderLength, slider, widget);3324 int available = p ixelMetric(PM_SliderSpaceAvailable, slider, widget);3112 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); 3113 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 3114 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); 3325 3115 int interval = slider->tickInterval; 3326 3116 if (interval <= 0) { … … 3380 3170 if (scrollbar->subControls & SC_ScrollBarSubLine) { 3381 3171 newScrollbar.state = saveFlags; 3382 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget);3172 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubLine, widget); 3383 3173 if (newScrollbar.rect.isValid()) { 3384 3174 if (!(scrollbar->activeSubControls & SC_ScrollBarSubLine)) 3385 3175 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3386 drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget);3176 proxy()->drawControl(CE_ScrollBarSubLine, &newScrollbar, p, widget); 3387 3177 } 3388 3178 } … … 3390 3180 newScrollbar.rect = scrollbar->rect; 3391 3181 newScrollbar.state = saveFlags; 3392 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget);3182 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddLine, widget); 3393 3183 if (newScrollbar.rect.isValid()) { 3394 3184 if (!(scrollbar->activeSubControls & SC_ScrollBarAddLine)) 3395 3185 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3396 drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget);3186 proxy()->drawControl(CE_ScrollBarAddLine, &newScrollbar, p, widget); 3397 3187 } 3398 3188 } … … 3400 3190 newScrollbar.rect = scrollbar->rect; 3401 3191 newScrollbar.state = saveFlags; 3402 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget);3192 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSubPage, widget); 3403 3193 if (newScrollbar.rect.isValid()) { 3404 3194 if (!(scrollbar->activeSubControls & SC_ScrollBarSubPage)) 3405 3195 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3406 drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget);3196 proxy()->drawControl(CE_ScrollBarSubPage, &newScrollbar, p, widget); 3407 3197 } 3408 3198 } … … 3410 3200 newScrollbar.rect = scrollbar->rect; 3411 3201 newScrollbar.state = saveFlags; 3412 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget);3202 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarAddPage, widget); 3413 3203 if (newScrollbar.rect.isValid()) { 3414 3204 if (!(scrollbar->activeSubControls & SC_ScrollBarAddPage)) 3415 3205 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3416 drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget);3206 proxy()->drawControl(CE_ScrollBarAddPage, &newScrollbar, p, widget); 3417 3207 } 3418 3208 } … … 3420 3210 newScrollbar.rect = scrollbar->rect; 3421 3211 newScrollbar.state = saveFlags; 3422 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget);3212 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarFirst, widget); 3423 3213 if (newScrollbar.rect.isValid()) { 3424 3214 if (!(scrollbar->activeSubControls & SC_ScrollBarFirst)) 3425 3215 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3426 drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget);3216 proxy()->drawControl(CE_ScrollBarFirst, &newScrollbar, p, widget); 3427 3217 } 3428 3218 } … … 3430 3220 newScrollbar.rect = scrollbar->rect; 3431 3221 newScrollbar.state = saveFlags; 3432 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget);3222 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarLast, widget); 3433 3223 if (newScrollbar.rect.isValid()) { 3434 3224 if (!(scrollbar->activeSubControls & SC_ScrollBarLast)) 3435 3225 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3436 drawControl(CE_ScrollBarLast, &newScrollbar, p, widget);3226 proxy()->drawControl(CE_ScrollBarLast, &newScrollbar, p, widget); 3437 3227 } 3438 3228 } … … 3440 3230 newScrollbar.rect = scrollbar->rect; 3441 3231 newScrollbar.state = saveFlags; 3442 newScrollbar.rect = subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget);3232 newScrollbar.rect = proxy()->subControlRect(cc, &newScrollbar, SC_ScrollBarSlider, widget); 3443 3233 if (newScrollbar.rect.isValid()) { 3444 3234 if (!(scrollbar->activeSubControls & SC_ScrollBarSlider)) 3445 3235 newScrollbar.state &= ~(State_Sunken | State_MouseOver); 3446 drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget);3236 proxy()->drawControl(CE_ScrollBarSlider, &newScrollbar, p, widget); 3447 3237 3448 3238 if (scrollbar->state & State_HasFocus) { … … 3452 3242 newScrollbar.rect.width() - 5, 3453 3243 newScrollbar.rect.height() - 5); 3454 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);3244 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 3455 3245 } 3456 3246 } … … 3474 3264 3475 3265 if (sb->frame && (sb->subControls & SC_SpinBoxFrame)) { 3476 QRect r = subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget);3266 QRect r = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxFrame, widget); 3477 3267 qDrawWinPanel(p, r, sb->palette, true); 3478 3268 } … … 3498 3288 : PE_IndicatorSpinUp); 3499 3289 3500 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget);3501 drawPrimitive(PE_PanelButtonBevel, ©, p, widget);3290 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxUp, widget); 3291 proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p, widget); 3502 3292 copy.rect.adjust(3, 0, -4, 0); 3503 drawPrimitive(pe, ©, p, widget);3293 proxy()->drawPrimitive(pe, ©, p, widget); 3504 3294 } 3505 3295 … … 3524 3314 : PE_IndicatorSpinDown); 3525 3315 3526 copy.rect = subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget);3527 drawPrimitive(PE_PanelButtonBevel, ©, p, widget);3316 copy.rect = proxy()->subControlRect(CC_SpinBox, sb, SC_SpinBoxDown, widget); 3317 proxy()->drawPrimitive(PE_PanelButtonBevel, ©, p, widget); 3528 3318 copy.rect.adjust(3, 0, -4, 0); 3529 drawPrimitive(pe, ©, p, widget);3319 proxy()->drawPrimitive(pe, ©, p, widget); 3530 3320 } 3531 3321 } … … 3537 3327 = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { 3538 3328 QRect button, menuarea; 3539 button = subControlRect(cc, toolbutton, SC_ToolButton, widget);3540 menuarea = subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget);3329 button = proxy()->subControlRect(cc, toolbutton, SC_ToolButton, widget); 3330 menuarea = proxy()->subControlRect(cc, toolbutton, SC_ToolButtonMenu, widget); 3541 3331 3542 3332 State bflags = toolbutton->state & ~State_Sunken; … … 3560 3350 tool.rect = button; 3561 3351 tool.state = bflags; 3562 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3352 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3563 3353 } 3564 3354 } … … 3569 3359 fr.rect.adjust(3, 3, -3, -3); 3570 3360 if (toolbutton->features & QStyleOptionToolButton::MenuButtonPopup) 3571 fr.rect.adjust(0, 0, -p ixelMetric(QStyle::PM_MenuButtonIndicator,3361 fr.rect.adjust(0, 0, -proxy()->pixelMetric(QStyle::PM_MenuButtonIndicator, 3572 3362 toolbutton, widget), 0); 3573 drawPrimitive(PE_FrameFocusRect, &fr, p, widget);3363 proxy()->drawPrimitive(PE_FrameFocusRect, &fr, p, widget); 3574 3364 } 3575 3365 QStyleOptionToolButton label = *toolbutton; 3576 3366 label.state = bflags; 3577 int fw = p ixelMetric(PM_DefaultFrameWidth, opt, widget);3367 int fw = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); 3578 3368 label.rect = button.adjusted(fw, fw, -fw, -fw); 3579 drawControl(CE_ToolButtonLabel, &label, p, widget);3369 proxy()->drawControl(CE_ToolButtonLabel, &label, p, widget); 3580 3370 3581 3371 if (toolbutton->subControls & SC_ToolButtonMenu) { … … 3583 3373 tool.state = mflags; 3584 3374 if (mflags & (State_Sunken | State_On | State_Raised)) 3585 drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget);3586 drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget);3375 proxy()->drawPrimitive(PE_IndicatorButtonDropDown, &tool, p, widget); 3376 proxy()->drawPrimitive(PE_IndicatorArrowDown, &tool, p, widget); 3587 3377 } else if (toolbutton->features & QStyleOptionToolButton::HasMenu) { 3588 int mbi = p ixelMetric(PM_MenuButtonIndicator, toolbutton, widget);3378 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, toolbutton, widget); 3589 3379 QRect ir = toolbutton->rect; 3590 3380 QStyleOptionToolButton newBtn = *toolbutton; 3591 3381 newBtn.rect = QRect(ir.right() + 5 - mbi, ir.y() + ir.height() - mbi + 4, mbi - 6, mbi - 6); 3592 drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget);3382 proxy()->drawPrimitive(PE_IndicatorArrowDown, &newBtn, p, widget); 3593 3383 } 3594 3384 } … … 3614 3404 p->fillRect(opt->rect, fillBrush); 3615 3405 3616 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget);3406 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarLabel, widget); 3617 3407 3618 3408 p->setPen(tb->palette.highlightedText().color()); … … 3627 3417 tool.palette = tb->palette; 3628 3418 if (tb->subControls & SC_TitleBarCloseButton && tb->titleBarFlags & Qt::WindowSystemMenuHint) { 3629 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, widget);3419 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarCloseButton, widget); 3630 3420 down = tb->activeSubControls & SC_TitleBarCloseButton && (opt->state & State_Sunken); 3631 3421 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool … … 3639 3429 tool.rect = ir; 3640 3430 tool.state = down ? State_Sunken : State_Raised; 3641 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3431 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3642 3432 3643 3433 p->save(); 3644 3434 if (down) 3645 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3646 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3647 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3435 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3436 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3437 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3648 3438 p->restore(); 3649 3439 } … … 3652 3442 && tb->titleBarFlags & Qt::WindowMaximizeButtonHint 3653 3443 && !(tb->titleBarState & Qt::WindowMaximized)) { 3654 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget);3444 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMaxButton, widget); 3655 3445 3656 3446 down = tb->activeSubControls & SC_TitleBarMaxButton && (opt->state & State_Sunken); … … 3658 3448 tool.rect = ir; 3659 3449 tool.state = down ? State_Sunken : State_Raised; 3660 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3450 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3661 3451 3662 3452 p->save(); 3663 3453 if (down) 3664 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3665 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3666 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3454 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3455 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3456 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3667 3457 p->restore(); 3668 3458 } … … 3671 3461 && tb->titleBarFlags & Qt::WindowMinimizeButtonHint 3672 3462 && !(tb->titleBarState & Qt::WindowMinimized)) { 3673 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget);3463 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarMinButton, widget); 3674 3464 down = tb->activeSubControls & SC_TitleBarMinButton && (opt->state & State_Sunken); 3675 3465 pm = standardIcon(SP_TitleBarMinButton, &tool, widget).pixmap(10, 10); 3676 3466 tool.rect = ir; 3677 3467 tool.state = down ? State_Sunken : State_Raised; 3678 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3468 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3679 3469 3680 3470 p->save(); 3681 3471 if (down) 3682 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3683 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3684 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3472 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3473 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3474 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3685 3475 p->restore(); 3686 3476 } … … 3693 3483 3694 3484 if (drawNormalButton) { 3695 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget);3485 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarNormalButton, widget); 3696 3486 down = tb->activeSubControls & SC_TitleBarNormalButton && (opt->state & State_Sunken); 3697 3487 pm = standardIcon(SP_TitleBarNormalButton, &tool, widget).pixmap(10, 10); 3698 3488 tool.rect = ir; 3699 3489 tool.state = down ? State_Sunken : State_Raised; 3700 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3490 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3701 3491 3702 3492 p->save(); 3703 3493 if (down) 3704 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3705 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3706 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3494 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3495 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3496 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3707 3497 p->restore(); 3708 3498 } … … 3711 3501 && tb->titleBarFlags & Qt::WindowShadeButtonHint 3712 3502 && !(tb->titleBarState & Qt::WindowMinimized)) { 3713 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget);3503 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarShadeButton, widget); 3714 3504 down = (tb->activeSubControls & SC_TitleBarShadeButton && (opt->state & State_Sunken)); 3715 3505 pm = standardIcon(SP_TitleBarShadeButton, &tool, widget).pixmap(10, 10); 3716 3506 tool.rect = ir; 3717 3507 tool.state = down ? State_Sunken : State_Raised; 3718 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3508 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3719 3509 p->save(); 3720 3510 if (down) 3721 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3722 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3723 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3511 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3512 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3513 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3724 3514 p->restore(); 3725 3515 } … … 3728 3518 && tb->titleBarFlags & Qt::WindowShadeButtonHint 3729 3519 && tb->titleBarState & Qt::WindowMinimized) { 3730 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget);3520 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarUnshadeButton, widget); 3731 3521 3732 3522 down = tb->activeSubControls & SC_TitleBarUnshadeButton && (opt->state & State_Sunken); … … 3734 3524 tool.rect = ir; 3735 3525 tool.state = down ? State_Sunken : State_Raised; 3736 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3526 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3737 3527 p->save(); 3738 3528 if (down) 3739 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3740 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3741 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3529 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3530 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3531 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3742 3532 p->restore(); 3743 3533 } 3744 3534 if (tb->subControls & SC_TitleBarContextHelpButton 3745 3535 && tb->titleBarFlags & Qt::WindowContextHelpButtonHint) { 3746 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget);3536 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarContextHelpButton, widget); 3747 3537 3748 3538 down = tb->activeSubControls & SC_TitleBarContextHelpButton && (opt->state & State_Sunken); … … 3750 3540 tool.rect = ir; 3751 3541 tool.state = down ? State_Sunken : State_Raised; 3752 drawPrimitive(PE_PanelButtonTool, &tool, p, widget);3542 proxy()->drawPrimitive(PE_PanelButtonTool, &tool, p, widget); 3753 3543 p->save(); 3754 3544 if (down) 3755 p->translate(p ixelMetric(PM_ButtonShiftHorizontal, tb, widget),3756 p ixelMetric(PM_ButtonShiftVertical, tb, widget));3757 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3545 p->translate(proxy()->pixelMetric(PM_ButtonShiftHorizontal, tb, widget), 3546 proxy()->pixelMetric(PM_ButtonShiftVertical, tb, widget)); 3547 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3758 3548 p->restore(); 3759 3549 } 3760 3550 if (tb->subControls & SC_TitleBarSysMenu && tb->titleBarFlags & Qt::WindowSystemMenuHint) { 3761 ir = subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu, widget);3551 ir = proxy()->subControlRect(CC_TitleBar, tb, SC_TitleBarSysMenu, widget); 3762 3552 if (!tb->icon.isNull()) { 3763 3553 tb->icon.paint(p, ir); 3764 3554 } else { 3765 int iconSize = p ixelMetric(PM_SmallIconSize, tb, widget);3555 int iconSize = proxy()->pixelMetric(PM_SmallIconSize, tb, widget); 3766 3556 pm = standardIcon(SP_TitleBarMenuButton, &tool, widget).pixmap(iconSize, iconSize); 3767 3557 tool.rect = ir; 3768 3558 p->save(); 3769 drawItemPixmap(p, ir, Qt::AlignCenter, pm);3559 proxy()->drawItemPixmap(p, ir, Qt::AlignCenter, pm); 3770 3560 p->restore(); 3771 3561 } … … 3795 3585 if (dial->subControls & QStyle::SC_DialTickmarks) { 3796 3586 p->setPen(pal.foreground().color()); 3797 p->drawLines( calcLines(dial, widget)); // ### calcLines could be cached...3587 p->drawLines(QStyleHelper::calcLines(dial)); 3798 3588 } 3799 3589 3800 3590 if (dial->state & State_Enabled) { 3801 p->setBrush(pal.brush(QPalette::ColorRole( styleHint(SH_Dial_BackgroundRole,3591 p->setBrush(pal.brush(QPalette::ColorRole(proxy()->styleHint(SH_Dial_BackgroundRole, 3802 3592 dial, widget)))); 3803 3593 p->setPen(Qt::NoPen); … … 3817 3607 p->drawPolygon(arrow); 3818 3608 3819 a = angle(QPointF(width / 2, height / 2), arrow[0]);3609 a = QStyleHelper::angle(QPointF(width / 2, height / 2), arrow[0]); 3820 3610 p->setBrush(Qt::NoBrush); 3821 3611 … … 3860 3650 } 3861 3651 fropt.rect = br.adjusted(-2, -2, 2, 2); 3862 drawPrimitive(QStyle::PE_FrameFocusRect, &fropt, p, widget);3652 proxy()->drawPrimitive(QStyle::PE_FrameFocusRect, &fropt, p, widget); 3863 3653 } 3864 3654 p->restore(); … … 3870 3660 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) { 3871 3661 // Draw frame 3872 QRect textRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget);3873 QRect checkBoxRect = subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget);3662 QRect textRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxLabel, widget); 3663 QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxCheckBox, widget); 3874 3664 if (groupBox->subControls & QStyle::SC_GroupBoxFrame) { 3875 3665 QStyleOptionFrameV2 frame; … … 3878 3668 frame.lineWidth = groupBox->lineWidth; 3879 3669 frame.midLineWidth = groupBox->midLineWidth; 3880 frame.rect = subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget);3670 frame.rect = proxy()->subControlRect(CC_GroupBox, opt, SC_GroupBoxFrame, widget); 3881 3671 p->save(); 3882 3672 QRegion region(groupBox->rect); … … 3893 3683 } 3894 3684 p->setClipRegion(region); 3895 drawPrimitive(PE_FrameGroupBox, &frame, p, widget);3685 proxy()->drawPrimitive(PE_FrameGroupBox, &frame, p, widget); 3896 3686 p->restore(); 3897 3687 } … … 3903 3693 p->setPen(textColor); 3904 3694 int alignment = int(groupBox->textAlignment); 3905 if (! styleHint(QStyle::SH_UnderlineShortcut, opt, widget))3695 if (!proxy()->styleHint(QStyle::SH_UnderlineShortcut, opt, widget)) 3906 3696 alignment |= Qt::TextHideMnemonic; 3907 3697 3908 drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,3698 proxy()->drawItemText(p, textRect, Qt::TextShowMnemonic | Qt::AlignHCenter | alignment, 3909 3699 groupBox->palette, groupBox->state & State_Enabled, groupBox->text, 3910 3700 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText); … … 3914 3704 fropt.QStyleOption::operator=(*groupBox); 3915 3705 fropt.rect = textRect; 3916 drawPrimitive(PE_FrameFocusRect, &fropt, p, widget);3706 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, p, widget); 3917 3707 } 3918 3708 } … … 3923 3713 box.QStyleOption::operator=(*groupBox); 3924 3714 box.rect = checkBoxRect; 3925 drawPrimitive(PE_IndicatorCheckBox, &box, p, widget);3715 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, p, widget); 3926 3716 } 3927 3717 } … … 3940 3730 btnOpt.state |= State_Sunken; 3941 3731 btnOpt.state &= ~State_Raised; 3942 bsx = p ixelMetric(PM_ButtonShiftHorizontal);3943 bsy = p ixelMetric(PM_ButtonShiftVertical);3732 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); 3733 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); 3944 3734 } else { 3945 3735 btnOpt.state |= State_Raised; … … 3948 3738 bsy = 0; 3949 3739 } 3950 btnOpt.rect = subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget);3951 drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);3740 btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiCloseButton, widget); 3741 proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); 3952 3742 QPixmap pm = standardIcon(SP_TitleBarCloseButton).pixmap(16, 16); 3953 drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);3743 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); 3954 3744 } 3955 3745 if (opt->subControls & QStyle::SC_MdiNormalButton) { … … 3957 3747 btnOpt.state |= State_Sunken; 3958 3748 btnOpt.state &= ~State_Raised; 3959 bsx = p ixelMetric(PM_ButtonShiftHorizontal);3960 bsy = p ixelMetric(PM_ButtonShiftVertical);3749 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); 3750 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); 3961 3751 } else { 3962 3752 btnOpt.state |= State_Raised; … … 3965 3755 bsy = 0; 3966 3756 } 3967 btnOpt.rect = subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget);3968 drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);3757 btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiNormalButton, widget); 3758 proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); 3969 3759 QPixmap pm = standardIcon(SP_TitleBarNormalButton).pixmap(16, 16); 3970 drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);3760 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); 3971 3761 } 3972 3762 if (opt->subControls & QStyle::SC_MdiMinButton) { … … 3974 3764 btnOpt.state |= State_Sunken; 3975 3765 btnOpt.state &= ~State_Raised; 3976 bsx = p ixelMetric(PM_ButtonShiftHorizontal);3977 bsy = p ixelMetric(PM_ButtonShiftVertical);3766 bsx = proxy()->pixelMetric(PM_ButtonShiftHorizontal); 3767 bsy = proxy()->pixelMetric(PM_ButtonShiftVertical); 3978 3768 } else { 3979 3769 btnOpt.state |= State_Raised; … … 3982 3772 bsy = 0; 3983 3773 } 3984 btnOpt.rect = subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget);3985 drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget);3774 btnOpt.rect = proxy()->subControlRect(CC_MdiControls, opt, SC_MdiMinButton, widget); 3775 proxy()->drawPrimitive(PE_PanelButtonCommand, &btnOpt, p, widget); 3986 3776 QPixmap pm = standardIcon(SP_TitleBarMinButton).pixmap(16, 16); 3987 drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm);3777 proxy()->drawItemPixmap(p, btnOpt.rect.translated(bsx, bsy), Qt::AlignCenter, pm); 3988 3778 } 3989 3779 } … … 4007 3797 case CC_Slider: 4008 3798 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 4009 QRect r = subControlRect(cc, slider, SC_SliderHandle, widget);3799 QRect r = proxy()->subControlRect(cc, slider, SC_SliderHandle, widget); 4010 3800 if (r.isValid() && r.contains(pt)) { 4011 3801 sc = SC_SliderHandle; 4012 3802 } else { 4013 r = subControlRect(cc, slider, SC_SliderGroove ,widget);3803 r = proxy()->subControlRect(cc, slider, SC_SliderGroove ,widget); 4014 3804 if (r.isValid() && r.contains(pt)) 4015 3805 sc = SC_SliderGroove; … … 4024 3814 uint ctrl = SC_ScrollBarAddLine; 4025 3815 while (ctrl <= SC_ScrollBarGroove) { 4026 r = subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget);3816 r = proxy()->subControlRect(cc, scrollbar, QStyle::SubControl(ctrl), widget); 4027 3817 if (r.isValid() && r.contains(pt)) { 4028 3818 sc = QStyle::SubControl(ctrl); … … 4040 3830 uint ctrl = SC_ToolButton; 4041 3831 while (ctrl <= SC_ToolButtonMenu) { 4042 r = subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget);3832 r = proxy()->subControlRect(cc, toolbutton, QStyle::SubControl(ctrl), widget); 4043 3833 if (r.isValid() && r.contains(pt)) { 4044 3834 sc = QStyle::SubControl(ctrl); … … 4064 3854 uint ctrl = SC_SpinBoxUp; 4065 3855 while (ctrl <= SC_SpinBoxEditField) { 4066 r = subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget);3856 r = proxy()->subControlRect(cc, spinbox, QStyle::SubControl(ctrl), widget); 4067 3857 if (r.isValid() && r.contains(pt)) { 4068 3858 sc = QStyle::SubControl(ctrl); … … 4080 3870 4081 3871 while (ctrl <= SC_TitleBarLabel) { 4082 r = subControlRect(cc, tb, QStyle::SubControl(ctrl), widget);3872 r = proxy()->subControlRect(cc, tb, QStyle::SubControl(ctrl), widget); 4083 3873 if (r.isValid() && r.contains(pt)) { 4084 3874 sc = QStyle::SubControl(ctrl); … … 4095 3885 uint ctrl = SC_ComboBoxArrow; // Start here and go down. 4096 3886 while (ctrl > 0) { 4097 r = subControlRect(cc, cb, QStyle::SubControl(ctrl), widget);3887 r = proxy()->subControlRect(cc, cb, QStyle::SubControl(ctrl), widget); 4098 3888 if (r.isValid() && r.contains(pt)) { 4099 3889 sc = QStyle::SubControl(ctrl); … … 4111 3901 uint ctrl = SC_GroupBoxCheckBox; 4112 3902 while (ctrl <= SC_GroupBoxFrame) { 4113 r = subControlRect(cc, groupBox, QStyle::SubControl(ctrl), widget);3903 r = proxy()->subControlRect(cc, groupBox, QStyle::SubControl(ctrl), widget); 4114 3904 if (r.isValid() && r.contains(pt)) { 4115 3905 sc = QStyle::SubControl(ctrl); … … 4126 3916 uint ctrl = SC_MdiMinButton; 4127 3917 while (ctrl <= SC_MdiCloseButton) { 4128 r = subControlRect(CC_MdiControls, opt, QStyle::SubControl(ctrl), widget);3918 r = proxy()->subControlRect(CC_MdiControls, opt, QStyle::SubControl(ctrl), widget); 4129 3919 if (r.isValid() && r.contains(pt) && (opt->subControls & ctrl)) { 4130 3920 sc = QStyle::SubControl(ctrl); … … 4152 3942 case CC_Slider: 4153 3943 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 4154 int tickOffset = p ixelMetric(PM_SliderTickmarkOffset, slider, widget);4155 int thickness = p ixelMetric(PM_SliderControlThickness, slider, widget);3944 int tickOffset = proxy()->pixelMetric(PM_SliderTickmarkOffset, slider, widget); 3945 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, slider, widget); 4156 3946 4157 3947 switch (sc) { 4158 3948 case SC_SliderHandle: { 4159 3949 int sliderPos = 0; 4160 int len = p ixelMetric(PM_SliderLength, slider, widget);3950 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 4161 3951 bool horizontal = slider->orientation == Qt::Horizontal; 4162 3952 sliderPos = sliderPositionFromValue(slider->minimum, slider->maximum, … … 4189 3979 if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 4190 3980 const QRect scrollBarRect = scrollbar->rect; 4191 int sbextent = p ixelMetric(PM_ScrollBarExtent, scrollbar, widget);3981 int sbextent = proxy()->pixelMetric(PM_ScrollBarExtent, scrollbar, widget); 4192 3982 int maxlen = ((scrollbar->orientation == Qt::Horizontal) ? 4193 3983 scrollBarRect.width() : scrollBarRect.height()) - (sbextent * 2); … … 4199 3989 sliderlen = (qint64(scrollbar->pageStep) * maxlen) / (range + scrollbar->pageStep); 4200 3990 4201 int slidermin = p ixelMetric(PM_ScrollBarSliderMin, scrollbar, widget);3991 int slidermin = proxy()->pixelMetric(PM_ScrollBarSliderMin, scrollbar, widget); 4202 3992 if (sliderlen < slidermin || range > INT_MAX / 2) 4203 3993 sliderlen = slidermin; … … 4272 4062 if (const QStyleOptionSpinBox *spinbox = qstyleoption_cast<const QStyleOptionSpinBox *>(opt)) { 4273 4063 QSize bs; 4274 int fw = spinbox->frame ? p ixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;4064 int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; 4275 4065 bs.setHeight(qMax(8, spinbox->rect.height()/2 - fw)); 4276 4066 // 1.6 -approximate golden mean … … 4313 4103 case CC_ToolButton: 4314 4104 if (const QStyleOptionToolButton *tb = qstyleoption_cast<const QStyleOptionToolButton *>(opt)) { 4315 int mbi = p ixelMetric(PM_MenuButtonIndicator, tb, widget);4105 int mbi = proxy()->pixelMetric(PM_MenuButtonIndicator, tb, widget); 4316 4106 ret = tb->rect; 4317 4107 switch (sc) { … … 4453 4243 int topMargin = 0; 4454 4244 int topHeight = 0; 4455 int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);4245 int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); 4456 4246 if (groupBox->text.size() || (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)) { 4457 4247 topHeight = groupBox->fontMetrics.height(); … … 4473 4263 if (!(widget && widget->inherits("Q3GroupBox")) 4474 4264 && ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)) { 4475 frameWidth = p ixelMetric(PM_DefaultFrameWidth, groupBox, widget);4265 frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth, groupBox, widget); 4476 4266 } 4477 4267 ret = frameRect.adjusted(frameWidth, frameWidth + topHeight - topMargin, … … 4489 4279 ret.setHeight(h); 4490 4280 4491 int indicatorWidth = p ixelMetric(PM_IndicatorWidth, opt, widget);4492 int indicatorSpace = p ixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1;4281 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, opt, widget); 4282 int indicatorSpace = proxy()->pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1; 4493 4283 bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox; 4494 4284 int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0; … … 4504 4294 // Adjust for check box 4505 4295 if (sc == SC_GroupBoxCheckBox) { 4506 int indicatorHeight = p ixelMetric(PM_IndicatorHeight, opt, widget);4296 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, opt, widget); 4507 4297 left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth); 4508 4298 int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2; … … 4590 4380 break; 4591 4381 case PM_DialogButtonsSeparator: 4592 ret = 5;4382 ret = int(QStyleHelper::dpiScaled(5.)); 4593 4383 break; 4594 4384 case PM_DialogButtonsButtonWidth: 4595 ret = 70;4385 ret = int(QStyleHelper::dpiScaled(70.)); 4596 4386 break; 4597 4387 case PM_DialogButtonsButtonHeight: 4598 ret = 30;4388 ret = int(QStyleHelper::dpiScaled(30.)); 4599 4389 break; 4600 4390 case PM_CheckListControllerSize: 4601 4391 case PM_CheckListButtonSize: 4602 ret = 16;4392 ret = int(QStyleHelper::dpiScaled(16.)); 4603 4393 break; 4604 4394 case PM_TitleBarHeight: { 4605 4395 if (const QStyleOptionTitleBar *tb = qstyleoption_cast<const QStyleOptionTitleBar *>(opt)) { 4606 4396 if ((tb->titleBarFlags & Qt::WindowType_Mask) == Qt::Tool) { 4607 ret = qMax(widget ? widget->fontMetrics(). lineSpacing() : opt->fontMetrics.lineSpacing(), 16);4397 ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 16); 4608 4398 #ifndef QT_NO_DOCKWIDGET 4609 4399 } else if (qobject_cast<const QDockWidget*>(widget)) { 4610 ret = qMax(widget->fontMetrics(). lineSpacing(), 13);4400 ret = qMax(widget->fontMetrics().height(), int(QStyleHelper::dpiScaled(13))); 4611 4401 #endif 4612 4402 } else { 4613 ret = qMax(widget ? widget->fontMetrics(). lineSpacing() : opt->fontMetrics.lineSpacing(), 18);4403 ret = qMax(widget ? widget->fontMetrics().height() : opt->fontMetrics.height(), 18); 4614 4404 } 4615 4405 } else { 4616 ret = 18;4406 ret = int(QStyleHelper::dpiScaled(18.)); 4617 4407 } 4618 4408 4619 4409 break; } 4620 4410 case PM_ScrollBarSliderMin: 4621 ret = 9;4411 ret = int(QStyleHelper::dpiScaled(9.)); 4622 4412 break; 4623 4413 4624 4414 case PM_ButtonMargin: 4625 ret = 6;4415 ret = int(QStyleHelper::dpiScaled(6.)); 4626 4416 break; 4627 4417 4628 4418 case PM_DockWidgetTitleBarButtonMargin: 4629 ret = 2;4419 ret = int(QStyleHelper::dpiScaled(2.)); 4630 4420 break; 4631 4421 … … 4635 4425 4636 4426 case PM_MenuButtonIndicator: 4637 ret = 12;4427 ret = int(QStyleHelper::dpiScaled(12.)); 4638 4428 break; 4639 4429 … … 4650 4440 case PM_TabBarBaseOverlap: 4651 4441 case PM_TabBarBaseHeight: 4652 ret = p ixelMetric(PM_DefaultFrameWidth, opt, widget);4442 ret = proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); 4653 4443 break; 4654 4444 4655 4445 case PM_MdiSubWindowFrameWidth: 4656 ret = 4;4446 ret = int(QStyleHelper::dpiScaled(4.)); 4657 4447 break; 4658 4448 4659 4449 case PM_MdiSubWindowMinimizedWidth: 4660 ret = 196;4450 ret = int(QStyleHelper::dpiScaled(196.)); 4661 4451 break; 4662 4452 … … 4669 4459 ret = qMax(16, s); 4670 4460 } else { 4671 ret = 16;4461 ret = int(QStyleHelper::dpiScaled(16.)); 4672 4462 } 4673 4463 break; … … 4679 4469 #ifndef QT_NO_SLIDER 4680 4470 case PM_SliderThickness: 4681 ret = 16;4471 ret = int(QStyleHelper::dpiScaled(16.)); 4682 4472 break; 4683 4473 … … 4686 4476 int space = (sl->orientation == Qt::Horizontal) ? sl->rect.height() 4687 4477 : sl->rect.width(); 4688 int thickness = p ixelMetric(PM_SliderControlThickness, sl, widget);4478 int thickness = proxy()->pixelMetric(PM_SliderControlThickness, sl, widget); 4689 4479 int ticks = sl->tickPosition; 4690 4480 … … 4703 4493 if (const QStyleOptionSlider *sl = qstyleoption_cast<const QStyleOptionSlider *>(opt)) { 4704 4494 if (sl->orientation == Qt::Horizontal) 4705 ret = sl->rect.width() - p ixelMetric(PM_SliderLength, sl, widget);4495 ret = sl->rect.width() - proxy()->pixelMetric(PM_SliderLength, sl, widget); 4706 4496 else 4707 ret = sl->rect.height() - p ixelMetric(PM_SliderLength, sl, widget);4497 ret = sl->rect.height() - proxy()->pixelMetric(PM_SliderLength, sl, widget); 4708 4498 } else { 4709 4499 ret = 0; … … 4713 4503 #ifndef QT_NO_DOCKWIDGET 4714 4504 case PM_DockWidgetSeparatorExtent: 4715 ret = 6;4505 ret = int(QStyleHelper::dpiScaled(6.)); 4716 4506 break; 4717 4507 4718 4508 case PM_DockWidgetHandleExtent: 4719 ret = 8;4509 ret = int(QStyleHelper::dpiScaled(8.)); 4720 4510 break; 4721 4511 case PM_DockWidgetTitleMargin: … … 4746 4536 4747 4537 case PM_ToolBarItemSpacing: 4748 ret = 4;4538 ret = int(QStyleHelper::dpiScaled(4.)); 4749 4539 break; 4750 4540 4751 4541 case PM_ToolBarHandleExtent: 4752 ret = 8;4542 ret = int(QStyleHelper::dpiScaled(8.)); 4753 4543 break; 4754 4544 4755 4545 case PM_ToolBarSeparatorExtent: 4756 ret = 6;4546 ret = int(QStyleHelper::dpiScaled(6.)); 4757 4547 break; 4758 4548 4759 4549 case PM_ToolBarExtensionExtent: 4760 ret = 12;4550 ret = int(QStyleHelper::dpiScaled(12.)); 4761 4551 break; 4762 4552 #endif // QT_NO_TOOLBAR … … 4768 4558 4769 4559 case PM_TabBarTabHSpace: 4770 ret = 24;4560 ret = int(QStyleHelper::dpiScaled(24.)); 4771 4561 break; 4772 4562 … … 4797 4587 4798 4588 case PM_IndicatorWidth: 4799 ret = 13;4589 ret = int(QStyleHelper::dpiScaled(13.)); 4800 4590 break; 4801 4591 4802 4592 case PM_IndicatorHeight: 4803 ret = 13;4593 ret = int(QStyleHelper::dpiScaled(13.)); 4804 4594 break; 4805 4595 4806 4596 case PM_ExclusiveIndicatorWidth: 4807 ret = 12;4597 ret = int(QStyleHelper::dpiScaled(12.)); 4808 4598 break; 4809 4599 4810 4600 case PM_ExclusiveIndicatorHeight: 4811 ret = 12;4601 ret = int(QStyleHelper::dpiScaled(12.)); 4812 4602 break; 4813 4603 4814 4604 case PM_MenuTearoffHeight: 4815 ret = 10;4605 ret = int(QStyleHelper::dpiScaled(10.)); 4816 4606 break; 4817 4607 4818 4608 case PM_MenuScrollerHeight: 4819 ret = 10;4609 ret = int(QStyleHelper::dpiScaled(10.)); 4820 4610 break; 4821 4611 … … 4827 4617 4828 4618 case PM_HeaderMargin: 4829 ret = 4;4619 ret = int(QStyleHelper::dpiScaled(4.)); 4830 4620 break; 4831 4621 case PM_HeaderMarkSize: 4832 ret = 32;4622 ret = int(QStyleHelper::dpiScaled(32.)); 4833 4623 break; 4834 4624 case PM_HeaderGripMargin: 4835 ret = 4;4625 ret = int(QStyleHelper::dpiScaled(4.)); 4836 4626 break; 4837 4627 case PM_TabBarScrollButtonWidth: 4838 ret = 16;4628 ret = int(QStyleHelper::dpiScaled(16.)); 4839 4629 break; 4840 4630 case PM_LayoutLeftMargin: … … 4849 4639 isWindow = widget->isWindow(); 4850 4640 } 4851 ret = p ixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin);4641 ret = proxy()->pixelMetric(isWindow ? PM_DefaultTopLevelMargin : PM_DefaultChildMargin); 4852 4642 } 4853 4643 break; 4854 4644 case PM_LayoutHorizontalSpacing: 4855 4645 case PM_LayoutVerticalSpacing: 4856 ret = p ixelMetric(PM_DefaultLayoutSpacing);4646 ret = proxy()->pixelMetric(PM_DefaultLayoutSpacing); 4857 4647 break; 4858 4648 4859 4649 case PM_DefaultTopLevelMargin: 4860 ret = 11;4650 ret = int(QStyleHelper::dpiScaled(11.)); 4861 4651 break; 4862 4652 case PM_DefaultChildMargin: 4863 ret = 9;4653 ret = int(QStyleHelper::dpiScaled(9.)); 4864 4654 break; 4865 4655 case PM_DefaultLayoutSpacing: 4866 ret = 6; 4656 ret = int(QStyleHelper::dpiScaled(6.)); 4657 break; 4658 4659 case PM_ToolBarIconSize: 4660 ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ToolBarIconSize); 4661 if (!ret) 4662 ret = int(QStyleHelper::dpiScaled(24.)); 4867 4663 break; 4868 4664 4869 4665 case PM_TabBarIconSize: 4870 case PM_ToolBarIconSize:4871 4666 case PM_ListViewIconSize: 4872 ret = p ixelMetric(PM_SmallIconSize, opt, widget);4667 ret = proxy()->pixelMetric(PM_SmallIconSize, opt, widget); 4873 4668 break; 4874 4669 4875 4670 case PM_ButtonIconSize: 4876 4671 case PM_SmallIconSize: 4877 ret = 16;4672 ret = int(QStyleHelper::dpiScaled(16.)); 4878 4673 break; 4879 4674 case PM_IconViewIconSize: 4880 ret = p ixelMetric(PM_LargeIconSize, opt, widget);4675 ret = proxy()->pixelMetric(PM_LargeIconSize, opt, widget); 4881 4676 break; 4882 4677 4883 4678 case PM_LargeIconSize: 4884 ret = 32;4679 ret = int(QStyleHelper::dpiScaled(32.)); 4885 4680 break; 4886 4681 … … 4890 4685 case PM_CheckBoxLabelSpacing: 4891 4686 case PM_RadioButtonLabelSpacing: 4892 ret = 6;4687 ret = int(QStyleHelper::dpiScaled(6.)); 4893 4688 break; 4894 4689 case PM_SizeGripSize: 4895 ret = 13;4690 ret = int(QStyleHelper::dpiScaled(13.)); 4896 4691 break; 4897 4692 case PM_MessageBoxIconSize: 4898 ret = 32; 4693 #ifdef Q_WS_MAC 4694 if (QApplication::desktopSettingsAware()) { 4695 ret = 64; // No DPI scaling, it's handled elsewhere. 4696 } else 4697 #endif 4698 { 4699 ret = int(QStyleHelper::dpiScaled(32.)); 4700 } 4899 4701 break; 4900 4702 case PM_TextCursorWidth: … … 4906 4708 case PM_TabCloseIndicatorWidth: 4907 4709 case PM_TabCloseIndicatorHeight: 4908 ret = 16;4710 ret = int(QStyleHelper::dpiScaled(16.)); 4909 4711 break; 4910 4712 case PM_ScrollView_ScrollBarSpacing: 4911 ret = 2 * p ixelMetric(PM_DefaultFrameWidth, opt, widget);4713 ret = 2 * proxy()->pixelMetric(PM_DefaultFrameWidth, opt, widget); 4912 4714 break; 4913 4715 case PM_SubMenuOverlap: 4914 ret = -p ixelMetric(QStyle::PM_MenuPanelWidth, opt, widget);4716 ret = -proxy()->pixelMetric(QStyle::PM_MenuPanelWidth, opt, widget); 4915 4717 break; 4916 4718 default: … … 4935 4737 int w = csz.width(), 4936 4738 h = csz.height(), 4937 bm = p ixelMetric(PM_ButtonMargin, btn, widget),4938 fw = p ixelMetric(PM_DefaultFrameWidth, btn, widget) * 2;4739 bm = proxy()->pixelMetric(PM_ButtonMargin, btn, widget), 4740 fw = proxy()->pixelMetric(PM_DefaultFrameWidth, btn, widget) * 2; 4939 4741 w += bm + fw; 4940 4742 h += bm + fw; 4941 4743 if (btn->features & QStyleOptionButton::AutoDefaultButton){ 4942 int dbw = p ixelMetric(PM_ButtonDefaultIndicator, btn, widget) * 2;4744 int dbw = proxy()->pixelMetric(PM_ButtonDefaultIndicator, btn, widget) * 2; 4943 4745 w += dbw; 4944 4746 h += dbw; … … 4952 4754 bool isRadio = (ct == CT_RadioButton); 4953 4755 4954 int w = p ixelMetric(isRadio ? PM_ExclusiveIndicatorWidth4756 int w = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorWidth 4955 4757 : PM_IndicatorWidth, btn, widget); 4956 int h = p ixelMetric(isRadio ? PM_ExclusiveIndicatorHeight4758 int h = proxy()->pixelMetric(isRadio ? PM_ExclusiveIndicatorHeight 4957 4759 : PM_IndicatorHeight, btn, widget); 4958 4760 … … 4960 4762 // we add 4 pixels for label margins 4961 4763 if (btn->icon.isNull() || !btn->text.isEmpty()) 4962 margins = 4 + p ixelMetric(isRadio ? PM_RadioButtonLabelSpacing4764 margins = 4 + proxy()->pixelMetric(isRadio ? PM_RadioButtonLabelSpacing 4963 4765 : PM_CheckBoxLabelSpacing, opt, widget); 4964 4766 sz += QSize(w + margins, 4); … … 4978 4780 h = mi->fontMetrics.height() + 8; 4979 4781 if (!mi->icon.isNull()) { 4980 int iconExtent = p ixelMetric(PM_SmallIconSize);4782 int iconExtent = proxy()->pixelMetric(PM_SmallIconSize); 4981 4783 h = qMax(h, mi->icon.actualSize(QSize(iconExtent, iconExtent)).height() + 4); 4982 4784 } … … 5003 4805 case CT_ComboBox: 5004 4806 if (const QStyleOptionComboBox *cmb = qstyleoption_cast<const QStyleOptionComboBox *>(opt)) { 5005 int fw = cmb->frame ? p ixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0;5006 const int textMargins = 2*(p ixelMetric(PM_FocusFrameHMargin) + 1);4807 int fw = cmb->frame ? proxy()->pixelMetric(PM_ComboBoxFrameWidth, opt, widget) * 2 : 0; 4808 const int textMargins = 2*(proxy()->pixelMetric(PM_FocusFrameHMargin) + 1); 5007 4809 // QItemDelegate::sizeHint expands the textMargins two times, thus the 2*textMargins... 5008 int other = qMax(23, 2*textMargins + p ixelMetric(QStyle::PM_ScrollBarExtent, opt, widget));4810 int other = qMax(23, 2*textMargins + proxy()->pixelMetric(QStyle::PM_ScrollBarExtent, opt, widget)); 5009 4811 sz = QSize(sz.width() + fw + other, sz.height() + fw); 5010 4812 } … … 5014 4816 if (const QStyleOptionHeader *hdr = qstyleoption_cast<const QStyleOptionHeader *>(opt)) { 5015 4817 bool nullIcon = hdr->icon.isNull(); 5016 int margin = p ixelMetric(QStyle::PM_HeaderMargin, hdr, widget);5017 int iconSize = nullIcon ? 0 : p ixelMetric(QStyle::PM_SmallIconSize, hdr, widget);4818 int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, hdr, widget); 4819 int iconSize = nullIcon ? 0 : proxy()->pixelMetric(QStyle::PM_SmallIconSize, hdr, widget); 5018 4820 QSize txt = hdr->fontMetrics.size(0, hdr->text); 5019 4821 sz.setHeight(margin + qMax(iconSize, txt.height()) + margin); … … 5213 5015 if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) { 5214 5016 mask->region = widget->rect(); 5215 int vmargin = p ixelMetric(QStyle::PM_FocusFrameVMargin),5216 hmargin = p ixelMetric(QStyle::PM_FocusFrameHMargin);5017 int vmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameVMargin), 5018 hmargin = proxy()->pixelMetric(QStyle::PM_FocusFrameHMargin); 5217 5019 mask->region -= QRect(widget->rect().adjusted(hmargin, vmargin, -hmargin, -vmargin)); 5218 5020 } … … 5227 5029 if(QStyleHintReturnMask *mask = qstyleoption_cast<QStyleHintReturnMask*>(hret)) { 5228 5030 mask->region = opt->rect; 5229 int margin = p ixelMetric(PM_DefaultFrameWidth) * 2;5031 int margin = proxy()->pixelMetric(PM_DefaultFrameWidth) * 2; 5230 5032 mask->region -= opt->rect.adjusted(margin, margin, -margin, -margin); 5231 5033 } … … 5255 5057 5256 5058 case SH_ItemView_ActivateItemOnSingleClick: 5257 ret = false;5059 ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ItemView_ActivateItemOnSingleClick); 5258 5060 break; 5259 5061 … … 5283 5085 break; 5284 5086 case SH_DialogButtonBox_ButtonsHaveIcons: 5087 #ifdef Q_WS_X11 5088 return true; 5089 #endif 5285 5090 ret = 0; 5286 5091 break; … … 5345 5150 ret = true; 5346 5151 break; 5152 case SH_ToolButtonStyle: 5153 ret = qt_guiPlatformPlugin()->platformHint(QGuiPlatformPlugin::PH_ToolButtonStyle); 5154 break; 5155 case SH_RequestSoftwareInputPanel: 5156 ret = RSIP_OnMouseClickAndAlreadyFocused; 5157 break; 5347 5158 default: 5348 5159 ret = 0; … … 5357 5168 const QWidget *widget) const 5358 5169 { 5170 const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); 5359 5171 #ifdef QT_NO_IMAGEFORMAT_PNG 5360 Q_UNUSED(option);5361 5172 Q_UNUSED(widget); 5362 5173 Q_UNUSED(sp); 5363 5174 #else 5364 #ifdef Q_WS_X115365 Q_D(const QCommonStyle);5366 5175 QPixmap pixmap; 5367 if (qApp->desktopSettingsAware()) { 5368 d->lookupIconTheme();5176 5177 if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { 5369 5178 switch (sp) { 5179 case SP_DialogYesButton: 5180 case SP_DialogOkButton: 5181 pixmap = QIcon::fromTheme(QLatin1String("dialog-ok")).pixmap(16); 5182 break; 5183 case SP_DialogApplyButton: 5184 pixmap = QIcon::fromTheme(QLatin1String("dialog-ok-apply")).pixmap(16); 5185 break; 5186 case SP_DialogDiscardButton: 5187 pixmap = QIcon::fromTheme(QLatin1String("edit-delete")).pixmap(16); 5188 break; 5189 case SP_DialogCloseButton: 5190 pixmap = QIcon::fromTheme(QLatin1String("dialog-close")).pixmap(16); 5191 break; 5370 5192 case SP_DirHomeIcon: 5371 { 5372 pixmap = d->findIcon(16, QLatin1String("folder_home.png")); 5373 if (!pixmap.isNull()) 5374 return pixmap; 5375 break; 5376 } 5193 pixmap = QIcon::fromTheme(QLatin1String("user-home")).pixmap(16); 5194 break; 5377 5195 case SP_MessageBoxInformation: 5378 { 5379 pixmap = d->findIcon(32, QLatin1String("messagebox_info.png")); 5380 if (!pixmap.isNull()) 5381 return pixmap; 5382 break; 5383 } 5196 pixmap = QIcon::fromTheme(QLatin1String("messagebox_info")).pixmap(16); 5197 break; 5384 5198 case SP_MessageBoxWarning: 5385 { 5386 pixmap = d->findIcon(32, QLatin1String("messagebox_warning.png")); 5387 if (!pixmap.isNull()) 5388 return pixmap; 5389 break; 5390 } 5199 pixmap = QIcon::fromTheme(QLatin1String("messagebox_warning")).pixmap(16); 5200 break; 5391 5201 case SP_MessageBoxCritical: 5392 { 5393 pixmap = d->findIcon(32, QLatin1String("messagebox_critical.png")); 5394 if (!pixmap.isNull()) 5395 return pixmap; 5396 break; 5397 } 5202 pixmap = QIcon::fromTheme(QLatin1String("messagebox_critical")).pixmap(16); 5203 break; 5398 5204 case SP_MessageBoxQuestion: 5399 { 5400 pixmap = d->findIcon(32, QLatin1String("help.png")); 5401 if (!pixmap.isNull()) 5402 return pixmap; 5403 break; 5404 } 5205 pixmap = QIcon::fromTheme(QLatin1String("help")).pixmap(16); 5206 break; 5405 5207 case SP_DialogOpenButton: 5406 5208 case SP_DirOpenIcon: 5407 { 5408 pixmap = d->findIcon(16, QLatin1String("folder-open.png")); 5409 if (pixmap.isNull()) 5410 pixmap = d->findIcon(16, QLatin1String("folder_open.png")); 5411 if (!pixmap.isNull()) 5412 return pixmap; 5413 break; 5414 } 5209 pixmap = QIcon::fromTheme(QLatin1String("folder-open")).pixmap(16); 5210 break; 5415 5211 case SP_FileIcon: 5416 { 5417 pixmap = d->findIcon(16, QLatin1String("text-x-generic.png")); 5418 if (pixmap.isNull()) 5419 pixmap = d->findIcon(16, QLatin1String("empty.png")); 5420 if (!pixmap.isNull()) 5421 return pixmap; 5422 break; 5423 } 5424 case SP_FileLinkIcon: 5425 { 5426 pixmap = d->findIcon(16, QLatin1String("link_overlay.png")); 5427 if (!pixmap.isNull()) { 5428 QPixmap fileIcon = d->findIcon(16, QLatin1String("text-x-generic.png")); 5429 if (fileIcon.isNull()) 5430 fileIcon = d->findIcon(16, QLatin1String("empty.png")); 5431 if (!fileIcon.isNull()) { 5432 QPainter painter(&fileIcon); 5433 painter.drawPixmap(0, 0, 16, 16, pixmap); 5434 return fileIcon; 5435 } 5436 } 5437 break; 5438 } 5212 pixmap = QIcon::fromTheme(QLatin1String("text-x-generic"), 5213 QIcon::fromTheme(QLatin1String("empty"))).pixmap(16); 5214 break; 5439 5215 case SP_DirClosedIcon: 5440 5216 case SP_DirIcon: 5441 { 5442 pixmap = d->findIcon(16, QLatin1String("folder.png")); 5443 if (!pixmap.isNull()) 5444 return pixmap; 5445 break; 5446 } 5217 pixmap = QIcon::fromTheme(QLatin1String("folder")).pixmap(16); 5218 break; 5219 case SP_DriveFDIcon: 5220 pixmap = QIcon::fromTheme(QLatin1String("media-floppy"), 5221 QIcon::fromTheme(QLatin1String("3floppy_unmount"))).pixmap(16); 5222 break; 5223 case SP_ComputerIcon: 5224 pixmap = QIcon::fromTheme(QLatin1String("computer"), 5225 QIcon::fromTheme(QLatin1String("system"))).pixmap(16); 5226 break; 5227 case SP_DesktopIcon: 5228 pixmap = QIcon::fromTheme(QLatin1String("user-desktop"), 5229 QIcon::fromTheme(QLatin1String("desktop"))).pixmap(16); 5230 break; 5231 case SP_TrashIcon: 5232 pixmap = QIcon::fromTheme(QLatin1String("user-trash"), 5233 QIcon::fromTheme(QLatin1String("trashcan_empty"))).pixmap(16); 5234 break; 5235 case SP_DriveCDIcon: 5236 case SP_DriveDVDIcon: 5237 pixmap = QIcon::fromTheme(QLatin1String("media-optical"), 5238 QIcon::fromTheme(QLatin1String("cdrom_unmount"))).pixmap(16); 5239 break; 5240 case SP_DriveHDIcon: 5241 pixmap = QIcon::fromTheme(QLatin1String("drive-harddisk"), 5242 QIcon::fromTheme(QLatin1String("hdd_unmount"))).pixmap(16); 5243 break; 5244 case SP_FileDialogToParent: 5245 pixmap = QIcon::fromTheme(QLatin1String("go-up"), 5246 QIcon::fromTheme(QLatin1String("up"))).pixmap(16); 5247 break; 5248 case SP_FileDialogNewFolder: 5249 pixmap = QIcon::fromTheme(QLatin1String("folder_new")).pixmap(16); 5250 break; 5251 case SP_ArrowUp: 5252 pixmap = QIcon::fromTheme(QLatin1String("go-up"), 5253 QIcon::fromTheme(QLatin1String("up"))).pixmap(16); 5254 break; 5255 case SP_ArrowDown: 5256 pixmap = QIcon::fromTheme(QLatin1String("go-down"), 5257 QIcon::fromTheme(QLatin1String("down"))).pixmap(16); 5258 break; 5259 case SP_ArrowRight: 5260 pixmap = QIcon::fromTheme(QLatin1String("go-next"), 5261 QIcon::fromTheme(QLatin1String("forward"))).pixmap(16); 5262 break; 5263 case SP_ArrowLeft: 5264 pixmap = QIcon::fromTheme(QLatin1String("go-previous"), 5265 QIcon::fromTheme(QLatin1String("back"))).pixmap(16); 5266 break; 5267 case SP_FileDialogDetailedView: 5268 pixmap = QIcon::fromTheme(QLatin1String("view_detailed")).pixmap(16); 5269 break; 5270 case SP_FileDialogListView: 5271 pixmap = QIcon::fromTheme(QLatin1String("view_icon")).pixmap(16); 5272 break; 5273 case SP_BrowserReload: 5274 pixmap = QIcon::fromTheme(QLatin1String("reload")).pixmap(16); 5275 break; 5276 case SP_BrowserStop: 5277 pixmap = QIcon::fromTheme(QLatin1String("process-stop")).pixmap(16); 5278 break; 5279 case SP_MediaPlay: 5280 pixmap = QIcon::fromTheme(QLatin1String("media-playback-start")).pixmap(16); 5281 break; 5282 case SP_MediaPause: 5283 pixmap = QIcon::fromTheme(QLatin1String("media-playback-pause")).pixmap(16); 5284 break; 5285 case SP_MediaStop: 5286 pixmap = QIcon::fromTheme(QLatin1String("media-playback-stop")).pixmap(16); 5287 break; 5288 case SP_MediaSeekForward: 5289 pixmap = QIcon::fromTheme(QLatin1String("media-seek-forward")).pixmap(16); 5290 break; 5291 case SP_MediaSeekBackward: 5292 pixmap = QIcon::fromTheme(QLatin1String("media-seek-backward")).pixmap(16); 5293 break; 5294 case SP_MediaSkipForward: 5295 pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); 5296 break; 5297 case SP_MediaSkipBackward: 5298 pixmap = QIcon::fromTheme(QLatin1String("media-skip-backward")).pixmap(16); 5299 break; 5300 case SP_DialogResetButton: 5301 pixmap = QIcon::fromTheme(QLatin1String("edit-clear")).pixmap(24); 5302 break; 5303 case SP_DialogHelpButton: 5304 pixmap = QIcon::fromTheme(QLatin1String("help-contents")).pixmap(24); 5305 break; 5306 case SP_DialogNoButton: 5307 case SP_DialogCancelButton: 5308 pixmap = QIcon::fromTheme(QLatin1String("dialog-cancel"), 5309 QIcon::fromTheme(QLatin1String("process-stop"))).pixmap(24); 5310 break; 5311 case SP_DialogSaveButton: 5312 pixmap = QIcon::fromTheme(QLatin1String("document-save")).pixmap(24); 5313 break; 5314 case SP_FileLinkIcon: 5315 pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16); 5316 if (!pixmap.isNull()) { 5317 QPixmap fileIcon = QIcon::fromTheme(QLatin1String("text-x-generic")).pixmap(16); 5318 if (fileIcon.isNull()) 5319 fileIcon = QIcon::fromTheme(QLatin1String("empty")).pixmap(16); 5320 if (!fileIcon.isNull()) { 5321 QPainter painter(&fileIcon); 5322 painter.drawPixmap(0, 0, 16, 16, pixmap); 5323 return fileIcon; 5324 } 5325 } 5326 break; 5447 5327 case SP_DirLinkIcon: 5448 { 5449 pixmap = d->findIcon(16, QLatin1String("link_overlay.png")); 5328 pixmap = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")).pixmap(16); 5450 5329 if (!pixmap.isNull()) { 5451 QPixmap dirIcon = d->findIcon(16, QLatin1String("folder.png"));5330 QPixmap dirIcon = QIcon::fromTheme(QLatin1String("folder")).pixmap(16); 5452 5331 if (!dirIcon.isNull()) { 5453 5332 QPainter painter(&dirIcon); … … 5457 5336 } 5458 5337 break; 5459 }5460 case SP_DriveFDIcon:5461 {5462 pixmap = d->findIcon(16, QLatin1String("media-floppy.png"));5463 if (pixmap.isNull())5464 pixmap = d->findIcon(16, QLatin1String("3floppy_unmount.png"));5465 if (!pixmap.isNull())5466 return pixmap;5467 break;5468 }5469 case SP_ComputerIcon:5470 {5471 pixmap = d->findIcon(16, QLatin1String("computer.png"));5472 if (pixmap.isNull())5473 pixmap = d->findIcon(16, QLatin1String("system.png"));5474 if (!pixmap.isNull())5475 return pixmap;5476 break;5477 }5478 case SP_DesktopIcon:5479 {5480 pixmap = d->findIcon(16, QLatin1String("user-desktop.png"));5481 if (pixmap.isNull())5482 pixmap = d->findIcon(16, QLatin1String("desktop.png"));5483 if (!pixmap.isNull())5484 return pixmap;5485 break;5486 }5487 case SP_TrashIcon:5488 {5489 pixmap = d->findIcon(16, QLatin1String("user-trash.png"));5490 if (pixmap.isNull())5491 pixmap = d->findIcon(16, QLatin1String("trashcan_empty.png"));5492 if (!pixmap.isNull())5493 return pixmap;5494 break;5495 }5496 case SP_DriveCDIcon:5497 case SP_DriveDVDIcon:5498 {5499 pixmap = d->findIcon(16, QLatin1String("media-optical.png"));5500 if (pixmap.isNull())5501 pixmap = d->findIcon(16, QLatin1String("cdrom_unmount.png"));5502 if (!pixmap.isNull())5503 return pixmap;5504 break;5505 }5506 case SP_DriveHDIcon:5507 {5508 pixmap = d->findIcon(16, QLatin1String("drive-harddisk.png"));5509 if (pixmap.isNull())5510 pixmap = d->findIcon(16, QLatin1String("hdd_unmount.png"));5511 if (!pixmap.isNull())5512 return pixmap;5513 break;5514 }5515 case SP_FileDialogToParent:5516 {5517 pixmap = d->findIcon(32, QLatin1String("go-up.png"));5518 if (pixmap.isNull())5519 pixmap = d->findIcon(32, QLatin1String("up.png"));5520 if (!pixmap.isNull())5521 return pixmap;5522 break;5523 }5524 case SP_FileDialogNewFolder:5525 {5526 pixmap = d->findIcon(16, QLatin1String("folder_new.png"));5527 if (!pixmap.isNull())5528 return pixmap;5529 break;5530 }5531 case SP_ArrowUp:5532 {5533 pixmap = d->findIcon(32, QLatin1String("go-up.png"));5534 if (pixmap.isNull())5535 pixmap = d->findIcon(32, QLatin1String("up.png"));5536 if (!pixmap.isNull())5537 return pixmap;5538 break;5539 }5540 case SP_ArrowDown:5541 {5542 pixmap = d->findIcon(32, QLatin1String("go-down.png"));5543 if (pixmap.isNull())5544 pixmap = d->findIcon(32, QLatin1String("down.png"));5545 if (!pixmap.isNull())5546 return pixmap;5547 break;5548 }5549 case SP_ArrowRight:5550 {5551 pixmap = d->findIcon(32, QLatin1String("go-next.png"));5552 if (pixmap.isNull())5553 pixmap = d->findIcon(32, QLatin1String("forward.png"));5554 if (!pixmap.isNull())5555 return pixmap;5556 break;5557 }5558 case SP_ArrowLeft:5559 {5560 pixmap = d->findIcon(32, QLatin1String("go-previous.png"));5561 if (pixmap.isNull())5562 pixmap = d->findIcon(32, QLatin1String("back.png"));5563 if (!pixmap.isNull())5564 return pixmap;5565 break;5566 }5567 case SP_FileDialogDetailedView:5568 {5569 pixmap = d->findIcon(16, QLatin1String("view_detailed.png"));5570 if (!pixmap.isNull())5571 return pixmap;5572 break;5573 }5574 5575 case SP_FileDialogListView:5576 {5577 pixmap = d->findIcon(16, QLatin1String("view_icon.png"));5578 if (!pixmap.isNull())5579 return pixmap;5580 break;5581 }5582 case SP_BrowserReload:5583 {5584 pixmap = d->findIcon(32, QLatin1String("reload.png"));5585 if (!pixmap.isNull())5586 return pixmap;5587 break;5588 }5589 case SP_BrowserStop:5590 {5591 pixmap = d->findIcon(32, QLatin1String("stop.png"));5592 if (!pixmap.isNull())5593 return pixmap;5594 break;5595 }5596 case SP_MediaPlay:5597 {5598 pixmap = d->findIcon(16, QLatin1String("player_play.png"));5599 if (!pixmap.isNull())5600 return pixmap;5601 break;5602 }5603 case SP_MediaPause:5604 {5605 pixmap = d->findIcon(16, QLatin1String("player_pause.png"));5606 if (!pixmap.isNull())5607 return pixmap;5608 break;5609 }5610 case SP_MediaStop:5611 {5612 pixmap = d->findIcon(16, QLatin1String("player_stop.png"));5613 if (!pixmap.isNull())5614 return pixmap;5615 break;5616 }5617 case SP_MediaSeekForward:5618 {5619 pixmap = d->findIcon(16, QLatin1String("player_fwd.png"));5620 if (!pixmap.isNull())5621 return pixmap;5622 break;5623 }5624 case SP_MediaSeekBackward:5625 {5626 pixmap = d->findIcon(16, QLatin1String("player_rew.png"));5627 if (!pixmap.isNull())5628 return pixmap;5629 break;5630 }5631 case SP_MediaSkipForward:5632 {5633 pixmap = d->findIcon(16, QLatin1String("player_end.png"));5634 if (!pixmap.isNull())5635 return pixmap;5636 break;5637 }5638 case SP_MediaSkipBackward:5639 {5640 pixmap = d->findIcon(16, QLatin1String("player_start.png"));5641 if (!pixmap.isNull())5642 return pixmap;5643 break;5644 }5645 5646 5338 default: 5647 5339 break; 5648 5340 } 5649 5341 } 5650 #endif //Q_WS_X11 5342 5343 if (!pixmap.isNull()) 5344 return pixmap; 5651 5345 #endif //QT_NO_IMAGEFORMAT_PNG 5652 5346 switch (sp) { 5653 5347 #ifndef QT_NO_IMAGEFORMAT_XPM 5654 5348 case SP_ToolBarHorizontalExtensionButton: 5655 if ( QApplication::layoutDirection() == Qt::RightToLeft) {5349 if (rtl) { 5656 5350 QImage im(tb_extension_arrow_h_xpm); 5657 5351 im = im.convertToFormat(QImage::Format_ARGB32).mirrored(true, false); … … 5669 5363 case SP_CommandLink: 5670 5364 case SP_ArrowForward: 5671 if ( QApplication::layoutDirection() == Qt::RightToLeft)5672 return standardPixmap(SP_ArrowLeft, option, widget);5673 return standardPixmap(SP_ArrowRight, option, widget);5365 if (rtl) 5366 return proxy()->standardPixmap(SP_ArrowLeft, option, widget); 5367 return proxy()->standardPixmap(SP_ArrowRight, option, widget); 5674 5368 case SP_ArrowBack: 5675 if ( QApplication::layoutDirection() == Qt::RightToLeft)5676 return standardPixmap(SP_ArrowRight, option, widget);5677 return standardPixmap(SP_ArrowLeft, option, widget);5369 if (rtl) 5370 return proxy()->standardPixmap(SP_ArrowRight, option, widget); 5371 return proxy()->standardPixmap(SP_ArrowLeft, option, widget); 5678 5372 case SP_ArrowLeft: 5679 5373 return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png")); … … 5685 5379 return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png")); 5686 5380 case SP_FileDialogToParent: 5687 return standardPixmap(SP_ArrowUp, option, widget);5381 return proxy()->standardPixmap(SP_ArrowUp, option, widget); 5688 5382 case SP_FileDialogNewFolder: 5689 5383 return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png")); … … 5697 5391 return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png")); 5698 5392 case SP_FileDialogBack: 5699 return standardPixmap(SP_ArrowBack, option, widget);5393 return proxy()->standardPixmap(SP_ArrowBack, option, widget); 5700 5394 case SP_DriveHDIcon: 5701 5395 return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/harddrive-16.png")); … … 5784 5478 { 5785 5479 QIcon icon; 5786 #ifdef Q_WS_X11 5787 Q_D(const QCommonStyle); 5788 if (qApp->desktopSettingsAware()) { 5789 d->lookupIconTheme(); 5790 QPixmap pixmap; 5480 const bool rtl = (option && option->direction == Qt::RightToLeft) || (!option && QApplication::isRightToLeft()); 5481 if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) { 5791 5482 switch (standardIcon) { 5792 5483 case SP_DirHomeIcon: 5793 { 5794 icon = d->createIcon(QLatin1String("folder_home.png")); 5795 break; 5796 } 5484 icon = QIcon::fromTheme(QLatin1String("user-home")); 5485 break; 5797 5486 case SP_MessageBoxInformation: 5798 { 5799 icon = d->createIcon(QLatin1String("dialog-information.png")); 5800 if (icon.isNull()) 5801 icon = d->createIcon(QLatin1String("messagebox_info.png")); 5802 break; 5803 } 5487 icon = QIcon::fromTheme(QLatin1String("dialog-information")); 5488 break; 5804 5489 case SP_MessageBoxWarning: 5805 { 5806 icon = d->createIcon(QLatin1String("dialog-warning.png")); 5807 if (icon.isNull()) 5808 icon = d->createIcon(QLatin1String("messagebox_warning.png")); 5809 break; 5810 } 5490 icon = QIcon::fromTheme(QLatin1String("dialog-warning")); 5491 break; 5811 5492 case SP_MessageBoxCritical: 5812 { 5813 icon = d->createIcon(QLatin1String("dialog-error.png")); 5814 if (icon.isNull()) 5815 icon = d->createIcon(QLatin1String("messagebox_critical.png")); 5816 break; 5817 } 5493 icon = QIcon::fromTheme(QLatin1String("dialog-error")); 5494 break; 5818 5495 case SP_MessageBoxQuestion: 5819 { 5820 icon = d->createIcon(QLatin1String("help.png")); 5821 break; 5822 } 5496 icon = QIcon::fromTheme(QLatin1String("dialog-question")); 5497 break; 5823 5498 case SP_DialogOpenButton: 5824 5499 case SP_DirOpenIcon: 5825 { 5826 icon = d->createIcon(QLatin1String("folder-open.png")); 5827 if (icon.isNull()) 5828 icon = d->createIcon(QLatin1String("folder_open.png")); 5829 break; 5830 } 5500 icon = QIcon::fromTheme(QLatin1String("folder-open")); 5501 break; 5502 case SP_DialogSaveButton: 5503 icon = QIcon::fromTheme(QLatin1String("document-save")); 5504 break; 5505 case SP_DialogApplyButton: 5506 icon = QIcon::fromTheme(QLatin1String("dialog-ok-apply")); 5507 break; 5508 case SP_DialogYesButton: 5509 case SP_DialogOkButton: 5510 icon = QIcon::fromTheme(QLatin1String("dialog-ok")); 5511 break; 5512 case SP_DialogDiscardButton: 5513 icon = QIcon::fromTheme(QLatin1String("edit-delete")); 5514 break; 5515 case SP_DialogResetButton: 5516 icon = QIcon::fromTheme(QLatin1String("edit-clear")); 5517 break; 5518 case SP_DialogHelpButton: 5519 icon = QIcon::fromTheme(QLatin1String("help-contents")); 5520 break; 5831 5521 case SP_FileIcon: 5832 { 5833 icon = d->createIcon(QLatin1String("text-x-generic.png")); 5834 if (icon.isNull()) 5835 icon = d->createIcon(QLatin1String("empty.png")); 5836 break; 5837 } 5522 icon = QIcon::fromTheme(QLatin1String("text-x-generic")); 5523 break; 5838 5524 case SP_DirClosedIcon: 5839 5525 case SP_DirIcon: 5840 { 5841 icon = d->createIcon(QLatin1String("folder.png")); 5842 break; 5843 } 5526 icon = QIcon::fromTheme(QLatin1String("folder")); 5527 break; 5844 5528 case SP_DriveFDIcon: 5845 { 5846 icon = d->createIcon(QLatin1String("floppy_unmount.png")); 5847 break; 5848 } 5529 icon = QIcon::fromTheme(QLatin1String("floppy_unmount")); 5530 break; 5849 5531 case SP_ComputerIcon: 5850 { 5851 icon = d->createIcon(QLatin1String("computer.png")); 5852 if (icon.isNull()) 5853 icon = d->createIcon(QLatin1String("system.png")); 5854 break; 5855 } 5532 icon = QIcon::fromTheme(QLatin1String("computer"), 5533 QIcon::fromTheme(QLatin1String("system"))); 5534 break; 5856 5535 case SP_DesktopIcon: 5857 { 5858 icon = d->createIcon(QLatin1String("user-desktop.png")); 5859 break; 5860 } 5536 icon = QIcon::fromTheme(QLatin1String("user-desktop")); 5537 break; 5861 5538 case SP_TrashIcon: 5862 { 5863 icon = d->createIcon(QLatin1String("user-trash.png")); 5864 break; 5865 } 5539 icon = QIcon::fromTheme(QLatin1String("user-trash")); 5540 break; 5866 5541 case SP_DriveCDIcon: 5867 5542 case SP_DriveDVDIcon: 5543 icon = QIcon::fromTheme(QLatin1String("media-optical")); 5544 break; 5545 case SP_DriveHDIcon: 5546 icon = QIcon::fromTheme(QLatin1String("drive-harddisk")); 5547 break; 5548 case SP_FileDialogToParent: 5549 icon = QIcon::fromTheme(QLatin1String("go-up")); 5550 break; 5551 case SP_FileDialogNewFolder: 5552 icon = QIcon::fromTheme(QLatin1String("folder-new")); 5553 break; 5554 case SP_ArrowUp: 5555 icon = QIcon::fromTheme(QLatin1String("go-up")); 5556 break; 5557 case SP_ArrowDown: 5558 icon = QIcon::fromTheme(QLatin1String("go-down")); 5559 break; 5560 case SP_ArrowRight: 5561 icon = QIcon::fromTheme(QLatin1String("go-next")); 5562 break; 5563 case SP_ArrowLeft: 5564 icon = QIcon::fromTheme(QLatin1String("go-previous")); 5565 break; 5566 case SP_DialogCancelButton: 5567 icon = QIcon::fromTheme(QLatin1String("dialog-cancel"), 5568 QIcon::fromTheme(QLatin1String("process-stop"))); 5569 break; 5570 case SP_DialogCloseButton: 5571 icon = QIcon::fromTheme(QLatin1String("window-close")); 5572 break; 5573 case SP_FileDialogDetailedView: 5574 icon = QIcon::fromTheme(QLatin1String("view-list-details")); 5575 break; 5576 case SP_FileDialogListView: 5577 icon = QIcon::fromTheme(QLatin1String("view-list-icons")); 5578 break; 5579 case SP_BrowserReload: 5580 icon = QIcon::fromTheme(QLatin1String("view-refresh")); 5581 break; 5582 case SP_BrowserStop: 5583 icon = QIcon::fromTheme(QLatin1String("process-stop")); 5584 break; 5585 case SP_MediaPlay: 5586 icon = QIcon::fromTheme(QLatin1String("media-playback-start")); 5587 break; 5588 case SP_MediaPause: 5589 icon = QIcon::fromTheme(QLatin1String("media-playback-pause")); 5590 break; 5591 case SP_MediaStop: 5592 icon = QIcon::fromTheme(QLatin1String("media-playback-stop")); 5593 break; 5594 case SP_MediaSeekForward: 5595 icon = QIcon::fromTheme(QLatin1String("media-seek-forward")); 5596 break; 5597 case SP_MediaSeekBackward: 5598 icon = QIcon::fromTheme(QLatin1String("media-seek-backward")); 5599 break; 5600 case SP_MediaSkipForward: 5601 icon = QIcon::fromTheme(QLatin1String("media-skip-forward")); 5602 break; 5603 case SP_MediaSkipBackward: 5604 icon = QIcon::fromTheme(QLatin1String("media-skip-backward")); 5605 break; 5606 case SP_MediaVolume: 5607 icon = QIcon::fromTheme(QLatin1String("audio-volume-medium")); 5608 break; 5609 case SP_MediaVolumeMuted: 5610 icon = QIcon::fromTheme(QLatin1String("audio-volume-muted")); 5611 break; 5612 case SP_ArrowForward: 5613 if (rtl) 5614 return standardIconImplementation(SP_ArrowLeft, option, widget); 5615 return standardIconImplementation(SP_ArrowRight, option, widget); 5616 case SP_ArrowBack: 5617 if (rtl) 5618 return standardIconImplementation(SP_ArrowRight, option, widget); 5619 return standardIconImplementation(SP_ArrowLeft, option, widget); 5620 case SP_FileLinkIcon: 5868 5621 { 5869 icon = d->createIcon(QLatin1String("media-optical.png")); 5870 if (icon.isNull()) 5871 icon = d->createIcon(QLatin1String("cdrom_unmount.png")); 5872 break; 5873 } 5874 case SP_DriveHDIcon: 5622 QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")); 5623 if (!linkIcon.isNull()) { 5624 QIcon baseIcon = standardIconImplementation(SP_FileIcon, option, widget); 5625 const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off); 5626 for (int i = 0 ; i < sizes.size() ; ++i) { 5627 int size = sizes[i].width(); 5628 QPixmap basePixmap = baseIcon.pixmap(size); 5629 QPixmap linkPixmap = linkIcon.pixmap(size/2); 5630 QPainter painter(&basePixmap); 5631 painter.drawPixmap(size/2, size/2, linkPixmap); 5632 icon.addPixmap(basePixmap); 5633 } 5634 } 5635 } 5636 break; 5637 case SP_DirLinkIcon: 5875 5638 { 5876 icon = d->createIcon(QLatin1String("drive-harddisk.png")); 5877 if (icon.isNull()) 5878 icon = d->createIcon(QLatin1String("hdd_unmount.png")); 5879 break; 5880 } 5881 case SP_FileDialogToParent: 5882 { 5883 icon = d->createIcon(QLatin1String("go-up.png")); 5884 if (icon.isNull()) 5885 icon = d->createIcon(QLatin1String("up.png")); 5886 break; 5887 } 5888 case SP_FileDialogNewFolder: 5889 { 5890 icon = d->createIcon(QLatin1String("folder_new.png")); 5891 break; 5892 } 5893 case SP_ArrowUp: 5894 { 5895 icon = d->createIcon(QLatin1String("go-up.png")); 5896 if (icon.isNull()) 5897 icon = d->createIcon(QLatin1String("up.png")); 5898 break; 5899 } 5900 case SP_ArrowDown: 5901 { 5902 icon = d->createIcon(QLatin1String("go-down.png")); 5903 if (icon.isNull()) 5904 icon = d->createIcon(QLatin1String("down.png")); 5905 break; 5906 } 5907 case SP_ArrowRight: 5908 { 5909 icon = d->createIcon(QLatin1String("go-next.png")); 5910 if (icon.isNull()) 5911 icon = d->createIcon(QLatin1String("forward.png")); 5912 break; 5913 } 5914 case SP_ArrowLeft: 5915 { 5916 icon = d->createIcon(QLatin1String("go-previous.png")); 5917 if (icon.isNull()) 5918 icon = d->createIcon(QLatin1String("back.png")); 5919 break; 5920 } 5921 case SP_FileDialogDetailedView: 5922 { 5923 icon = d->createIcon(QLatin1String("view-list-details.png")); 5924 if (icon.isNull()) 5925 icon = d->createIcon(QLatin1String("view_detailed.png")); 5926 break; 5927 } 5928 case SP_FileDialogListView: 5929 { 5930 icon = d->createIcon(QLatin1String("view-list-icons.png")); 5931 if (icon.isNull()) 5932 icon = d->createIcon(QLatin1String("view_icon.png")); 5933 break; 5934 } 5935 case SP_BrowserReload: 5936 { 5937 icon = d->createIcon(QLatin1String("view-refresh.png")); 5938 if (icon.isNull()) 5939 icon = d->createIcon(QLatin1String("reload.png")); 5940 break; 5941 } 5942 case SP_BrowserStop: 5943 { 5944 icon = d->createIcon(QLatin1String("process-stop.png")); 5945 if (icon.isNull()) 5946 icon = d->createIcon(QLatin1String("stop.png")); 5947 break; 5948 } 5949 case SP_MediaPlay: 5950 { 5951 icon = d->createIcon(QLatin1String("media-playback-start.png")); 5952 if (icon.isNull()) 5953 icon = d->createIcon(QLatin1String("player_play.png")); 5954 break; 5955 } 5956 case SP_MediaPause: 5957 { 5958 icon = d->createIcon(QLatin1String("media-playback-pause.png")); 5959 if (icon.isNull()) 5960 icon = d->createIcon(QLatin1String("player_pause.png")); 5961 break; 5962 } 5963 case SP_MediaStop: 5964 { 5965 icon = d->createIcon(QLatin1String("media-playback-stop.png")); 5966 if (icon.isNull()) 5967 icon = d->createIcon(QLatin1String("player_stop.png")); 5968 break; 5969 } 5970 case SP_MediaSeekForward: 5971 { 5972 icon = d->createIcon(QLatin1String("media-skip-forward.png")); 5973 if (icon.isNull()) 5974 icon = d->createIcon(QLatin1String("player_fwd.png")); 5975 break; 5976 } 5977 case SP_MediaSeekBackward: 5978 { 5979 icon = d->createIcon(QLatin1String("media-skip-backward.png")); 5980 if (icon.isNull()) 5981 icon = d->createIcon(QLatin1String("player_rew.png")); 5982 break; 5983 } 5984 case SP_MediaSkipForward: 5985 { 5986 icon = d->createIcon(QLatin1String("media-skip-forward.png")); 5987 if (icon.isNull()) 5988 icon = d->createIcon(QLatin1String("player_end.png")); 5989 break; 5990 } 5991 case SP_MediaSkipBackward: 5992 { 5993 icon = d->createIcon(QLatin1String("media-skip-backward.png")); 5994 if (icon.isNull()) 5995 icon = d->createIcon(QLatin1String("player_start.png")); 5996 break; 5997 } 5998 5999 case SP_FileLinkIcon: { 6000 icon = QIcon(standardPixmap(standardIcon, option, widget)); 6001 QPixmap pixmap = d->findIcon(32, QLatin1String("link_overlay.png")); 6002 if (!pixmap.isNull()) { 6003 QPixmap fileIcon = d->findIcon(32, QLatin1String("text-x-generic.png")); 6004 if (fileIcon.isNull()) 6005 fileIcon = d->findIcon(32, QLatin1String("empty.png")); 6006 if (!fileIcon.isNull()) { 6007 QPainter painter(&fileIcon); 6008 painter.drawPixmap(0, 0, 32, 32, pixmap); 6009 icon.addPixmap(fileIcon); 6010 } 6011 } 6012 } 6013 break; 6014 case SP_DirLinkIcon: { 6015 icon = QIcon(standardPixmap(standardIcon, option, widget)); 6016 QPixmap pixmap = d->findIcon(32, QLatin1String("link_overlay.png")); 6017 if (!pixmap.isNull()) { 6018 QPixmap fileIcon = d->findIcon(32, QLatin1String("folder.png")); 6019 if (!fileIcon.isNull()) { 6020 QPainter painter(&fileIcon); 6021 painter.drawPixmap(0, 0, 32, 32, pixmap); 6022 icon.addPixmap(fileIcon); 6023 } 6024 } 5639 QIcon linkIcon = QIcon::fromTheme(QLatin1String("emblem-symbolic-link")); 5640 if (!linkIcon.isNull()) { 5641 QIcon baseIcon = standardIconImplementation(SP_DirIcon, option, widget); 5642 const QList<QSize> sizes = baseIcon.availableSizes(QIcon::Normal, QIcon::Off); 5643 for (int i = 0 ; i < sizes.size() ; ++i) { 5644 int size = sizes[i].width(); 5645 QPixmap basePixmap = baseIcon.pixmap(size); 5646 QPixmap linkPixmap = linkIcon.pixmap(size/2); 5647 QPainter painter(&basePixmap); 5648 painter.drawPixmap(size/2, size/2, linkPixmap); 5649 icon.addPixmap(basePixmap); 5650 } 5651 } 6025 5652 } 6026 5653 break; … … 6028 5655 break; 6029 5656 } 5657 } // if (QApplication::desktopSettingsAware() && !QIcon::themeName().isEmpty()) 6030 5658 if (!icon.isNull()) 6031 5659 return icon; 6032 } 6033 #endif//Q_WS_X11 5660 #if defined(Q_WS_MAC) 5661 if (QApplication::desktopSettingsAware()) { 5662 OSType iconType = 0; 5663 switch (standardIcon) { 5664 case QStyle::SP_MessageBoxQuestion: 5665 case QStyle::SP_MessageBoxInformation: 5666 case QStyle::SP_MessageBoxWarning: 5667 case QStyle::SP_MessageBoxCritical: 5668 iconType = kGenericApplicationIcon; 5669 break; 5670 case SP_DesktopIcon: 5671 iconType = kDesktopIcon; 5672 break; 5673 case SP_TrashIcon: 5674 iconType = kTrashIcon; 5675 break; 5676 case SP_ComputerIcon: 5677 iconType = kComputerIcon; 5678 break; 5679 case SP_DriveFDIcon: 5680 iconType = kGenericFloppyIcon; 5681 break; 5682 case SP_DriveHDIcon: 5683 iconType = kGenericHardDiskIcon; 5684 break; 5685 case SP_DriveCDIcon: 5686 case SP_DriveDVDIcon: 5687 iconType = kGenericCDROMIcon; 5688 break; 5689 case SP_DriveNetIcon: 5690 iconType = kGenericNetworkIcon; 5691 break; 5692 case SP_DirOpenIcon: 5693 iconType = kOpenFolderIcon; 5694 break; 5695 case SP_DirClosedIcon: 5696 case SP_DirLinkIcon: 5697 iconType = kGenericFolderIcon; 5698 break; 5699 case SP_FileLinkIcon: 5700 case SP_FileIcon: 5701 iconType = kGenericDocumentIcon; 5702 break; 5703 case SP_DirIcon: { 5704 // A rather special case 5705 QIcon closeIcon = QStyle::standardIcon(SP_DirClosedIcon, option, widget); 5706 QIcon openIcon = QStyle::standardIcon(SP_DirOpenIcon, option, widget); 5707 closeIcon.addPixmap(openIcon.pixmap(16, 16), QIcon::Normal, QIcon::On); 5708 closeIcon.addPixmap(openIcon.pixmap(32, 32), QIcon::Normal, QIcon::On); 5709 closeIcon.addPixmap(openIcon.pixmap(64, 64), QIcon::Normal, QIcon::On); 5710 closeIcon.addPixmap(openIcon.pixmap(128, 128), QIcon::Normal, QIcon::On); 5711 return closeIcon; 5712 } 5713 case SP_TitleBarNormalButton: 5714 case SP_TitleBarCloseButton: { 5715 QIcon titleBarIcon; 5716 if (standardIcon == SP_TitleBarCloseButton) { 5717 titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-16.png")); 5718 titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/closedock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); 5719 } else { 5720 titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-16.png")); 5721 titleBarIcon.addFile(QLatin1String(":/trolltech/styles/macstyle/images/dockdock-down-16.png"), QSize(16, 16), QIcon::Normal, QIcon::On); 5722 } 5723 return titleBarIcon; 5724 } 5725 default: 5726 break; 5727 } 5728 if (iconType != 0) { 5729 QIcon retIcon; 5730 IconRef icon; 5731 IconRef overlayIcon = 0; 5732 if (iconType != kGenericApplicationIcon) { 5733 GetIconRef(kOnSystemDisk, kSystemIconsCreator, iconType, &icon); 5734 } else { 5735 FSRef fsRef; 5736 ProcessSerialNumber psn = { 0, kCurrentProcess }; 5737 GetProcessBundleLocation(&psn, &fsRef); 5738 GetIconRefFromFileInfo(&fsRef, 0, 0, 0, 0, kIconServicesNormalUsageFlag, &icon, 0); 5739 if (standardIcon == SP_MessageBoxCritical) { 5740 overlayIcon = icon; 5741 GetIconRef(kOnSystemDisk, kSystemIconsCreator, kAlertCautionIcon, &icon); 5742 } 5743 } 5744 if (icon) { 5745 qt_mac_constructQIconFromIconRef(icon, overlayIcon, &retIcon, standardIcon); 5746 ReleaseIconRef(icon); 5747 } 5748 if (overlayIcon) 5749 ReleaseIconRef(overlayIcon); 5750 return retIcon; 5751 } 5752 } // if (QApplication::desktopSettingsAware()) 5753 #endif // Q_WS_MAC 6034 5754 6035 5755 switch (standardIcon) { … … 6120 5840 break; 6121 5841 case SP_ArrowForward: 6122 if ( QApplication::layoutDirection() == Qt::RightToLeft)5842 if (rtl) 6123 5843 return standardIconImplementation(SP_ArrowLeft, option, widget); 6124 5844 return standardIconImplementation(SP_ArrowRight, option, widget); 6125 5845 case SP_ArrowBack: 6126 if ( QApplication::layoutDirection() == Qt::RightToLeft)5846 if (rtl) 6127 5847 return standardIconImplementation(SP_ArrowRight, option, widget); 6128 5848 return standardIconImplementation(SP_ArrowLeft, option, widget); … … 6231 5951 #endif // QT_NO_IMAGEFORMAT_PNG 6232 5952 default: 6233 icon.addPixmap( standardPixmap(standardIcon, option, widget));5953 icon.addPixmap(proxy()->standardPixmap(standardIcon, option, widget)); 6234 5954 break; 6235 5955 }
Note:
See TracChangeset
for help on using the changeset viewer.