chore: 格式化ElaWidgetTools代码
This commit is contained in:
@@ -6,30 +6,20 @@
|
||||
#include <QStyleOption>
|
||||
|
||||
#include "ElaTheme.h"
|
||||
ElaColorDisplayDelegate::ElaColorDisplayDelegate(QObject* parent)
|
||||
: QStyledItemDelegate{parent}
|
||||
{
|
||||
_pThemeMode = eTheme->getThemeMode();
|
||||
}
|
||||
ElaColorDisplayDelegate::ElaColorDisplayDelegate(QObject *parent) : QStyledItemDelegate{parent} { _pThemeMode = eTheme->getThemeMode(); }
|
||||
|
||||
ElaColorDisplayDelegate::~ElaColorDisplayDelegate()
|
||||
{
|
||||
}
|
||||
ElaColorDisplayDelegate::~ElaColorDisplayDelegate() {}
|
||||
|
||||
void ElaColorDisplayDelegate::paint(QPainter* painter, const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
void ElaColorDisplayDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const {
|
||||
painter->save();
|
||||
painter->setRenderHints(QPainter::Antialiasing);
|
||||
QRectF itemRect = option.rect;
|
||||
// 颜色球绘制
|
||||
QColor displayColor = index.data(Qt::UserRole).value<QColor>();
|
||||
if (displayColor.isValid())
|
||||
{
|
||||
if (displayColor.isValid()) {
|
||||
painter->setPen(ElaThemeColor(_pThemeMode, PopupBorderHover));
|
||||
painter->setBrush(index.data(Qt::UserRole).value<QColor>());
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
QPen pen(ElaThemeColor(_pThemeMode, PopupBorderHover));
|
||||
pen.setStyle(Qt::DashLine);
|
||||
painter->setPen(pen);
|
||||
@@ -37,8 +27,7 @@ void ElaColorDisplayDelegate::paint(QPainter* painter, const QStyleOptionViewIte
|
||||
painter->drawEllipse(itemRect.center(), 10, 10);
|
||||
|
||||
// 覆盖效果绘制
|
||||
if (option.state.testFlag(QStyle::State_MouseOver) || option.state.testFlag(QStyle::State_Selected))
|
||||
{
|
||||
if (option.state.testFlag(QStyle::State_MouseOver) || option.state.testFlag(QStyle::State_Selected)) {
|
||||
painter->setBrush(Qt::NoBrush);
|
||||
painter->drawEllipse(itemRect.center(), 13, 13);
|
||||
}
|
||||
@@ -47,7 +36,4 @@ void ElaColorDisplayDelegate::paint(QPainter* painter, const QStyleOptionViewIte
|
||||
QStyledItemDelegate::paint(painter, option, index);
|
||||
}
|
||||
|
||||
QSize ElaColorDisplayDelegate::sizeHint(const QStyleOptionViewItem& option, const QModelIndex& index) const
|
||||
{
|
||||
return QSize(30, 30);
|
||||
}
|
||||
QSize ElaColorDisplayDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const { return QSize(30, 30); }
|
||||
|
||||
Reference in New Issue
Block a user