~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to src/gui/styles/qcommonstyle.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-10-12 23:14:14 UTC
  • mto: (15.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20061012231414-y2oqbom5dy389os0
Tags: upstream-4.2.0
ImportĀ upstreamĀ versionĀ 4.2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include <qcache.h>
30
30
#include <qdockwidget.h>
31
31
#include <qdrawutil.h>
 
32
#include <qdialogbuttonbox.h>
32
33
#include <qgroupbox.h>
33
34
#include <qmenu.h>
34
35
#include <qpainter.h>
41
42
#include <qtoolbutton.h>
42
43
#include <qrubberband.h>
43
44
#include <private/qcommonstylepixmaps_p.h>
44
 
#include <private/qdialogbuttons_p.h>
45
45
#include <private/qmath_p.h>
46
46
#include <qdebug.h>
 
47
#include <qtextformat.h>
47
48
 
48
49
#include <limits.h>
49
50
 
394
395
                QPolygon pa(3);
395
396
                p->setPen(QPen(opt->palette.light(), 0));
396
397
                p->drawLine(opt->rect.x() + opt->rect.width(), opt->rect.y(),
397
 
                            opt->rect.x() + opt->rect.width() / 2, opt->rect.height());
 
398
                            opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
398
399
                p->setPen(QPen(opt->palette.dark(), 0));
399
 
                pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.height());
 
400
                pa.setPoint(0, opt->rect.x() + opt->rect.width() / 2, opt->rect.y() + opt->rect.height());
400
401
                pa.setPoint(1, opt->rect.x(), opt->rect.y());
401
402
                pa.setPoint(2, opt->rect.x() + opt->rect.width(), opt->rect.y());
402
403
                p->drawPolyline(pa);
403
404
            } else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
404
405
                QPolygon pa(3);
405
406
                p->setPen(QPen(opt->palette.light(), 0));
406
 
                pa.setPoint(0, opt->rect.x(), opt->rect.height());
407
 
                pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.height());
 
407
                pa.setPoint(0, opt->rect.x(), opt->rect.y() + opt->rect.height());
 
408
                pa.setPoint(1, opt->rect.x() + opt->rect.width(), opt->rect.y() + opt->rect.height());
408
409
                pa.setPoint(2, opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
409
410
                p->drawPolyline(pa);
410
411
                p->setPen(QPen(opt->palette.dark(), 0));
411
 
                p->drawLine(opt->rect.x(), opt->rect.height(),
 
412
                p->drawLine(opt->rect.x(), opt->rect.y() + opt->rect.height(),
412
413
                            opt->rect.x() + opt->rect.width() / 2, opt->rect.y());
413
414
            }
414
415
            p->setPen(oldPen);
801
802
            }
802
803
            if (!btn->text.isEmpty()){
803
804
                drawItemText(p, textRect, alignment | Qt::TextShowMnemonic,
804
 
                    btn->palette, btn->state & State_Enabled, btn->text, QPalette::Foreground);
 
805
                    btn->palette, btn->state & State_Enabled, btn->text, QPalette::WindowText);
805
806
            }
806
807
        }
807
808
        break;
811
812
        QStyleOption arrowOpt = *opt;
812
813
        arrowOpt.state |= State_Enabled;
813
814
        drawPrimitive(((opt->state & State_DownArrow) ? PE_IndicatorArrowDown : PE_IndicatorArrowUp),
814
 
                      &arrowOpt, p, widget);
 
815
                    &arrowOpt, p, widget);
815
816
        break; }
816
817
    case CE_MenuTearoff:
817
818
        if (opt->state & State_Selected)
864
865
        break;
865
866
    case CE_ProgressBarGroove:
866
867
        qDrawShadePanel(p, opt->rect, opt->palette, true, 1,
867
 
                        &opt->palette.brush(QPalette::Background));
 
868
                        &opt->palette.brush(QPalette::Window));
868
869
        break;
869
870
    case CE_ProgressBarLabel:
870
871
        if (const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(opt)) {
988
989
                int pixw = pixmap.width();
989
990
 
990
991
                QRect aligned = alignedRect(header->direction, QFlag(header->iconAlignment), pixmap.size(), rect);
991
 
                QRect inter = aligned.intersect(rect);
 
992
                QRect inter = aligned.intersected(rect);
992
993
                p->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width(), inter.height());
993
994
 
994
995
                if (header->direction == Qt::LeftToRight)
1048
1049
                        alignment |= Qt::TextHideMnemonic;
1049
1050
 
1050
1051
                    if (toolbutton->toolButtonStyle == Qt::ToolButtonTextUnderIcon) {
1051
 
                        int fh = p->fontMetrics().height();
1052
 
                        pr.adjust(0, 3, 0, -fh - 3);
 
1052
                        pr.setHeight(pmSize.height() + 6);
 
1053
 
1053
1054
                        tr.adjust(0, pr.bottom(), 0, -3);
1054
1055
                        pr.translate(shiftX, shiftY);
1055
1056
                        if (!hasArrow) {
1277
1278
                tr.setLeft(tr.left() + iconSize.width() + 4);
1278
1279
            }
1279
1280
 
1280
 
            if (verticalTabs){
1281
 
                QPixmap pixmap(tr.size());
1282
 
                pixmap.fill(Qt::transparent);
1283
 
                QPainter pixPainter(&pixmap);
1284
 
                drawItemText(&pixPainter, pixmap.rect(), alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::Foreground);
1285
 
                drawItemPixmap(p,tr,alignment,pixmap);
 
1281
            drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::WindowText);
 
1282
            if (verticalTabs)
1286
1283
                p->restore();
1287
 
            } else {
1288
 
                drawItemText(p, tr, alignment, tab->palette, tab->state & State_Enabled, tab->text, QPalette::Foreground);
1289
 
            }
