mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-08-22 01:05:53 -05:00
first draft of UI improvements
group settings of the general tab highlight if the scene switcher is inactive add draft of allowing editing in place define additional populate functions for audio and media
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -34,45 +34,6 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
loadUI();
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateSceneSelection(QComboBox *sel, bool addPrevious)
|
||||
{
|
||||
BPtr<char *> scenes = obs_frontend_get_scene_names();
|
||||
char **temp = scenes;
|
||||
while (*temp) {
|
||||
const char *name = *temp;
|
||||
sel->addItem(name);
|
||||
temp++;
|
||||
}
|
||||
|
||||
if (addPrevious)
|
||||
sel->addItem(previous_scene_name);
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateTransitionSelection(QComboBox *sel)
|
||||
{
|
||||
obs_frontend_source_list *transitions = new obs_frontend_source_list();
|
||||
obs_frontend_get_transitions(transitions);
|
||||
|
||||
for (size_t i = 0; i < transitions->sources.num; i++) {
|
||||
const char *name =
|
||||
obs_source_get_name(transitions->sources.array[i]);
|
||||
sel->addItem(name);
|
||||
}
|
||||
|
||||
obs_frontend_source_list_free(transitions);
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateWindowSelection(QComboBox *sel)
|
||||
{
|
||||
std::vector<std::string> windows;
|
||||
GetWindowList(windows);
|
||||
sort(windows.begin(), windows.end());
|
||||
|
||||
for (std::string &window : windows) {
|
||||
sel->addItem(window.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::loadUI()
|
||||
{
|
||||
#if __APPLE__
|
||||
@@ -237,7 +198,7 @@ void SwitcherData::Thread()
|
||||
break;
|
||||
case round_trip_func:
|
||||
checkSceneSequence(match, scene, transition,
|
||||
lock);
|
||||
lock);
|
||||
if (sceneChangedDuringWait()) //scene might have changed during the sleep
|
||||
{
|
||||
goto startLoop;
|
||||
@@ -343,6 +304,79 @@ void SwitcherData::Stop()
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateSceneSelection(QComboBox *sel, bool addPrevious)
|
||||
{
|
||||
BPtr<char *> scenes = obs_frontend_get_scene_names();
|
||||
char **temp = scenes;
|
||||
while (*temp) {
|
||||
const char *name = *temp;
|
||||
sel->addItem(name);
|
||||
temp++;
|
||||
}
|
||||
|
||||
if (addPrevious)
|
||||
sel->addItem(previous_scene_name);
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateTransitionSelection(QComboBox *sel)
|
||||
{
|
||||
obs_frontend_source_list *transitions = new obs_frontend_source_list();
|
||||
obs_frontend_get_transitions(transitions);
|
||||
|
||||
for (size_t i = 0; i < transitions->sources.num; i++) {
|
||||
const char *name =
|
||||
obs_source_get_name(transitions->sources.array[i]);
|
||||
sel->addItem(name);
|
||||
}
|
||||
|
||||
obs_frontend_source_list_free(transitions);
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateWindowSelection(QComboBox *sel)
|
||||
{
|
||||
std::vector<std::string> windows;
|
||||
GetWindowList(windows);
|
||||
sort(windows.begin(), windows.end());
|
||||
|
||||
for (std::string &window : windows) {
|
||||
sel->addItem(window.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateAudioSelection(QComboBox *sel)
|
||||
{
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
QComboBox *combo = reinterpret_cast<QComboBox *>(data);
|
||||
uint32_t flags = obs_source_get_output_flags(source);
|
||||
|
||||
if ((flags & OBS_SOURCE_AUDIO) != 0) {
|
||||
const char *name = obs_source_get_name(source);
|
||||
combo->addItem(name);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_enum_sources(sourceEnum, sel);
|
||||
}
|
||||
|
||||
void SceneSwitcher::populateMediaSelection(QComboBox *sel)
|
||||
{
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
QComboBox *combo = reinterpret_cast<QComboBox *>(data);
|
||||
std::string sourceId = obs_source_get_id(source);
|
||||
if (sourceId.compare("ffmpeg_source") == 0 ||
|
||||
sourceId.compare("vlc_source") == 0) {
|
||||
const char *name = obs_source_get_name(source);
|
||||
combo->addItem(name);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_enum_sources(sourceEnum, sel);
|
||||
}
|
||||
|
||||
/********************************************************************************
|
||||
* OBS module setup
|
||||
********************************************************************************/
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QGraphicsColorizeEffect>
|
||||
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
|
||||
@@ -79,16 +81,52 @@ void SceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
switcher->interval = value;
|
||||
}
|
||||
|
||||
void SceneSwitcher::StartInactivePulse()
|
||||
{
|
||||
ui->pluginRunningText->setStyleSheet("QLabel { \
|
||||
border-style: outset; \
|
||||
border-width: 2px; \
|
||||
border-radius: 10px; \
|
||||
border-color: rgb(0,0,0,0) \
|
||||
}");
|
||||
|
||||
QGraphicsColorizeEffect *eEffect =
|
||||
new QGraphicsColorizeEffect(ui->pluginRunningText);
|
||||
ui->pluginRunningText->setGraphicsEffect(eEffect);
|
||||
QPropertyAnimation *paAnimation =
|
||||
new QPropertyAnimation(eEffect, "color");
|
||||
paAnimation->setStartValue(QColor(0, 0, 0, 0));
|
||||
paAnimation->setEndValue(QColor(Qt::red));
|
||||
paAnimation->setDuration(1000);
|
||||
|
||||
connect(paAnimation, &QPropertyAnimation::finished, [paAnimation]() {
|
||||
if (switcher->stop)
|
||||
QTimer::singleShot(1000, [paAnimation] {
|
||||
paAnimation->start();
|
||||
});
|
||||
});
|
||||
|
||||
paAnimation->start();
|
||||
}
|
||||
|
||||
void SceneSwitcher::ResetInactivePulse()
|
||||
{
|
||||
ui->pluginRunningText->setStyleSheet(
|
||||
"QLabel { background-color: rgb(0,0,0,0); }");
|
||||
}
|
||||
|
||||
void SceneSwitcher::SetStarted()
|
||||
{
|
||||
ui->toggleStartButton->setText("Stop");
|
||||
ui->pluginRunningText->setText("Active");
|
||||
ResetInactivePulse();
|
||||
}
|
||||
|
||||
void SceneSwitcher::SetStopped()
|
||||
{
|
||||
ui->toggleStartButton->setText("Start");
|
||||
ui->pluginRunningText->setText("Inactive");
|
||||
StartInactivePulse();
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_toggleStartButton_clicked()
|
||||
|
||||
@@ -55,9 +55,6 @@ public:
|
||||
void SetAudioVolumeMeter(const QString &name);
|
||||
|
||||
void loadUI();
|
||||
void populateSceneSelection(QComboBox *sel, bool addPrevious);
|
||||
void populateTransitionSelection(QComboBox *sel);
|
||||
void populateWindowSelection(QComboBox *sel);
|
||||
void setupGeneralTab();
|
||||
void setupTitleTab();
|
||||
void setupExecutableTab();
|
||||
@@ -73,6 +70,13 @@ public:
|
||||
void setupAudioTab();
|
||||
void setTabOrder();
|
||||
|
||||
static void populateSceneSelection(QComboBox *sel,
|
||||
bool addPrevious = false);
|
||||
static void populateTransitionSelection(QComboBox *sel);
|
||||
static void populateWindowSelection(QComboBox *sel);
|
||||
static void populateAudioSelection(QComboBox *sel);
|
||||
static void populateMediaSelection(QComboBox *sel);
|
||||
|
||||
public slots:
|
||||
void on_switches_currentRowChanged(int idx);
|
||||
void on_up_clicked();
|
||||
@@ -85,6 +89,8 @@ public slots:
|
||||
void on_startupBehavior_currentIndexChanged(int index);
|
||||
void on_noMatchSwitchScene_currentTextChanged(const QString &text);
|
||||
void on_checkInterval_valueChanged(int value);
|
||||
void StartInactivePulse();
|
||||
void ResetInactivePulse();
|
||||
void on_toggleStartButton_clicked();
|
||||
void on_tabMoved(int from, int to);
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
#include <QComboBox>
|
||||
#include <QSpinBox>
|
||||
#include <QLabel>
|
||||
#include <string>
|
||||
|
||||
#include "utility.hpp"
|
||||
#include "switch-generic.hpp"
|
||||
#include "volume-control.hpp"
|
||||
|
||||
constexpr auto audio_func = 8;
|
||||
constexpr auto default_priority_8 = audio_func;
|
||||
@@ -113,3 +118,27 @@ static inline QString MakeAudioSwitchName(const QString &scene,
|
||||
const QString &transition,
|
||||
const QString &audioSrouce,
|
||||
const int &volume);
|
||||
|
||||
class AudioSwitchWidget : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
AudioSwitchWidget(QWidget *parent = nullptr,
|
||||
const QString &audioScene = "<none>",
|
||||
const QString &audioTransition = "<none>",
|
||||
const QString &audioSource = "<none>",
|
||||
const int &threshold = 0);
|
||||
|
||||
private:
|
||||
QComboBox *audioScenes;
|
||||
QComboBox *audioTransitions;
|
||||
QComboBox *audioSources;
|
||||
QSpinBox *audioVolumeThreshold;
|
||||
|
||||
VolControl *volMeter;
|
||||
|
||||
QLabel *whenLabel;
|
||||
QLabel *aboveLabel;
|
||||
QLabel *switchLabel;
|
||||
QLabel *usingLabel;
|
||||
};
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#include <QWidget>
|
||||
#include <QHBoxLayout>
|
||||
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include "headers/volume-control.hpp"
|
||||
|
||||
@@ -289,20 +292,7 @@ void SceneSwitcher::setupAudioTab()
|
||||
{
|
||||
populateSceneSelection(ui->audioScenes, true);
|
||||
populateTransitionSelection(ui->audioTransitions);
|
||||
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
QComboBox *combo = reinterpret_cast<QComboBox *>(data);
|
||||
uint32_t flags = obs_source_get_output_flags(source);
|
||||
|
||||
if ((flags & OBS_SOURCE_AUDIO) != 0) {
|
||||
const char *name = obs_source_get_name(source);
|
||||
combo->addItem(name);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_enum_sources(sourceEnum, ui->audioSources);
|
||||
populateAudioSelection(ui->audioSources);
|
||||
|
||||
for (auto &s : switcher->audioSwitches) {
|
||||
std::string sceneName = (s.usePreviousScene)
|
||||
@@ -315,9 +305,18 @@ void SceneSwitcher::setupAudioTab()
|
||||
audioSourceName.c_str(),
|
||||
s.volumeThreshold);
|
||||
|
||||
QListWidgetItem *item =
|
||||
new QListWidgetItem(listText, ui->audioSwitches);
|
||||
item->setData(Qt::UserRole, listText);
|
||||
//QListWidgetItem *item =
|
||||
// new QListWidgetItem(listText, ui->audioSwitches);
|
||||
//item->setData(Qt::UserRole, listText);
|
||||
|
||||
QListWidgetItem *item;
|
||||
item = new QListWidgetItem(ui->audioSwitches);
|
||||
ui->audioSwitches->addItem(item);
|
||||
AudioSwitchWidget *sw = new AudioSwitchWidget(
|
||||
nullptr, sceneName.c_str(), transitionName.c_str(),
|
||||
audioSourceName.c_str(), s.volumeThreshold);
|
||||
item->setSizeHint(sw->minimumSizeHint());
|
||||
ui->audioSwitches->setItemWidget(item, sw);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -333,3 +332,64 @@ static inline QString MakeAudioSwitchName(const QString &scene,
|
||||
QStringLiteral(" using ") + transition;
|
||||
return switchName;
|
||||
}
|
||||
|
||||
AudioSwitchWidget::AudioSwitchWidget(QWidget *parent, const QString &audioScene,
|
||||
const QString &audioTransition,
|
||||
const QString &audioSource,
|
||||
const int &threshold)
|
||||
: QWidget(parent)
|
||||
{
|
||||
audioScenes = new QComboBox();
|
||||
audioTransitions = new QComboBox();
|
||||
audioSources = new QComboBox();
|
||||
audioVolumeThreshold = new QSpinBox();
|
||||
|
||||
obs_source_t *soruce =
|
||||
obs_get_source_by_name(audioSource.toUtf8().constData());
|
||||
volMeter = new VolControl(soruce);
|
||||
obs_source_release(soruce);
|
||||
|
||||
whenLabel = new QLabel("When the volume of");
|
||||
aboveLabel = new QLabel("is above");
|
||||
switchLabel = new QLabel("switch to");
|
||||
usingLabel = new QLabel("using");
|
||||
|
||||
audioVolumeThreshold->setSuffix("%");
|
||||
audioVolumeThreshold->setMaximum(100);
|
||||
audioVolumeThreshold->setMinimum(0);
|
||||
|
||||
QWidget::connect(volMeter->GetSlider(), SIGNAL(valueChanged(int)),
|
||||
audioVolumeThreshold, SLOT(setValue(int)));
|
||||
QWidget::connect(audioVolumeThreshold, SIGNAL(valueChanged(int)),
|
||||
volMeter->GetSlider(), SLOT(setValue(int)));
|
||||
|
||||
SceneSwitcher::populateSceneSelection(audioScenes, true);
|
||||
SceneSwitcher::populateTransitionSelection(audioTransitions);
|
||||
SceneSwitcher::populateAudioSelection(audioSources);
|
||||
|
||||
audioScenes->setCurrentText(audioScene);
|
||||
audioTransitions->setCurrentText(audioTransition);
|
||||
audioSources->setCurrentText(audioSource);
|
||||
audioVolumeThreshold->setValue(threshold);
|
||||
|
||||
setStyleSheet("* { background-color: transparent; }");
|
||||
|
||||
QHBoxLayout *switchLayout = new QHBoxLayout;
|
||||
|
||||
switchLayout->addWidget(whenLabel);
|
||||
switchLayout->addWidget(audioSources);
|
||||
switchLayout->addWidget(aboveLabel);
|
||||
switchLayout->addWidget(audioVolumeThreshold);
|
||||
switchLayout->addWidget(switchLabel);
|
||||
switchLayout->addWidget(audioScenes);
|
||||
switchLayout->addWidget(usingLabel);
|
||||
switchLayout->addWidget(audioTransitions);
|
||||
switchLayout->addStretch();
|
||||
|
||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||
|
||||
mainLayout->addLayout(switchLayout);
|
||||
mainLayout->addWidget(volMeter);
|
||||
|
||||
setLayout(mainLayout);
|
||||
}
|
||||
|
||||
@@ -254,20 +254,7 @@ void SceneSwitcher::setupMediaTab()
|
||||
{
|
||||
populateSceneSelection(ui->mediaScenes, true);
|
||||
populateTransitionSelection(ui->mediaTransitions);
|
||||
|
||||
auto sourceEnum = [](void *data, obs_source_t *source) -> bool /* -- */
|
||||
{
|
||||
QComboBox *combo = reinterpret_cast<QComboBox *>(data);
|
||||
std::string sourceId = obs_source_get_id(source);
|
||||
if (sourceId.compare("ffmpeg_source") == 0 ||
|
||||
sourceId.compare("vlc_source") == 0) {
|
||||
const char *name = obs_source_get_name(source);
|
||||
combo->addItem(name);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_enum_sources(sourceEnum, ui->mediaSources);
|
||||
populateMediaSelection(ui->mediaSources);
|
||||
|
||||
ui->mediaStates->addItem("None");
|
||||
ui->mediaStates->addItem("Playing");
|
||||
|
||||
Reference in New Issue
Block a user