/*
 * Qt5-UKUI's Library
 *
 * Copyright (C) 2020, Tianjin KYLIN Information Technology 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: Lei Chen <leichen@kylinos.cn>
 *
 */


#include <QPushButton>
#include <QToolButton>
#include <QApplication>
#include <QPainter>
#include <KWindowEffects>


#include "ukui-style-settings.h"
#include "kabstract-style-parameters.h"
#include "black-list.h"

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

KAbstractStyleParameters::KAbstractStyleParameters(QObject *parent, bool isDark)
{

}

QPalette KAbstractStyleParameters::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;
}


//Default widget theme
KDefaultStyleParameters::KDefaultStyleParameters(QObject *parent, bool isDark) : KAbstractStyleParameters(parent, isDark)
{
    radius = 6;

    ColoseButtonColor = QColor(243, 34, 45);


    initPalette(isDark);
}

void KDefaultStyleParameters::initPalette(bool isDark)
{
    //ukui-light palette UKUI3.1
    QColor windowText_at(38, 38, 38),
           windowText_iat(0, 0, 0, 255 * 0.55),
           windowText_dis(0, 0, 0, 255 * 0.3),
           button_at(230, 230, 230),
           button_iat(230, 230, 230),
           button_dis(233, 233, 233),
           light_at(255, 255, 255),
           light_iat(255, 255, 255),
           light_dis(242, 242, 242),
           midlight_at(218, 218, 218),
           midlight_iat(218, 218, 218),
           midlight_dis(230, 230, 230),
           dark_at(77, 77, 77),
           dark_iat(77, 77, 77),
           dark_dis(64, 64, 64),
           mid_at(115, 115, 115),
           mid_iat(115, 115, 115),
           mid_dis(102, 102, 102),
           text_at(38, 38, 38),
           text_iat(38, 38, 38),
           text_dis(0, 0, 0, 255 * 0.3),
           brightText_at(0, 0, 0),
           brightText_iat(0, 0, 0),
           brightText_dis(0, 0, 0),
           buttonText_at(38, 38, 38),
           buttonText_iat(38, 38, 38),
           buttonText_dis(179, 179, 179),
           base_at(255, 255, 255),
           base_iat(245, 245, 245),
           base_dis(237, 237, 237),
           window_at(245, 245, 245),
           window_iat(237, 237, 237),
           window_dis(230, 230, 230),
           shadow_at(0, 0, 0, 255 * 0.16),
           shadow_iat(0, 0, 0, 255 * 0.16),
           shadow_dis(0, 0, 0, 255 * 0.21),
//           shadow_at(214, 214, 214),
//           shadow_iat(214, 214, 214),
//           shadow_dis(201, 201, 201),
           highLight_at(55, 144, 250),
           highLight_iat(55, 144, 250),
           highLight_dis(233, 233, 233),
           highLightText_at(255, 255, 255),
           highLightText_iat(255, 255, 255),
           highLightText_dis(179, 179, 179),
           link_at(55, 144, 250),
           link_iat(55, 144, 250),
           link_dis(55, 144, 250),
           linkVisited_at(114, 46, 209),
           linkVisited_iat(114, 46, 209),
           linkVisited_dis(114, 46, 209),
           alternateBase_at(245, 245, 245),
           alternateBase_iat(245, 245, 245),
           alternateBase_dis(245, 245, 245),
           noRale_at(240, 240, 240),
           noRole_iat(240, 240, 240),
           noRole_dis(217, 217, 217),
           toolTipBase_at(255, 255, 255),
           toolTipBase_iat(255, 255, 255),
           toolTipBase_dis(255, 255, 255),
           toolTipText_at(38, 38, 38),
           toolTipText_iat(38, 38, 38),
           toolTipText_dis(38, 38, 38),
           placeholderText_at(0, 0, 0, 255 * 0.35),
           placeholderText_iat(0, 0, 0, 255 * 0.35),
           placeholderText_dis(0, 0, 0, 255 * 0.3);

    //ukui-dark
    if (isDark) {
        windowText_at.setRgb(217, 217, 217);
        windowText_iat.setRgb(255, 255, 255, 255 * 0.55);
        windowText_dis.setRgb(255, 255, 255, 255 * 0.3);
        button_at.setRgb(55, 55, 59);
        button_iat.setRgb(55, 55, 59);
        button_dis.setRgb(46, 46, 48);
        light_at.setRgb(255, 255, 255),
        light_iat.setRgb(255, 255, 255),
        light_dis.setRgb(242, 242, 242),
        midlight_at.setRgb(95, 95, 98);
        midlight_iat.setRgb(95, 95, 98);
        midlight_dis.setRgb(79, 79, 82);
        dark_at.setRgb(38, 38, 38);
        dark_iat.setRgb(38, 38, 38);
        dark_dis.setRgb(26, 26, 26);
        mid_at.setRgb(115, 115, 115);
        mid_iat.setRgb(115, 115, 115);
        mid_dis.setRgb(102, 102, 102);
        text_at.setRgb(217, 217, 217);
        text_iat.setRgb(217, 217, 217);
        text_dis.setRgb(255, 255, 255, 255 * 0.3);
        brightText_at.setRgb(255, 255, 255);
        brightText_iat.setRgb(255, 255, 255);
        brightText_dis.setRgb(255, 255, 255);
        buttonText_at.setRgb(217, 217, 217);
        buttonText_iat.setRgb(217, 217, 217);
        buttonText_dis.setRgb(76, 76, 79);
        base_at.setRgb(29, 29, 29);
        base_iat.setRgb(28, 28, 28);
        base_dis.setRgb(36, 36, 36);
        window_at.setRgb(35, 36, 38);
        window_iat.setRgb(26, 26, 26);
        window_dis.setRgb(18, 18, 18);
        shadow_at.setRgb(0, 0, 0, 255 * 0.16),
        shadow_iat.setRgb(0, 0, 0, 255 * 0.16),
        shadow_dis.setRgb(0, 0, 0, 255 * 0.21),
//        shadow_at.setRgb(214, 214, 214);
//        shadow_iat.setRgb(214, 214, 214);
//        shadow_dis.setRgb(201, 201, 201);
        highLight_at.setRgb(55, 144, 250);
        highLight_iat.setRgb(55, 144, 250);
        highLight_dis.setRgb(46, 46, 46);
        highLightText_at.setRgb(255, 255, 255);
        highLightText_iat.setRgb(255, 255, 255);
        highLightText_dis.setRgb(77, 77, 77);
        link_at.setRgb(55, 144, 250);
        link_iat.setRgb(55, 144, 250);
        link_dis.setRgb(55, 144, 250);
        linkVisited_at.setRgb(114, 46, 209);
        linkVisited_iat.setRgb(114, 46, 209);
        linkVisited_dis.setRgb(114, 46, 209);
        alternateBase_at.setRgb(38, 38, 38);
        alternateBase_iat.setRgb(38, 38, 38);
        alternateBase_dis.setRgb(38, 38, 38);
        noRale_at.setRgb(51, 51, 51);
        noRole_iat.setRgb(51, 51, 51);
        noRole_dis.setRgb(60, 60, 60);
        toolTipBase_at.setRgb(38, 38, 38);
        toolTipBase_iat.setRgb(38, 38, 38);
        toolTipBase_dis.setRgb(38, 38, 38);
        toolTipText_at.setRgb(217, 217, 217);
        toolTipText_iat.setRgb(217, 217, 217);
        toolTipText_dis.setRgb(217, 217, 217);
        placeholderText_at.setRgb(255, 255, 255, 255 * 0.35);
        placeholderText_iat.setRgb(255, 255, 255, 255 * 0.35);
        placeholderText_dis.setRgb(255, 255, 255, 255 * 0.3);
    }

    defaultPalette.setColor(QPalette::Active, QPalette::WindowText, windowText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::WindowText, windowText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::WindowText, windowText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Button, button_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Button, button_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Button, button_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Light, light_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Light, light_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Light, light_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Midlight, midlight_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Midlight, midlight_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Midlight, midlight_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Dark, dark_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Dark, dark_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Dark, dark_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Mid, mid_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Mid, mid_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Mid, mid_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Text, text_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Text, text_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Text, text_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::BrightText, brightText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::BrightText, brightText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::BrightText, brightText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ButtonText, buttonText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ButtonText, buttonText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Base, base_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Base, base_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Base, base_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Window, window_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Window, window_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Window, window_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Shadow, shadow_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Shadow, shadow_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Shadow, shadow_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Highlight, highLight_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Highlight, highLight_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Highlight, highLight_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::HighlightedText, highLightText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Link, link_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Link, link_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Link, link_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::LinkVisited, linkVisited_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, linkVisited_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::LinkVisited, linkVisited_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::AlternateBase, alternateBase_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::AlternateBase, alternateBase_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::AlternateBase, alternateBase_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::NoRole, noRale_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::NoRole, noRole_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::NoRole, noRole_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ToolTipBase, toolTipBase_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipBase, toolTipBase_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipBase, toolTipBase_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ToolTipText, toolTipText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipText, toolTipText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipText, toolTipText_dis);

#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
    defaultPalette.setColor(QPalette::Active, QPalette::PlaceholderText, placeholderText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::PlaceholderText, placeholderText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::PlaceholderText, placeholderText_dis);
#endif
}


void KDefaultStyleParameters::initPushButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    pushButtonParameters.radius = 6;

    QBrush defaultBrush;
    QBrush clickBrush;
    QBrush hoverBrush;
    QBrush disableBrush;
    QBrush disableOnBrush;


    QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);
    if (isDark) {
        hoverBrush = QBrush(mixColor(highlight, mix, 0.2));
        clickBrush = QBrush(mixColor(highlight, mix, 0.05));
    } else {
        hoverBrush = QBrush(mixColor(highlight, mix, 0.05));
        clickBrush = QBrush(mixColor(highlight, mix, 0.2));
    }
    defaultBrush = option->palette.brush(QPalette::Active, QPalette::Button);
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disableOnBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    if (qobject_cast<const QPushButton *>(widget)) {
        bool isWindowButton = false;
        bool isWindowColoseButton = false;
        bool isImportant = false;
        bool useButtonPalette = false;

        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 (isWindowColoseButton) {
            QColor ColoseButton = ColoseButtonColor;

            if (isDark) {
                hoverBrush = QBrush(mixColor(ColoseButton, mix, 0.2));
                clickBrush = QBrush(mixColor(ColoseButton, mix, 0.05));
            } else {
                hoverBrush = QBrush(mixColor(ColoseButton, mix, 0.05));
                clickBrush = QBrush(mixColor(ColoseButton, mix, 0.2));
            }
        } else if (isWindowButton && useTransparentButtonList().contains(qAppName())) {
            if (isDark) {
                mix.setAlphaF(0.28);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.15);
                clickBrush = QBrush(mix);
            } else {
                mix.setAlphaF(0.15);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.28);
                clickBrush = QBrush(mix);
            }
        } else if (useButtonPalette || isWindowButton) {
            QColor button = option->palette.color(QPalette::Active, QPalette::Button);

            if (isDark) {
                hoverBrush = QBrush(mixColor(button, mix, 0.2));
                clickBrush = QBrush(mixColor(button, mix, 0.05));
            } else {
                hoverBrush = QBrush(mixColor(button, mix, 0.05));
                clickBrush = QBrush(mixColor(button, mix, 0.2));
            }
        }

        if (isImportant) {
            defaultBrush = highlight;
        }
    }

    pushButtonParameters.pushButtonDefaultBrush   = defaultBrush;
    pushButtonParameters.pushButtonClickBrush     = clickBrush;
    pushButtonParameters.pushButtonHoverBrush     = hoverBrush;
    pushButtonParameters.pushButtonDisableBrush   = disableBrush;
    pushButtonParameters.pushButtonDisableOnBrush = disableOnBrush;
}