1290
1284
 
1291
1285
            if (tabV2.state & State_HasFocus) {
1292
1286
                const int OFFSET = 1 + pixelMetric(PM_DefaultFrameWidth);
1320
1314
        int sy = y;
1321
1315
        int s = sw / 3;
1322
1316
 
1323
 
        if (opt->direction == Qt::RightToLeft) {
 
1317
        Qt::Corner corner;
 
1318
        if (const QStyleOptionSizeGrip *sgOpt = qstyleoption_cast<const QStyleOptionSizeGrip *>(opt))
 
1319
            corner = sgOpt->corner;
 
1320
        else if (opt->direction == Qt::RightToLeft)
 
1321
            corner = Qt::BottomLeftCorner;
 
1322
        else
 
1323
            corner = Qt::BottomRightCorner;
 
1324
 
 
1325
        if (corner == Qt::BottomLeftCorner) {
1324
1326
            sx = x + sw;
1325
1327
            for (int i = 0; i < 4; ++i) {
1326
1328
                p->setPen(QPen(opt->palette.light().color(), 1));
1332
1334
                sx -= s;
1333
1335
                sy += s;
1334
1336
            }
1335
 
        } else {
 
1337
        } else if (corner == Qt::BottomRightCorner) {
1336
1338
            for (int i = 0; i < 4; ++i) {
1337
1339
                p->setPen(QPen(opt->palette.light().color(), 1));
1338
1340
                p->drawLine(sx - 1, sw, sw, sy - 1);
1343
1345
                sx += s;
1344
1346
                sy += s;
1345
1347
            }
 
1348
        } else if (corner == Qt::TopRightCorner) {
 
1349
            sy = y + sw;
 
1350
            for (int i = 0; i < 4; ++i) {
 
1351
                p->setPen(QPen(opt->palette.light().color(), 1));
 
1352
                p->drawLine(sx - 1, y, sw, sy + 1);
 
1353
                p->setPen(QPen(opt->palette.dark().color(), 1));
 
1354
                p->drawLine(sx, y, sw, sy);
 
1355
                p->setPen(QPen(opt->palette.dark().color(), 1));
 
1356
                p->drawLine(sx + 1, y, sw, sy - 1);
 
1357
                sx += s;
 
1358
                sy -= s;
 
1359
            }
 
1360
        } else if (corner == Qt::TopLeftCorner) {
 
1361
            for (int i = 0; i < 4; ++i) {
 
1362
                p->setPen(QPen(opt->palette.light().color(), 1));
 
1363
                p->drawLine(x, sy - 1, sx - 1, y);
 
1364
                p->setPen(QPen(opt->palette.dark().color(), 1));
 
1365
                p->drawLine(x, sy, sx, y);
 
1366
                p->setPen(QPen(opt->palette.dark().color(), 1));
 
1367
                p->drawLine(x, sy + 1, sx + 1, y);
 
1368
                sx += s;
 
1369
                sy += s;
 
1370
            }
1346
1371
        }
1347
1372
        p->restore();
1348
1373
        break; }
1367
1392
            if (styleHint(QStyle::SH_RubberBand_Mask, opt, widget, &mask))
1368
1393
                p->setClipRegion(mask.region);
1369
1394
            p->drawTiledPixmap(r.x(), r.y(), r.width(), r.height(), tiledPixmap);
1370
 
            p->setPen(opt->palette.color(QPalette::Active, QPalette::Foreground));
 
1395
            p->setPen(opt->palette.color(QPalette::Active, QPalette::WindowText));
1371
1396
            p->setBrush(Qt::NoBrush);
1372
1397
            p->drawRect(r.adjusted(0, 0, -1, -1));
1373
1398
            if (rbOpt->shape == QRubberBand::Rectangle)
1390
1415
                drawItemText(p, r.adjusted(indent + 1, 1, -indent - 1, -1),
1391
1416
                              Qt::AlignLeft | Qt::AlignVCenter, dwOpt->palette,
1392
1417
                              dwOpt->state & State_Enabled, dwOpt->title,
1393
 
                              QPalette::Foreground);
 
1418
                              QPalette::WindowText);
1394
1419
            }
1395
1420
        }
1396
1421
        break;
1412
1437
        }
1413
1438
        break;
1414
1439
    case CE_FocusFrame:
1415
 
        p->fillRect(opt->rect, opt->palette.foreground());
 
1440
            p->fillRect(opt->rect, opt->palette.foreground());
1416
1441
        break;
1417
1442
    case CE_HeaderSection:
1418
 
        qDrawShadePanel(p, opt->rect, opt->palette,
 
1443
            qDrawShadePanel(p, opt->rect, opt->palette,
1419
1444
                        opt->state & State_Sunken, 1,
1420
1445
                        &opt->palette.brush(QPalette::Button));
1421
1446
        break;
1558
1583
            }
1559
1584
            r = iconRect | textRect;
1560
1585
            r.adjust(-3, -2, 3, 2);
1561
 
            r = r.intersect(btn->rect);
 
1586
            r = r.intersected(btn->rect);
