slider vertical状态响应鼠标中间键方向问题处理 scrollbar也存在这个问题修改

This commit is contained in:
tanjing 2024-01-11 14:22:55 +08:00
parent c19bd0a2dc
commit f3741d9638
2 changed files with 19 additions and 8 deletions

View File

@ -598,7 +598,8 @@
}, },
"UseButtonPalette":{ "UseButtonPalette":{
"DefaultBrush" : {"value": "Button_at", "type": "paletterole"}, "DefaultBrush" : {"value": "Button_at", "type": "paletterole"},
"HoverBrush" : {"type": "gradient"}, "HoverBrush" : {"value": "95, 95, 95 ~ 65, 65, 65", "type": "gradient"},
"ClickBrush" : {"value": "95, 95, 95", "type": "color"},
"DisableBrush" : {"value": "Button_dis", "type": "paletterole"}, "DisableBrush" : {"value": "Button_dis", "type": "paletterole"},
"TextColor" : {"value": "BrightText_at", "type": "paletterole"}, "TextColor" : {"value": "BrightText_at", "type": "paletterole"},
"TextHoverColor" : {"value": "BrightText_at", "type": "paletterole"}, "TextHoverColor" : {"value": "BrightText_at", "type": "paletterole"},

View File

@ -383,7 +383,7 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
if((e->type() ==QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) && (proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button() || if((e->type() ==QEvent::MouseButtonPress || e->type() == QEvent::MouseButtonDblClick) && (proxy()->styleHint(QStyle::SH_Slider_AbsoluteSetButtons) == mousePressEvent->button() ||
proxy()->styleHint(QStyle::SH_Slider_PageSetButtons) == mousePressEvent->button())){ proxy()->styleHint(QStyle::SH_Slider_PageSetButtons) == mousePressEvent->button())){
//qDebug() << "e->type:" << e->type() << mousePressEvent->button(); // qDebug() << "e->type:" << e->type() << mousePressEvent->button();
if(obj->property("animation").isValid() && !obj->property("animation").toBool()) if(obj->property("animation").isValid() && !obj->property("animation").toBool())
return false; return false;
@ -412,6 +412,8 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
QRect handleRect = sliderHandleRec(); QRect handleRect = sliderHandleRec();
if(horizontal){ if(horizontal){
// qDebug() << "mousepressevent1111 pos...." << mousePressEvent->pos().x() << handleRect.x();
if(mousePressEvent->pos().x() <= handleRect.x()){ if(mousePressEvent->pos().x() <= handleRect.x()){
animator->setExtraProperty("addValue", false); animator->setExtraProperty("addValue", false);
@ -423,6 +425,7 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
return false; return false;
} }
else{ else{
// qDebug() << "mousepressevent1111 pos...." << mousePressEvent->pos().y() << handleRect.y();
if(mousePressEvent->pos().y() <= handleRect.y()){ if(mousePressEvent->pos().y() <= handleRect.y()){
animator->setExtraProperty("addValue", true); animator->setExtraProperty("addValue", true);
@ -459,15 +462,19 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
sliderMin = gr.x(); sliderMin = gr.x();
sliderMax = gr.right() - sliderLength + 1; sliderMax = gr.right() - sliderLength + 1;
pos = (mousePressEvent->pos() - center).x(); pos = (mousePressEvent->pos() - center).x();
// qDebug() << "pos....:" << mousePressEvent->pos() << center << pos; // qDebug() << "Horizontal pos....:" << mousePressEvent->pos() << center << pos;
} else { } else {
sliderLength = sr.height(); sliderLength = sr.height();
sliderMin = gr.y(); sliderMin = gr.y();
sliderMax = gr.bottom() - sliderLength + 1; sliderMax = gr.bottom() - sliderLength + 1;
pos = (mousePressEvent->pos() - center).y(); pos = (mousePressEvent->pos() - center).y();
// qDebug() << "vertical pos....:" << mousePressEvent->pos() << center << pos;
} }
// qDebug() << "minumum..." << slider->minimum() << slider->maximum() << sliderMin << sliderMax << pos; // qDebug() << "minumum..." << slider->minimum() << slider->maximum() << sliderMin << sliderMax << pos << opt->upsideDown;
int sliderValue = sliderValueFromPosition(slider->minimum(), slider->maximum(), pos - sliderMin, sliderMax - sliderMin, opt->upsideDown); bool upsideDown = (slider->orientation() == Qt::Horizontal) ?
(slider->invertedAppearance() != (slider->layoutDirection() == Qt::RightToLeft))
: (!slider->invertedAppearance());
int sliderValue = sliderValueFromPosition(slider->minimum(), slider->maximum(), pos - sliderMin, sliderMax - sliderMin, upsideDown);//opt->upsideDown);
// qDebug() << "sliderValue....." << sliderValue << slider->value(); // qDebug() << "sliderValue....." << sliderValue << slider->value();
step = sliderValue - slider->value(); step = sliderValue - slider->value();
// qDebug() << "step0000...." << step; // qDebug() << "step0000...." << step;
@ -527,11 +534,11 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
if(horizontal){ if(horizontal){
if(mousePressEvent->pos().x() <= scrollbarSliderRec().x()){ if(mousePressEvent->pos().x() <= scrollbarSliderRec().x()){
animator->setExtraProperty("addValue", scrollbar->layoutDirection() == Qt::RightToLeft ? true : false); animator->setExtraProperty("addValue", /*scrollbar->layoutDirection() == Qt::RightToLeft ? true :*/ false);
} }
else if(mousePressEvent->pos().x() >= scrollbarSliderRec().x() + scrollbarSliderRec().width()){ else if(mousePressEvent->pos().x() >= scrollbarSliderRec().x() + scrollbarSliderRec().width()){
animator->setExtraProperty("addValue", scrollbar->layoutDirection() == Qt::RightToLeft ? false : true); animator->setExtraProperty("addValue", /*scrollbar->layoutDirection() == Qt::RightToLeft ? false :*/ true);
} }
else else
return false; return false;
@ -597,9 +604,12 @@ bool UKUIConfigStyle::eventFilter(QObject *obj, QEvent *e)
} }
bool upsideDown = scrollbar->invertedAppearance();
// if(scrollbar->layoutDirection() == Qt::RightToLeft && scrollbar->orientation() == Qt::Horizontal)
// upsideDown = !upsideDown;
// qDebug() << "minimum..." << scrollbar->minimum() << scrollbar->maximum() << pos << sliderMin << sliderMax; // qDebug() << "minimum..." << scrollbar->minimum() << scrollbar->maximum() << pos << sliderMin << sliderMax;
int scrollValue = sliderValueFromPosition(scrollbar->minimum(), scrollbar->maximum(), pos - sliderMin, int scrollValue = sliderValueFromPosition(scrollbar->minimum(), scrollbar->maximum(), pos - sliderMin,
sliderMax - sliderMin, opt->upsideDown); sliderMax - sliderMin, upsideDown);//opt->upsideDown);
// qDebug() << "scrollValue....." << scrollValue << scrollbar->value(); // qDebug() << "scrollValue....." << scrollValue << scrollbar->value();
step = scrollValue - scrollbar->value(); step = scrollValue - scrollbar->value();
// qDebug() << "step0000...." << step; // qDebug() << "step0000...." << step;