Newer
Older
#include "StyledDropShadowEffect.h"

Alexandr Mruchok
committed
#include "AppStyleSheetHandler.h"
StyledDropShadowEffect::StyledDropShadowEffect(QObject *a_parent /*= Q_NULLPTR*/)
:QGraphicsDropShadowEffect(a_parent)
{
///@details Collecting data from css
void StyledDropShadowEffect::updateStyleProperties()
{
StyleSheatSearchPar searchPar;
searchPar.widgetName = "#" + parent()->objectName();
searchPar.subcontrol = "shadow";
setDataShadowProperties(AppStyleSheetHandler::getWidgetStyleSheet(searchPar),defaultShadow);
searchPar.pseudoClass = "hover";
setDataShadowProperties(AppStyleSheetHandler::getWidgetStyleSheet(searchPar),hoverShadow);
}
///@details Setting and setting the default shadow
void StyledDropShadowEffect::updateStyle(StyleShedow a_style)
{
switch (a_style)
{
case DEFAULT_SHADOW:setShadowProperties(defaultShadow);break;
case HOVER_SHADOW:setShadowProperties(hoverShadow);break;
default:break;
}
}
///@details Saving data to a shadow structure
/// @param a_property String with settings from css.
/// @param data Data structure with shadow settings.
void StyledDropShadowEffect::setDataShadowProperties(const QString &stylesheet, ShadowProperties &data)
{

Alexandr Mruchok
committed
QString colorStr = AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "color");
data.color = Utils::toColor(colorStr);
data.blur = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "blur"));
data.x = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "x"));
data.y = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "y"));
}
///@details Set shadow options
/// @param data Data structure with shadow settings.
void StyledDropShadowEffect::setShadowProperties(ShadowProperties &data)
{
this->setColor(data.color);
this->setBlurRadius(data.blur);
this->setOffset(data.x, data.y);