diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp b/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp index 431cbd2..bd0728b 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style.cpp @@ -410,7 +410,7 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e) // opt->init(slider); // qDebug() << "pppppppp;;;;;;;;;:" << subControlRect(CC_Slider, opt, SC_SliderHandle, slider); - QRect handleRect = sliderHandleRec(); + QRect handleRect = sliderHandleRec(slider); if(horizontal){ // qDebug() << "mousepressevent1111 pos...." << mousePressEvent->pos().x() << handleRect.x(); @@ -532,23 +532,23 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e) // qDebug() << "event..." << e->type() << mousePressEvent->button(); const bool horizontal = scrollbar->orientation() == Qt::Horizontal; - if(horizontal){ - if(mousePressEvent->pos().x() <= scrollbarSliderRec().x()){ - animator->setExtraProperty("addValue", /*scrollbar->layoutDirection() == Qt::RightToLeft ? true :*/ false); + QRect handleRect = scrollbarSliderRec(scrollbar); + if(horizontal){ + if(mousePressEvent->pos().x() <= handleRect.x()){ + animator->setExtraProperty("addValue", /*scrollbar->layoutDirection() == Qt::RightToLeft ? true :*/ false); } - else if(mousePressEvent->pos().x() >= scrollbarSliderRec().x() + scrollbarSliderRec().width()){ + else if(mousePressEvent->pos().x() >= handleRect.x() + handleRect.width()){ animator->setExtraProperty("addValue", /*scrollbar->layoutDirection() == Qt::RightToLeft ? false :*/ true); } else return false; } else{ - if(mousePressEvent->pos().y() <= scrollbarSliderRec().y()){ + if(mousePressEvent->pos().y() <= handleRect.y()){ animator->setExtraProperty("addValue", false); - } - else if(mousePressEvent->pos().y() >= scrollbarSliderRec().y() + scrollbarSliderRec().height()){ + else if(mousePressEvent->pos().y() >= handleRect.y() + handleRect.height()){ animator->setExtraProperty("addValue", true); } else @@ -909,26 +909,44 @@ void UKUIConfigStyle::updateTabletModeValue(bool isTabletMode) } } -QRect UKUIConfigStyle::scrollbarSliderRec() +QRect UKUIConfigStyle::scrollbarSliderRec(QWidget *w) { - return m_scrollBarSliderRec; + if(w && m_scrollBarSliderRec.contains(w)) + return m_scrollBarSliderRec.value(w); + return QRect(); } -void UKUIConfigStyle::setScrollbarSliderRec(QRect rect) const +void UKUIConfigStyle::setScrollbarSliderRec(QWidget *w, QRect rect) const { - if(m_scrollBarSliderRec != rect) - m_scrollBarSliderRec = rect; + if(w){ + if(m_scrollBarSliderRec.contains(w)){ + QRect r = m_scrollBarSliderRec.value(w); + if(r != rect) + m_scrollBarSliderRec.insert(w, rect); + return; + } + m_scrollBarSliderRec.insert(w, rect); + } } -QRect UKUIConfigStyle::sliderHandleRec() +QRect UKUIConfigStyle::sliderHandleRec(QWidget *w) { - return m_sliderHandleRec; + if(w && m_sliderHandleRec.contains(w)) + return m_sliderHandleRec.value(w); + return QRect(); } -void UKUIConfigStyle::setSliderHandleRec(QRect rect) const +void UKUIConfigStyle::setSliderHandleRec(QWidget *w, QRect rect) const { - if(m_sliderHandleRec != rect) - m_sliderHandleRec = rect; + if(w){ + if(m_sliderHandleRec.contains(w)){ + QRect r = m_sliderHandleRec.value(w); + if(r != rect) + m_sliderHandleRec.insert(w, rect); + return; + } + m_sliderHandleRec.insert(w, rect); + } } @@ -3781,7 +3799,7 @@ void UKUIConfigStyle::drawComplexControl(QStyle::ComplexControl control, const Q else handle.setX((option->rect.width() - handle.width()) / 2); handleOption.rect = handle; - setSliderHandleRec(handleOption.rect); + setSliderHandleRec(const_cast(widget), handleOption.rect); sp->initConfigSliderParameters(isUseDarkPalette(), &handleOption, widget); @@ -4506,7 +4524,7 @@ void UKUIConfigStyle::drawControl(QStyle::ControlElement element, const QStyleOp drawRect = bar->rect; } - setScrollbarSliderRec(QRect(drawRect.x(), drawRect.y(), drawRect.width(), drawRect.height())); + setScrollbarSliderRec(const_cast(widget), QRect(drawRect.x(), drawRect.y(), drawRect.width(), drawRect.height())); //hover color animation // animator->setAnimatorDirectionForward("slider_opacity", mouseOver); diff --git a/ukui-styles/qt5-config-style-ukui/ukui-config-style.h b/ukui-styles/qt5-config-style-ukui/ukui-config-style.h index 5b78807..6a4b64f 100644 --- a/ukui-styles/qt5-config-style-ukui/ukui-config-style.h +++ b/ukui-styles/qt5-config-style-ukui/ukui-config-style.h @@ -144,10 +144,10 @@ protected: private Q_SLOTS: void updateTabletModeValue(bool isTabletMode); - QRect scrollbarSliderRec(); - void setScrollbarSliderRec(QRect rect) const; - QRect sliderHandleRec(); - void setSliderHandleRec(QRect rect) const; + QRect scrollbarSliderRec(QWidget *w); + void setScrollbarSliderRec(QWidget *w, QRect rect) const; + QRect sliderHandleRec(QWidget *w); + void setSliderHandleRec(QWidget *w,QRect rect) const; private: bool isUseDarkPalette() const; @@ -194,8 +194,8 @@ private: // UKUIConfigStyleParameters UKUIConfigStyleSpace::UKUIConfigStyleParameters *sp = nullptr; - mutable QRect m_scrollBarSliderRec; - mutable QRect m_sliderHandleRec; + mutable QHash m_scrollBarSliderRec; + mutable QHash m_sliderHandleRec; BlurHelper *m_blur_helper = nullptr; GestureHelper *m_gesture_helper = nullptr;