/*
 * Qt5-UKUI's Library
 *
 * Copyright (C) 2023, KylinSoft Co., Ltd.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 3 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this library.  If not, see <https://www.gnu.org/licenses/>.
 *
 * Authors: xibowen <xibowen@kylinos.cn>
 *
 */


#include <QPushButton>
#include <QToolButton>
#include <QApplication>
#include <QPainter>
// #include <KWindowEffects>
#include <QPainterPath>
#include <QDebug>
#include <QObject>
#include <QGSettings>
#include <QDBusMessage>
#include <QDBusArgument>
#include <QDBusConnection>
#include <QFile>
#include <QStandardPaths>
#include <QStyle>

#include "settings/ukui-style-settings.h"
#include "ukui-config-style-parameters.h"
#include "settings/black-list.h"
#include "../platformthemedebug.h"

extern QColor configMixColor(const QColor &c1, const QColor &c2, qreal bias);
extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int transposed);

using namespace UKUIConfigStyleSpace;

UKUIConfigStyleParameters::UKUIConfigStyleParameters(QObject *parent, bool isDark, QString cfgName)
{
//    QDBusMessage message = QDBusMessage::createMethodCall("com.kylin.statusmanager.interface",
//                                                           "/",
//                                                           "com.kylin.statusmanager.interface",
//                                                           "get_current_tabletmode");
//    QDBusMessage ret = QDBusConnection::sessionBus().call(message);
//    if (ret.type() != QDBusMessage::ReplyMessage) {
//        //从返回参数获取返回值
//        cDebug << "complex type failed!";
//    } else {
//        m_isTableMode = ret.arguments()[0].value<bool>();
//    }

    updateParameters(m_isTableMode);

    auto settings = UKUIStyleSettings::globalInstance();
    if (settings->keys().contains("styleName"))
        m_styleName = settings->get("styleName").toString();

    if (settings->keys().contains("widgetThemeName"))
        m_widgetThemeName = settings->get("widgetThemeName").toString();

    if (settings->keys().contains("themeColor"))
        m_themeColor = settings->get("themeColor").toString();

    m_dtconfig = new UKUIGlobalDTConfig::GlobalDTConfig();

    initPalette();
    initElemsDefaultStyleStrategy();
}

UKUIConfigStyleParameters::~UKUIConfigStyleParameters()
{
    if(m_dtconfig)
    {
        delete m_dtconfig;
    }
}

void UKUIConfigStyleParameters::initPalette()
{
    defaultPalette.setColor(QPalette::Active, QPalette::WindowText, m_dtconfig->windowTextActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::WindowText, m_dtconfig->windowTextInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::WindowText, m_dtconfig->windowTextDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Button, m_dtconfig->buttonActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Button, m_dtconfig->buttonInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Button, m_dtconfig->buttonDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Light, m_dtconfig->lightActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Light, m_dtconfig->lightInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Light, m_dtconfig->lightDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Midlight, m_dtconfig->midlightActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Midlight, m_dtconfig->midlightInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Midlight, m_dtconfig->midlightDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Dark, m_dtconfig->darkActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Dark, m_dtconfig->darkInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Dark, m_dtconfig->darkDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Mid, m_dtconfig->midActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Mid, m_dtconfig->midInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Mid, m_dtconfig->midDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Text, m_dtconfig->textActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Text, m_dtconfig->textInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Text, m_dtconfig->textDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::BrightText, m_dtconfig->brightTextActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::BrightText, m_dtconfig->brightTextInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::BrightText, m_dtconfig->brightTextDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::ButtonText, m_dtconfig->buttonTextActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::ButtonText, m_dtconfig->buttonTextInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::ButtonText, m_dtconfig->buttonTextDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Base, m_dtconfig->baseActive().color());
    // defaultPalette.setColor(QPalette::Inactive, QPalette::Base, m_dtconfig->baseInactive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Base, m_dtconfig->baseActive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Base, m_dtconfig->baseDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Window, m_dtconfig->windowActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Window, m_dtconfig->windowInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Window, m_dtconfig->windowDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Shadow, m_dtconfig->shadowActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Shadow, m_dtconfig->shadowInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Shadow, m_dtconfig->shadowDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Highlight, m_dtconfig->highLightActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Highlight, m_dtconfig->highLightInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Highlight, m_dtconfig->highLightDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::HighlightedText, m_dtconfig->highLightedTextActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, m_dtconfig->highLightedTextInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, m_dtconfig->highLightedTextDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::Link, m_dtconfig->linkActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::Link, m_dtconfig->linkInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::Link, m_dtconfig->linkDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::LinkVisited, m_dtconfig->linkVisitedActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, m_dtconfig->linkVisitedInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::LinkVisited, m_dtconfig->linkVisitedDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::AlternateBase, m_dtconfig->alternateBaseActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::AlternateBase, m_dtconfig->alternateBaseInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::AlternateBase, m_dtconfig->alternateBaseDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::NoRole, m_dtconfig->noRoleActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::NoRole, m_dtconfig->noRoleInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::NoRole, m_dtconfig->noRoleDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::ToolTipBase, m_dtconfig->toolTipBaseActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipBase, m_dtconfig->toolTipBaseInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipBase, m_dtconfig->toolTipBaseDisable().color());

    defaultPalette.setColor(QPalette::Active, QPalette::ToolTipText, m_dtconfig->toolTipTextActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipText, m_dtconfig->toolTipTextInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipText, m_dtconfig->toolTipTextDisable().color());

#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
    defaultPalette.setColor(QPalette::Active, QPalette::PlaceholderText, m_dtconfig->placeholderTextActive().color());
    defaultPalette.setColor(QPalette::Inactive, QPalette::PlaceholderText, m_dtconfig->placeholderTextInactive().color());
    defaultPalette.setColor(QPalette::Disabled, QPalette::PlaceholderText, m_dtconfig->placeholderTextDisable().color());
#endif

    Indicator_IconDefault = m_dtconfig->kFontPrimary().color();
    Indicator_IconHover   = m_dtconfig->kFontPrimary().color();
    Indicator_IconSunken  = m_dtconfig->kFontPrimary().color();
    Indicator_IconDisable = m_dtconfig->kFontPrimary().color();
}

QPalette UKUIConfigStyleParameters::setPalette(QPalette &palette)
{
    palette.setColor(QPalette::Active, QPalette::WindowText, defaultPalette.color(QPalette::Active, QPalette::WindowText));
    palette.setColor(QPalette::Inactive, QPalette::WindowText, defaultPalette.color(QPalette::Inactive, QPalette::WindowText));
    palette.setColor(QPalette::Disabled, QPalette::WindowText, defaultPalette.color(QPalette::Disabled, QPalette::WindowText));

    palette.setColor(QPalette::Active, QPalette::Button, defaultPalette.color(QPalette::Active, QPalette::Button));
    palette.setColor(QPalette::Inactive, QPalette::Button, defaultPalette.color(QPalette::Inactive, QPalette::Button));
    palette.setColor(QPalette::Disabled, QPalette::Button, defaultPalette.color(QPalette::Disabled, QPalette::Button));

    palette.setColor(QPalette::Active, QPalette::Light, defaultPalette.color(QPalette::Active, QPalette::Light));
    palette.setColor(QPalette::Inactive, QPalette::Light, defaultPalette.color(QPalette::Inactive, QPalette::Light));
    palette.setColor(QPalette::Disabled, QPalette::Light, defaultPalette.color(QPalette::Disabled, QPalette::Light));

    palette.setColor(QPalette::Active, QPalette::Midlight, defaultPalette.color(QPalette::Active, QPalette::Midlight));
    palette.setColor(QPalette::Inactive, QPalette::Midlight, defaultPalette.color(QPalette::Inactive, QPalette::Midlight));
    palette.setColor(QPalette::Disabled, QPalette::Midlight, defaultPalette.color(QPalette::Disabled, QPalette::Midlight));

    palette.setColor(QPalette::Active, QPalette::Dark, defaultPalette.color(QPalette::Active, QPalette::Dark));
    palette.setColor(QPalette::Inactive, QPalette::Dark, defaultPalette.color(QPalette::Inactive, QPalette::Dark));
    palette.setColor(QPalette::Disabled, QPalette::Dark, defaultPalette.color(QPalette::Disabled, QPalette::Dark));

    palette.setColor(QPalette::Active, QPalette::Mid, defaultPalette.color(QPalette::Active, QPalette::Mid));
    palette.setColor(QPalette::Inactive, QPalette::Mid, defaultPalette.color(QPalette::Inactive, QPalette::Mid));
    palette.setColor(QPalette::Disabled, QPalette::Mid, defaultPalette.color(QPalette::Disabled, QPalette::Mid));

    palette.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Active, QPalette::Text));
    palette.setColor(QPalette::Inactive, QPalette::Text, defaultPalette.color(QPalette::Inactive, QPalette::Text));
    palette.setColor(QPalette::Disabled, QPalette::Text, defaultPalette.color(QPalette::Disabled, QPalette::Text));

    palette.setColor(QPalette::Active, QPalette::BrightText, defaultPalette.color(QPalette::Active, QPalette::BrightText));
    palette.setColor(QPalette::Inactive, QPalette::BrightText, defaultPalette.color(QPalette::Inactive, QPalette::BrightText));
    palette.setColor(QPalette::Disabled, QPalette::BrightText, defaultPalette.color(QPalette::Disabled, QPalette::BrightText));

    palette.setColor(QPalette::Active, QPalette::ButtonText, defaultPalette.color(QPalette::Active, QPalette::ButtonText));
    palette.setColor(QPalette::Inactive, QPalette::ButtonText, defaultPalette.color(QPalette::Inactive, QPalette::ButtonText));
    palette.setColor(QPalette::Disabled, QPalette::ButtonText, defaultPalette.color(QPalette::Disabled, QPalette::ButtonText));

    palette.setColor(QPalette::Active, QPalette::Base, defaultPalette.color(QPalette::Active, QPalette::Base));
    palette.setColor(QPalette::Inactive, QPalette::Base, defaultPalette.color(QPalette::Inactive, QPalette::Base));
    palette.setColor(QPalette::Disabled, QPalette::Base, defaultPalette.color(QPalette::Disabled, QPalette::Base));

    palette.setColor(QPalette::Active, QPalette::Window, defaultPalette.color(QPalette::Active, QPalette::Window));
    palette.setColor(QPalette::Inactive, QPalette::Window, defaultPalette.color(QPalette::Inactive, QPalette::Window));
    palette.setColor(QPalette::Disabled, QPalette::Window, defaultPalette.color(QPalette::Disabled, QPalette::Window));

    palette.setColor(QPalette::Active, QPalette::Shadow, defaultPalette.color(QPalette::Active, QPalette::Shadow));
    palette.setColor(QPalette::Inactive, QPalette::Shadow, defaultPalette.color(QPalette::Inactive, QPalette::Shadow));
    palette.setColor(QPalette::Disabled, QPalette::Shadow, defaultPalette.color(QPalette::Disabled, QPalette::Shadow));

    palette.setColor(QPalette::Active, QPalette::Highlight, defaultPalette.color(QPalette::Active, QPalette::Highlight));
    palette.setColor(QPalette::Inactive, QPalette::Highlight, defaultPalette.color(QPalette::Inactive, QPalette::Highlight));
    palette.setColor(QPalette::Disabled, QPalette::Highlight, defaultPalette.color(QPalette::Disabled, QPalette::Highlight));

    palette.setColor(QPalette::Active, QPalette::HighlightedText, defaultPalette.color(QPalette::Active, QPalette::HighlightedText));
    palette.setColor(QPalette::Inactive, QPalette::HighlightedText, defaultPalette.color(QPalette::Inactive, QPalette::HighlightedText));
    palette.setColor(QPalette::Disabled, QPalette::HighlightedText, defaultPalette.color(QPalette::Disabled, QPalette::HighlightedText));

    palette.setColor(QPalette::Active, QPalette::Link, defaultPalette.color(QPalette::Active, QPalette::Link));
    palette.setColor(QPalette::Inactive, QPalette::Link, defaultPalette.color(QPalette::Inactive, QPalette::Link));
    palette.setColor(QPalette::Disabled, QPalette::Link, defaultPalette.color(QPalette::Disabled, QPalette::Link));

    palette.setColor(QPalette::Active, QPalette::LinkVisited, defaultPalette.color(QPalette::Active, QPalette::LinkVisited));
    palette.setColor(QPalette::Inactive, QPalette::LinkVisited, defaultPalette.color(QPalette::Inactive, QPalette::LinkVisited));
    palette.setColor(QPalette::Disabled, QPalette::LinkVisited, defaultPalette.color(QPalette::Disabled, QPalette::LinkVisited));

    palette.setColor(QPalette::Active, QPalette::AlternateBase, defaultPalette.color(QPalette::Active, QPalette::AlternateBase));
    palette.setColor(QPalette::Inactive, QPalette::AlternateBase, defaultPalette.color(QPalette::Inactive, QPalette::AlternateBase));
    palette.setColor(QPalette::Disabled, QPalette::AlternateBase, defaultPalette.color(QPalette::Disabled, QPalette::AlternateBase));

    palette.setColor(QPalette::Active, QPalette::NoRole, defaultPalette.color(QPalette::Active, QPalette::NoRole));
    palette.setColor(QPalette::Inactive, QPalette::NoRole, defaultPalette.color(QPalette::Inactive, QPalette::NoRole));
    palette.setColor(QPalette::Disabled, QPalette::NoRole, defaultPalette.color(QPalette::Disabled, QPalette::NoRole));

    palette.setColor(QPalette::Active, QPalette::ToolTipBase, defaultPalette.color(QPalette::Active, QPalette::ToolTipBase));
    palette.setColor(QPalette::Inactive, QPalette::ToolTipBase, defaultPalette.color(QPalette::Inactive, QPalette::ToolTipBase));
    palette.setColor(QPalette::Disabled, QPalette::ToolTipBase, defaultPalette.color(QPalette::Disabled, QPalette::ToolTipBase));

    palette.setColor(QPalette::Active, QPalette::ToolTipText, defaultPalette.color(QPalette::Active, QPalette::ToolTipText));
    palette.setColor(QPalette::Inactive, QPalette::ToolTipText, defaultPalette.color(QPalette::Inactive, QPalette::ToolTipText));
    palette.setColor(QPalette::Disabled, QPalette::ToolTipText, defaultPalette.color(QPalette::Disabled, QPalette::ToolTipText));

#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
    palette.setColor(QPalette::Active, QPalette::PlaceholderText, defaultPalette.color(QPalette::Active, QPalette::PlaceholderText));
    palette.setColor(QPalette::Inactive, QPalette::PlaceholderText, defaultPalette.color(QPalette::Inactive, QPalette::PlaceholderText));
    palette.setColor(QPalette::Disabled, QPalette::PlaceholderText, defaultPalette.color(QPalette::Disabled, QPalette::PlaceholderText));
#endif

    return palette;
}

int UKUIConfigStyleParameters::getSpinBoxControlLayout()
{
    return m_spinBoxControlLayout;
}

void UKUIConfigStyleParameters::setUKUIThemeColor(QPalette p, QString themeColor)
{
    m_themeColor = themeColor;
    m_default_palette = p;
}

QString UKUIConfigStyleParameters::themeColor()
{
    return m_themeColor;
}

void UKUIConfigStyleParameters::updateParameters(bool isTabletMode)
{
    if (isTabletMode) {//styleName == "ukui-dark"){//
        m_scaleRatio4_3 = (4 * 1.0) / 3.0;
        m_scaleRatio3_2 = (3 * 1.0) / 2.0;
        m_scaleRatio2_1 = (2 * 1.0) / 1.0;
        m_scaleSliderDefaultLength = (241 * 1.0) / (94 * 1.0);
        m_ScaleComboBoxDefaultLength = (49 * 1.0) / (40 * 1.0);
        m_ScaleLineEditDefaultLength = (49 * 1.0) / (40 * 1.0);
        m_scaleTabBarHeight6_5 = (6 *1.0) / (5 * 1.0);

        m_isTableMode = true;
        m_spinBoxControlLayout = SpinBoxControlLayout::Horizontal;
        m_headerDefaultSectionSizeVertical = m_headerDefaultSectionSizeVertical4_3;
    } else {
        m_scaleRatio4_3 = 1.0;
        m_scaleRatio3_2 = 1.0;
        m_scaleRatio2_1 = 1.0;
        m_scaleSliderDefaultLength = 1.0;
        m_ScaleComboBoxDefaultLength = 1.0;
        m_ScaleLineEditDefaultLength = 1.0;
        m_scaleTabBarHeight6_5 = 1.0;

        m_isTableMode = false;
        m_spinBoxControlLayout = SpinBoxControlLayout::Vertical;
        m_headerDefaultSectionSizeVertical = m_headerDefaultSectionSizeVertical1_1;
    }

    ComboBox_DefaultMenuItemHeight = ComboBox_DefaultMenuItemHeight_original * m_scaleRatio4_3;
    MenuItem_DefaultHeight = MenuItem_DefaultHeight_origin * m_scaleRatio4_3;
    MenuItemSeparator_MarginHeight = MenuItemSeparator_MarginHeight_origin * m_scaleRatio4_3;
    LineEdit_DefaultHeight = LineEdit_DefaultHeight_origin * m_scaleRatio4_3;
    IconButton_DefaultWidth = IconButton_DefaultWidth_origin * m_scaleRatio4_3;
    Button_DefaultHeight = Button_DefaultHeight_origin * m_scaleRatio4_3;
    SpinBox_DefaultHeight = SpinBox_DefaultHeight_origin * m_scaleRatio4_3;
    ComboBox_DefaultHeight = ComboBox_DefaultHeight_origin * m_scaleRatio4_3;
    RadioButton_DefaultHeight = RadioButton_DefaultHeight_origin * m_scaleRatio4_3;
    CheckBox_DefaultHeight = CheckBox_DefaultHeight_origin * m_scaleRatio4_3;
    Table_HeaderHeight = Table_HeaderHeight_origin * m_scaleRatio4_3;
    ScroolBar_Width = ScroolBar_Width_origin * m_scaleRatio3_2;

    Slider_Length = Slider_Length_origin * m_slider_handle_scaleRatio;
    Slider_Thickness = Slider_Thickness_origin * m_slider_handle_scaleRatio;

    Slider_DefaultWidth = Slider_DefaultWidth_origin * m_scaleRatio2_1;
    Slider_GrooveLength = Slider_GrooveLength_origin * m_scaleRatio2_1;
    Slider_DefaultLength = Slider_DefaultLength_origin * m_scaleSliderDefaultLength;

    LineEdit_DefaultWidth = LineEdit_DefaultWidth_origin * m_ScaleLineEditDefaultLength;
    TabBar_DefaultHeight = TabBar_DefaultHeight_origin * m_scaleTabBarHeight6_5;
    ViewItem_DefaultHeight = ViewItem_DefaultHeight_origin * m_scaleRatio4_3;
    ToolTip_Height = ToolTip_Height_origin * m_scaleRatio4_3;
}

QColor UKUIConfigStyleParameters::lanhuHSLToQtHsl(int h, int s, int l, int a)
{
    QColor c;
    c.setHsl(h, s * 255.0 /100.0, l * 255.0 /100.0, a);
    return c;
}

QColor UKUIConfigStyleParameters::adjustColor(const QColor c, int hRange, int sRange, int lRange, int aRange)
{
    QColor cc;
    int s, l, a;

    if ((c.hslSaturationF() + sRange * 1.0 / 100.0) > 1) {
        cWarning << "adjustColor s out of range1";
        s = 255;
    } else if((c.hslSaturationF() + sRange * 1.0 / 100.0) < 0) {
        cWarning << "adjustColor s out of range0";
        s = 0;
    } else
        s = (c.hslSaturationF() + sRange * 1.0 / 100.0) *255.0;

    if ((c.lightnessF() + lRange * 1.0 / 100.0) > 0.97) {//根据设计稿寻光色彩识别   l应<=0.97
        cWarning << "adjustColor l out of range1" << c.lightnessF() << lRange << (c.lightnessF() + lRange * 1.0 / 100.0);
        l = 255.0 * 0.97;
    } else if ((c.lightnessF() + lRange * 1.0 / 100.0) < 0.15) {//根据设计稿上l最小取的均值
        cWarning << "adjustColor l out of range0";
        l = 0.15 * 255.0;
    } else
        l = (c.lightnessF() + lRange * 1.0 / 100.0) *255.0;

    if ((c.alphaF() + aRange * 1.0 / 100.0) > 1) {
        cWarning << "adjustColor a out of range1";
        a = 255;
    } else if ((c.alphaF() + aRange * 1.0 / 100.0) < 0) {
        cWarning << "adjustColor a out of range0";
        a = 0;
    } else
        a = (c.alphaF() + aRange * 1.0 / 100.0) *255.0;

    cc.setHsl(c.hslHue() + hRange, s, l, a);
//    cDebug << "33333" << c.hslHue() + hRange << (c.hslSaturationF() + sRange * 1.0 / 100.0) *255.0 <<
//                (c.lightnessF() + lRange * 1.0 / 100.0) * 255.0 <<
//                (c.alphaF() + aRange * 1.0 / 100.0) * 255.0;

    return  cc;
}

