From b82a49e88166b55a799a08e4ca7e3f39ec827acb Mon Sep 17 00:00:00 2001 From: cg2121 Date: Tue, 13 Feb 2024 03:41:48 -0600 Subject: [PATCH] UI: Use OBSSourceLabel for VolControl The OBSSourceLabel handles renaming of a source, so we don't have to use the rename signals for volume controls. --- UI/volume-control.cpp | 13 ++----------- UI/volume-control.hpp | 6 ++---- UI/window-basic-main.cpp | 5 ----- 3 files changed, 4 insertions(+), 20 deletions(-) diff --git a/UI/volume-control.cpp b/UI/volume-control.cpp index e4b6125e4..a900a3fa7 100644 --- a/UI/volume-control.cpp +++ b/UI/volume-control.cpp @@ -5,6 +5,7 @@ #include "mute-checkbox.hpp" #include "slider-ignorewheel.hpp" #include "slider-absoluteset-style.hpp" +#include "source-label.hpp" #include #include #include @@ -219,16 +220,6 @@ void VolControl::updateText() slider->setAccessibleName(accText); } -QString VolControl::GetName() const -{ - return nameLabel->text(); -} - -void VolControl::SetName(const QString &newName) -{ - nameLabel->setText(newName); -} - void VolControl::EmitConfigClicked() { emit ConfigClicked(); @@ -253,7 +244,7 @@ VolControl::VolControl(OBSSource source_, bool showConfig, bool vertical) vertical(vertical), contextMenu(nullptr) { - nameLabel = new QLabel(); + nameLabel = new OBSSourceLabel(source); volLabel = new QLabel(); mute = new MuteCheckBox(); diff --git a/UI/volume-control.hpp b/UI/volume-control.hpp index ecc7b23f9..5f9a6762f 100644 --- a/UI/volume-control.hpp +++ b/UI/volume-control.hpp @@ -272,6 +272,7 @@ protected: class QLabel; class QSlider; class MuteCheckBox; +class OBSSourceLabel; class VolControl : public QWidget { Q_OBJECT @@ -279,7 +280,7 @@ class VolControl : public QWidget { private: OBSSource source; std::vector sigs; - QLabel *nameLabel; + OBSSourceLabel *nameLabel; QLabel *volLabel; VolumeMeter *volMeter; QSlider *slider; @@ -321,9 +322,6 @@ public: inline obs_source_t *GetSource() const { return source; } - QString GetName() const; - void SetName(const QString &newName); - void SetMeterDecayRate(qreal q); void setPeakMeterType(enum obs_peak_meter_type peakMeterType); diff --git a/UI/window-basic-main.cpp b/UI/window-basic-main.cpp index 46d40389b..591a91e48 100644 --- a/UI/window-basic-main.cpp +++ b/UI/window-basic-main.cpp @@ -3339,11 +3339,6 @@ void OBSBasic::RenameSources(OBSSource source, QString newName, { RenameListValues(ui->scenes, newName, prevName); - for (size_t i = 0; i < volumes.size(); i++) { - if (volumes[i]->GetName().compare(prevName) == 0) - volumes[i]->SetName(newName); - } - if (vcamConfig.type == VCamOutputType::SourceOutput && prevName == QString::fromStdString(vcamConfig.source)) vcamConfig.source = newName.toStdString();