1562
1587
            r = visualRect(btn->direction, btn->rect, r);
1563
1588
        }
1564
1589
        break;
1605
1630
            }
1606
1631
            r = iconRect | textRect;
1607
1632
            r.adjust(-3, -2, 3, 2);
1608
 
            r = r.intersect(btn->rect);
 
1633
            r = r.intersected(btn->rect);
1609
1634
            r = visualRect(btn->direction, btn->rect, r);
1610
1635
        }
1611
1636
        break;
1618
1643
                r.setRect(0, tickOffset - 1, slider->rect.width(), thickness + 2);
1619
1644
            else
1620
1645
                r.setRect(tickOffset - 1, 0, thickness + 2, slider->rect.height());
1621
 
            r = r.intersect(slider->rect);
 
1646
            r = r.intersected(slider->rect);
1622
1647
            r = visualRect(opt->direction, opt->rect, r);
1623
1648
        }
1624
1649
        break;
1689
1714
 
1690
1715
        if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(opt)) {
1691
1716
            // Subtract width needed for arrow, if there is one
1692
 
            if (header->sortIndicator != QStyleOptionHeader::None)
1693
 
                r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2));
 
1717
            if (header->sortIndicator != QStyleOptionHeader::None) {
 
1718
                if (opt->state & State_Horizontal)
 
1719
                    r.setWidth(r.width() - (opt->rect.height() / 2) - (margin * 2));
 
1720
                else
 
1721
                    r.setHeight(r.height() - (opt->rect.width() / 2) - (margin * 2));
 
1722
            }
1694
1723
        }
1695
1724
        r = visualRect(opt->direction, opt->rect, r);
1696
1725
        break; }
1700
1729
        int x = opt->rect.x();
1701
1730
        int y = opt->rect.y();
1702
1731
        int margin = pixelMetric(QStyle::PM_HeaderMargin, opt, widget);
1703
 
        if (opt->state & State_Horizontal)
1704
 
            r.setRect(x + w - margin * 2 - (h / 2), y + 5, h / 2, h - margin * 2);
1705
 
        else
1706
 
            r.setRect(x + 5, y, h / 2, h - margin * 2);
 
1732
                        
 
1733
        if (opt->state & State_Horizontal) {
 
1734
            int horiz_size = h / 2;
 
1735
            r.setRect(x + w - margin * 2 - horiz_size, y + 5, 
 
1736
                      horiz_size, h - margin * 2 - 5);
 
1737
        } else {
 
1738
            int vert_size = w / 2;
 
1739
            r.setRect(x + 5, y + h - margin * 2 - vert_size, 
 
1740
                      w - margin * 2 - 5, vert_size);
 
1741
        }
1707
1742
        r = visualRect(opt->direction, opt->rect, r);
1708
1743
        break; }
1709
1744
 
1819
1854
            switch (twf->shape) {
1820
1855
            case QTabBar::RoundedNorth:
1821
1856
            case QTabBar::TriangularNorth:
1822
 
                r = QRect(QPoint(0,twf->tabBarSize.height() - overlap), QSize(twf->rect.width(), twf->rect.height() - twf->tabBarSize.height() + overlap));
 
1857
                r = QRect(QPoint(0,qMax(twf->tabBarSize.height() - overlap, 0)),
 
1858
                          QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
1823
1859
                break;
1824
1860
            case QTabBar::RoundedSouth:
1825
1861
            case QTabBar::TriangularSouth:
1826
 
                r = QRect(QPoint(0,0), QSize(twf->rect.width(), twf->rect.height() - twf->tabBarSize.height() + overlap));
 
1862
                r = QRect(QPoint(0,0), QSize(twf->rect.width(), qMin(twf->rect.height() - twf->tabBarSize.height() + overlap, twf->rect.height())));
1827
1863
                break;
1828
1864
            case QTabBar::RoundedEast:
1829
1865
            case QTabBar::TriangularEast:
1830
 
                r = QRect(QPoint(0, 0), QSize(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.height()));
 
1866
                r = QRect(QPoint(0, 0), QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
1831
1867
                break;
1832
1868
            case QTabBar::RoundedWest:
1833
1869
            case QTabBar::TriangularWest:
1834
 
                r = QRect(QPoint(twf->tabBarSize.width() - overlap, 0), QSize(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.height()));
 
1870
                r = QRect(QPoint(qMax(twf->tabBarSize.width() - overlap, 0), 0),
 
1871
                          QSize(qMin(twf->rect.width() - twf->tabBarSize.width() + overlap, twf->rect.width()), twf->rect.height()));
1835
1872
                break;
1836
1873
            }
1837
1874
            if (sr == SE_TabWidgetTabContents)
1905
1942
    case SE_TreeViewDisclosureItem:
1906
1943
        r = opt->rect;
1907
1944
        break;
 
1945
    case SE_LineEditContents:
 
1946
        if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt)) {
 
1947
            r = f->rect.adjusted(f->lineWidth, f->lineWidth, -f->lineWidth, -f->lineWidth);
 
1948
            r = visualRect(opt->direction, opt->rect, r);
 
1949
        }
 
1950
        break;
 
1951
    case SE_FrameContents:
 
1952
        if (const QStyleOptionFrameV2 *f = qstyleoption_cast<const QStyleOptionFrameV2 *>(opt)) {
 
1953
            int fw = pixelMetric(PM_DefaultFrameWidth, f, widget);
 
1954
            r = opt->rect.adjusted(fw, fw, -fw, -fw);
 
1955
            r = visualRect(opt->direction, opt->rect, r);
 
1956
        }
 
