Changeset 561 for trunk/src/gui/styles/qcleanlooksstyle.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/qcleanlooksstyle.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 ** … … 45 45 #if !defined(QT_NO_STYLE_CLEANLOOKS) || defined(QT_PLUGIN) 46 46 47 #include <private/qstylehelper_p.h> 47 48 #include "qwindowsstyle_p.h" 48 49 #include <qcombobox.h> … … 73 74 QT_BEGIN_NAMESPACE 74 75 75 static const bool UsePixmapCache = true;76 using namespace QStyleHelper; 76 77 77 78 enum Direction { … … 84 85 // from windows style 85 86 static const int windowsItemFrame = 2; // menu item frame width 86 static const int windowsSepHeight = 6; // separator item height87 87 static const int windowsItemHMargin = 3; // menu item hor text margin 88 88 static const int windowsItemVMargin = 8; // menu item ver text margin 89 static const int windowsArrowHMargin = 6; // arrow horizontal margin90 static const int windowsTabSpacing = 12; // space between text and tab91 static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark92 89 static const int windowsRightBorder = 15; // right border on windows 93 static const int windowsCheckMarkWidth = 12; // checkmarks width on windows94 90 95 91 /* XPM */ … … 462 458 " "}; 463 459 464 #ifdef Q_WS_X11465 extern "C" {466 struct GConfClient;467 struct GError;468 typedef void (*Ptr_g_type_init)();469 typedef GConfClient* (*Ptr_gconf_client_get_default)();470 typedef char* (*Ptr_gconf_client_get_string)(GConfClient*, const char*, GError **);471 typedef void (*Ptr_g_object_unref)(void *);472 typedef void (*Ptr_g_error_free)(GError *);473 typedef void (*Ptr_g_free)(void*);474 }475 476 static Ptr_g_type_init p_g_type_init = 0;477 static Ptr_gconf_client_get_default p_gconf_client_get_default = 0;478 static Ptr_gconf_client_get_string p_gconf_client_get_string = 0;479 static Ptr_g_object_unref p_g_object_unref = 0;480 static Ptr_g_error_free p_g_error_free = 0;481 static Ptr_g_free p_g_free = 0;482 #endif483 484 460 static void qt_cleanlooks_draw_gradient(QPainter *painter, const QRect &rect, const QColor &gradientStart, 485 461 const QColor &gradientStop, Direction direction = TopDown, QBrush bgBrush = QBrush()) … … 542 518 else { 543 519 int size = horizontal ? rect.width() : rect.height() ; 544 if (size < 1)545 size = 1;546 float edge = 4.0/(float)size;547 gradient->setColorAt(0, gradientStart);548 gradient->setColorAt(edge, gradientMid.lighter(104));549 gradient->setColorAt(1.0 - edge, gradientMid.darker(100));550 gradient->setColorAt(1.0, gradientStop);520 if (size > 4) { 521 float edge = 4.0/(float)size; 522 gradient->setColorAt(0, gradientStart); 523 gradient->setColorAt(edge, gradientMid.lighter(104)); 524 gradient->setColorAt(1.0 - edge, gradientMid.darker(100)); 525 gradient->setColorAt(1.0, gradientStop); 526 } 551 527 } 552 528 painter->fillRect(rect, *gradient); 553 529 delete gradient; 554 }555 556 static QString uniqueName(const QString &key, const QStyleOption *option, const QSize &size)557 {558 QString tmp;559 const QStyleOptionComplex *complexOption = qstyleoption_cast<const QStyleOptionComplex *>(option);560 tmp.sprintf("%s-%d-%d-%lld-%dx%d-%d", key.toLatin1().constData(), uint(option->state),561 complexOption ? uint(complexOption->activeSubControls) : uint(0),562 option->palette.cacheKey(), size.width(), size.height(), option->direction);563 #ifndef QT_NO_SPINBOX564 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {565 tmp.append(QLatin1Char('-'));566 tmp.append(QString::number(spinBox->buttonSymbols));567 tmp.append(QLatin1Char('-'));568 tmp.append(QString::number(spinBox->stepEnabled));569 tmp.append(QLatin1Char('-'));570 tmp.append(QLatin1Char(spinBox->frame ? '1' : '0'));571 }572 #endif // QT_NO_SPINBOX573 return tmp;574 530 } 575 531 … … 606 562 607 563 painter->setPen(QPen(mdiButtonBorderColor, 1)); 608 painter->drawLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()); 609 painter->drawLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()); 610 painter->drawLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2); 611 painter->drawLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2); 612 painter->drawPoint(tmp.left() + 1, tmp.top() + 1); 613 painter->drawPoint(tmp.right() - 1, tmp.top() + 1); 614 painter->drawPoint(tmp.left() + 1, tmp.bottom() - 1); 615 painter->drawPoint(tmp.right() - 1, tmp.bottom() - 1); 564 const QLine lines[4] = { 565 QLine(tmp.left() + 2, tmp.top(), tmp.right() - 2, tmp.top()), 566 QLine(tmp.left() + 2, tmp.bottom(), tmp.right() - 2, tmp.bottom()), 567 QLine(tmp.left(), tmp.top() + 2, tmp.left(), tmp.bottom() - 2), 568 QLine(tmp.right(), tmp.top() + 2, tmp.right(), tmp.bottom() - 2) 569 }; 570 painter->drawLines(lines, 4); 571 const QPoint points[4] = { 572 QPoint(tmp.left() + 1, tmp.top() + 1), 573 QPoint(tmp.right() - 1, tmp.top() + 1), 574 QPoint(tmp.left() + 1, tmp.bottom() - 1), 575 QPoint(tmp.right() - 1, tmp.bottom() - 1) 576 }; 577 painter->drawPoints(points, 4); 616 578 617 579 painter->setPen(titleBarHighlight); … … 783 745 button.QStyleOption::operator=(*option); 784 746 button.state &= ~State_MouseOver; 785 drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget);747 proxy()->drawPrimitive(PE_IndicatorCheckBox, &button, painter, widget); 786 748 } 787 749 return; … … 803 765 break; 804 766 case PE_IndicatorButtonDropDown: 805 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);767 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 806 768 break; 807 769 case PE_IndicatorToolBarSeparator: … … 888 850 if (widget && widget->inherits("QDockWidgetTitleButton")) { 889 851 if (option->state & State_MouseOver) 890 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);852 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 891 853 } else { 892 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);854 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 893 855 } 894 856 } … … 903 865 else 904 866 dockWidgetHandle.state |= State_Horizontal; 905 drawControl(CE_Splitter, &dockWidgetHandle, painter, widget);867 proxy()->drawControl(CE_Splitter, &dockWidgetHandle, painter, widget); 906 868 } 907 869 break; … … 929 891 #ifdef QT3_SUPPORT 930 892 if (widget && widget->inherits("Q3ToolBar")) { 931 drawPrimitive(PE_Q3Separator, option, painter, widget);893 proxy()->drawPrimitive(PE_Q3Separator, option, painter, widget); 932 894 break; 933 895 } … … 945 907 painter->setPen(buttonShadowAlpha); 946 908 painter->drawLine(QPoint(r.left() + 2, r.top() - 1), QPoint(r.right() - 2, r.top() - 1)); 947 painter->drawPoint(r.right() - 1, r.top()); 948 painter->drawPoint(r.right(), r.top() + 1); 949 painter->drawPoint(r.right() - 1, r.bottom()); 950 painter->drawPoint(r.right(), r.bottom() - 1); 951 painter->drawPoint(r.left() + 1, r.top() ); 952 painter->drawPoint(r.left(), r.top() + 1); 953 painter->drawPoint(r.left() + 1, r.bottom() ); 954 painter->drawPoint(r.left(), r.bottom() - 1); 909 const QPoint points[8] = { 910 QPoint(r.right() - 1, r.top()), 911 QPoint(r.right(), r.top() + 1), 912 QPoint(r.right() - 1, r.bottom()), 913 QPoint(r.right(), r.bottom() - 1), 914 QPoint(r.left() + 1, r.top() ), 915 QPoint(r.left(), r.top() + 1), 916 QPoint(r.left() + 1, r.bottom() ), 917 QPoint(r.left(), r.bottom() - 1) 918 }; 919 painter->drawPoints(points, 8); 955 920 painter->setPen(QPen(option->palette.background().color(), 1)); 956 921 painter->drawLine(QPoint(r.left() + 2, r.top() + 1), QPoint(r.right() - 2, r.top() + 1)); … … 984 949 painter->drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); 985 950 painter->drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right() - 2, r.bottom())); 986 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 987 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); 988 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 989 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); 951 const QPoint points2[4] = { 952 QPoint(r.right() - 1, r.bottom() - 1), 953 QPoint(r.right() - 1, r.top() + 1), 954 QPoint(r.left() + 1, r.bottom() - 1), 955 QPoint(r.left() + 1, r.top() + 1) 956 }; 957 painter->drawPoints(points2, 4); 990 958 painter->drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); 991 959 painter->setPen(oldPen); … … 1085 1053 painter->setBrushOrigin(rect.topLeft()); 1086 1054 painter->setPen(Qt::NoPen); 1087 painter->drawRect(rect.left(), rect.top(), rect.width(), 1); // Top 1088 painter->drawRect(rect.left(), rect.bottom(), rect.width(), 1); // Bottom 1089 painter->drawRect(rect.left(), rect.top(), 1, rect.height()); // Left 1090 painter->drawRect(rect.right(), rect.top(), 1, rect.height()); // Right 1055 const QRect rects[4] = { 1056 QRect(rect.left(), rect.top(), rect.width(), 1), // Top 1057 QRect(rect.left(), rect.bottom(), rect.width(), 1), // Bottom 1058 QRect(rect.left(), rect.top(), 1, rect.height()), // Left 1059 QRect(rect.right(), rect.top(), 1, rect.height()) // Right 1060 }; 1061 painter->drawRects(rects, 4); 1091 1062 painter->restore(); 1092 1063 } … … 1110 1081 r = option->rect.adjusted(0, 1, 0, -1); 1111 1082 painter->setPen(QPen(Qt::black, 0)); 1112 painter->drawLine(QPoint(r.left() + 2, r.top()), 1113 QPoint(r.right() - 2, r.top())); 1114 painter->drawLine(QPoint(r.left(), r.top() + 2), 1115 QPoint(r.left(), r.bottom() - 2)); 1116 painter->drawLine(QPoint(r.right(), r.top() + 2), 1117 QPoint(r.right(), r.bottom() - 2)); 1118 painter->drawLine(QPoint(r.left() + 2, r.bottom()), 1119 QPoint(r.right() - 2, r.bottom())); 1120 painter->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 1121 painter->drawPoint(QPoint(r.right() - 1, r.top() + 1)); 1122 painter->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 1123 painter->drawPoint(QPoint(r.left() + 1, r.top() + 1)); 1083 const QLine lines[4] = { 1084 QLine(QPoint(r.left() + 2, r.top()), 1085 QPoint(r.right() - 2, r.top())), 1086 QLine(QPoint(r.left(), r.top() + 2), 1087 QPoint(r.left(), r.bottom() - 2)), 1088 QLine(QPoint(r.right(), r.top() + 2), 1089 QPoint(r.right(), r.bottom() - 2)), 1090 QLine(QPoint(r.left() + 2, r.bottom()), 1091 QPoint(r.right() - 2, r.bottom())) 1092 }; 1093 painter->drawLines(lines, 4); 1094 const QPoint points[4] = { 1095 QPoint(r.right() - 1, r.bottom() - 1), 1096 QPoint(r.right() - 1, r.top() + 1), 1097 QPoint(r.left() + 1, r.bottom() - 1), 1098 QPoint(r.left() + 1, r.top() + 1) 1099 }; 1100 painter->drawPoints(points, 4); 1124 1101 painter->setPen(oldPen); 1125 1102 } … … 1185 1162 p->drawLine(QPoint(r.left() + 2, r.bottom()), 1186 1163 QPoint(r.right() - 2, r.bottom())); 1187 p->drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 1188 p->drawPoint(QPoint(r.right() - 1, r.top() + 1)); 1189 p->drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 1190 p->drawPoint(QPoint(r.left() + 1, r.top() + 1)); 1164 const QPoint points[4] = { 1165 QPoint(r.right() - 1, r.bottom() - 1), 1166 QPoint(r.right() - 1, r.top() + 1), 1167 QPoint(r.left() + 1, r.bottom() - 1), 1168 QPoint(r.left() + 1, r.top() + 1) 1169 }; 1170 p->drawPoints(points, 4); 1191 1171 1192 1172 if (!isDefault && !hasFocus && isEnabled) … … 1208 1188 1209 1189 p->setPen(topShadow); 1210 p->drawPoint(QPoint(r.right(), r.top() + 1)); 1211 p->drawPoint(QPoint(r.right() - 1, r.top() )); 1212 p->drawPoint(QPoint(r.right(), r.bottom() - 1)); 1213 p->drawPoint(QPoint(r.right() - 1, r.bottom() )); 1214 p->drawPoint(QPoint(r.left() + 1, r.bottom())); 1215 p->drawPoint(QPoint(r.left(), r.bottom() - 1)); 1216 p->drawPoint(QPoint(r.left() + 1, r.top())); 1217 p->drawPoint(QPoint(r.left(), r.top() + 1)); 1190 const QPoint points2[8] = { 1191 QPoint(r.right(), r.top() + 1), 1192 QPoint(r.right() - 1, r.top() ), 1193 QPoint(r.right(), r.bottom() - 1), 1194 QPoint(r.right() - 1, r.bottom() ), 1195 QPoint(r.left() + 1, r.bottom()), 1196 QPoint(r.left(), r.bottom() - 1), 1197 QPoint(r.left() + 1, r.top()), 1198 QPoint(r.left(), r.top() + 1) 1199 }; 1200 p->drawPoints(points2, 8); 1218 1201 1219 1202 topShadow.setAlpha(30); … … 1228 1211 r.adjust(-1, -1, 1, 1); 1229 1212 p->setPen(buttonShadowAlpha.darker(120)); 1230 p->drawLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)); 1231 p->drawLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)); 1232 p->drawLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)); 1233 p->drawLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)); 1234 p->drawPoint(r.topRight() + QPoint(-2, 1)); 1235 p->drawPoint(r.topRight() + QPoint(-1, 2)); 1236 p->drawPoint(r.bottomRight() + QPoint(-1, -2)); 1237 p->drawPoint(r.bottomRight() + QPoint(-2, -1)); 1238 p->drawPoint(r.topLeft() + QPoint(1, 2)); 1239 p->drawPoint(r.topLeft() + QPoint(2, 1)); 1240 p->drawPoint(r.bottomLeft() + QPoint(1, -2)); 1241 p->drawPoint(r.bottomLeft() + QPoint(2, -1)); 1213 const QLine lines[4] = { 1214 QLine(r.topLeft() + QPoint(3, 0), r.topRight() - QPoint(3, 0)), 1215 QLine(r.bottomLeft() + QPoint(3, 0), r.bottomRight() - QPoint(3, 0)), 1216 QLine(r.topLeft() + QPoint(0, 3), r.bottomLeft() - QPoint(0, 3)), 1217 QLine(r.topRight() + QPoint(0, 3), r.bottomRight() - QPoint(0, 3)) 1218 }; 1219 p->drawLines(lines, 4); 1220 const QPoint points3[8] = { 1221 r.topRight() + QPoint(-2, 1), 1222 r.topRight() + QPoint(-1, 2), 1223 r.bottomRight() + QPoint(-1, -2), 1224 r.bottomRight() + QPoint(-2, -1), 1225 r.topLeft() + QPoint(1, 2), 1226 r.topLeft() + QPoint(2, 1), 1227 r.bottomLeft() + QPoint(1, -2), 1228 r.bottomLeft() + QPoint(2, -1) 1229 }; 1230 p->drawPoints(points3, 8); 1242 1231 } 1243 1232 painter->setPen(oldPen); … … 1258 1247 QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); 1259 1248 1260 int borderThickness = p ixelMetric(PM_TabBarBaseOverlap, twf, widget);1249 int borderThickness = proxy()->pixelMetric(PM_TabBarBaseOverlap, twf, widget); 1261 1250 bool reverse = (twf->direction == Qt::RightToLeft); 1262 1251 QRect tabBarRect; … … 1352 1341 1353 1342 painter->setPen(alphaCornerColor); 1354 painter->drawPoint(leftBottomInnerCorner1); 1355 painter->drawPoint(leftBottomInnerCorner2); 1356 painter->drawPoint(rightBottomInnerCorner1); 1357 painter->drawPoint(rightBottomInnerCorner2); 1358 painter->drawPoint(leftTopInnerCorner1); 1359 painter->drawPoint(leftTopInnerCorner2); 1343 const QPoint points[6] = { 1344 leftBottomInnerCorner1, 1345 leftBottomInnerCorner2, 1346 rightBottomInnerCorner1, 1347 rightBottomInnerCorner2, 1348 leftTopInnerCorner1, 1349 leftTopInnerCorner2 1350 }; 1351 painter->drawPoints(points, 6); 1360 1352 } 1361 1353 #endif // QT_NO_TABWIDGET … … 1371 1363 d->tabBarcloseButtonIcon = standardIcon(SP_DialogCloseButton, option, widget); 1372 1364 if ((option->state & State_Enabled) && (option->state & State_MouseOver)) 1373 drawPrimitive(PE_PanelButtonCommand, option, painter, widget);1365 proxy()->drawPrimitive(PE_PanelButtonCommand, option, painter, widget); 1374 1366 QPixmap pixmap = d->tabBarcloseButtonIcon.pixmap(QSize(16, 16), QIcon::Normal, QIcon::On); 1375 drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap);1367 proxy()->drawItemPixmap(painter, option->rect, Qt::AlignCenter, pixmap); 1376 1368 } 1377 1369 break; … … 1544 1536 break; 1545 1537 } 1546 if ( QApplication::layoutDirection()== Qt::RightToLeft) { //reverse layout changes the order of Beginning/end1538 if (toolbar->direction == Qt::RightToLeft) { //reverse layout changes the order of Beginning/end 1547 1539 bool tmp = paintLeftBorder; 1548 1540 paintRightBorder=paintLeftBorder; … … 1650 1642 = painter->fontMetrics().elidedText(dwOpt->title, 1651 1643 Qt::ElideRight, titleRect.width()); 1652 drawItemText(painter,1644 proxy()->drawItemText(painter, 1653 1645 titleRect, 1654 1646 Qt::AlignLeft | Qt::AlignVCenter | Qt::TextShowMnemonic, dwOpt->palette, … … 1665 1657 if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { 1666 1658 QPixmap cache; 1667 QString pixmapName = uniqueName(QLatin1String("headersection"), option, option->rect.size());1668 pixmapName += Q Latin1String("-") + QString::number(int(header->position));1669 pixmapName += Q Latin1String("-") + QString::number(int(header->orientation));1659 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("headersection"), option, option->rect.size()); 1660 pixmapName += QString::number(- int(header->position)); 1661 pixmapName += QString::number(- int(header->orientation)); 1670 1662 QRect r = option->rect; 1671 1663 QColor gradientStopColor; … … 1684 1676 painter->fillRect(r, gradient); 1685 1677 1686 if (! UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {1678 if (!QPixmapCache::find(pixmapName, cache)) { 1687 1679 cache = QPixmap(r.size()); 1688 1680 cache.fill(Qt::transparent); … … 1703 1695 cachePainter.drawLine(pixmapRect.topRight() + QPoint(0, 3), pixmapRect.bottomRight() + QPoint(0, -3)); } 1704 1696 cachePainter.end(); 1705 if (UsePixmapCache) 1706 QPixmapCache::insert(pixmapName, cache); 1697 QPixmapCache::insert(pixmapName, cache); 1707 1698 } 1708 1699 painter->drawPixmap(r.topLeft(), cache); … … 1716 1707 QColor borderColor = dark.lighter(110); 1717 1708 painter->setPen(QPen(borderColor, 0)); 1718 painter->drawLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())); 1719 painter->drawLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())); 1720 painter->drawLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)); 1721 painter->drawLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)); 1709 const QLine lines[4] = { 1710 QLine(QPoint(rect.left() + 1, rect.top()), QPoint(rect.right() - 1, rect.top())), 1711 QLine(QPoint(rect.left() + 1, rect.bottom()), QPoint(rect.right() - 1, rect.bottom())), 1712 QLine(QPoint(rect.left(), rect.top() + 1), QPoint(rect.left(), rect.bottom() - 1)), 1713 QLine(QPoint(rect.right(), rect.top() + 1), QPoint(rect.right(), rect.bottom() - 1)) 1714 }; 1715 painter->drawLines(lines, 4); 1722 1716 QColor alphaCorner = mergedColors(borderColor, option->palette.background().color()); 1723 1717 QColor innerShadow = mergedColors(borderColor, option->palette.base().color()); … … 1725 1719 //corner smoothing 1726 1720 painter->setPen(alphaCorner); 1727 painter->drawPoint(rect.topRight()); 1728 painter->drawPoint(rect.topLeft()); 1729 painter->drawPoint(rect.bottomRight()); 1730 painter->drawPoint(rect.bottomLeft()); 1721 const QPoint points[4] = { 1722 rect.topRight(), 1723 rect.topLeft(), 1724 rect.bottomRight(), 1725 rect.bottomLeft() 1726 }; 1727 painter->drawPoints(points, 4); 1731 1728 1732 1729 //inner shadow … … 1759 1756 if (vertical) { 1760 1757 rect = QRect(rect.left(), rect.top(), rect.height(), rect.width()); // flip width and height 1761 QTransform m; 1762 m.translate(rect.height()-1, -1.0); 1758 QTransform m = QTransform::fromTranslate(rect.height()-1, -1.0); 1763 1759 m.rotate(90.0); 1764 1760 painter->setTransform(m, true); … … 1767 1763 int maxWidth = rect.width() - 4; 1768 1764 int minWidth = 4; 1769 qint64 progress = (qint64)qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar 1770 double vc6_workaround = ((progress - qint64(bar->minimum)) / qMax(double(1.0), double(qint64(bar->maximum) - qint64(bar->minimum))) * maxWidth); 1771 int progressBarWidth = (int(vc6_workaround) > minWidth ) ? int(vc6_workaround) : minWidth; 1772 int width = indeterminate ? maxWidth : progressBarWidth; 1765 qreal progress = qMax(bar->progress, bar->minimum); // workaround for bug in QProgressBar 1766 int progressBarWidth = (progress - bar->minimum) * qreal(maxWidth) / qMax(qreal(1.0), qreal(bar->maximum) - bar->minimum); 1767 int width = indeterminate ? maxWidth : qMax(minWidth, progressBarWidth); 1773 1768 1774 1769 bool reverse = (!vertical && (bar->direction == Qt::RightToLeft)) || vertical; … … 1855 1850 1856 1851 painter->setPen(QPen(highlightOutline, 0)); 1857 painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())); 1858 painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())); 1859 painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); 1860 painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); 1852 const QLine lines[4] = { 1853 QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom())), 1854 QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom())), 1855 QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), 1856 QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) 1857 }; 1858 painter->drawLines(lines, 4); 1861 1859 1862 1860 //draw text … … 1865 1863 if (!styleHint(SH_UnderlineShortcut, mbi, widget)) 1866 1864 alignment |= Qt::TextHideMnemonic; 1867 drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole);1865 proxy()->drawItemText(painter, item.rect, alignment, mbi->palette, mbi->state & State_Enabled, mbi->text, textRole); 1868 1866 } 1869 1867 … … 1892 1890 if (!menuItem->text.isEmpty()) { 1893 1891 painter->setFont(menuItem->font); 1894 drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,1892 proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, 1895 1893 menuItem->palette, menuItem->state & State_Enabled, menuItem->text, 1896 1894 QPalette::Text); … … 1912 1910 r = r.adjusted(-1, 0, 1, 0); 1913 1911 painter->setPen(QPen(highlightOutline, 0)); 1914 painter->drawLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)); 1915 painter->drawLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)); 1916 painter->drawLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())); 1917 painter->drawLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())); 1912 const QLine lines[4] = { 1913 QLine(QPoint(r.left(), r.top() + 1), QPoint(r.left(), r.bottom() - 1)), 1914 QLine(QPoint(r.right(), r.top() + 1), QPoint(r.right(), r.bottom() - 1)), 1915 QLine(QPoint(r.left() + 1, r.bottom()), QPoint(r.right() - 1, r.bottom())), 1916 QLine(QPoint(r.left() + 1, r.top()), QPoint(r.right() - 1, r.top())) 1917 }; 1918 painter->drawLines(lines, 4); 1918 1919 } else { 1919 1920 painter->fillRect(option->rect, menuBackground); … … 1996 1997 QPixmap pixmap; 1997 1998 1998 int smallIconSize = p ixelMetric(PM_SmallIconSize, option, widget);1999 int smallIconSize = proxy()->pixelMetric(PM_SmallIconSize, option, widget); 1999 2000 QSize iconSize(smallIconSize, smallIconSize); 2000 2001 #ifndef QT_NO_COMBOBOX … … 2022 2023 opt.state |= State_Sunken; 2023 2024 opt.rect = vCheckRect; 2024 drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget);2025 proxy()->drawPrimitive(PE_PanelButtonCommand, &opt, painter, widget); 2025 2026 } 2026 2027 painter->drawPixmap(pmr.topLeft(), pixmap); … … 2055 2056 QRect vShortcutRect = visualRect(opt->direction, menuitem->rect, 2056 2057 QRect(textRect.topRight(), QPoint(menuitem->rect.right(), textRect.bottom()))); 2057 if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {2058 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { 2058 2059 p->setPen(menuitem->palette.light().color()); 2059 2060 p->drawText(vShortcutRect.adjusted(1, 1, 1, 1), text_flags, s.mid(t + 1)); … … 2064 2065 } 2065 2066 QFont font = menuitem->font; 2067 // font may not have any "hard" flags set. We override 2068 // the point size so that when it is resolved against the device, this font will win. 2069 // This is mainly to handle cases where someone sets the font on the window 2070 // and then the combo inherits it and passes it onward. At that point the resolve mask 2071 // is very, very weak. This makes it stonger. 2072 font.setPointSizeF(QFontInfo(menuItem->font).pointSizeF()); 2066 2073 2067 2074 if (menuitem->menuItemType == QStyleOptionMenuItem::DefaultItem) … … 2069 2076 2070 2077 p->setFont(font); 2071 if (dis && !act && styleHint(SH_EtchDisabledText, option, widget)) {2078 if (dis && !act && proxy()->styleHint(SH_EtchDisabledText, option, widget)) { 2072 2079 p->setPen(menuitem->palette.light().color()); 2073 2080 p->drawText(vTextRect.adjusted(1, 1, 1, 1), text_flags, s.left(t)); … … 2092 2099 newMI.palette.setColor(QPalette::ButtonText, 2093 2100 newMI.palette.highlightedText().color()); 2094 drawPrimitive(arrow, &newMI, painter, widget);2101 proxy()->drawPrimitive(arrow, &newMI, painter, widget); 2095 2102 } 2096 2103 } … … 2153 2160 if (button->features & QStyleOptionButton::HasMenu) 2154 2161 ir = ir.adjusted(0, 0, -pixelMetric(PM_MenuButtonIndicator, button, widget), 0); 2155 drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled),2162 proxy()->drawItemText(painter, ir, tf, button->palette, (button->state & State_Enabled), 2156 2163 button->text, QPalette::ButtonText); 2157 2164 } … … 2208 2215 && tab->selectedPosition 2209 2216 == QStyleOptionTab::PreviousIsSelected)); 2210 int tabBarAlignment = styleHint(SH_TabBar_Alignment, tab, widget);2217 int tabBarAlignment = proxy()->styleHint(SH_TabBar_Alignment, tab, widget); 2211 2218 bool leftAligned = (!rtlHorTabs && tabBarAlignment == Qt::AlignLeft) 2212 2219 || (rtlHorTabs … … 2221 2228 2222 2229 QColor background = tab->palette.background().color(); 2223 int borderThinkness = p ixelMetric(PM_TabBarBaseOverlap, tab, widget);2230 int borderThinkness = proxy()->pixelMetric(PM_TabBarBaseOverlap, tab, widget); 2224 2231 if (selected) 2225 2232 borderThinkness /= 2; … … 2457 2464 if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { 2458 2465 QPixmap cache; 2459 QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());2460 if (! UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {2466 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); 2467 if (!QPixmapCache::find(pixmapName, cache)) { 2461 2468 cache = QPixmap(spinBox->rect.size()); 2462 2469 cache.fill(Qt::transparent); … … 2474 2481 QStyleOptionSpinBox spinBoxCopy = *spinBox; 2475 2482 spinBoxCopy.rect = pixmapRect; 2476 QRect upRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget);2477 QRect downRect = subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget);2478 2479 int fw = spinBoxCopy.frame ? p ixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0;2483 QRect upRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxUp, widget); 2484 QRect downRect = proxy()->subControlRect(CC_SpinBox, &spinBoxCopy, SC_SpinBoxDown, widget); 2485 2486 int fw = spinBoxCopy.frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, &spinBoxCopy, widget) : 0; 2480 2487 cachePainter.fillRect(rect.adjusted(1, qMax(fw - 1, 0), -1, -fw), 2481 2488 option->palette.base()); … … 2489 2496 2490 2497 // antialias corners 2491 cachePainter.drawPoint(QPoint(r.right(), r.top() + 1)); 2492 cachePainter.drawPoint(QPoint(r.right() - 1, r.top() )); 2493 cachePainter.drawPoint(QPoint(r.right(), r.bottom() - 1)); 2494 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() )); 2495 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom())); 2496 cachePainter.drawPoint(QPoint(r.left(), r.bottom() - 1)); 2497 cachePainter.drawPoint(QPoint(r.left() + 1, r.top())); 2498 cachePainter.drawPoint(QPoint(r.left(), r.top() + 1)); 2498 const QPoint points[8] = { 2499 QPoint(r.right(), r.top() + 1), 2500 QPoint(r.right() - 1, r.top() ), 2501 QPoint(r.right(), r.bottom() - 1), 2502 QPoint(r.right() - 1, r.bottom() ), 2503 QPoint(r.left() + 1, r.bottom()), 2504 QPoint(r.left(), r.bottom() - 1), 2505 QPoint(r.left() + 1, r.top()), 2506 QPoint(r.left(), r.top() + 1) 2507 }; 2508 cachePainter.drawPoints(points, 8); 2499 2509 2500 2510 // draw frame … … 2524 2534 2525 2535 // top and bottom lines 2526 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())); 2527 cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())); 2528 cachePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)); 2529 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 2536 const QLine lines[4] = { 2537 QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- 2, r.bottom())), 2538 QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - 2, r.top())), 2539 QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right(), r.bottom() - 2)), 2540 QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) 2541 }; 2542 cachePainter.drawLines(lines, 4); 2530 2543 } 2531 2544 … … 2561 2574 if (spinBox->frame) { 2562 2575 // rounded corners 2563 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 2564 cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); 2565 cachePainter.drawPoint(QPoint(r.right() - 1, r.bottom() - 1)); 2566 cachePainter.drawPoint(QPoint(r.right() - 1, r.top() + 1)); 2576 const QPoint points[4] = { 2577 QPoint(r.left() + 1, r.bottom() - 1), 2578 QPoint(r.left() + 1, r.top() + 1), 2579 QPoint(r.right() - 1, r.bottom() - 1), 2580 QPoint(r.right() - 1, r.top() + 1) 2581 }; 2582 cachePainter.drawPoints(points, 4); 2567 2583 2568 2584 if (option->state & State_HasFocus) { … … 2573 2589 cachePainter.drawRect(rect.adjusted(1, 2, -3 -downRect.width(), -3)); 2574 2590 cachePainter.setPen(QPen(darkoutline, 0)); 2575 cachePainter.drawLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())); 2576 cachePainter.drawLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())); 2577 cachePainter.drawLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)); 2578 cachePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)); 2591 const QLine lines[4] = { 2592 QLine(QPoint(r.left() + 2, r.bottom()), QPoint(r.right()- downRect.width() - 1, r.bottom())), 2593 QLine(QPoint(r.left() + 2, r.top()), QPoint(r.right() - downRect.width() - 1, r.top())), 2594 QLine(QPoint(r.right() - downRect.width() - 1, r.top() + 1), QPoint(r.right()- downRect.width() - 1, r.bottom() - 1)), 2595 QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left(), r.bottom() - 2)) 2596 }; 2597 cachePainter.drawLines(lines, 4); 2579 2598 cachePainter.drawPoint(QPoint(r.left() + 1, r.bottom() - 1)); 2580 2599 cachePainter.drawPoint(QPoint(r.left() + 1, r.top() + 1)); … … 2675 2694 } 2676 2695 cachePainter.end(); 2677 if (UsePixmapCache) 2678 QPixmapCache::insert(pixmapName, cache); 2696 QPixmapCache::insert(pixmapName, cache); 2679 2697 } 2680 2698 painter->drawPixmap(spinBox->rect.topLeft(), cache); … … 2700 2718 QStyleOptionDockWidgetV2 dockwidget; 2701 2719 dockwidget.QStyleOption::operator=(*option); 2702 drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget);2720 proxy()->drawControl(CE_DockWidgetTitle, &dockwidget, painter, widget); 2703 2721 } else 2704 2722 #endif // QT3_SUPPORT … … 2722 2740 painter->drawLine(fullRect.left() + 5, fullRect.top(), fullRect.right() - 5, fullRect.top()); 2723 2741 painter->drawLine(fullRect.left(), fullRect.top() + 4, fullRect.left(), fullRect.bottom()); 2724 painter->drawPoint(fullRect.left() + 4, fullRect.top() + 1); 2725 painter->drawPoint(fullRect.left() + 3, fullRect.top() + 1); 2726 painter->drawPoint(fullRect.left() + 2, fullRect.top() + 2); 2727 painter->drawPoint(fullRect.left() + 1, fullRect.top() + 3); 2728 painter->drawPoint(fullRect.left() + 1, fullRect.top() + 4); 2742 const QPoint points[5] = { 2743 QPoint(fullRect.left() + 4, fullRect.top() + 1), 2744 QPoint(fullRect.left() + 3, fullRect.top() + 1), 2745 QPoint(fullRect.left() + 2, fullRect.top() + 2), 2746 QPoint(fullRect.left() + 1, fullRect.top() + 3), 2747 QPoint(fullRect.left() + 1, fullRect.top() + 4) 2748 }; 2749 painter->drawPoints(points, 5); 2729 2750 2730 2751 painter->drawLine(fullRect.right(), fullRect.top() + 4, fullRect.right(), fullRect.bottom()); 2731 painter->drawPoint(fullRect.right() - 3, fullRect.top() + 1); 2732 painter->drawPoint(fullRect.right() - 4, fullRect.top() + 1); 2733 painter->drawPoint(fullRect.right() - 2, fullRect.top() + 2); 2734 painter->drawPoint(fullRect.right() - 1, fullRect.top() + 3); 2735 painter->drawPoint(fullRect.right() - 1, fullRect.top() + 4); 2752 const QPoint points2[5] = { 2753 QPoint(fullRect.right() - 3, fullRect.top() + 1), 2754 QPoint(fullRect.right() - 4, fullRect.top() + 1), 2755 QPoint(fullRect.right() - 2, fullRect.top() + 2), 2756 QPoint(fullRect.right() - 1, fullRect.top() + 3), 2757 QPoint(fullRect.right() - 1, fullRect.top() + 4) 2758 }; 2759 painter->drawPoints(points2, 5); 2736 2760 2737 2761 // draw bottomline … … 2743 2767 } 2744 2768 // draw title 2745 QRect textRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget);2769 QRect textRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarLabel, widget); 2746 2770 QFont font = painter->font(); 2747 2771 font.setBold(true); … … 2758 2782 if ((titleBar->subControls & SC_TitleBarMinButton) && (titleBar->titleBarFlags & Qt::WindowMinimizeButtonHint) && 2759 2783 !(titleBar->titleBarState& Qt::WindowMinimized)) { 2760 QRect minButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget);2784 QRect minButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMinButton, widget); 2761 2785 if (minButtonRect.isValid()) { 2762 2786 bool hover = (titleBar->activeSubControls & SC_TitleBarMinButton) && (titleBar->state & State_MouseOver); … … 2779 2803 if ((titleBar->subControls & SC_TitleBarMaxButton) && (titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && 2780 2804 !(titleBar->titleBarState & Qt::WindowMaximized)) { 2781 QRect maxButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget);2805 QRect maxButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarMaxButton, widget); 2782 2806 if (maxButtonRect.isValid()) { 2783 2807 bool hover = (titleBar->activeSubControls & SC_TitleBarMaxButton) && (titleBar->state & State_MouseOver); … … 2792 2816 maxButtonIconRect.right() - 1, maxButtonIconRect.top() + 1); 2793 2817 painter->setPen(textAlphaColor); 2794 painter->drawPoint(maxButtonIconRect.topLeft()); 2795 painter->drawPoint(maxButtonIconRect.topRight()); 2796 painter->drawPoint(maxButtonIconRect.bottomLeft()); 2797 painter->drawPoint(maxButtonIconRect.bottomRight()); 2818 const QPoint points[4] = { 2819 maxButtonIconRect.topLeft(), 2820 maxButtonIconRect.topRight(), 2821 maxButtonIconRect.bottomLeft(), 2822 maxButtonIconRect.bottomRight() 2823 }; 2824 painter->drawPoints(points, 4); 2798 2825 } 2799 2826 } … … 2801 2828 // close button 2802 2829 if ((titleBar->subControls & SC_TitleBarCloseButton) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { 2803 QRect closeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget);2830 QRect closeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarCloseButton, widget); 2804 2831 if (closeButtonRect.isValid()) { 2805 2832 bool hover = (titleBar->activeSubControls & SC_TitleBarCloseButton) && (titleBar->state & State_MouseOver); … … 2808 2835 QRect closeIconRect = closeButtonRect.adjusted(buttonMargin, buttonMargin, -buttonMargin, -buttonMargin); 2809 2836 painter->setPen(textAlphaColor); 2810 painter->drawLine(closeIconRect.left() + 1, closeIconRect.top(), 2811 closeIconRect.right(), closeIconRect.bottom() - 1); 2812 painter->drawLine(closeIconRect.left(), closeIconRect.top() + 1, 2813 closeIconRect.right() - 1, closeIconRect.bottom()); 2814 painter->drawLine(closeIconRect.right() - 1, closeIconRect.top(), 2815 closeIconRect.left(), closeIconRect.bottom() - 1); 2816 painter->drawLine(closeIconRect.right(), closeIconRect.top() + 1, 2817 closeIconRect.left() + 1, closeIconRect.bottom()); 2818 painter->drawPoint(closeIconRect.topLeft()); 2819 painter->drawPoint(closeIconRect.topRight()); 2820 painter->drawPoint(closeIconRect.bottomLeft()); 2821 painter->drawPoint(closeIconRect.bottomRight()); 2837 const QLine lines[4] = { 2838 QLine(closeIconRect.left() + 1, closeIconRect.top(), 2839 closeIconRect.right(), closeIconRect.bottom() - 1), 2840 QLine(closeIconRect.left(), closeIconRect.top() + 1, 2841 closeIconRect.right() - 1, closeIconRect.bottom()), 2842 QLine(closeIconRect.right() - 1, closeIconRect.top(), 2843 closeIconRect.left(), closeIconRect.bottom() - 1), 2844 QLine(closeIconRect.right(), closeIconRect.top() + 1, 2845 closeIconRect.left() + 1, closeIconRect.bottom()) 2846 }; 2847 painter->drawLines(lines, 4); 2848 const QPoint points[4] = { 2849 closeIconRect.topLeft(), 2850 closeIconRect.topRight(), 2851 closeIconRect.bottomLeft(), 2852 closeIconRect.bottomRight() 2853 }; 2854 painter->drawPoints(points, 4); 2822 2855 2823 2856 painter->setPen(textColor); … … 2835 2868 ((titleBar->titleBarFlags & Qt::WindowMaximizeButtonHint) && 2836 2869 (titleBar->titleBarState & Qt::WindowMaximized)))) { 2837 QRect normalButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget);2870 QRect normalButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarNormalButton, widget); 2838 2871 if (normalButtonRect.isValid()) { 2839 2872 … … 2849 2882 frontWindowRect.right() - 1, frontWindowRect.top() + 1); 2850 2883 painter->setPen(textAlphaColor); 2851 painter->drawPoint(frontWindowRect.topLeft()); 2852 painter->drawPoint(frontWindowRect.topRight()); 2853 painter->drawPoint(frontWindowRect.bottomLeft()); 2854 painter->drawPoint(frontWindowRect.bottomRight()); 2884 const QPoint points[4] = { 2885 frontWindowRect.topLeft(), 2886 frontWindowRect.topRight(), 2887 frontWindowRect.bottomLeft(), 2888 frontWindowRect.bottomRight() 2889 }; 2890 painter->drawPoints(points, 4); 2855 2891 2856 2892 QRect backWindowRect = normalButtonIconRect.adjusted(3, 0, 0, -3); … … 2864 2900 backWindowRect.right() - 1, backWindowRect.top() + 1); 2865 2901 painter->setPen(textAlphaColor); 2866 painter->drawPoint(backWindowRect.topLeft()); 2867 painter->drawPoint(backWindowRect.topRight()); 2868 painter->drawPoint(backWindowRect.bottomLeft()); 2869 painter->drawPoint(backWindowRect.bottomRight()); 2902 const QPoint points2[4] = { 2903 backWindowRect.topLeft(), 2904 backWindowRect.topRight(), 2905 backWindowRect.bottomLeft(), 2906 backWindowRect.bottomRight() 2907 }; 2908 painter->drawPoints(points2, 4); 2870 2909 painter->restore(); 2871 2910 } … … 2875 2914 if (titleBar->subControls & SC_TitleBarContextHelpButton 2876 2915 && (titleBar->titleBarFlags & Qt::WindowContextHelpButtonHint)) { 2877 QRect contextHelpButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget);2916 QRect contextHelpButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarContextHelpButton, widget); 2878 2917 if (contextHelpButtonRect.isValid()) { 2879 2918 bool hover = (titleBar->activeSubControls & SC_TitleBarContextHelpButton) && (titleBar->state & State_MouseOver); … … 2894 2933 // shade button 2895 2934 if (titleBar->subControls & SC_TitleBarShadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { 2896 QRect shadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget);2935 QRect shadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarShadeButton, widget); 2897 2936 if (shadeButtonRect.isValid()) { 2898 2937 bool hover = (titleBar->activeSubControls & SC_TitleBarShadeButton) && (titleBar->state & State_MouseOver); … … 2907 2946 // unshade button 2908 2947 if (titleBar->subControls & SC_TitleBarUnshadeButton && (titleBar->titleBarFlags & Qt::WindowShadeButtonHint)) { 2909 QRect unshadeButtonRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget);2948 QRect unshadeButtonRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarUnshadeButton, widget); 2910 2949 if (unshadeButtonRect.isValid()) { 2911 2950 bool hover = (titleBar->activeSubControls & SC_TitleBarUnshadeButton) && (titleBar->state & State_MouseOver); … … 2919 2958 2920 2959 if ((titleBar->subControls & SC_TitleBarSysMenu) && (titleBar->titleBarFlags & Qt::WindowSystemMenuHint)) { 2921 QRect iconRect = subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget);2960 QRect iconRect = proxy()->subControlRect(CC_TitleBar, titleBar, SC_TitleBarSysMenu, widget); 2922 2961 if (iconRect.isValid()) { 2923 2962 if (!titleBar->icon.isNull()) { … … 2929 2968 tool.rect = iconRect; 2930 2969 painter->save(); 2931 drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm);2970 proxy()->drawItemPixmap(painter, iconRect, Qt::AlignCenter, pm); 2932 2971 painter->restore(); 2933 2972 } … … 2949 2988 2950 2989 QRect rect = scrollBar->rect; 2951 QRect scrollBarSubLine = subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget);2952 QRect scrollBarAddLine = subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget);2953 QRect scrollBarSlider = subControlRect(control, scrollBar, SC_ScrollBarSlider, widget);2954 QRect grooveRect = subControlRect(control, scrollBar, SC_ScrollBarGroove, widget);2990 QRect scrollBarSubLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSubLine, widget); 2991 QRect scrollBarAddLine = proxy()->subControlRect(control, scrollBar, SC_ScrollBarAddLine, widget); 2992 QRect scrollBarSlider = proxy()->subControlRect(control, scrollBar, SC_ScrollBarSlider, widget); 2993 QRect grooveRect = proxy()->subControlRect(control, scrollBar, SC_ScrollBarGroove, widget); 2955 2994 2956 2995 // paint groove … … 3087 3126 // The SubLine (up/left) buttons 3088 3127 if (scrollBar->subControls & SC_ScrollBarSubLine) { 3089 //int scrollBarExtent = p ixelMetric(PM_ScrollBarExtent, option, widget);3128 //int scrollBarExtent = proxy()->pixelMetric(PM_ScrollBarExtent, option, widget); 3090 3129 QRect pixmapRect = scrollBarSubLine; 3091 3130 if (isEnabled ) { … … 3133 3172 QStyleOption arrowOpt = *option; 3134 3173 arrowOpt.rect = scrollBarSubLine.adjusted(3, 3, -2, -2); 3135 drawPrimitive(arrow, &arrowOpt, painter, widget);3174 proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget); 3136 3175 3137 3176 3138 3177 // The AddLine (down/right) button 3139 3178 if (scrollBar->subControls & SC_ScrollBarAddLine) { 3140 QString addLinePixmapName = uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16));3179 QString addLinePixmapName = QStyleHelper::uniqueName(QLatin1String("scrollbar_addline"), option, QSize(16, 16)); 3141 3180 QRect pixmapRect = scrollBarAddLine; 3142 3181 if (isEnabled) { … … 3184 3223 QStyleOption arrowOpt = *option; 3185 3224 arrowOpt.rect = scrollBarAddLine.adjusted(3, 3, -2, -2); 3186 drawPrimitive(arrow, &arrowOpt, painter, widget);3225 proxy()->drawPrimitive(arrow, &arrowOpt, painter, widget); 3187 3226 } 3188 3227 } … … 3199 3238 bool focus = isEnabled && (comboBox->state & State_HasFocus); 3200 3239 QPixmap cache; 3201 QString pixmapName = uniqueName(QLatin1String("combobox"), option, comboBox->rect.size());3240 QString pixmapName = QStyleHelper::uniqueName(QLatin1String("combobox"), option, comboBox->rect.size()); 3202 3241 if (sunken) 3203 3242 pixmapName += QLatin1String("-sunken"); … … 3207 3246 pixmapName += QLatin1String("-enabled"); 3208 3247 3209 if (! UsePixmapCache || !QPixmapCache::find(pixmapName, cache)) {3248 if (!QPixmapCache::find(pixmapName, cache)) { 3210 3249 cache = QPixmap(comboBox->rect.size()); 3211 3250 cache.fill(Qt::transparent); … … 3216 3255 3217 3256 QRect rect = pixmapRect; 3218 QRect downArrowRect = subControlRect(CC_ComboBox, &comboBoxCopy,3257 QRect downArrowRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, 3219 3258 SC_ComboBoxArrow, widget); 3220 QRect editRect = subControlRect(CC_ComboBox, &comboBoxCopy,3259 QRect editRect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, 3221 3260 SC_ComboBoxEditField, widget); 3222 3261 // Draw a push button … … 3232 3271 } 3233 3272 3234 drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);3273 proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); 3235 3274 3236 3275 //remove shadow from left side of edit field when pressed: … … 3274 3313 buttonOption.state &= ~State_MouseOver; 3275 3314 } 3276 drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget);3315 proxy()->drawPrimitive(PE_PanelButtonCommand, &buttonOption, &cachePainter, widget); 3277 3316 3278 3317 cachePainter.setPen(buttonShadow.darker(102)); … … 3327 3366 } 3328 3367 // Draw the focus rect 3329 if ((focus && (option->state & State_KeyboardFocusChange)) && !comboBox->editable) { 3368 if (focus && !comboBox->editable 3369 && ((option->state & State_KeyboardFocusChange) || styleHint(SH_UnderlineShortcut, option, widget))) { 3330 3370 QStyleOptionFocusRect focus; 3331 focus.rect = subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget)3371 focus.rect = proxy()->subControlRect(CC_ComboBox, &comboBoxCopy, SC_ComboBoxEditField, widget) 3332 3372 .adjusted(0, 2, option->direction == Qt::RightToLeft ? 1 : -1, -2); 3333 drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget);3373 proxy()->drawPrimitive(PE_FrameFocusRect, &focus, &cachePainter, widget); 3334 3374 } 3335 3375 cachePainter.end(); 3336 if (UsePixmapCache) 3337 QPixmapCache::insert(pixmapName, cache); 3376 QPixmapCache::insert(pixmapName, cache); 3338 3377 } 3339 3378 painter->drawPixmap(comboBox->rect.topLeft(), cache); … … 3346 3385 painter->save(); 3347 3386 if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(option)) { 3348 QRect textRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget);3349 QRect checkBoxRect = subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget);3387 QRect textRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxLabel, widget); 3388 QRect checkBoxRect = proxy()->subControlRect(CC_GroupBox, groupBox, SC_GroupBoxCheckBox, widget); 3350 3389 bool flat = groupBox->features & QStyleOptionFrameV2::Flat; 3351 3390 … … 3357 3396 frame.lineWidth = groupBox->lineWidth; 3358 3397 frame.midLineWidth = groupBox->midLineWidth; 3359 frame.rect = subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget);3398 frame.rect = proxy()->subControlRect(CC_GroupBox, option, SC_GroupBoxFrame, widget); 3360 3399 3361 3400 painter->save(); … … 3366 3405 painter->setClipRegion(region); 3367 3406 frame.palette.setBrush(QPalette::Dark, option->palette.mid().color().lighter(110)); 3368 drawPrimitive(PE_FrameGroupBox, &frame, painter);3407 proxy()->drawPrimitive(PE_FrameGroupBox, &frame, painter); 3369 3408 painter->restore(); 3370 3409 } … … 3394 3433 box.QStyleOption::operator=(*groupBox); 3395 3434 box.rect = checkBoxRect; 3396 drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget);3435 proxy()->drawPrimitive(PE_IndicatorCheckBox, &box, painter, widget); 3397 3436 } 3398 3437 } … … 3403 3442 case CC_Slider: 3404 3443 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 3405 QRect groove = subControlRect(CC_Slider, option, SC_SliderGroove, widget);3406 QRect handle = subControlRect(CC_Slider, option, SC_SliderHandle, widget);3407 QRect ticks = subControlRect(CC_Slider, option, SC_SliderTickmarks, widget);3444 QRect groove = proxy()->subControlRect(CC_Slider, option, SC_SliderGroove, widget); 3445 QRect handle = proxy()->subControlRect(CC_Slider, option, SC_SliderHandle, widget); 3446 QRect ticks = proxy()->subControlRect(CC_Slider, option, SC_SliderTickmarks, widget); 3408 3447 3409 3448 bool horizontal = slider->orientation == Qt::Horizontal; … … 3422 3461 3423 3462 if ((option->subControls & SC_SliderGroove) && groove.isValid()) { 3424 QString groovePixmapName = uniqueName(QLatin1String("slider_groove"), option, groove.size());3463 QString groovePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_groove"), option, groove.size()); 3425 3464 QRect pixmapRect(0, 0, groove.width(), groove.height()); 3426 3465 3427 3466 // draw background groove 3428 if (! UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) {3467 if (!QPixmapCache::find(groovePixmapName, cache)) { 3429 3468 cache = QPixmap(pixmapRect.size()); 3430 3469 cache.fill(Qt::transparent); … … 3453 3492 groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2)); 3454 3493 groovePainter.end(); 3455 if (UsePixmapCache) 3456 QPixmapCache::insert(groovePixmapName, cache); 3494 QPixmapCache::insert(groovePixmapName, cache); 3457 3495 } 3458 3496 painter->drawPixmap(groove.topLeft(), cache); … … 3461 3499 QRect clipRect; 3462 3500 groovePixmapName += QLatin1String("_blue"); 3463 if (! UsePixmapCache || !QPixmapCache::find(groovePixmapName, cache)) {3501 if (!QPixmapCache::find(groovePixmapName, cache)) { 3464 3502 cache = QPixmap(pixmapRect.size()); 3465 3503 cache.fill(Qt::transparent); … … 3480 3518 groovePainter.drawRect(pixmapRect.adjusted(1, 1, -2, -2)); 3481 3519 groovePainter.end(); 3482 if (UsePixmapCache) 3483 QPixmapCache::insert(groovePixmapName, cache); 3520 QPixmapCache::insert(groovePixmapName, cache); 3484 3521 } 3485 3522 if (horizontal) { … … 3502 3539 // draw handle 3503 3540 if ((option->subControls & SC_SliderHandle) ) { 3504 QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());3505 if (! UsePixmapCache || !QPixmapCache::find(handlePixmapName, cache)) {3541 QString handlePixmapName = QStyleHelper::uniqueName(QLatin1String("slider_handle"), option, handle.size()); 3542 if (!QPixmapCache::find(handlePixmapName, cache)) { 3506 3543 cache = QPixmap(handle.size()); 3507 3544 cache.fill(Qt::transparent); … … 3543 3580 handlePainter.setRenderHint(QPainter::Antialiasing); 3544 3581 handlePainter.translate(0.5, 0.5); 3545 handlePainter.drawLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())); 3546 handlePainter.drawLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())); 3547 handlePainter.drawLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())); 3548 handlePainter.drawLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())); 3582 const QLine lines[4] = { 3583 QLine(QPoint(r.left(), r.bottom() - 2), QPoint(r.left() + 2, r.bottom())), 3584 QLine(QPoint(r.left(), r.top() + 2), QPoint(r.left() + 2, r.top())), 3585 QLine(QPoint(r.right(), r.bottom() - 2), QPoint(r.right() - 2, r.bottom())), 3586 QLine(QPoint(r.right(), r.top() + 2), QPoint(r.right() - 2, r.top())) 3587 }; 3588 handlePainter.drawLines(lines, 4); 3549 3589 handlePainter.restore();; 3550 3590 handlePainter.setPen(QPen(outline.darker(130), 1)); … … 3584 3624 } 3585 3625 handlePainter.end(); 3586 if (UsePixmapCache) 3587 QPixmapCache::insert(handlePixmapName, cache); 3626 QPixmapCache::insert(handlePixmapName, cache); 3588 3627 } 3589 3628 … … 3594 3633 fropt.QStyleOption::operator=(*slider); 3595 3634 fropt.rect = slider->rect; 3596 drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget);3635 proxy()->drawPrimitive(PE_FrameFocusRect, &fropt, painter, widget); 3597 3636 } 3598 3637 } 3599 3638 if (option->subControls & SC_SliderTickmarks) { 3600 3639 painter->setPen(darkOutline); 3601 int tickSize = p ixelMetric(PM_SliderTickmarkOffset, option, widget);3602 int available = p ixelMetric(PM_SliderSpaceAvailable, slider, widget);3640 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); 3641 int available = proxy()->pixelMetric(PM_SliderSpaceAvailable, slider, widget); 3603 3642 int interval = slider->tickInterval; 3604 3643 if (interval <= 0) { … … 3614 3653 3615 3654 int v = slider->minimum; 3616 int len = p ixelMetric(PM_SliderLength, slider, widget);3655 int len = proxy()->pixelMetric(PM_SliderLength, slider, widget); 3617 3656 while (v <= slider->maximum + 1) { 3618 3657 if (v == slider->maximum + 1 && interval == 1) … … 3657 3696 break; 3658 3697 #endif // QT_NO_SLIDER 3698 #ifndef QT_NO_DIAL 3699 case CC_Dial: 3700 if (const QStyleOptionSlider *dial = qstyleoption_cast<const QStyleOptionSlider *>(option)) 3701 QStyleHelper::drawDial(dial, painter); 3702 break; 3703 #endif // QT_NO_DIAL 3659 3704 default: 3660 3705 QWindowsStyle::drawComplexControl(control, option, painter, widget); … … 3773 3818 if (!btn->icon.isNull() && btn->iconSize.height() > 16) 3774 3819 newSize -= QSize(0, 2); 3820 newSize += QSize(0, 1); 3775 3821 } 3776 3822 if (const QPushButton *button = qobject_cast<const QPushButton *>(widget)) { … … 3781 3827 } 3782 3828 break; 3829 #ifndef QT_NO_GROUPBOX 3783 3830 case CT_GroupBox: 3831 // Since we use a bold font we have to recalculate base width 3832 if (const QGroupBox *gb = qobject_cast<const QGroupBox*>(widget)) { 3833 QFont font = gb->font(); 3834 font.setBold(true); 3835 QFontMetrics metrics(font); 3836 int baseWidth = metrics.width(gb->title()) + metrics.width(QLatin1Char(' ')); 3837 if (gb->isCheckable()) { 3838 baseWidth += proxy()->pixelMetric(QStyle::PM_IndicatorWidth, option, widget); 3839 baseWidth += proxy()->pixelMetric(QStyle::PM_CheckBoxLabelSpacing, option, widget); 3840 } 3841 newSize.setWidth(qMax(baseWidth, newSize.width())); 3842 } 3843 newSize += QSize(0, 1); 3844 break; 3845 #endif //QT_NO_GROUPBOX 3784 3846 case CT_RadioButton: 3785 3847 case CT_CheckBox: … … 3808 3870 if (menuItem->menuItemType == QStyleOptionMenuItem::Separator) { 3809 3871 if (!menuItem->text.isEmpty()) { 3810 newSize.setHeight(menuItem->fontMetrics. lineSpacing());3872 newSize.setHeight(menuItem->fontMetrics.height()); 3811 3873 } 3812 3874 } … … 3849 3911 { 3850 3912 QWindowsStyle::polish(app); 3851 #ifdef Q_WS_X113852 Q_D(QCleanlooksStyle);3853 3854 QString dataDirs = QLatin1String(getenv("XDG_DATA_DIRS"));3855 3856 if (dataDirs.isEmpty())3857 dataDirs = QLatin1String("/usr/local/share/:/usr/share/");3858 3859 dataDirs.prepend(QDir::homePath() + QLatin1String("/:"));3860 d->iconDirs = dataDirs.split(QLatin1String(":"));3861 #endif3862 3913 } 3863 3914 … … 3960 4011 case CC_Slider: 3961 4012 if (const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option)) { 3962 int tickSize = p ixelMetric(PM_SliderTickmarkOffset, option, widget);4013 int tickSize = proxy()->pixelMetric(PM_SliderTickmarkOffset, option, widget); 3963 4014 switch (subControl) { 3964 4015 case SC_SliderHandle: { … … 4015 4066 QSize bs; 4016 4067 int center = spinbox->rect.height() / 2; 4017 int fw = spinbox->frame ? p ixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0;4068 int fw = spinbox->frame ? proxy()->pixelMetric(PM_SpinBoxFrameWidth, spinbox, widget) : 0; 4018 4069 int y = fw; 4019 4070 bs.setHeight(qMax(8, spinbox->rect.height()/2 - y)); … … 4056 4107 int topMargin = 0; 4057 4108 int topHeight = 0; 4058 int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);4109 int verticalAlignment = proxy()->styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget); 4059 4110 bool flat = groupBox->features & QStyleOptionFrameV2::Flat; 4060 4111 if (!groupBox->text.isEmpty()) { … … 4087 4138 QSize textRect = fontMetrics.boundingRect(groupBoxWidget->title()).size() + QSize(2, 2); 4088 4139 if (subControl == SC_GroupBoxCheckBox) { 4089 int indicatorWidth = p ixelMetric(PM_IndicatorWidth, option, widget);4090 int indicatorHeight = p ixelMetric(PM_IndicatorHeight, option, widget);4140 int indicatorWidth = proxy()->pixelMetric(PM_IndicatorWidth, option, widget); 4141 int indicatorHeight = proxy()->pixelMetric(PM_IndicatorHeight, option, widget); 4091 4142 rect.setWidth(indicatorWidth); 4092 4143 rect.setHeight(indicatorHeight); … … 4109 4160 break; 4110 4161 case SC_ComboBoxEditField: { 4111 int frameWidth = p ixelMetric(PM_DefaultFrameWidth);4162 int frameWidth = proxy()->pixelMetric(PM_DefaultFrameWidth); 4112 4163 rect = visualRect(option->direction, option->rect, rect); 4113 4164 rect.setRect(option->rect.left() + frameWidth, option->rect.top() + frameWidth, … … 4360 4411 r.adjust(0, 0, 0, -4); 4361 4412 } else { 4362 if ( QApplication::layoutDirection()== Qt::LeftToRight)4413 if (opt->direction == Qt::LeftToRight) 4363 4414 r.adjust(4, 0, 0, 0); 4364 4415 else … … 4375 4426 } 4376 4427 return r; 4377 }4378 4379 void QCleanlooksStylePrivate::lookupIconTheme() const4380 {4381 #ifdef Q_WS_X114382 4383 if (themeName.isEmpty()) {4384 //resolve glib and gconf functions4385 p_g_type_init = (Ptr_g_type_init)QLibrary::resolve(QLatin1String("gobject-2.0"), 0, "g_type_init");4386 p_gconf_client_get_default = (Ptr_gconf_client_get_default)QLibrary::resolve(QLatin1String("gconf-2"), 4, "gconf_client_get_default");4387 p_gconf_client_get_string = (Ptr_gconf_client_get_string)QLibrary::resolve(QLatin1String("gconf-2"), 4, "gconf_client_get_string");4388 p_g_object_unref = (Ptr_g_object_unref)QLibrary::resolve(QLatin1String("gobject-2.0"), 0, "g_object_unref");4389 p_g_error_free = (Ptr_g_error_free)QLibrary::resolve(QLatin1String("glib-2.0"), 0, "g_error_free");4390 p_g_free = (Ptr_g_free)QLibrary::resolve(QLatin1String("glib-2.0"), 0, "g_free");4391 4392 if (p_g_type_init &&4393 p_gconf_client_get_default &&4394 p_gconf_client_get_string &&4395 p_g_object_unref &&4396 p_g_error_free &&4397 p_g_free) {4398 4399 p_g_type_init();4400 GConfClient* client = p_gconf_client_get_default();4401 GError *err = 0;4402 char *str = p_gconf_client_get_string(client, "/desktop/gnome/interface/icon_theme", &err);4403 if (!err) {4404 themeName = QString::fromUtf8(str);4405 p_g_free(str);4406 }4407 p_g_object_unref(client);4408 if (err)4409 p_g_error_free (err);4410 }4411 if (themeName.isEmpty())4412 themeName = QLatin1String("gnome");4413 }4414 #endif4415 4428 } 4416 4429 … … 4422 4435 const QWidget *widget) const 4423 4436 { 4424 #ifdef Q_WS_X114425 Q_D(const QCleanlooksStyle);4426 if (!qApp->desktopSettingsAware())4427 return QWindowsStyle::standardIconImplementation(standardIcon, option, widget);4428 QIcon icon;4429 QPixmap pixmap;4430 QPixmap link;4431 d->lookupIconTheme();4432 switch (standardIcon) {4433 case SP_DirIcon: {4434 icon = QIcon(standardPixmap(standardIcon, option, widget));4435 icon.addPixmap(standardPixmap(SP_DirClosedIcon, option, widget),4436 QIcon::Normal, QIcon::Off);4437 pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory.png"));4438 if (!pixmap.isNull())4439 icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);4440 pixmap = d->findIcon(48, QLatin1String("gnome-fs-directory.png"));4441 if (!pixmap.isNull())4442 icon.addPixmap(pixmap, QIcon::Normal, QIcon::Off);4443 pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory-accept.png"));4444 if (!pixmap.isNull())4445 icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);4446 pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory-accept.png"));4447 if (!pixmap.isNull())4448 icon.addPixmap(pixmap, QIcon::Normal, QIcon::On);4449 }4450 break;4451 case SP_DirLinkIcon:4452 {4453 icon = QIcon(standardPixmap(standardIcon, option, widget));4454 QPixmap link = d->findIcon(12, QLatin1String("emblem-symbolic-link.png"));4455 if (!link.isNull()) {4456 icon.addPixmap(standardPixmap(SP_DirLinkIcon, option, widget));4457 pixmap = d->findIcon(16, QLatin1String("gnome-fs-directory.png"));4458 if (!pixmap.isNull()) {4459 QPainter painter(&pixmap);4460 painter.drawPixmap(8, 8, 8, 8, link);4461 painter.end();4462 icon.addPixmap(pixmap);4463 }4464 }4465 break;4466 }4467 case SP_FileIcon:4468 {4469 icon = d->createIcon(QLatin1String("unknown.png"));4470 if (icon.isNull())4471 icon = d->createIcon(QLatin1String("gnome-fs-regular.png"));4472 if (icon.isNull())4473 icon = d->createIcon(QLatin1String("stock_new.png"));4474 break;4475 }4476 case SP_DialogCloseButton:4477 {4478 icon = d->createIcon(QLatin1String("gtk-close.png"));4479 if (icon.isNull())4480 icon = d->createIcon(QLatin1String("stock-close.png"));4481 break;4482 }4483 case SP_DirHomeIcon:4484 {4485 icon = d->createIcon(QLatin1String("folder_home.png"));4486 if (icon.isNull())4487 icon = d->createIcon(QLatin1String("gnome_home.png"));4488 break;4489 }4490 case SP_DriveFDIcon:4491 {4492 icon = d->createIcon(QLatin1String("gnome-dev-floppy.png"));4493 break;4494 }4495 case SP_ComputerIcon:4496 {4497 icon = d->createIcon(QLatin1String("gnome-fs-client.png"));4498 break;4499 }4500 case SP_DesktopIcon:4501 {4502 icon = d->createIcon(QLatin1String("gnome-fs-desktop.png"));4503 break;4504 }4505 case SP_TrashIcon:4506 {4507 icon = d->createIcon(QLatin1String("gnome-fs-trash-empty.png"));4508 break;4509 }4510 case SP_DriveCDIcon:4511 case SP_DriveDVDIcon:4512 {4513 icon = d->createIcon(QLatin1String("gnome-dev-cdrom.png"));4514 break;4515 }4516 case SP_DriveHDIcon:4517 {4518 icon = d->createIcon(QLatin1String("gnome-dev-harddisk.png"));4519 break;4520 }4521 case SP_ArrowUp:4522 {4523 icon = d->createIcon(QLatin1String("stock_up.png"));4524 break;4525 }4526 case SP_ArrowDown:4527 {4528 icon = d->createIcon(QLatin1String("stock_down.png"));4529 break;4530 }4531 case SP_ArrowRight:4532 {4533 icon = d->createIcon(QLatin1String("stock_right.png"));4534 break;4535 }4536 case SP_ArrowLeft:4537 {4538 icon = d->createIcon(QLatin1String("stock_left.png"));4539 break;4540 }4541 case SP_BrowserReload:4542 {4543 icon = d->createIcon(QLatin1String("view-refresh.png"));4544 break;4545 }4546 case SP_BrowserStop:4547 {4548 pixmap = d->findIcon(24, QLatin1String("stop.png"));4549 break;4550 }4551 case SP_FileLinkIcon:4552 {4553 icon = QIcon(standardPixmap(standardIcon, option, widget));4554 QPixmap link = d->findIcon(12, QLatin1String("emblem-symbolic-link.png"));4555 if (!link.isNull()) {4556 icon.addPixmap(standardPixmap(SP_FileLinkIcon,option, widget));4557 pixmap = d->findIcon(16, QLatin1String("unknown.png"));4558 if (pixmap.isNull())4559 pixmap = d->findIcon(16, QLatin1String("stock_new.png"));4560 if (!pixmap.isNull()) {4561 QPainter painter(&pixmap);4562 painter.drawPixmap(8, 8, 8, 8, link);4563 painter.end();4564 icon.addPixmap(pixmap);4565 }4566 }4567 break;4568 }4569 case SP_ArrowForward:4570 if (QApplication::layoutDirection() == Qt::RightToLeft)4571 return standardIconImplementation(SP_ArrowLeft, option, widget);4572 return standardIconImplementation(SP_ArrowRight, option, widget);4573 case SP_ArrowBack:4574 if (QApplication::layoutDirection() == Qt::RightToLeft)4575 return standardIconImplementation(SP_ArrowRight, option, widget);4576 return standardIconImplementation(SP_ArrowLeft, option, widget);4577 default:4578 icon = QIcon(standardPixmap(standardIcon, option, widget));4579 }4580 if (!icon.isNull())4581 return icon;4582 #endif // Q_WS_X114583 4437 return QWindowsStyle::standardIconImplementation(standardIcon, option, widget); 4584 4438 } … … 4590 4444 const QWidget *widget) const 4591 4445 { 4592 #ifdef Q_WS_X114593 Q_D(const QCleanlooksStyle);4594 4446 QPixmap pixmap; 4595 if (!qApp->desktopSettingsAware()) 4596 return QWindowsStyle::standardPixmap(standardPixmap, opt, widget); 4597 d->lookupIconTheme(); 4447 4598 4448 #ifndef QT_NO_IMAGEFORMAT_XPM 4599 4449 switch (standardPixmap) { 4600 case SP_MessageBoxInformation:4601 {4602 pixmap = d->findIcon(48, QLatin1String("dialog-info.png"));4603 if (pixmap.isNull())4604 pixmap = d->findIcon(48, QLatin1String("stock_dialog-info.png"));4605 if (!pixmap.isNull())4606 return pixmap;4607 break;4608 }4609 case SP_MessageBoxWarning:4610 {4611 pixmap = d->findIcon(48, QLatin1String("dialog-warning.png"));4612 if (pixmap.isNull())4613 pixmap = d->findIcon(48, QLatin1String("stock_dialog-warning.png"));4614 if (!pixmap.isNull())4615 return pixmap;4616 break;4617 }4618 case SP_MessageBoxCritical:4619 {4620 pixmap = d->findIcon(48, QLatin1String("dialog-error.png"));4621 if (pixmap.isNull())4622 pixmap = d->findIcon(48, QLatin1String("stock_dialog-error.png"));4623 if (!pixmap.isNull())4624 return pixmap;4625 break;4626 }4627 case SP_MessageBoxQuestion:4628 {4629 pixmap = d->findIcon(48, QLatin1String("dialog-question.png"));4630 if (!pixmap.isNull())4631 return pixmap;4632 break;4633 }4634 case SP_DirHomeIcon:4635 {4636 pixmap = d->findIcon(16, QLatin1String("folder_home.png"));4637 if (pixmap.isNull())4638 pixmap = d->findIcon(16, QLatin1String("gnome_home.png"));4639 if (!pixmap.isNull())4640 return pixmap;4641 break;4642 }4643 case SP_DialogOpenButton:4644 case SP_DirOpenIcon:4645 {4646 pixmap = d->findIcon(24, QLatin1String("stock_open.png"));4647 if (!pixmap.isNull())4648 return pixmap;4649 break;4650 }4651 case SP_FileIcon:4652 {4653 pixmap = d->findIcon(24, QLatin1String("unknown.png"));4654 if (pixmap.isNull())4655 pixmap = d->findIcon(24, QLatin1String("gnome-fs-regular.png"));4656 if (pixmap.isNull())4657 pixmap = d->findIcon(24, QLatin1String("stock_new.png"));4658 if (!pixmap.isNull())4659 return pixmap;4660 break;4661 }4662 case SP_FileLinkIcon:4663 {4664 pixmap = d->findIcon(24, QLatin1String("emblem-symbolic-link.png"));4665 if (!pixmap.isNull()) {4666 QPixmap fileIcon = d->findIcon(24, QLatin1String("unknown.png"));4667 if (fileIcon.isNull())4668 fileIcon = d->findIcon(24, QLatin1String("stock_new.png"));4669 if (!fileIcon.isNull()) {4670 QPainter painter(&fileIcon);4671 painter.setRenderHint(QPainter::SmoothPixmapTransform);4672 painter.drawPixmap(12, 12, 12, 12, pixmap);4673 return fileIcon;4674 }4675 }4676 break;4677 }4678 case SP_DirClosedIcon:4679 case SP_DirIcon:4680 {4681 pixmap = d->findIcon(24, QLatin1String("gnome-fs-directory.png"));4682 if (!pixmap.isNull())4683 return pixmap;4684 break;4685 }4686 case SP_DirLinkIcon:4687 {4688 pixmap = d->findIcon(24, QLatin1String("emblem-symbolic-link.png"));4689 if (!pixmap.isNull()) {4690 QPixmap dirIcon = d->findIcon(24, QLatin1String("gnome-fs-directory.png"));4691 if (!dirIcon.isNull()) {4692 QPainter painter(&dirIcon);4693 painter.setRenderHint(QPainter::SmoothPixmapTransform);4694 painter.drawPixmap(12, 12, 12, 12, pixmap);4695 return dirIcon;4696 }4697 }4698 break;4699 }4700 case SP_DriveFDIcon:4701 {4702 pixmap = d->findIcon(24, QLatin1String("gnome-dev-floppy.png"));4703 if (!pixmap.isNull())4704 return pixmap;4705 break;4706 }4707 case SP_ComputerIcon:4708 {4709 pixmap = d->findIcon(24, QLatin1String("gnome-fs-client.png"));4710 if (!pixmap.isNull())4711 return pixmap;4712 break;4713 }4714 case SP_DesktopIcon:4715 {4716 pixmap = d->findIcon(24, QLatin1String("gnome-fs-desktop.png"));4717 if (!pixmap.isNull())4718 return pixmap;4719 break;4720 }4721 case SP_TrashIcon:4722 {4723 pixmap = d->findIcon(24, QLatin1String("gnome-fs-trash-empty.png"));4724 if (!pixmap.isNull())4725 return pixmap;4726 break;4727 }4728 case SP_DriveCDIcon:4729 case SP_DriveDVDIcon:4730 {4731 pixmap = d->findIcon(24, QLatin1String("gnome-dev-cdrom.png"));4732 if (!pixmap.isNull())4733 return pixmap;4734 break;4735 }4736 case SP_DriveHDIcon:4737 {4738 pixmap = d->findIcon(24, QLatin1String("gnome-dev-harddisk.png"));4739 if (!pixmap.isNull())4740 return pixmap;4741 break;4742 }4743 case SP_FileDialogToParent:4744 {4745 pixmap = d->findIcon(16, QLatin1String("stock_up.png"));4746 if (!pixmap.isNull())4747 return pixmap;4748 break;4749 }4750 case SP_FileDialogNewFolder:4751 {4752 pixmap = d->findIcon(16, QLatin1String("stock_new-dir.png"));4753 if (!pixmap.isNull())4754 return pixmap;4755 break;4756 }4757 case SP_ArrowUp:4758 {4759 pixmap = d->findIcon(16, QLatin1String("stock_up.png"));4760 if (!pixmap.isNull())4761 return pixmap;4762 break;4763 }4764 case SP_ArrowDown:4765 {4766 pixmap = d->findIcon(16, QLatin1String("stock_down.png"));4767 if (!pixmap.isNull())4768 return pixmap;4769 break;4770 }4771 case SP_ArrowRight:4772 {4773 pixmap = d->findIcon(16, QLatin1String("stock_right.png"));4774 if (!pixmap.isNull())4775 return pixmap;4776 break;4777 }4778 case SP_ArrowLeft:4779 {4780 pixmap = d->findIcon(16, QLatin1String("stock_left.png"));4781 if (!pixmap.isNull())4782 return pixmap;4783 break;4784 }4785 case SP_DialogCloseButton:4786 {4787 pixmap = d->findIcon(24, QLatin1String("gtk-close.png"));4788 if (pixmap.isNull())4789 pixmap = d->findIcon(24, QLatin1String("stock-close.png"));4790 if (!pixmap.isNull())4791 return pixmap;4792 break;4793 }4794 case SP_DialogApplyButton:4795 {4796 pixmap = d->findIcon(24, QLatin1String("dialog-apply.png"));4797 if (pixmap.isNull())4798 pixmap = d->findIcon(24, QLatin1String("stock-apply.png"));4799 if (!pixmap.isNull())4800 return pixmap;4801 break;4802 }4803 case SP_DialogResetButton:4804 {4805 pixmap = d->findIcon(24, QLatin1String("gtk-clear.png"));4806 if (!pixmap.isNull())4807 return pixmap;4808 break;4809 }4810 case SP_DialogHelpButton:4811 {4812 pixmap = d->findIcon(24, QLatin1String("gtk-help.png"));4813 if (!pixmap.isNull())4814 return pixmap;4815 break;4816 }4817 case SP_DialogOkButton:4818 {4819 pixmap = d->findIcon(24, QLatin1String("dialog-ok.png"));4820 if (pixmap.isNull())4821 pixmap = d->findIcon(24, QLatin1String("stock-ok.png"));4822 if (!pixmap.isNull())4823 return pixmap;4824 break;4825 }4826 case SP_DialogCancelButton:4827 {4828 pixmap = d->findIcon(24, QLatin1String("dialog-cancel.png"));4829 if (pixmap.isNull())4830 pixmap = d->findIcon(24, QLatin1String("stock-cancel.png"));4831 if (pixmap.isNull())4832 pixmap = d->findIcon(24, QLatin1String("process-stop.png"));4833 if (!pixmap.isNull())4834 return pixmap;4835 break;4836 }4837 case SP_DialogSaveButton:4838 {4839 pixmap = d->findIcon(24, QLatin1String("stock_save.png"));4840 if (!pixmap.isNull())4841 return pixmap;4842 break;4843 }4844 case SP_BrowserStop:4845 {4846 pixmap = d->findIcon(16, QLatin1String("process-stop.png"));4847 if (!pixmap.isNull())4848 return pixmap;4849 break;4850 }4851 case SP_BrowserReload:4852 {4853 pixmap = d->findIcon(16, QLatin1String("view-refresh.png"));4854 if (!pixmap.isNull())4855 return pixmap;4856 break;4857 }4858 case SP_MediaPlay:4859 {4860 pixmap = d->findIcon(24, QLatin1String("media-playback-start.png"));4861 if (!pixmap.isNull())4862 return pixmap;4863 break;4864 }4865 case SP_MediaPause:4866 {4867 pixmap = d->findIcon(24, QLatin1String("media-playback-pause.png"));4868 if (!pixmap.isNull())4869 return pixmap;4870 break;4871 }4872 case SP_MediaStop:4873 {4874 pixmap = d->findIcon(24, QLatin1String("media-playback-stop.png"));4875 if (!pixmap.isNull())4876 return pixmap;4877 break;4878 }4879 case SP_MediaVolume:4880 {4881 pixmap = d->findIcon(16, QLatin1String("audio-volume-medium.png"));4882 if (!pixmap.isNull())4883 return pixmap;4884 break;4885 }4886 case SP_MediaVolumeMuted:4887 {4888 pixmap = d->findIcon(16, QLatin1String("audio-volume-muted.png"));4889 if (!pixmap.isNull())4890 return pixmap;4891 break;4892 }4893 case SP_MediaSeekForward:4894 {4895 pixmap = d->findIcon(24, QLatin1String("media-seek-forward.png"));4896 if (!pixmap.isNull())4897 return pixmap;4898 break;4899 }4900 case SP_MediaSeekBackward:4901 {4902 pixmap = d->findIcon(24, QLatin1String("media-seek-backward.png"));4903 if (!pixmap.isNull())4904 return pixmap;4905 break;4906 }4907 case SP_MediaSkipForward:4908 {4909 pixmap = d->findIcon(24, QLatin1String("media-skip-forward.png"));4910 if (!pixmap.isNull())4911 return pixmap;4912 break;4913 }4914 case SP_MediaSkipBackward:4915 {4916 pixmap = d->findIcon(24, QLatin1String("media-skip-backward.png"));4917 if (!pixmap.isNull())4918 return pixmap;4919 break;4920 }4921 case SP_TitleBarMenuButton:4922 case SP_TitleBarShadeButton:4923 case SP_TitleBarUnshadeButton:4924 case SP_TitleBarMaxButton:4925 case SP_TitleBarContextHelpButton:4926 return QWindowsStyle::standardPixmap(standardPixmap, opt, widget);4927 4450 case SP_TitleBarNormalButton: 4928 4451 return QPixmap((const char **)dock_widget_restore_xpm); … … 4937 4460 } 4938 4461 #endif //QT_NO_IMAGEFORMAT_XPM 4939 #endif //Q_WS_X11 4462 4940 4463 return QWindowsStyle::standardPixmap(standardPixmap, opt, widget); 4941 4464 }
Note:
See TracChangeset
for help on using the changeset viewer.