forked from openkylin/qt5-ukui-platformtheme
处理多个scrollbar sliderbar时获取的handlerect不正确的问题
This commit is contained in:
parent
b5f588c81c
commit
ea60b48fae
|
@ -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<QWidget*>(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<QWidget*>(widget), QRect(drawRect.x(), drawRect.y(), drawRect.width(), drawRect.height()));
|
||||
|
||||
//hover color animation
|
||||
// animator->setAnimatorDirectionForward("slider_opacity", mouseOver);
|
||||
|
|
|
@ -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<QWidget*, QRect> m_scrollBarSliderRec;
|
||||
mutable QHash<QWidget*, QRect> m_sliderHandleRec;
|
||||
|
||||
BlurHelper *m_blur_helper = nullptr;
|
||||
GestureHelper *m_gesture_helper = nullptr;
|
||||
|
|
Loading…
Reference in New Issue