1957
        break;
1908
1958
    default:
1909
1959
        break;
1910
1960
    }
2568
2618
                QRegion region(groupBox->rect);
2569
2619
                if (!groupBox->text.isEmpty()) {
2570
2620
                    bool ltr = groupBox->direction == Qt::LeftToRight;
2571
 
                    QRect finalRect = checkBoxRect.unite(textRect);
 
2621
                    QRect finalRect = checkBoxRect.united(textRect);
2572
2622
                    if (groupBox->subControls & QStyle::SC_GroupBoxCheckBox)
2573
2623
                        finalRect.adjust(ltr ? -4 : 0, 0, ltr ? 0 : 4, 0);
2574
2624
                    region -= finalRect;
2590
2640
 
2591
2641
                    drawItemText(p, textRect,  Qt::TextShowMnemonic | Qt::AlignHCenter | alignment,
2592
2642
                                 groupBox->palette, groupBox->state & State_Enabled, groupBox->text,
2593
 
                                 textColor.isValid() ? QPalette::NoRole : QPalette::Foreground);
 
2643
                                 textColor.isValid() ? QPalette::NoRole : QPalette::WindowText);
2594
2644
 
2595
2645
                    if (groupBox->state & State_HasFocus) {
2596
2646
                        QStyleOptionFocusRect fropt;
2612
2662
        break;
2613
2663
#endif // QT_NO_GROUPBOX
2614
2664
    default:
2615
 
        qWarning("drawComplexControl control not handled %d", cc);
 
2665
        qWarning("QCommonStyle::drawComplexControl: Control %d not handled", cc);
2616
2666
    }
2617
2667
}
2618
2668
 
2726
2776
        break;
2727
2777
#endif // QT_NO_GROUPBOX
2728
2778
    default:
2729
 
        qWarning("QCommonStyle::hitTestComplexControl case not handled %d", cc);
 
2779
        qWarning("QCommonStyle::hitTestComplexControl: Case %d not handled", cc);
2730
2780
    }
2731
2781
    return sc;
2732
2782
}
3024
3074
        }
3025
3075
        break;
3026
3076
#ifndef QT_NO_GROUPBOX
3027
 
    case CC_GroupBox:
 