void KDefaultStyleParameters::initToolButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    toolButtonParameters.radius = 6;

    QBrush defaultBrush;
    QBrush clickBrush;
    QBrush hoverBrush;
    QBrush disableBrush;
    QBrush disableOnBrush;

    QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);
    if (isDark) {
        hoverBrush = QBrush(mixColor(highlight, mix, 0.2));
        clickBrush = QBrush(mixColor(highlight, mix, 0.05));
    } else {
        hoverBrush = QBrush(mixColor(highlight, mix, 0.05));
        clickBrush = QBrush(mixColor(highlight, mix, 0.2));
    }
    defaultBrush = option->palette.brush(QPalette::Active, QPalette::Button);
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disableOnBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    if (qobject_cast<const QToolButton *>(widget)) {
        bool isWindowButton = false;
        bool isWindowColoseButton = false;
        bool useButtonPalette = false;

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

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

        if (isWindowColoseButton) {
            QColor ColoseButton = ColoseButtonColor;

            if (isDark) {
                hoverBrush = QBrush(mixColor(ColoseButton, mix, 0.2));
                clickBrush = QBrush(mixColor(ColoseButton, mix, 0.05));
            } else {
                hoverBrush = QBrush(mixColor(ColoseButton, mix, 0.05));
                clickBrush = QBrush(mixColor(ColoseButton, mix, 0.2));
            }
        } else if (isWindowButton && useTransparentButtonList().contains(qAppName())) {
            if (isDark) {
                mix.setAlphaF(0.28);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.15);
                clickBrush = QBrush(mix);
            } else {
                mix.setAlphaF(0.15);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.28);
                clickBrush = QBrush(mix);
            }
        } else if (useButtonPalette || isWindowButton) {
            QColor button = option->palette.color(QPalette::Active, QPalette::Button);

            if (isDark) {
                hoverBrush = QBrush(mixColor(button, mix, 0.2));
                clickBrush = QBrush(mixColor(button, mix, 0.05));
            } else {
                hoverBrush = QBrush(mixColor(button, mix, 0.05));
                clickBrush = QBrush(mixColor(button, mix, 0.2));
            }
        }
    }

    toolButtonParameters.toolButtonDefaultBrush   = defaultBrush;
    toolButtonParameters.toolButtonClickBrush     = clickBrush;
    toolButtonParameters.toolButtonHoverBrush     = hoverBrush;
    toolButtonParameters.toolButtonDisableBrush   = disableBrush;
    toolButtonParameters.toolButtonDisableOnBrush = disableOnBrush;
}

void KDefaultStyleParameters::initLineEditParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    lineEditParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush focusBrush;
    QBrush disableBrush;

    QPen defaultPen;
    QPen hoverPen;
    QPen focusPen;
    QPen disablePen;

    //default state
    defaultBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    defaultPen = QPen(Qt::NoPen);

    //hover state
    hoverBrush = defaultBrush;
    hoverPen = defaultPen;

    //focus state
    focusBrush = option->palette.brush(QPalette::Active, QPalette::Base);
    focusPen = QPen(option->palette.brush(QPalette::Active, QPalette::Highlight),
                    2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //disable state
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disablePen = QPen(Qt::NoPen);


    lineEditParameters.lineEditDefaultBrush = defaultBrush;
    lineEditParameters.lineEditHoverBrush = hoverBrush;
    lineEditParameters.lineEditFocusBrush = focusBrush;
    lineEditParameters.lineEditDisableBrush = disableBrush;

    lineEditParameters.lineEditDefaultPen = defaultPen;
    lineEditParameters.lineEditHoverPen = hoverPen;
    lineEditParameters.lineEditFocusPen = focusPen;
    lineEditParameters.lineEditDisablePen = disablePen;
}

void KDefaultStyleParameters::initSpinBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    spinBoxParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush focusBrush;
    QBrush disableBrush;

    QPen defaultPen;
    QPen hoverPen;
    QPen focusPen;
    QPen disablePen;

    //default state
    defaultBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    defaultPen = QPen(Qt::NoPen);

    //hover state
    hoverBrush = defaultBrush;
    hoverPen = defaultPen;

    //focus state
    focusBrush = option->palette.brush(QPalette::Active, QPalette::Base);
    focusPen = QPen(option->palette.brush(QPalette::Active, QPalette::Highlight),
                    2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //disable state
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disablePen = QPen(Qt::NoPen);


    spinBoxParameters.spinBoxDefaultBrush = defaultBrush;
    spinBoxParameters.spinBoxHoverBrush = hoverBrush;
    spinBoxParameters.spinBoxFocusBrush = focusBrush;
    spinBoxParameters.spinBoxDisableBrush = disableBrush;

    spinBoxParameters.spinBoxDefaultPen = defaultPen;
    spinBoxParameters.spinBoxHoverPen = hoverPen;
    spinBoxParameters.spinBoxFocusPen = focusPen;
    spinBoxParameters.spinBoxDisablePen = disablePen;
}

void KDefaultStyleParameters::initComboBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    comboBoxParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush onBrush;
    QBrush editBrush;
    QBrush disableBrush;

    QPen defaultPen;
    QPen hoverPen;
    QPen onPen;
    QPen editPen;
    QPen disablePen;

    QColor button = option->palette.color(QPalette::Active, QPalette::Button);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //default state
    defaultBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    defaultPen = QPen(Qt::NoPen);

    //hover state
    if (isDark) {
        hoverBrush = QBrush(mixColor(button, mix, 0.2));
    } else {
        hoverBrush = QBrush(mixColor(button, mix, 0.05));
    }
    hoverPen = QPen(Qt::NoPen);

    //on state
    if (isDark) {
        onBrush = QBrush(mixColor(button, mix, 0.05));
    } else {
        onBrush = QBrush(mixColor(button, mix, 0.2));
    }
    onPen = QPen(Qt::NoPen);

    //focus and on state,edit mode
    editBrush = option->palette.brush(QPalette::Active, QPalette::Base);
    editPen = QPen(option->palette.brush(QPalette::Active, QPalette::Highlight),
                    2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //disable state
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disablePen = QPen(Qt::NoPen);


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

    comboBoxParameters.comboBoxDefaultPen = defaultPen;
    comboBoxParameters.comboBoxHoverPen = hoverPen;
    comboBoxParameters.comboBoxOnPen = onPen;
    comboBoxParameters.comboBoxEditPen = editPen;
    comboBoxParameters.comboBoxDisablePen = disablePen;
}

void KDefaultStyleParameters::initListParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    listParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush selectBrush;
    QBrush disableBrush;


    //default
    defaultBrush = QBrush(Qt::transparent);

    //hover
    hoverBrush = option->palette.brush(QPalette::Disabled, QPalette::Midlight);

    //select
    selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //disable
    disableBrush = QBrush(Qt::transparent);


    listParameters.listDefaultBrush = defaultBrush;
    listParameters.listHoverBrush   = hoverBrush;
    listParameters.listSelectBrush  = selectBrush;
    listParameters.listDisableBrush = disableBrush;
}

void KDefaultStyleParameters::initTreeParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    treeParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush selectBrush;
    QBrush disableBrush;

    QBrush branchDefaultBrush;
    QBrush branchHoverBrush;
    QBrush branchSelectBrush;
    QBrush branchDisableBrush;


    //default
    defaultBrush = QBrush(Qt::transparent);
    branchDefaultBrush = defaultBrush;

    //hover
    hoverBrush = option->palette.brush(QPalette::Disabled, QPalette::Midlight);
    branchHoverBrush = hoverBrush;

    //select
    selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);
    branchSelectBrush = selectBrush;

    //disable
    disableBrush = QBrush(Qt::transparent);
    branchDisableBrush = disableBrush;


    treeParameters.treeDefaultBrush = defaultBrush;
    treeParameters.treeHoverBrush   = hoverBrush;
    treeParameters.treeSelectBrush  = selectBrush;
    treeParameters.treeDisableBrush = disableBrush;

    treeParameters.treeBranchDefaultBrush = branchDefaultBrush;
    treeParameters.treeBranchHoverBrush   =  branchHoverBrush;
    treeParameters.treeBranchSelectBrush  =  branchSelectBrush;
    treeParameters.treeBranchDisableBrush =  branchDisableBrush;
}

void KDefaultStyleParameters::initTableParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    tableParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush selectBrush;
    QBrush disableBrush;


    //default
    defaultBrush = QBrush(Qt::transparent);

    //hover
    hoverBrush = option->palette.brush(QPalette::Disabled, QPalette::Midlight);

    //select
    selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //disable
    disableBrush = QBrush(Qt::transparent);


    tableParameters.tableDefaultBrush = defaultBrush;
    tableParameters.tableHoverBrush   = hoverBrush;
    tableParameters.tableSelectBrush  = selectBrush;
    tableParameters.tableDisableBrush = disableBrush;
}

void KDefaultStyleParameters::initCheckBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    checkBoxParameters.radius = 4;

    QPen defaultPen;
    QPen hoverPen;
    QPen clickPen;
    QPen disablePen;
    QPen onDefaultPen;
    QPen onHoverPen;
    QPen onClickPen;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush clickBrush;
    QBrush disableBrush;
    QBrush onDefaultBrush;
    QBrush onHoverBrush;
    QBrush onClickBrush;

    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //default
    if (isDark) {
        defaultPen = QPen(option->palette.brush(QPalette::Disabled, QPalette::Mid),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    } else {
        defaultPen = QPen(option->palette.brush(QPalette::Disabled, QPalette::HighlightedText),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    }
    defaultBrush = QBrush(option->palette.color(QPalette::Active, QPalette::Base).lighter(200));

    //hover
    hoverPen = defaultPen;
    if (isDark) {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    } else {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.05));
    }

    //click
    clickPen = defaultPen;
    if (isDark) {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.1));
    } else {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    }


    //disable
    disablePen = defaultPen;
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    //on default
    onDefaultPen = QPen(Qt::NoPen);
    onDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //on hover
    onHoverPen = QPen(Qt::NoPen);
    if (isDark) {
        onHoverBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.2));
    } else {
        onHoverBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.05));
    }

    //on click
    onClickPen = QPen(Qt::NoPen);
    if (isDark) {
        onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.05));
    } else {
        onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.2));
    }

    checkBoxParameters.checkBoxDefaultPen = defaultPen;
    checkBoxParameters.checkBoxHoverPen = hoverPen;
    checkBoxParameters.checkBoxClickPen = clickPen;
    checkBoxParameters.checkBoxDisablePen = disablePen;
    checkBoxParameters.checkBoxOnDefaultPen = onDefaultPen;
    checkBoxParameters.checkBoxOnHoverPen = onHoverPen;
    checkBoxParameters.checkBoxOnClickPen = onClickPen;

    checkBoxParameters.checkBoxDefaultBrush = defaultBrush;
    checkBoxParameters.checkBoxHoverBrush = hoverBrush;
    checkBoxParameters.checkBoxClickBrush = clickBrush;
    checkBoxParameters.checkBoxDisableBrush = disableBrush;
    checkBoxParameters.checkBoxOnDefaultBrush = onDefaultBrush;
    checkBoxParameters.checkBoxOnHoverBrush = onHoverBrush;
    checkBoxParameters.checkBoxOnClickBrush = onClickBrush;
}

void KDefaultStyleParameters::initRadioButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    radioButtonParameters.radius = 6;

    QPen defaultPen;
    QPen hoverPen;
    QPen clickPen;
    QPen disablePen;
    QPen onDefaultPen;
    QPen onHoverPen;
    QPen onClickPen;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush clickBrush;
    QBrush disableBrush;
    QBrush onDefaultBrush;
    QBrush onHoverBrush;
    QBrush onClickBrush;

    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //default
    if (isDark) {
        defaultPen = QPen(option->palette.brush(QPalette::Disabled, QPalette::Mid),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    } else {
        defaultPen = QPen(option->palette.brush(QPalette::Disabled, QPalette::HighlightedText),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    }
    defaultBrush = QBrush(option->palette.color(QPalette::Active, QPalette::Base).lighter(200));

    //hover
    hoverPen = defaultPen;
    if (isDark) {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    } else {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.05));
    }

    //click
    clickPen = defaultPen;
    if (isDark) {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.1));
    } else {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    }

    //disable
    disablePen = defaultPen;
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    //on default
    onDefaultPen = QPen(Qt::NoPen);
    onDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //on hover
    onHoverPen = QPen(Qt::NoPen);
    if (isDark) {
        onHoverBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.2));
    } else {
        onHoverBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.05));
    }

    //on click
    onClickPen = QPen(Qt::NoPen);
    if (isDark) {
        onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.05));
    } else {
        onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.2));
    }


    //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("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>();
        }
    }


    radioButtonParameters.radioButtonDefaultPen = defaultPen;
    radioButtonParameters.radioButtonHoverPen = hoverPen;
    radioButtonParameters.radioButtonClickPen = clickPen;
    radioButtonParameters.radioButtonDisablePen = disablePen;
    radioButtonParameters.radioButtonOnDefaultPen = onDefaultPen;
    radioButtonParameters.radioButtonOnHoverPen = onHoverPen;
    radioButtonParameters.radioButtonOnClickPen = onClickPen;

    radioButtonParameters.radioButtonDefaultBrush = defaultBrush;
    radioButtonParameters.radioButtonHoverBrush = hoverBrush;
    radioButtonParameters.radioButtonClickBrush = clickBrush;
    radioButtonParameters.radioButtonDisableBrush = disableBrush;
    radioButtonParameters.radioButtonOnDefaultBrush = onDefaultBrush;
    radioButtonParameters.radioButtonOnHoverBrush = onHoverBrush;
    radioButtonParameters.radioButtonOnClickBrush = onClickBrush;
}

void KDefaultStyleParameters::initSliderParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    QBrush handleDefaultBrush;
    QBrush handleHoverBrush;
    QBrush handleClickBrush;
    QBrush handleDisableBrush;

    QBrush grooveValueDefaultBrush;
    QBrush grooveValueHoverBrush;
    QBrush grooveValueDisableBrush;
    QBrush grooveUnvalueDefaultBrush;
    QBrush grooveUnvalueHoverBrush;
    QBrush grooveUnvalueDisableBrush;

    QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //handle default
    handleDefaultBrush = option->palette.color(QPalette::Active, QPalette::Highlight);

    //handle hover
    if (isDark) {
        handleHoverBrush = QBrush(mixColor(highlight, mix, 0.2));
    } else {
        handleHoverBrush = QBrush(mixColor(highlight, mix, 0.05));
    }

    //handle click
    if (isDark) {
        handleClickBrush = QBrush(mixColor(highlight, mix, 0.05));
    } else {
        handleClickBrush = QBrush(mixColor(highlight, mix, 0.2));
    }

    //handle disable
    handleDisableBrush = option->palette.color(QPalette::Disabled, QPalette::ButtonText);

    //groove value default
    grooveValueDefaultBrush = handleHoverBrush;

    //groove value hover
    grooveValueHoverBrush = handleClickBrush;

    //groove value disable
    grooveValueDisableBrush = handleDisableBrush;

    //groove unvalue default
    grooveUnvalueDefaultBrush = option->palette.color(QPalette::Active, QPalette::Button);

    //groove unvalue hover
    grooveUnvalueHoverBrush = grooveUnvalueDefaultBrush;

    //groove unvalue disable
    grooveUnvalueDisableBrush = grooveUnvalueDefaultBrush;


    sliderParameters.sliderHandleDefaultBrush = handleDefaultBrush;
    sliderParameters.sliderHandleHoverBrush = handleHoverBrush;
    sliderParameters.sliderHandleClickBrush = handleClickBrush;
    sliderParameters.sliderHandleDisableBrush = handleDisableBrush;

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

    sliderParameters.sliderGrooveUnvalueDefaultBrush = grooveUnvalueDefaultBrush;
    sliderParameters.sliderGrooveUnvalueHoverBrush = grooveUnvalueHoverBrush;
    sliderParameters.sliderGrooveUnvalueDisableBrush = grooveUnvalueDisableBrush;
}

void KDefaultStyleParameters::initProgressBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    QBrush contentBrush;
    QBrush grooveDefaultBrush;
    QBrush grooveDisableBrush;

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

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

    //content
    QColor startColor = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor endColor = option->palette.color(QPalette::Active, QPalette::Highlight).lighter(120);
    QLinearGradient linearGradient;
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    if (vertical) {
        if (reverse) {
            linearGradient.setStart(pb->rect.bottomLeft());
            linearGradient.setFinalStop(pb->rect.topLeft());
        } else {
            linearGradient.setStart(pb->rect.topLeft());
            linearGradient.setFinalStop(pb->rect.bottomLeft());
        }
    } else {
        if (reverse) {
            linearGradient.setStart(pb->rect.topRight());
            linearGradient.setFinalStop(pb->rect.topLeft());
        } else {
            linearGradient.setStart(pb->rect.topLeft());
            linearGradient.setFinalStop(pb->rect.topRight());
        }
    }
    contentBrush = QBrush(linearGradient);

    //groove default
    grooveDefaultBrush = pb->palette.brush(QPalette::Active, QPalette::Button);

    //groove disable
    grooveDisableBrush = pb->palette.brush(QPalette::Disabled, QPalette::Button);


    progressBarParameters.radius = 6;
    progressBarParameters.progressBarContentBrush = contentBrush;
    progressBarParameters.progressBarGrooveDefaultBrush = grooveDefaultBrush;
    progressBarParameters.progressBarGrooveDisableBrush = grooveDisableBrush;
}

void KDefaultStyleParameters::initScrollBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int sliderRadius;
    QBrush grooveDefaultBrush;
    QBrush grooveInactiveBrush;
    QBrush sliderDefaultBrush;
    QBrush sliderHoverBrush;
    QBrush sliderClickBrush;
    QBrush sliderDisableBrush;

    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);
    const QStyleOptionSlider *bar = qstyleoption_cast<const QStyleOptionSlider *>(option);

    //radius
    if (bar->orientation == Qt::Horizontal) {
        sliderRadius = (bar->rect.height()) / 4;
    } else {
        sliderRadius = (bar->rect.width()) / 4;
    }

    //groove default
    grooveDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Base);

    //groove inactive
    grooveInactiveBrush = option->palette.brush(QPalette::Inactive, QPalette::Base);

    //slider default
    sliderDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Button);

    //slider hover
    if (isDark) {
        sliderHoverBrush = QBrush(mixColor(sliderDefaultBrush.color(), mix, 0.2));
    } else {
        sliderHoverBrush = QBrush(mixColor(sliderDefaultBrush.color(), mix, 0.05));
    }

    //slider click
    if (isDark) {
        sliderClickBrush = QBrush(mixColor(sliderDefaultBrush.color(), mix, 0.05));
    } else {
        sliderClickBrush = QBrush(mixColor(sliderDefaultBrush.color(), mix, 0.2));
    }

    //slider disable
    sliderDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);


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

void KDefaultStyleParameters::initToolTipParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    QBrush backgroundBrush;

    //background
    backgroundBrush = option->palette.color(QPalette::Active, QPalette::ToolTipBase);


    toolTipParameters.radius = 6;
    toolTipParameters.toolTipBackgroundBrush = backgroundBrush;
}

void KDefaultStyleParameters::initTabWidgetParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int tabradius = 6;
    QBrush widgetBackgroundBrush;
    QBrush tabBarBackgroundBrush;
    QBrush tabBarDefaultBrush;
    QBrush tabBarHoverBrush;
    QBrush tabBarSelectBrush;

    //tab widget background
    widgetBackgroundBrush = option->palette.brush(QPalette::Active, QPalette::Base);

    //tabbar background
    tabBarBackgroundBrush = option->palette.brush(QPalette::Active, QPalette::Window);

    //tabbar default
    tabBarDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Window);

    //tabbar hover
    QColor hover_color = option->palette.color(QPalette::Active, QPalette::Window);
    QColor mix    = option->palette.color(QPalette::Active, QPalette::BrightText);
    tabBarHoverBrush = QBrush(mixColor(hover_color, mix, 0.1));

    //tabbar select
    tabBarSelectBrush = option->palette.brush(QPalette::Active, QPalette::Base);


    if (widget && widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
        tabradius = widget->property("setRadius").value<int>();
    }


    tabWidgetParameters.radius = tabradius;
    tabWidgetParameters.tabWidgetBackgroundBrush = widgetBackgroundBrush;
    tabWidgetParameters.tabBarBackgroundBrush = tabBarBackgroundBrush;
    tabWidgetParameters.tabBarDefaultBrush = tabBarDefaultBrush;
    tabWidgetParameters.tabBarHoverBrush = tabBarHoverBrush;
    tabWidgetParameters.tabBarSelectBrush = tabBarSelectBrush;
}

void KDefaultStyleParameters::initMenuParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

    int frameradius = 8;
    int itemradius = 6;
    QPixmap framePixmap(option->rect.size());
    QBrush itemSelectBrush;


    //frame Pixmap
    framePixmap.fill(Qt::transparent);
    if (qobject_cast<const QFrame*>(widget)) {
        QPainter pixmapPainter(&framePixmap);
        pixmapPainter.setPen(Qt::NoPen);
        pixmapPainter.setBrush(option->palette.color(QPalette::Active, QPalette::Base).lighter(300));
        pixmapPainter.setRenderHint(QPainter::Antialiasing, true);
        pixmapPainter.drawRoundedRect(option->rect, frameradius, frameradius);
    } else {
        int rander = 5;

        // Draw a black floor
        QPainter pixmapPainter(&framePixmap);
        pixmapPainter.setRenderHint(QPainter::Antialiasing, true);
        pixmapPainter.setPen(Qt::transparent);
        pixmapPainter.setBrush(option->palette.color(QPalette::Active, QPalette::BrightText));
        pixmapPainter.drawRoundedRect(option->rect.adjusted(+rander, +rander, -rander, -rander), frameradius, frameradius);
        pixmapPainter.end();

        // Blur the black background
        QImage img = framePixmap.toImage();
        qt_blurImage(img, 4, false, false);

        // Dig out the center part, Shadow rendering
        framePixmap = QPixmap::fromImage(img);
        QPainter pixmapPainter2(&framePixmap);
        pixmapPainter2.setRenderHint(QPainter::Antialiasing);
        pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
        pixmapPainter2.setPen(Qt::transparent);
        pixmapPainter2.setBrush(Qt::transparent);
        pixmapPainter2.drawRoundedRect(option->rect.adjusted(+rander, +rander, -rander, -rander), frameradius, frameradius);
        pixmapPainter2.end();

        //That's when I started drawing the frame floor
        auto color = option->palette.color(QPalette::Base);
        if (UKUIStyleSettings::isSchemaInstalled("org.ukui.style")) {
            auto opacity = UKUIStyleSettings::globalInstance()->get("menuTransparency").toInt()/100.0;
            color.setAlphaF(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);
        }

        QPainterPath path;
        QRegion region;
        if (widget) {
            region = widget->mask();
        }
        if (region.isEmpty()) {
            path.addRoundedRect(option->rect.adjusted(+rander, +rander, -rander,-rander), frameradius, frameradius);
        } else {
            path.addRegion(region);
        }

        //draw blur background
        QPainter pixmapPainter3(&framePixmap);
        pixmapPainter3.setRenderHint(QPainter::Antialiasing);
        pixmapPainter3.setPen(Qt::transparent);
        pixmapPainter3.setBrush(color);
        pixmapPainter3.drawPath(path);
    }

    //item select brush
    itemSelectBrush = QBrush(option->palette.brush(QPalette::Active, QPalette::Highlight));

    menuParameters.frameRadius = frameradius;
    menuParameters.itemRadius = itemradius;
    menuParameters.menuFramePixmap = framePixmap;
    menuParameters.menuItemSelectBrush = itemSelectBrush;
}


//Classical widget theme
KClassicalStyleParameters::KClassicalStyleParameters(QObject *parent, bool isDark) : KAbstractStyleParameters(parent, isDark)
{
    radius = 0;
    CheckBox_Radius = 0;

    initPalette(isDark);
}

void KClassicalStyleParameters::initPalette(bool isDark)
{

    QColor windowText_at(38, 38, 38),
           windowText_iat(38, 38, 38),
           windowText_dis(166, 166, 166),
           button_at(230, 230, 230),
           button_iat(230, 230, 230),
           button_dis(233, 233, 233),
           light_at(255, 255, 255),
           light_iat(255, 255, 255),
           light_dis(242, 242, 242),
           midlight_at(217, 217, 217),
           midlight_iat(217, 217, 217),
           midlight_dis(230, 230, 230),
           dark_at(77, 77, 77),
           dark_iat(77, 77, 77),
           dark_dis(64, 64, 64),
           mid_at(115, 115, 115),
           mid_iat(115, 115, 115),
           mid_dis(102, 102, 102),
           text_at(38, 38, 38),
           text_iat(38, 38, 38),
           text_dis(140, 140, 140),
           brightText_at(89, 89, 89),
           brightText_iat(89, 89, 89),
           brightText_dis(77, 77, 77),
           buttonText_at(38, 38, 38),
           buttonText_iat(38, 38, 38),
           buttonText_dis(179, 179, 179),
           base_at(255, 255, 255),
           base_iat(245, 245, 245),
           base_dis(237, 237, 237),
           window_at(245, 245, 245),
           window_iat(237, 237, 237),
           window_dis(230, 230, 230),
           shadow_at(214, 214, 214),
           shadow_iat(214, 214, 214),
           shadow_dis(201, 201, 201),
           highLight_at(55, 144, 250),
           highLight_iat(55, 144, 250),
           hightight_dis(233, 233, 233),
           highLightText_at(255, 255, 255),
           highLightText_iat(255, 255, 255),
           highLightText_dis(179, 179, 179),
           link_at(55, 144, 250),
           link_iat(55, 144, 250),
           link_dis(55, 144, 250),
           linkVisited_at(114, 46, 209),
           linkVisited_iat(114, 46, 209),
           linkVisited_dis(114, 46, 209),
           alternateBase_at(244, 245, 245),
           noRale_at(240, 240, 240),
           noRole_iat(240, 240, 240),
           noRole_dis(217, 217, 217),
           toolTipBase(255, 255, 255),
           toolTipText(38, 38, 38),
           placeholderText(38, 38, 38);

    if (isDark) {
        windowText_at.setRgb(217, 217, 217);
        windowText_iat.setRgb(217, 217, 217);
        windowText_dis.setRgb(77, 77, 77);
        button_at.setRgb(55, 55, 59);
        button_iat.setRgb(55, 55, 59);
        button_dis.setRgb(46, 46, 48);
        midlight_at.setRgb(77, 77, 77);
        midlight_iat.setRgb(77, 77, 77);
        midlight_dis.setRgb(64, 64, 64);
        dark_at.setRgb(38, 38, 38);
        dark_iat.setRgb(38, 38, 38);
        dark_dis.setRgb(26, 26, 26);
        text_at.setRgb(217, 217, 217);
        text_iat.setRgb(217, 217, 217);
        text_dis.setRgb(77, 77, 77);
        brightText_at.setRgb(255, 255, 255);
        brightText_iat.setRgb(255, 255, 255);
        brightText_dis.setRgb(77, 77, 77);
        buttonText_at.setRgb(217, 217, 217);
        buttonText_iat.setRgb(217, 217, 217);
        buttonText_dis.setRgb(76, 76, 79);
        base_at.setRgb(18, 18, 18);
        base_iat.setRgb(28, 28, 28);
        base_dis.setRgb(36, 36, 36);
        window_at.setRgb(35, 36, 38);
        window_iat.setRgb(26, 26, 26);
        window_dis.setRgb(18, 18, 18);
        hightight_dis.setRgb(46, 46, 48);
        highLightText_dis.setRgb(77, 77, 77);
        alternateBase_at.setRgb(38, 38, 38);
        noRale_at.setRgb(51, 51, 51);
        noRole_iat.setRgb(51, 51, 51);
        noRole_dis.setRgb(60, 60, 64);
        toolTipBase.setRgb(38, 38, 38);
        toolTipText.setRgb(217, 217, 217);
        placeholderText.setRgb(166, 166, 166);
    }

    defaultPalette.setColor(QPalette::Active, QPalette::WindowText, windowText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::WindowText, windowText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::WindowText, windowText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Button, button_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Button, button_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Button, button_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Light, light_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Light, light_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Light, light_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Midlight, midlight_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Midlight, midlight_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Midlight, midlight_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Dark, dark_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Dark, dark_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Dark, dark_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Mid, mid_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Mid, mid_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Mid, mid_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Text, text_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Text, text_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Text, text_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::BrightText, brightText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::BrightText, brightText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::BrightText, brightText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ButtonText, buttonText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ButtonText, buttonText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Base, base_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Base, base_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Base, base_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Window, window_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Window, window_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Window, window_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Shadow, shadow_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Shadow, shadow_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Shadow, shadow_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Highlight, highLight_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Highlight, highLight_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Highlight, hightight_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::HighlightedText, highLightText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Link, link_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Link, link_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Link, link_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::LinkVisited, linkVisited_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, linkVisited_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::LinkVisited, linkVisited_dis);

    defaultPalette.setColor(QPalette::AlternateBase, alternateBase_at);

    defaultPalette.setColor(QPalette::Active, QPalette::NoRole, noRale_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::NoRole, noRole_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::NoRole, noRole_dis);

    defaultPalette.setColor(QPalette::ToolTipBase, toolTipBase);

    defaultPalette.setColor(QPalette::ToolTipText, toolTipText);

#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
    defaultPalette.setColor(QPalette::PlaceholderText, placeholderText);
#endif
}

void KClassicalStyleParameters::initPushButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initToolButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initLineEditParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initSpinBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initComboBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initListParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initTreeParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initTableParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initCheckBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initRadioButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initSliderParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initProgressBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initScrollBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initToolTipParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initTabWidgetParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}

void KClassicalStyleParameters::initMenuParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{

}


//fashion widget theme
KFashionStyleParameters::KFashionStyleParameters(QObject *parent, bool isDark) : KAbstractStyleParameters(parent, isDark)
{
    radius = 6;

    ColoseButtonColor = QColor("#F86458");

    initPalette(isDark);
}

void KFashionStyleParameters::initPalette(bool isDark)
{
    //ukui-light palette UKUI3.1
    QColor windowText_at(38, 38, 38),
           windowText_iat(0, 0, 0, 255 * 0.55),
           windowText_dis(0, 0, 0, 255 * 0.3),
           button_at(230, 230, 230),
           button_iat(230, 230, 230),
           button_dis(233, 233, 233),
           light_at(255, 255, 255),
           light_iat(255, 255, 255),
           light_dis(242, 242, 242),
           midlight_at(218, 218, 218),
           midlight_iat(218, 218, 218),
           midlight_dis(230, 230, 230),
           dark_at(77, 77, 77),
           dark_iat(77, 77, 77),
           dark_dis(64, 64, 64),
           mid_at(115, 115, 115),
           mid_iat(115, 115, 115),
           mid_dis(102, 102, 102),
           text_at(38, 38, 38),
           text_iat(38, 38, 38),
           text_dis(0, 0, 0, 255 * 0.3),
           brightText_at(0, 0, 0),
           brightText_iat(0, 0, 0),
           brightText_dis(0, 0, 0),
           buttonText_at(38, 38, 38),
           buttonText_iat(38, 38, 38),
           buttonText_dis(179, 179, 179),
           base_at(255, 255, 255),
           base_iat(245, 245, 245),
           base_dis(237, 237, 237),
           window_at(245, 245, 245),
           window_iat(237, 237, 237),
           window_dis(230, 230, 230),
           shadow_at(0, 0, 0, 255 * 0.16),
           shadow_iat(0, 0, 0, 255 * 0.16),
           shadow_dis(0, 0, 0, 255 * 0.21),
//           shadow_at(214, 214, 214),
//           shadow_iat(214, 214, 214),
//           shadow_dis(201, 201, 201),
           highLight_at(55, 144, 250),
           highLight_iat(55, 144, 250),
           highLight_dis(233, 233, 233),
           highLightText_at(255, 255, 255),
           highLightText_iat(255, 255, 255),
           highLightText_dis(179, 179, 179),
           link_at(55, 144, 250),
           link_iat(55, 144, 250),
           link_dis(55, 144, 250),
           linkVisited_at(114, 46, 209),
           linkVisited_iat(114, 46, 209),
           linkVisited_dis(114, 46, 209),
           alternateBase_at(245, 245, 245),
           alternateBase_iat(245, 245, 245),
           alternateBase_dis(245, 245, 245),
           noRale_at(240, 240, 240),
           noRole_iat(240, 240, 240),
           noRole_dis(217, 217, 217),
           toolTipBase_at(255, 255, 255),
           toolTipBase_iat(255, 255, 255),
           toolTipBase_dis(255, 255, 255),
           toolTipText_at(38, 38, 38),
           toolTipText_iat(38, 38, 38),
           toolTipText_dis(38, 38, 38),
           placeholderText_at(0, 0, 0, 255 * 0.35),
           placeholderText_iat(0, 0, 0, 255 * 0.35),
           placeholderText_dis(0, 0, 0, 255 * 0.3);

    //ukui-dark
    if (isDark) {
        windowText_at.setRgb(217, 217, 217);
        windowText_iat.setRgb(255, 255, 255, 255 * 0.55);
        windowText_dis.setRgb(255, 255, 255, 255 * 0.3);
        button_at.setRgb(55, 55, 59);
        button_iat.setRgb(55, 55, 59);
        button_dis.setRgb(46, 46, 48);
        light_at.setRgb(255, 255, 255),
        light_iat.setRgb(255, 255, 255),
        light_dis.setRgb(242, 242, 242),
        midlight_at.setRgb(95, 95, 98);
        midlight_iat.setRgb(95, 95, 98);
        midlight_dis.setRgb(79, 79, 82);
        dark_at.setRgb(38, 38, 38);
        dark_iat.setRgb(38, 38, 38);
        dark_dis.setRgb(26, 26, 26);
        mid_at.setRgb(115, 115, 115);
        mid_iat.setRgb(115, 115, 115);
        mid_dis.setRgb(102, 102, 102);
        text_at.setRgb(217, 217, 217);
        text_iat.setRgb(217, 217, 217);
        text_dis.setRgb(255, 255, 255, 255 * 0.3);
        brightText_at.setRgb(255, 255, 255);
        brightText_iat.setRgb(255, 255, 255);
        brightText_dis.setRgb(255, 255, 255);
        buttonText_at.setRgb(217, 217, 217);
        buttonText_iat.setRgb(217, 217, 217);
        buttonText_dis.setRgb(76, 76, 79);
        base_at.setRgb(29, 29, 29);
        base_iat.setRgb(28, 28, 28);
        base_dis.setRgb(36, 36, 36);
        window_at.setRgb(35, 36, 38);
        window_iat.setRgb(26, 26, 26);
        window_dis.setRgb(18, 18, 18);
        shadow_at.setRgb(0, 0, 0, 255 * 0.16),
        shadow_iat.setRgb(0, 0, 0, 255 * 0.16),
        shadow_dis.setRgb(0, 0, 0, 255 * 0.21),
//        shadow_at.setRgb(214, 214, 214);
//        shadow_iat.setRgb(214, 214, 214);
//        shadow_dis.setRgb(201, 201, 201);
        highLight_at.setRgb(55, 144, 250);
        highLight_iat.setRgb(55, 144, 250);
        highLight_dis.setRgb(46, 46, 46);
        highLightText_at.setRgb(255, 255, 255);
        highLightText_iat.setRgb(255, 255, 255);
        highLightText_dis.setRgb(77, 77, 77);
        link_at.setRgb(55, 144, 250);
        link_iat.setRgb(55, 144, 250);
        link_dis.setRgb(55, 144, 250);
        linkVisited_at.setRgb(114, 46, 209);
        linkVisited_iat.setRgb(114, 46, 209);
        linkVisited_dis.setRgb(114, 46, 209);
        alternateBase_at.setRgb(38, 38, 38);
        alternateBase_iat.setRgb(38, 38, 38);
        alternateBase_dis.setRgb(38, 38, 38);
        noRale_at.setRgb(51, 51, 51);
        noRole_iat.setRgb(51, 51, 51);
        noRole_dis.setRgb(60, 60, 60);
        toolTipBase_at.setRgb(38, 38, 38);
        toolTipBase_iat.setRgb(38, 38, 38);
        toolTipBase_dis.setRgb(38, 38, 38);
        toolTipText_at.setRgb(217, 217, 217);
        toolTipText_iat.setRgb(217, 217, 217);
        toolTipText_dis.setRgb(217, 217, 217);
        placeholderText_at.setRgb(255, 255, 255, 255 * 0.35);
        placeholderText_iat.setRgb(255, 255, 255, 255 * 0.35);
        placeholderText_dis.setRgb(255, 255, 255, 255 * 0.3);
    }

    defaultPalette.setColor(QPalette::Active, QPalette::WindowText, windowText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::WindowText, windowText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::WindowText, windowText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Button, button_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Button, button_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Button, button_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Light, light_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Light, light_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Light, light_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Midlight, midlight_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Midlight, midlight_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Midlight, midlight_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Dark, dark_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Dark, dark_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Dark, dark_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Mid, mid_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Mid, mid_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Mid, mid_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Text, text_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Text, text_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Text, text_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::BrightText, brightText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::BrightText, brightText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::BrightText, brightText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ButtonText, buttonText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ButtonText, buttonText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ButtonText, buttonText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Base, base_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Base, base_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Base, base_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Window, window_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Window, window_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Window, window_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Shadow, shadow_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Shadow, shadow_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Shadow, shadow_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Highlight, highLight_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Highlight, highLight_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Highlight, highLight_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::HighlightedText, highLightText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::HighlightedText, highLightText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::HighlightedText, highLightText_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::Link, link_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::Link, link_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::Link, link_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::LinkVisited, linkVisited_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::LinkVisited, linkVisited_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::LinkVisited, linkVisited_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::AlternateBase, alternateBase_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::AlternateBase, alternateBase_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::AlternateBase, alternateBase_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::NoRole, noRale_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::NoRole, noRole_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::NoRole, noRole_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ToolTipBase, toolTipBase_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipBase, toolTipBase_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipBase, toolTipBase_dis);

    defaultPalette.setColor(QPalette::Active, QPalette::ToolTipText, toolTipText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::ToolTipText, toolTipText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::ToolTipText, toolTipText_dis);

#if (QT_VERSION >= QT_VERSION_CHECK(5,12,0))
    defaultPalette.setColor(QPalette::Active, QPalette::PlaceholderText, placeholderText_at);
    defaultPalette.setColor(QPalette::Inactive, QPalette::PlaceholderText, placeholderText_iat);
    defaultPalette.setColor(QPalette::Disabled, QPalette::PlaceholderText, placeholderText_dis);
#endif
}

void KFashionStyleParameters::initPushButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    pushButtonParameters.radius = 6;

    QBrush defaultBrush;
    QBrush clickBrush;
    QBrush hoverBrush;
    QBrush disableBrush;
    QBrush disableOnBrush;

    QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;

    //hover
    linearGradient.setStart(option->rect.topLeft());
    linearGradient.setFinalStop(option->rect.bottomLeft());
    if (isDark) {
        startColor = mixColor(highlight, QColor(Qt::white), 0.2);
        endColor = mixColor(highlight, QColor(Qt::black), 0.05);
    } else {
        startColor = mixColor(highlight, QColor(Qt::white), 0.05);
        endColor = mixColor(highlight, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    hoverBrush = QBrush(linearGradient);

    clickBrush = QBrush(mixColor(highlight, mix, 0.1));
    defaultBrush = option->palette.brush(QPalette::Active, QPalette::Button);
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disableOnBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    if (qobject_cast<const QPushButton *>(widget)) {
        bool isWindowButton = false;
        bool isWindowColoseButton = false;
        bool isImportant = false;
        bool useButtonPalette = false;

        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 (isWindowColoseButton) {
            QColor ColoseButton = ColoseButtonColor;

            //hover
            if (isDark) {
                startColor = mixColor(ColoseButton, QColor(Qt::white), 0.2);
                endColor = mixColor(ColoseButton, QColor(Qt::black), 0.05);
            } else {
                startColor = mixColor(ColoseButton, QColor(Qt::white), 0.05);
                endColor = mixColor(ColoseButton, QColor(Qt::black), 0.2);
            }
            linearGradient.setColorAt(0, startColor);
            linearGradient.setColorAt(1, endColor);
            hoverBrush = QBrush(linearGradient);

            //click
            clickBrush = QBrush(mixColor(ColoseButton, mix, 0.1));
        } else if (isWindowButton && useTransparentButtonList().contains(qAppName())) {
            if (isDark) {
                mix.setAlphaF(0.28);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.15);
                clickBrush = QBrush(mix);
            } else {
                mix.setAlphaF(0.15);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.28);
                clickBrush = QBrush(mix);
            }
        } else if (useButtonPalette || isWindowButton) {
            QColor button = option->palette.color(QPalette::Active, QPalette::Button);

            //hover
            if (isDark) {
                startColor = mixColor(button, QColor(Qt::white), 0.2);
                endColor = mixColor(button, QColor(Qt::white), 0.05);
            } else {
                startColor = mixColor(button, QColor(Qt::black), 0.05);
                endColor = mixColor(button, QColor(Qt::black), 0.2);
            }
            linearGradient.setColorAt(0, startColor);
            linearGradient.setColorAt(1, endColor);
            hoverBrush = QBrush(linearGradient);

            //click
            clickBrush = QBrush(mixColor(button, mix, 0.2));
        }

        if (isImportant) {
            defaultBrush = highlight;
        }
    }

    pushButtonParameters.pushButtonDefaultBrush   = defaultBrush;
    pushButtonParameters.pushButtonClickBrush     = clickBrush;
    pushButtonParameters.pushButtonHoverBrush     = hoverBrush;
    pushButtonParameters.pushButtonDisableBrush   = disableBrush;
    pushButtonParameters.pushButtonDisableOnBrush = disableOnBrush;
}

void KFashionStyleParameters::initToolButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    toolButtonParameters.radius = 6;

    QBrush defaultBrush;
    QBrush clickBrush;
    QBrush hoverBrush;
    QBrush disableBrush;
    QBrush disableOnBrush;

    QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;

    //hover
    linearGradient.setStart(option->rect.topLeft());
    linearGradient.setFinalStop(option->rect.bottomLeft());
    if (isDark) {
        startColor = mixColor(highlight, QColor(Qt::white), 0.2);
        endColor = mixColor(highlight, QColor(Qt::black), 0.05);
    } else {
        startColor = mixColor(highlight, QColor(Qt::white), 0.05);
        endColor = mixColor(highlight, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    hoverBrush = QBrush(linearGradient);

    clickBrush = QBrush(mixColor(highlight, mix, 0.1));
    defaultBrush = option->palette.brush(QPalette::Active, QPalette::Button);
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disableOnBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    if (qobject_cast<const QToolButton *>(widget)) {
        bool isWindowButton = false;
        bool isWindowColoseButton = false;
        bool useButtonPalette = false;

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

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

        if (isWindowColoseButton) {
            QColor ColoseButton = ColoseButtonColor;

            //hover
            if (isDark) {
                startColor = mixColor(ColoseButton, QColor(Qt::white), 0.2);
                endColor = mixColor(ColoseButton, QColor(Qt::black), 0.05);
            } else {
                startColor = mixColor(ColoseButton, QColor(Qt::white), 0.05);
                endColor = mixColor(ColoseButton, QColor(Qt::black), 0.02);
            }
            linearGradient.setColorAt(0, startColor);
            linearGradient.setColorAt(1, endColor);
            hoverBrush = QBrush(linearGradient);

            //click
            clickBrush = QBrush(mixColor(ColoseButton, mix, 0.1));
        } else if (isWindowButton && useTransparentButtonList().contains(qAppName())) {
            if (isDark) {
                mix.setAlphaF(0.28);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.15);
                clickBrush = QBrush(mix);
            } else {
                mix.setAlphaF(0.15);
                hoverBrush = QBrush(mix);
                mix.setAlphaF(0.28);
                clickBrush = QBrush(mix);
            }
        } else if (useButtonPalette || isWindowButton) {
            QColor button = option->palette.color(QPalette::Active, QPalette::Button);

            //hover
            if (isDark) {
                startColor = mixColor(button, QColor(Qt::white), 0.2);
                endColor = mixColor(button, QColor(Qt::white), 0.05);
            } else {
                startColor = mixColor(button, QColor(Qt::black), 0.05);
                endColor = mixColor(button, QColor(Qt::black), 0.2);
            }
            linearGradient.setColorAt(0, startColor);
            linearGradient.setColorAt(1, endColor);
            hoverBrush = QBrush(linearGradient);

            //click
            clickBrush = QBrush(mixColor(button, mix, 0.2));
        }
    }

    toolButtonParameters.toolButtonDefaultBrush   = defaultBrush;
    toolButtonParameters.toolButtonClickBrush     = clickBrush;
    toolButtonParameters.toolButtonHoverBrush     = hoverBrush;
    toolButtonParameters.toolButtonDisableBrush   = disableBrush;
    toolButtonParameters.toolButtonDisableOnBrush = disableOnBrush;
}

void KFashionStyleParameters::initLineEditParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    lineEditParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush focusBrush;
    QBrush disableBrush;

    QPen defaultPen;
    QPen hoverPen;
    QPen focusPen;
    QPen disablePen;

    //default state
    defaultBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    defaultPen = QPen(Qt::NoPen);

    //hover state
    hoverBrush = defaultBrush;
    hoverPen = defaultPen;

    //focus state
    focusBrush = option->palette.brush(QPalette::Active, QPalette::Base);
    focusPen = QPen(option->palette.brush(QPalette::Active, QPalette::Highlight),
                    1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //disable state
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disablePen = QPen(Qt::NoPen);


    lineEditParameters.lineEditDefaultBrush = defaultBrush;
    lineEditParameters.lineEditHoverBrush = hoverBrush;
    lineEditParameters.lineEditFocusBrush = focusBrush;
    lineEditParameters.lineEditDisableBrush = disableBrush;

    lineEditParameters.lineEditDefaultPen = defaultPen;
    lineEditParameters.lineEditHoverPen = hoverPen;
    lineEditParameters.lineEditFocusPen = focusPen;
    lineEditParameters.lineEditDisablePen = disablePen;
}

void KFashionStyleParameters::initSpinBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    spinBoxParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush focusBrush;
    QBrush disableBrush;

    QPen defaultPen;
    QPen hoverPen;
    QPen focusPen;
    QPen disablePen;

    //default state
    defaultBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    defaultPen = QPen(Qt::NoPen);

    //hover state
    hoverBrush = defaultBrush;
    hoverPen = defaultPen;

    //focus state
    focusBrush = option->palette.brush(QPalette::Active, QPalette::Base);
    focusPen = QPen(option->palette.brush(QPalette::Active, QPalette::Highlight),
                    1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //disable state
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disablePen = QPen(Qt::NoPen);


    spinBoxParameters.spinBoxDefaultBrush = defaultBrush;
    spinBoxParameters.spinBoxHoverBrush = hoverBrush;
    spinBoxParameters.spinBoxFocusBrush = focusBrush;
    spinBoxParameters.spinBoxDisableBrush = disableBrush;

    spinBoxParameters.spinBoxDefaultPen = defaultPen;
    spinBoxParameters.spinBoxHoverPen = hoverPen;
    spinBoxParameters.spinBoxFocusPen = focusPen;
    spinBoxParameters.spinBoxDisablePen = disablePen;
}

void KFashionStyleParameters::initComboBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    comboBoxParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush onBrush;
    QBrush editBrush;
    QBrush disableBrush;

    QPen defaultPen;
    QPen hoverPen;
    QPen onPen;
    QPen editPen;
    QPen disablePen;

    QColor button = option->palette.color(QPalette::Active, QPalette::Button);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //default state
    defaultBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    defaultPen = QPen(Qt::NoPen);

    //hover state
    if (isDark) {
        hoverBrush = QBrush(mixColor(button, mix, 0.2));
    } else {
        hoverBrush = QBrush(mixColor(button, mix, 0.05));
    }
    hoverPen = QPen(Qt::NoPen);

    //on state
    if (isDark) {
        onBrush = QBrush(mixColor(button, mix, 0.05));
    } else {
        onBrush = QBrush(mixColor(button, mix, 0.2));
    }
    onPen = QPen(Qt::NoPen);

    //focus and on state,edit mode
    editBrush = option->palette.brush(QPalette::Active, QPalette::Base);
    editPen = QPen(option->palette.brush(QPalette::Active, QPalette::Highlight),
                    1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);

    //disable state
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);
    disablePen = QPen(Qt::NoPen);


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

    comboBoxParameters.comboBoxDefaultPen = defaultPen;
    comboBoxParameters.comboBoxHoverPen = hoverPen;
    comboBoxParameters.comboBoxOnPen = onPen;
    comboBoxParameters.comboBoxEditPen = editPen;
    comboBoxParameters.comboBoxDisablePen = disablePen;
}

void KFashionStyleParameters::initListParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    listParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush selectBrush;
    QBrush disableBrush;


    //default
    defaultBrush = QBrush(Qt::transparent);

    //hover
    QColor button = option->palette.color(QPalette::Active, QPalette::Button);
    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;
    linearGradient.setStart(option->rect.topLeft());
    linearGradient.setFinalStop(option->rect.bottomLeft());
    if (isDark) {
        startColor = mixColor(button, QColor(Qt::white), 0.2);
        endColor = mixColor(button, QColor(Qt::white), 0.05);
    } else {
        startColor = mixColor(button, QColor(Qt::black), 0.05);
        endColor = mixColor(button, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    hoverBrush = QBrush(linearGradient);

    //select
    selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //disable
    disableBrush = QBrush(Qt::transparent);


    listParameters.listDefaultBrush = defaultBrush;
    listParameters.listHoverBrush   = hoverBrush;
    listParameters.listSelectBrush  = selectBrush;
    listParameters.listDisableBrush = disableBrush;
}

void KFashionStyleParameters::initTreeParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    treeParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush selectBrush;
    QBrush disableBrush;

    QBrush branchDefaultBrush;
    QBrush branchHoverBrush;
    QBrush branchSelectBrush;
    QBrush branchDisableBrush;


    //default
    defaultBrush = QBrush(Qt::transparent);
    branchDefaultBrush = defaultBrush;

    //hover
    QColor button = option->palette.color(QPalette::Active, QPalette::Button);
    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;
    linearGradient.setStart(option->rect.topLeft());
    linearGradient.setFinalStop(option->rect.bottomLeft());
    if (isDark) {
        startColor = mixColor(button, QColor(Qt::white), 0.2);
        endColor = mixColor(button, QColor(Qt::white), 0.05);
    } else {
        startColor = mixColor(button, QColor(Qt::black), 0.05);
        endColor = mixColor(button, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    hoverBrush = QBrush(linearGradient);
    branchHoverBrush = hoverBrush;

    //select
    selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);
    branchSelectBrush = selectBrush;

    //disable
    disableBrush = QBrush(Qt::transparent);
    branchDisableBrush = disableBrush;


    treeParameters.treeDefaultBrush = defaultBrush;
    treeParameters.treeHoverBrush   = hoverBrush;
    treeParameters.treeSelectBrush  = selectBrush;
    treeParameters.treeDisableBrush = disableBrush;

    treeParameters.treeBranchDefaultBrush = branchDefaultBrush;
    treeParameters.treeBranchHoverBrush   =  branchHoverBrush;
    treeParameters.treeBranchSelectBrush  =  branchSelectBrush;
    treeParameters.treeBranchDisableBrush =  branchDisableBrush;
}

void KFashionStyleParameters::initTableParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    tableParameters.radius = 6;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush selectBrush;
    QBrush disableBrush;


    //default
    defaultBrush = QBrush(Qt::transparent);

    //hover
    QColor button = option->palette.color(QPalette::Active, QPalette::Button);
    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;
    linearGradient.setStart(option->rect.topLeft());
    linearGradient.setFinalStop(option->rect.bottomLeft());
    if (isDark) {
        startColor = mixColor(button, QColor(Qt::white), 0.2);
        endColor = mixColor(button, QColor(Qt::white), 0.05);
    } else {
        startColor = mixColor(button, QColor(Qt::black), 0.05);
        endColor = mixColor(button, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    hoverBrush = QBrush(linearGradient);

    //select
    selectBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //disable
    disableBrush = QBrush(Qt::transparent);


    tableParameters.tableDefaultBrush = defaultBrush;
    tableParameters.tableHoverBrush   = hoverBrush;
    tableParameters.tableSelectBrush  = selectBrush;
    tableParameters.tableDisableBrush = disableBrush;
}

void KFashionStyleParameters::initCheckBoxParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    checkBoxParameters.radius = 4;

    QPen defaultPen;
    QPen hoverPen;
    QPen clickPen;
    QPen disablePen;
    QPen onDefaultPen;
    QPen onHoverPen;
    QPen onClickPen;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush clickBrush;
    QBrush disableBrush;
    QBrush onDefaultBrush;
    QBrush onHoverBrush;
    QBrush onClickBrush;

    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //default
    if (isDark) {
        defaultPen = QPen(option->palette.brush(QPalette::Active, QPalette::ButtonText),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    } else {
        defaultPen = QPen(option->palette.brush(QPalette::Disabled, QPalette::ButtonText),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    }
    defaultBrush = QBrush(option->palette.color(QPalette::Active, QPalette::Base).lighter(200));

    //hover
    hoverPen = defaultPen;
    if (isDark) {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    } else {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.05));
    }

    //click
    clickPen = defaultPen;
    if (isDark) {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.1));
    } else {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    }


    //disable
    disablePen = defaultPen;
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    //on default
    onDefaultPen = QPen(Qt::NoPen);
    onDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //on hover
    onHoverPen = QPen(Qt::NoPen);
    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;
    linearGradient.setStart(option->rect.topLeft());
    linearGradient.setFinalStop(option->rect.bottomLeft());
    if (isDark) {
        startColor = mixColor(onDefaultBrush.color(), QColor(Qt::white), 0.2);
        endColor = mixColor(onDefaultBrush.color(), QColor(Qt::black), 0.05);
    } else {
        startColor = mixColor(onDefaultBrush.color(), QColor(Qt::white), 0.05);
        endColor = mixColor(onDefaultBrush.color(), QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    onHoverBrush = QBrush(linearGradient);

    //on click
    onClickPen = QPen(Qt::NoPen);
    onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.1));

    checkBoxParameters.checkBoxDefaultPen = defaultPen;
    checkBoxParameters.checkBoxHoverPen = hoverPen;
    checkBoxParameters.checkBoxClickPen = clickPen;
    checkBoxParameters.checkBoxDisablePen = disablePen;
    checkBoxParameters.checkBoxOnDefaultPen = onDefaultPen;
    checkBoxParameters.checkBoxOnHoverPen = onHoverPen;
    checkBoxParameters.checkBoxOnClickPen = onClickPen;

    checkBoxParameters.checkBoxDefaultBrush = defaultBrush;
    checkBoxParameters.checkBoxHoverBrush = hoverBrush;
    checkBoxParameters.checkBoxClickBrush = clickBrush;
    checkBoxParameters.checkBoxDisableBrush = disableBrush;
    checkBoxParameters.checkBoxOnDefaultBrush = onDefaultBrush;
    checkBoxParameters.checkBoxOnHoverBrush = onHoverBrush;
    checkBoxParameters.checkBoxOnClickBrush = onClickBrush;
}

void KFashionStyleParameters::initRadioButtonParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    radioButtonParameters.radius = 6;

    QPen defaultPen;
    QPen hoverPen;
    QPen clickPen;
    QPen disablePen;
    QPen onDefaultPen;
    QPen onHoverPen;
    QPen onClickPen;

    QBrush defaultBrush;
    QBrush hoverBrush;
    QBrush clickBrush;
    QBrush disableBrush;
    QBrush onDefaultBrush;
    QBrush onHoverBrush;
    QBrush onClickBrush;

    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //default
    if (isDark) {
        defaultPen = QPen(option->palette.brush(QPalette::Active, QPalette::ButtonText),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    } else {
        defaultPen = QPen(option->palette.brush(QPalette::Disabled, QPalette::ButtonText),
                          1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
    }
    defaultBrush = QBrush(option->palette.color(QPalette::Active, QPalette::Base).lighter(200));

    //hover
    hoverPen = defaultPen;
    if (isDark) {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    } else {
        hoverBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.05));
    }

    //click
    clickPen = defaultPen;
    if (isDark) {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.1));
    } else {
        clickBrush = QBrush(mixColor(defaultBrush.color(), mix, 0.15));
    }

    //disable
    disablePen = defaultPen;
    disableBrush = option->palette.brush(QPalette::Disabled, QPalette::NoRole);

    //on default
    onDefaultPen = QPen(Qt::NoPen);
    onDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Highlight);

    //on hover
    onHoverPen = QPen(Qt::NoPen);
    if (isDark) {
        onHoverBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.2));
    } else {
        onHoverBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.05));
    }

    //on click
    onClickPen = QPen(Qt::NoPen);
    if (isDark) {
        onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.05));
    } else {
        onClickBrush = QBrush(mixColor(onDefaultBrush.color(), mix, 0.2));
    }


    //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("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>();
        }
    }


    radioButtonParameters.radioButtonDefaultPen = defaultPen;
    radioButtonParameters.radioButtonHoverPen = hoverPen;
    radioButtonParameters.radioButtonClickPen = clickPen;
    radioButtonParameters.radioButtonDisablePen = disablePen;
    radioButtonParameters.radioButtonOnDefaultPen = onDefaultPen;
    radioButtonParameters.radioButtonOnHoverPen = onHoverPen;
    radioButtonParameters.radioButtonOnClickPen = onClickPen;

    radioButtonParameters.radioButtonDefaultBrush = defaultBrush;
    radioButtonParameters.radioButtonHoverBrush = hoverBrush;
    radioButtonParameters.radioButtonClickBrush = clickBrush;
    radioButtonParameters.radioButtonDisableBrush = disableBrush;
    radioButtonParameters.radioButtonOnDefaultBrush = onDefaultBrush;
    radioButtonParameters.radioButtonOnHoverBrush = onHoverBrush;
    radioButtonParameters.radioButtonOnClickBrush = onClickBrush;
}

void KFashionStyleParameters::initSliderParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    QBrush handleDefaultBrush;
    QBrush handleHoverBrush;
    QBrush handleClickBrush;
    QBrush handleDisableBrush;

    QBrush grooveValueDefaultBrush;
    QBrush grooveValueHoverBrush;
    QBrush grooveValueDisableBrush;
    QBrush grooveUnvalueDefaultBrush;
    QBrush grooveUnvalueHoverBrush;
    QBrush grooveUnvalueDisableBrush;

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

    QColor highlight = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

    //handle default
    handleDefaultBrush = option->palette.color(QPalette::Active, QPalette::Highlight);

    //handle hover
    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;
    if (slider->orientation == Qt::Vertical) {
        linearGradient.setStart(option->rect.topLeft());
        linearGradient.setFinalStop(option->rect.topRight());
    } else {
        linearGradient.setStart(option->rect.topLeft());
        linearGradient.setFinalStop(option->rect.bottomLeft());
    }

    if (isDark) {
        startColor = mixColor(highlight, QColor(Qt::white), 0.2);
        endColor = mixColor(highlight, QColor(Qt::black), 0.05);
    } else {
        startColor = mixColor(highlight, QColor(Qt::white), 0.05);
        endColor = mixColor(highlight, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    handleHoverBrush = QBrush(linearGradient);

    //handle click
    handleClickBrush = QBrush(mixColor(highlight, mix, 0.1));

    //handle disable
    handleDisableBrush = option->palette.color(QPalette::Disabled, QPalette::ButtonText);

    //groove value default
    grooveValueDefaultBrush = handleHoverBrush;

    //groove value hover
    grooveValueHoverBrush = handleClickBrush;

    //groove value disable
    grooveValueDisableBrush = handleDisableBrush;

    //groove unvalue default
    grooveUnvalueDefaultBrush = option->palette.color(QPalette::Active, QPalette::Button);

    //groove unvalue hover
    grooveUnvalueHoverBrush = grooveUnvalueDefaultBrush;

    //groove unvalue disable
    grooveUnvalueDisableBrush = grooveUnvalueDefaultBrush;


    sliderParameters.sliderHandleDefaultBrush = handleDefaultBrush;
    sliderParameters.sliderHandleHoverBrush = handleHoverBrush;
    sliderParameters.sliderHandleClickBrush = handleClickBrush;
    sliderParameters.sliderHandleDisableBrush = handleDisableBrush;

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

    sliderParameters.sliderGrooveUnvalueDefaultBrush = grooveUnvalueDefaultBrush;
    sliderParameters.sliderGrooveUnvalueHoverBrush = grooveUnvalueHoverBrush;
    sliderParameters.sliderGrooveUnvalueDisableBrush = grooveUnvalueDisableBrush;
}

void KFashionStyleParameters::initProgressBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    QBrush contentBrush;
    QBrush grooveDefaultBrush;
    QBrush grooveDisableBrush;

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

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

    //content
    QColor startColor = option->palette.color(QPalette::Active, QPalette::Highlight);
    QColor endColor = option->palette.color(QPalette::Active, QPalette::Highlight).lighter(120);
    QLinearGradient linearGradient;
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    if (vertical) {
        if (reverse) {
            linearGradient.setStart(pb->rect.bottomLeft());
            linearGradient.setFinalStop(pb->rect.topLeft());
        } else {
            linearGradient.setStart(pb->rect.topLeft());
            linearGradient.setFinalStop(pb->rect.bottomLeft());
        }
    } else {
        if (reverse) {
            linearGradient.setStart(pb->rect.topRight());
            linearGradient.setFinalStop(pb->rect.topLeft());
        } else {
            linearGradient.setStart(pb->rect.topLeft());
            linearGradient.setFinalStop(pb->rect.topRight());
        }
    }
    contentBrush = QBrush(linearGradient);

    //groove default
    grooveDefaultBrush = pb->palette.brush(QPalette::Active, QPalette::Button);

    //groove disable
    grooveDisableBrush = pb->palette.brush(QPalette::Disabled, QPalette::Button);


    progressBarParameters.radius = 6;
    progressBarParameters.progressBarContentBrush = contentBrush;
    progressBarParameters.progressBarGrooveDefaultBrush = grooveDefaultBrush;
    progressBarParameters.progressBarGrooveDisableBrush = grooveDisableBrush;
}

void KFashionStyleParameters::initScrollBarParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int sliderRadius;
    QBrush grooveDefaultBrush;
    QBrush grooveInactiveBrush;
    QBrush sliderDefaultBrush;
    QBrush sliderHoverBrush;
    QBrush sliderClickBrush;
    QBrush sliderDisableBrush;

    QColor mix = option->palette.color(QPalette::Active, QPalette::BrightText);

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

    //radius
    if (bar->orientation == Qt::Horizontal) {
        sliderRadius = (bar->rect.height()) / 4;
    } else {
        sliderRadius = (bar->rect.width()) / 4;
    }

    //groove default
    grooveDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Base);

    //groove inactive
    grooveInactiveBrush = option->palette.brush(QPalette::Inactive, QPalette::Base);

    //slider default
    sliderDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Button);

    //slider hover
    QColor startColor;
    QColor endColor;
    QLinearGradient linearGradient;
    if (bar->orientation == Qt::Horizontal) {
        linearGradient.setStart(option->rect.topLeft());
        linearGradient.setFinalStop(option->rect.bottomLeft());
    } else {
        linearGradient.setStart(option->rect.topLeft());
        linearGradient.setFinalStop(option->rect.topRight());
    }
    QColor color = option->palette.color(QPalette::Active, QPalette::Button);
    if (isDark) {
        startColor = mixColor(color, QColor(Qt::white), 0.2);
        endColor = mixColor(color, QColor(Qt::white), 0.05);
    } else {
        startColor = mixColor(color, QColor(Qt::black), 0.05);
        endColor = mixColor(color, QColor(Qt::black), 0.2);
    }
    linearGradient.setColorAt(0, startColor);
    linearGradient.setColorAt(1, endColor);
    sliderHoverBrush = QBrush(linearGradient);

    //slider click
    sliderClickBrush = QBrush(mixColor(sliderDefaultBrush.color(), mix, 0.2));

    //slider disable
    sliderDisableBrush = option->palette.brush(QPalette::Disabled, QPalette::Button);


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

void KFashionStyleParameters::initToolTipParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    QBrush backgroundBrush;

    //background
    backgroundBrush = option->palette.color(QPalette::Active, QPalette::ToolTipBase);


    toolTipParameters.radius = 6;
    toolTipParameters.toolTipBackgroundBrush = backgroundBrush;
}

void KFashionStyleParameters::initTabWidgetParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int tabradius = 6;
    QBrush widgetBackgroundBrush;
    QBrush tabBarBackgroundBrush;
    QBrush tabBarDefaultBrush;
    QBrush tabBarHoverBrush;
    QBrush tabBarSelectBrush;

    //tab widget background
    widgetBackgroundBrush = option->palette.brush(QPalette::Active, QPalette::Base);

    //tabbar background
    tabBarBackgroundBrush = option->palette.brush(QPalette::Active, QPalette::Window);

    //tabbar default
    tabBarDefaultBrush = option->palette.brush(QPalette::Active, QPalette::Window);

    //tabbar hover
    QColor hover_color = option->palette.color(QPalette::Active, QPalette::Window);
    QColor mix    = option->palette.color(QPalette::Active, QPalette::BrightText);
    tabBarHoverBrush = QBrush(mixColor(hover_color, mix, 0.1));

    //tabbar select
    tabBarSelectBrush = option->palette.brush(QPalette::Active, QPalette::Base);


    if (widget && widget->property("setRadius").isValid() && widget->property("setRadius").canConvert<int>()) {
        tabradius = widget->property("setRadius").value<int>();
    }


    tabWidgetParameters.radius = tabradius;
    tabWidgetParameters.tabWidgetBackgroundBrush = widgetBackgroundBrush;
    tabWidgetParameters.tabBarBackgroundBrush = tabBarBackgroundBrush;
    tabWidgetParameters.tabBarDefaultBrush = tabBarDefaultBrush;
    tabWidgetParameters.tabBarHoverBrush = tabBarHoverBrush;
    tabWidgetParameters.tabBarSelectBrush = tabBarSelectBrush;
}

void KFashionStyleParameters::initMenuParameters(bool isDark, const QStyleOption *option, const QWidget *widget)
{
    int frameradius = 8;
    int itemradius = 6;
    QPixmap framePixmap(option->rect.size());
    QBrush itemSelectBrush;

    //frame Pixmap
    framePixmap.fill(Qt::transparent);
    QRect drawRect;
    if (qobject_cast<const QFrame*>(widget)) {
        //path has 1px blank on right and bottom
        drawRect = option->rect.adjusted(0, 0, 1, 1);

        QPainterPath drawRectPath;
        drawRectPath.moveTo(drawRect.left(), drawRect.top() + frameradius);
        drawRectPath.arcTo(QRect(drawRect.left(), drawRect.top(), 2 * frameradius, 2 * frameradius), 180, -90);
        drawRectPath.lineTo(drawRect.right() - frameradius, drawRect.top());
        drawRectPath.arcTo(QRect(drawRect.right() - 2 * frameradius, drawRect.top(), 2 * frameradius, 2 * frameradius), 90, -90);
        drawRectPath.lineTo(drawRect.right(), drawRect.bottom() - 28);
        drawRectPath.arcTo(QRect(drawRect.right() - 2 * 20, drawRect.bottom() - 2 * 28, 2 * 20, 2 * 28), 0, -90);
        drawRectPath.lineTo(drawRect.left() + frameradius, drawRect.bottom());
        drawRectPath.arcTo(QRect(drawRect.left(), drawRect.bottom() - 2 * frameradius, 2 * frameradius, 2 * frameradius), -90, -90);
        drawRectPath.lineTo(drawRect.left(), drawRect.top() + frameradius);

        QPainter pixmapPainter(&framePixmap);
        pixmapPainter.setPen(Qt::NoPen);
        pixmapPainter.setBrush(option->palette.color(QPalette::Active, QPalette::Base).lighter(300));
        pixmapPainter.setRenderHint(QPainter::Antialiasing, true);
        pixmapPainter.drawPath(drawRectPath);
        pixmapPainter.end();

        QPainterPath drawRightBottomPath;
        drawRightBottomPath.moveTo(drawRect.right(), drawRect.bottom() - 28);
        drawRightBottomPath.arcTo(QRect(drawRect.right() - 2 * 20, drawRect.bottom() - 2 * 28, 2 * 20, 2 * 28), 0, -90);
        drawRightBottomPath.lineTo(drawRect.right() - frameradius, drawRect.bottom());
        drawRightBottomPath.arcTo(QRect(drawRect.right() - 2 * frameradius, drawRect.bottom() - 2 * frameradius, 2 * frameradius, 2 * frameradius), -90, 90);
        drawRightBottomPath.lineTo(drawRect.right(), drawRect.bottom() - 28);

        //draw right bottom corner
        QColor startColor = option->palette.color(QPalette::Active, QPalette::Base).lighter(300);
        QColor endColor = mixColor(startColor, QColor(Qt::black), 0.25);
        QLinearGradient linearGradient;
        QPainter pixmapPainter2(&framePixmap);
        linearGradient.setColorAt(0, startColor);
        linearGradient.setColorAt(1, endColor);
        linearGradient.setStart(drawRect.right(), drawRect.bottom() - 28);
        linearGradient.setFinalStop(drawRect.right(), drawRect.bottom());
        pixmapPainter2.setRenderHint(QPainter::Antialiasing);
        pixmapPainter2.setPen(Qt::transparent);
        pixmapPainter2.setBrush(linearGradient);
        pixmapPainter2.drawPath(drawRightBottomPath);
    } else {
        int rander = 5;
        drawRect = option->rect.adjusted(+rander, +rander, -rander, -rander);

        // Draw a black floor
        QPainter pixmapPainter(&framePixmap);
        pixmapPainter.setRenderHint(QPainter::Antialiasing, true);
        pixmapPainter.setPen(Qt::transparent);
        pixmapPainter.setBrush(option->palette.color(QPalette::Active, QPalette::BrightText));
        pixmapPainter.drawRoundedRect(drawRect.adjusted(1, 1, -1, -1), frameradius, frameradius);
        pixmapPainter.end();

        // Blur the black background
        QImage img = framePixmap.toImage();
        qt_blurImage(img, 4, false, false);

        // Dig out the center part, Shadow rendering
        framePixmap = QPixmap::fromImage(img);
        QPainter pixmapPainter2(&framePixmap);
        pixmapPainter2.setRenderHint(QPainter::Antialiasing);
        pixmapPainter2.setCompositionMode(QPainter::CompositionMode_Clear);
        pixmapPainter2.setPen(Qt::transparent);
        pixmapPainter2.setBrush(Qt::transparent);
        pixmapPainter2.drawRoundedRect(drawRect.adjusted(1, 1, -1, -1), frameradius, frameradius);
        pixmapPainter2.end();

        //That's when I started drawing the frame floor
        QColor color = option->palette.color(QPalette::Base);
        QColor startColor;
        QColor endColor;
        if (isDark) {
            endColor = option->palette.color(QPalette::Active, QPalette::Base).lighter(300);
            startColor = mixColor(endColor, QColor(Qt::white), 0.2);
        } else {
            startColor = option->palette.color(QPalette::Active, QPalette::Base).lighter(300);
            endColor = mixColor(startColor, QColor(Qt::black), 0.2);
        }

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

        QRegion region;
        if (widget) {
            region = widget->mask();
        }

        if (!region.isEmpty()) {
            QPainterPath path;
            path.addRegion(region);

            //draw blur background
            QPainter pixmapPainter3(&framePixmap);
            pixmapPainter3.setRenderHint(QPainter::Antialiasing);
            pixmapPainter3.setPen(Qt::transparent);
            pixmapPainter3.setBrush(color);
            pixmapPainter3.drawPath(path);
        } else {
            //path has 1px blank on right and bottom
            drawRect.adjust(0, 0, 1, 1);

            QPainterPath drawRectPath;
            drawRectPath.moveTo(drawRect.left(), drawRect.top() + frameradius);
            drawRectPath.arcTo(QRect(drawRect.left(), drawRect.top(), 2 * frameradius, 2 * frameradius), 180, -90);
            drawRectPath.lineTo(drawRect.right() - frameradius, drawRect.top());
            drawRectPath.arcTo(QRect(drawRect.right() - 2 * frameradius, drawRect.top(), 2 * frameradius, 2 * frameradius), 90, -90);
            drawRectPath.lineTo(drawRect.right(), drawRect.bottom() - 28);
            drawRectPath.arcTo(QRect(drawRect.right() - 2 * 20, drawRect.bottom() - 2 * 28, 2 * 20, 2 * 28), 0, -90);
            drawRectPath.lineTo(drawRect.left() + frameradius, drawRect.bottom());
            drawRectPath.arcTo(QRect(drawRect.left(), drawRect.bottom() - 2 * frameradius, 2 * frameradius, 2 * frameradius), -90, -90);
            drawRectPath.lineTo(drawRect.left(), drawRect.top() + frameradius);

            //draw blur background
            QPainter pixmapPainter3(&framePixmap);
            pixmapPainter3.setRenderHint(QPainter::Antialiasing);
            pixmapPainter3.setPen(Qt::transparent);
            pixmapPainter3.setBrush(color);
            pixmapPainter3.drawPath(drawRectPath);
            pixmapPainter3.end();

            QPainterPath drawRightBottomPath;
            drawRightBottomPath.moveTo(drawRect.right(), drawRect.bottom() - 28);
            drawRightBottomPath.arcTo(QRect(drawRect.right() - 2 * 20, drawRect.bottom() - 2 * 28, 2 * 20, 2 * 28), 0, -90);
            drawRightBottomPath.lineTo(drawRect.right() - frameradius, drawRect.bottom());
            drawRightBottomPath.arcTo(QRect(drawRect.right() - 2 * frameradius, drawRect.bottom() - 2 * frameradius, 2 * frameradius, 2 * frameradius), -90, 90);
            drawRightBottomPath.lineTo(drawRect.right(), drawRect.bottom() - 28);

            //draw right bottom corner
            QLinearGradient linearGradient;
            linearGradient.setColorAt(0, startColor);
            linearGradient.setColorAt(1, endColor);
            linearGradient.setStart(drawRect.right(), drawRect.bottom() - 28);
            linearGradient.setFinalStop(drawRect.right(), drawRect.bottom());
            QPainter pixmapPainter4(&framePixmap);
            pixmapPainter4.setRenderHint(QPainter::Antialiasing);
            pixmapPainter4.setPen(Qt::transparent);
            pixmapPainter4.setBrush(linearGradient);
            pixmapPainter4.drawPath(drawRightBottomPath);
        }
    }

    //item select brush
    itemSelectBrush = QBrush(option->palette.brush(QPalette::Active, QPalette::Highlight));


    menuParameters.frameRadius = frameradius;
    menuParameters.itemRadius = itemradius;
    menuParameters.menuFramePixmap = framePixmap;
    menuParameters.menuItemSelectBrush = itemSelectBrush;
}