QColor UKUIConfigStyleParameters::adjustH(const QColor c, int range)
{
    QColor cc;
    cc.setHsl(c.hslHue() + range, c.hslSaturation(), c.lightness(), c.alpha());
    return cc;
}

QColor UKUIConfigStyleParameters::adjustS(const QColor c, int range)
{
    QColor cc;
    int s;

    if ((c.hslSaturationF() + range * 1.0 / 100.0) > 1) {
        cWarning << "adjustS s out of range1";
        s = 255;
    } else if ((c.hslSaturationF() + range * 1.0 / 100.0) < 0) {
        cWarning << "adjustS s out of range0";
        s = 0;
    } else
        s = (c.hslSaturationF() + range * 1.0 / 100.0) *255.0;
    cc.setHsl(c.hslHue(), s, c.lightness(), c.alpha());
    return cc;
}

QColor UKUIConfigStyleParameters::adjustL(const QColor c, int range)
{
    QColor cc;
    int l;

    if ((c.lightnessF() + range * 1.0 / 100.0) > 0.97) {
        cWarning << "adjustL l out of range1";
        l = 255.0 * 0.97;
    } else if((c.lightnessF() + range * 1.0 / 100.0) < 0.15) {
        cWarning << "adjustL l out of range0" << c.lightnessF() << range << (c.lightnessF() + range * 1.0 / 100.0);
        l = 255.0 * 0.15;
    } else
        l = (c.lightnessF() + range * 1.0 / 100.0) *255.0;

    cc.setHsl(c.hslHue(), c.hslSaturation(), l, c.alpha());
    return cc;
}

QColor UKUIConfigStyleParameters::adjustA(const QColor c, int range)
{
    QColor cc;
    int a;
    if ((c.alphaF() + range * 1.0 / 100.0) > 1) {
        cWarning << "adjustA a out of range1";
        a = 255;
    } else if ((c.alphaF() + range * 1.0 / 100.0) < 0) {
        cWarning << "adjustA a out of range0";
        a = 0;
    } else
        a = (c.alphaF() + range * 1.0 / 100.0) *255.0;

    cc.setHsl(c.hslHue(), c.hslSaturation(), c.lightness(), a);
    return cc;
}

QColor UKUIConfigStyleParameters::highlightClick(bool isDark, QPalette p)
{
    if (isDark) {
        return adjustColor(p.color(QPalette::Active, QPalette::Highlight), 0, -25, -34);//hightlight->210,72%,71% 210,47%,37%
    }
    return adjustColor(p.color(QPalette::Active, QPalette::Highlight), 3, 10, 31);//hightlight->209,87%,57% 212,97%,88%
}

QColor UKUIConfigStyleParameters::highlightHover(bool isDark, QPalette p)
{
    if (isDark) {
        return adjustColor(p.color(QPalette::Active, QPalette::Highlight), 0, -26, -40);//210,46%,31%
    }
    return adjustColor(p.color(QPalette::Active, QPalette::Highlight), 4, 2, 36);//213,89%,93%
}

QColor UKUIConfigStyleParameters::buttonDarkClick(bool isDark, QPalette p)
{
    if (isDark) {
        return adjustColor(p.color(QPalette::Disabled, QPalette::ButtonText), 0, 1, 5);
    }
    return QColor();
}

void UKUIConfigStyleParameters::normalButtonColor(bool isDark, QPalette p, QPen &defaultPen, QBrush &defaultBrush,
                                                  QPen &hoverPen, QBrush &hoverBrush, QPen &clickPen, QBrush &clickBrush,
                                                  QPen &disablePen, QBrush &disableBrush)
{
    //hover
    if (isDark) {
        //hightlight->210,72%,71% 210,67%,56%
        hoverPen = QPen(QBrush(adjustColor(p.color(QPalette::Active, QPalette::Highlight), 0, -5, -15)),
                        1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    } else {
        //hightlight->209,87%,57% 213,73%,72%
        hoverPen = QPen(QBrush(adjustColor(p.color(QPalette::Active, QPalette::Highlight), 4, -14, 15)),
                        1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    }
    hoverBrush = QBrush(highlightHover(isDark, p));

    //click
    if (isDark) {
        //hightlight->210,72%,71%
        clickPen = QPen(p.brush(QPalette::Active, QPalette::Highlight),
                        1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    } else {
        //hightlight->209,87%,57% 214,66%,60%
        clickPen = QPen(QBrush(adjustColor(p.color(QPalette::Active, QPalette::Highlight), 5, -21, 3)),
                        1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    }
    clickBrush = QBrush(highlightClick(isDark, p));
}

UKUIGlobalDTConfig::GlobalDTConfig* UKUIConfigStyleParameters::readCfg()
{
    if(!m_dtconfig){
        m_dtconfig = new UKUIGlobalDTConfig::GlobalDTConfig();
    }

    return m_dtconfig;
}

void UKUIConfigStyleParameters::initHeaderViewStyle()
{
    QBrush linePenBrush = m_dtconfig->kLineNormal();
    m_verticalDividerLinePen = QPen(linePenBrush,
                                (linePenBrush.style() == Qt::NoBrush || linePenBrush.color().alpha() == 0) ? 0 : 1,
                                    Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
}

QBrush UKUIConfigStyleParameters::parseBrush(QRect rect, QBrush dtBrush)
{
    QBrush result;
    if(dtBrush.style() == Qt::SolidPattern){
        result = dtBrush;
    } else if (dtBrush.style() == Qt::LinearGradientPattern) {
        QLinearGradient linearGradient;
        linearGradient.setStart(rect.topLeft());
        linearGradient.setFinalStop(rect.bottomLeft());
        linearGradient.setStops(dtBrush.gradient()->stops());
        result = QBrush(linearGradient);
    }

    return result;
}

void UKUIConfigStyleParameters::initElemsDefaultStyleStrategy()
{
    int elemCnt = static_cast<int>(StyleCtrlElement::ElementsCount);

    TransparencyUsage.resize(elemCnt);
    TransparencyUsage.fill(true);
    TransparencyUsage.setBit((int)StyleCtrlElement::LineEdit,false);

    FocusUsage.resize(elemCnt);
    FocusUsage.fill(false);

    FocusUsage.setBit((int)StyleCtrlElement::LineEdit,true);
    FocusUsage.setBit((int)StyleCtrlElement::SpinBox,true);
    // FocusUsage.setBit((int)StyleCtrlElement::RadioButton,true);暂时关闭Radio按钮的焦点边框

//    FocusUsage.setBit((int)StyleCtrlElement::PushButtonBevel,true);

//    自定义  半透明实色切换、focus边框绘制，或者在对应组件的参数init函数中初始化
//    TransparencyUsage.setBit((int)StyleCtrlElement::RadioButton,false);
//    ...
//    FocusUsage.setBit((int)StyleCtrlElement::Menu,true);
//    ...


}

void UKUIConfigStyleParameters::initConfigPushButtonBevelParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    m_PushButtonParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::PushButtonBevel]);//是否需要focus状态绘制，使用默认初始值初始化
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::PushButtonBevel];//获取半透明的默认使用情况

    bool isWindowButton = false;
    bool isWindowColoseButton = false;
    bool isImportant = false;
    bool useButtonPalette = false;

    int radius = m_dtconfig->kradiusNormal();


    //Check的颜色应该使用important状态的颜色，无论是否半透明，都是使用同一套颜色
    QBrush checkBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    QBrush checkHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
    QBrush checkClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
    QBrush checkDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable());

    QBrush checkPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    QBrush checkHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover());
    QBrush checkClickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick());
    QBrush checkDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable());

    QBrush inactiveBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());

    QPen checkPen        = QPen(checkPenBrush, (checkPenBrush.style() == Qt::NoBrush || checkPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen checkHoverPen   =  QPen(checkHoverPenBrush, (checkHoverPenBrush.style() == Qt::NoBrush || checkHoverPenBrush.color().alpha() == 0) ? 0 : 1,
                                Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen checkClickPen   = QPen(checkClickPenBrush, (checkClickPenBrush.style() == Qt::NoBrush || checkClickPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen checkDisablePen = QPen(checkDisablePenBrush, (checkDisablePenBrush.style() == Qt::NoBrush || checkDisablePenBrush.color().alpha() == 0) ? 0 : 1,
                                Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen focusPen        = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    //初始化需要显示的状态
    if (widget) {
        if (widget->property("isWindowButton").isValid()) {
            if (widget->property("isWindowButton").toInt() == 0x01) {
                isWindowButton = true;
            }
            if (widget->property("isWindowButton").toInt() == 0x02) {
                isWindowColoseButton = true;
            }
        }
        if (widget->property("isImportant").isValid()) {
            isImportant = widget->property("isImportant").toBool();
        }

        if (widget->property("useButtonPalette").isValid()) {
            useButtonPalette = widget->property("useButtonPalette").toBool();
        }

        if (widget->property("needTranslucent").isValid()) {
            needTranslucent = widget->property("needTranslucent").toBool();
        }
    }

    //初始化组件所使用的的颜色
    QBrush  defaultBrush, disableBrush, hoverBrush, clickBrush,
            defaultPenBrush, hoverPenBrush, clickPenBrush, disablePenBrush;

    //半透明
    if (needTranslucent) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
        hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());

    } else {
        //实色
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
        hoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        clickBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
    }

    defaultPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover());
    clickPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick());
    disablePenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable());

    QPen defaultPen     = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen hoverPen       = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen clickPen       = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen disablePen     = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    //关闭按钮，例如窗口的 叉按钮，应该用红色，v11主题没有针对pushbutton定义这个颜色
    if (isWindowColoseButton) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
        hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorHover());
        clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorClick());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
    }

    //一直选中状态的颜色, v11主题可以移除important状态的颜色设置
    if (isImportant) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
        hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
        clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable());
    }

    auto *w = const_cast<QWidget *>(widget);

    if (w) {
        w->setProperty("radius",            radius);
        w->setProperty("defaultBrush",      defaultBrush);
        w->setProperty("clickBrush",        clickBrush);
        w->setProperty("hoverBrush",        hoverBrush);
        w->setProperty("disableBrush",      disableBrush);
        w->setProperty("checkBrush",        checkBrush);
        w->setProperty("checkHoverBrush",   checkHoverBrush);
        w->setProperty("checkClickBrush",   checkClickBrush);
        w->setProperty("checkDisableBrush", checkDisableBrush);
        w->setProperty("defaultPen",        defaultPen);
        w->setProperty("clickPen",          clickPen);
        w->setProperty("hoverPen",          hoverPen);
        w->setProperty("disablePen",        disablePen);
        w->setProperty("checkPen",          checkPen);
        w->setProperty("checkHoverPen",     checkHoverPen);
        w->setProperty("checkClickPen",     checkClickPen);
        w->setProperty("checkDisablePen",   checkDisablePen);
        w->setProperty("focusPen",          focusPen);
    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert<QBrush>()) {
            clickBrush = widget->property("setClickBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setCheckBrush").isValid() && widget->property("setCheckBrush").canConvert<QBrush>()) {
            checkBrush = widget->property("setCheckBrush").value<QBrush>();
        }
        if (widget->property("setCheckHoverBrush").isValid() && widget->property("setCheckHoverBrush").canConvert<QBrush>()) {
            checkHoverBrush = widget->property("setCheckHoverBrush").value<QBrush>();
        }
        if (widget->property("setCheckClickBrush").isValid() && widget->property("setCheckClickBrush").canConvert<QBrush>()) {
            checkClickBrush = widget->property("setCheckClickBrush").value<QBrush>();
        }
        if (widget->property("setCheckDisableBrush").isValid() && widget->property("setCheckDisableBrush").canConvert<QBrush>()) {
            checkDisableBrush = widget->property("setCheckDisableBrush").value<QBrush>();
        }
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setClickPen").isValid() && widget->property("setClickPen").canConvert<QPen>()) {
            clickPen = widget->property("setClickPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }
        if (widget->property("setCheckPen").isValid() && widget->property("setCheckPen").canConvert<QPen>()) {
            checkPen = widget->property("setCheckPen").value<QPen>();
        }
        if (widget->property("setCheckHoverPen").isValid() && widget->property("setCheckHoverPen").canConvert<QPen>()) {
            checkHoverPen = widget->property("setCheckHoverPen").value<QPen>();
        }
        if (widget->property("setCheckClickPen").isValid() && widget->property("setCheckClickPen").canConvert<QPen>()) {
            checkClickPen = widget->property("setCheckClickPen").value<QPen>();
        }
        if (widget->property("setCheckDisablePen").isValid() && widget->property("setCheckDisablePen").canConvert<QPen>()) {
            checkDisablePen = widget->property("setCheckDisablePen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_PushButtonParameters.radius                      = radius;
    m_PushButtonParameters.pushButtonDefaultBrush      = defaultBrush;
    m_PushButtonParameters.pushButtonClickBrush        = clickBrush;
    m_PushButtonParameters.pushButtonHoverBrush        = hoverBrush;
    m_PushButtonParameters.pushButtonDisableBrush      = disableBrush;
    m_PushButtonParameters.pushButtonCheckBrush        = checkBrush;
    m_PushButtonParameters.pushButtonCheckHoverBrush   = checkHoverBrush;
    m_PushButtonParameters.pushButtonCheckClickBrush   = checkClickBrush;
    m_PushButtonParameters.pushButtonCheckDisableBrush = checkDisableBrush;
    m_PushButtonParameters.pushButtonInactiveBrush     = inactiveBrush;
    m_PushButtonParameters.pushButtonDefaultPen        = defaultPen;
    m_PushButtonParameters.pushButtonClickPen          = clickPen;
    m_PushButtonParameters.pushButtonHoverPen          = hoverPen;
    m_PushButtonParameters.pushButtonDisablePen        = disablePen;
    m_PushButtonParameters.pushButtonCheckPen          = checkPen;
    m_PushButtonParameters.pushButtonCheckHoverPen     = checkHoverPen;
    m_PushButtonParameters.pushButtonCheckClickPen     = checkClickPen;
    m_PushButtonParameters.pushButtonCheckDisablePen   = checkDisablePen;
    m_PushButtonParameters.pushButtonFocusPen          = focusPen;
}

void UKUIConfigStyleParameters::getDefaultConfigPushButtonBevelParameters(ConfigPushButtonParameters *p, bool isDark)
{
    initConfigPushButtonBevelParameters(isDark, nullptr, nullptr);
    p->radius = m_PushButtonParameters.radius;
    p->pushButtonDefaultBrush      = m_PushButtonParameters.pushButtonDefaultBrush     ;
    p->pushButtonClickBrush        = m_PushButtonParameters.pushButtonClickBrush       ;
    p->pushButtonHoverBrush        = m_PushButtonParameters.pushButtonHoverBrush       ;
    p->pushButtonDisableBrush      = m_PushButtonParameters.pushButtonDisableBrush     ;
    p->pushButtonCheckBrush        = m_PushButtonParameters.pushButtonCheckBrush       ;
    p->pushButtonCheckHoverBrush   = m_PushButtonParameters.pushButtonCheckHoverBrush  ;
    p->pushButtonCheckClickBrush   = m_PushButtonParameters.pushButtonCheckClickBrush  ;
    p->pushButtonCheckDisableBrush = m_PushButtonParameters.pushButtonCheckDisableBrush;
    p->pushButtonDefaultPen        = m_PushButtonParameters.pushButtonDefaultPen       ;
    p->pushButtonClickPen          = m_PushButtonParameters.pushButtonClickPen         ;
    p->pushButtonHoverPen          = m_PushButtonParameters.pushButtonHoverPen         ;
    p->pushButtonDisablePen        = m_PushButtonParameters.pushButtonDisablePen       ;
    p->pushButtonCheckPen          = m_PushButtonParameters.pushButtonCheckPen         ;
    p->pushButtonCheckHoverPen     = m_PushButtonParameters.pushButtonCheckHoverPen    ;
    p->pushButtonCheckClickPen     = m_PushButtonParameters.pushButtonCheckClickPen    ;
    p->pushButtonCheckDisablePen   = m_PushButtonParameters.pushButtonCheckDisablePen  ;
    p->pushButtonFocusPen          = m_PushButtonParameters.pushButtonFocusPen         ;
    p->pushButtonInactiveBrush     = m_PushButtonParameters.pushButtonInactiveBrush    ;
}

void UKUIConfigStyleParameters::initConfigPushButtonLabelParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    bool iconHighlight = false;
    bool textHighlight = false;

    const QStyleOptionButton *button = option ? qstyleoption_cast<const QStyleOptionButton *>(option) : nullptr;
    bool isWindowButton = false;
    bool useButtonPalette = false;
    bool isImportant = false;
    bool isWindowColoseButton = false;
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::PushButtonLabel];


    if (widget) {
        if (widget->property("isWindowButton").isValid()) {
            if (widget->property("isWindowButton").toInt() == 0x01) {
                isWindowButton = true;
            }
            if (widget->property("isWindowButton").toInt() == 0x02) {
                isWindowColoseButton = true;
            }
        }
        if (widget->property("isImportant").isValid()) {
            isImportant = widget->property("isImportant").toBool();
        }

        if (widget->property("useButtonPalette").isValid()) {
            useButtonPalette = widget->property("useButtonPalette").toBool();
        }

        if (widget->property("needTranslucent").isValid()) {
            needTranslucent = widget->property("needTranslucent").toBool();
        }
    }

    QColor textDefaultColor   = parseBrush(option ? option->rect : QRect(),isImportant ?
                                             m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color();
    QColor textHoverColor     = parseBrush(option ? option->rect : QRect(), (isImportant || isWindowColoseButton) ?
                                             m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color();
    // QColor textDisableColor   = parseBrush(option ? option->rect : QRect(), isImportant ?
    //                                          m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()).color();

    QColor textDisableColor   = parseBrush(option ? option->rect : QRect(), isImportant ? m_dtconfig->kFontWhiteDisable() : m_dtconfig->kFontPrimaryDisable()).color();

    QColor textHighlightColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightedTextActive()).color();

    //icon
    if (button && (button->state & QStyle::State_On || isWindowColoseButton || isImportant))
        iconHighlight = true;

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("iconHighlight",      iconHighlight);
        w->setProperty("textHighlight",      textHighlight);
        w->setProperty("textDefaultColor",   textDefaultColor);
        w->setProperty("textHoverColor",     textHoverColor);
        w->setProperty("textDisableColor",   textDisableColor);
        w->setProperty("textHighlightColor", textHighlightColor);
    }

    if (widget) {
        if (widget->property("setIconHoverClickHighlight").isValid() && widget->property("setIconHoverClickHighlight").canConvert<bool>()) {
            iconHighlight = widget->property("setIconHoverClickHighlight").value<bool>();
        }
        if (widget->property("setTextHoverClickHighlight").isValid() && widget->property("setTextHoverClickHighlight").canConvert<bool>()) {
            textHighlight = widget->property("setTextHoverClickHighlight").value<bool>();
        }
        if (widget->property("setTextDefaultColor").isValid() && widget->property("setTextDefaultColor").canConvert<QColor>()) {
            textDefaultColor = widget->property("setTextDefaultColor").value<QColor>();
        }
        if (widget->property("setTextHoverColor").isValid() && widget->property("setTextHoverColor").canConvert<QColor>()) {
            textHoverColor = widget->property("setTextHoverColor").value<QColor>();
        }
        if (widget->property("setTextDisableColor").isValid() && widget->property("setTextDisableColor").canConvert<QColor>()) {
            textDisableColor = widget->property("setTextDisableColor").value<QColor>();
        }
        if (widget->property("setTextHighlightColor").isValid() && widget->property("setTextHighlightColor").canConvert<QColor>()) {
            textHighlightColor = widget->property("setTextHighlightColor").value<QColor>();
        }
    }

    m_PushButtonParameters.iconHoverClickHighlight = iconHighlight;
    m_PushButtonParameters.textHoverClickHighlight = textHighlight;
    m_PushButtonParameters.textDefaultColor        = textDefaultColor;
    m_PushButtonParameters.textHoverColor          = textHoverColor;
    m_PushButtonParameters.textDisableColor        = textDisableColor;
    m_PushButtonParameters.textHighlightColor      = textHighlightColor;
}

void UKUIConfigStyleParameters::getDefaultConfigPushButtonLabelParameters(ConfigPushButtonParameters *p, bool isDark)
{
    initConfigPushButtonLabelParameters(isDark, nullptr, nullptr);
    p->iconHoverClickHighlight = m_PushButtonParameters.iconHoverClickHighlight;
    p->textHoverClickHighlight = m_PushButtonParameters.textHoverClickHighlight;
    p->textDefaultColor        = m_PushButtonParameters.textDefaultColor       ;
    p->textHoverColor          = m_PushButtonParameters.textHoverColor         ;
    p->textDisableColor        = m_PushButtonParameters.textDisableColor       ;
    p->textHighlightColor      = m_PushButtonParameters.textHighlightColor     ;
}