3077
    case CC_GroupBox: {
3028
3078
        if (const QStyleOptionGroupBox *groupBox = qstyleoption_cast<const QStyleOptionGroupBox *>(opt)) {
3029
 
            int topMargin = 0;
3030
 
            int topHeight = 0;
3031
 
            int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
3032
 
            if (groupBox->text.size()) {
3033
 
                topHeight = groupBox->fontMetrics.height();
3034
 
                if (verticalAlignment & Qt::AlignVCenter)
3035
 
                    topMargin = topHeight / 2;
3036
 
                else if (verticalAlignment & Qt::AlignTop)
3037
 
                    topMargin = topHeight;
3038
 
            }
3039
 
 
3040
 
            QRect frameRect = groupBox->rect;
3041
 
            frameRect.setTop(topMargin);
3042
 
 
3043
 
            if (sc == SC_GroupBoxFrame) {
3044
 
                ret = frameRect;
3045
 
                break;
3046
 
            }
3047
 
 
3048
 
            if (sc == SC_GroupBoxContents) {
3049
 
                int margin = 0;
 
3079
            switch (sc) {
 
3080
            case SC_GroupBoxFrame:
 
3081
                // FALL THROUGH
 
3082
            case SC_GroupBoxContents: {
 
3083
                int topMargin = 0;
 
3084
                int topHeight = 0;
 
3085
                int verticalAlignment = styleHint(SH_GroupBox_TextLabelVerticalAlignment, groupBox, widget);
 
3086
                if (groupBox->text.size()) {
 
3087
                    topHeight = groupBox->fontMetrics.height();
 
3088
                    if (verticalAlignment & Qt::AlignVCenter)
 
3089
                        topMargin = topHeight / 2;
 
3090
                    else if (verticalAlignment & Qt::AlignTop)
 
3091
                        topMargin = topHeight;
 
3092
                }
 
3093
 
 
3094
                QRect frameRect = groupBox->rect;
 
3095
                
 
3096
                if (sc == SC_GroupBoxFrame) {
 
3097
                    frameRect.setTop(topMargin);
 
3098
                    ret = frameRect;
 
3099
                    break;
 
3100
                }
 
3101
 
 
3102
                int frameWidth = 0;
3050
3103
                if ((groupBox->features & QStyleOptionFrameV2::Flat) == 0)
3051
 
                    margin = pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
3052
 
                ret = frameRect.adjusted(margin, margin + topHeight, -margin, -margin);
3053
 
                break;
3054
 
            }
3055
 
 
3056
 
            QFontMetrics fontMetrics = groupBox->fontMetrics;
3057
 
            int h = fontMetrics.height();
3058
 
            int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
3059
 
            int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8;
3060
 
            ret = groupBox->rect.adjusted(marg, 1, -marg, 0);
3061
 
            ret.setHeight(h);
3062
 
            QRect labelRect = alignedRect(groupBox->direction, groupBox->textAlignment,
3063
 
                                          QSize(tw, h), ret);
3064
 
 
3065
 
            int indicatorWidth = pixelMetric(PM_IndicatorWidth, opt, widget);
3066
 
            int checkSpacing = pixelMetric(PM_CheckBoxLabelSpacing, opt, widget);
3067
 
            bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
3068
 
            bool rtl = groupBox->direction == Qt::RightToLeft;
3069
 
            if (hasCheckBox) {
3070
 
                if (!rtl)
3071
 
                    labelRect.moveLeft(labelRect.left() + indicatorWidth + checkSpacing - 1);
3072
 
                else
3073
 
                    labelRect.moveLeft(labelRect.left() - indicatorWidth - checkSpacing + 1);
3074
 
            }
3075
 
 
3076
 
            if (sc == SC_GroupBoxLabel)
3077
 
                ret = labelRect;
3078
 
 
3079
 
            if (sc == SC_GroupBoxCheckBox) {
3080
 
                // Hmm... since I used alignedRect, I can't use visual rect down here.
3081
 
                int indicatorHeight = pixelMetric(PM_IndicatorHeight, opt, widget);
3082
 
                int left = rtl ? labelRect.right() - indicatorWidth : labelRect.left();
3083
 
                if (hasCheckBox)
3084
 
                    left += rtl ? indicatorWidth + checkSpacing - 1 : -(indicatorWidth + checkSpacing) + 3;
3085
 
                ret.setRect(left, ret.top() + (fontMetrics.height() - indicatorHeight) / 2,
3086
 
                        indicatorWidth, indicatorHeight);
 
3104
                    frameWidth = pixelMetric(PM_DefaultFrameWidth, groupBox, widget);
 
3105
                ret = frameRect.adjusted(frameWidth, frameWidth + topHeight, -frameWidth, -frameWidth);
 
3106
                break;
 
3107
            }
 
3108
            case SC_GroupBoxCheckBox:
 
3109
                // FALL THROUGH
 
3110
            case SC_GroupBoxLabel: {
 
3111
                QFontMetrics fontMetrics = groupBox->fontMetrics;
 
3112
                int h = fontMetrics.height();
 
3113
                int tw = fontMetrics.size(Qt::TextShowMnemonic, groupBox->text + QLatin1Char(' ')).width();
 
3114
                int marg = (groupBox->features & QStyleOptionFrameV2::Flat) ? 0 : 8;
 
3115
                ret = groupBox->rect.adjusted(marg, 0, -marg, 0);
 
3116
                ret.setHeight(h);
 
3117
 
 
3118
                int indicatorWidth = pixelMetric(PM_IndicatorWidth, opt, widget);
 
3119
                int indicatorSpace = pixelMetric(PM_CheckBoxLabelSpacing, opt, widget) - 1;
 
3120
                bool hasCheckBox = groupBox->subControls & QStyle::SC_GroupBoxCheckBox;
 
3121
                int checkBoxSize = hasCheckBox ? (indicatorWidth + indicatorSpace) : 0;
 
3122
 
 
3123
                // Adjusted rect for label + indicatorWidth + indicatorSpace
 
3124
                QRect totalRect = alignedRect(groupBox->direction, groupBox->textAlignment,
 
3125
                                              QSize(tw + checkBoxSize, h), ret);
 
3126
 
 
3127
                // Adjust totalRect if checkbox is set
 
3128
                if (hasCheckBox) {
 
3129
                    bool ltr = groupBox->direction == Qt::LeftToRight;
 
3130
                    int left = 0;
 
3131
                    // Adjust for check box
 
3132
                    if (sc == SC_GroupBoxCheckBox) {
 
3133
                        int indicatorHeight = pixelMetric(PM_IndicatorHeight, opt, widget);
 
3134
                        left = ltr ? totalRect.left() : (totalRect.right() - indicatorWidth);
 
3135
                        int top = totalRect.top() + (fontMetrics.height() - indicatorHeight) / 2;
 
3136
                        totalRect.setRect(left, top, indicatorWidth, indicatorHeight);
 
3137
                    // Adjust for label
 
3138
                    } else {
 
3139
                        left = ltr ? (totalRect.left() + checkBoxSize - 2) : totalRect.left();
 
3140
                        totalRect.setRect(left, totalRect.top(),
 
3141
                                          totalRect.width() - checkBoxSize, totalRect.height());
 
3142
                    }
 
3143
                }
 
3144
                ret = totalRect;
 
3145
                break;
 
3146
            }
 
3147
            default:
 
3148
                break;
3087
3149
            }
3088
3150
        }
3089
3151
        break;
 
3152
    }
3090
3153
#endif // QT_NO_GROUPBOX
3091
3154
    default:
3092
 
        qWarning("QCommonStyle::subControlRect case not handled %d", cc);
 
3155
        qWarning("QCommonStyle::subControlRect: Case %d not handled", cc);
3093
3156
    }
3094
3157
    return ret;
3095
3158
}
3368
3431
        ret = pixelMetric(PM_SmallIconSize, opt, widget);
3369
3432
        break;
3370
3433
 
 
3434
    case PM_ButtonIconSize:
3371
3435
    case PM_SmallIconSize:
3372
3436
        ret = 16;
3373
3437
        break;
3388
3452
    case PM_SizeGripSize:
3389
3453
        ret = 13;
3390
3454
        break;
 
3455
    case PM_MessageBoxIconSize:
 
3456
        ret = 32;
 
3457
        break;
3391
3458
    default:
3392
3459
        ret = 0;
3393
3460
        break;
