chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -5,25 +5,18 @@
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "ElaTheme.h"
|
||||
ElaRadioButtonStyle::ElaRadioButtonStyle(QStyle* style)
|
||||
{
|
||||
ElaRadioButtonStyle::ElaRadioButtonStyle(QStyle *style) {
|
||||
_themeMode = eTheme->getThemeMode();
|
||||
connect(eTheme, &ElaTheme::themeModeChanged, this, [=](ElaThemeType::ThemeMode themeMode) { _themeMode = themeMode; });
|
||||
}
|
||||
|
||||
ElaRadioButtonStyle::~ElaRadioButtonStyle()
|
||||
{
|
||||
}
|
||||
ElaRadioButtonStyle::~ElaRadioButtonStyle() {}
|
||||
|
||||
void ElaRadioButtonStyle::drawPrimitive(PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
|
||||
{
|
||||
switch (element)
|
||||
{
|
||||
case PE_IndicatorRadioButton:
|
||||
{
|
||||
const QStyleOptionButton* bopt = qstyleoption_cast<const QStyleOptionButton*>(option);
|
||||
if (!bopt)
|
||||
{
|
||||
void ElaRadioButtonStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
|
||||
switch (element) {
|
||||
case PE_IndicatorRadioButton: {
|
||||
const QStyleOptionButton *bopt = qstyleoption_cast<const QStyleOptionButton *>(option);
|
||||
if (!bopt) {
|
||||
break;
|
||||
}
|
||||
QRect buttonRect = bopt->rect;
|
||||
@@ -31,51 +24,40 @@ void ElaRadioButtonStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
|
||||
painter->save();
|
||||
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform);
|
||||
|
||||
if (bopt->state & QStyle::State_Off)
|
||||
{
|
||||
if (bopt->state & QStyle::State_Off) {
|
||||
painter->setPen(QPen(ElaThemeColor(_themeMode, BasicBorder), 1.5));
|
||||
if (bopt->state & QStyle::State_MouseOver)
|
||||
{
|
||||
if (bopt->state & QStyle::State_MouseOver) {
|
||||
painter->setBrush(ElaThemeColor(_themeMode, BasicHover));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
painter->setBrush(ElaThemeColor(_themeMode, BasicBase));
|
||||
}
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), 8.5, 8.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
painter->setPen(Qt::NoPen);
|
||||
// 外圆形
|
||||
painter->setBrush(ElaThemeColor(_themeMode, PrimaryNormal));
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 2, buttonRect.width() / 2);
|
||||
// 内圆形
|
||||
painter->setBrush(ElaThemeColor(_themeMode, BasicTextInvert));
|
||||
if (bopt->state & QStyle::State_Sunken)
|
||||
{
|
||||
if (bopt->state & QStyle::State_MouseOver)
|
||||
{
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 4.5, buttonRect.width() / 4.5);
|
||||
if (bopt->state & QStyle::State_Sunken) {
|
||||
if (bopt->state & QStyle::State_MouseOver) {
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 4.5,
|
||||
buttonRect.width() / 4.5);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bopt->state & QStyle::State_MouseOver)
|
||||
{
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 3.5, buttonRect.width() / 3.5);
|
||||
}
|
||||
else
|
||||
{
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 4, buttonRect.width() / 4);
|
||||
} else {
|
||||
if (bopt->state & QStyle::State_MouseOver) {
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 3.5,
|
||||
buttonRect.width() / 3.5);
|
||||
} else {
|
||||
painter->drawEllipse(QPointF(buttonRect.center().x() + 1, buttonRect.center().y() + 1), buttonRect.width() / 4,
|
||||
buttonRect.width() / 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
painter->restore();
|
||||
return;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -83,20 +65,15 @@ void ElaRadioButtonStyle::drawPrimitive(PrimitiveElement element, const QStyleOp
|
||||
QProxyStyle::drawPrimitive(element, option, painter, widget);
|
||||
}
|
||||
|
||||
int ElaRadioButtonStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const
|
||||
{
|
||||
switch (metric)
|
||||
{
|
||||
case QStyle::PM_ExclusiveIndicatorWidth:
|
||||
{
|
||||
int ElaRadioButtonStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const {
|
||||
switch (metric) {
|
||||
case QStyle::PM_ExclusiveIndicatorWidth: {
|
||||
return 20;
|
||||
}
|
||||
case QStyle::PM_ExclusiveIndicatorHeight:
|
||||
{
|
||||
case QStyle::PM_ExclusiveIndicatorHeight: {
|
||||
return 20;
|
||||
}
|
||||
default:
|
||||
{
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user