mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-22 01:05:53 -05:00
adjust audio add to new UI
This commit is contained in:
@@ -12,9 +12,9 @@ constexpr auto audio_func = 8;
|
||||
constexpr auto default_priority_8 = audio_func;
|
||||
|
||||
struct AudioSwitch : virtual SceneSwitcherEntry {
|
||||
OBSWeakSource audioSource;
|
||||
int volumeThreshold;
|
||||
float peak;
|
||||
OBSWeakSource audioSource = nullptr;
|
||||
int volumeThreshold = 0;
|
||||
float peak = -1;
|
||||
std::string audioSwitchStr;
|
||||
obs_volmeter_t *volmeter = nullptr;
|
||||
|
||||
@@ -26,6 +26,7 @@ struct AudioSwitch : virtual SceneSwitcherEntry {
|
||||
const float inputPeak[MAX_AUDIO_CHANNELS]);
|
||||
void resetVolmeter();
|
||||
|
||||
inline AudioSwitch(){};
|
||||
inline AudioSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
|
||||
OBSWeakSource audioSource_, int volumeThreshold_,
|
||||
bool usePreviousScene_, std::string audioSwitchStr_);
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
#include <obs.hpp>
|
||||
|
||||
struct SceneSwitcherEntry {
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
bool usePreviousScene;
|
||||
OBSWeakSource scene = nullptr;
|
||||
OBSWeakSource transition = nullptr;
|
||||
bool usePreviousScene = false;
|
||||
|
||||
virtual bool valid()
|
||||
{
|
||||
@@ -28,7 +28,7 @@ struct SceneSwitcherEntry {
|
||||
getType(), sceneName);
|
||||
}
|
||||
|
||||
inline SceneSwitcherEntry() : usePreviousScene(false) {}
|
||||
inline SceneSwitcherEntry() {}
|
||||
|
||||
inline SceneSwitcherEntry(OBSWeakSource scene_,
|
||||
OBSWeakSource transition_,
|
||||
|
||||
@@ -80,55 +80,15 @@ int SceneSwitcher::audioFindByData(const QString &source, const int &volume)
|
||||
|
||||
void SceneSwitcher::on_audioAdd_clicked()
|
||||
{
|
||||
QString sceneName = ui->audioScenes->currentText();
|
||||
QString transitionName = ui->audioTransitions->currentText();
|
||||
QString audioSourceName = ui->audioSources->currentText();
|
||||
int vol = ui->audioVolumeThreshold->value();
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->audioSwitches.emplace_back(AudioSwitch());
|
||||
|
||||
if (sceneName.isEmpty() || audioSourceName.isEmpty())
|
||||
return;
|
||||
|
||||
OBSWeakSource source = GetWeakSourceByQString(sceneName);
|
||||
OBSWeakSource audioSource = GetWeakSourceByQString(audioSourceName);
|
||||
OBSWeakSource transition = GetWeakTransitionByQString(transitionName);
|
||||
|
||||
QString text = MakeAudioSwitchName(sceneName, transitionName,
|
||||
audioSourceName, vol);
|
||||
QVariant v = QVariant::fromValue(text);
|
||||
|
||||
int idx = audioFindByData(audioSourceName, vol);
|
||||
|
||||
if (idx == -1) {
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->audioSwitches.emplace_back(
|
||||
source, transition, audioSource, vol,
|
||||
(sceneName == QString(previous_scene_name)),
|
||||
text.toUtf8().constData());
|
||||
QListWidgetItem *item =
|
||||
new QListWidgetItem(text, ui->audioSwitches);
|
||||
item->setData(Qt::UserRole, v);
|
||||
} else {
|
||||
QListWidgetItem *item = ui->audioSwitches->item(idx);
|
||||
item->setText(text);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->audioSwitches) {
|
||||
if (s.audioSource == audioSource &&
|
||||
s.volumeThreshold == vol) {
|
||||
s.scene = source;
|
||||
s.transition = transition;
|
||||
s.usePreviousScene =
|
||||
(sceneName ==
|
||||
QString(previous_scene_name));
|
||||
s.audioSwitchStr =
|
||||
text.toUtf8().constData();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
QListWidgetItem *item;
|
||||
item = new QListWidgetItem(ui->audioSwitches);
|
||||
ui->audioSwitches->addItem(item);
|
||||
AudioSwitchWidget *sw = new AudioSwitchWidget(&switcher->audioSwitches.back());
|
||||
item->setSizeHint(sw->minimumSizeHint());
|
||||
ui->audioSwitches->setItemWidget(item, sw);
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_audioRemove_clicked()
|
||||
@@ -300,14 +260,6 @@ void SceneSwitcher::setupAudioTab()
|
||||
: GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string audioSourceName = GetWeakSourceName(s.audioSource);
|
||||
QString listText = MakeAudioSwitchName(sceneName.c_str(),
|
||||
transitionName.c_str(),
|
||||
audioSourceName.c_str(),
|
||||
s.volumeThreshold);
|
||||
|
||||
//QListWidgetItem *item =
|
||||
// new QListWidgetItem(listText, ui->audioSwitches);
|
||||
//item->setData(Qt::UserRole, listText);
|
||||
|
||||
QListWidgetItem *item;
|
||||
item = new QListWidgetItem(ui->audioSwitches);
|
||||
|
||||
Reference in New Issue
Block a user