3448
3515
                if (!mi->icon.isNull())
3449
3516
                    h = qMax(h, mi->icon.pixmap(pixelMetric(PM_SmallIconSize), QIcon::Normal).height() + 4);
3450
3517
            }
3451
 
            if (mi->text.contains('\t'))
 
3518
            if (mi->text.contains(QLatin1Char('\t')))
3452
3519
                w += 12;
3453
3520
            if (maxpmw > 0)
3454
3521
                w += maxpmw + 6;
3488
3555
    case CT_TabWidget:
3489
3556
        sz += QSize(4, 4);
3490
3557
        break;
 
3558
    case CT_LineEdit:
 
3559
        if (const QStyleOptionFrame *f = qstyleoption_cast<const QStyleOptionFrame *>(opt))
 
3560
            sz += QSize(2*f->lineWidth, 2*f->lineWidth);
 
3561
        break;
 
3562
#ifndef QT_NO_GROUPBOX
 
3563
    case CT_GroupBox:
 
3564
        if (const QGroupBox *grb = static_cast<const QGroupBox *>(widget))
 
3565
            sz += QSize(!grb->isFlat() ? 16 : 0, 0);
 
3566
        break;
 
3567
#endif // QT_NO_GROUPBOX
3491
3568
    case CT_ScrollBar:
3492
3569
    case CT_MenuBar:
3493
3570
    case CT_Menu:
3494
3571
    case CT_MenuBarItem:
3495
 
    case CT_LineEdit:
3496
3572
    case CT_Q3Header:
3497
3573
    case CT_Slider:
3498
3574
    case CT_ProgressBar:
3513
3589
    int ret = 0;
3514
3590
 
3515
3591
    switch (sh) {
 
3592
    case SH_Menu_KeyboardSearch:
 
3593
        ret = false;
 
3594
        break;
 
3595
    case SH_Slider_AbsoluteSetButtons:
 
3596
        ret = Qt::MidButton;
 
3597
        break;
 
3598
    case SH_Slider_PageSetButtons:
 
3599
        ret = Qt::LeftButton;
 
3600
        break;
3516
3601
    case SH_ScrollBar_ContextMenu:
3517
3602
        ret = true;
3518
3603
        break;
3519
 
    case SH_DialogButtons_DefaultButton:
3520
 
        ret = QDialogButtons::Accept;
 
3604
    case SH_DialogButtons_DefaultButton:  // This value not used anywhere.
 
3605
        ret = QDialogButtonBox::AcceptRole;
3521
3606
        break;
3522
3607
#ifndef QT_NO_GROUPBOX
3523
3608
    case SH_GroupBox_TextLabelVerticalAlignment:
3588
3673
        ret = 75;
3589
3674
        break;
3590
3675
 
 
3676
    case SH_Menu_SelectionWrap:
 
3677
        ret = true;
 
3678
        break;
 
3679
 
3591
3680
    case SH_Menu_FillScreenWithScroll:
3592
3681
        ret = true;
3593
3682
        break;
3643
3732
        break;
3644
3733
 
3645
3734
    case SH_Dial_BackgroundRole:
3646
 
        ret = QPalette::Background;
 
3735
        ret = QPalette::Window;
3647
3736
        break;
3648
3737
 
3649
3738
    case SH_ComboBox_LayoutDirection:
3668
3757
    case SH_ScrollBar_RollBetweenButtons:
3669
3758
        ret = false;
3670
3759
        break;
 
3760
    case SH_TabBar_ElideMode:
 
3761
        ret = Qt::ElideNone;
 
3762
        break;
 
3763
    case SH_DialogButtonLayout:
 
3764
        ret = QDialogButtonBox::WinLayout;
 
3765
        break;
 
3766
    case SH_ComboBox_PopupFrameStyle:
 
3767
        ret = QFrame::StyledPanel | QFrame::Plain;
 
3768
        break;
 
3769
    case SH_MessageBox_TextInteractionFlags:
 
3770
        ret = Qt::LinksAccessibleByMouse;
 
3771
        break;
 
3772
    case SH_DialogButtonBox_ButtonsHaveIcons:
 
3773
        ret = 0;
 
3774
        break;
 
3775
    case SH_SpellCheckUnderlineStyle:
 
3776
        ret = QTextCharFormat::WaveUnderline;
 
3777
        break;
 
3778
    case SH_MessageBox_CenterButtons:
 
3779
        ret = true;
 
3780
        break;
 
3781
    case SH_ItemView_MovementWithoutUpdatingSelection:
 
3782
        ret = true;
 
3783
        break;
3671
3784
    default:
3672
3785
        ret = 0;
3673
3786
        break;
3677
3790
}
3678
3791
 
3679
3792
/*! \reimp */
3680
 
QPixmap QCommonStyle::standardPixmap(StandardPixmap standardPixmap, const QStyleOption *,
3681
 
                                     const QWidget *) const
 
3793
QPixmap QCommonStyle::standardPixmap(StandardPixmap sp, const QStyleOption *option,
 
3794
                                     const QWidget *widget) const
