#include "customapplicationstyle.h"
#include <QPainter>
#include <QStyleOption>
#include "editorsettingsoptions.h"

void CustomApplicationStyle::drawPrimitive(PrimitiveElement element, const QStyleOption *option,
                                           QPainter *painter, const QWidget *widget) const
{
    if (element == QStyle::PE_IndicatorItemViewItemDrop) {
        //此为用户拖动进来的操作流程
        painter->setRenderHint(QPainter::Antialiasing, true);

        QColor color(207, 207, 207);
        QPen pen(color);
        pen.setWidth(2);
        painter->setPen(pen);
        //设置一个宽度为2的灰色画笔
        if (option->rect.height() == 0) {
            color.setAlpha(50);
            painter->setBrush(color);
            painter->drawLine(option->rect.topLeft(), option->rect.topRight());
        } else {
            color.setAlpha(200);
            painter->fillRect(option->rect, color);
        }
        //如果高度为0，透明度设置为50%，画线；否则设为不透明，填充灰色
    } else {
        //此为默认创建流程
        QProxyStyle::drawPrimitive(element, option, painter, widget);
    }
}

void CustomApplicationStyle::setTheme(Theme::Value theme)
{
    m_theme = theme;
}
//初始化主题
CustomApplicationStyle::CustomApplicationStyle() : m_theme(Theme::Light) { }
//初始化主题，默认主题为浅色