Browse Source

UI: Replace SIGNAL and SLOT macros in custom widgets

gxalpha 2 years ago
parent
commit
ac170a2d83

+ 3 - 7
UI/double-slider.cpp

@@ -4,8 +4,9 @@
 
 DoubleSlider::DoubleSlider(QWidget *parent) : SliderIgnoreScroll(parent)
 {
-	connect(this, SIGNAL(valueChanged(int)), this,
-		SLOT(intValChanged(int)));
+	connect(this, &DoubleSlider::valueChanged, [this](int val) {
+		emit doubleValChanged((minVal / minStep + val) * minStep);
+	});
 }
 
 void DoubleSlider::setDoubleConstraints(double newMin, double newMax,
@@ -24,11 +25,6 @@ void DoubleSlider::setDoubleConstraints(double newMin, double newMax,
 	setDoubleVal(val);
 }
 
-void DoubleSlider::intValChanged(int val)
-{
-	emit doubleValChanged((minVal / minStep + val) * minStep);
-}
-
 void DoubleSlider::setDoubleVal(double val)
 {
 	setValue(lround((val - minVal) / minStep));

+ 0 - 1
UI/double-slider.hpp

@@ -18,6 +18,5 @@ signals:
 	void doubleValChanged(double val);
 
 public slots:
-	void intValChanged(int val);
 	void setDoubleVal(double val);
 };

+ 4 - 3
UI/lineedit-autoresize.cpp

@@ -2,10 +2,11 @@
 
 LineEditAutoResize::LineEditAutoResize()
 {
-	connect(this, SIGNAL(textChanged()), this, SLOT(checkTextLength()));
+	connect(this, &LineEditAutoResize::textChanged, this,
+		&LineEditAutoResize::checkTextLength);
 	connect(document()->documentLayout(),
-		SIGNAL(documentSizeChanged(const QSizeF &)), this,
-		SLOT(resizeVertically(const QSizeF &)));
+		&QAbstractTextDocumentLayout::documentSizeChanged, this,
+		&LineEditAutoResize::resizeVertically);
 }
 
 void LineEditAutoResize::checkTextLength()

+ 3 - 7
UI/visibility-item-widget.cpp

@@ -34,8 +34,9 @@ VisibilityItemWidget::VisibilityItemWidget(obs_source_t *source_)
 	setLayout(itemLayout);
 	setStyleSheet("background-color: rgba(255, 255, 255, 0);");
 
-	connect(vis, SIGNAL(clicked(bool)), this,
-		SLOT(VisibilityClicked(bool)));
+	connect(vis, &VisibilityCheckBox::clicked, [this](bool visible) {
+		obs_source_set_enabled(source, visible);
+	});
 }
 
 void VisibilityItemWidget::OBSSourceEnabled(void *param, calldata_t *data)
@@ -58,11 +59,6 @@ void VisibilityItemWidget::OBSSourceRenamed(void *param, calldata_t *data)
 				  Q_ARG(QString, QT_UTF8(name)));
 }
 
-void VisibilityItemWidget::VisibilityClicked(bool visible)
-{
-	obs_source_set_enabled(source, visible);
-}
-
 void VisibilityItemWidget::SourceEnabled(bool enabled)
 {
 	if (vis->isChecked() != enabled)

+ 0 - 1
UI/visibility-item-widget.hpp

@@ -29,7 +29,6 @@ private:
 	static void OBSSourceRenamed(void *param, calldata_t *data);
 
 private slots:
-	void VisibilityClicked(bool visible);
 	void SourceEnabled(bool enabled);
 	void SourceRenamed(QString name);
 

+ 4 - 9
UI/volume-control.cpp

@@ -388,8 +388,8 @@ VolControl::VolControl(OBSSource source_, bool showConfig, bool vertical)
 			       "audio_monitoring", OBSMixersOrMonitoringChanged,
 			       this);
 
-	QWidget::connect(slider, SIGNAL(valueChanged(int)), this,
-			 SLOT(SliderChanged(int)));
+	QWidget::connect(slider, &VolumeSlider::valueChanged, this,
+			 &VolControl::SliderChanged);
 	QWidget::connect(mute, &MuteCheckBox::clicked, this,
 			 &VolControl::SetMuted);
 
@@ -1163,11 +1163,6 @@ void VolumeMeter::paintVTicks(QPainter &painter, int x, int y, int height)
 
 #define CLIP_FLASH_DURATION_MS 1000
 
-void VolumeMeter::ClipEnding()
-{
-	clipping = false;
-}
-
 inline int VolumeMeter::convertToInt(float number)
 {
 	constexpr int min = std::numeric_limits<int>::min();
@@ -1264,7 +1259,7 @@ void VolumeMeter::paintHMeter(QPainter &painter, int x, int y, int width,
 	} else if (int(magnitude) != 0) {
 		if (!clipping) {
 			QTimer::singleShot(CLIP_FLASH_DURATION_MS, this,
-					   SLOT(ClipEnding()));
+					   [&]() { clipping = false; });
 			clipping = true;
 		}
 
@@ -1376,7 +1371,7 @@ void VolumeMeter::paintVMeter(QPainter &painter, int x, int y, int width,
 	} else {
 		if (!clipping) {
 			QTimer::singleShot(CLIP_FLASH_DURATION_MS, this,
-					   SLOT(ClipEnding()));
+					   [&]() { clipping = false; });
 			clipping = true;
 		}
 

+ 0 - 3
UI/volume-control.hpp

@@ -94,9 +94,6 @@ class VolumeMeter : public QWidget {
 
 	friend class VolControl;
 
-private slots:
-	void ClipEnding();
-
 private:
 	obs_volmeter_t *obs_volmeter;
 	static QWeakPointer<VolumeMeterTimer> updateTimer;