3682
3795
{
3683
 
    switch (standardPixmap) {
 
3796
    switch (sp) {
3684
3797
#ifndef QT_NO_IMAGEFORMAT_XPM
3685
3798
    case SP_ToolBarHorizontalExtensionButton:
3686
3799
        if (QApplication::layoutDirection() == Qt::RightToLeft) {
3697
3810
        return QPixmap(filedialog_end_xpm);
3698
3811
#endif // QT_NO_IMAGEFORMAT_XPM
3699
3812
#ifndef QT_NO_IMAGEFORMAT_PNG
 
3813
    case SP_ArrowForward:
 
3814
        if (QApplication::layoutDirection() == Qt::RightToLeft)
 
3815
            return standardPixmap(SP_ArrowLeft, option, widget);
 
3816
        return standardPixmap(SP_ArrowRight, option, widget);
 
3817
    case SP_ArrowBack:
 
3818
        if (QApplication::layoutDirection() == Qt::RightToLeft)
 
3819
            return standardPixmap(SP_ArrowRight, option, widget);
 
3820
        return standardPixmap(SP_ArrowLeft, option, widget);
 
3821
    case SP_ArrowLeft:
 
3822
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png"));
 
3823
    case SP_ArrowRight:
 
3824
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/right-16.png"));
 
3825
    case SP_ArrowUp:
 
3826
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/up-16.png"));
 
3827
    case SP_ArrowDown:
 
3828
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png"));
3700
3829
    case SP_FileDialogToParent:
3701
 
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/parentdir-16.png"));
 
3830
        return standardPixmap(SP_ArrowUp, option, widget);
3702
3831
    case SP_FileDialogNewFolder:
3703
3832
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png"));
3704
3833
    case SP_FileDialogDetailedView:
3710
3839
    case SP_FileDialogListView:
3711
3840
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png"));
3712
3841
    case SP_FileDialogBack:
3713
 
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/back-16.png"));
 
3842
        return standardPixmap(SP_ArrowBack, option, widget);
3714
3843
    case SP_DriveHDIcon:
3715
3844
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/harddrive-16.png"));
3716
3845
    case SP_TrashIcon:
3729
3858
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dvd-16.png"));
3730
3859
    case SP_DirOpenIcon:
3731
3860
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-16.png"));
 
3861
    case SP_DirIcon:
3732
3862
    case SP_DirClosedIcon:
3733
3863
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-16.png"));
3734
3864
    case SP_DirLinkIcon:
3737
3867
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/file-16.png"));
3738
3868
    case SP_FileLinkIcon:
3739
3869
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/filelink-16.png"));
 
3870
    case SP_DialogOkButton:
 
3871
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-16.png"));
 
3872
    case SP_DialogCancelButton:
 
3873
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-16.png"));
 
3874
    case SP_DialogHelpButton:
 
3875
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-16.png"));
 
3876
    case SP_DialogOpenButton:
 
3877
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png"));
 
3878
    case SP_DialogSaveButton:
 
3879
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"));
 
3880
    case SP_DialogCloseButton:
 
3881
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-16.png"));
 
3882
    case SP_DialogApplyButton:
 
3883
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-16.png"));
 
3884
    case SP_DialogResetButton:
 
3885
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-reset-16.png"));
 
3886
    case SP_DialogDiscardButton:
 
3887
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-discard-16.png"));
 
3888
    case SP_DialogYesButton:
 
3889
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-16.png"));
 
3890
    case SP_DialogNoButton:
 
3891
        return QPixmap(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-16.png"));
3740
3892
#endif // QT_NO_IMAGEFORMAT_PNG
3741
3893
    default:
3742
3894
        break;
3744
3896
    return QPixmap();
3745
3897
}
3746
3898
 
 
3899
/*!
 
3900
    \internal
 
3901
*/
 
3902
QIcon QCommonStyle::standardIconImplementation(StandardPixmap standardIcon, const QStyleOption *option,
 
3903
                                               const QWidget *widget) const
 
3904
{
 
3905
    QIcon icon;
 
3906
    switch (standardIcon) {
 
3907
#ifndef QT_NO_IMAGEFORMAT_PNG
 
3908
     case SP_FileDialogNewFolder:
 
3909
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-16.png"));
 
3910
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-32.png"));
 
3911
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/newdirectory-128.png"));
 
3912
        break;
 
3913
    case SP_FileDialogBack:
 
3914
        return standardIconImplementation(SP_ArrowBack, option, widget);
 
3915
    case SP_FileDialogToParent:
 
3916
        return standardIconImplementation(SP_ArrowUp, option, widget);
 
3917
    case SP_FileDialogDetailedView:
 
3918
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-16.png"));
 
3919
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-32.png"));
 
3920
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewdetailed-128.png"));
 
3921
        break;
 
3922
    case SP_FileDialogInfoView:
 
3923
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-16.png"));
 
3924
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-32.png"));
 
3925
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/fileinfo-128.png"));
 
3926
        break;
 
3927
    case SP_FileDialogContentsView:
 
3928
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-16.png"));
 
3929
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-32.png"));
 
3930
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/filecontents-128.png"));
 
3931
        break;
 
3932
    case SP_FileDialogListView:
 
3933
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-16.png"));
 
3934
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-32.png"));
 
3935
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/viewlist-128.png"));
 
3936
        break;
 
3937
    case SP_DialogOkButton:
 
3938
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-16.png"));
 
3939
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-32.png"));
 
3940
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-ok-128.png"));
 
3941
        break;
 
3942
    case SP_DialogCancelButton:
 
3943
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-16.png"));
 
3944
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-32.png"));
 
3945
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-cancel-128.png"));
 
3946
        break;
 
3947
    case SP_DialogHelpButton:
 
3948
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-16.png"));
 
3949
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-32.png"));
 
3950
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-help-128.png"));
 
3951
        break;
 
3952
    case SP_DialogOpenButton:
 
3953
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-16.png"));
 
3954
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-32.png"));
 
3955
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-open-128.png"));
 
3956
        break;
 
3957
    case SP_DialogSaveButton:
 
3958
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-16.png"));
 
3959
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-32.png"));
 
3960
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-save-128.png"));
 
3961
        break;
 
3962
    case SP_DialogCloseButton:
 
3963
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-16.png"));
 
3964
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-32.png"));
 
3965
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-close-128.png"));
 
3966
        break;
 
3967
    case SP_DialogApplyButton:
 
3968
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-16.png"));
 
3969
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-32.png"));
 
3970
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-apply-128.png"));
 
3971
        break;
 
3972
    case SP_DialogResetButton:
 
3973
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-reset-16.png"));
 
3974
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-reset-32.png"));
 
3975
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-reset-128.png"));
 
3976
        break;
 
3977
    case SP_DialogDiscardButton:
 
3978
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-discard-16.png"));
 
3979
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-discard-32.png"));
 
3980
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-discard-128.png"));
 
3981
        break;
 
3982
    case SP_DialogYesButton:
 
3983
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-16.png"));
 
3984
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-32.png"));
 
3985
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-yes-128.png"));
 
3986
        break;
 
3987
    case SP_DialogNoButton:
 
3988
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-16.png"));
 
3989
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-32.png"));
 
3990
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/standardbutton-no-128.png"));
 
3991
        break;
 
3992
    case SP_ArrowForward:
 
3993
        if (QApplication::layoutDirection() == Qt::RightToLeft)
 
3994
            return standardIconImplementation(SP_ArrowLeft, option, widget);
 
3995
        return standardIconImplementation(SP_ArrowRight, option, widget);
 
3996
    case SP_ArrowBack:
 
3997
        if (QApplication::layoutDirection() == Qt::RightToLeft)
 
3998
            return standardIconImplementation(SP_ArrowRight, option, widget);
 
3999
        return standardIconImplementation(SP_ArrowLeft, option, widget);
 
4000
    case SP_ArrowLeft:
 
4001
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-16.png"));
 
4002
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-32.png"));
 
4003
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/left-128.png"));
 
4004
        break;
 
4005
    case SP_ArrowRight:
 
4006
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-16.png"));
 
4007
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-32.png"));
 
4008
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/right-128.png"));
 
4009
        break;
 
4010
    case SP_ArrowUp:
 
4011
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-16.png"));
 
4012
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-32.png"));
 
4013
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/up-128.png"));
 
4014
        break;
 
4015
    case SP_ArrowDown:
 
4016
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-16.png"));
 
4017
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-32.png"));
 
4018
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/down-128.png"));
 
4019
        break;
 
4020
   case SP_DirIcon:
 
4021
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-16.png"),
 
4022
                     QSize(), QIcon::Normal, QIcon::Off);
 
4023
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-16.png"),
 
4024
                     QSize(), QIcon::Normal, QIcon::On);
 
4025
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-32.png"),
 
4026
                     QSize(32, 32), QIcon::Normal, QIcon::Off);
 
4027
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-32.png"),
 
4028
                     QSize(32, 32), QIcon::Normal, QIcon::On);
 
4029
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/dirclosed-128.png"),
 
4030
                     QSize(128, 128), QIcon::Normal, QIcon::Off);
 
4031
        icon.addFile(QLatin1String(":/trolltech/styles/commonstyle/images/diropen-128.png"),
 
4032
                     QSize(128, 128), QIcon::Normal, QIcon::On);
 
4033
        break;
 
4034
#endif // QT_NO_IMAGEFORMAT_PNG
 
4035
    default:
 
4036
        icon.addPixmap(standardPixmap(standardIcon, option, widget));
 
4037
        break;
 
4038
    }
 
