Skip to content
Snippets Groups Projects
CustomComboBox.cpp 1.27 KiB
Newer Older
konstantin.kukharenko's avatar
konstantin.kukharenko committed
#include "CustomComboBox.h"

/** @brief constructor
 *  @param a_parent object parent
 */
CustomComboBox::CustomComboBox(QWidget *parent):
    QComboBox (parent)
{
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    m_styledshadow = new StyledDropShadowEffect(this);
}
konstantin.kukharenko's avatar
konstantin.kukharenko committed
/** @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);
konstantin.kukharenko's avatar
konstantin.kukharenko committed
}

/** @brief Reimplemented QComboBox::enterEvent is sent to the widget when the mouse cursor enters the widget.
 *  @param event
 */
void CustomComboBox:: enterEvent(QEvent *event)
{
    Q_UNUSED(event);
konstantin.kukharenko's avatar
konstantin.kukharenko committed
    m_styledshadow->updateStyle(HOVER_SHADOW);
    setGraphicsEffect(m_styledshadow);
konstantin.kukharenko's avatar
konstantin.kukharenko committed

    setProperty("hoverState",1);
    style()->unpolish(this);
    style()->polish(this);
    update();
}

/** @brief Reimplemented QComboBox::leaveEvent is sent to the widget when the mouse cursor leaves the widget.
 *  @param event
 */
void CustomComboBox::leaveEvent(QEvent *event)
{
    Q_UNUSED(event);

konstantin.kukharenko's avatar
konstantin.kukharenko committed
    m_styledshadow->updateStyle(DEFAULT_SHADOW);
    setGraphicsEffect(m_styledshadow);

konstantin.kukharenko's avatar
konstantin.kukharenko committed
    setProperty("hoverState",0);
    style()->unpolish(this);
    style()->polish(this);
    update();
}