void UKUIConfigStyleParameters::initConfigToolButtonPanelParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

    bool isWindowButton = false;
    bool isWindowColoseButton = false;
    bool isImportant = false;
    bool useButtonPalette = false;
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ToolButtonPanel];
    m_ToolButtonParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ToolButtonPanel]);

    int radius = m_dtconfig->kradiusNormal();


    QBrush checkBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive());
    QBrush checkHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
    QBrush checkClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
    QBrush checkDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightDisable());

    QBrush checkPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal());
    QBrush checkHoverPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover());
    QBrush checkClickPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick());
    QBrush checkDisablePenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable());

    QPen checkPen        = QPen(checkPenBrush, (checkPenBrush.style() == Qt::NoBrush || checkPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen checkHoverPen   =  QPen(checkHoverPenBrush, (checkHoverPenBrush.style() == Qt::NoBrush || checkHoverPenBrush.color().alpha() == 0) ? 0 : 1,
                                Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen checkClickPen   = QPen(checkClickPenBrush, (checkClickPenBrush.style() == Qt::NoBrush || checkClickPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen checkDisablePen = QPen(checkDisablePenBrush, (checkDisablePenBrush.style() == Qt::NoBrush || checkDisablePenBrush.color().alpha() == 0) ? 0 : 1,
                                Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen focusPen        = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);



    if (widget) {
        if (widget->property("isWindowButton").isValid()) {
            if (widget->property("isWindowButton").toInt() == 0x01) {
                isWindowButton = true;
            }
            if (widget->property("isWindowButton").toInt() == 0x02) {
                isWindowColoseButton = true;
            }
        }
        if (widget->property("isImportant").isValid()) {
            isImportant = widget->property("isImportant").toBool();
        }

        if (widget->property("useButtonPalette").isValid()) {
            useButtonPalette = widget->property("useButtonPalette").toBool();
        }

        if (widget->property("needTranslucent").isValid()) {
            needTranslucent = widget->property("needTranslucent").toBool();
        }
    }

    QBrush  defaultBrush, disableBrush, hoverBrush, clickBrush,
            defaultPenBrush, hoverPenBrush, clickPenBrush, disablePenBrush;

    if (needTranslucent) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
        hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());

    } else {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
        hoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        clickBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
    }

    defaultPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover());
    clickPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick());
    disablePenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable());


    QPen defaultPen     = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen hoverPen       = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen clickPen       = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen disablePen     = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    if (isWindowColoseButton) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
        hoverBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorHover());
        clickBrush= parseBrush(option ? option->rect : QRect(), m_dtconfig->kErrorClick());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha0());
    }

    if (isImportant) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
        hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
        clickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable());
    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",      defaultBrush);
        w->setProperty("clickBrush",        clickBrush);
        w->setProperty("hoverBrush",        hoverBrush);
        w->setProperty("disableBrush",      disableBrush);
        w->setProperty("checkBrush",        checkBrush);
        w->setProperty("checkHoverBrush",   checkHoverBrush);
        w->setProperty("checkClickBrush",   checkClickBrush);
        w->setProperty("checkDisableBrush", checkDisableBrush);
        w->setProperty("defaultPen",        defaultPen);
        w->setProperty("clickPen",          clickPen);
        w->setProperty("hoverPen",          hoverPen);
        w->setProperty("disablePen",        disablePen);
        w->setProperty("checkPen",          checkPen);
        w->setProperty("checkHoverPen",     checkHoverPen);
        w->setProperty("checkClickPen",     checkClickPen);
        w->setProperty("checkDisablePen",   checkDisablePen);
        w->setProperty("focusPen",          focusPen);
    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert<QBrush>()) {
            clickBrush = widget->property("setClickBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setCheckBrush").isValid() && widget->property("setCheckBrush").canConvert<QBrush>()) {
            checkBrush = widget->property("setCheckBrush").value<QBrush>();
        }
        if (widget->property("setCheckHoverBrush").isValid() && widget->property("setCheckHoverBrush").canConvert<QBrush>()) {
            checkHoverBrush = widget->property("setCheckHoverBrush").value<QBrush>();
        }
        if (widget->property("setCheckClickBrush").isValid() && widget->property("setCheckClickBrush").canConvert<QBrush>()) {
            checkClickBrush = widget->property("setCheckClickBrush").value<QBrush>();
        }
        if (widget->property("setCheckDisableBrush").isValid() && widget->property("setCheckDisableBrush").canConvert<QBrush>()) {
            checkDisableBrush = widget->property("setCheckDisableBrush").value<QBrush>();
        }
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setClickPen").isValid() && widget->property("setClickPen").canConvert<QPen>()) {
            clickPen = widget->property("setClickPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }
        if (widget->property("setCheckPen").isValid() && widget->property("setCheckPen").canConvert<QPen>()) {
            checkPen = widget->property("setCheckPen").value<QPen>();
        }
        if (widget->property("setCheckHoverPen").isValid() && widget->property("setCheckHoverPen").canConvert<QPen>()) {
            checkHoverPen = widget->property("setCheckHoverPen").value<QPen>();
        }
        if (widget->property("setCheckClickPen").isValid() && widget->property("setCheckClickPen").canConvert<QPen>()) {
            checkClickPen = widget->property("setCheckClickPen").value<QPen>();
        }
        if (widget->property("setCheckDisablePen").isValid() && widget->property("setCheckDisablePen").canConvert<QPen>()) {
            checkDisablePen = widget->property("setCheckDisablePen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_ToolButtonParameters.radius                      = radius;
    m_ToolButtonParameters.toolButtonDefaultBrush      = defaultBrush;
    m_ToolButtonParameters.toolButtonClickBrush        = clickBrush;
    m_ToolButtonParameters.toolButtonHoverBrush        = hoverBrush;
    m_ToolButtonParameters.toolButtonDisableBrush      = disableBrush;
    m_ToolButtonParameters.toolButtonCheckBrush        = checkBrush;
    m_ToolButtonParameters.toolButtonCheckHoverBrush   = checkHoverBrush;
    m_ToolButtonParameters.toolButtonCheckClickBrush   = checkClickBrush;
    m_ToolButtonParameters.toolButtonCheckDisableBrush = checkDisableBrush;
    m_ToolButtonParameters.toolButtonDefaultPen        = defaultPen;
    m_ToolButtonParameters.toolButtonClickPen          = clickPen;
    m_ToolButtonParameters.toolButtonHoverPen          = hoverPen;
    m_ToolButtonParameters.toolButtonDisablePen        = disablePen;
    m_ToolButtonParameters.toolButtonCheckPen          = checkPen;
    m_ToolButtonParameters.toolButtonCheckHoverPen     = checkHoverPen;
    m_ToolButtonParameters.toolButtonCheckClickPen     = checkClickPen;
    m_ToolButtonParameters.toolButtonCheckDisablePen   = checkDisablePen;
    m_ToolButtonParameters.toolButtonFocusPen          = focusPen;
}

void UKUIConfigStyleParameters::getDefaultConfigToolButtonPanelParameters(ConfigToolButtonParameters *p, bool isDark)
{
    initConfigToolButtonPanelParameters(isDark, nullptr, nullptr);
    p->radius                      = m_ToolButtonParameters.radius;
    p->toolButtonDefaultBrush      = m_ToolButtonParameters.toolButtonDefaultBrush     ;
    p->toolButtonClickBrush        = m_ToolButtonParameters.toolButtonClickBrush       ;
    p->toolButtonHoverBrush        = m_ToolButtonParameters.toolButtonHoverBrush       ;
    p->toolButtonDisableBrush      = m_ToolButtonParameters.toolButtonDisableBrush     ;
    p->toolButtonCheckBrush        = m_ToolButtonParameters.toolButtonCheckBrush       ;
    p->toolButtonCheckHoverBrush   = m_ToolButtonParameters.toolButtonCheckHoverBrush  ;
    p->toolButtonCheckClickBrush   = m_ToolButtonParameters.toolButtonCheckClickBrush  ;
    p->toolButtonCheckDisableBrush = m_ToolButtonParameters.toolButtonCheckDisableBrush;
    p->toolButtonDefaultPen        = m_ToolButtonParameters.toolButtonDefaultPen       ;
    p->toolButtonClickPen          = m_ToolButtonParameters.toolButtonClickPen         ;
    p->toolButtonHoverPen          = m_ToolButtonParameters.toolButtonHoverPen         ;
    p->toolButtonDisablePen        = m_ToolButtonParameters.toolButtonDisablePen       ;
    p->toolButtonCheckPen          = m_ToolButtonParameters.toolButtonCheckPen         ;
    p->toolButtonCheckHoverPen     = m_ToolButtonParameters.toolButtonCheckHoverPen    ;
    p->toolButtonCheckClickPen     = m_ToolButtonParameters.toolButtonCheckClickPen    ;
    p->toolButtonCheckDisablePen   = m_ToolButtonParameters.toolButtonCheckDisablePen  ;
    p->toolButtonFocusPen          = m_ToolButtonParameters.toolButtonFocusPen         ;

}

void UKUIConfigStyleParameters::initConfigToolButtonLabelParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    bool iconHighlight = false;
    bool textHighlight = false;

    const QStyleOptionToolButton *button = qstyleoption_cast<const QStyleOptionToolButton *>(option);
    bool isWindowButton = false;
    bool useButtonPalette = false;
    bool isImportant = false;
    bool isWindowColoseButton = false;
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ToolButtonLabel];

    if (widget) {
        if (widget->property("isWindowButton").isValid()) {
            if (widget->property("isWindowButton").toInt() == 0x01) {
                isWindowButton = true;
            }
            if (widget->property("isWindowButton").toInt() == 0x02) {
                isWindowColoseButton = true;
            }
        }
        if (widget->property("isImportant").isValid()) {
            isImportant = widget->property("isImportant").toBool();
        }

        if (widget->property("useButtonPalette").isValid()) {
            useButtonPalette = widget->property("useButtonPalette").toBool();
        }

        if (widget->property("needTranslucent").isValid()) {
            needTranslucent = widget->property("needTranslucent").toBool();
        }
    }

    QColor textDefaultColor   = parseBrush(option ? option->rect : QRect(), isImportant
                                         ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color();

    QColor textHoverColor     = parseBrush(option ? option->rect : QRect(), (isImportant || isWindowColoseButton)
                                         ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive()).color();
    QColor textDisableColor   = parseBrush(option ? option->rect : QRect(), isImportant
                                         ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()).color();
    QColor textHighlightColor = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightedTextActive()).color();

    //icon
    if (button && (button->state & QStyle::State_On || isWindowColoseButton || isImportant))
        iconHighlight = true;

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("iconHighlight", iconHighlight);
        w->setProperty("textHighlight", textHighlight);
        w->setProperty("textDefaultColor", textDefaultColor);
        w->setProperty("textHoverColor",   textHoverColor);
        w->setProperty("textDisableColor", textDisableColor);
        w->setProperty("textHighlightColor", textHighlightColor);
    }
    if (widget) {

        if (widget->property("setIconHoverClickHighlight").isValid() && widget->property("setIconHoverClickHighlight").canConvert<bool>()) {
            iconHighlight = widget->property("setIconHoverClickHighlight").value<bool>();
        }
        if (widget->property("setTextHoverClickHighlight").isValid() && widget->property("setTextHoverClickHighlight").canConvert<bool>()) {
            textHighlight = widget->property("setTextHoverClickHighlight").value<bool>();
        }
        if (widget->property("setTextDefaultColor").isValid() && widget->property("setTextDefaultColor").canConvert<QColor>()) {
            textDefaultColor = widget->property("setTextDefaultColor").value<QColor>();
        }
        if (widget->property("setTextHoverColor").isValid() && widget->property("setTextHoverColor").canConvert<QColor>()) {
            textHoverColor = widget->property("setTextHoverColor").value<QColor>();
        }
        if (widget->property("setTextDisableColor").isValid() && widget->property("setTextDisableColor").canConvert<QColor>()) {
            textDisableColor = widget->property("setTextDisableColor").value<QColor>();
        }
        if (widget->property("setTextHighlightColor").isValid() && widget->property("setTextHighlightColor").canConvert<QColor>()) {
            textHighlightColor = widget->property("setTextHighlightColor").value<QColor>();
        }
    }

    m_ToolButtonParameters.iconHoverClickHighlight   = iconHighlight;
    m_ToolButtonParameters.textHoverClickHighlight   = textHighlight;
    m_ToolButtonParameters.textDefaultColor          = textDefaultColor;
    m_ToolButtonParameters.textHoverColor            = textHoverColor;
    m_ToolButtonParameters.textDisableColor          = textDisableColor;
    m_ToolButtonParameters.textHighlightColor        = textHighlightColor;
}

void UKUIConfigStyleParameters::getDefaultConfigToolButtonLabelParameters(ConfigToolButtonParameters *p, bool isDark)
{
    initConfigToolButtonLabelParameters(isDark, nullptr, nullptr);
    p->iconHoverClickHighlight = m_ToolButtonParameters.iconHoverClickHighlight;
    p->textHoverClickHighlight = m_ToolButtonParameters.textHoverClickHighlight;
    p->textDefaultColor        = m_ToolButtonParameters.textDefaultColor       ;
    p->textHoverColor          = m_ToolButtonParameters.textHoverColor         ;
    p->textDisableColor        = m_ToolButtonParameters.textDisableColor       ;
}

void UKUIConfigStyleParameters::initConfigLineEditParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int radius = m_dtconfig->kradiusNormal();

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::LineEdit];
    m_LineEditParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::LineEdit]);

    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }


    QBrush  defaultBrush, hoverBrush, focusBrush, disableBrush,
            defaultPenBrush, hoverPenBrush, focusPenBrush, disablePenBrush;

    if (needTranslucent) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());

        focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInputAlpha());
    } else {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        hoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());

        focusBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInput());
    }

    defaultPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover());
    disablePenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable());

    focusPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());

    QPen defaultPen     = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen hoverPen       = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen focusPen       = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen disablePen     = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",      defaultBrush);
        w->setProperty("focusBrush",        focusBrush);
        w->setProperty("hoverBrush",        hoverBrush);
        w->setProperty("disableBrush",      disableBrush);
        w->setProperty("defaultPen",        defaultPen);
        w->setProperty("hoverPen",          hoverPen);
        w->setProperty("disablePen",        disablePen);
        w->setProperty("focusPen",          focusPen);
    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setFocusBrush").isValid() && widget->property("setFocusBrush").canConvert<QBrush>()) {
            focusBrush = widget->property("setFocusBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }
    }

    m_LineEditParameters.radius               = radius;
    m_LineEditParameters.lineEditDefaultBrush = defaultBrush;
    m_LineEditParameters.lineEditHoverBrush   = hoverBrush;
    m_LineEditParameters.lineEditFocusBrush   = focusBrush;
    m_LineEditParameters.lineEditDisableBrush = disableBrush;
    m_LineEditParameters.lineEditDefaultPen   = defaultPen;
    m_LineEditParameters.lineEditHoverPen     = hoverPen;
    m_LineEditParameters.lineEditFocusPen     = focusPen;
    m_LineEditParameters.lineEditDisablePen   = disablePen;
}

void UKUIConfigStyleParameters::getDefaultConfigLineEditParameters(ConfigLineEditParameters *p, bool isDark)
{
    initConfigLineEditParameters(isDark, nullptr, nullptr);
    p->radius               = m_LineEditParameters.radius              ;
    p->lineEditDefaultBrush = m_LineEditParameters.lineEditDefaultBrush;
    p->lineEditHoverBrush   = m_LineEditParameters.lineEditHoverBrush  ;
    p->lineEditFocusBrush   = m_LineEditParameters.lineEditFocusBrush  ;
    p->lineEditDisableBrush = m_LineEditParameters.lineEditDisableBrush;
    p->lineEditDefaultPen   = m_LineEditParameters.lineEditDefaultPen  ;
    p->lineEditHoverPen     = m_LineEditParameters.lineEditHoverPen    ;
    p->lineEditFocusPen     = m_LineEditParameters.lineEditFocusPen    ;
    p->lineEditDisablePen   = m_LineEditParameters.lineEditDisablePen  ;
}

void UKUIConfigStyleParameters::initConfigSpinBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool isHorizonLayout)
{
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::SpinBox];
    m_SpinBoxParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::SpinBox]);

    int radius = m_dtconfig->kradiusNormal();

    QBrush  defaultBrush,hoverBrush,clickBrush,disableBrush,focusBrush,
            defaultPenBrush,hoverPenBrush,clickPenBrush,disablePenBrush,focusPenBrush;

    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }

    if (needTranslucent) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        hoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
        clickBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());

        focusBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());//
//        focusBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInputAlpha()); 等待 ukui-globaltheme更新为kcomponentinputAlpha

    } else {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        hoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
        clickBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());

        focusBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());//
