0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-19 20:32:15 +02:00

UI: Add ability to reset sliders when double clicked

This commit is contained in:
cg2121 2018-09-02 22:17:09 -05:00
parent a4a7deeed6
commit 11f1442a3c
4 changed files with 35 additions and 4 deletions

View File

@ -207,6 +207,7 @@ set(obs_HEADERS
properties-view.hpp
properties-view.moc.hpp
display-helpers.hpp
balance-slider.hpp
double-slider.hpp
focus-list.hpp
menu-button.hpp

View File

@ -4,7 +4,6 @@
#include <QSpinBox>
#include <QComboBox>
#include <QCheckBox>
#include <QSlider>
#include "qt-wrappers.hpp"
#include "obs-app.hpp"
#include "adv-audio-control.hpp"
@ -32,7 +31,7 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
nameLabel = new QLabel();
volume = new QSpinBox();
forceMono = new QCheckBox();
balance = new QSlider(Qt::Horizontal);
balance = new BalanceSlider();
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
monitoringType = new QComboBox();
#endif
@ -82,6 +81,7 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
forceMonoContainer->layout()->setAlignment(forceMono,
Qt::AlignHCenter | Qt::AlignVCenter);
balance->setOrientation(Qt::Horizontal);
balance->setMinimum(0);
balance->setMaximum(100);
balance->setTickPosition(QSlider::TicksAbove);
@ -153,6 +153,8 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_)
this, SLOT(downmixMonoChanged(bool)));
QWidget::connect(balance, SIGNAL(valueChanged(int)),
this, SLOT(balanceChanged(int)));
QWidget::connect(balance, SIGNAL(doubleClicked()),
this, SLOT(ResetBalance()));
QWidget::connect(syncOffset, SIGNAL(valueChanged(int)),
this, SLOT(syncOffsetChanged(int)));
#if defined(_WIN32) || defined(__APPLE__) || HAVE_PULSEAUDIO
@ -314,6 +316,12 @@ void OBSAdvAudioCtrl::balanceChanged(int val)
obs_source_set_balance_value(source, bal);
}
void OBSAdvAudioCtrl::ResetBalance()
{
balance->setValue(50);
}
void OBSAdvAudioCtrl::syncOffsetChanged(int milliseconds)
{
int64_t cur_val = obs_source_get_sync_offset(source);

View File

@ -3,12 +3,12 @@
#include <obs.hpp>
#include <QWidget>
#include <QPointer>
#include "balance-slider.hpp"
class QGridLayout;
class QLabel;
class QSpinBox;
class QCheckBox;
class QSlider;
class QComboBox;
class OBSAdvAudioCtrl : public QObject {
@ -24,7 +24,7 @@ private:
QPointer<QLabel> nameLabel;
QPointer<QSpinBox> volume;
QPointer<QCheckBox> forceMono;
QPointer<QSlider> balance;
QPointer<BalanceSlider>balance;
QPointer<QLabel> labelL;
QPointer<QLabel> labelR;
QPointer<QSpinBox> syncOffset;
@ -70,4 +70,5 @@ public slots:
void mixer4Changed(bool checked);
void mixer5Changed(bool checked);
void mixer6Changed(bool checked);
void ResetBalance();
};

21
UI/balance-slider.hpp Normal file
View File

@ -0,0 +1,21 @@
#pragma once
#include <QSlider>
#include <QMouseEvent>
class BalanceSlider : public QSlider {
Q_OBJECT
public:
inline BalanceSlider(QWidget *parent = 0) : QSlider(parent) {}
signals:
void doubleClicked();
protected:
void mouseDoubleClickEvent(QMouseEvent *event)
{
emit doubleClicked();
event->accept();
}
};