Ticket #50183: patch-qt5-fix-appearance.diff

File patch-qt5-fix-appearance.diff, 20.1 KB (added by RJVB (René Bertin), 8 years ago)
  • qt5/style/qtcurve.cpp

    diff --git qt5/style/qtcurve.cpp qt5/style/qtcurve.cpp
    index 1e17882..f70e1cb 100644
     
    9898
    9999namespace QtCurve {
    100100
     101static inline void setPainterPen(QPainter *p, const QColor &col, const qreal width=1.0)
     102{
     103    p->setPen(QPen(col, width));
     104}
     105
    101106static Style::Icon
    102107pix2Icon(QStyle::StandardPixmap pix)
    103108{
    Style::drawFadedLine(QPainter *p, const QRect &r, const QColor &col, 
    11931198        if(fadeSizeEnd>=0 && fadeSizeEnd<=1.0)
    11941199            grad.setColorAt(1.0-fadeSizeEnd, col);
    11951200        grad.setColorAt(1, fadeEnd && opts.fadeLines ? fade : col);
    1196         p->setPen(QPen(QBrush(grad), 1));
     1201        p->setPen(QPen(QBrush(grad), QPENWIDTH1));
    11971202    }
    11981203    else
    11991204        p->setPen(col);
    void Style::drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int o 
    12111216        x2(r.x()+r.width()-1),
    12121217        y2(r.y()+r.height()-1),
    12131218        i;
    1214     QPen dp(cols[dark], 1),
    1215         lp(cols[0], 1);
     1219    QPen dp(cols[dark], QPENWIDTH1),
     1220        lp(cols[0], QPENWIDTH1);
    12161221
    12171222    if(opts.fadeLines && (horiz ? r.width() : r.height())>16)
    12181223    {
    void Style::drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int o 
    12251230        grad.setColorAt(0.6, cols[dark]);
    12261231        grad.setColorAt(1, fade);
    12271232
    1228         dp=QPen(QBrush(grad), 1);
     1233        dp=QPen(QBrush(grad), QPENWIDTH1);
    12291234
    12301235        if(LINE_FLAT!=type)
    12311236        {
    void Style::drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int o 
    12361241            grad.setColorAt(0.4, cols[0]);
    12371242            grad.setColorAt(0.6, cols[0]);
    12381243            grad.setColorAt(1, fade);
    1239             lp=QPen(QBrush(grad), 1);
     1244            lp=QPen(QBrush(grad), QPENWIDTH1);
    12401245        }
    12411246    }
    12421247
    Style::drawLightBevel(QPainter *p, const QRect &r, const QStyleOption *option, 
    16131618                        round, (int)realRound, pixSize.width(), pixSize.height(),
    16141619                        state, fill.rgba(), (int)(radius * 100));
    16151620            if (!m_usePixmapCache || !QPixmapCache::find(key, pix)) {
    1616                 const float scale = ((int(pixSize.width() * 1.2) + 1.0) /
    1617                                      pixSize.width());
    1618                 pix = QPixmap(pixSize * scale);
     1621                pix = QPixmap(pixSize);
    16191622                pix.fill(Qt::transparent);
    16201623
    16211624                QPainter pixPainter(&pix);
    1622                 pixPainter.scale(scale, scale);
    16231625                ERound oldRound = opts.round;
    16241626                opts.round = realRound;
     1627                pixPainter.setRenderHint(QPainter::Antialiasing, true);
    16251628                drawLightBevelReal(&pixPainter, QRect(0, 0, pixSize.width(),
    16261629                                                      pixSize.height()), option,
    16271630                                   widget, round, fill, custom, doBorder, w,
    16281631                                   false, realRound, onToolbar);
    16291632                opts.round = oldRound;
    16301633                pixPainter.end();
    1631                 pix = pix.scaled(pixSize);
    16321634
    16331635                if (m_usePixmapCache) {
    16341636                    QPixmapCache::insert(key, pix);
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    17701772                        bool horizontal((horiz && WIDGET_SB_BUTTON!=w)|| (!horiz && WIDGET_SB_BUTTON==w)),
    17711773                            thin(WIDGET_SB_BUTTON==w || WIDGET_SPIN==w || ((horiz ? r.height() : r.width())<16));
    17721774
    1773                         p->setPen(m_mouseOverCols[MO_PLASTIK_DARK(w)]);
     1775                        setPainterPen(p, m_mouseOverCols[MO_PLASTIK_DARK(w)], QPENWIDTH1);
    17741776                        if(horizontal)
    17751777                        {
    17761778                            drawAaLine(p, r.x()+1, r.y()+1, r.x()+r.width()-2, r.y()+1);
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    17831785                        }
    17841786                        if(!thin)
    17851787                        {
    1786                             p->setPen(m_mouseOverCols[MO_PLASTIK_LIGHT(w)]);
     1788                            setPainterPen(p, m_mouseOverCols[MO_PLASTIK_LIGHT(w)], QPENWIDTH1);
    17871789                            if(horizontal)
    17881790                            {
    17891791                                drawAaLine(p, r.x()+1, r.y()+2, r.x()+r.width()-2, r.y()+2);
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    18891891    }
    18901892
    18911893    if (!colouredMouseOver && lightBorder) {
    1892         p->setPen(cols[LIGHT_BORDER(app)]);
     1894        setPainterPen(p, cols[LIGHT_BORDER(app)], QPENWIDTH1);
    18931895        p->drawPath(buildPath(r, w, round,
    18941896                              qtcGetRadius(&opts, r.width(),
    18951897                                           r.height(), w, RADIUS_INTERNAL)));
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    19011903        buildSplitPath(r, round, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_INTERNAL),
    19021904                       innerTlPath, innerBrPath);
    19031905
    1904         p->setPen(border[colouredMouseOver ? MO_STD_LIGHT(w, sunken) : (sunken ? dark : 0)]);
     1906        setPainterPen(p, border[colouredMouseOver ? MO_STD_LIGHT(w, sunken) : (sunken ? dark : 0)], QPENWIDTH1);
    19051907        p->drawPath(innerTlPath);
    19061908        if(colouredMouseOver || bevelledButton || draw3dfull)
    19071909        {
    1908             p->setPen(border[colouredMouseOver ? MO_STD_DARK(w) : (sunken ? 0 : dark)]);
     1910            setPainterPen(p, border[colouredMouseOver ? MO_STD_DARK(w) : (sunken ? 0 : dark)], QPENWIDTH1);
    19091911            p->drawPath(innerBrPath);
    19101912        }
    19111913    }
    void Style::drawGlow(QPainter *p, const QRect &r, EWidget w, const QColor *cols) 
    19671969    col.setAlphaF(GLOW_ALPHA(defShade));
    19681970    p->setBrush(Qt::NoBrush);
    19691971    p->setRenderHint(QPainter::Antialiasing, true);
    1970     p->setPen(col);
     1972    setPainterPen(p, col, QPENWIDTH1);
    19711973    p->drawPath(buildPath(r, w, ROUNDED_ALL, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_ETCH)));
    19721974    p->setRenderHint(QPainter::Antialiasing, QPAINTER_ANTIALIAS_MAYBE_ON);
    19731975}
    void Style::drawEtch(QPainter *p, const QRect &r, const QWidget *widget, EWidge 
    19861988    col.setAlphaF(USE_CUSTOM_ALPHAS(opts) ? opts.customAlphas[ALPHA_ETCH_DARK] : ETCH_TOP_ALPHA);
    19871989    p->setBrush(Qt::NoBrush);
    19881990    p->setRenderHint(QPainter::Antialiasing, true);
    1989     p->setPen(col);
     1991    setPainterPen(p, col, QPENWIDTH1);
    19901992
    19911993    if(!raised && WIDGET_SLIDER!=w)
    19921994    {
    void Style::drawEtch(QPainter *p, const QRect &r, const QWidget *widget, EWidge 
    19951997        {
    19961998            QColor col(Qt::white);
    19971999            col.setAlphaF(USE_CUSTOM_ALPHAS(opts) ? opts.customAlphas[ALPHA_ETCH_LIGHT] : ETCH_BOTTOM_ALPHA); // 0.25);
    1998             p->setPen(col);
     2000            setPainterPen(p, col, QPENWIDTH1);
    19992001        }
    20002002        else
    2001             p->setPen(getLowerEtchCol(widget));
     2003            setPainterPen(p, getLowerEtchCol(widget), QPENWIDTH1);
    20022004    }
    20032005
    20042006    p->drawPath(br);
    void Style::drawBgndRing(QPainter &painter, int x, int y, int size, int size2, b 
    20122014    QColor col(Qt::white);
    20132015
    20142016    col.setAlphaF(RINGS_INNER_ALPHA(isWindow ? opts.bgndImage.type : opts.menuBgndImage.type));
     2017    if (width == 1) {
     2018        width = QPENWIDTH1;
     2019    }
    20152020    painter.setPen(QPen(col, width));
    20162021    painter.drawEllipse(QRectF(x+width2, y+width2, size-width, size-width));
    20172022
    20182023    if(IMG_BORDERED_RINGS==(isWindow ? opts.bgndImage.type : opts.menuBgndImage.type))
    20192024    {
    20202025        col.setAlphaF(RINGS_OUTER_ALPHA);
    2021         painter.setPen(QPen(col, 1));
     2026        painter.setPen(QPen(col, QPENWIDTH1));
    20222027        painter.drawEllipse(QRectF(x, y, size, size));
    20232028        if(size2)
    20242029            painter.drawEllipse(QRectF(x+width, y+width, size2, size2));
    QPixmap Style::drawStripes(const QColor &color, int opacity) const 
    20482053        if(100!=opacity)
    20492054        {
    20502055            col2.setAlphaF(opacity/100.0);
    2051             pixPainter.setPen(col);
     2056            pixPainter.setPen(QPen(col, QPENWIDTH1));
    20522057            for(int i=0; i<pix.height(); i+=4)
    20532058                pixPainter.drawLine(0, i, pix.width()-1, i);
    20542059        }
    20552060        else
    20562061            pixPainter.fillRect(pix.rect(), col);
    2057         pixPainter.setPen(QColor((3*col.red()+col2.red())/4,
     2062        pixPainter.setPen(QPen(QColor((3*col.red()+col2.red())/4,
    20582063                                 (3*col.green()+col2.green())/4,
    20592064                                 (3*col.blue()+col2.blue())/4,
    2060                                  100!=opacity ? col2.alpha() : 255));
     2065                                 100!=opacity ? col2.alpha() : 255), QPENWIDTH1));
    20612066
    20622067        for(int i=1; i<pix.height(); i+=4)
    20632068        {
    20642069            pixPainter.drawLine(0, i, pix.width()-1, i);
    20652070            pixPainter.drawLine(0, i+2, pix.width()-1, i+2);
    20662071        }
    2067         pixPainter.setPen(col2);
     2072        pixPainter.setPen(QPen(col2, QPENWIDTH1));
    20682073        for(int i=2; i<pix.height()-1; i+=4)
    20692074            pixPainter.drawLine(0, i, pix.width()-1, i);
    20702075
    Style::drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, 
    25542559
    25552560            buildSplitPath(inner, round, qtcGetRadius(&opts, inner.width(), inner.height(), w, RADIUS_INTERNAL), topPath, botPath);
    25562561
    2557             p->setPen((enabled || BORDER_SUNKEN==borderProfile) /*&&
     2562            setPainterPen(p, (enabled || BORDER_SUNKEN==borderProfile) /*&&
    25582563                                                                  (BORDER_RAISED==borderProfile || BORDER_LIGHT==borderProfile || hasFocus || APPEARANCE_FLAT!=app)*/
    25592564                      ? tl
    2560                       : option->palette.background().color());
     2565                      : option->palette.background().color(), QPENWIDTH1);
    25612566            p->drawPath(topPath);
    25622567            if(WIDGET_SCROLLVIEW==w || // Because of list view headers, need to draw dark line on right!
    25632568               (! ( (WIDGET_ENTRY==w && !hasFocus && !hasMouseOver) ||
    25642569                    (WIDGET_ENTRY!=w && doBlend && BORDER_SUNKEN==borderProfile) ) ) )
    25652570            {
    25662571                if(!hasFocus && !hasMouseOver && BORDER_LIGHT!=borderProfile && WIDGET_SCROLLVIEW!=w)
    2567                     p->setPen(/*WIDGET_SCROLLVIEW==w && !hasFocus
     2572                    setPainterPen(p, /*WIDGET_SCROLLVIEW==w && !hasFocus
    25682573                                ? checkColour(option, QPalette::Window)
    25692574                                : WIDGET_ENTRY==w && !hasFocus
    25702575                                ? checkColour(option, QPalette::Base)
    25712576                                : */enabled && (BORDER_SUNKEN==borderProfile || hasFocus || /*APPEARANCE_FLAT!=app ||*/
    25722577                                                WIDGET_TAB_TOP==w || WIDGET_TAB_BOT==w)
    25732578                                ? br
    2574                                 : checkColour(option, QPalette::Window));
     2579                                : checkColour(option, QPalette::Window), QPENWIDTH1);
    25752580                p->drawPath(botPath);
    25762581            }
    25772582        }
    Style::drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, 
    25862591
    25872592        col.setAlphaF(LOWER_BORDER_ALPHA);
    25882593        buildSplitPath(r, round, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_EXTERNAL), topPath, botPath);
    2589         p->setPen(/*enabled ? */border/* : col*/);
     2594        p->setPen(QPen(/*enabled ? */border/* : col*/, QPENWIDTH1));
    25902595        p->drawPath(topPath);
    25912596//         if(enabled)
    25922597        p->setPen(col);
    Style::drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, 
    25942599    }
    25952600    else
    25962601    {
    2597         p->setPen(border);
     2602        p->setPen(QPen(border, QPENWIDTH1));
    25982603        p->drawPath(buildPath(r, w, round, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_EXTERNAL)));
    25992604    }
    26002605
  • qt5/style/qtcurve_api.cpp

    diff --git qt5/style/qtcurve_api.cpp qt5/style/qtcurve_api.cpp
    index f418d10..a52f62c 100644
    void Style::drawComplexControl(ComplexControl control, const QStyleOptionComplex 
    53095309
    53105310                    grad.setColorAt(0, dark);
    53115311                    grad.setColorAt(1, m_backgroundCols[QTC_STD_BORDER]);
    5312                     painter->setPen(QPen(QBrush(grad), 1));
     5312                    painter->setPen(QPen(QBrush(grad), QPENWIDTH1));
    53135313                    painter->drawLine(r.x(), start.y(), r.x(), end.y());
    53145314                    painter->drawLine(r.x()+r.width()-1, start.y(), r.x()+r.width()-1, end.y());
    53155315
    void Style::drawComplexControl(ComplexControl control, const QStyleOptionComplex 
    53175317                    {
    53185318                        grad.setColorAt(0, light);
    53195319                        grad.setColorAt(1, m_backgroundCols[0]);
    5320                         painter->setPen(QPen(QBrush(grad), 1));
     5320                        painter->setPen(QPen(QBrush(grad), QPENWIDTH1));
    53215321                        painter->drawLine(r.x()+1, start.y(), r.x()+1, end.y());
    53225322                    }
    53235323                }
  • qt5/style/qtcurve_p.h

    diff --git qt5/style/qtcurve_p.h qt5/style/qtcurve_p.h
    index 6f2ee31..2350227 100644
    bool isA(const QObject *w, const char *type); 
    286286
    287287}
    288288
     289// allow testing pen widths slightly different from 1 as Qt5 might not anti-alias correctly for width 1
     290#define QPENWIDTH1  1
    289291#define QPAINTER_ANTIALIAS_MAYBE_ON true
    290292
    291293#endif
  • qt5/style/qtcurve_primitive.cpp

    diff --git qt5/style/qtcurve_primitive.cpp qt5/style/qtcurve_primitive.cpp
    index c014df8..ad37acb 100644
     
    4848#endif
    4949
    5050namespace QtCurve {
     51
     52static inline void setPainterPen(QPainter *p, const QColor &col, const qreal width=1.0)
     53{
     54    p->setPen(QPen(col, width));
     55}
     56
    5157bool
    5258Style::drawPrimitiveIndicatorTabClose(PrimitiveElement,
    5359                                      const QStyleOption*option,
    Style::drawPrimitiveFrameGroupBox(PrimitiveElement, 
    493499                    col.setAlphaF(0.0);
    494500                    grad.setColorAt(1, col);
    495501                    painter->setRenderHint(QPainter::Antialiasing, true);
    496                     painter->setPen(QPen(QBrush(grad), 1));
     502                    painter->setPen(QPen(QBrush(grad), QPENWIDTH1));
    497503                    painter->drawPath(path);
    498504                }
    499505                if (opts.gbLabel & (GB_LBL_INSIDE | GB_LBL_OUTSIDE)) {
    Style::drawPrimitiveButton(PrimitiveElement element, const QStyleOption *option, 
    12341240            path.lineTo(xd + offset + etchOffset, yd + offset + 6 + etchOffset);
    12351241            path.lineTo(xd + offset + etchOffset, yd + offset + etchOffset);
    12361242            painter->setBrush(cols[isDown ? 0 : 4]);
    1237             painter->setPen(cols[isDown ? 0 : 4]);
     1243            setPainterPen(painter, cols[isDown ? 0 : 4], QPENWIDTH1);
    12381244            painter->setRenderHint(QPainter::Antialiasing, true);
    12391245            painter->drawPath(path);
    12401246            painter->setRenderHint(QPainter::Antialiasing, QPAINTER_ANTIALIAS_MAYBE_ON);
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    15411547            if (opts.crSize != CR_SMALL_SIZE && menu) {
    15421548                y -= 2;
    15431549            }
     1550            painter->setRenderHint(QPainter::Antialiasing, true);
    15441551            drawLightBevel(painter, rect, &opt, widget, ROUNDED_ALL,
    15451552                           getFill(&opt, use, true, false), use, true,
    15461553                           WIDGET_RADIO_BUTTON);
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    15801587            painter->setRenderHint(QPainter::Antialiasing, true);
    15811588            if (coloredMo) {
    15821589                painter->setBrush(Qt::NoBrush);
    1583                 painter->setPen(use[CR_MO_FILL]);
     1590                setPainterPen(painter, use[CR_MO_FILL], QPENWIDTH1);
    15841591                painter->drawArc(QRectF(x + 1, y + 1, opts.crSize - 2,
    15851592                                        opts.crSize - 2), 0, 360 * 16);
    15861593                painter->drawArc(QRectF(x + 2, y + 2, opts.crSize - 4,
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    15931600                if (!glow) {
    15941601                    topCol.setAlphaF(ETCH_RADIO_TOP_ALPHA);
    15951602                }
    1596                 painter->setPen(topCol);
     1603                setPainterPen(painter, topCol, QPENWIDTH1);
    15971604                painter->drawArc(QRectF(x - 0.5, y - 0.5, opts.crSize + 1,
    15981605                                        opts.crSize + 1), 45 * 16, 180 * 16);
    15991606                if (!glow) {
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    16021609                painter->drawArc(QRectF(x - 0.5, y - 0.5, opts.crSize + 1,
    16031610                                        opts.crSize + 1), 225 * 16, 180 * 16);
    16041611            }
    1605             painter->setPen(use[BORDER_VAL(state & State_Enabled)]);
     1612            setPainterPen(painter, use[BORDER_VAL(state & State_Enabled)], QPENWIDTH1);
    16061613            painter->drawArc(QRectF(x + 0.25, y + 0.25, opts.crSize - 0.5,
    16071614                                    opts.crSize - 0.5), 0, 360 * 16);
    16081615            if (!coloredMo) {
    1609                 painter->setPen(btn[state & State_MouseOver ? 3 : 4]);
     1616                setPainterPen(painter, btn[state & State_MouseOver ? 3 : 4], QPENWIDTH1);
    16101617                painter->drawArc(QRectF(x + 0.75, y + 0.75, opts.crSize - 1.5,
    16111618                                        opts.crSize - 1.5),
    16121619                                 lightBorder ? 0 : 45 * 16,
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    16611668        if (r == QRect(0, 0, 14, 15)) { // OO.o 3.2 =14x15?
    16621669            rect.adjust(-1, -1, -1, -1);
    16631670        }
    1664         painter->setPen(option ? option->palette.text().color() :
    1665                         QApplication::palette().text().color());
     1671        setPainterPen(painter, option ? option->palette.text().color() :
     1672                        QApplication::palette().text().color(), QPENWIDTH1);
    16661673        drawRect(painter, r);
    16671674        // LibreOffice its 15x15 - and arrow is not centred, so adjust this...
    16681675        if (r == QRect(0, 0, 15, 15)) {
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    16921699            opt.state &= ~State_On;
    16931700            opt.state |= State_Raised;
    16941701            opt.rect = rect;
     1702            painter->setRenderHint(QPainter::Antialiasing, true);
    16951703            drawLightBevel(painter, rect, &opt, widget, ROUNDED_ALL,
    16961704                           getFill(&opt, use, true, false),
    16971705                           use, true, WIDGET_CHECKBOX);
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    17211729
    17221730            if (opts.coloredMouseOver != MO_NONE && !glow && mo) {
    17231731                painter->setRenderHint(QPainter::Antialiasing, true);
    1724                 painter->setPen(use[CR_MO_FILL]);
     1732                setPainterPen(painter, use[CR_MO_FILL], QPENWIDTH1);
    17251733                drawAaRect(painter, rect.adjusted(1, 1, -1, -1));
    17261734                painter->setRenderHint(QPainter::Antialiasing, QPAINTER_ANTIALIAS_MAYBE_ON);
    17271735            } else {
    1728                 painter->setPen(midColor(state & State_Enabled ?
     1736                setPainterPen(painter, midColor(state & State_Enabled ?
    17291737                                         palette.base().color() :
    1730                                          palette.background().color(), use[3]));
     1738                                         palette.background().color(), use[3]), QPENWIDTH1);
    17311739                if (lightBorder) {
    17321740                    drawRect(painter, rect.adjusted(1, 1, -1, -1));
    17331741                } else {
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    17401748                }
    17411749            }
    17421750
     1751            painter->setRenderHint(QPainter::Antialiasing, true);
    17431752            if (doEtch && !view) {
    17441753                if (glow && !(opts.thin & THIN_FRAMES)) {
    17451754                    drawGlow(painter, r, WIDGET_CHECKBOX);
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    17511760            }
    17521761            drawBorder(painter, rect, option, ROUNDED_ALL, use,
    17531762                       WIDGET_CHECKBOX);
     1763            painter->setRenderHint(QPainter::Antialiasing, QPAINTER_ANTIALIAS_MAYBE_ON);
    17541764        }
    17551765    }
    17561766    if (state & State_On || selectedOOMenu) {
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    17621772        // tri-state
    17631773        int x(rect.center().x()), y(rect.center().y());
    17641774
    1765         painter->setPen(checkRadioCol(option));
     1775        setPainterPen(painter, checkRadioCol(option), QPENWIDTH1);
    17661776        painter->drawLine(x - 3, y, x + 3, y);
    17671777        painter->drawLine(x - 3, y + 1, x + 3, y + 1);
    17681778    }