//        focusBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentInput());等待 ukui-globaltheme更新为kcomponentinputAlpha
    }

    defaultPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover());
    disablePenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable());
    clickPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick());

    focusPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());


    QPen defaultPen     = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen hoverPen       = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen focusPen       = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen disablePen     = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen clickPen       = QPen(clickPenBrush, (clickPenBrush.style() == Qt::NoBrush || clickPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    //箭头元素相关token

    //    QBrush upFocusHoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()       );
    //    QBrush upClickBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()       );
    //    QBrush downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()       );
    //    QBrush downClickBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick()       );


    QBrush  upDefaultBrush, upDisableBrush, upHoverBrush, upClickBrush, upFocusHoverBrush,
            downHoverBrush, downDisableBrush, downFocusHoverBrush, downClickBrush, downDefaultBrush;

    //箭头区域背景色
    if (needTranslucent) {
        upDefaultBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive());
        upHoverBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        upFocusHoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        upClickBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
        upDisableBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable());

        downDefaultBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive());
        downHoverBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        downClickBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
        downDisableBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable());
    } else {
        upDefaultBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive());
        upHoverBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        upFocusHoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        upClickBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
        upDisableBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable());

        downDefaultBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->buttonActive());
        downHoverBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        downFocusHoverBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        downClickBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
        downDisableBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable());
    }


    //箭头区域边框
    QPen upDefaultPen      = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal())    ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen upHoverPen        = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover())      ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen upFocusHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick())      ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen upClickPen        = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick())      ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen upDisablePen      = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable())    ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen downDefaultPen    = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal())  ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen downHoverPen      = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover())    ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandHover()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen downFocusHoverPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick())    ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen downClickPen      = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick())    ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandClick()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen downDisablePen    = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable())  ,
                                  parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandDisable()).color().alpha()<= 0 ?
                                      0 : 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    if (isHorizonLayout)
        hoverPen.setWidth(2);

    QRect upLinearRect(!option ? QPoint(0, 0) : QPoint(option->rect.left(), option->rect.top()),
                       !option ? QPoint(0, 0) : QPoint(option->rect.left(), option->rect.center().y()));

    QRect downLinearRect(!option ? QPoint(0, 0) : QPoint(option->rect.left(), option->rect.center().y()),
                         !option ? QPoint(0, 0) : QPoint(option->rect.left(), option->rect.bottom()));

    //up hover
    if (m_dtconfig->kComponentHover().style() == Qt::LinearGradientPattern) {
        upHoverBrush = parseBrush(option ? option->rect : upLinearRect, m_dtconfig->kComponentHover());
        downHoverBrush = parseBrush(option ? option->rect : downLinearRect, m_dtconfig->kComponentHover());
    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",        defaultBrush);
        w->setProperty("focusBrush",          focusBrush);
        w->setProperty("hoverBrush",          hoverBrush);
        w->setProperty("disableBrush",        disableBrush);
        w->setProperty("defaultPen",          defaultPen);
        w->setProperty("hoverPen",            hoverPen);
        w->setProperty("disablePen",          disablePen);
        w->setProperty("focusPen",            focusPen);

        w->setProperty("upDefaultBrush",      upDefaultBrush);
        w->setProperty("upHoverBrush",        upHoverBrush);
        w->setProperty("upFocusHoverBrush",   upFocusHoverBrush);
        w->setProperty("upClickBrush",        upClickBrush);
        w->setProperty("upDisableBrush",      upDisableBrush);

        w->setProperty("downDefaultBrush",    downDefaultBrush);
        w->setProperty("downHoverBrush",      downHoverBrush);
        w->setProperty("downFocusHoverBrush", downFocusHoverBrush);
        w->setProperty("downClickBrush",      downClickBrush);
        w->setProperty("downDisableBrush",      downDisableBrush);

        w->setProperty("upDefaultPen",        upDefaultPen);
        w->setProperty("upHoverPen",          upHoverPen);
        w->setProperty("upFocusHoverPen",     upFocusHoverPen);
        w->setProperty("upClickPen",          upClickPen);
        w->setProperty("upDisablePen",        upDisablePen);

        w->setProperty("downDefaultPen",      downDefaultPen);
        w->setProperty("downHoverPen",        downHoverPen);
        w->setProperty("downFocusHoverPen",   downFocusHoverPen);
        w->setProperty("downClickPen",        downClickPen);
        w->setProperty("downDisablePen",      downDisablePen);
    }
    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }

        //brush
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setFocusBrush").isValid() && widget->property("setFocusBrush").canConvert<QBrush>()) {
            focusBrush = widget->property("setFocusBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }

        //pen
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }

        //up button brush
        if (widget->property("setUpDefaultBrush").isValid() && widget->property("setUpDefaultBrush").canConvert<QBrush>()) {
            upDefaultBrush = widget->property("setUpDefaultBrush").value<QBrush>();
        }
        if (widget->property("setUpHoverBrush").isValid() && widget->property("setUpHoverBrush").canConvert<QBrush>()) {
            upHoverBrush = widget->property("setUpHoverBrush").value<QBrush>();
        }
        if (widget->property("setUpFocusHoverBrush").isValid() && widget->property("setUpFocusHoverBrush").canConvert<QBrush>()) {
            upFocusHoverBrush = widget->property("setUpFocusHoverBrush").value<QBrush>();
        }
        if (widget->property("setUpClickBrush").isValid() && widget->property("setUpClickBrush").canConvert<QBrush>()) {
            upClickBrush = widget->property("setUpClickBrush").value<QBrush>();
        }
        if (widget->property("setUpDisableBrush").isValid() && widget->property("setUpDisableBrush").canConvert<QBrush>()) {
            upDisableBrush = widget->property("setUpDisableBrush").value<QBrush>();
        }

        //down button brush
        if (widget->property("setDownDefaultBrush").isValid() && widget->property("setDownDefaultBrush").canConvert<QBrush>()) {
            downDefaultBrush = widget->property("setDownDefaultBrush").value<QBrush>();
        }
        if (widget->property("setDownHoverBrush").isValid() && widget->property("setDownHoverBrush").canConvert<QBrush>()) {
            downHoverBrush = widget->property("setDownHoverBrush").value<QBrush>();
        }
        if (widget->property("setDownFocusHoverBrush").isValid() && widget->property("setDownFocusHoverBrush").canConvert<QBrush>()) {
            downFocusHoverBrush = widget->property("setDownFocusHoverBrush").value<QBrush>();
        }
        if (widget->property("setDownClickBrush").isValid() && widget->property("setDownClickBrush").canConvert<QBrush>()) {
            downClickBrush = widget->property("setDownClickBrush").value<QBrush>();
        }
        if (widget->property("setDownDisableBrush").isValid() && widget->property("setDownDisableBrush").canConvert<QBrush>()) {
            downDisableBrush = widget->property("setDownDisableBrush").value<QBrush>();
        }

        //up button pen
        if (widget->property("setUpDefaultPen").isValid() && widget->property("setUpDefaultPen").canConvert<QPen>()) {
            upDefaultPen = widget->property("setUpDefaultPen").value<QPen>();
        }
        if (widget->property("setUpHoverPen").isValid() && widget->property("setUpHoverPen").canConvert<QPen>()) {
            upHoverPen = widget->property("setUpHoverPen").value<QPen>();
        }
        if (widget->property("setUpFocusHoverPen").isValid() && widget->property("setUpFocusHoverPen").canConvert<QPen>()) {
            upFocusHoverPen = widget->property("setUpFocusHoverPen").value<QPen>();
        }
        if (widget->property("setUpClickPen").isValid() && widget->property("setUpClickPen").canConvert<QPen>()) {
            upClickPen = widget->property("setUpClickPen").value<QPen>();
        }
        if (widget->property("setUpDisablePen").isValid() && widget->property("setUpDisablePen").canConvert<QPen>()) {
            upDisablePen = widget->property("setUpDisablePen").value<QPen>();
        }

        //down button pen
        if (widget->property("setDownDefaultPen").isValid() && widget->property("setDownDefaultPen").canConvert<QPen>()) {
            downDefaultPen = widget->property("setDownDefaultPen").value<QPen>();
        }
        if (widget->property("setDownHoverPen").isValid() && widget->property("setDownHoverPen").canConvert<QPen>()) {
            downHoverPen = widget->property("setDownHoverPen").value<QPen>();
        }
        if (widget->property("setDownFocusHoverPen").isValid() && widget->property("setDownFocusHoverPen").canConvert<QPen>()) {
            downFocusHoverPen = widget->property("setDownFocusHoverPen").value<QPen>();
        }
        if (widget->property("setDownClickPen").isValid() && widget->property("setDownClickPen").canConvert<QPen>()) {
            downClickPen = widget->property("setDownClickPen").value<QPen>();
        }
        if (widget->property("setDownDisablePen").isValid() && widget->property("setDownDisablePen").canConvert<QPen>()) {
            downDisablePen = widget->property("setDownDisablePen").value<QPen>();
        }
    }

    m_SpinBoxParameters.radius = radius;
    m_SpinBoxParameters.spinBoxDefaultBrush = defaultBrush;
    m_SpinBoxParameters.spinBoxHoverBrush   = hoverBrush;
    m_SpinBoxParameters.spinBoxFocusBrush   = focusBrush;
    m_SpinBoxParameters.spinBoxDisableBrush = disableBrush;
    m_SpinBoxParameters.spinBoxClickBrush   = clickBrush;

    m_SpinBoxParameters.spinBoxDefaultPen = defaultPen;
    m_SpinBoxParameters.spinBoxHoverPen   = hoverPen;
    m_SpinBoxParameters.spinBoxFocusPen   = focusPen;
    m_SpinBoxParameters.spinBoxClickPen   = clickPen;
    m_SpinBoxParameters.spinBoxDisablePen = disablePen;

    m_SpinBoxParameters.spinBoxUpDefaultBrush      = upDefaultBrush;
    m_SpinBoxParameters.spinBoxUpHoverBrush        = upHoverBrush;
    m_SpinBoxParameters.spinBoxUpFocusHoverBrush   = upFocusHoverBrush;
    m_SpinBoxParameters.spinBoxUpClickBrush        = upClickBrush;
    m_SpinBoxParameters.spinBoxUpDisableBrush      = upDisableBrush;

    m_SpinBoxParameters.spinBoxDownDefaultBrush    = downDefaultBrush;
    m_SpinBoxParameters.spinBoxDownHoverBrush      = downHoverBrush;
    m_SpinBoxParameters.spinBoxDownFocusHoverBrush = downFocusHoverBrush;
    m_SpinBoxParameters.spinBoxDownClickBrush      = downClickBrush;
    m_SpinBoxParameters.spinBoxDownDisableBrush    = downDisableBrush;

    m_SpinBoxParameters.spinBoxUpDefaultPen    = upDefaultPen;
    m_SpinBoxParameters.spinBoxUpHoverPen      = upHoverPen;
    m_SpinBoxParameters.spinBoxUpFocusHoverPen = upFocusHoverPen;
    m_SpinBoxParameters.spinBoxUpClickPen      = upClickPen;
    m_SpinBoxParameters.spinBoxUpDisablePen    = upDisablePen;

    m_SpinBoxParameters.spinBoxDownDefaultPen    = downDefaultPen;
    m_SpinBoxParameters.spinBoxDownHoverPen      = downHoverPen;
    m_SpinBoxParameters.spinBoxDownFocusHoverPen = downFocusHoverPen;
    m_SpinBoxParameters.spinBoxDownClickPen      = downClickPen;
    m_SpinBoxParameters.spinBoxDownDisablePen    = downDisablePen;

    m_SpinBoxParameters.spinBoxUpIconHightPixMap = true;
    m_SpinBoxParameters.spinBoxDownIconHightPixMap = true;
}

void UKUIConfigStyleParameters::getDefaultConfigSpinBoxParameters(ConfigSpinBoxParameters *p, bool isDark)
{
    initConfigSpinBoxParameters(isDark, nullptr, nullptr);
    p->radius                     = m_SpinBoxParameters.radius                     ;
    p->spinBoxDefaultBrush        = m_SpinBoxParameters.spinBoxDefaultBrush        ;
    p->spinBoxHoverBrush          = m_SpinBoxParameters.spinBoxHoverBrush          ;
    p->spinBoxFocusBrush          = m_SpinBoxParameters.spinBoxFocusBrush          ;
    p->spinBoxDisableBrush        = m_SpinBoxParameters.spinBoxDisableBrush        ;
    p->spinBoxClickBrush          = m_SpinBoxParameters.spinBoxClickBrush          ;

    p->spinBoxDefaultPen          = m_SpinBoxParameters.spinBoxDefaultPen          ;
    p->spinBoxHoverPen            = m_SpinBoxParameters.spinBoxHoverPen            ;
    p->spinBoxFocusPen            = m_SpinBoxParameters.spinBoxFocusPen            ;
    p->spinBoxDisablePen          = m_SpinBoxParameters.spinBoxDisablePen          ;
    p->spinBoxClickPen            = m_SpinBoxParameters.spinBoxClickPen            ;

    p->spinBoxUpDefaultBrush      = m_SpinBoxParameters.spinBoxUpDefaultBrush      ;
    p->spinBoxUpHoverBrush        = m_SpinBoxParameters.spinBoxUpHoverBrush        ;
    p->spinBoxUpFocusHoverBrush   = m_SpinBoxParameters.spinBoxUpFocusHoverBrush   ;
    p->spinBoxUpClickBrush        = m_SpinBoxParameters.spinBoxUpClickBrush        ;
    p->spinBoxDownHoverBrush      = m_SpinBoxParameters.spinBoxDownHoverBrush      ;
    p->spinBoxDownFocusHoverBrush = m_SpinBoxParameters.spinBoxDownFocusHoverBrush ;
    p->spinBoxDownClickBrush      = m_SpinBoxParameters.spinBoxDownClickBrush      ;
    p->spinBoxDownDefaultBrush    = m_SpinBoxParameters.spinBoxDownDefaultBrush    ;
    p->spinBoxUpDisableBrush     = m_SpinBoxParameters.spinBoxUpDisableBrush;

    p->spinBoxUpDefaultPen        = m_SpinBoxParameters.spinBoxUpDefaultPen        ;
    p->spinBoxUpHoverPen          = m_SpinBoxParameters.spinBoxUpHoverPen          ;
    p->spinBoxUpFocusHoverPen     = m_SpinBoxParameters.spinBoxUpFocusHoverPen     ;
    p->spinBoxUpClickPen          = m_SpinBoxParameters.spinBoxUpClickPen          ;
    p->spinBoxUpDisablePen        = m_SpinBoxParameters.spinBoxUpDisablePen        ;

    p->spinBoxDownDefaultPen      = m_SpinBoxParameters.spinBoxDownDefaultPen      ;
    p->spinBoxDownHoverPen        = m_SpinBoxParameters.spinBoxDownHoverPen        ;
    p->spinBoxDownFocusHoverPen   = m_SpinBoxParameters.spinBoxDownFocusHoverPen   ;
    p->spinBoxDownClickPen        = m_SpinBoxParameters.spinBoxDownClickPen        ;
    p->spinBoxDownDisablePen      = m_SpinBoxParameters.spinBoxDownDisablePen      ;

    p->spinBoxUpIconHightPixMap   = m_SpinBoxParameters.spinBoxUpIconHightPixMap   ;
    p->spinBoxDownIconHightPixMap = m_SpinBoxParameters.spinBoxDownIconHightPixMap ;

}

void UKUIConfigStyleParameters::initConfigComboBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

    int radius = m_dtconfig->kradiusNormal();


    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ComboBox];
    m_ComboBoxParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ComboBox]);

    QBrush  defaultBrush,hoverBrush,onBrush,editBrush,disableBrush,
            defaultPenBrush,hoverPenBrush,onPenBrush,editPenBrush,disablePenBrush,focusPenBrush;

    if (needTranslucent) {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        hoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        onBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
        editBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());
    } else {
        defaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        hoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        onBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
        disableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
        editBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());
    }


    defaultPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentHover());
    onPenBrush       = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick());
    editPenBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive());
    disablePenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentDisable());
    focusPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus());


    QPen defaultPen     = QPen(defaultPenBrush, (defaultPenBrush.style() == Qt::NoBrush || defaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen hoverPen       = QPen(hoverPenBrush, (hoverPenBrush.style() == Qt::NoBrush || hoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen onPen          = QPen(onPenBrush, (onPenBrush.style() == Qt::NoBrush || onPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen editPen        = QPen(editPenBrush, (editPenBrush.style() == Qt::NoBrush || editPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen disablePen     = QPen(disablePenBrush, (disablePenBrush.style() == Qt::NoBrush || disablePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen focusPen       = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",   defaultBrush);
        w->setProperty("onBrush",        onBrush);
        w->setProperty("hoverBrush",     hoverBrush);
        w->setProperty("disableBrush",   disableBrush);
        w->setProperty("editBrush",      editBrush);
        w->setProperty("defaultPen",     defaultPen);
        w->setProperty("hoverPen",       hoverPen);
        w->setProperty("onPen",          onPen);
        w->setProperty("disablePen",     disablePen);
        w->setProperty("editPen",        editPen);
        w->setProperty("focusPen",       focusPen);
    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setOnBrush").isValid() && widget->property("setOnBrush").canConvert<QBrush>()) {
            onBrush = widget->property("setOnBrush").value<QBrush>();
        }
        if (widget->property("setBoxEditBrush").isValid() && widget->property("setBoxEditBrush").canConvert<QBrush>()) {
            editBrush = widget->property("setBoxEditBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setOnPen").isValid() && widget->property("setOnPen").canConvert<QPen>()) {
            onPen = widget->property("setOnPen").value<QPen>();
        }
        if (widget->property("setEditPen").isValid() && widget->property("setEditPen").canConvert<QPen>()) {
            editPen = widget->property("setEditPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_ComboBoxParameters.radius               = radius;

    m_ComboBoxParameters.comboBoxDefaultBrush = defaultBrush;
    m_ComboBoxParameters.comboBoxHoverBrush   = hoverBrush;
    m_ComboBoxParameters.comboBoxOnBrush      = onBrush;
    m_ComboBoxParameters.comboBoxEditBrush    = editBrush;
    m_ComboBoxParameters.comboBoxDisableBrush = disableBrush;

    m_ComboBoxParameters.comboBoxDefaultPen   = defaultPen;
    m_ComboBoxParameters.comboBoxHoverPen     = hoverPen;
    m_ComboBoxParameters.comboBoxOnPen        = onPen;
    m_ComboBoxParameters.comboBoxEditPen      = editPen;
    m_ComboBoxParameters.comboBoxDisablePen   = disablePen;
    m_ComboBoxParameters.comboBoxFocusPen     = focusPen;
}

void UKUIConfigStyleParameters::getDefaultConfigComboBoxParameters(ConfigComboBoxParameters *p, bool isDark)
{
    initConfigComboBoxParameters(isDark, nullptr, nullptr);
    p->radius               = m_ComboBoxParameters.radius              ;
    p->comboBoxDefaultBrush = m_ComboBoxParameters.comboBoxDefaultBrush;
    p->comboBoxHoverBrush   = m_ComboBoxParameters.comboBoxHoverBrush  ;
    p->comboBoxOnBrush      = m_ComboBoxParameters.comboBoxOnBrush     ;
    p->comboBoxEditBrush    = m_ComboBoxParameters.comboBoxEditBrush   ;
    p->comboBoxDisableBrush = m_ComboBoxParameters.comboBoxDisableBrush;
    p->comboBoxDefaultPen   = m_ComboBoxParameters.comboBoxDefaultPen  ;
    p->comboBoxHoverPen     = m_ComboBoxParameters.comboBoxHoverPen    ;
    p->comboBoxOnPen        = m_ComboBoxParameters.comboBoxOnPen       ;
    p->comboBoxEditPen      = m_ComboBoxParameters.comboBoxEditPen     ;
    p->comboBoxDisablePen   = m_ComboBoxParameters.comboBoxDisablePen  ;
    p->comboBoxFocusPen     = m_ComboBoxParameters.comboBoxFocusPen    ;
}

void UKUIConfigStyleParameters::initConfigListParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool highlight)
{
    bool select = false;
    if(option){
        select = option->state & QStyle::State_Selected;
    }
    int radius = m_dtconfig->kradiusNormal();

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::List];
    m_ListParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::List]);


    bool highlightMode = highlight;
    if (widget && widget->property("highlightMode").isValid()) {
        highlightMode = widget->property("highlightMode").toBool();
    }
    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }


    QBrush defaultBrush,hoverBrush,selectBrush,disableBrush;
    QBrush alternatingRowsNormalBrush, alternatingRowsHoverBrush, alternatingRowsDisableBrush;

    if (needTranslucent) {
        defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ?
                                           m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal())) : QBrush(Qt::transparent);
        hoverBrush   = parseBrush(option ? option->rect : QRect(), select ?
                       (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kContainAlphaHover());

        disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ?
                                           m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedAlphaDisable())) : QBrush(Qt::transparent);


        selectBrush  = parseBrush(option ? option->rect : QRect(), select ?
                       (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaClick()) : m_dtconfig->kContainAlphaClick());


        alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), select ?
                                                    (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal()) : m_dtconfig->kContainSecondaryAlphaNormal());

        alternatingRowsHoverBrush = parseBrush(option ? option->rect : QRect(), select ?
                                                  (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kContainAlphaHover());

        alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), select ?
                                                     (highlightMode ? m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedAlphaDisable()) : m_dtconfig->kContainSecondaryAlphaNormal());


    } else {
        defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ?
                                           m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal())) : QBrush(Qt::transparent);
        hoverBrush   = parseBrush(option ? option->rect : QRect(), select ?
                       (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kContainHover());

        disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ?
                                           m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedDisable())) : QBrush(Qt::transparent);

        selectBrush  = parseBrush(option ? option->rect : QRect(), select ?
                       (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedClick()) : m_dtconfig->kContainClick());


        alternatingRowsNormalBrush = parseBrush(option ? option->rect : QRect(), select ?
                                                    (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal()) : m_dtconfig->kContainSecondaryNormal());

        alternatingRowsHoverBrush = parseBrush(option ? option->rect : QRect(), select ?
                                                  (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kContainHover());

        alternatingRowsDisableBrush = parseBrush(option ? option->rect : QRect(), select ?
                                                     (highlightMode ? m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedDisable()) : m_dtconfig->kContainSecondaryNormal());
    }


    QPen textHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), select ?
                          (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen textSelectPen  = QPen(parseBrush(option ? option->rect : QRect(), select ?
                          (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ?
                          (highlightMode ? m_dtconfig->kFontWhiteDisable() : m_dtconfig->kFontPrimaryDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


//    QBrush hoverPenBrush = select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kLineComponentHover();
//    QPen hoverPen       = QPen(parseBrush(option ? option->rect : QRect(), hoverPenBrush),
//                               parseBrush(option ? option->rect : QRect(), hoverPenBrush).color().alpha() > 0 ?
//                                   1 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QBrush selectPenBrush = select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kLineComponentClick();
//    QPen selectPen      = QPen(parseBrush(option ? option->rect : QRect(), selectPenBrush),
//                               parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() > 0 ?
//                                   1 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen focusPen       = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()),
//                               parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentClick()).color().alpha() > 0 ?
//                                   2 : 0, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen hoverPen       = QPen(Qt::NoPen);
    QPen selectPen      = QPen(Qt::NoPen);
    QPen focusPen       = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",   defaultBrush);
        w->setProperty("hoverBrush",     hoverBrush);
        w->setProperty("disableBrush",   disableBrush);
        w->setProperty("selectBrush",    selectBrush);
        w->setProperty("textHoverPen",   textHoverPen);
        w->setProperty("textSelectPen",  textSelectPen);
        w->setProperty("textDisablePen", textDisablePen);
        w->setProperty("hoverPen",       hoverPen);
        w->setProperty("selectPen",      selectPen);
        w->setProperty("focusPen",       focusPen);
    }
    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setSelectBrush").isValid() && widget->property("setSelectBrush").canConvert<QBrush>()) {
            selectBrush = widget->property("setSelectBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert<QPen>()) {
            textHoverPen = widget->property("setTextHoverPen").value<QPen>();
        }
        if (widget->property("setTextSelectPen").isValid() && widget->property("setTextSelectPen").canConvert<QPen>()) {
            textSelectPen = widget->property("setTextSelectPen").value<QPen>();
        }
        if (widget->property("setTextDisablePen").isValid() && widget->property("setTextDisablePen").canConvert<QPen>()) {
            textDisablePen = widget->property("setTextDisablePen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setSelectPen").isValid() && widget->property("setSelectPen").canConvert<QPen>()) {
            selectPen = widget->property("setSelectPen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_ListParameters.radius = radius;
    m_ListParameters.listDefaultBrush = defaultBrush;
    m_ListParameters.listHoverBrush   = hoverBrush;
    m_ListParameters.listSelectBrush  = selectBrush;
    m_ListParameters.listDisableBrush = disableBrush;
    m_ListParameters.listTextHoverPen = textHoverPen;
    m_ListParameters.listTextSelectPen  = textSelectPen;
    m_ListParameters.listTextDisablePen = textDisablePen;
    m_ListParameters.listHoverPen  = hoverPen;
    m_ListParameters.listSelectPen = selectPen;
    m_ListParameters.listFocusPen  = focusPen;

    m_ListParameters.listAlternatingRowsNormalBrush = alternatingRowsNormalBrush;
    m_ListParameters.listAlternatingRowsHoverBrush = alternatingRowsHoverBrush;
    m_ListParameters.listAlternatingRowsDisableBrush = alternatingRowsDisableBrush;
}

void UKUIConfigStyleParameters::getDefaultConfigListParameters(ConfigListParameters *p, bool isDark)
{
    initConfigListParameters(isDark, nullptr, nullptr);

    p->radius             = m_ListParameters.radius             ;
    p->listDefaultBrush   = m_ListParameters.listDefaultBrush   ;
    p->listHoverBrush     = m_ListParameters.listHoverBrush     ;
    p->listSelectBrush    = m_ListParameters.listSelectBrush    ;
    p->listDisableBrush   = m_ListParameters.listDisableBrush   ;
    p->listTextHoverPen   = m_ListParameters.listTextHoverPen   ;
    p->listTextSelectPen  = m_ListParameters.listTextSelectPen  ;
    p->listTextDisablePen = m_ListParameters.listTextDisablePen ;
    p->listHoverPen       = m_ListParameters.listHoverPen       ;
    p->listSelectPen      = m_ListParameters.listSelectPen      ;
    p->listFocusPen       = m_ListParameters.listFocusPen       ;

    p->listAlternatingRowsNormalBrush = m_ListParameters.listAlternatingRowsNormalBrush;
    p->listAlternatingRowsHoverBrush = m_ListParameters.listAlternatingRowsHoverBrush;
    p->listAlternatingRowsDisableBrush = m_ListParameters.listAlternatingRowsDisableBrush;
}

void UKUIConfigStyleParameters::getHighlightModeConfigListParameters(ConfigListParameters *p, bool isDark)
{
    initConfigListParameters(isDark, nullptr, nullptr, true);

    p->radius             = m_ListParameters.radius             ;
    p->listDefaultBrush   = m_ListParameters.listDefaultBrush   ;
    p->listHoverBrush     = m_ListParameters.listHoverBrush     ;
    p->listSelectBrush    = m_ListParameters.listSelectBrush    ;
    p->listDisableBrush   = m_ListParameters.listDisableBrush   ;
    p->listTextHoverPen   = m_ListParameters.listTextHoverPen   ;
    p->listTextSelectPen  = m_ListParameters.listTextSelectPen  ;
    p->listTextDisablePen = m_ListParameters.listTextDisablePen ;
    p->listHoverPen       = m_ListParameters.listHoverPen       ;
    p->listSelectPen      = m_ListParameters.listSelectPen      ;
    p->listFocusPen       = m_ListParameters.listFocusPen       ;

    p->listAlternatingRowsNormalBrush = m_ListParameters.listAlternatingRowsNormalBrush;
    p->listAlternatingRowsHoverBrush = m_ListParameters.listAlternatingRowsHoverBrush;
    p->listAlternatingRowsDisableBrush = m_ListParameters.listAlternatingRowsDisableBrush;
}
void UKUIConfigStyleParameters::initConfigTreeParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool highlight)
{
    bool select = false;
    if(option){
        select = option->state & QStyle::State_Selected;
    }

    int radius = m_dtconfig->kradiusNormal();

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Tree];
    m_TreeParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Tree]);


    bool highlightMode = highlight;
    if (widget && widget->property("highlightMode").isValid()) {
        highlightMode = widget->property("highlightMode").toBool();
    }


    QBrush defaultBrush,hoverBrush,selectBrush,disableBrush;

    if (needTranslucent) {
        defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal())) : QBrush(Qt::transparent);
        hoverBrush = parseBrush(option ? option->rect : QRect(),   select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kContainAlphaHover());
        selectBrush = parseBrush(option ? option->rect : QRect(),  select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal()) : QBrush(Qt::transparent));
        disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedAlphaDisable())) : QBrush(Qt::transparent);
    } else {
        defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal())) : QBrush(Qt::transparent);
        hoverBrush = parseBrush(option ? option->rect : QRect(),   select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kContainHover());
        selectBrush = parseBrush(option ? option->rect : QRect(),  select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal()) : QBrush(Qt::transparent));
        disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->kBrandDisable() : m_dtconfig->kComponentSelectedDisable())) : QBrush(Qt::transparent);
    }


//    QPen textHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen textSelectPen  = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontSecondaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen textHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen textSelectPen  = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kFontWhite() : m_dtconfig->kFontPrimary())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kFontWhiteDisable() : m_dtconfig->kFontPrimaryDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    QBrush hoverPenBrush,selectPenBrush,focusPenBrush;
    hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover());
    selectPenBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal());
    focusPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal());


//    QPen hoverPen       = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen selectPen      = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen focusPen       = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen hoverPen       = QPen(Qt::NoPen);
    QPen selectPen      = QPen(Qt::NoPen);
    QPen focusPen       = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    QBrush branchDefaultBrush = defaultBrush;
    QBrush branchHoverBrush = hoverBrush;
    QBrush branchSelectBrush = selectBrush;
    QBrush branchDisableBrush = disableBrush;

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",       defaultBrush);
        w->setProperty("hoverBrush",         hoverBrush);
        w->setProperty("disableBrush",       disableBrush);
        w->setProperty("selectBrush",        selectBrush);
        w->setProperty("branchDefaultBrush", branchDefaultBrush);
        w->setProperty("branchHoverBrush",   branchHoverBrush);
        w->setProperty("branchSelectBrush",  branchSelectBrush);
        w->setProperty("branchDisableBrush", branchDisableBrush);
        w->setProperty("textHoverPen",       textHoverPen);
        w->setProperty("textSelectPen",      textSelectPen);
        w->setProperty("textDisablePen",     textDisablePen);
        w->setProperty("hoverPen",           hoverPen);
        w->setProperty("selectPen",          selectPen);
        w->setProperty("focusPen",           focusPen);
    }
    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setSelectBrush").isValid() && widget->property("setSelectBrush").canConvert<QBrush>()) {
            selectBrush = widget->property("setSelectBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setBranchDefaultBrush").isValid() && widget->property("setBranchDefaultBrush").canConvert<QBrush>()) {
            branchDefaultBrush = widget->property("setBranchDefaultBrush").value<QBrush>();
        }
        if (widget->property("setBranchHoverBrush").isValid() && widget->property("setBranchHoverBrush").canConvert<QBrush>()) {
            branchHoverBrush = widget->property("setBranchHoverBrush").value<QBrush>();
        }
        if (widget->property("setBranchSelectBrush").isValid() && widget->property("setBranchSelectBrush").canConvert<QBrush>()) {
            branchSelectBrush = widget->property("setBranchSelectBrush").value<QBrush>();
        }
        if (widget->property("setBranchDisableBrush").isValid() && widget->property("setBranchDisableBrush").canConvert<QBrush>()) {
            branchDisableBrush = widget->property("setBranchDisableBrush").value<QBrush>();
        }
        if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert<QPen>()) {
            textHoverPen = widget->property("setTextHoverPen").value<QPen>();
        }
        if (widget->property("setTextSelectPen").isValid() && widget->property("setTextSelectPen").canConvert<QPen>()) {
            textSelectPen = widget->property("setTextSelectPen").value<QPen>();
        }
        if (widget->property("setTextDisablePen").isValid() && widget->property("setTextDisablePen").canConvert<QPen>()) {
            textDisablePen = widget->property("setTextDisablePen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setSelectPen").isValid() && widget->property("setSelectPen").canConvert<QPen>()) {
            selectPen = widget->property("setSelectPen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_TreeParameters.radius           = radius;
    m_TreeParameters.treeDefaultBrush = defaultBrush;
    m_TreeParameters.treeHoverBrush   = hoverBrush;
    m_TreeParameters.treeSelectBrush  = selectBrush;
    m_TreeParameters.treeDisableBrush = disableBrush;

    m_TreeParameters.treeBranchDefaultBrush = branchDefaultBrush;
    m_TreeParameters.treeBranchHoverBrush   =  branchHoverBrush;
    m_TreeParameters.treeBranchSelectBrush  =  branchSelectBrush;
    m_TreeParameters.treeBranchDisableBrush =  branchDisableBrush;

    m_TreeParameters.treeHoverPen       = hoverPen;
    m_TreeParameters.treeSelectPen      = selectPen;
    m_TreeParameters.treeFocusPen       = focusPen;
    m_TreeParameters.treeTextHoverPen   = textHoverPen;
    m_TreeParameters.treeTextSelectPen  = textSelectPen;
    m_TreeParameters.treeTextDisablePen = textDisablePen;
}

void UKUIConfigStyleParameters::getDefaultConfigTreeParameters(ConfigTreeParameters *p, bool isDark)
{
    initConfigTreeParameters(isDark, nullptr, nullptr);

    p->radius                 = m_TreeParameters.radius                ;
    p->treeDefaultBrush       = m_TreeParameters.treeDefaultBrush      ;
    p->treeHoverBrush         = m_TreeParameters.treeHoverBrush        ;
    p->treeSelectBrush        = m_TreeParameters.treeSelectBrush       ;
    p->treeDisableBrush       = m_TreeParameters.treeDisableBrush      ;
    p->treeBranchDefaultBrush = m_TreeParameters.treeBranchDefaultBrush;
    p->treeBranchHoverBrush   = m_TreeParameters.treeBranchHoverBrush  ;
    p->treeBranchSelectBrush  = m_TreeParameters.treeBranchSelectBrush ;
    p->treeBranchDisableBrush = m_TreeParameters.treeBranchDisableBrush;
    p->treeHoverPen           = m_TreeParameters.treeHoverPen          ;
    p->treeSelectPen          = m_TreeParameters.treeSelectPen         ;
    p->treeFocusPen           = m_TreeParameters.treeFocusPen          ;
    p->treeTextHoverPen       = m_TreeParameters.treeTextHoverPen      ;
    p->treeTextSelectPen      = m_TreeParameters.treeTextSelectPen     ;
    p->treeTextDisablePen     = m_TreeParameters.treeTextDisablePen    ;
}

void UKUIConfigStyleParameters::getHighlightModeConfigTreeParameters(ConfigTreeParameters *p, bool isDark)
{
    initConfigTreeParameters(isDark, nullptr, nullptr, true);

    p->radius                 = m_TreeParameters.radius                ;
    p->treeDefaultBrush       = m_TreeParameters.treeDefaultBrush      ;
    p->treeHoverBrush         = m_TreeParameters.treeHoverBrush        ;
    p->treeSelectBrush        = m_TreeParameters.treeSelectBrush       ;
    p->treeDisableBrush       = m_TreeParameters.treeDisableBrush      ;
    p->treeBranchDefaultBrush = m_TreeParameters.treeBranchDefaultBrush;
    p->treeBranchHoverBrush   = m_TreeParameters.treeBranchHoverBrush  ;
    p->treeBranchSelectBrush  = m_TreeParameters.treeBranchSelectBrush ;
    p->treeBranchDisableBrush = m_TreeParameters.treeBranchDisableBrush;
    p->treeHoverPen           = m_TreeParameters.treeHoverPen          ;
    p->treeSelectPen          = m_TreeParameters.treeSelectPen         ;
    p->treeFocusPen           = m_TreeParameters.treeFocusPen          ;
    p->treeTextHoverPen       = m_TreeParameters.treeTextHoverPen      ;
    p->treeTextSelectPen      = m_TreeParameters.treeTextSelectPen     ;
    p->treeTextDisablePen     = m_TreeParameters.treeTextDisablePen    ;
}

void UKUIConfigStyleParameters::initConfigTableParameters(bool isDark, const QStyleOption *option, const QWidget *widget, bool highlight)
{
    bool select = false;
    if(option){
        select = option->state & QStyle::State_Selected;
    }

    int radius = m_dtconfig->kradiusNormal();

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Table];
    m_TableParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Table]);

    bool highlightMode = highlight;
    if (widget && widget->property("highlightMode").isValid()) {
        highlightMode = widget->property("highlightMode").toBool();
    }

    highlightMode = false;//v11主题设计中没有定义Table中元素的高亮

    QBrush defaultBrush,hoverBrush,selectBrush,disableBrush;

    if (needTranslucent) {
        defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedAlphaNormal())) : QBrush(Qt::transparent);
        hoverBrush = parseBrush(option ? option->rect : QRect(),   select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedAlphaHover()) : m_dtconfig->kComponentAlphaHover());
        selectBrush = parseBrush(option ? option->rect : QRect(),  select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedAlphaNormal()) : QBrush(Qt::transparent));
        disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedAlphaDisable())) : QBrush(Qt::transparent);
    } else {
        defaultBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedNormal())) : QBrush(Qt::transparent);
        hoverBrush = parseBrush(option ? option->rect : QRect(),   select ? (highlightMode ? m_dtconfig->kBrandHover() : m_dtconfig->kComponentSelectedHover()) : m_dtconfig->kComponentHover());
        selectBrush = parseBrush(option ? option->rect : QRect(),  select ? (highlightMode ? m_dtconfig->kBrandNormal() : m_dtconfig->kComponentSelectedNormal()) : QBrush(Qt::transparent));
        disableBrush = select ? (parseBrush(option ? option->rect : QRect(), highlightMode ? m_dtconfig->highLightActive() : m_dtconfig->kComponentSelectedDisable())) : QBrush(Qt::transparent);
    }

//    QPen textHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen textSelectPen  = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->buttonTextActive())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->buttonTextDisable()) : m_dtconfig->kFontSecondaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen textHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->kFontPrimary())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen textSelectPen  = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextActive() : m_dtconfig->kFontPrimary())   : m_dtconfig->kFontPrimary()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen textDisablePen = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->highLightedTextDisable() : m_dtconfig->kFontPrimaryDisable()) : m_dtconfig->kFontPrimaryDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


//    QBrush hoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover());
//    QBrush selectPenBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal());
//    QBrush focusPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineBrandNormal());

//    QPen hoverPen       = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandHover() : m_dtconfig->kComponentHover()) : m_dtconfig->kContainHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen selectPen      = QPen(parseBrush(option ? option->rect : QRect(), select ? (highlightMode ? m_dtconfig->kLineBrandClick() : m_dtconfig->kComponentNormal()) : m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
//    QPen focusPen       = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen hoverPen       = QPen(Qt::NoPen);
    QPen selectPen      = QPen(Qt::NoPen);
    QPen focusPen       = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",       defaultBrush);
        w->setProperty("hoverBrush",         hoverBrush);
        w->setProperty("disableBrush",       disableBrush);
        w->setProperty("selectBrush",        selectBrush);
        w->setProperty("textHoverPen",       textHoverPen);
        w->setProperty("textSelectPen",      textSelectPen);
        w->setProperty("textDisablePen",      textSelectPen);
        w->setProperty("hoverPen",           hoverPen);
        w->setProperty("selectPen",          selectPen);
        w->setProperty("focusPen",           focusPen);
    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setSelectBrush").isValid() && widget->property("setSelectBrush").canConvert<QBrush>()) {
            selectBrush = widget->property("setSelectBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setSelectPen").isValid() && widget->property("setSelectPen").canConvert<QPen>()) {
            selectPen = widget->property("setSelectPen").value<QPen>();
        }
        if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert<QPen>()) {
            textHoverPen = widget->property("setTextHoverPen").value<QPen>();
        }
        if (widget->property("setTextSelectPen").isValid() && widget->property("setTextSelectPen").canConvert<QPen>()) {
            textSelectPen = widget->property("setTextSelectPen").value<QPen>();
        }
        if (widget->property("setTextDisablePen").isValid() && widget->property("setTextDisablePen").canConvert<QPen>()) {
            textSelectPen = widget->property("setTextDisablePen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_TableParameters.radius              = radius;
    m_TableParameters.tableDefaultBrush   = defaultBrush;
    m_TableParameters.tableHoverBrush     = hoverBrush;
    m_TableParameters.tableSelectBrush    = selectBrush;
    m_TableParameters.tableDisableBrush   = disableBrush;
    m_TableParameters.tableHoverPen       = hoverPen;
    m_TableParameters.tableSelectPen      = selectPen;
    m_TableParameters.tableFocusPen       = focusPen;
    m_TableParameters.tableTextHoverPen   = textHoverPen;
    m_TableParameters.tableTextSelectPen  = textSelectPen;
    m_TableParameters.tableTextDisablePen = textDisablePen;
}

void UKUIConfigStyleParameters::getDefaultConfigTableParameters(ConfigTableParameters *p, bool isDark)
{
    initConfigTableParameters(isDark, nullptr, nullptr);

    p->radius              = m_TableParameters.radius             ;
    p->tableDefaultBrush   = m_TableParameters.tableDefaultBrush  ;
    p->tableHoverBrush     = m_TableParameters.tableHoverBrush    ;
    p->tableSelectBrush    = m_TableParameters.tableSelectBrush   ;
    p->tableDisableBrush   = m_TableParameters.tableDisableBrush  ;
    p->tableHoverPen       = m_TableParameters.tableHoverPen      ;
    p->tableSelectPen      = m_TableParameters.tableSelectPen     ;
    p->tableFocusPen       = m_TableParameters.tableFocusPen      ;
    p->tableTextHoverPen   = m_TableParameters.tableTextHoverPen  ;
    p->tableTextSelectPen  = m_TableParameters.tableTextSelectPen ;
    p->tableTextDisablePen = m_TableParameters.tableTextDisablePen;
}

void UKUIConfigStyleParameters::getHighlightModeConfigTableParameters(ConfigTableParameters *p, bool isDark)
{
    initConfigTableParameters(isDark, nullptr, nullptr, true);

    p->radius              = m_TableParameters.radius             ;
    p->tableDefaultBrush   = m_TableParameters.tableDefaultBrush  ;
    p->tableHoverBrush     = m_TableParameters.tableHoverBrush    ;
    p->tableSelectBrush    = m_TableParameters.tableSelectBrush   ;
    p->tableDisableBrush   = m_TableParameters.tableDisableBrush  ;
    p->tableHoverPen       = m_TableParameters.tableHoverPen      ;
    p->tableSelectPen      = m_TableParameters.tableSelectPen     ;
    p->tableFocusPen       = m_TableParameters.tableFocusPen      ;
    p->tableTextHoverPen   = m_TableParameters.tableTextHoverPen  ;
    p->tableTextSelectPen  = m_TableParameters.tableTextSelectPen ;
    p->tableTextDisablePen = m_TableParameters.tableTextDisablePen;
}

void UKUIConfigStyleParameters::initConfigCheckBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::CheckBox];
    m_CheckBoxParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::CheckBox]);


    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }

    int radius = (widget && widget->property("minRadius").isValid()) ?
                widget->property("minRadius").toInt() : m_dtconfig->kradiusMin();

    QPen defaultPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen focusPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen hoverPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen clickPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen disablePen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen onDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen onHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen onClickPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen contentPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1,
                             Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    QBrush defaultBrush,hoverBrush,clickBrush,disableBrush,disableOnNoChangeBrush;//Checkbox off状态下Brush
    QBrush onDefaultBrush,onHoverBrush,onClickBrush;//checkbox on、nochange状态下Brush，
    QBrush pathBrush,pathDisableBrush,hookLineBrush,hookLineDisableBrush;

    if (needTranslucent) {
        defaultBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        hoverBrush       = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        clickBrush       = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
        disableBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
        disableOnNoChangeBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable());
    } else {
        defaultBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        hoverBrush       = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        clickBrush       = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
        disableBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
        disableOnNoChangeBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable());
    }

    onDefaultBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    onHoverBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
    onClickBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick());

    pathBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightInactive());
    pathDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kGrayAlpha10());
    hookLineBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    hookLineDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhiteDisable());



    QBrush textBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimary());
    QBrush textDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable());

    bool onHoverBrushIslinearGradient = false;

    if (m_dtconfig->kBrandHover().style() == Qt::LinearGradientPattern) {
        onHoverBrushIslinearGradient = true;
    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",       defaultBrush);
        w->setProperty("hoverBrush",         hoverBrush);
        w->setProperty("clickBrush",         clickBrush);
        w->setProperty("disableBrush",       disableBrush);
        w->setProperty("disableOnNoChangeBrush",disableOnNoChangeBrush);
        w->setProperty("onDefaultBrush",     onDefaultBrush);
        w->setProperty("onHoverBrush",       onHoverBrush);
        w->setProperty("onClickBrush",       onClickBrush);
        w->setProperty("pathDisableBrush",   pathDisableBrush);
        w->setProperty("pathBrush",          pathBrush);
        w->setProperty("contentPen",         contentPen);
        w->setProperty("defaultPen",         defaultPen);
        w->setProperty("focusPen",           focusPen);
        w->setProperty("disablePen",         disablePen);
        w->setProperty("hoverPen",           hoverPen);
        w->setProperty("clickPen",           clickPen);
        w->setProperty("onDefaultPen",       onDefaultPen);
        w->setProperty("onHoverPen",         onHoverPen);
        w->setProperty("onClickPen",         onClickPen);
        w->setProperty("onHoverBrushIslinearGradient",         onHoverBrushIslinearGradient);

        w->setProperty("textBrush",          textBrush);
        w->setProperty("textDisableBrush",   textDisableBrush);

    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setContentPen").isValid() && widget->property("setContentPen").canConvert<QPen>()) {
            contentPen = widget->property("setContentPen").value<QPen>();
        }
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setClickPen").isValid() && widget->property("setClickPen").canConvert<QPen>()) {
            clickPen = widget->property("setClickPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }
        if (widget->property("setOnDefaultPen").isValid() && widget->property("setOnDefaultPen").canConvert<QPen>()) {
            onDefaultPen = widget->property("setOnDefaultPen").value<QPen>();
        }
        if (widget->property("setOnHoverPen").isValid() && widget->property("setOnHoverPen").canConvert<QPen>()) {
            onHoverPen = widget->property("setOnHoverPen").value<QPen>();
        }
        if (widget->property("setOnClickPen").isValid() && widget->property("setOnClickPen").canConvert<QPen>()) {
            onClickPen = widget->property("setOnClickPen").value<QPen>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert<QBrush>()) {
            clickBrush = widget->property("setClickBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setOnDefaultBrush").isValid() && widget->property("setOnDefaultBrush").canConvert<QBrush>()) {
            onDefaultBrush = widget->property("setOnDefaultBrush").value<QBrush>();
        }
        if (widget->property("setOnHoverBrush").isValid() && widget->property("setOnHoverBrush").canConvert<QBrush>()) {
            onHoverBrush = widget->property("setOnHoverBrush").value<QBrush>();
        }
        if (widget->property("setOnClickBrush").isValid() && widget->property("setOnClickBrush").canConvert<QBrush>()) {
            onClickBrush = widget->property("setOnClickBrush").value<QBrush>();
        }
        if (widget->property("setPathBrush").isValid() && widget->property("setPathBrush").canConvert<QBrush>()) {
            pathBrush = widget->property("setPathBrush").value<QBrush>();
        }
        if (widget->property("setPathDisableBrush").isValid() && widget->property("setPathDisableBrush").canConvert<QBrush>()) {
            pathDisableBrush = widget->property("setPathDisableBrush").value<QBrush>();
        }
        if (widget->property("setOnHoverBrushIslinearGradient").isValid() && widget->property("setOnHoverBrushIslinearGradient").canConvert<bool>()) {
            onHoverBrushIslinearGradient = widget->property("setOnHoverBrushIslinearGradient").value<bool>();
        }
        if (widget->property("setDisableOnNoChangeBrush").isValid() && widget->property("setDisableOnNoChangeBrush").canConvert<QBrush>()) {
            disableOnNoChangeBrush = widget->property("setDisableOnNoChangeBrush").value<QBrush>();
        }
        if (widget->property("setTextBrush").isValid() && widget->property("setTextBrush").canConvert<QBrush>()) {
            textBrush = widget->property("setTextBrush").value<QBrush>();
        }
        if (widget->property("setTextDisableBrush").isValid() && widget->property("setTextDisableBrush").canConvert<QBrush>()) {
            textDisableBrush = widget->property("setTextDisableBrush").value<QBrush>();
        }
    }

    m_CheckBoxParameters.radius = radius;
    m_CheckBoxParameters.checkBoxDefaultPen = defaultPen;
    m_CheckBoxParameters.checkBoxFocusPen   = focusPen;
    m_CheckBoxParameters.checkBoxHoverPen = hoverPen;
    m_CheckBoxParameters.checkBoxClickPen = clickPen;
    m_CheckBoxParameters.checkBoxDisablePen = disablePen;
    m_CheckBoxParameters.checkBoxOnDefaultPen = onDefaultPen;
    m_CheckBoxParameters.checkBoxOnHoverPen = onHoverPen;
    m_CheckBoxParameters.checkBoxOnClickPen = onClickPen;
    m_CheckBoxParameters.checkBoxContentPen = contentPen;

    m_CheckBoxParameters.checkBoxDefaultBrush = defaultBrush;
    m_CheckBoxParameters.checkBoxHoverBrush = hoverBrush;
    m_CheckBoxParameters.checkBoxClickBrush = clickBrush;
    m_CheckBoxParameters.checkBoxDisableBrush = disableBrush;
    m_CheckBoxParameters.checkBoxDisableOnNoChangeBrush = disableOnNoChangeBrush;
    m_CheckBoxParameters.checkBoxOnDefaultBrush = onDefaultBrush;
    m_CheckBoxParameters.checkBoxOnHoverBrush = onHoverBrush;
    m_CheckBoxParameters.checkBoxOnClickBrush = onClickBrush;
    m_CheckBoxParameters.checkBoxPathBrush = pathBrush;
    m_CheckBoxParameters.checkBoxPathDisableBrush = pathDisableBrush;
    m_CheckBoxParameters.checkboxHookLineBrush = hookLineBrush;
    m_CheckBoxParameters.checkboxHookLineDisableBrush = hookLineDisableBrush;
    m_CheckBoxParameters.checkBoxTextBrush = textBrush;
    m_CheckBoxParameters.checkBoxTextDisableBrush = textDisableBrush;

    m_CheckBoxParameters.onHoverBrushIslinearGradient = onHoverBrushIslinearGradient;
}

void UKUIConfigStyleParameters::getDefaultConfigCheckBoxParameters(ConfigCheckBoxParameters *p, bool isDark)
{
    initConfigCheckBoxParameters(isDark, nullptr, nullptr);

    p->radius                       = m_CheckBoxParameters.radius                      ;
    p->checkBoxDefaultPen           = m_CheckBoxParameters.checkBoxDefaultPen          ;
    p->checkBoxHoverPen             = m_CheckBoxParameters.checkBoxHoverPen            ;
    p->checkBoxClickPen             = m_CheckBoxParameters.checkBoxClickPen            ;
    p->checkBoxDisablePen           = m_CheckBoxParameters.checkBoxDisablePen          ;
    p->checkBoxOnDefaultPen         = m_CheckBoxParameters.checkBoxOnDefaultPen        ;
    p->checkBoxOnHoverPen           = m_CheckBoxParameters.checkBoxOnHoverPen          ;
    p->checkBoxOnClickPen           = m_CheckBoxParameters.checkBoxOnClickPen          ;
    p->checkBoxContentPen           = m_CheckBoxParameters.checkBoxContentPen          ;
    p->checkBoxDefaultBrush         = m_CheckBoxParameters.checkBoxDefaultBrush        ;
    p->checkBoxHoverBrush           = m_CheckBoxParameters.checkBoxHoverBrush          ;
    p->checkBoxClickBrush           = m_CheckBoxParameters.checkBoxClickBrush          ;
    p->checkBoxDisableBrush         = m_CheckBoxParameters.checkBoxDisableBrush        ;
    p->checkBoxOnDefaultBrush       = m_CheckBoxParameters.checkBoxOnDefaultBrush      ;
    p->checkBoxOnHoverBrush         = m_CheckBoxParameters.checkBoxOnHoverBrush        ;
    p->checkBoxOnClickBrush         = m_CheckBoxParameters.checkBoxOnClickBrush        ;
    p->checkBoxPathBrush            = m_CheckBoxParameters.checkBoxPathBrush           ;
    p->checkBoxPathDisableBrush     = m_CheckBoxParameters.checkBoxPathDisableBrush    ;
    p->onHoverBrushIslinearGradient = m_CheckBoxParameters.onHoverBrushIslinearGradient;
    p->checkBoxDisableOnNoChangeBrush = m_CheckBoxParameters.checkBoxDisableOnNoChangeBrush;
    p->checkboxHookLineBrush = m_CheckBoxParameters.checkboxHookLineBrush;
    p->checkboxHookLineDisableBrush = m_CheckBoxParameters.checkboxHookLineDisableBrush;

    p->checkBoxFocusPen      = m_CheckBoxParameters.checkBoxFocusPen;
    p->checkBoxTextBrush            = m_CheckBoxParameters.checkBoxTextBrush           ;
    p->checkBoxTextDisableBrush     = m_CheckBoxParameters.checkBoxDisableBrush        ;

}

void UKUIConfigStyleParameters::initConfigRadioButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::RadioButton];
    m_RadioButtonParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::RadioButton]);

    m_RadioButtonParameters.radius = m_dtconfig->kradiusMenu();

    QBrush defaultBrush,hoverBrush,clickBrush,disableBrush;//RadioButton整体Brsuh(off)
    QBrush onDefaultBrush,onClickBrush,onHoverBrush,onDisableBrush;//On状态下外圆的Brush
    QBrush childrenOnDefaultBrush,childrenOnHoverBrush,childrenOnClickBrush,childrenOnDisableBrush;//内圆的 Brush

    if (needTranslucent) {
        defaultBrush           = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        hoverBrush             = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        clickBrush             = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
        disableBrush           = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaDisable());
    } else {
        defaultBrush           = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        hoverBrush             = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        clickBrush             = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
        disableBrush           = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());
    }

    onDefaultBrush         = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    onHoverBrush           = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandHover());
    onClickBrush           = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandClick());
    onDisableBrush         = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandDisable());

    childrenOnDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    childrenOnHoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    childrenOnClickBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    childrenOnDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());


    QPen defaultPen,hoverPen,clickPen,disablePen,focusPen;
    QPen onDefaultPen,onHoverPen,onClickPen,onDisablePen;

    // if (needTranslucent) {
    //     defaultPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    //     hoverPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    //     clickPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    //     disablePen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    // } else {
    //     defaultPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    //     hoverPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    //     clickPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    //     disablePen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    // }
    //off状态边框
    defaultPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    hoverPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    clickPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    disablePen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //on状态边框
    onDefaultPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxNormal()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    onHoverPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxHover()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    onClickPen   = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxClick()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    onDisablePen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineSelectboxDisable()), 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    focusPen     = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus()), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QBrush textBrush        = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimary());
    QBrush textDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimaryDisable());

    if(option)
    m_RadioButtonParameters.childrenRadius =
            (qstyleoption_cast<const QStyleOptionButton*>(option)->rect.adjusted(1, 1, -1, -1).width()) / 2 - 2;

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("defaultBrush",           defaultBrush);
        w->setProperty("hoverBrush",             hoverBrush);
        w->setProperty("clickBrush",             clickBrush);
        w->setProperty("disableBrush",           disableBrush);
        w->setProperty("onDefaultBrush",         onDefaultBrush);
        w->setProperty("onHoverBrush",           onHoverBrush);
        w->setProperty("onClickBrush",           onClickBrush);
        w->setProperty("onDisableBrush",         onDisableBrush);
        w->setProperty("childrenOnDefaultBrush", childrenOnDefaultBrush);
        w->setProperty("childrenOnHoverBrush",   childrenOnHoverBrush);
        w->setProperty("childrenOnClickBrush",   childrenOnClickBrush);
        w->setProperty("childrenOnDisableBrush", childrenOnDisableBrush);
        w->setProperty("defaultPen",             defaultPen);
        w->setProperty("disablePen",             disablePen);
        w->setProperty("hoverPen",               hoverPen);
        w->setProperty("clickPen",               clickPen);
        w->setProperty("onDefaultPen",           onDefaultPen);
        w->setProperty("onHoverPen",             onHoverPen);
        w->setProperty("onClickPen",             onClickPen);
        w->setProperty("onDisablePen",           onDisablePen);
        w->setProperty("focusPen",               focusPen);
        w->setProperty("textBrush",          textBrush);
        w->setProperty("textDisableBrush",   textDisableBrush);
    }

    //if set property
    if (widget) {
        if (widget->property("setDefaultPen").isValid() && widget->property("setDefaultPen").canConvert<QPen>()) {
            defaultPen = widget->property("setDefaultPen").value<QPen>();
        }
        if (widget->property("setHoverPen").isValid() && widget->property("setHoverPen").canConvert<QPen>()) {
            hoverPen = widget->property("setHoverPen").value<QPen>();
        }
        if (widget->property("setClickPen").isValid() && widget->property("setClickPen").canConvert<QPen>()) {
            clickPen = widget->property("setClickPen").value<QPen>();
        }
        if (widget->property("setDisablePen").isValid() && widget->property("setDisablePen").canConvert<QPen>()) {
            disablePen = widget->property("setDisablePen").value<QPen>();
        }
        if (widget->property("setOnDefaultPen").isValid() && widget->property("setOnDefaultPen").canConvert<QPen>()) {
            onDefaultPen = widget->property("setOnDefaultPen").value<QPen>();
        }
        if (widget->property("setOnHoverPen").isValid() && widget->property("setOnHoverPen").canConvert<QPen>()) {
            onHoverPen = widget->property("setOnHoverPen").value<QPen>();
        }
        if (widget->property("setOnClickPen").isValid() && widget->property("setOnClickPen").canConvert<QPen>()) {
            onClickPen = widget->property("setOnClickPen").value<QPen>();
        }
        if (widget->property("setOnDisablePen").isValid() && widget->property("setOnDisablePen").canConvert<QPen>()) {
            onDisablePen = widget->property("setOnDisablePen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QPen>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
        if (widget->property("setDefaultBrush").isValid() && widget->property("setDefaultBrush").canConvert<QBrush>()) {
            defaultBrush = widget->property("setDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHoverBrush").isValid() && widget->property("setHoverBrush").canConvert<QBrush>()) {
            hoverBrush = widget->property("setHoverBrush").value<QBrush>();
        }
        if (widget->property("setClickBrush").isValid() && widget->property("setClickBrush").canConvert<QBrush>()) {
            clickBrush = widget->property("setClickBrush").value<QBrush>();
        }
        if (widget->property("setDisableBrush").isValid() && widget->property("setDisableBrush").canConvert<QBrush>()) {
            disableBrush = widget->property("setDisableBrush").value<QBrush>();
        }
        if (widget->property("setOnDefaultBrush").isValid() && widget->property("setOnDefaultBrush").canConvert<QBrush>()) {
            onDefaultBrush = widget->property("setOnDefaultBrush").value<QBrush>();
        }
        if (widget->property("setOnHoverBrush").isValid() && widget->property("setOnHoverBrush").canConvert<QBrush>()) {
            onHoverBrush = widget->property("setOnHoverBrush").value<QBrush>();
        }
        if (widget->property("setOnClickBrush").isValid() && widget->property("setOnClickBrush").canConvert<QBrush>()) {
            onClickBrush = widget->property("setOnClickBrush").value<QBrush>();
        }
        if (widget->property("setOnDisableBrush").isValid() && widget->property("setOnDisableBrush").canConvert<QBrush>()) {
            onClickBrush = widget->property("setOnDisableBrush").value<QBrush>();
        }
        if (widget->property("setChildrenOnDefaultBrush").isValid() && widget->property("setChildrenOnDefaultBrush").canConvert<QBrush>()) {
            childrenOnDefaultBrush = widget->property("setChildrenOnDefaultBrush").value<QBrush>();
        }
        if (widget->property("setChildrenOnHoverBrush").isValid() && widget->property("setChildrenOnHoverBrush").canConvert<QBrush>()) {
            childrenOnHoverBrush = widget->property("setChildrenOnHoverBrush").value<QBrush>();
        }
        if (widget->property("setChildrenOnClickBrush").isValid() && widget->property("setChildrenOnClickBrush").canConvert<QBrush>()) {
            childrenOnClickBrush = widget->property("setChildrenOnClickBrush").value<QBrush>();
        }
        if (widget->property("setChildrenOnDisableBrush").isValid() && widget->property("setChildrenOnDisableBrush").canConvert<QBrush>()) {
            childrenOnDisableBrush = widget->property("setChildrenOnDisableBrush").value<QBrush>();
        }

        if (widget->property("setTextBrush").isValid() && widget->property("setTextBrush").canConvert<QBrush>()) {
            textBrush = widget->property("setTextBrush").value<QBrush>();
        }
        if (widget->property("setTextDisableBrush").isValid() && widget->property("setTextDisableBrush").canConvert<QBrush>()) {
            textDisableBrush = widget->property("setTextDisableBrush").value<QBrush>();
        }

    }

    m_RadioButtonParameters.radioButtonDefaultPen = defaultPen;
    m_RadioButtonParameters.radioButtonHoverPen = hoverPen;
    m_RadioButtonParameters.radioButtonClickPen = clickPen;

    m_RadioButtonParameters.radioButtonFocusPen = focusPen;

    m_RadioButtonParameters.radioButtonDisablePen = disablePen;

    m_RadioButtonParameters.radioButtonOnDefaultPen = onDefaultPen;
    m_RadioButtonParameters.radioButtonOnHoverPen = onHoverPen;
    m_RadioButtonParameters.radioButtonOnClickPen = onClickPen;

    m_RadioButtonParameters.radioButtonOnDisablePen = onDisablePen;


    m_RadioButtonParameters.radioButtonDefaultBrush = defaultBrush;
    m_RadioButtonParameters.radioButtonHoverBrush = hoverBrush;
    m_RadioButtonParameters.radioButtonClickBrush = clickBrush;

    m_RadioButtonParameters.radioButtonDisableBrush = disableBrush;
    m_RadioButtonParameters.radioButtonOnDefaultBrush = onDefaultBrush;
    m_RadioButtonParameters.radioButtonOnHoverBrush = onHoverBrush;
    m_RadioButtonParameters.radioButtonOnClickBrush = onClickBrush;

    m_RadioButtonParameters.radioButtonOnDisableBrush = onDisableBrush;

    m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush = childrenOnDefaultBrush;
    m_RadioButtonParameters.radioButtonChildrenOnHoverBrush = childrenOnHoverBrush;
    m_RadioButtonParameters.radioButtonChildrenOnClickBrush = childrenOnClickBrush;
    m_RadioButtonParameters.radioButtonChildrenOnDisableBrush = childrenOnDisableBrush;

    m_RadioButtonParameters.radioButtonTextBrush = textBrush;
    m_RadioButtonParameters.radioButtonTextDisableBrush = textDisableBrush;

}

void UKUIConfigStyleParameters::getDefaultConfigRadioButtonParameters(ConfigRadioButtonParameters *p, bool isDark)
{
    initConfigRadioButtonParameters(isDark, nullptr, nullptr);
    p->radioButtonDefaultPen             = m_RadioButtonParameters.radioButtonDefaultPen            ;
    p->radioButtonHoverPen               = m_RadioButtonParameters.radioButtonHoverPen              ;
    p->radioButtonClickPen               = m_RadioButtonParameters.radioButtonClickPen              ;
    p->radioButtonDisablePen             = m_RadioButtonParameters.radioButtonDisablePen            ;
    p->radioButtonOnDefaultPen           = m_RadioButtonParameters.radioButtonOnDefaultPen          ;
    p->radioButtonOnHoverPen             = m_RadioButtonParameters.radioButtonOnHoverPen            ;
    p->radioButtonOnClickPen             = m_RadioButtonParameters.radioButtonOnClickPen            ;
    p->radioButtonOnDisablePen           = m_RadioButtonParameters.radioButtonOnDisablePen          ;

    p->radioButtonFocusPen               = m_RadioButtonParameters.radioButtonFocusPen              ;
    p->radioButtonDefaultBrush           = m_RadioButtonParameters.radioButtonDefaultBrush          ;
    p->radioButtonHoverBrush             = m_RadioButtonParameters.radioButtonHoverBrush            ;
    p->radioButtonClickBrush             = m_RadioButtonParameters.radioButtonClickBrush            ;
    p->radioButtonDisableBrush           = m_RadioButtonParameters.radioButtonDisableBrush          ;
    p->radioButtonOnDefaultBrush         = m_RadioButtonParameters.radioButtonOnDefaultBrush        ;
    p->radioButtonOnHoverBrush           = m_RadioButtonParameters.radioButtonOnHoverBrush          ;
    p->radioButtonOnClickBrush           = m_RadioButtonParameters.radioButtonOnClickBrush          ;
    p->radioButtonOnDisableBrush         = m_RadioButtonParameters.radioButtonOnDisableBrush        ;
    p->radioButtonChildrenOnDefaultBrush = m_RadioButtonParameters.radioButtonChildrenOnDefaultBrush;
    p->radioButtonChildrenOnHoverBrush   = m_RadioButtonParameters.radioButtonChildrenOnHoverBrush  ;
    p->radioButtonChildrenOnClickBrush   = m_RadioButtonParameters.radioButtonChildrenOnClickBrush  ;
    p->radioButtonChildrenOnDisableBrush = m_RadioButtonParameters.radioButtonChildrenOnDisableBrush;
    p->radioButtonTextBrush              = m_RadioButtonParameters.radioButtonTextBrush           ;
    p->radioButtonTextDisableBrush       = m_RadioButtonParameters.radioButtonDisableBrush        ;
}

void UKUIConfigStyleParameters::initConfigSliderParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int grooveRadius = Slider_GrooveLength/2;

    float disableAlpha = 0.45f;

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Slider];
    m_SliderParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Slider]);

    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }

    //滑动控制圈的颜色
    QBrush handleDefaultBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    QBrush handleHoverBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    QBrush handleClickBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());
    QBrush handleDisableBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontWhite());// rgba(255, 255, 255, 1)

    auto handleDisableColor = handleDisableBrush.color();
    handleDisableColor.setAlphaF(isDark ? 0.45: 0.9);
    handleDisableBrush = QBrush(handleDisableColor);

    QBrush handleDisbaleBaseBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive());//rgba(255, 255, 255, 1);   dark:rgba(26, 26, 26, 1);


    //已划过的滑动条部分的颜色
    QBrush grooveValueDefaultBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    QBrush grooveValueHoverBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    QBrush grooveValueDisableBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());//rgba(54, 118, 245, 1); 实色

    auto grooveValueDisableColor = grooveValueDisableBrush.color();
    grooveValueDisableColor.setAlphaF(disableAlpha*grooveValueDisableColor.alphaF());
    grooveValueDisableBrush.setColor(grooveValueDisableColor);


    //未划过的滑动条部分的颜色
    QBrush grooveUnvalueDefaultBrush,grooveUnvalueHoverBrush,grooveUnvalueDisableBrush;
    if (needTranslucent) {
        grooveUnvalueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        grooveUnvalueHoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
        grooveUnvalueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());//rgba(0, 0, 0, 0.04)
    } else {
        grooveUnvalueDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        grooveUnvalueHoverBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
        grooveUnvalueDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());//rgba(240, 240, 240, 1);
    }
    QColor grooveUnvalueDisableColor = grooveUnvalueDisableBrush.color();
    grooveUnvalueDisableColor.setAlphaF(grooveUnvalueDisableColor.alphaF() * disableAlpha);
    grooveUnvalueDisableBrush.setColor(grooveUnvalueDisableColor);


    //滑动控制圈的外框
    QBrush handleDefaultPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    QBrush handleHoverPenBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    QBrush handleClickPenBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());
    QBrush handleDisablePenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());


    QBrush sliderGroovePenBrush(Qt::NoBrush);

    QBrush focusPenBrush            = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus());

    QPen handleDefaultPen   = QPen(handleDefaultPenBrush, (handleDefaultPenBrush.style() == Qt::NoBrush || handleDefaultPenBrush.color().alpha() == 0) ? 0 : 4,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen handleHoverPen     = QPen(handleHoverPenBrush, (handleHoverPenBrush.style() == Qt::NoBrush || handleHoverPenBrush.color().alpha() == 0) ? 0 : 4,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen handleClickPen     = QPen(handleClickPenBrush, (handleClickPenBrush.style() == Qt::NoBrush || handleClickPenBrush.color().alpha() == 0) ? 0 : 5,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen handleDisablePen   = QPen(handleDisablePenBrush, (handleDisablePenBrush.style() == Qt::NoBrush || handleDisablePenBrush.color().alpha() == 0) ? 0 : 4,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen sliderGroovePen    = QPen(sliderGroovePenBrush, (sliderGroovePenBrush.style() == Qt::NoBrush || sliderGroovePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen focusPen           = QPen(focusPenBrush, (focusPenBrush.style() == Qt::NoBrush || focusPenBrush.color().alpha() == 0) ? 0 : 2,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);



    QPainterPath handlePath;
    int radius = m_dtconfig->kradiusNormal();

    const QStyleOptionSlider *slider = qstyleoption_cast<const QStyleOptionSlider *>(option);
    const bool horizontal = slider ? slider->orientation == Qt::Horizontal : false;

    QRect handleRect = option ? option->rect : QRect(0,0,0,0);
    handlePath.addEllipse(handleRect);

    if (m_dtconfig->kBrandHover().style() == Qt::LinearGradientPattern && !horizontal) {
        //vertical handle hover
        QLinearGradient linearGradient;
        linearGradient.setStart(!option ? QPoint(0,0) : option->rect.topRight());
        linearGradient.setFinalStop(!option ? QPoint(0,0) : option->rect.topLeft());
        linearGradient.setStops(m_dtconfig->kBrandHover().gradient()->stops());
        handleHoverBrush = QBrush(linearGradient);
    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius",                    radius);
        w->setProperty("grooveRadius",              grooveRadius);
        w->setProperty("handleDefaultBrush",        handleDefaultBrush);
        w->setProperty("handleHoverBrush",          handleHoverBrush);
        w->setProperty("handleClickBrush",          handleClickBrush);
        w->setProperty("handleDisableBrush",        handleDisableBrush);
        w->setProperty("handleDisbaleBaseBrush",    handleDisbaleBaseBrush);
        w->setProperty("grooveValueDefaultBrush",   grooveValueDefaultBrush);
        w->setProperty("grooveValueHoverBrush",     grooveValueHoverBrush);
        w->setProperty("grooveValueDisableBrush",   grooveValueDisableBrush);
        w->setProperty("grooveUnvalueDefaultBrush", grooveUnvalueDefaultBrush);
        w->setProperty("grooveUnvalueHoverBrush",   grooveUnvalueHoverBrush);
        w->setProperty("grooveUnvalueDisableBrush", grooveUnvalueDisableBrush);
        w->setProperty("handleDefaultPen",          handleDefaultPen);
        w->setProperty("handleHoverPen",            handleHoverPen);
        w->setProperty("handleClickPen",            handleClickPen);
        w->setProperty("handleDisablePen",          handleDisablePen);
        w->setProperty("sliderGroovePen",           sliderGroovePen);
        w->setProperty("focusPen",                  focusPen);
    }

    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setGrooveRadius").isValid() && widget->property("setGrooveRadius").canConvert<int>()) {
            grooveRadius = widget->property("setGrooveRadius").value<int>();
        }
        if (widget->property("setHandleDefaultBrush").isValid() && widget->property("setHandleDefaultBrush").canConvert<QBrush>()) {
            handleDefaultBrush = widget->property("setHandleDefaultBrush").value<QBrush>();
        }
        if (widget->property("setHandleHoverBrush").isValid() && widget->property("setHandleHoverBrush").canConvert<QBrush>()) {
            handleHoverBrush = widget->property("setHandleHoverBrush").value<QBrush>();
        }
        if (widget->property("setHandleClickBrush").isValid() && widget->property("setHandleClickBrush").canConvert<QBrush>()) {
            handleClickBrush = widget->property("setHandleClickBrush").value<QBrush>();
        }
        if (widget->property("setHandleDisableBrush").isValid() && widget->property("setHandleDisableBrush").canConvert<QBrush>()) {
            handleDisableBrush = widget->property("setHandleDisableBrush").value<QBrush>();
        }
        if (widget->property("setHandleDisableBaseBrush").isValid() && widget->property("setHandleDisableBaseBrush").canConvert<QBrush>()) {
            handleDisbaleBaseBrush = widget->property("setHandleDisableBaseBrush").value<QBrush>();
        }
        if (widget->property("setGrooveValueDefaultBrush").isValid() && widget->property("setGrooveValueDefaultBrush").canConvert<QBrush>()) {
            grooveValueDefaultBrush = widget->property("setGrooveValueDefaultBrush").value<QBrush>();
        }
        if (widget->property("setGrooveValueHoverBrush").isValid() && widget->property("setGrooveValueHoverBrush").canConvert<QBrush>()) {
            grooveValueHoverBrush = widget->property("setGrooveValueHoverBrush").value<QBrush>();
        }
        if (widget->property("setGrooveValueDisableBrush").isValid() && widget->property("setGrooveValueDisableBrush").canConvert<QBrush>()) {
            grooveValueDisableBrush = widget->property("setGrooveValueDisableBrush").value<QBrush>();
        }
        if (widget->property("setGrooveUnvalueDefaultBrush").isValid() && widget->property("setGrooveUnvalueDefaultBrush").canConvert<QBrush>()) {
            grooveUnvalueDefaultBrush = widget->property("setGrooveUnvalueDefaultBrush").value<QBrush>();
        }
        if (widget->property("setGrooveUnvalueHoverBrush").isValid() && widget->property("setGrooveUnvalueHoverBrush").canConvert<QBrush>()) {
            grooveUnvalueHoverBrush = widget->property("setGrooveUnvalueHoverBrush").value<QBrush>();
        }
        if (widget->property("setGrooveUnvalueDisableBrush").isValid() && widget->property("setGrooveUnvalueDisableBrush").canConvert<QBrush>()) {
            grooveUnvalueDisableBrush = widget->property("setGrooveUnvalueDisableBrush").value<QBrush>();
        }

        if (widget->property("setHandleDefaultPen").isValid() && widget->property("setHandleDefaultPen").canConvert<QBrush>()) {
            handleDefaultPen = widget->property("setHandleDefaultPen").value<QPen>();
        }
        if (widget->property("setHandleHoverPen").isValid() && widget->property("setHandleHoverPen").canConvert<QBrush>()) {
            handleHoverPen = widget->property("setHandleHoverPen").value<QPen>();
        }
        if (widget->property("setHandleClickPen").isValid() && widget->property("setHandleClickPen").canConvert<QBrush>()) {
            handleClickPen = widget->property("setHandleClickPen").value<QPen>();
        }
        if (widget->property("setHandleDisablePen").isValid() && widget->property("setHandleDisablePen").canConvert<QBrush>()) {
            handleDisablePen = widget->property("setHandleDisablePen").value<QPen>();
        }
        if (widget->property("setSliderGroovePen").isValid() && widget->property("setSliderGroovePen").canConvert<QBrush>()) {
            sliderGroovePen = widget->property("setSliderGroovePen").value<QPen>();
        }
        if (widget->property("setFocusPen").isValid() && widget->property("setFocusPen").canConvert<QBrush>()) {
            focusPen = widget->property("setFocusPen").value<QPen>();
        }
    }

    m_SliderParameters.radius = radius;
    m_SliderParameters.sliderGrooveRadius = grooveRadius;

    m_SliderParameters.sliderHandleDefaultBrush = handleDefaultBrush;
    m_SliderParameters.sliderHandleHoverBrush = handleHoverBrush;
    m_SliderParameters.sliderHandleClickBrush = handleClickBrush;
    m_SliderParameters.sliderHandleDisableBrush = handleDisableBrush;
    m_SliderParameters.sliderHandleDisbaleBaseBrush = handleDisbaleBaseBrush;

    m_SliderParameters.sliderGrooveValueDefaultBrush = grooveValueDefaultBrush;
    m_SliderParameters.sliderGrooveValueHoverBrush   = grooveValueHoverBrush;
    m_SliderParameters.sliderGrooveValueDisableBrush = grooveValueDisableBrush;

    m_SliderParameters.sliderGrooveUnvalueDefaultBrush = grooveUnvalueDefaultBrush;
    m_SliderParameters.sliderGrooveUnvalueHoverBrush   = grooveUnvalueHoverBrush;
    m_SliderParameters.sliderGrooveUnvalueDisableBrush = grooveUnvalueDisableBrush;

    m_SliderParameters.sliderHandleDefaultPen = handleDefaultPen;
    m_SliderParameters.sliderHandleHoverPen   = handleHoverPen;
    m_SliderParameters.sliderHandleClickPen   = handleClickPen;
    m_SliderParameters.sliderHandleDisablePen = handleDisablePen;
    m_SliderParameters.sliderGroovePen        = sliderGroovePen;
    m_SliderParameters.focusPen               = focusPen;


    m_SliderParameters.sliderHandlePath = handlePath;
}



void UKUIConfigStyleParameters::getDefaultSliderParameters(ConfigSliderParameters *p, bool isDark)
{
    initConfigSliderParameters(isDark, nullptr, nullptr);
    p->radius                          = m_SliderParameters.radius                         ;
    p->sliderGrooveRadius              = m_SliderParameters.sliderGrooveRadius             ;
    p->sliderHandleDefaultBrush        = m_SliderParameters.sliderHandleDefaultBrush       ;
    p->sliderHandleHoverBrush          = m_SliderParameters.sliderHandleHoverBrush         ;
    p->sliderHandleClickBrush          = m_SliderParameters.sliderHandleClickBrush         ;
    p->sliderHandleDisableBrush        = m_SliderParameters.sliderHandleDisableBrush       ;
    p->sliderHandleDisbaleBaseBrush    = m_SliderParameters.sliderHandleDisbaleBaseBrush   ;
    p->sliderGrooveValueDefaultBrush   = m_SliderParameters.sliderGrooveValueDefaultBrush  ;
    p->sliderGrooveValueHoverBrush     = m_SliderParameters.sliderGrooveValueHoverBrush    ;
    p->sliderGrooveValueDisableBrush   = m_SliderParameters.sliderGrooveValueDisableBrush  ;
    p->sliderGrooveUnvalueDefaultBrush = m_SliderParameters.sliderGrooveUnvalueDefaultBrush;
    p->sliderGrooveUnvalueHoverBrush   = m_SliderParameters.sliderGrooveUnvalueHoverBrush  ;
    p->sliderGrooveUnvalueDisableBrush = m_SliderParameters.sliderGrooveUnvalueDisableBrush;
    p->sliderHandleDefaultPen          = m_SliderParameters.sliderHandleDefaultPen         ;
    p->sliderHandleHoverPen            = m_SliderParameters.sliderHandleHoverPen           ;
    p->sliderHandleClickPen            = m_SliderParameters.sliderHandleClickPen           ;
    p->sliderHandleDisablePen          = m_SliderParameters.sliderHandleDisablePen         ;
    p->sliderGroovePen                 = m_SliderParameters.sliderGroovePen                ;
    p->focusPen                        = m_SliderParameters.focusPen                       ;
}


void UKUIConfigStyleParameters::initConfigProgressBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    // int normalRadius = m_dtconfig->kradiusNormal();
    // int radius = widget ? (widget->height() / 2 > normalRadius ? normalRadius : widget->height() / 2) : normalRadius;

    const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option);
    if (!pb) {
        return ;
    }
    const bool indeterminate = (pb->minimum == 0 && pb->maximum == 0);//是否为indeterminate状态
    int radius = indeterminate ? (m_dtconfig->kradiusMin()) : (m_dtconfig->kradiusNormal());

    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ProgressBar];
    m_ProgressBarParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ProgressBar]);

    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }

    //已划过的进度区域颜色
    QBrush contentBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());

    //未填充的进度区域颜色
    QBrush grooveDefaultBrush;
    if (needTranslucent) {
        grooveDefaultBrush   = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaNormal());
    } else {
        grooveDefaultBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());
    }

    QBrush grooveDisableBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());

    QBrush sliderBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandNormal());

    QBrush contentPenBrush          = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive());
    QBrush grooveDefaultPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineComponentNormal());
    QBrush grooveDisablePenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentDisable());

    // QPen contentPen         = QPen(contentPenBrush, (contentPenBrush.style() == Qt::NoBrush || contentPenBrush.color().alpha() == 0) ? 0 : 1,
    //                            Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen contentPen         = QPen(Qt::NoPen);
    QPen grooveDefaultPen   = QPen(grooveDefaultPenBrush, (grooveDefaultPenBrush.style() == Qt::NoBrush || grooveDefaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen grooveDisablePen   = QPen(grooveDisablePenBrush, (grooveDisablePenBrush.style() == Qt::NoBrush || grooveDisablePenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    // const QStyleOptionProgressBar *pb = qstyleoption_cast<const QStyleOptionProgressBar *>(option);
    // const bool vertical = pb ? pb->orientation == Qt::Vertical : false;
    // const bool inverted = pb ? pb->invertedAppearance : false;

    // bool reverse = (!vertical && pb && (pb->direction == Qt::RightToLeft)) || vertical;
    // if (inverted)
    //     reverse = !reverse;

    //content
    // if (contentBrush.style() == Qt::LinearGradientPattern) {
    //     QLinearGradient linearGradient;
    //     linearGradient.setStops(contentBrush.gradient()->stops());
    //     if (vertical) {
    //         if (reverse) {
    //             linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.bottomLeft());
    //             linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.topLeft());
    //         } else {
    //             linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topLeft());
    //             linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.bottomLeft());
    //         }
    //     } else {
    //         if (reverse) {
    //             linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topRight());
    //             linearGradient.setFinalStop(pb->rect.topLeft());
    //         } else {
    //             linearGradient.setStart(!pb ? QPoint(0, 0) : pb->rect.topLeft());
    //             linearGradient.setFinalStop(!pb ? QPoint(0, 0) : pb->rect.topRight());
    //         }
    //     }
    //     contentBrush = QBrush(linearGradient);
    // }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("contentPen",              contentPen);
        w->setProperty("grooveDefaultPen",        grooveDefaultPen);
        w->setProperty("grooveDisablePen",        grooveDisablePen);
        w->setProperty("contentBrush",            contentBrush);
        w->setProperty("grooveDefaultBrush",      grooveDefaultBrush);
        w->setProperty("grooveDisableBrush",      grooveDisableBrush);
        w->setProperty("progressSliderBrush",     sliderBrush);
    }

    if(widget){
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setContentBrush").isValid() && widget->property("setContentBrush").canConvert<QBrush>()) {
            contentBrush = widget->property("setContentBrush").value<QBrush>();
        }
        if (widget->property("setGrooveDefaultBrush").isValid() && widget->property("setGrooveDefaultBrush").canConvert<QBrush>()) {
            grooveDefaultBrush = widget->property("setGrooveDefaultBrush").value<QBrush>();
        }
        if (widget->property("setGrooveDisableBrush").isValid() && widget->property("setGrooveDisableBrush").canConvert<QBrush>()) {
            grooveDisableBrush = widget->property("setGrooveDisableBrush").value<QBrush>();
        }
        if (widget->property("setGrooveDefaultPen").isValid() && widget->property("setGrooveDefaultPen").canConvert<QColor>()) {
            grooveDefaultPen = widget->property("setGrooveDefaultPen").value<QPen>();
        }
        if (widget->property("setGrooveDisablePen").isValid() && widget->property("setGrooveDisablePen").canConvert<QColor>()) {
            grooveDisablePen = widget->property("setGrooveDisablePen").value<QPen>();
        }
        if (widget->property("setSliderBrush").isValid() && widget->property("setSliderBrush").canConvert<QColor>()) {
            sliderBrush = widget->property("setSliderBrush").value<QBrush>();
        }
    }

    m_ProgressBarParameters.radius = radius;

    m_ProgressBarParameters.progressBarContentPen       = contentPen;
    m_ProgressBarParameters.progressBarGrooveDefaultPen = grooveDefaultPen;
    m_ProgressBarParameters.progressBarGrooveDisablePen = grooveDisablePen;

    m_ProgressBarParameters.progressBarContentBrush       = contentBrush;
    m_ProgressBarParameters.progressBarGrooveDefaultBrush = grooveDefaultBrush;
    m_ProgressBarParameters.progressBarGrooveDisableBrush = grooveDisableBrush;

    m_ProgressBarParameters.progressSliderBrush           = sliderBrush;
}

void UKUIConfigStyleParameters::getDefaultProgressBarParameters(ConfigProgressBarParameters *p, bool isDark)
{
    initConfigProgressBarParameters(isDark, nullptr, nullptr);
    p->radius                          = m_ProgressBarParameters.radius                         ;
    p->progressBarContentPen           = m_ProgressBarParameters.progressBarContentPen          ;
    p->progressBarGrooveDefaultPen     = m_ProgressBarParameters.progressBarGrooveDefaultPen    ;
    p->progressBarGrooveDisablePen     = m_ProgressBarParameters.progressBarGrooveDisablePen    ;
    p->progressBarContentBrush         = m_ProgressBarParameters.progressBarContentBrush        ;
    p->progressBarGrooveDefaultBrush   = m_ProgressBarParameters.progressBarGrooveDefaultBrush  ;
    p->progressBarGrooveDisableBrush   = m_ProgressBarParameters.progressBarGrooveDisableBrush  ;
}

void UKUIConfigStyleParameters::initConfigScrollBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int sliderRadius;
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::ScrollBar];
    m_ScrollBarParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::ScrollBar]);

    if (widget && widget->property("needTranslucent").isValid()) {
        needTranslucent = widget->property("needTranslucent").toBool();
    }

    QBrush grooveDefaultBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());
    QBrush grooveInactiveBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());

    //scrollbar本身颜色
    QBrush sliderDefaultBrush,sliderHoverBrush,sliderClickBrush,sliderDisableBrush;
    if (needTranslucent) {
        sliderDefaultBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedAlphaNormal());
        sliderHoverBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedAlphaHover());
        sliderClickBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedAlphaClick());
        sliderDisableBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedAlphaDisable());
    } else {
        sliderDefaultBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedNormal());
        sliderHoverBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedHover());
        sliderClickBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedClick());
        sliderDisableBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentSelectedDisable());
    }

    const QStyleOptionSlider *bar = qstyleoption_cast<const QStyleOptionSlider *>(option);

    //radius
    int normalRadius = m_dtconfig->kradiusMin();
    if (bar && normalRadius != 0) {
        if (bar->orientation == Qt::Horizontal) {
            sliderRadius = (bar->rect.height()) / 4;
        } else {
            sliderRadius = (bar->rect.width()) / 4;
        }
        m_ScrollBarParameters.grooveWidthAnimation = true;
        ScrooBar_ShowLine = false;
        ScroolBar_LineLength = 0;
    } else {
        int normalRadius = m_dtconfig->kradiusNormal();
        sliderRadius = normalRadius;
        m_ScrollBarParameters.grooveWidthAnimation = false;
        ScrooBar_ShowLine = true;
        ScroolBar_LineLength = 16;
    }

    //slider hover
    // if (m_dtconfig->kContainHover().style() == Qt::LinearGradientPattern && bar && bar->orientation == Qt::Vertical) {
        // QLinearGradient linearGradient;
        // linearGradient.setStart(!option ? QPoint(0,0) : option->rect.topRight());
        // linearGradient.setFinalStop(!option ? QPoint(0,0) : option->rect.topLeft());
        // linearGradient.setStops(m_dtconfig->kContainHover().gradient()->stops());
        // sliderHoverBrush = QBrush(linearGradient);
    // }
    if (m_dtconfig->kContainHover().style() == Qt::LinearGradientPattern && bar && bar->orientation == Qt::Vertical) {
        QLinearGradient linearGradient;
        // 起点：顶部中点 (0.5 * width, 0)
        linearGradient.setStart(!option ? QPoint(0,0) : QPoint(option->rect.width() * 0.5, option->rect.top()));
        // 终点：底部中点 (0.5 * width, height)
        linearGradient.setFinalStop(!option ? QPoint(0,0) : QPoint(option->rect.width() * 0.5, option->rect.bottom()));
        linearGradient.setStops(m_dtconfig->kContainHover().gradient()->stops());
        sliderHoverBrush = QBrush(linearGradient);
    }
    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", sliderRadius);
        w->setProperty("grooveDefaultBrush",     grooveDefaultBrush);
        w->setProperty("grooveInactiveBrush",     grooveInactiveBrush);
        w->setProperty("sliderDefaultBrush",     sliderDefaultBrush);
        w->setProperty("sliderHoverBrush",     sliderHoverBrush);
        w->setProperty("sliderClickBrush",     sliderClickBrush);
        w->setProperty("sliderDisableBrush",     sliderDisableBrush);
    }
    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setGrooveDefaultBrush").isValid() && widget->property("setGrooveDefaultBrush").canConvert<QBrush>()) {
            grooveDefaultBrush = widget->property("setGrooveDefaultBrush").value<QBrush>();
        }
        if (widget->property("setGrooveInactiveBrush").isValid() && widget->property("setGrooveInactiveBrush").canConvert<QBrush>()) {
            grooveInactiveBrush = widget->property("setGrooveInactiveBrush").value<QBrush>();
        }
        if (widget->property("setSliderDefaultBrush").isValid() && widget->property("setSliderDefaultBrush").canConvert<QBrush>()) {
            sliderDefaultBrush = widget->property("setSliderDefaultBrush").value<QBrush>();
        }
        if (widget->property("setSliderHoverBrush").isValid() && widget->property("setSliderHoverBrush").canConvert<QBrush>()) {
            sliderHoverBrush = widget->property("setSliderHoverBrush").value<QBrush>();
        }
        if (widget->property("setSliderClickBrush").isValid() && widget->property("setSliderClickBrush").canConvert<QBrush>()) {
            sliderClickBrush = widget->property("setSliderClickBrush").value<QBrush>();
        }
        if (widget->property("setSliderDisableBrush").isValid() && widget->property("setSliderDisableBrush").canConvert<QBrush>()) {
            sliderDisableBrush = widget->property("setSliderDisableBrush").value<QBrush>();
        }
    }

    m_ScrollBarParameters.radius = sliderRadius;
    ScroolBar_Height= 68;
    m_ScrollBarParameters.scrollBarGrooveDefaultBrush  = grooveDefaultBrush;
    m_ScrollBarParameters.scrollBarGrooveInactiveBrush = grooveInactiveBrush;
    m_ScrollBarParameters.scrollBarSliderDefaultBrush  = sliderDefaultBrush;
    m_ScrollBarParameters.scrollBarSliderHoverBrush    = sliderHoverBrush;
    m_ScrollBarParameters.scrollBarSliderClickBrush    = sliderClickBrush;
    m_ScrollBarParameters.scrollBarSliderDisableBrush  = sliderDisableBrush;
}

