diff --git a/controls/CustomComboBox.cpp b/controls/CustomComboBox.cpp index 1e284709f0df2a692ba31f1292bc3d200630f8ef..e2d27475cf651eea286e3ff6fe71aa47a2373a0d 100644 --- a/controls/CustomComboBox.cpp +++ b/controls/CustomComboBox.cpp @@ -21,6 +21,7 @@ void CustomComboBox::setObjectName(const QString &name) void CustomComboBox::showPopup() { + qDebug() << "show Popup"; emit showCustomWindow(); } /** @brief Reimplemented QComboBox::enterEvent is sent to the widget when the mouse cursor enters the widget. diff --git a/controls/CustomPlacementButton_New.cpp b/controls/CustomPlacementButton_New.cpp index f32974aeda9aec8518005fac296cc8886a3d363d..9fe313ad30d0f1347c8912495257298abb2106fe 100644 --- a/controls/CustomPlacementButton_New.cpp +++ b/controls/CustomPlacementButton_New.cpp @@ -36,12 +36,13 @@ CustomPlacementButton_New::CustomPlacementButton_New(QWidget *a_parent) //Adding subcontrols to layout m_layout->addWidget(&m_lbLeftSpacing); - for (QLabel *subcontrol: m_subcontrols){ + for (QLabel *subcontrol: m_subcontrols) + { // Set up subcontroll ScaledContents: subcontrol->setScaledContents(true); m_layout->addWidget(subcontrol); - subcontrol->setProperty("hover", false ); - subcontrol->setProperty(qPrintable(Properties::CHECKED), false); + + CustomPlacementButton_New::setWidgetState(subcontrol); } m_layout->addWidget(&m_lbRightSpacing); @@ -51,9 +52,6 @@ CustomPlacementButton_New::CustomPlacementButton_New(QWidget *a_parent) connect(this, &QAbstractButton::toggled, [=](bool a_checked) { this->setState(this->underMouse(), a_checked); }); - - m_styledshadow = new StyledDropShadowEffect(this); - } /** @brief Reimplemented QPushButton::setText method. Sets text property of text subcontrol. @@ -77,19 +75,13 @@ void CustomPlacementButton_New::setState(bool isHover, bool isChecked) const char* hoverProperty = qPrintable(Properties::HOVER); const char* checkedProperty = qPrintable(Properties::CHECKED); - m_lbText.setProperty(hoverProperty , isHover ); - m_lbText.setProperty(checkedProperty, isChecked); - m_lbText.style()->unpolish(&m_lbText); - m_lbText.style()->polish(&m_lbText); - + if (isHover != this->property(hoverProperty) && isChecked != this->property(checkedProperty)) + { for (QLabel *subcontrol: m_subcontrols) - { - subcontrol->setProperty(hoverProperty , isHover ); - subcontrol->setProperty(checkedProperty, isChecked); + setWidgetState(subcontrol, isHover, isChecked); - subcontrol->style()->unpolish(subcontrol); - subcontrol->style()->polish(subcontrol); - } + setWidgetState(this, isHover, isChecked); + } } /** @brief add new subcontrol and place it in layout @@ -101,9 +93,8 @@ void CustomPlacementButton_New::addSubcontrol(QString a_id) QLabel *newSubcontrol = new QLabel((QPushButton*)this); newSubcontrol->setObjectName(a_id); -// newSubcontrol->widget()->setScaledContents(true); - newSubcontrol->setProperty("hover", false ); -// newSubcontrol->setProperty(qPrintable(Properties::CHECKED), false); + CustomPlacementButton_New::setWidgetState(newSubcontrol, this->underMouse(), isChecked()); + //add to list and layout m_subcontrols.append(newSubcontrol); m_layout->insertWidget(m_layout->count() - 1, newSubcontrol); @@ -127,6 +118,12 @@ void CustomPlacementButton_New::setImagePosition(ImagePos a_position /*= ImagePo } } +void CustomPlacementButton_New::setGraphicsEffect(StyledDropShadowEffect *a_effect) +{ + m_styledShadow = a_effect; + QPushButton::setGraphicsEffect(a_effect); +} + /** @brief event is sent to the widget when the mouse cursor enters the widget. * @param event @@ -138,8 +135,8 @@ void CustomPlacementButton_New::enterEvent(QEvent *event) if (isEnabled()) setState(true, isChecked()); - m_styledshadow->updateStyle(HOVER_SHADOW); - setGraphicsEffect(m_styledshadow); + if (m_styledShadow) + m_styledShadow->updateStyle(HOVER_SHADOW); } /** @brief A leave event is sent to the widget when the mouse cursor leaves the widget. @@ -152,8 +149,20 @@ void CustomPlacementButton_New::leaveEvent(QEvent *event) if (isEnabled()) setState(false, isChecked()); - m_styledshadow->updateStyle(DEFAULT_SHADOW); - setGraphicsEffect(m_styledshadow); + if (m_styledShadow) + m_styledShadow->updateStyle(DEFAULT_SHADOW); +} + +void CustomPlacementButton_New::setWidgetState(QWidget *a_widget, bool a_isHover, bool a_isChecked) +{ + const char* hoverProperty = qPrintable(Properties::HOVER); + const char* checkedProperty = qPrintable(Properties::CHECKED); + + a_widget->setProperty(hoverProperty , a_isHover ); + a_widget->setProperty(checkedProperty, a_isChecked); + + a_widget->style()->unpolish(a_widget); + a_widget->style()->polish (a_widget); } /** @brief Reimplemented QPushButton::setObjectName method. Updates stylesheets. @@ -162,7 +171,5 @@ void CustomPlacementButton_New::leaveEvent(QEvent *event) void CustomPlacementButton_New::setObjectName(const QString &name) { QPushButton::setObjectName(name); - m_styledshadow->updateStyleProperties(); - setGraphicsEffect(m_styledshadow); - + m_styledShadow->updateStyleProperties(); } diff --git a/controls/CustomPlacementButton_New.h b/controls/CustomPlacementButton_New.h index 5e0f5dab77ee0f1644907c94f66386b1ce09d5d6..2400e25502611aabcd8d1f81fda69abc65732d88 100644 --- a/controls/CustomPlacementButton_New.h +++ b/controls/CustomPlacementButton_New.h @@ -74,10 +74,11 @@ public: /// @param a_position Enum ImagePos Right or Left. void setImagePosition(ImagePos a_position = ImagePos::Left); + void setGraphicsEffect(StyledDropShadowEffect *a_effect); private: ///For effect. - StyledDropShadowEffect *m_styledshadow; + StyledDropShadowEffect *m_styledShadow = nullptr; protected: /// Cursor in. /// @param event Signal source. @@ -92,6 +93,9 @@ protected: QLabel m_lbImage; ///<label with image QLabel m_lbText; ///<label with text QLabel m_lbRightSpacing; ///<label for right spacing + +private: + static void setWidgetState(QWidget* a_widget, bool a_isHover=false, bool a_isChecked = false); }; #endif // CUSTOMPLACEMENTBUTTON_NEW_H diff --git a/controls/StyledDropShadowEffect.cpp b/controls/StyledDropShadowEffect.cpp index 6885bffe84b691e246799655efb7ae98fc988c84..da32df84230500825165a87587a02a06f254690c 100755 --- a/controls/StyledDropShadowEffect.cpp +++ b/controls/StyledDropShadowEffect.cpp @@ -32,6 +32,9 @@ void StyledDropShadowEffect::updateStyle(StyleShedow a_style) case HOVER_SHADOW:setShadowProperties(hoverShadow);break; default:break; } + + this->update(); +// qobject_cast<QWidget*>(this->parent())->setGraphicsEffect(this); } ///@details Saving data to a shadow structure diff --git a/controls/controls.pri b/controls/controls.pri index a09a65d29f42145f2fd51a0c377172e138e1223f..2a6a106094382b168ea7a502b685e3829d729e33 100644 --- a/controls/controls.pri +++ b/controls/controls.pri @@ -8,9 +8,7 @@ SOURCES += \ $$PWD/CustomLineHeightTextEdit.cpp \ $$PWD/CustomPlacementButton.cpp \ $$PWD/CustomPlacementButton_New.cpp \ - $$PWD/CustomWidget.cpp \ $$PWD/FAQWidget.cpp \ - $$PWD/ListModel.cpp \ $$PWD/ServersComboBox.cpp \ $$PWD/AnimatedLineEdit.cpp \ $$PWD/ScreenOverlaying.cpp \ @@ -27,9 +25,7 @@ HEADERS += \ $$PWD/CustomLineHeightTextEdit.h \ $$PWD/CustomPlacementButton.h \ $$PWD/CustomPlacementButton_New.h \ - $$PWD/CustomWidget.h \ $$PWD/FAQWidget.h \ - $$PWD/ListModel.h \ $$PWD/ServersComboBox.h \ $$PWD/AnimatedLineEdit.h \ $$PWD/ScreenOverlaying.h \