Ticket #50183: patch-qt5-no-penwidth=1.diff

File patch-qt5-no-penwidth=1.diff, 17.4 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..38c5152 100644
     
    9898
    9999namespace QtCurve {
    100100
     101static inline void setPainterPen(QPainter *p, const QColor &colour, const qreal width=1.0)
     102{
     103    QPen pen(colour, width);
     104    p->setPen(pen);
     105}
     106
    101107static Style::Icon
    102108pix2Icon(QStyle::StandardPixmap pix)
    103109{
    Style::drawFadedLine(QPainter *p, const QRect &r, const QColor &col, 
    11931199        if(fadeSizeEnd>=0 && fadeSizeEnd<=1.0)
    11941200            grad.setColorAt(1.0-fadeSizeEnd, col);
    11951201        grad.setColorAt(1, fadeEnd && opts.fadeLines ? fade : col);
    1196         p->setPen(QPen(QBrush(grad), 1));
     1202        p->setPen(QPen(QBrush(grad), QPenWidth1));
    11971203    }
    11981204    else
    11991205        p->setPen(col);
    void Style::drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int o 
    12111217        x2(r.x()+r.width()-1),
    12121218        y2(r.y()+r.height()-1),
    12131219        i;
    1214     QPen dp(cols[dark], 1),
    1215         lp(cols[0], 1);
     1220    QPen dp(cols[dark], QPenWidth1),
     1221        lp(cols[0], QPenWidth1);
    12161222
    12171223    if(opts.fadeLines && (horiz ? r.width() : r.height())>16)
    12181224    {
    void Style::drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int o 
    12251231        grad.setColorAt(0.6, cols[dark]);
    12261232        grad.setColorAt(1, fade);
    12271233
    1228         dp=QPen(QBrush(grad), 1);
     1234        dp=QPen(QBrush(grad), QPenWidth1);
    12291235
    12301236        if(LINE_FLAT!=type)
    12311237        {
    void Style::drawLines(QPainter *p, const QRect &r, bool horiz, int nLines, int o 
    12361242            grad.setColorAt(0.4, cols[0]);
    12371243            grad.setColorAt(0.6, cols[0]);
    12381244            grad.setColorAt(1, fade);
    1239             lp=QPen(QBrush(grad), 1);
     1245            lp=QPen(QBrush(grad), QPenWidth1);
    12401246        }
    12411247    }
    12421248
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    17701776                        bool horizontal((horiz && WIDGET_SB_BUTTON!=w)|| (!horiz && WIDGET_SB_BUTTON==w)),
    17711777                            thin(WIDGET_SB_BUTTON==w || WIDGET_SPIN==w || ((horiz ? r.height() : r.width())<16));
    17721778
    1773                         p->setPen(m_mouseOverCols[MO_PLASTIK_DARK(w)]);
     1779                        setPainterPen(p, m_mouseOverCols[MO_PLASTIK_DARK(w)], QPenWidth1);
    17741780                        if(horizontal)
    17751781                        {
    17761782                            drawAaLine(p, r.x()+1, r.y()+1, r.x()+r.width()-2, r.y()+1);
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    17831789                        }
    17841790                        if(!thin)
    17851791                        {
    1786                             p->setPen(m_mouseOverCols[MO_PLASTIK_LIGHT(w)]);
     1792                            setPainterPen(p, m_mouseOverCols[MO_PLASTIK_LIGHT(w)], QPenWidth1);
    17871793                            if(horizontal)
    17881794                            {
    17891795                                drawAaLine(p, r.x()+1, r.y()+2, r.x()+r.width()-2, r.y()+2);
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    18891895    }
    18901896
    18911897    if (!colouredMouseOver && lightBorder) {
    1892         p->setPen(cols[LIGHT_BORDER(app)]);
     1898        setPainterPen(p, cols[LIGHT_BORDER(app)], QPenWidth1);
    18931899        p->drawPath(buildPath(r, w, round,
    18941900                              qtcGetRadius(&opts, r.width(),
    18951901                                           r.height(), w, RADIUS_INTERNAL)));
    Style::drawLightBevelReal(QPainter *p, const QRect &rOrig, 
    19011907        buildSplitPath(r, round, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_INTERNAL),
    19021908                       innerTlPath, innerBrPath);
    19031909
    1904         p->setPen(border[colouredMouseOver ? MO_STD_LIGHT(w, sunken) : (sunken ? dark : 0)]);
     1910        setPainterPen(p, border[colouredMouseOver ? MO_STD_LIGHT(w, sunken) : (sunken ? dark : 0)], QPenWidth1);
    19051911        p->drawPath(innerTlPath);
    19061912        if(colouredMouseOver || bevelledButton || draw3dfull)
    19071913        {
    1908             p->setPen(border[colouredMouseOver ? MO_STD_DARK(w) : (sunken ? 0 : dark)]);
     1914            setPainterPen(p, border[colouredMouseOver ? MO_STD_DARK(w) : (sunken ? 0 : dark)], QPenWidth1);
    19091915            p->drawPath(innerBrPath);
    19101916        }
    19111917    }
    void Style::drawGlow(QPainter *p, const QRect &r, EWidget w, const QColor *cols) 
    19671973    col.setAlphaF(GLOW_ALPHA(defShade));
    19681974    p->setBrush(Qt::NoBrush);
    19691975    p->setRenderHint(QPainter::Antialiasing, true);
    1970     p->setPen(col);
     1976    setPainterPen(p, col, QPenWidth1);
    19711977    p->drawPath(buildPath(r, w, ROUNDED_ALL, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_ETCH)));
    19721978    p->setRenderHint(QPainter::Antialiasing, QPAINTER_ANTIALIAS_MAYBE_ON);
    19731979}
    void Style::drawEtch(QPainter *p, const QRect &r, const QWidget *widget, EWidge 
    19861992    col.setAlphaF(USE_CUSTOM_ALPHAS(opts) ? opts.customAlphas[ALPHA_ETCH_DARK] : ETCH_TOP_ALPHA);
    19871993    p->setBrush(Qt::NoBrush);
    19881994    p->setRenderHint(QPainter::Antialiasing, true);
    1989     p->setPen(col);
     1995    setPainterPen(p, col, QPenWidth1);
    19901996
    19911997    if(!raised && WIDGET_SLIDER!=w)
    19921998    {
    void Style::drawEtch(QPainter *p, const QRect &r, const QWidget *widget, EWidge 
    19952001        {
    19962002            QColor col(Qt::white);
    19972003            col.setAlphaF(USE_CUSTOM_ALPHAS(opts) ? opts.customAlphas[ALPHA_ETCH_LIGHT] : ETCH_BOTTOM_ALPHA); // 0.25);
    1998             p->setPen(col);
     2004            setPainterPen(p, col, QPenWidth1);
    19992005        }
    20002006        else
    2001             p->setPen(getLowerEtchCol(widget));
     2007            setPainterPen(p, getLowerEtchCol(widget), QPenWidth1);
    20022008    }
    20032009
    20042010    p->drawPath(br);
    void Style::drawBgndRing(QPainter &painter, int x, int y, int size, int size2, b 
    20122018    QColor col(Qt::white);
    20132019
    20142020    col.setAlphaF(RINGS_INNER_ALPHA(isWindow ? opts.bgndImage.type : opts.menuBgndImage.type));
     2021    if (width == 1) {
     2022        width = QPenWidth1;
     2023    }
    20152024    painter.setPen(QPen(col, width));
    20162025    painter.drawEllipse(QRectF(x+width2, y+width2, size-width, size-width));
    20172026
    20182027    if(IMG_BORDERED_RINGS==(isWindow ? opts.bgndImage.type : opts.menuBgndImage.type))
    20192028    {
    20202029        col.setAlphaF(RINGS_OUTER_ALPHA);
    2021         painter.setPen(QPen(col, 1));
     2030        painter.setPen(QPen(col, QPenWidth1));
    20222031        painter.drawEllipse(QRectF(x, y, size, size));
    20232032        if(size2)
    20242033            painter.drawEllipse(QRectF(x+width, y+width, size2, size2));
    QPixmap Style::drawStripes(const QColor &color, int opacity) const 
    20482057        if(100!=opacity)
    20492058        {
    20502059            col2.setAlphaF(opacity/100.0);
    2051             pixPainter.setPen(col);
     2060            pixPainter.setPen(QPen(col, QPenWidth1));
    20522061            for(int i=0; i<pix.height(); i+=4)
    20532062                pixPainter.drawLine(0, i, pix.width()-1, i);
    20542063        }
    20552064        else
    20562065            pixPainter.fillRect(pix.rect(), col);
    2057         pixPainter.setPen(QColor((3*col.red()+col2.red())/4,
     2066        pixPainter.setPen(QPen(QColor((3*col.red()+col2.red())/4,
    20582067                                 (3*col.green()+col2.green())/4,
    20592068                                 (3*col.blue()+col2.blue())/4,
    2060                                  100!=opacity ? col2.alpha() : 255));
     2069                                 100!=opacity ? col2.alpha() : 255), QPenWidth1));
    20612070
    20622071        for(int i=1; i<pix.height(); i+=4)
    20632072        {
    20642073            pixPainter.drawLine(0, i, pix.width()-1, i);
    20652074            pixPainter.drawLine(0, i+2, pix.width()-1, i+2);
    20662075        }
    2067         pixPainter.setPen(col2);
     2076        pixPainter.setPen(QPen(col2, QPenWidth1));
    20682077        for(int i=2; i<pix.height()-1; i+=4)
    20692078            pixPainter.drawLine(0, i, pix.width()-1, i);
    20702079
    Style::drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, 
    25542563
    25552564            buildSplitPath(inner, round, qtcGetRadius(&opts, inner.width(), inner.height(), w, RADIUS_INTERNAL), topPath, botPath);
    25562565
    2557             p->setPen((enabled || BORDER_SUNKEN==borderProfile) /*&&
     2566            setPainterPen(p, (enabled || BORDER_SUNKEN==borderProfile) /*&&
    25582567                                                                  (BORDER_RAISED==borderProfile || BORDER_LIGHT==borderProfile || hasFocus || APPEARANCE_FLAT!=app)*/
    25592568                      ? tl
    2560                       : option->palette.background().color());
     2569                      : option->palette.background().color(), QPenWidth1);
    25612570            p->drawPath(topPath);
    25622571            if(WIDGET_SCROLLVIEW==w || // Because of list view headers, need to draw dark line on right!
    25632572               (! ( (WIDGET_ENTRY==w && !hasFocus && !hasMouseOver) ||
    25642573                    (WIDGET_ENTRY!=w && doBlend && BORDER_SUNKEN==borderProfile) ) ) )
    25652574            {
    25662575                if(!hasFocus && !hasMouseOver && BORDER_LIGHT!=borderProfile && WIDGET_SCROLLVIEW!=w)
    2567                     p->setPen(/*WIDGET_SCROLLVIEW==w && !hasFocus
     2576                    setPainterPen(p, /*WIDGET_SCROLLVIEW==w && !hasFocus
    25682577                                ? checkColour(option, QPalette::Window)
    25692578                                : WIDGET_ENTRY==w && !hasFocus
    25702579                                ? checkColour(option, QPalette::Base)
    25712580                                : */enabled && (BORDER_SUNKEN==borderProfile || hasFocus || /*APPEARANCE_FLAT!=app ||*/
    25722581                                                WIDGET_TAB_TOP==w || WIDGET_TAB_BOT==w)
    25732582                                ? br
    2574                                 : checkColour(option, QPalette::Window));
     2583                                : checkColour(option, QPalette::Window), QPenWidth1);
    25752584                p->drawPath(botPath);
    25762585            }
    25772586        }
    Style::drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, 
    25862595
    25872596        col.setAlphaF(LOWER_BORDER_ALPHA);
    25882597        buildSplitPath(r, round, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_EXTERNAL), topPath, botPath);
    2589         p->setPen(/*enabled ? */border/* : col*/);
     2598        p->setPen(QPen(/*enabled ? */border/* : col*/, QPenWidth1));
    25902599        p->drawPath(topPath);
    25912600//         if(enabled)
    25922601        p->setPen(col);
    Style::drawBorder(QPainter *p, const QRect &r, const QStyleOption *option, 
    25942603    }
    25952604    else
    25962605    {
    2597         p->setPen(border);
     2606        p->setPen(QPen(border, QPenWidth1));
    25982607        p->drawPath(buildPath(r, w, round, qtcGetRadius(&opts, r.width(), r.height(), w, RADIUS_EXTERNAL)));
    25992608    }
    26002609
  • qt5/style/qtcurve_api.cpp

    diff --git qt5/style/qtcurve_api.cpp qt5/style/qtcurve_api.cpp
    index f418d10..7a555f0 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..7f38291 100644
    void adjustToolbarButtons(const QWidget *widget, const QToolBar *toolbar, 
    284284                          int &bottomAdjust, int &round);
    285285bool isA(const QObject *w, const char *type);
    286286
     287// test: avoid a pen width of exactly 1 as Qt5 (tends to) disrespect(s) anti-alias settings for that width
     288static const qreal QPenWidth1 = 1;
    287289}
    288290
    289291#define QPAINTER_ANTIALIAS_MAYBE_ON true
  • qt5/style/qtcurve_primitive.cpp

    diff --git qt5/style/qtcurve_primitive.cpp qt5/style/qtcurve_primitive.cpp
    index c014df8..51698bc 100644
     
    4848#endif
    4949
    5050namespace QtCurve {
     51
     52static inline void setPainterPen(QPainter *p, const QColor &colour, const qreal width=1.0)
     53{
     54    QPen pen(colour);
     55    pen.setWidthF(width);
     56    p->setPen(pen);
     57}
     58
    5159bool
    5260Style::drawPrimitiveIndicatorTabClose(PrimitiveElement,
    5361                                      const QStyleOption*option,
    Style::drawPrimitiveFrameGroupBox(PrimitiveElement, 
    493501                    col.setAlphaF(0.0);
    494502                    grad.setColorAt(1, col);
    495503                    painter->setRenderHint(QPainter::Antialiasing, true);
    496                     painter->setPen(QPen(QBrush(grad), 1));
     504                    painter->setPen(QPen(QBrush(grad), QPenWidth1));
    497505                    painter->drawPath(path);
    498506                }
    499507                if (opts.gbLabel & (GB_LBL_INSIDE | GB_LBL_OUTSIDE)) {
    Style::drawPrimitiveButton(PrimitiveElement element, const QStyleOption *option, 
    12341242            path.lineTo(xd + offset + etchOffset, yd + offset + 6 + etchOffset);
    12351243            path.lineTo(xd + offset + etchOffset, yd + offset + etchOffset);
    12361244            painter->setBrush(cols[isDown ? 0 : 4]);
    1237             painter->setPen(cols[isDown ? 0 : 4]);
     1245            setPainterPen(painter, cols[isDown ? 0 : 4], QPenWidth1);
    12381246            painter->setRenderHint(QPainter::Antialiasing, true);
    12391247            painter->drawPath(path);
    12401248            painter->setRenderHint(QPainter::Antialiasing, QPAINTER_ANTIALIAS_MAYBE_ON);
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    15801588            painter->setRenderHint(QPainter::Antialiasing, true);
    15811589            if (coloredMo) {
    15821590                painter->setBrush(Qt::NoBrush);
    1583                 painter->setPen(use[CR_MO_FILL]);
     1591                setPainterPen(painter, use[CR_MO_FILL], QPenWidth1);
    15841592                painter->drawArc(QRectF(x + 1, y + 1, opts.crSize - 2,
    15851593                                        opts.crSize - 2), 0, 360 * 16);
    15861594                painter->drawArc(QRectF(x + 2, y + 2, opts.crSize - 4,
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    15931601                if (!glow) {
    15941602                    topCol.setAlphaF(ETCH_RADIO_TOP_ALPHA);
    15951603                }
    1596                 painter->setPen(topCol);
     1604                setPainterPen(painter, topCol, QPenWidth1);
    15971605                painter->drawArc(QRectF(x - 0.5, y - 0.5, opts.crSize + 1,
    15981606                                        opts.crSize + 1), 45 * 16, 180 * 16);
    15991607                if (!glow) {
    Style::drawPrimitiveIndicatorRadioButton(PrimitiveElement, 
    16021610                painter->drawArc(QRectF(x - 0.5, y - 0.5, opts.crSize + 1,
    16031611                                        opts.crSize + 1), 225 * 16, 180 * 16);
    16041612            }
    1605             painter->setPen(use[BORDER_VAL(state & State_Enabled)]);
     1613            setPainterPen(painter, use[BORDER_VAL(state & State_Enabled)], QPenWidth1);
    16061614            painter->drawArc(QRectF(x + 0.25, y + 0.25, opts.crSize - 0.5,
    16071615                                    opts.crSize - 0.5), 0, 360 * 16);
    16081616            if (!coloredMo) {
    1609                 painter->setPen(btn[state & State_MouseOver ? 3 : 4]);
     1617                setPainterPen(painter, btn[state & State_MouseOver ? 3 : 4], QPenWidth1);
    16101618                painter->drawArc(QRectF(x + 0.75, y + 0.75, opts.crSize - 1.5,
    16111619                                        opts.crSize - 1.5),
    16121620                                 lightBorder ? 0 : 45 * 16,
    Style::drawPrimitiveIndicatorCheckBox(PrimitiveElement element, 
    16611669        if (r == QRect(0, 0, 14, 15)) { // OO.o 3.2 =14x15?
    16621670            rect.adjust(-1, -1, -1, -1);
    16631671        }
    1664         painter->setPen(option ? option->palette.text().color() :
    1665                         QApplication::palette().text().color());
     1672        setPainterPen(painter, option ? option->palette.text().color() :
     1673                        QApplication::palette().text().color(), QPenWidth1);
    16661674        drawRect(painter, r);
    16671675        // LibreOffice its 15x15 - and arrow is not centred, so adjust this...
    16681676        if (r == QRect(0, 0, 15, 15)) {
    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, 
    17621770        // tri-state
    17631771        int x(rect.center().x()), y(rect.center().y());
    17641772
    1765         painter->setPen(checkRadioCol(option));
     1773        setPainterPen(painter, checkRadioCol(option), QPenWidth1);
    17661774        painter->drawLine(x - 3, y, x + 3, y);
    17671775        painter->drawLine(x - 3, y + 1, x + 3, y + 1);
    17681776    }