QWindows11Style: HighDPI aware qDrawPlainRoundedRect
Change-Id: Ic9562a20bce59c265c539a1378f5f8fd8e9e9a17 Reviewed-by: Alessandro Portale <alessandro.portale@qt.io> (cherry picked from commit df24438e6a2adb344d78628e7a79432f88fab5e9) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
e831b220d9
commit
8ffd1adfef
@ -736,19 +736,19 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
|
|
||||||
painter->setPen(highContrastTheme == true ? option->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]);
|
painter->setPen(highContrastTheme == true ? option->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]);
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->drawRoundedRect(tipRect.marginsAdded(QMargins(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(tipRect.marginsAdded(QMarginsF(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PE_FrameTabWidget:
|
case PE_FrameTabWidget:
|
||||||
if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
|
if (const QStyleOptionTabWidgetFrame *frame = qstyleoption_cast<const QStyleOptionTabWidgetFrame *>(option)) {
|
||||||
QRectF frameRect = frame->rect.marginsRemoved(QMargins(1,1,1,1));
|
QRectF frameRect = frame->rect.marginsRemoved(QMargins(0,0,0,0));
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(frame->palette.base());
|
painter->setBrush(frame->palette.base());
|
||||||
painter->drawRoundedRect(frameRect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(frameRect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
|
|
||||||
painter->setPen(highContrastTheme == true ? frame->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]);
|
painter->setPen(highContrastTheme == true ? frame->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]);
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->drawRoundedRect(frameRect.marginsAdded(QMargins(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(frameRect.marginsRemoved(QMarginsF(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PE_FrameGroupBox:
|
case PE_FrameGroupBox:
|
||||||
@ -855,8 +855,14 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PE_PanelButtonBevel:{
|
case PE_PanelButtonBevel:{
|
||||||
QRect rect = option->rect.marginsRemoved(QMargins(2,2,2,2));
|
QRectF rect = option->rect.marginsRemoved(QMargins(2,2,2,2));
|
||||||
|
rect.adjust(-0.5,-0.5,0.5,0.5);
|
||||||
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][controlStrokePrimary]));
|
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][controlStrokePrimary]));
|
||||||
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
|
|
||||||
|
rect = option->rect.marginsRemoved(QMargins(2,2,2,2));
|
||||||
|
painter->setPen(Qt::NoPen);
|
||||||
if (!(state & (State_Raised)))
|
if (!(state & (State_Raised)))
|
||||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
||||||
else if (state & State_MouseOver)
|
else if (state & State_MouseOver)
|
||||||
@ -917,7 +923,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
if (const auto *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
|
if (const auto *frame = qstyleoption_cast<const QStyleOptionFrame *>(option)) {
|
||||||
if (frame->frameShape == QFrame::NoFrame)
|
if (frame->frameShape == QFrame::NoFrame)
|
||||||
break;
|
break;
|
||||||
QRectF rect = option->rect.adjusted(2,2,-2,-2);
|
QRectF rect = option->rect.adjusted(1,1,-1,-1);
|
||||||
if (widget && widget->inherits("QComboBoxPrivateContainer")) {
|
if (widget && widget->inherits("QComboBoxPrivateContainer")) {
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][menuPanelFill]);
|
painter->setBrush(WINUI3Colors[colorSchemeIndex][menuPanelFill]);
|
||||||
@ -930,7 +936,7 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
|
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][frameColorLight]));
|
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][frameColorLight]));
|
||||||
painter->drawRoundedRect(rect.marginsAdded(QMargins(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect.marginsRemoved(QMarginsF(0.5,0.5,0.5,0.5)), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
|
|
||||||
if (widget && widget->inherits("QTextEdit")) {
|
if (widget && widget->inherits("QTextEdit")) {
|
||||||
QRegion clipRegion = option->rect;
|
QRegion clipRegion = option->rect;
|
||||||
|
@ -664,8 +664,11 @@ void qDrawPlainRoundedRect(QPainter *p, int x, int y, int w, int h,
|
|||||||
p->save();
|
p->save();
|
||||||
p->setPen(c);
|
p->setPen(c);
|
||||||
p->setBrush(Qt::NoBrush);
|
p->setBrush(Qt::NoBrush);
|
||||||
for (int i=0; i<lineWidth; i++)
|
for (int i=0; i<lineWidth; i++) {
|
||||||
p->drawRoundedRect(x+i, y+i, w-i*2 - 1, h-i*2 - 1, rx, ry);
|
QRectF rect(x+i, y+i, w-i*2 - 1, h-i*2 - 1);
|
||||||
|
rect.marginsRemoved(QMarginsF(0.5,0.5,0.5,0.5));
|
||||||
|
p->drawRoundedRect(rect, rx, ry);
|
||||||
|
}
|
||||||
if (fill) { // fill with fill color
|
if (fill) { // fill with fill color
|
||||||
p->setPen(Qt::NoPen);
|
p->setPen(Qt::NoPen);
|
||||||
p->setBrush(*fill);
|
p->setBrush(*fill);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user