mirror of
https://github.com/crystalidea/qt-build-tools.git
synced 2024-11-22 02:34:28 +08:00
6.8, fixed https://bugreports.qt.io/browse/QTBUG-129439
This commit is contained in:
parent
b0937302d5
commit
053d796cef
@ -4,6 +4,7 @@
|
|||||||
#include "qwindows11style_p.h"
|
#include "qwindows11style_p.h"
|
||||||
#include <qstylehints.h>
|
#include <qstylehints.h>
|
||||||
#include <private/qstyleanimation_p.h>
|
#include <private/qstyleanimation_p.h>
|
||||||
|
#include <private/qstyle_p.h>
|
||||||
#include <private/qstylehelper_p.h>
|
#include <private/qstylehelper_p.h>
|
||||||
#include <private/qapplication_p.h>
|
#include <private/qapplication_p.h>
|
||||||
#include <qstyleoption.h>
|
#include <qstyleoption.h>
|
||||||
@ -254,55 +255,42 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
|
|||||||
painter->drawLine(option->rect.bottomLeft() + QPointF(7,-0.5), option->rect.bottomRight() + QPointF(-7,-0.5));
|
painter->drawLine(option->rect.bottomLeft() + QPointF(7,-0.5), option->rect.bottomRight() + QPointF(-7,-0.5));
|
||||||
painter->restore();
|
painter->restore();
|
||||||
}
|
}
|
||||||
QRectF frameRect = option->rect;
|
const QRectF frameRect = QRectF(option->rect).adjusted(2.5, 2.5, -2.5, -2.5);
|
||||||
frameRect.adjust(0.5,0.5,-0.5,-0.5);
|
const QBrush fillBrush = option->palette.brush(QPalette::Base);
|
||||||
QBrush fillColor = option->palette.brush(QPalette::Base);
|
painter->setBrush(fillBrush);
|
||||||
painter->setBrush(fillColor);
|
|
||||||
painter->setPen(QPen(highContrastTheme == true ? sb->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]));
|
painter->setPen(QPen(highContrastTheme == true ? sb->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorLight]));
|
||||||
painter->drawRoundedRect(frameRect.adjusted(2,2,-2,-2), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(frameRect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
QPoint mousePos = widget ? widget->mapFromGlobal(QCursor::pos()) : QPoint();
|
const QPoint mousePos = widget ? widget->mapFromGlobal(QCursor::pos()) : QPoint();
|
||||||
QColor hoverColor = WINUI3Colors[colorSchemeIndex][subtleHighlightColor];
|
|
||||||
if (sub & SC_SpinBoxEditField) {
|
if (sub & SC_SpinBoxEditField) {
|
||||||
QRect rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget).adjusted(0, 0, 0, 1);
|
const QRect rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxEditField, widget).adjusted(0, 0, 0, 1);
|
||||||
if (rect.contains(mousePos) && !(state & State_HasFocus)) {
|
if (!(state & State_HasFocus) && rect.contains(mousePos)) {
|
||||||
QBrush fillColor = QBrush(WINUI3Colors[colorSchemeIndex][subtleHighlightColor]);
|
const QColor fillColor = WINUI3Colors[colorSchemeIndex][subtleHighlightColor];
|
||||||
painter->setBrush(fillColor);
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->drawRoundedRect(option->rect.adjusted(2,2,-2,-2), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->setBrush(QBrush(fillColor));
|
||||||
|
painter->drawRoundedRect(option->rect.adjusted(2, 2, -2, -2), secondLevelRoundingRadius,
|
||||||
|
secondLevelRoundingRadius);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sub & SC_SpinBoxUp) {
|
const auto drawUpDown = [&](QStyle::SubControl sc) {
|
||||||
QRect rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxUp, widget).adjusted(0, 0, 0, 1);
|
const bool isUp = sc == SC_SpinBoxUp;
|
||||||
|
QRect rect = proxy()->subControlRect(CC_SpinBox, option, isUp ? SC_SpinBoxUp : SC_SpinBoxDown, widget);
|
||||||
|
if (isUp)
|
||||||
|
rect.adjust(0, 0, 0, 1);
|
||||||
if (rect.contains(mousePos)) {
|
if (rect.contains(mousePos)) {
|
||||||
|
const QColor hoverColor = WINUI3Colors[colorSchemeIndex][subtleHighlightColor];
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(QBrush(hoverColor));
|
painter->setBrush(QBrush(hoverColor));
|
||||||
painter->drawRoundedRect(rect.adjusted(1,1,-1,-1),secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect.adjusted(1, 1, -1, -1), secondLevelRoundingRadius,
|
||||||
|
secondLevelRoundingRadius);
|
||||||
}
|
}
|
||||||
painter->save();
|
|
||||||
painter->translate(rect.center());
|
|
||||||
painter->translate(-rect.center());
|
|
||||||
painter->setFont(assetFont);
|
painter->setFont(assetFont);
|
||||||
painter->setPen(sb->palette.buttonText().color());
|
painter->setPen(sb->palette.buttonText().color());
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->drawText(rect,"\uE018", Qt::AlignVCenter | Qt::AlignHCenter);
|
const auto str = isUp ? QStringLiteral(u"\uE018") : QStringLiteral(u"\uE019");
|
||||||
painter->restore();
|
painter->drawText(rect, str, Qt::AlignVCenter | Qt::AlignHCenter);
|
||||||
}
|
};
|
||||||
if (sub & SC_SpinBoxDown) {
|
if (sub & SC_SpinBoxUp) drawUpDown(SC_SpinBoxUp);
|
||||||
QRect rect = proxy()->subControlRect(CC_SpinBox, option, SC_SpinBoxDown, widget);
|
if (sub & SC_SpinBoxDown) drawUpDown(SC_SpinBoxDown);
|
||||||
if (rect.contains(mousePos)) {
|
|
||||||
painter->setPen(Qt::NoPen);
|
|
||||||
painter->setBrush(QBrush(hoverColor));
|
|
||||||
painter->drawRoundedRect(rect.adjusted(1,1,-1,-1), secondLevelRoundingRadius, secondLevelRoundingRadius);
|
|
||||||
}
|
|
||||||
painter->save();
|
|
||||||
painter->translate(rect.center());
|
|
||||||
painter->translate(-rect.center());
|
|
||||||
painter->setFont(assetFont);
|
|
||||||
painter->setPen(sb->palette.buttonText().color());
|
|
||||||
painter->setBrush(Qt::NoBrush);
|
|
||||||
painter->drawText(rect,"\uE019", Qt::AlignVCenter | Qt::AlignHCenter);
|
|
||||||
painter->restore();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif // QT_CONFIG(spinbox)
|
#endif // QT_CONFIG(spinbox)
|
||||||
@ -480,70 +468,64 @@ void QWindows11Style::drawComplexControl(ComplexControl control, const QStyleOpt
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
#endif // QT_CONFIG(combobox)
|
#endif // QT_CONFIG(combobox)
|
||||||
case QStyle::CC_ScrollBar:
|
case CC_ScrollBar:
|
||||||
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
if (const QStyleOptionSlider *scrollbar = qstyleoption_cast<const QStyleOptionSlider *>(option)) {
|
||||||
QRectF rect = scrollbar->rect;
|
const bool vertical = scrollbar->orientation == Qt::Vertical;
|
||||||
QPointF center = rect.center();
|
const bool horizontal = scrollbar->orientation == Qt::Horizontal;
|
||||||
|
const bool isMouseOver = state & State_MouseOver;
|
||||||
|
|
||||||
if (scrollbar->orientation == Qt::Vertical && rect.width()>24)
|
if (isMouseOver) {
|
||||||
rect.marginsRemoved(QMargins(0,2,2,2));
|
QRectF rect = scrollbar->rect;
|
||||||
else if (scrollbar->orientation == Qt::Horizontal && rect.height()>24)
|
const QPointF center = rect.center();
|
||||||
rect.marginsRemoved(QMargins(2,0,2,2));
|
if (vertical && rect.width() > 24) {
|
||||||
|
rect.marginsRemoved(QMargins(0, 2, 2, 2));
|
||||||
if (state & State_MouseOver) {
|
rect.setWidth(rect.width() / 2);
|
||||||
if (scrollbar->orientation == Qt::Vertical && rect.width()>24)
|
} else if (horizontal && rect.height() > 24) {
|
||||||
rect.setWidth(rect.width()/2);
|
rect.marginsRemoved(QMargins(2, 0, 2, 2));
|
||||||
else if (scrollbar->orientation == Qt::Horizontal && rect.height()>24)
|
rect.setHeight(rect.height() / 2);
|
||||||
rect.setHeight(rect.height()/2);
|
}
|
||||||
rect.moveCenter(center);
|
rect.moveCenter(center);
|
||||||
painter->setBrush(scrollbar->palette.base());
|
painter->setBrush(scrollbar->palette.base());
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->drawRoundedRect(rect, topLevelRoundingRadius, topLevelRoundingRadius);
|
painter->drawRoundedRect(rect, topLevelRoundingRadius, topLevelRoundingRadius);
|
||||||
|
|
||||||
|
rect = rect.marginsRemoved(QMarginsF(0.5, 0.5, 0.5, 0.5));
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
painter->setPen(WINUI3Colors[colorSchemeIndex][frameColorLight]);
|
painter->setPen(WINUI3Colors[colorSchemeIndex][frameColorLight]);
|
||||||
painter->drawRoundedRect(rect.marginsRemoved(QMarginsF(0.5,0.5,0.5,0.5)), topLevelRoundingRadius + 0.5, topLevelRoundingRadius + 0.5);
|
painter->drawRoundedRect(rect, topLevelRoundingRadius + 0.5, topLevelRoundingRadius + 0.5);
|
||||||
}
|
}
|
||||||
if (sub & SC_ScrollBarSlider) {
|
if (sub & SC_ScrollBarSlider) {
|
||||||
QRectF rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
|
QRectF rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSlider, widget);
|
||||||
QPointF center = rect.center();
|
const QPointF center = rect.center();
|
||||||
if (flags & State_MouseOver) {
|
if (vertical)
|
||||||
if (scrollbar->orientation == Qt::Vertical)
|
rect.setWidth(isMouseOver ? rect.width() / 2 : 1);
|
||||||
rect.setWidth(rect.width()/2);
|
else
|
||||||
else
|
rect.setHeight(isMouseOver ? rect.height() / 2 : 1);
|
||||||
rect.setHeight(rect.height()/2);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (scrollbar->orientation == Qt::Vertical)
|
|
||||||
rect.setWidth(1);
|
|
||||||
else
|
|
||||||
rect.setHeight(1);
|
|
||||||
|
|
||||||
}
|
|
||||||
rect.moveCenter(center);
|
rect.moveCenter(center);
|
||||||
painter->setBrush(Qt::gray);
|
painter->setBrush(Qt::gray);
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
}
|
}
|
||||||
if (sub & SC_ScrollBarAddLine) {
|
if (sub & SC_ScrollBarAddLine) {
|
||||||
QRectF rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
|
if (isMouseOver) {
|
||||||
if (flags & State_MouseOver) {
|
const QRectF rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarAddLine, widget);
|
||||||
painter->setFont(QFont("Segoe Fluent Icons",6));
|
QFont f(assetFont);
|
||||||
|
f.setPointSize(6);
|
||||||
|
painter->setFont(f);
|
||||||
painter->setPen(Qt::gray);
|
painter->setPen(Qt::gray);
|
||||||
if (scrollbar->orientation == Qt::Vertical)
|
const auto str = vertical ? QStringLiteral("\uEDDC") : QStringLiteral("\uEDDA");
|
||||||
painter->drawText(rect,"\uEDDC", Qt::AlignVCenter | Qt::AlignHCenter);
|
painter->drawText(rect, str, Qt::AlignVCenter | Qt::AlignHCenter);
|
||||||
else
|
|
||||||
painter->drawText(rect,"\uEDDA", Qt::AlignVCenter | Qt::AlignHCenter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (sub & SC_ScrollBarSubLine) {
|
if (sub & SC_ScrollBarSubLine) {
|
||||||
QRectF rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
|
if (isMouseOver) {
|
||||||
if (flags & State_MouseOver) {
|
const QRectF rect = proxy()->subControlRect(CC_ScrollBar, option, SC_ScrollBarSubLine, widget);
|
||||||
|
QFont f(assetFont);
|
||||||
|
f.setPointSize(6);
|
||||||
|
painter->setFont(f);
|
||||||
painter->setPen(Qt::gray);
|
painter->setPen(Qt::gray);
|
||||||
if (scrollbar->orientation == Qt::Vertical)
|
const auto str = vertical ? QStringLiteral("\uEDDB") : QStringLiteral("\uEDD9");
|
||||||
painter->drawText(rect,"\uEDDB", Qt::AlignVCenter | Qt::AlignHCenter);
|
painter->drawText(rect, str, Qt::AlignVCenter | Qt::AlignHCenter);
|
||||||
else
|
|
||||||
painter->drawText(rect,"\uEDD9", Qt::AlignVCenter | Qt::AlignHCenter);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -837,6 +819,18 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case PE_IndicatorHeaderArrow:
|
||||||
|
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
|
||||||
|
painter->setPen(header->palette.text().color());
|
||||||
|
painter->setFont(assetFont);
|
||||||
|
QRectF rect = option->rect;
|
||||||
|
if (header->sortIndicator & QStyleOptionHeader::SortUp) {
|
||||||
|
painter->drawText(rect,Qt::AlignCenter,"\uE96D");
|
||||||
|
} else if (header->sortIndicator & QStyleOptionHeader::SortDown) {
|
||||||
|
painter->drawText(rect,Qt::AlignCenter,"\uE96E");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
case PE_IndicatorCheckBox:
|
case PE_IndicatorCheckBox:
|
||||||
{
|
{
|
||||||
QNumberStyleAnimation* animation = qobject_cast<QNumberStyleAnimation*>(d->animation(option->styleObject));
|
QNumberStyleAnimation* animation = qobject_cast<QNumberStyleAnimation*>(d->animation(option->styleObject));
|
||||||
@ -854,14 +848,8 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
clipRect.setLeft(rect.x() + (rect.width() - clipRect.width()) / 2.0);
|
clipRect.setLeft(rect.x() + (rect.width() - clipRect.width()) / 2.0);
|
||||||
clipRect.setWidth(clipWidth * clipRect.width());
|
clipRect.setWidth(clipWidth * clipRect.width());
|
||||||
|
|
||||||
|
|
||||||
QBrush fillBrush = (option->state & State_On || option->state & State_NoChange) ? option->palette.accent() : option->palette.window();
|
|
||||||
if (state & State_MouseOver && (option->state & State_On || option->state & State_NoChange))
|
|
||||||
fillBrush.setColor(fillBrush.color().lighter(107));
|
|
||||||
else if (state & State_MouseOver && !(option->state & State_On || option->state & State_NoChange))
|
|
||||||
fillBrush.setColor(fillBrush.color().darker(107));
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
painter->setBrush(fillBrush);
|
painter->setBrush(buttonFillBrush(option));
|
||||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius, Qt::AbsoluteSize);
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius, Qt::AbsoluteSize);
|
||||||
|
|
||||||
painter->setPen(QPen(highContrastTheme == true ? option->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorStrong]));
|
painter->setPen(QPen(highContrastTheme == true ? option->palette.buttonText().color() : WINUI3Colors[colorSchemeIndex][frameColorStrong]));
|
||||||
@ -926,28 +914,30 @@ void QWindows11Style::drawPrimitive(PrimitiveElement element, const QStyleOption
|
|||||||
break;
|
break;
|
||||||
case PE_PanelButtonTool:
|
case PE_PanelButtonTool:
|
||||||
case PE_PanelButtonBevel:{
|
case PE_PanelButtonBevel:{
|
||||||
QRectF rect = option->rect.marginsRemoved(QMargins(2,2,2,2));
|
const bool isEnabled = state & QStyle::State_Enabled;
|
||||||
rect.adjust(-0.5,-0.5,0.5,0.5);
|
const bool isMouseOver = state & QStyle::State_MouseOver;
|
||||||
|
const bool isRaised = state & QStyle::State_Raised;
|
||||||
|
const QRectF rect = option->rect.marginsRemoved(QMargins(2,2,2,2));
|
||||||
painter->setBrush(Qt::NoBrush);
|
painter->setBrush(Qt::NoBrush);
|
||||||
if (element == PE_PanelButtonTool
|
if (element == PE_PanelButtonTool && ((!isMouseOver && !isRaised) || !isEnabled))
|
||||||
&& ((!(state & QStyle::State_MouseOver) && !(state & QStyle::State_Raised))
|
|
||||||
|| !(state & QStyle::State_Enabled)))
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
else
|
else
|
||||||
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->setBrush(buttonFillBrush(option));
|
||||||
|
painter->drawRoundedRect(rect.marginsAdded(QMargins(0.5, 0.5, 0.5, 0.5)),
|
||||||
|
secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
|
|
||||||
painter->setPen(Qt::NoPen);
|
painter->setPen(Qt::NoPen);
|
||||||
if (!(state & (State_Raised)))
|
if (!isRaised)
|
||||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillTertiary]);
|
||||||
else if (state & State_MouseOver)
|
else if (isMouseOver)
|
||||||
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillSecondary]);
|
painter->setBrush(WINUI3Colors[colorSchemeIndex][controlFillSecondary]);
|
||||||
else
|
else
|
||||||
painter->setBrush(option->palette.button());
|
painter->setBrush(option->palette.button());
|
||||||
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
painter->drawRoundedRect(rect, secondLevelRoundingRadius, secondLevelRoundingRadius);
|
||||||
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][controlStrokeSecondary]));
|
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][controlStrokeSecondary]));
|
||||||
if (state & State_Raised)
|
if (isRaised)
|
||||||
painter->drawLine(rect.bottomLeft() + QPoint(2,1), rect.bottomRight() + QPoint(-2,1));
|
painter->drawLine(rect.bottomLeft() + QPoint(2,1), rect.bottomRight() + QPoint(-2,1));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1187,12 +1177,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
rect.translate(shiftX, shiftY);
|
rect.translate(shiftX, shiftY);
|
||||||
painter->setFont(toolbutton->font);
|
painter->setFont(toolbutton->font);
|
||||||
const QString text = d->toolButtonElideText(toolbutton, rect, alignment);
|
const QString text = d->toolButtonElideText(toolbutton, rect, alignment);
|
||||||
if (toolbutton->state & State_Raised || toolbutton->palette.isBrushSet(QPalette::Current, QPalette::ButtonText))
|
painter->setPen(buttonLabelPen(option, colorSchemeIndex));
|
||||||
painter->setPen(QPen(toolbutton->palette.buttonText().color()));
|
|
||||||
else if (!(toolbutton->state & State_Enabled))
|
|
||||||
painter->setPen(flags & State_On ? QPen(WINUI3Colors[colorSchemeIndex][textAccentDisabled]) : QPen(toolbutton->palette.buttonText().color()));
|
|
||||||
else
|
|
||||||
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][controlTextSecondary]));
|
|
||||||
proxy()->drawItemText(painter, rect, alignment, toolbutton->palette,
|
proxy()->drawItemText(painter, rect, alignment, toolbutton->palette,
|
||||||
toolbutton->state & State_Enabled, text);
|
toolbutton->state & State_Enabled, text);
|
||||||
} else {
|
} else {
|
||||||
@ -1243,12 +1228,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
}
|
}
|
||||||
tr.translate(shiftX, shiftY);
|
tr.translate(shiftX, shiftY);
|
||||||
const QString text = d->toolButtonElideText(toolbutton, tr, alignment);
|
const QString text = d->toolButtonElideText(toolbutton, tr, alignment);
|
||||||
if (toolbutton->state & State_Raised || toolbutton->palette.isBrushSet(QPalette::Current, QPalette::ButtonText))
|
painter->setPen(buttonLabelPen(option, colorSchemeIndex));
|
||||||
painter->setPen(QPen(toolbutton->palette.buttonText().color()));
|
|
||||||
else if (!(toolbutton->state & State_Enabled))
|
|
||||||
painter->setPen(flags & State_On ? QPen(WINUI3Colors[colorSchemeIndex][textAccentDisabled]) : QPen(toolbutton->palette.buttonText().color()));
|
|
||||||
else
|
|
||||||
painter->setPen(QPen(WINUI3Colors[colorSchemeIndex][controlTextSecondary]));
|
|
||||||
proxy()->drawItemText(painter, QStyle::visualRect(toolbutton->direction, rect, tr), alignment, toolbutton->palette,
|
proxy()->drawItemText(painter, QStyle::visualRect(toolbutton->direction, rect, tr), alignment, toolbutton->palette,
|
||||||
toolbutton->state & State_Enabled, text);
|
toolbutton->state & State_Enabled, text);
|
||||||
} else {
|
} else {
|
||||||
@ -1434,13 +1414,7 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
tf |= Qt::AlignHCenter;
|
tf |= Qt::AlignHCenter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
painter->setPen(buttonLabelPen(option, colorSchemeIndex));
|
||||||
if (btn->state & State_Sunken)
|
|
||||||
painter->setPen(flags & State_On ? QPen(WINUI3Colors[colorSchemeIndex][textOnAccentSecondary]) : QPen(WINUI3Colors[colorSchemeIndex][controlTextSecondary]));
|
|
||||||
else if (!(btn->state & State_Enabled))
|
|
||||||
painter->setPen(flags & State_On ? QPen(WINUI3Colors[colorSchemeIndex][textAccentDisabled]) : QPen(btn->palette.buttonText().color()));
|
|
||||||
else
|
|
||||||
painter->setPen(flags & State_On ? QPen(WINUI3Colors[colorSchemeIndex][textOnAccentPrimary]) : QPen(btn->palette.buttonText().color()));
|
|
||||||
proxy()->drawItemText(painter, textRect, tf, option->palette,btn->state & State_Enabled, btn->text);
|
proxy()->drawItemText(painter, textRect, tf, option->palette,btn->state & State_Enabled, btn->text);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1798,6 +1772,9 @@ void QWindows11Style::drawControl(ControlElement element, const QStyleOption *op
|
|||||||
option->rect.x() + 1,option->rect.y() + option->rect.height() - 2);
|
option->rect.x() + 1,option->rect.y() + option->rect.height() - 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget);
|
||||||
|
d->viewItemDrawText(painter, vopt, textRect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -1847,6 +1824,10 @@ QRect QWindows11Style::subElementRect(QStyle::SubElement element, const QStyleOp
|
|||||||
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
|
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case QStyle::SE_HeaderLabel:
|
||||||
|
case QStyle::SE_HeaderArrow:
|
||||||
|
ret = QCommonStyle::subElementRect(element, option, widget);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
|
ret = QWindowsVistaStyle::subElementRect(element, option, widget);
|
||||||
}
|
}
|
||||||
@ -2231,6 +2212,7 @@ static void populateLightSystemBasePalette(QPalette &result)
|
|||||||
const bool styleSheetChanged = oldStyleSheet != qApp->styleSheet();
|
const bool styleSheetChanged = oldStyleSheet != qApp->styleSheet();
|
||||||
|
|
||||||
const QColor textColor = QColor(0x00,0x00,0x00,0xE4);
|
const QColor textColor = QColor(0x00,0x00,0x00,0xE4);
|
||||||
|
const QColor textDisabled = QColor(0x00,0x00,0x00,0x5C);
|
||||||
const QColor btnFace = QColor(0xFF,0xFF,0xFF,0xB3);
|
const QColor btnFace = QColor(0xFF,0xFF,0xFF,0xB3);
|
||||||
const QColor alternateBase = QColor(0x00,0x00,0x00,0x09);
|
const QColor alternateBase = QColor(0x00,0x00,0x00,0x09);
|
||||||
const QColor btnHighlight = result.accent().color();
|
const QColor btnHighlight = result.accent().color();
|
||||||
@ -2253,6 +2235,8 @@ static void populateLightSystemBasePalette(QPalette &result)
|
|||||||
SET_IF_UNRESOLVED(QPalette::All, QPalette::ToolTipText, result.windowText().color());
|
SET_IF_UNRESOLVED(QPalette::All, QPalette::ToolTipText, result.windowText().color());
|
||||||
SET_IF_UNRESOLVED(QPalette::All, QPalette::AlternateBase, alternateBase);
|
SET_IF_UNRESOLVED(QPalette::All, QPalette::AlternateBase, alternateBase);
|
||||||
|
|
||||||
|
result.setColor(QPalette::Disabled, QPalette::WindowText, textDisabled);
|
||||||
|
|
||||||
if (result.midlight() == result.button())
|
if (result.midlight() == result.button())
|
||||||
result.setColor(QPalette::Midlight, btnColor.lighter(110));
|
result.setColor(QPalette::Midlight, btnColor.lighter(110));
|
||||||
oldStyleSheet = qApp->styleSheet();
|
oldStyleSheet = qApp->styleSheet();
|
||||||
@ -2285,6 +2269,31 @@ void QWindows11Style::polish(QPalette& result)
|
|||||||
result.setColor(QPalette::Active, QPalette::HighlightedText, result.windowText().color());
|
result.setColor(QPalette::Active, QPalette::HighlightedText, result.windowText().color());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QBrush QWindows11Style::buttonFillBrush(const QStyleOption *option)
|
||||||
|
{
|
||||||
|
const bool isOn = (option->state & QStyle::State_On || option->state & QStyle::State_NoChange);
|
||||||
|
QBrush brush = isOn ? option->palette.accent() : option->palette.window();
|
||||||
|
if (option->state & QStyle::State_MouseOver)
|
||||||
|
brush.setColor(isOn ? brush.color().lighter(107) : brush.color().darker(107));
|
||||||
|
return brush;
|
||||||
|
}
|
||||||
|
|
||||||
|
QPen QWindows11Style::buttonLabelPen(const QStyleOption *option, int colorSchemeIndex)
|
||||||
|
{
|
||||||
|
if (option->palette.isBrushSet(QPalette::Current, QPalette::ButtonText))
|
||||||
|
return QPen(option->palette.buttonText().color());
|
||||||
|
|
||||||
|
const bool isOn = option->state & QStyle::State_On;
|
||||||
|
if (option->state & QStyle::State_Sunken)
|
||||||
|
return QPen(isOn ? WINUI3Colors[colorSchemeIndex][textOnAccentSecondary]
|
||||||
|
: WINUI3Colors[colorSchemeIndex][controlTextSecondary]);
|
||||||
|
if (!(option->state & QStyle::State_Enabled))
|
||||||
|
return QPen(isOn ? WINUI3Colors[colorSchemeIndex][textAccentDisabled]
|
||||||
|
: option->palette.buttonText().color());
|
||||||
|
return QPen(isOn ? WINUI3Colors[colorSchemeIndex][textOnAccentPrimary]
|
||||||
|
: option->palette.buttonText().color());
|
||||||
|
}
|
||||||
|
|
||||||
#undef SET_IF_UNRESOLVED
|
#undef SET_IF_UNRESOLVED
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -51,6 +51,11 @@ public:
|
|||||||
void unpolish(QWidget *widget) override;
|
void unpolish(QWidget *widget) override;
|
||||||
protected:
|
protected:
|
||||||
QWindows11Style(QWindows11StylePrivate &dd);
|
QWindows11Style(QWindows11StylePrivate &dd);
|
||||||
|
|
||||||
|
private:
|
||||||
|
static inline QBrush buttonFillBrush(const QStyleOption *option);
|
||||||
|
static inline QPen buttonLabelPen(const QStyleOption *option, int colorSchemeIndex);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(QWindows11Style)
|
Q_DISABLE_COPY_MOVE(QWindows11Style)
|
||||||
Q_DECLARE_PRIVATE(QWindows11Style)
|
Q_DECLARE_PRIVATE(QWindows11Style)
|
||||||
|
Loading…
Reference in New Issue
Block a user