void UKUIConfigStyleParameters::getDefaultScrollBarParameters(ConfigScrollBarParameters *p, bool isDark)
{
    initConfigScrollBarParameters(isDark, nullptr, nullptr);
    p->radius                       = m_ScrollBarParameters.radius                      ;
    p->scrollBarGrooveDefaultBrush  = m_ScrollBarParameters.scrollBarGrooveDefaultBrush ;
    p->scrollBarGrooveInactiveBrush = m_ScrollBarParameters.scrollBarGrooveInactiveBrush;
    p->scrollBarSliderDefaultBrush  = m_ScrollBarParameters.scrollBarSliderDefaultBrush ;
    p->scrollBarSliderHoverBrush    = m_ScrollBarParameters.scrollBarSliderHoverBrush   ;
    p->scrollBarSliderClickBrush    = m_ScrollBarParameters.scrollBarSliderClickBrush   ;
    p->scrollBarSliderDisableBrush  = m_ScrollBarParameters.scrollBarSliderDisableBrush ;
}

void UKUIConfigStyleParameters::initConfigToolTipParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Tooltip];
    m_ToolTipParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Tooltip]);

//    QPen backgroundPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()),
//                              (parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()).color().alpha() == 0 ||
//                              parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive()).color() == Qt::NoPen ) ? 0 : 1,
//                              Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    QPen backgroundPen = QPen(parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowInactive()),1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //background
    auto color = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive()).color();
    if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
        auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0;
        color.setAlphaF(1.0);//opacity);
    }
    if (qApp->property("blurEnable").isValid()) {
        bool blurEnable = qApp->property("blurEnable").toBool();
        if (!blurEnable) {
            color.setAlphaF(1);
        }
    }
    if (widget) {
        if (widget->property("useSystemStyleBlur").isValid() && !widget->property("useSystemStyleBlur").toBool()) {
            color.setAlphaF(1);
        }
    }
    //if blur effect is not supported, do not use transparent color.
    // if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) {
    //     color.setAlphaF(1);
    // }
    QBrush backgroundBrush = color;

    int radius = m_dtconfig->kradiusMenu();
    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            radius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setBackgroundBrush").isValid() && widget->property("setBackgroundBrush").canConvert<QBrush>()) {
            backgroundBrush = widget->property("setBackgroundBrush").value<QBrush>();
        }
        if (widget->property("setBackgroundPen").isValid() && widget->property("setBackgroundPen").canConvert<QBrush>()) {
            backgroundPen = widget->property("setBackgroundPen").value<QPen>();
        }
    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", radius);
        w->setProperty("backgroundBrush",     backgroundBrush);
        w->setProperty("backgroundPen",     backgroundPen);
    }
    m_ToolTipParameters.radius = radius;
    m_ToolTipParameters.toolTipBackgroundBrush = backgroundBrush;
    m_ToolTipParameters.toolTipBackgroundPen = backgroundPen;
}

void UKUIConfigStyleParameters::getDefaultToolTipParameters(ConfigToolTipParameters *p, bool isDark)
{
    initConfigToolTipParameters(isDark, nullptr, nullptr);
    p->radius                 = m_ToolTipParameters.radius                ;
    p->toolTipBackgroundBrush = m_ToolTipParameters.toolTipBackgroundBrush;
    p->toolTipBackgroundPen   = m_ToolTipParameters.toolTipBackgroundPen  ;
}
//解析TabWidget相关颜色
void UKUIConfigStyleParameters::initConfigTabWidgetParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::TabWidget];
    m_TabWidgetParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::TabWidget]);

    bool selected = false;
    if (option) {
        selected = option->state & QStyle::State_Selected;
    }

    int tabradius = m_dtconfig->kradiusWindow();

    QBrush widgetBackgroundBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive());

    //整个TabBar的背景色
    //QBrush tabBarBackgroundBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());
    QBrush tabBarBackgroundBrush = Qt::transparent;


    //tab默认背景色
    QBrush tabBarDefaultBrush    = selected ? parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal()) : Qt::transparent;

    QBrush tabBarHoverBrush,tabBarSelectBrush,tabBarClickBrush,tabBarFocusBrush;

    tabBarFocusBrush      = parseBrush(option ? option->rect : QRect(), selected ? m_dtconfig->kContainGeneralNormal() : Qt::transparent);

    if (needTranslucent) {
        tabBarHoverBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainAlphaHover());//是否选中，都是该token
        tabBarClickBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainAlphaClick());

        tabBarSelectBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());

    } else {
        tabBarHoverBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainHover());
        tabBarClickBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainClick());

        tabBarSelectBrush     = parseBrush(option ? option->rect : QRect(), m_dtconfig->kContainGeneralNormal());
    }


//    QBrush tabBarHoverPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
//    QBrush tabBarClickPenPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
//    QBrush tabBarDefaultPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentNormal());

    QBrush tabBarHoverPenBrush    = Qt::transparent;
    QBrush tabBarClickPenPenBrush = Qt::transparent;
    QBrush tabBarDefaultPenBrush  = Qt::transparent;

    QBrush tabBarFocusPenBrush    = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus());
    QBrush tabBarDividerPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kDivider());

    QPen tabBarHoverPen   = QPen(tabBarHoverPenBrush, (tabBarHoverPenBrush.style() == Qt::NoBrush || tabBarHoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen tabBarClickPen   = QPen(tabBarClickPenPenBrush, (tabBarClickPenPenBrush.style() == Qt::NoBrush || tabBarClickPenPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen tabBarDefaultPen = QPen(tabBarDefaultPenBrush, (tabBarDefaultPenBrush.style() == Qt::NoBrush || tabBarDefaultPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen tabBarFocusPen   = QPen(tabBarFocusPenBrush, (tabBarFocusPenBrush.style() == Qt::NoBrush || tabBarFocusPenBrush.color().alpha() == 0) ? 0 : 2,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    QPen tabBarDividerPen = QPen(tabBarDividerPenBrush, (tabBarDividerPenBrush.style() == Qt::NoBrush || tabBarDividerPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


//    if((option->state & QStyle::State_HasFocus) && (option->state & QStyle::State_Enabled)){
//        tabBarPen = tabBarFocusPen;
//    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("radius", tabradius);
        w->setProperty("widgetBackgroundBrush", widgetBackgroundBrush);
        w->setProperty("tabBarBackgroundBrush", tabBarBackgroundBrush);
        w->setProperty("tabBarDefaultBrush",    tabBarDefaultBrush);
        w->setProperty("tabBarHoverBrush",      tabBarHoverBrush);
        w->setProperty("tabBarClickBrush",      tabBarClickBrush);
        w->setProperty("tabBarSelectBrush",     tabBarSelectBrush);
        w->setProperty("tabBarDefaultPen",      tabBarDefaultPen);
        w->setProperty("tabBarFocusPen",        tabBarFocusPen);
        w->setProperty("tabBarClickPen",        tabBarClickPen);
        w->setProperty("tabBarHoverPen",        tabBarHoverPen);
    }
    if (widget) {
        if (widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
            tabradius = widget->property("setRadius").value<int>();
        }
        if (widget->property("setWidgetBackgroundBrush").isValid() && widget->property("setWidgetBackgroundBrush").canConvert<QBrush>()) {
            widgetBackgroundBrush = widget->property("setWidgetBackgroundBrush").value<QBrush>();
        }
        if (widget->property("setTabBarBackgroundBrush").isValid() && widget->property("setTabBarBackgroundBrush").canConvert<QBrush>()) {
            tabBarBackgroundBrush = widget->property("setTabBarBackgroundBrush").value<QBrush>();
        }
        if (widget->property("setTabBarDefaultBrush").isValid() && widget->property("setTabBarDefaultBrush").canConvert<QBrush>()) {
            tabBarDefaultBrush = widget->property("setTabBarDefaultBrush").value<QBrush>();
        }
        if (widget->property("setTabBarHoverBrush").isValid() && widget->property("setTabBarHoverBrush").canConvert<QBrush>()) {
            tabBarHoverBrush = widget->property("setTabBarHoverBrush").value<QBrush>();
        }
        if (widget->property("setTabBarClickBrush").isValid() && widget->property("setTabBarClickBrush").canConvert<QBrush>()) {
            tabBarClickBrush = widget->property("setTabBarClickBrush").value<QBrush>();
        }
        if (widget->property("setTabBarSelectBrush").isValid() && widget->property("setTabBarSelectBrush").canConvert<QBrush>()) {
            tabBarSelectBrush = widget->property("setTabBarSelectBrush").value<QBrush>();
        }
        if (widget->property("setTabBarDefaultPen").isValid() && widget->property("setTabBarDefaultPen").canConvert<QPen>()) {
            tabBarDefaultPen = widget->property("setTabBarDefaultPen").value<QPen>();
        }
        if (widget->property("setTabBarFocusPen").isValid() && widget->property("setTabBarFocusPen").canConvert<QPen>()) {
            tabBarFocusPen = widget->property("setTabBarFocusPen").value<QPen>();
        }
        if (widget->property("setTabBarClickPen").isValid() && widget->property("setTabBarClickPen").canConvert<QPen>()) {
            tabBarFocusPen = widget->property("setTabBarClickPen").value<QPen>();
        }
        if (widget->property("setTabBarHoverPen").isValid() && widget->property("setTabBarHoverPen").canConvert<QPen>()) {
            tabBarFocusPen = widget->property("setTabBarHoverPen").value<QPen>();
        }
    }

    m_TabWidgetParameters.radius = tabradius;
    m_TabWidgetParameters.tabWidgetBackgroundBrush = widgetBackgroundBrush;
    m_TabWidgetParameters.tabBarBackgroundBrush = tabBarBackgroundBrush;
    m_TabWidgetParameters.tabBarDefaultBrush = tabBarDefaultBrush;
    m_TabWidgetParameters.tabBarHoverBrush = tabBarHoverBrush;
    m_TabWidgetParameters.tabBarClickBrush = tabBarClickBrush;
    m_TabWidgetParameters.tabBarSelectBrush = tabBarSelectBrush;
    m_TabWidgetParameters.tabBarDefaultPen  = tabBarDefaultPen;
    m_TabWidgetParameters.tabBarHoverPen  = tabBarHoverPen;
    m_TabWidgetParameters.tabBarClickPen  = tabBarClickPen;
    m_TabWidgetParameters.tabBarFocusPen  = tabBarFocusPen;

    m_TabWidgetParameters.tabBarDividerPen = tabBarDividerPen;
}

void UKUIConfigStyleParameters::getDefaultTabWidgetParameters(ConfigTabWidgetParameters *p, bool isDark)
{
    initConfigTabWidgetParameters(isDark, nullptr, nullptr);

    p->radius                   = m_TabWidgetParameters.radius                  ;
    p->tabWidgetBackgroundBrush = m_TabWidgetParameters.tabWidgetBackgroundBrush;
    p->tabBarBackgroundBrush    = m_TabWidgetParameters.tabBarBackgroundBrush   ;
    p->tabBarDefaultBrush       = m_TabWidgetParameters.tabBarDefaultBrush      ;
    p->tabBarHoverBrush         = m_TabWidgetParameters.tabBarHoverBrush        ;
    p->tabBarClickBrush         = m_TabWidgetParameters.tabBarClickBrush        ;
    p->tabBarSelectBrush        = m_TabWidgetParameters.tabBarSelectBrush       ;
    p->tabBarDefaultPen         = m_TabWidgetParameters.tabBarDefaultPen        ;
    p->tabBarHoverPen           = m_TabWidgetParameters.tabBarHoverPen          ;
    p->tabBarClickPen           = m_TabWidgetParameters.tabBarClickPen          ;
    p->tabBarFocusPen           = m_TabWidgetParameters.tabBarFocusPen          ;
    p->tabBarDividerPen         = m_TabWidgetParameters.tabBarDividerPen        ;
}

void UKUIConfigStyleParameters::initConfigMenuParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    bool needTranslucent = TransparencyUsage[(int)StyleCtrlElement::Menu];
    m_MenuParameters.setFocusEnable(FocusUsage[(int)StyleCtrlElement::Menu]);

    bool ishighlightMode = false;

    int frameradius = m_dtconfig->kradiusMenu();//整个菜单的圆角

    int itemradius = m_dtconfig->kradiusNormal();//被选择的item区域圆角

    //menu被选中item区域的背景色
    QBrush itemSelectBrush;
    QBrush itemClickBrush;

    if (needTranslucent) {
        itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaHover());
        itemClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentAlphaClick());
    } else {
        itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentHover());
        itemClickBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kComponentClick());
    }

    //被选中item中文本的颜色
    QBrush menuHoverPenBrush      = parseBrush(option ? option->rect : QRect(), m_dtconfig->kFontPrimary());

    QBrush menuItemFocusPenBrush  = parseBrush(option ? option->rect : QRect(), m_dtconfig->kBrandFocus());

    //整个menu外框颜色
    QBrush menuBackgroundPenBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->kLineWindowActive());
    QPen menuBackgroundPen = QPen(menuBackgroundPenBrush, (menuBackgroundPenBrush.style() == Qt::NoBrush || menuBackgroundPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    QPen menuHoverPen      = QPen(menuHoverPenBrush, (menuHoverPenBrush.style() == Qt::NoBrush || menuHoverPenBrush.color().alpha() == 0) ? 0 : 1,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);


    QPen menuItemFocusPen  = QPen(menuItemFocusPenBrush, (menuItemFocusPenBrush.style() == Qt::NoBrush || menuItemFocusPenBrush.color().alpha() == 0) ? 0 : 2,
                               Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    auto color = parseBrush(option ? option->rect : QRect(), m_dtconfig->baseActive()).color();
    if (widget && !widget->inherits("QComboBoxPrivateContainer") && UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
        auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0;
        color.setAlphaF(1.0);//opacity);
    }
    if (qApp->property("blurEnable").isValid()) {
        bool blurEnable = qApp->property("blurEnable").toBool();
        if (!blurEnable) {
            color.setAlphaF(1);
        }
    }
    if (widget) {
        if (widget->property("useSystemStyleBlur").isValid() && !widget->property("useSystemStyleBlur").toBool()) {
            color.setAlphaF(1);
        }
        if(widget->property("highlightMode").isValid()){
            ishighlightMode = widget->property("highlightMode").toBool();
        }
    }
    //if blur effect is not supported, do not use transparent color.
    // if (!KWindowEffects::isEffectAvailable(KWindowEffects::BlurBehind) || blackAppListWithBlurHelper().contains(qAppName())) {
    //     color.setAlphaF(1);
    // }
    QBrush menuBackgroundBrush = color;
    if(ishighlightMode){
        itemSelectBrush = parseBrush(option ? option->rect : QRect(), m_dtconfig->highLightActive());
    }

    auto *w = const_cast<QWidget *>(widget);
    if (w) {
        w->setProperty("frameradius", frameradius);
        w->setProperty("itemradius",  itemradius);
        w->setProperty("menuBackgroundBrush", menuBackgroundBrush);
        w->setProperty("menuBackgroundPen",   menuBackgroundPen);
        w->setProperty("itemSelectBrush",     itemSelectBrush);
        w->setProperty("itemClickBrush",      itemClickBrush);
        w->setProperty("menuHoverPen",        menuHoverPen);
        w->setProperty("itemFocusPen",        menuItemFocusPen);
    }

    if (widget) {
        if (widget->property("setFrameRadius").isValid() && widget->property("setFrameRadius").canConvert<int>()) {
            frameradius = widget->property("setFrameRadius").value<int>();
        }
        if (widget->property("setItemRadius").isValid() && widget->property("setItemRadius").canConvert<int>()) {
            itemradius = widget->property("setItemRadius").value<int>();
        }
        if (widget->property("setItemSelectBrush").isValid() && widget->property("setItemSelectBrush").canConvert<QBrush>()) {
            itemSelectBrush = widget->property("setItemSelectBrush").value<QBrush>();
        }
        if (widget->property("setItemClickBrush").isValid() && widget->property("setItemClickBrush").canConvert<QBrush>()) {
            itemClickBrush = widget->property("setItemClickBrush").value<QBrush>();
        }
        if (widget->property("setTextHoverPen").isValid() && widget->property("setTextHoverPen").canConvert<QPen>()) {
            menuHoverPen = widget->property("setTextHoverPen").value<QPen>();
        }
        if (widget->property("setMenuBackgroundBrush").isValid() && widget->property("setMenuBackgroundBrush").canConvert<QBrush>()) {
            menuBackgroundBrush = widget->property("setMenuBackgroundBrush").value<QBrush>();
        }
        if (widget->property("setMenuBackgroundPen").isValid() && widget->property("setMenuBackgroundPen").canConvert<QPen>()) {
            menuBackgroundPen = widget->property("setMenuBackgroundPen").value<QPen>();
        }
        if (widget->property("setItemFocusPen").isValid() && widget->property("setItemFocusPen").canConvert<QPen>()) {
            menuItemFocusPen = widget->property("setItemFocusPen").value<QPen>();
        }
    }

    m_MenuParameters.frameRadius = frameradius;
    m_MenuParameters.itemRadius = itemradius;
    m_MenuParameters.menuBackgroundBrush = menuBackgroundBrush;
    m_MenuParameters.menuBackgroundPen   = menuBackgroundPen;
    m_MenuParameters.menuItemSelectBrush = itemSelectBrush;
    m_MenuParameters.menuItemClickBrush = itemClickBrush;
    m_MenuParameters.menuItemFocusPen    = menuItemFocusPen;
    m_MenuParameters.menuTextHoverPen = menuHoverPen;
}

void UKUIConfigStyleParameters::getDefaultMenuParameters(ConfigMenuParameters *p, bool isDark)
{
    initConfigTabWidgetParameters(isDark, nullptr, nullptr);
    p->frameRadius         = m_MenuParameters.frameRadius        ;
    p->itemRadius          = m_MenuParameters.itemRadius         ;
    p->menuBackgroundBrush = m_MenuParameters.menuBackgroundBrush;
    p->menuBackgroundPen   = m_MenuParameters.menuBackgroundPen  ;
    p->menuItemSelectBrush = m_MenuParameters.menuItemSelectBrush;
    p->menuItemClickBrush  = m_MenuParameters.menuItemClickBrush;
    p->menuItemFocusPen    = m_MenuParameters.menuItemFocusPen   ;
    p->menuTextHoverPen    = m_MenuParameters.menuTextHoverPen   ;
}
