diff options
-rw-r--r-- | src/gui/painting/qcssutil.cpp | 8 | ||||
-rw-r--r-- | src/gui/styles/qstylesheetstyle.cpp | 13 | ||||
-rw-r--r-- | tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui | 433 |
3 files changed, 447 insertions, 7 deletions
diff --git a/src/gui/painting/qcssutil.cpp b/src/gui/painting/qcssutil.cpp index ac0ea08..ae8afed 100644 --- a/src/gui/painting/qcssutil.cpp +++ b/src/gui/painting/qcssutil.cpp @@ -353,7 +353,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles qNormalizeRadii(rect, radii, &tlr, &trr, &blr, &brr); // Drawn in increasing order of precendence - if (styles[BottomEdge] != BorderStyle_None) { + if (styles[BottomEdge] != BorderStyle_None && borders[BottomEdge] > 0) { qreal dw1 = (blr.width() || paintsOver(styles, colors, BottomEdge, LeftEdge)) ? 0 : borders[LeftEdge]; qreal dw2 = (brr.width() || paintsOver(styles, colors, BottomEdge, RightEdge)) ? 0 : borders[RightEdge]; qreal x1 = br.x() + blr.width(); @@ -365,7 +365,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles if (blr.width() || brr.width()) qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]); } - if (styles[RightEdge] != BorderStyle_None) { + if (styles[RightEdge] != BorderStyle_None && borders[RightEdge] > 0) { qreal dw1 = (trr.height() || paintsOver(styles, colors, RightEdge, TopEdge)) ? 0 : borders[TopEdge]; qreal dw2 = (brr.height() || paintsOver(styles, colors, RightEdge, BottomEdge)) ? 0 : borders[BottomEdge]; qreal x1 = br.x() + br.width() - borders[RightEdge]; @@ -377,7 +377,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles if (trr.height() || brr.height()) qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]); } - if (styles[LeftEdge] != BorderStyle_None) { + if (styles[LeftEdge] != BorderStyle_None && borders[LeftEdge] > 0) { qreal dw1 = (tlr.height() || paintsOver(styles, colors, LeftEdge, TopEdge)) ? 0 : borders[TopEdge]; qreal dw2 = (blr.height() || paintsOver(styles, colors, LeftEdge, BottomEdge)) ? 0 : borders[BottomEdge]; qreal x1 = br.x(); @@ -389,7 +389,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles if (tlr.height() || blr.height()) qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]); } - if (styles[TopEdge] != BorderStyle_None) { + if (styles[TopEdge] != BorderStyle_None && borders[TopEdge] > 0) { qreal dw1 = (tlr.width() || paintsOver(styles, colors, TopEdge, LeftEdge)) ? 0 : borders[LeftEdge]; qreal dw2 = (trr.width() || paintsOver(styles, colors, TopEdge, RightEdge)) ? 0 : borders[RightEdge]; qreal x1 = br.x() + tlr.width(); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 370290f..8ac811c 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1298,7 +1298,6 @@ void QRenderRule::unsetClip(QPainter *p) void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& off) { - setClip(p, borderRect(rect)); QBrush brush = hasBackground() ? background()->brush : QBrush(); if (brush.style() == Qt::NoBrush) brush = defaultBackground; @@ -1306,11 +1305,19 @@ void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& o if (brush.style() != Qt::NoBrush) { Origin origin = hasBackground() ? background()->clip : Origin_Border; // ### fix for gradients - p->fillRect(originRect(rect, origin), brush); + const QPainterPath &borderPath = borderClip(originRect(rect, origin)); + if (!borderPath.isEmpty()) { + // Drawn intead of being used as clipping path for better visual quality + bool wasAntialiased = p->renderHints() & QPainter::Antialiasing; + p->setRenderHint(QPainter::Antialiasing); + p->fillPath(borderPath, brush); + p->setRenderHint(QPainter::Antialiasing, wasAntialiased); + } else { + p->fillRect(originRect(rect, origin), brush); + } } drawBackgroundImage(p, rect, off); - unsetClip(p); } void QRenderRule::drawFrame(QPainter *p, const QRect& rect) diff --git a/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui new file mode 100644 index 0000000..96cb7f3 --- /dev/null +++ b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui @@ -0,0 +1,433 @@ +<?xml version="1.0" encoding="UTF-8"?> +<ui version="4.0"> + <class>MainWindow</class> + <widget class="QMainWindow" name="MainWindow"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>698</width> + <height>589</height> + </rect> + </property> + <property name="windowTitle"> + <string>MainWindow</string> + </property> + <property name="styleSheet"> + <string notr="true">* { + background: yellow; + padding: 2px; +} + +QAbstractButton, QAbstractSlider { + background: cyan; +} + +QFrame { + background: magenta; +} + +QLineEdit, QSpinBox { + background: white; +} + +#gb1 * { + border-radius: 4px; +} + +#gb2 * { + border: 1px solid blue; + border-radius: 4px; +} + +#gb3 * { + border: 0px solid blue; + border-radius: 4px; +} + +#gb4 * { + border-image: url("images/pushbutton.png") 6 6 6 6; + border-width:6px; + border-radius: 4px; +} +</string> + </property> + <widget class="QWidget" name="centralwidget"> + <layout class="QGridLayout" name="gridLayout_4"> + <item row="0" column="0"> + <widget class="QGroupBox" name="gb1"> + <property name="title"> + <string>No border</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <item> + <widget class="QFrame" name="frame"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_2"> + <item> + <widget class="QPushButton" name="pushButton_4"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_2"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_6"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_4"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_2"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="0"> + <widget class="QGroupBox" name="gb3"> + <property name="title"> + <string>0px border</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_2"> + <item> + <widget class="QFrame" name="frame_2"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QPushButton" name="pushButton_5"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_3"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_7"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_5"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_2"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_2"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_3"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item row="1" column="1"> + <widget class="QGroupBox" name="gb4"> + <property name="title"> + <string>border-image</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_4"> + <item> + <widget class="QFrame" name="frame_4"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_5"> + <item> + <widget class="QPushButton" name="pushButton_7"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_5"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_9"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_7"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_4"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_4"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_5"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + <item row="0" column="1"> + <widget class="QGroupBox" name="gb2"> + <property name="title"> + <string>1px border</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> + <item> + <widget class="QFrame" name="frame_3"> + <property name="frameShape"> + <enum>QFrame::StyledPanel</enum> + </property> + <property name="frameShadow"> + <enum>QFrame::Raised</enum> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4"> + <item> + <widget class="QPushButton" name="pushButton_6"> + <property name="text"> + <string>PushButton</string> + </property> + </widget> + </item> + <item> + <widget class="QSpinBox" name="spinBox_4"/> + </item> + <item> + <widget class="QRadioButton" name="radioButton_8"> + <property name="text"> + <string>RadioButton</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="checkBox_6"> + <property name="text"> + <string>CheckBox</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="lineEdit_3"> + <property name="text"> + <string/> + </property> + </widget> + </item> + <item> + <widget class="QComboBox" name="comboBox_3"/> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QListWidget" name="listWidget_4"> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + <item> + <property name="text"> + <string>New Item</string> + </property> + </item> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <widget class="QMenuBar" name="menubar"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>698</width> + <height>24</height> + </rect> + </property> + <widget class="QMenu" name="menuFile"> + <property name="title"> + <string>File</string> + </property> + <addaction name="actionOpen"/> + <addaction name="actionClose"/> + </widget> + <widget class="QMenu" name="menuEdit"> + <property name="title"> + <string>Edit</string> + </property> + </widget> + <addaction name="menuFile"/> + <addaction name="menuEdit"/> + </widget> + <widget class="QStatusBar" name="statusbar"/> + <action name="actionOpen"> + <property name="text"> + <string>Open</string> + </property> + </action> + <action name="actionClose"> + <property name="text"> + <string>Close</string> + </property> + </action> + </widget> + <resources/> + <connections/> +</ui> |