chore: 格式化ElaWidgetTools代码

This commit is contained in:
sleepwithoutbz
2025-09-20 01:39:00 +08:00
parent d2fded145d
commit 4ab391f8a1
394 changed files with 10913 additions and 15860 deletions

View File

@@ -5,73 +5,51 @@
#include <QStyleOption>
#include "ElaTheme.h"
ElaPivotStyle::ElaPivotStyle(QStyle* style)
{
ElaPivotStyle::ElaPivotStyle(QStyle *style) {
_pCurrentIndex = -1;
_pPivotSpacing = 5;
_themeMode = eTheme->getThemeMode();
connect(eTheme, &ElaTheme::themeModeChanged, this, [=](ElaThemeType::ThemeMode themeMode) {
_themeMode = themeMode;
});
_themeMode = eTheme->getThemeMode();
connect(eTheme, &ElaTheme::themeModeChanged, this, [=](ElaThemeType::ThemeMode themeMode) { _themeMode = themeMode; });
}
ElaPivotStyle::~ElaPivotStyle()
{
}
ElaPivotStyle::~ElaPivotStyle() {}
void ElaPivotStyle::drawPrimitive(PrimitiveElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
{
switch (element)
{
case QStyle::PE_PanelItemViewRow:
{
void ElaPivotStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
switch (element) {
case QStyle::PE_PanelItemViewRow: {
return;
}
case QStyle::PE_Widget:
{
case QStyle::PE_Widget: {
return;
}
default:
{
default: {
break;
}
}
QProxyStyle::drawPrimitive(element, option, painter, widget);
}
void ElaPivotStyle::drawControl(ControlElement element, const QStyleOption* option, QPainter* painter, const QWidget* widget) const
{
switch (element)
{
case QStyle::CE_ShapedFrame:
{
void ElaPivotStyle::drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const {
switch (element) {
case QStyle::CE_ShapedFrame: {
// viewport视口外的其他区域背景
return;
}
case QStyle::CE_ItemViewItem:
{
if (const QStyleOptionViewItem* vopt = qstyleoption_cast<const QStyleOptionViewItem*>(option))
{
case QStyle::CE_ItemViewItem: {
if (const QStyleOptionViewItem *vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option)) {
// 内容绘制
painter->save();
painter->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing);
QRect textRect = proxy()->subElementRect(SE_ItemViewItemText, vopt, widget);
textRect.adjust(0, 0, 0, -5);
// 文字绘制
if (!vopt->text.isEmpty())
{
if (_pPressIndex == vopt->index)
{
if (!vopt->text.isEmpty()) {
if (_pPressIndex == vopt->index) {
painter->setPen(ElaThemeColor(_themeMode, BasicTextPress));
}
else
{
if (_pCurrentIndex == vopt->index.row() || vopt->state.testFlag(QStyle::State_MouseOver))
{
} else {
if (_pCurrentIndex == vopt->index.row() || vopt->state.testFlag(QStyle::State_MouseOver)) {
painter->setPen(ElaThemeColor(_themeMode, BasicText));
}
else
{
} else {
painter->setPen(ElaThemeColor(_themeMode, BasicTextNoFocus));
}
}
@@ -81,24 +59,19 @@ void ElaPivotStyle::drawControl(ControlElement element, const QStyleOption* opti
}
return;
}
default:
{
default: {
break;
}
}
QProxyStyle::drawControl(element, option, painter, widget);
}
int ElaPivotStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, const QWidget* widget) const
{
switch (metric)
{
case QStyle::PM_FocusFrameHMargin:
{
int ElaPivotStyle::pixelMetric(PixelMetric metric, const QStyleOption *option, const QWidget *widget) const {
switch (metric) {
case QStyle::PM_FocusFrameHMargin: {
return _pPivotSpacing;
}
default:
{
default: {
break;
}
}
@@ -106,7 +79,4 @@ int ElaPivotStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, c
return QProxyStyle::pixelMetric(metric, option, widget);
}
const QColor& ElaPivotStyle::getMarkColor()
{
return ElaThemeColor(_themeMode, PrimaryNormal);
}
const QColor &ElaPivotStyle::getMarkColor() { return ElaThemeColor(_themeMode, PrimaryNormal); }