mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-30 17:58:37 +08:00
UI: Make T-Bar unclickable
The T-Bar should only be draggable and not act on clicks.
This commit is contained in:
@@ -94,3 +94,42 @@ QAccessible::Role VolumeAccessibleInterface::role() const
|
||||
{
|
||||
return QAccessible::Role::Slider;
|
||||
}
|
||||
|
||||
void SliderIgnoreClick::mousePressEvent(QMouseEvent *event)
|
||||
{
|
||||
QStyleOptionSlider styleOption;
|
||||
initStyleOption(&styleOption);
|
||||
QRect handle = style()->subControlRect(QStyle::CC_Slider, &styleOption,
|
||||
QStyle::SC_SliderHandle, this);
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QPointF pointExact = event->position();
|
||||
#endif
|
||||
if (handle.contains(
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
||||
QPoint(pointExact.x(), pointExact.y())
|
||||
#else
|
||||
// Ubuntu 20.04. Sigh.
|
||||
QPoint(event->x(), event->y())
|
||||
#endif
|
||||
)) {
|
||||
SliderIgnoreScroll::mousePressEvent(event);
|
||||
dragging = true;
|
||||
} else {
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
void SliderIgnoreClick::mouseReleaseEvent(QMouseEvent *event)
|
||||
{
|
||||
dragging = false;
|
||||
SliderIgnoreScroll::mouseReleaseEvent(event);
|
||||
}
|
||||
|
||||
void SliderIgnoreClick::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (dragging) {
|
||||
SliderIgnoreScroll::mouseMoveEvent(event);
|
||||
} else {
|
||||
event->accept();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <QInputEvent>
|
||||
#include <QtCore/QObject>
|
||||
#include <QAccessibleWidget>
|
||||
#include <QStyleOptionSlider>
|
||||
|
||||
class SliderIgnoreScroll : public QSlider {
|
||||
Q_OBJECT
|
||||
@@ -49,3 +50,20 @@ protected:
|
||||
virtual QAccessible::Role role() const override;
|
||||
virtual QString text(QAccessible::Text t) const override;
|
||||
};
|
||||
|
||||
class SliderIgnoreClick : public SliderIgnoreScroll {
|
||||
public:
|
||||
inline SliderIgnoreClick(Qt::Orientation orientation,
|
||||
QWidget *parent = nullptr)
|
||||
: SliderIgnoreScroll(orientation, parent)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual void mousePressEvent(QMouseEvent *event) override;
|
||||
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
||||
virtual void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
||||
private:
|
||||
bool dragging = false;
|
||||
};
|
||||
|
||||
@@ -797,7 +797,7 @@ void OBSBasic::CreateProgramOptions()
|
||||
mainButtonLayout->addWidget(transitionButton);
|
||||
mainButtonLayout->addWidget(configTransitions);
|
||||
|
||||
tBar = new SliderIgnoreScroll(Qt::Horizontal);
|
||||
tBar = new SliderIgnoreClick(Qt::Horizontal);
|
||||
tBar->setMinimum(0);
|
||||
tBar->setMaximum(T_BAR_PRECISION - 1);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user