4039
    return icon;
 
4040
}
 
4041
 
3747
4042
static inline uint qt_intensity(uint r, uint g, uint b)
3748
4043
{
3749
4044
    // 30% red, 59% green, 11% blue
3759
4054
        QImage im = pixmap.toImage().convertToFormat(QImage::Format_ARGB32);
3760
4055
 
3761
4056
        // Create a colortable based on the background (black -> bg -> white)
3762
 
        QColor bg = opt->palette.color(QPalette::Disabled, QPalette::Background);
 
4057
        QColor bg = opt->palette.color(QPalette::Disabled, QPalette::Window);
3763
4058
        int red = bg.red();
3764
4059
        int green = bg.green();
3765
4060
        int blue = bg.blue();
3802
4097
 
3803
4098
        return QPixmap::fromImage(im);
3804
4099
    }
 
4100
    case QIcon::Selected: {
 
4101
        QImage img = pixmap.toImage().convertToFormat(QImage::Format_ARGB32_Premultiplied);
 
4102
        QColor color = opt->palette.color(QPalette::Normal, QPalette::Highlight);
 
4103
        color.setAlphaF(0.3);
 
4104
        QPainter painter(&img);
 
4105
        painter.setCompositionMode(QPainter::CompositionMode_SourceAtop);
 
4106
        painter.fillRect(0, 0, img.width(), img.height(), color);
 
4107
        painter.end();
 
4108
        return QPixmap::fromImage(img); }
3805
4109
    case QIcon::Active:
3806
4110
        return pixmap;
3807
4111
    default: