Skip to content
Snippets Groups Projects
Commit 64b98528 authored by konstantin.kukharenko's avatar konstantin.kukharenko
Browse files

Merge branch 'features-3091' into 'develop'

Features 3091

See merge request !8
parents edaa08d6 cb278b1f
No related branches found
No related tags found
3 merge requests!17Develop old,!11Feature 3131,!8Features 3091
......@@ -6,7 +6,17 @@
CustomComboBox::CustomComboBox(QWidget *parent):
QComboBox (parent)
{
m_styledshadow = new StyledDropShadowEffect(this);
}
/** @brief Reimplemented QComboBox::setObjectName method. Updates stylesheets.
* @param text Text
*/
void CustomComboBox::setObjectName(const QString &name)
{
QComboBox::setObjectName(name);
m_styledshadow->updateStyleProperties();
setGraphicsEffect(m_styledshadow);
}
/** @brief Reimplemented QComboBox::enterEvent is sent to the widget when the mouse cursor enters the widget.
......@@ -15,6 +25,8 @@ CustomComboBox::CustomComboBox(QWidget *parent):
void CustomComboBox:: enterEvent(QEvent *event)
{
Q_UNUSED(event);
m_styledshadow->updateStyle(HOVER_SHADOW);
setGraphicsEffect(m_styledshadow);
setProperty("hoverState",1);
style()->unpolish(this);
......@@ -29,6 +41,9 @@ void CustomComboBox::leaveEvent(QEvent *event)
{
Q_UNUSED(event);
m_styledshadow->updateStyle(DEFAULT_SHADOW);
setGraphicsEffect(m_styledshadow);
setProperty("hoverState",0);
style()->unpolish(this);
style()->polish(this);
......
......@@ -3,6 +3,7 @@
#include <QComboBox>
#include "StyledDropShadowEffect.h"
/** @brief QComboBox with changing downArrow when hover on control.
......@@ -20,9 +21,12 @@ class CustomComboBox : public QComboBox
Q_OBJECT
public:
CustomComboBox(QWidget *parent = Q_NULLPTR);
void setObjectName(const QString &name);
protected:
void enterEvent(QEvent *event);
void leaveEvent(QEvent *event);
private:
StyledDropShadowEffect *m_styledshadow;
};
#endif // CUSTOMCOMBOBOX_H
#include "StyledDropShadowEffect.h"
#include "AppStyleSheetHandler.h"
#include "Utils.h"
#include <QWidget>
/** @brief constructor. Update style
* @param a_parent object parent
*/
StyledDropShadowEffect::StyledDropShadowEffect(QObject *a_parent /*= Q_NULLPTR*/)
:QGraphicsDropShadowEffect(a_parent)
{
this->updateStyle();
updateStyleProperties();
}
/** @brief get stylesheet from app and update shadow style
*/
void StyledDropShadowEffect::updateStyle()
///@details Collecting data from css
void StyledDropShadowEffect::updateStyleProperties()
{
StyleSheatSearchPar searchPar;
searchPar.widgetName = "#" + parent()->objectName();
searchPar.subcontrol = "shadow";
setDataShadowProperties(AppStyleSheetHandler::getWidgetStyleSheet(searchPar),defaultShadow);
QString stylesheet = AppStyleSheetHandler::getWidgetStyleSheet(searchPar);
updateStyle(DEFAULT_SHADOW);
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)
{
//Color:
QString colorStr = AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "color");
if (colorStr.isEmpty())
this->setColor(QColor(0,0,0,0));
data.color = QColor(0,0,0,0);
else
this->setColor(Utils::toColor(colorStr));
int blur = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "blur"));
this->setBlurRadius(blur);
data.color = Utils::toColor(colorStr);
data.blur = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "blur"));
//Offset:
int x = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "x"));
int y = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "y"));
data.x = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "x"));
data.y = Utils::toIntValue(AppStyleSheetHandler::getValueFromStylesheet(stylesheet, "y"));
}
this->setOffset(x, 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);
}
......@@ -16,12 +16,38 @@
*>}
* @todo Is searching style in comments also!
*/
///@details Structure with shadow settings
struct ShadowProperties
{
int x;
int y;
int blur;
QColor color;
};
enum StyleShedow{DEFAULT_SHADOW,HOVER_SHADOW};
class StyledDropShadowEffect : public QGraphicsDropShadowEffect
{
public:
StyledDropShadowEffect(QObject *a_parent = Q_NULLPTR);
void updateStyle();
///@details Setting the shadow
void updateStyle(StyleShedow a_style);
///@details Collecting data from css
void updateStyleProperties();
private:
///@details Saving data to a shadow structure
/// @param a_property String with settings from css.
/// @param data Data structure with shadow settings.
void setDataShadowProperties(const QString &a_property, ShadowProperties &data);
///@details Set shadow options
/// @param data Data structure with shadow settings.
void setShadowProperties(ShadowProperties &data);
///@details Default Shadow Data
ShadowProperties defaultShadow;
///@details Hover Shadow Data
ShadowProperties hoverShadow;
};
#endif // STYLEDDROPSHADOWEFFECT_H
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment