mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-08 09:36:07 -05:00
remove using namespace std
This commit is contained in:
@@ -34,7 +34,7 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
switcher->Prune();
|
||||
|
||||
@@ -128,11 +128,11 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
GetWeakSourceName(switcher->nonMatchingScene).c_str());
|
||||
ui->checkInterval->setValue(switcher->interval);
|
||||
|
||||
vector<string> windows;
|
||||
std::vector<std::string> windows;
|
||||
GetWindowList(windows);
|
||||
sort(windows.begin(), windows.end());
|
||||
|
||||
for (string &window : windows) {
|
||||
for (std::string &window : windows) {
|
||||
ui->windows->addItem(window.c_str());
|
||||
ui->ignoreWindowsWindows->addItem(window.c_str());
|
||||
ui->pauseWindowsWindows->addItem(window.c_str());
|
||||
@@ -145,8 +145,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
ui->executable->addItem(process);
|
||||
|
||||
for (auto &s : switcher->executableSwitches) {
|
||||
string sceneName = GetWeakSourceName(s.mScene);
|
||||
string transitionName = GetWeakSourceName(s.mTransition);
|
||||
std::string sceneName = GetWeakSourceName(s.mScene);
|
||||
std::string transitionName = GetWeakSourceName(s.mTransition);
|
||||
QString text = MakeSwitchNameExecutable(sceneName.c_str(),
|
||||
s.mExe,
|
||||
transitionName.c_str(),
|
||||
@@ -158,8 +158,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &s : switcher->windowSwitches) {
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString text = MakeSwitchName(sceneName.c_str(),
|
||||
s.window.c_str(),
|
||||
transitionName.c_str(),
|
||||
@@ -170,8 +170,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &s : switcher->screenRegionSwitches) {
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString text = MakeScreenRegionSwitchName(
|
||||
sceneName.c_str(), transitionName.c_str(), s.minX,
|
||||
s.minY, s.maxX, s.maxY);
|
||||
@@ -192,7 +192,7 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &scene : switcher->pauseScenesSwitches) {
|
||||
string sceneName = GetWeakSourceName(scene);
|
||||
std::string sceneName = GetWeakSourceName(scene);
|
||||
QString text = QString::fromStdString(sceneName);
|
||||
|
||||
QListWidgetItem *item =
|
||||
@@ -218,11 +218,11 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
|
||||
int smallestDelay = switcher->interval;
|
||||
for (auto &s : switcher->sceneRoundTripSwitches) {
|
||||
string sceneName1 = GetWeakSourceName(s.scene1);
|
||||
string sceneName2 = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene2);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName1 = GetWeakSourceName(s.scene1);
|
||||
std::string sceneName2 = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene2);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString text = MakeSceneRoundTripSwitchName(
|
||||
sceneName1.c_str(), sceneName2.c_str(),
|
||||
transitionName.c_str(), (double)s.delay / 1000);
|
||||
@@ -239,9 +239,9 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
: ui->intervalWarning->setVisible(false);
|
||||
|
||||
for (auto &s : switcher->sceneTransitions) {
|
||||
string sceneName1 = GetWeakSourceName(s.scene1);
|
||||
string sceneName2 = GetWeakSourceName(s.scene2);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName1 = GetWeakSourceName(s.scene1);
|
||||
std::string sceneName2 = GetWeakSourceName(s.scene2);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString text = MakeSceneTransitionName(sceneName1.c_str(),
|
||||
sceneName2.c_str(),
|
||||
transitionName.c_str());
|
||||
@@ -253,8 +253,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
//(transitionDurationLongerThanInterval(switcher->interval)) ? ui->transitionWarning->setVisible(true) : ui->transitionWarning->setVisible(false);
|
||||
|
||||
for (auto &s : switcher->defaultSceneTransitions) {
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString text = MakeDefaultSceneTransitionName(
|
||||
sceneName.c_str(), transitionName.c_str());
|
||||
|
||||
@@ -272,8 +272,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &s : switcher->randomSwitches) {
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString text = MakeRandomSwitchName(
|
||||
sceneName.c_str(), transitionName.c_str(), s.delay);
|
||||
|
||||
@@ -283,8 +283,8 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &s : switcher->fileSwitches) {
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString listText = MakeFileSwitchName(
|
||||
sceneName.c_str(), transitionName.c_str(),
|
||||
s.file.c_str(), s.text.c_str(), s.useRegex, s.useTime);
|
||||
@@ -295,11 +295,11 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &s : switcher->mediaSwitches) {
|
||||
string sourceName = GetWeakSourceName(s.source);
|
||||
string sceneName = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sourceName = GetWeakSourceName(s.source);
|
||||
std::string sceneName = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString listText = MakeMediaSwitchName(
|
||||
sourceName.c_str(), sceneName.c_str(),
|
||||
transitionName.c_str(), s.state, s.restriction, s.time);
|
||||
@@ -310,10 +310,10 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
}
|
||||
|
||||
for (auto &s : switcher->timeSwitches) {
|
||||
string sceneName = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = (s.usePreviousScene)
|
||||
? PREVIOUS_SCENE_NAME
|
||||
: GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
QString listText = MakeTimeSwitchName(
|
||||
sceneName.c_str(), transitionName.c_str(), s.time);
|
||||
|
||||
@@ -369,7 +369,7 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
screenRegionTimer->start(1000);
|
||||
|
||||
for (int p : switcher->functionNamesByPriority) {
|
||||
string s = "";
|
||||
std::string s = "";
|
||||
switch (p) {
|
||||
case READ_FILE_FUNC:
|
||||
s = "File Content";
|
||||
@@ -422,9 +422,9 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
||||
static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
{
|
||||
if (saving) {
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
obs_data_t *obj = obs_data_create();
|
||||
obs_data_array_t *array = obs_data_array_create();
|
||||
obs_data_array_t *windowTitleArray = obs_data_array_create();
|
||||
obs_data_array_t *screenRegionArray = obs_data_array_create();
|
||||
obs_data_array_t *pauseScenesArray = obs_data_array_create();
|
||||
obs_data_array_t *pauseWindowsArray = obs_data_array_create();
|
||||
@@ -465,7 +465,8 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_set_bool(array_obj, "fullscreen",
|
||||
s.fullscreen);
|
||||
obs_data_set_bool(array_obj, "focus", s.focus);
|
||||
obs_data_array_push_back(array, array_obj);
|
||||
obs_data_array_push_back(windowTitleArray,
|
||||
array_obj);
|
||||
obs_source_release(source);
|
||||
obs_source_release(transition);
|
||||
}
|
||||
@@ -522,7 +523,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
for (string &window : switcher->pauseWindowsSwitches) {
|
||||
for (std::string &window : switcher->pauseWindowsSwitches) {
|
||||
obs_data_t *array_obj = obs_data_create();
|
||||
obs_data_set_string(array_obj, "pauseWindow",
|
||||
window.c_str());
|
||||
@@ -530,7 +531,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
for (string &window : switcher->ignoreWindowsSwitches) {
|
||||
for (std::string &window : switcher->ignoreWindowsSwitches) {
|
||||
obs_data_t *array_obj = obs_data_create();
|
||||
obs_data_set_string(array_obj, "ignoreWindow",
|
||||
window.c_str());
|
||||
@@ -710,7 +711,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
for (string &window : switcher->ignoreIdleWindows) {
|
||||
for (std::string &window : switcher->ignoreIdleWindows) {
|
||||
obs_data_t *array_obj = obs_data_create();
|
||||
obs_data_set_string(array_obj, "window",
|
||||
window.c_str());
|
||||
@@ -819,7 +820,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
string nonMatchingSceneName =
|
||||
std::string nonMatchingSceneName =
|
||||
GetWeakSourceName(switcher->nonMatchingScene);
|
||||
|
||||
obs_data_set_int(obj, "interval", switcher->interval);
|
||||
@@ -829,7 +830,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
switcher->switchIfNotMatching);
|
||||
obs_data_set_bool(obj, "active", !switcher->stop);
|
||||
|
||||
obs_data_set_array(obj, "switches", array);
|
||||
obs_data_set_array(obj, "switches", windowTitleArray);
|
||||
obs_data_set_array(obj, "screenRegion", screenRegionArray);
|
||||
obs_data_set_array(obj, "pauseScenes", pauseScenesArray);
|
||||
obs_data_set_array(obj, "pauseWindows", pauseWindowsArray);
|
||||
@@ -847,16 +848,16 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_set_array(obj, "mediaSwitches", mediaArray);
|
||||
obs_data_set_array(obj, "timeSwitches", timeArray);
|
||||
|
||||
string autoStopSceneName =
|
||||
std::string autoStopSceneName =
|
||||
GetWeakSourceName(switcher->autoStopScene);
|
||||
obs_data_set_bool(obj, "autoStopEnable",
|
||||
switcher->autoStopEnable);
|
||||
obs_data_set_string(obj, "autoStopSceneName",
|
||||
autoStopSceneName.c_str());
|
||||
|
||||
string idleSceneName =
|
||||
std::string idleSceneName =
|
||||
GetWeakSourceName(switcher->idleData.scene);
|
||||
string idleTransitionName =
|
||||
std::string idleTransitionName =
|
||||
GetWeakSourceName(switcher->idleData.transition);
|
||||
obs_data_set_bool(obj, "idleEnable",
|
||||
switcher->idleData.idleEnable);
|
||||
@@ -899,7 +900,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
|
||||
obs_data_set_obj(save_data, "advanced-scene-switcher", obj);
|
||||
|
||||
obs_data_array_release(array);
|
||||
obs_data_array_release(windowTitleArray);
|
||||
obs_data_array_release(screenRegionArray);
|
||||
obs_data_array_release(pauseScenesArray);
|
||||
obs_data_array_release(pauseWindowsArray);
|
||||
@@ -920,7 +921,8 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
|
||||
obs_data_t *obj =
|
||||
obs_data_get_obj(save_data, "advanced-scene-switcher");
|
||||
obs_data_array_t *array = obs_data_get_array(obj, "switches");
|
||||
obs_data_array_t *windowTitleArray =
|
||||
obs_data_get_array(obj, "switches");
|
||||
obs_data_array_t *screenRegionArray =
|
||||
obs_data_get_array(obj, "screenRegion");
|
||||
obs_data_array_t *pauseScenesArray =
|
||||
@@ -958,7 +960,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
NO_SWITCH);
|
||||
switcher->switchIfNotMatching = (NoMatch)obs_data_get_int(
|
||||
obj, "switch_if_not_matching");
|
||||
string nonMatchingScene =
|
||||
std::string nonMatchingScene =
|
||||
obs_data_get_string(obj, "non_matching_scene");
|
||||
bool active = obs_data_get_bool(obj, "active");
|
||||
|
||||
@@ -966,10 +968,11 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
GetWeakSourceByName(nonMatchingScene.c_str());
|
||||
|
||||
switcher->windowSwitches.clear();
|
||||
size_t count = obs_data_array_count(array);
|
||||
size_t count = obs_data_array_count(windowTitleArray);
|
||||
|
||||
for (size_t i = 0; i < count; i++) {
|
||||
obs_data_t *array_obj = obs_data_array_item(array, i);
|
||||
obs_data_t *array_obj =
|
||||
obs_data_array_item(windowTitleArray, i);
|
||||
|
||||
const char *scene =
|
||||
obs_data_get_string(array_obj, "scene");
|
||||
@@ -1006,7 +1009,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
int minY = obs_data_get_int(array_obj, "minY");
|
||||
int maxX = obs_data_get_int(array_obj, "maxX");
|
||||
int maxY = obs_data_get_int(array_obj, "maxY");
|
||||
string regionStr = obs_data_get_string(
|
||||
std::string regionStr = obs_data_get_string(
|
||||
array_obj, "screenRegionStr");
|
||||
|
||||
switcher->screenRegionSwitches.emplace_back(
|
||||
@@ -1085,11 +1088,11 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_get_int(
|
||||
array_obj,
|
||||
"sceneRoundTripDelayMs"); //to be compatible with older versions
|
||||
string str = MakeSceneRoundTripSwitchName(
|
||||
scene1, scene2, transition,
|
||||
((double)delay) / 1000.0)
|
||||
.toUtf8()
|
||||
.constData();
|
||||
std::string str = MakeSceneRoundTripSwitchName(
|
||||
scene1, scene2, transition,
|
||||
((double)delay) / 1000.0)
|
||||
.toUtf8()
|
||||
.constData();
|
||||
const char *sceneRoundTripStr = str.c_str();
|
||||
|
||||
switcher->sceneRoundTripSwitches.emplace_back(
|
||||
@@ -1257,11 +1260,11 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
array_obj, "restriction");
|
||||
uint64_t time = obs_data_get_int(array_obj, "time");
|
||||
|
||||
string mediaStr = MakeMediaSwitchName(source, scene,
|
||||
transition, state,
|
||||
restriction, time)
|
||||
.toUtf8()
|
||||
.constData();
|
||||
std::string mediaStr =
|
||||
MakeMediaSwitchName(source, scene, transition,
|
||||
state, restriction, time)
|
||||
.toUtf8()
|
||||
.constData();
|
||||
|
||||
switcher->mediaSwitches.emplace_back(
|
||||
GetWeakSourceByName(scene),
|
||||
@@ -1288,7 +1291,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
QTime time = QTime::fromString(
|
||||
obs_data_get_string(array_obj, "time"));
|
||||
|
||||
string timeSwitchStr =
|
||||
std::string timeSwitchStr =
|
||||
MakeTimeSwitchName(scene, transition, time)
|
||||
.toUtf8()
|
||||
.constData();
|
||||
@@ -1302,16 +1305,16 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
obs_data_release(array_obj);
|
||||
}
|
||||
|
||||
string autoStopScene =
|
||||
std::string autoStopScene =
|
||||
obs_data_get_string(obj, "autoStopSceneName");
|
||||
switcher->autoStopEnable =
|
||||
obs_data_get_bool(obj, "autoStopEnable");
|
||||
switcher->autoStopScene =
|
||||
GetWeakSourceByName(autoStopScene.c_str());
|
||||
|
||||
string idleSceneName =
|
||||
std::string idleSceneName =
|
||||
obs_data_get_string(obj, "idleSceneName");
|
||||
string idleTransitionName =
|
||||
std::string idleTransitionName =
|
||||
obs_data_get_string(obj, "idleTransitionName");
|
||||
switcher->idleData.scene =
|
||||
GetWeakSourceByName(idleSceneName.c_str());
|
||||
@@ -1385,7 +1388,7 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
|
||||
switcher->threadPriority =
|
||||
obs_data_get_int(obj, "threadPriority");
|
||||
|
||||
obs_data_array_release(array);
|
||||
obs_data_array_release(windowTitleArray);
|
||||
obs_data_array_release(screenRegionArray);
|
||||
obs_data_array_release(pauseScenesArray);
|
||||
obs_data_array_release(ignoreWindowsArray);
|
||||
@@ -1417,21 +1420,21 @@ void SwitcherData::Thread()
|
||||
{
|
||||
blog(LOG_INFO, "Advanced Scene Switcher started");
|
||||
//to avoid scene duplication when rapidly switching scene collection
|
||||
this_thread::sleep_for(chrono::seconds(2));
|
||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
||||
|
||||
int sleep = 0;
|
||||
|
||||
while (true) {
|
||||
startLoop:
|
||||
unique_lock<mutex> lock(m);
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
bool match = false;
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
chrono::milliseconds duration;
|
||||
std::chrono::milliseconds duration;
|
||||
if (sleep > interval)
|
||||
duration = chrono::milliseconds(sleep);
|
||||
duration = std::chrono::milliseconds(sleep);
|
||||
else
|
||||
duration = chrono::milliseconds(interval);
|
||||
duration = std::chrono::milliseconds(interval);
|
||||
sleep = 0;
|
||||
switcher->Prune();
|
||||
writeSceneInfoToFile();
|
||||
@@ -1512,7 +1515,7 @@ endLoop:
|
||||
}
|
||||
|
||||
void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
unique_lock<mutex> &lock)
|
||||
std::unique_lock<std::mutex> &lock)
|
||||
{
|
||||
obs_source_t *source = obs_weak_source_get_source(scene);
|
||||
obs_source_t *currentSource = obs_frontend_get_current_scene();
|
||||
@@ -1605,7 +1608,7 @@ static void OBSEvent(enum obs_frontend_event event, void *switcher)
|
||||
|
||||
case OBS_FRONTEND_EVENT_SCENE_CHANGED: {
|
||||
SwitcherData *s = (SwitcherData *)switcher;
|
||||
lock_guard<mutex> lock(s->m);
|
||||
std::lock_guard<std::mutex> lock(s->m);
|
||||
//stop waiting if scene was manually changed
|
||||
if (s->sceneChangedDuringWait())
|
||||
s->cv.notify_one();
|
||||
|
||||
@@ -26,7 +26,7 @@ void SceneSwitcher::on_executables_currentRowChanged(int idx)
|
||||
|
||||
QString exec = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->executableSwitches) {
|
||||
if (exec.compare(s.mExe) == 0) {
|
||||
QString sceneName = GetWeakSourceName(s.mScene).c_str();
|
||||
@@ -50,7 +50,7 @@ void SceneSwitcher::on_executableUp_clicked()
|
||||
ui->executables->takeItem(index));
|
||||
ui->executables->setCurrentRow(index - 1);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
iter_swap(switcher->executableSwitches.begin() + index,
|
||||
switcher->executableSwitches.begin() + index - 1);
|
||||
@@ -65,7 +65,7 @@ void SceneSwitcher::on_executableDown_clicked()
|
||||
ui->executables->takeItem(index));
|
||||
ui->executables->setCurrentRow(index + 1);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
iter_swap(switcher->executableSwitches.begin() + index,
|
||||
switcher->executableSwitches.begin() + index + 1);
|
||||
@@ -92,7 +92,7 @@ void SceneSwitcher::on_executableAdd_clicked()
|
||||
int idx = executableFindByData(exeName);
|
||||
|
||||
if (idx == -1) {
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->executableSwitches.emplace_back(
|
||||
source, transition, exeName.toUtf8().constData(),
|
||||
inFocus);
|
||||
@@ -105,7 +105,7 @@ void SceneSwitcher::on_executableAdd_clicked()
|
||||
item->setText(text);
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->executableSwitches) {
|
||||
if (s.mExe == exeName) {
|
||||
s.mScene = source;
|
||||
@@ -127,7 +127,7 @@ void SceneSwitcher::on_executableRemove_clicked()
|
||||
QString exe = item->data(Qt::UserRole).toString();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->executableSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -146,7 +146,7 @@ void SceneSwitcher::on_executableRemove_clicked()
|
||||
void SwitcherData::checkExeSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
string title;
|
||||
std::string title;
|
||||
QStringList runningProcesses;
|
||||
bool ignored = false;
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ void SceneSwitcher::on_readFileCheckBox_stateChanged(int state)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (!state) {
|
||||
ui->browseButton_2->setDisabled(true);
|
||||
ui->readPathLineEdit->setDisabled(true);
|
||||
@@ -35,7 +35,7 @@ void SceneSwitcher::on_readPathLineEdit_textChanged(const QString &text)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (text.isEmpty()) {
|
||||
switcher->fileIO.readEnabled = false;
|
||||
return;
|
||||
@@ -49,7 +49,7 @@ void SceneSwitcher::on_writePathLineEdit_textChanged(const QString &text)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (text.isEmpty()) {
|
||||
switcher->fileIO.writeEnabled = false;
|
||||
return;
|
||||
@@ -196,7 +196,7 @@ void SceneSwitcher::on_fileAdd_clicked()
|
||||
new QListWidgetItem(switchText, ui->fileScenesList);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->fileSwitches.emplace_back(source, transition,
|
||||
fileName.toUtf8().constData(),
|
||||
text.toUtf8().constData(), useRegex,
|
||||
@@ -214,7 +214,7 @@ void SceneSwitcher::on_fileRemove_clicked()
|
||||
return;
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
auto &switches = switcher->fileSwitches;
|
||||
switches.erase(switches.begin() + idx);
|
||||
@@ -229,14 +229,14 @@ void SceneSwitcher::on_fileScenesList_currentRowChanged(int idx)
|
||||
if (idx == -1)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
if (switcher->fileSwitches.size() <= idx)
|
||||
return;
|
||||
FileSwitch s = switcher->fileSwitches[idx];
|
||||
|
||||
string sceneName = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string sceneName = GetWeakSourceName(s.scene);
|
||||
std::string transitionName = GetWeakSourceName(s.transition);
|
||||
|
||||
ui->fileScenes->setCurrentText(sceneName.c_str());
|
||||
ui->fileTransitions->setCurrentText(transitionName.c_str());
|
||||
|
||||
@@ -11,7 +11,7 @@ void SceneSwitcher::on_startAtLaunch_toggled(bool value)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->startAtLaunch = value;
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ void SceneSwitcher::on_noMatchDontSwitch_clicked()
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = NO_SWITCH;
|
||||
ui->noMatchSwitchScene->setEnabled(false);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ void SceneSwitcher::on_noMatchSwitch_clicked()
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = SWITCH;
|
||||
ui->noMatchSwitchScene->setEnabled(true);
|
||||
UpdateNonMatchingScene(ui->noMatchSwitchScene->currentText());
|
||||
@@ -52,7 +52,7 @@ void SceneSwitcher::on_noMatchRandomSwitch_clicked()
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->switchIfNotMatching = RANDOM_SWITCH;
|
||||
ui->noMatchSwitchScene->setEnabled(false);
|
||||
}
|
||||
@@ -62,7 +62,7 @@ void SceneSwitcher::on_noMatchSwitchScene_currentTextChanged(const QString &text
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateNonMatchingScene(text);
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ void SceneSwitcher::on_checkInterval_valueChanged(int value)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->interval = value;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,7 +152,7 @@ bool isFullscreen(std::string &title);
|
||||
/********************************************************************************
|
||||
* Screenregion helper
|
||||
********************************************************************************/
|
||||
pair<int, int> getCursorPos();
|
||||
std::pair<int, int> getCursorPos();
|
||||
|
||||
/********************************************************************************
|
||||
* Idle detection helper
|
||||
@@ -174,7 +174,7 @@ typedef struct obs_weak_source obs_weak_source_t;
|
||||
obs_weak_source_t *getNextTransition(obs_weak_source_t *scene1,
|
||||
obs_weak_source_t *scene2);
|
||||
void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
||||
unique_lock<mutex> &lock);
|
||||
std::unique_lock<std::mutex> &lock);
|
||||
|
||||
/********************************************************************************
|
||||
* Hotkey helper
|
||||
@@ -190,7 +190,7 @@ void startHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
|
||||
bool pressed);
|
||||
void startStopToggleHotkeyFunc(void *data, obs_hotkey_id id,
|
||||
obs_hotkey_t *hotkey, bool pressed);
|
||||
void loadKeybinding(obs_hotkey_id hotkeyId, string path);
|
||||
void loadKeybinding(obs_hotkey_id hotkeyId, std::string path);
|
||||
|
||||
/********************************************************************************
|
||||
* Main SwitcherData
|
||||
|
||||
@@ -34,14 +34,12 @@
|
||||
#define DEFAULT_PRIORITY_6 MEDIA_FUNC
|
||||
#define DEFAULT_PRIORITY_7 TIME_FUNC
|
||||
|
||||
using namespace std;
|
||||
|
||||
/********************************************************************************
|
||||
* Data structs for each scene switching method
|
||||
********************************************************************************/
|
||||
struct WindowSceneSwitch {
|
||||
OBSWeakSource scene;
|
||||
string window;
|
||||
std::string window;
|
||||
OBSWeakSource transition;
|
||||
bool fullscreen;
|
||||
bool focus;
|
||||
@@ -79,12 +77,12 @@ struct ScreenRegionSwitch {
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
int minX, minY, maxX, maxY;
|
||||
string regionStr;
|
||||
std::string regionStr;
|
||||
|
||||
inline ScreenRegionSwitch(OBSWeakSource scene_,
|
||||
OBSWeakSource transition_, int minX_,
|
||||
int minY_, int maxX_, int maxY_,
|
||||
string regionStr_)
|
||||
std::string regionStr_)
|
||||
: scene(scene_),
|
||||
transition(transition_),
|
||||
minX(minX_),
|
||||
@@ -102,12 +100,12 @@ struct SceneRoundTripSwitch {
|
||||
OBSWeakSource transition;
|
||||
int delay;
|
||||
bool usePreviousScene;
|
||||
string sceneRoundTripStr;
|
||||
std::string sceneRoundTripStr;
|
||||
|
||||
inline SceneRoundTripSwitch(OBSWeakSource scene1_,
|
||||
OBSWeakSource scene2_,
|
||||
OBSWeakSource transition_, int delay_,
|
||||
bool usePreviousScene_, string str)
|
||||
bool usePreviousScene_, std::string str)
|
||||
: scene1(scene1_),
|
||||
scene2(scene2_),
|
||||
transition(transition_),
|
||||
@@ -122,10 +120,10 @@ struct RandomSwitch {
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
double delay;
|
||||
string randomSwitchStr;
|
||||
std::string randomSwitchStr;
|
||||
|
||||
inline RandomSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
|
||||
double delay_, string str)
|
||||
double delay_, std::string str)
|
||||
: scene(scene_),
|
||||
transition(transition_),
|
||||
delay(delay_),
|
||||
@@ -138,11 +136,11 @@ struct SceneTransition {
|
||||
OBSWeakSource scene1;
|
||||
OBSWeakSource scene2;
|
||||
OBSWeakSource transition;
|
||||
string sceneTransitionStr;
|
||||
std::string sceneTransitionStr;
|
||||
|
||||
inline SceneTransition(OBSWeakSource scene1_, OBSWeakSource scene2_,
|
||||
OBSWeakSource transition_,
|
||||
string sceneTransitionStr_)
|
||||
std::string sceneTransitionStr_)
|
||||
: scene1(scene1_),
|
||||
scene2(scene2_),
|
||||
transition(transition_),
|
||||
@@ -154,11 +152,11 @@ struct SceneTransition {
|
||||
struct DefaultSceneTransition {
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
string sceneTransitionStr;
|
||||
std::string sceneTransitionStr;
|
||||
|
||||
inline DefaultSceneTransition(OBSWeakSource scene_,
|
||||
OBSWeakSource transition_,
|
||||
string sceneTransitionStr_)
|
||||
std::string sceneTransitionStr_)
|
||||
: scene(scene_),
|
||||
transition(transition_),
|
||||
sceneTransitionStr(sceneTransitionStr_)
|
||||
@@ -169,8 +167,8 @@ struct DefaultSceneTransition {
|
||||
struct FileSwitch {
|
||||
OBSWeakSource scene;
|
||||
OBSWeakSource transition;
|
||||
string file;
|
||||
string text;
|
||||
std::string file;
|
||||
std::string text;
|
||||
bool useRegex = false;
|
||||
bool useTime = false;
|
||||
QDateTime lastMod;
|
||||
@@ -191,9 +189,9 @@ struct FileSwitch {
|
||||
|
||||
struct FileIOData {
|
||||
bool readEnabled = false;
|
||||
string readPath;
|
||||
std::string readPath;
|
||||
bool writeEnabled = false;
|
||||
string writePath;
|
||||
std::string writePath;
|
||||
};
|
||||
|
||||
struct IdleData {
|
||||
@@ -238,11 +236,11 @@ struct TimeSwitch {
|
||||
QTime time;
|
||||
bool matched;
|
||||
bool usePreviousScene;
|
||||
string timeSwitchStr;
|
||||
std::string timeSwitchStr;
|
||||
|
||||
inline TimeSwitch(OBSWeakSource scene_, OBSWeakSource transition_,
|
||||
QTime time_, bool usePreviousScene_,
|
||||
string timeSwitchStr_)
|
||||
std::string timeSwitchStr_)
|
||||
: scene(scene_),
|
||||
transition(transition_),
|
||||
time(time_),
|
||||
@@ -262,11 +260,11 @@ class SwitcherThread;
|
||||
struct SwitcherData {
|
||||
SwitcherThread *th = nullptr;
|
||||
|
||||
condition_variable cv;
|
||||
mutex m;
|
||||
std::condition_variable cv;
|
||||
std::mutex m;
|
||||
bool transitionActive = false;
|
||||
bool waitForTransition = false;
|
||||
condition_variable transitionCv;
|
||||
std::condition_variable transitionCv;
|
||||
bool startAtLaunch = false;
|
||||
bool stop = false;
|
||||
|
||||
@@ -279,39 +277,39 @@ struct SwitcherData {
|
||||
OBSWeakSource nonMatchingScene;
|
||||
NoMatch switchIfNotMatching = NO_SWITCH;
|
||||
|
||||
vector<WindowSceneSwitch> windowSwitches;
|
||||
vector<string> ignoreIdleWindows;
|
||||
string lastTitle;
|
||||
std::vector<WindowSceneSwitch> windowSwitches;
|
||||
std::vector<std::string> ignoreIdleWindows;
|
||||
std::string lastTitle;
|
||||
|
||||
vector<ScreenRegionSwitch> screenRegionSwitches;
|
||||
std::vector<ScreenRegionSwitch> screenRegionSwitches;
|
||||
|
||||
vector<OBSWeakSource> pauseScenesSwitches;
|
||||
std::vector<OBSWeakSource> pauseScenesSwitches;
|
||||
|
||||
vector<string> pauseWindowsSwitches;
|
||||
std::vector<std::string> pauseWindowsSwitches;
|
||||
|
||||
vector<string> ignoreWindowsSwitches;
|
||||
std::vector<std::string> ignoreWindowsSwitches;
|
||||
|
||||
vector<SceneRoundTripSwitch> sceneRoundTripSwitches;
|
||||
std::vector<SceneRoundTripSwitch> sceneRoundTripSwitches;
|
||||
|
||||
vector<RandomSwitch> randomSwitches;
|
||||
std::vector<RandomSwitch> randomSwitches;
|
||||
|
||||
FileIOData fileIO;
|
||||
IdleData idleData;
|
||||
vector<FileSwitch> fileSwitches;
|
||||
std::vector<FileSwitch> fileSwitches;
|
||||
|
||||
vector<ExecutableSceneSwitch> executableSwitches;
|
||||
std::vector<ExecutableSceneSwitch> executableSwitches;
|
||||
|
||||
bool autoStopEnable = false;
|
||||
OBSWeakSource autoStopScene;
|
||||
|
||||
vector<SceneTransition> sceneTransitions;
|
||||
vector<DefaultSceneTransition> defaultSceneTransitions;
|
||||
std::vector<SceneTransition> sceneTransitions;
|
||||
std::vector<DefaultSceneTransition> defaultSceneTransitions;
|
||||
|
||||
vector<MediaSwitch> mediaSwitches;
|
||||
std::vector<MediaSwitch> mediaSwitches;
|
||||
|
||||
vector<TimeSwitch> timeSwitches;
|
||||
std::vector<TimeSwitch> timeSwitches;
|
||||
|
||||
vector<int> functionNamesByPriority = vector<int>{
|
||||
std::vector<int> functionNamesByPriority = std::vector<int>{
|
||||
DEFAULT_PRIORITY_0, DEFAULT_PRIORITY_1, DEFAULT_PRIORITY_2,
|
||||
DEFAULT_PRIORITY_3, DEFAULT_PRIORITY_4, DEFAULT_PRIORITY_5,
|
||||
DEFAULT_PRIORITY_6, DEFAULT_PRIORITY_7};
|
||||
@@ -355,7 +353,7 @@ struct SwitcherData {
|
||||
bool checkPause();
|
||||
void checkSceneRoundTrip(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition,
|
||||
unique_lock<mutex> &lock);
|
||||
std::unique_lock<std::mutex> &lock);
|
||||
void checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition);
|
||||
void checkWindowTitleSwitch(bool &match, OBSWeakSource &scene,
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <QString>
|
||||
#include <obs-frontend-api.h>
|
||||
#include "switcher-data-structs.hpp"
|
||||
using namespace std;
|
||||
|
||||
static inline bool WeakSourceValid(obs_weak_source_t *ws)
|
||||
{
|
||||
@@ -180,9 +179,9 @@ static inline QString MakeTimeSwitchName(const QString &scene,
|
||||
return switchName;
|
||||
}
|
||||
|
||||
static inline string GetWeakSourceName(obs_weak_source_t *weak_source)
|
||||
static inline std::string GetWeakSourceName(obs_weak_source_t *weak_source)
|
||||
{
|
||||
string name;
|
||||
std::string name;
|
||||
|
||||
obs_source_t *source = obs_weak_source_get_source(weak_source);
|
||||
if (source) {
|
||||
|
||||
@@ -16,15 +16,15 @@ void startHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
|
||||
|
||||
if (hotkeyData != NULL) {
|
||||
char *path = obs_module_config_path("");
|
||||
ofstream file;
|
||||
file.open(string(path).append(START_HOTKEY_PATH),
|
||||
ofstream::trunc);
|
||||
std::ofstream file;
|
||||
file.open(std::string(path).append(START_HOTKEY_PATH),
|
||||
std::ofstream::trunc);
|
||||
if (file.is_open()) {
|
||||
size_t num = obs_data_array_count(hotkeyData);
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
obs_data_t *data =
|
||||
obs_data_array_item(hotkeyData, i);
|
||||
string temp = obs_data_get_json(data);
|
||||
std::string temp = obs_data_get_json(data);
|
||||
obs_data_release(data);
|
||||
file << temp;
|
||||
}
|
||||
@@ -50,15 +50,15 @@ void stopHotkeyFunc(void *data, obs_hotkey_id id, obs_hotkey_t *hotkey,
|
||||
|
||||
if (hotkeyData != NULL) {
|
||||
char *path = obs_module_config_path("");
|
||||
ofstream file;
|
||||
file.open(string(path).append(STOP_HOTKEY_PATH),
|
||||
ofstream::trunc);
|
||||
std::ofstream file;
|
||||
file.open(std::string(path).append(STOP_HOTKEY_PATH),
|
||||
std::ofstream::trunc);
|
||||
if (file.is_open()) {
|
||||
size_t num = obs_data_array_count(hotkeyData);
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
obs_data_t *data =
|
||||
obs_data_array_item(hotkeyData, i);
|
||||
string temp = obs_data_get_json(data);
|
||||
std::string temp = obs_data_get_json(data);
|
||||
obs_data_release(data);
|
||||
file << temp;
|
||||
}
|
||||
@@ -86,15 +86,15 @@ void startStopToggleHotkeyFunc(void *data, obs_hotkey_id id,
|
||||
|
||||
if (hotkeyData != NULL) {
|
||||
char *path = obs_module_config_path("");
|
||||
ofstream file;
|
||||
file.open(string(path).append(TOGGLE_HOTKEY_PATH),
|
||||
ofstream::trunc);
|
||||
std::ofstream file;
|
||||
file.open(std::string(path).append(TOGGLE_HOTKEY_PATH),
|
||||
std::ofstream::trunc);
|
||||
if (file.is_open()) {
|
||||
size_t num = obs_data_array_count(hotkeyData);
|
||||
for (size_t i = 0; i < num; i++) {
|
||||
obs_data_t *data =
|
||||
obs_data_array_item(hotkeyData, i);
|
||||
string temp = obs_data_get_json(data);
|
||||
std::string temp = obs_data_get_json(data);
|
||||
obs_data_release(data);
|
||||
file << temp;
|
||||
}
|
||||
@@ -105,28 +105,28 @@ void startStopToggleHotkeyFunc(void *data, obs_hotkey_id id,
|
||||
obs_data_array_release(hotkeyData);
|
||||
}
|
||||
|
||||
string loadConfigFile(string filename)
|
||||
std::string loadConfigFile(std::string filename)
|
||||
{
|
||||
ifstream settingsFile;
|
||||
std::ifstream settingsFile;
|
||||
char *path = obs_module_config_path("");
|
||||
string value;
|
||||
std::string value;
|
||||
|
||||
settingsFile.open(string(path).append(filename));
|
||||
settingsFile.open(std::string(path).append(filename));
|
||||
if (settingsFile.is_open()) {
|
||||
settingsFile.seekg(0, ios::end);
|
||||
settingsFile.seekg(0, std::ios::end);
|
||||
value.reserve(settingsFile.tellg());
|
||||
settingsFile.seekg(0, ios::beg);
|
||||
value.assign((istreambuf_iterator<char>(settingsFile)),
|
||||
istreambuf_iterator<char>());
|
||||
settingsFile.seekg(0, std::ios::beg);
|
||||
value.assign((std::istreambuf_iterator<char>(settingsFile)),
|
||||
std::istreambuf_iterator<char>());
|
||||
settingsFile.close();
|
||||
}
|
||||
bfree(path);
|
||||
return value;
|
||||
}
|
||||
|
||||
void loadKeybinding(obs_hotkey_id hotkeyId, string path)
|
||||
void loadKeybinding(obs_hotkey_id hotkeyId, std::string path)
|
||||
{
|
||||
string bindings = loadConfigFile(path);
|
||||
std::string bindings = loadConfigFile(path);
|
||||
if (!bindings.empty()) {
|
||||
obs_data_array_t *hotkeyData = obs_data_array_create();
|
||||
obs_data_t *data = obs_data_create_from_json(bindings.c_str());
|
||||
|
||||
@@ -6,13 +6,13 @@ void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
||||
if (!idleData.idleEnable)
|
||||
return;
|
||||
|
||||
string title;
|
||||
std::string title;
|
||||
bool ignoreIdle = false;
|
||||
//lock.unlock();
|
||||
GetCurrentWindowTitle(title);
|
||||
//lock.lock();
|
||||
|
||||
for (string &window : ignoreIdleWindows) {
|
||||
for (std::string &window : ignoreIdleWindows) {
|
||||
if (window == title) {
|
||||
ignoreIdle = true;
|
||||
break;
|
||||
@@ -20,15 +20,15 @@ void SwitcherData::checkIdleSwitch(bool &match, OBSWeakSource &scene,
|
||||
}
|
||||
|
||||
if (!ignoreIdle) {
|
||||
for (string &window : ignoreIdleWindows) {
|
||||
for (std::string &window : ignoreIdleWindows) {
|
||||
try {
|
||||
bool matches =
|
||||
regex_match(title, regex(window));
|
||||
bool matches = std::regex_match(
|
||||
title, std::regex(window));
|
||||
if (matches) {
|
||||
ignoreIdle = true;
|
||||
break;
|
||||
}
|
||||
} catch (const regex_error &) {
|
||||
} catch (const std::regex_error &) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -50,7 +50,7 @@ void SceneSwitcher::on_idleCheckBox_stateChanged(int state)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (!state) {
|
||||
ui->idleScenes->setDisabled(true);
|
||||
ui->idleSpinBox->setDisabled(true);
|
||||
@@ -92,7 +92,7 @@ void SceneSwitcher::on_idleTransitions_currentTextChanged(const QString &text)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateIdleDataTransition(text);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ void SceneSwitcher::on_idleScenes_currentTextChanged(const QString &text)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateIdleDataScene(text);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ void SceneSwitcher::on_idleSpinBox_valueChanged(int i)
|
||||
{
|
||||
if (loading)
|
||||
return;
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->idleData.time = i;
|
||||
}
|
||||
|
||||
@@ -124,7 +124,7 @@ void SceneSwitcher::on_ignoreIdleWindows_currentRowChanged(int idx)
|
||||
|
||||
QString window = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &w : switcher->ignoreIdleWindows) {
|
||||
if (window.compare(w.c_str()) == 0) {
|
||||
ui->ignoreIdleWindowsWindows->setCurrentText(w.c_str());
|
||||
@@ -150,7 +150,7 @@ void SceneSwitcher::on_ignoreIdleAdd_clicked()
|
||||
new QListWidgetItem(windowName, ui->ignoreIdleWindows);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->ignoreIdleWindows.emplace_back(
|
||||
windowName.toUtf8().constData());
|
||||
ui->ignoreIdleWindows->sortItems();
|
||||
@@ -166,7 +166,7 @@ void SceneSwitcher::on_ignoreIdleRemove_clicked()
|
||||
QString windowName = item->data(Qt::UserRole).toString();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &windows = switcher->ignoreIdleWindows;
|
||||
|
||||
for (auto it = windows.begin(); it != windows.end(); ++it) {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
#include <util/platform.h>
|
||||
#include "../headers/advanced-scene-switcher.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
static Display *xdisplay = 0;
|
||||
|
||||
Display *disp()
|
||||
@@ -164,7 +162,7 @@ static std::string GetWindowTitle(size_t i)
|
||||
return windowTitle;
|
||||
}
|
||||
|
||||
void GetWindowList(vector<string> &windows)
|
||||
void GetWindowList(std::vector<std::string> &windows)
|
||||
{
|
||||
windows.resize(0);
|
||||
|
||||
@@ -185,7 +183,7 @@ void GetWindowList(QStringList &windows)
|
||||
}
|
||||
}
|
||||
|
||||
void GetCurrentWindowTitle(string &title)
|
||||
void GetCurrentWindowTitle(std::string &title)
|
||||
{
|
||||
if (!ewmhIsSupported()) {
|
||||
return;
|
||||
@@ -225,9 +223,9 @@ void GetCurrentWindowTitle(string &title)
|
||||
}
|
||||
}
|
||||
|
||||
pair<int, int> getCursorPos()
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
pair<int, int> pos(0, 0);
|
||||
std::pair<int, int> pos(0, 0);
|
||||
Display *dpy;
|
||||
Window root;
|
||||
Window ret_root;
|
||||
@@ -243,7 +241,7 @@ pair<int, int> getCursorPos()
|
||||
|
||||
if (XQueryPointer(dpy, root, &ret_root, &ret_child, &root_x, &root_y,
|
||||
&win_x, &win_y, &mask)) {
|
||||
pos = pair<int, int>(root_x, root_y);
|
||||
pos = std::pair<int, int>(root_x, root_y);
|
||||
}
|
||||
XCloseDisplay(dpy);
|
||||
return pos;
|
||||
@@ -255,7 +253,7 @@ bool isFullscreen(std::string &title)
|
||||
return false;
|
||||
|
||||
// Find switch in top level windows
|
||||
vector<Window> windows = getTopLevelWindows();
|
||||
std::vector<Window> windows = getTopLevelWindows();
|
||||
for (auto &window : windows) {
|
||||
XTextProperty text;
|
||||
int status = XGetTextProperty(
|
||||
@@ -306,7 +304,7 @@ void GetProcessList(QStringList &processes)
|
||||
{
|
||||
processes.clear();
|
||||
for (size_t i = 0; i < getTopLevelWindows().size(); ++i) {
|
||||
string s = GetWindowTitle(i);
|
||||
std::string s = GetWindowTitle(i);
|
||||
if (s != "")
|
||||
processes << QString::fromStdString(s);
|
||||
}
|
||||
@@ -314,7 +312,7 @@ void GetProcessList(QStringList &processes)
|
||||
|
||||
bool isInFocus(const QString &executable)
|
||||
{
|
||||
string current;
|
||||
std::string current;
|
||||
GetCurrentWindowTitle(current);
|
||||
|
||||
// True if executable switch equals current window
|
||||
|
||||
@@ -12,7 +12,7 @@ void SceneSwitcher::on_mediaSwitches_currentRowChanged(int idx)
|
||||
|
||||
QString mediaSceneStr = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->mediaSwitches) {
|
||||
if (mediaSceneStr.compare(s.mediaSwitchStr.c_str()) == 0) {
|
||||
QString sceneName = GetWeakSourceName(s.scene).c_str();
|
||||
@@ -60,7 +60,7 @@ void SceneSwitcher::on_mediaAdd_clicked()
|
||||
new QListWidgetItem(switchText, ui->mediaSwitches);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->mediaSwitches.emplace_back(
|
||||
scene, source, transition, state, restriction, time,
|
||||
(sceneName == QString(PREVIOUS_SCENE_NAME)),
|
||||
@@ -73,10 +73,10 @@ void SceneSwitcher::on_mediaRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string mediaStr =
|
||||
std::string mediaStr =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->mediaSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include <util/platform.h>
|
||||
#include "../headers/advanced-scene-switcher.hpp"
|
||||
|
||||
void GetWindowList(vector<string> &windows)
|
||||
void GetWindowList(std::vector<std::string> &windows)
|
||||
{
|
||||
windows.resize(0);
|
||||
|
||||
@@ -16,12 +16,12 @@ void GetWindowList(vector<string> &windows)
|
||||
kCGWindowListOptionAll, kCGNullWindowID);
|
||||
for (NSDictionary *app in apps) {
|
||||
// Construct string from NSString accounting for nil
|
||||
string name([[app objectForKey:@"kCGWindowName"]
|
||||
std::string name([[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
string owner([[app objectForKey:@"kCGWindowOwnerName"]
|
||||
std::string owner([[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
@@ -52,12 +52,12 @@ void GetWindowList(QStringList &windows)
|
||||
kCGWindowListOptionAll, kCGNullWindowID);
|
||||
for (NSDictionary *app in apps) {
|
||||
// Construct string from NSString accounting for nil
|
||||
string name([[app objectForKey:@"kCGWindowName"]
|
||||
std::string name([[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
string owner([[app objectForKey:@"kCGWindowOwnerName"]
|
||||
std::string owner([[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
@@ -76,7 +76,7 @@ void GetWindowList(QStringList &windows)
|
||||
}
|
||||
}
|
||||
|
||||
void GetCurrentWindowTitle(string &title)
|
||||
void GetCurrentWindowTitle(std::string &title)
|
||||
{
|
||||
title.resize(0);
|
||||
|
||||
@@ -91,13 +91,13 @@ void GetCurrentWindowTitle(string &title)
|
||||
// True if window is frontmost
|
||||
if (layer == 0) {
|
||||
// Construct string from NSString accounting for nil
|
||||
string name(
|
||||
std::string name(
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
string owner(
|
||||
std::string owner(
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
@@ -115,9 +115,9 @@ void GetCurrentWindowTitle(string &title)
|
||||
}
|
||||
}
|
||||
|
||||
pair<int, int> getCursorPos()
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
pair<int, int> pos(0, 0);
|
||||
std::pair<int, int> pos(0, 0);
|
||||
CGEventRef event = CGEventCreate(NULL);
|
||||
CGPoint cursorPos = CGEventGetLocation(event);
|
||||
CFRelease(event);
|
||||
@@ -126,7 +126,7 @@ pair<int, int> getCursorPos()
|
||||
return pos;
|
||||
}
|
||||
|
||||
bool isFullscreen(string &title)
|
||||
bool isFullscreen(std::string &title)
|
||||
{
|
||||
// Check for match
|
||||
@autoreleasepool {
|
||||
@@ -136,12 +136,12 @@ bool isFullscreen(string &title)
|
||||
kCGWindowListOptionAll, kCGNullWindowID);
|
||||
for (NSDictionary *app in apps) {
|
||||
// Construct string from NSString accounting for nil
|
||||
string name([[app objectForKey:@"kCGWindowName"]
|
||||
std::string name([[app objectForKey:@"kCGWindowName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
NSUTF8StringEncoding]);
|
||||
string owner([[app objectForKey:@"kCGWindowOwnerName"]
|
||||
std::string owner([[app objectForKey:@"kCGWindowOwnerName"]
|
||||
UTF8String],
|
||||
[[app objectForKey:@"kCGWindowOwnerName"]
|
||||
lengthOfBytesUsingEncoding:
|
||||
@@ -224,7 +224,7 @@ void GetProcessList(QStringList &list)
|
||||
|
||||
bool isInFocus(const QString &executable)
|
||||
{
|
||||
string current;
|
||||
std::string current;
|
||||
GetCurrentWindowTitle(current);
|
||||
|
||||
// True if executable switch equals current window
|
||||
|
||||
@@ -18,7 +18,7 @@ void SceneSwitcher::on_pauseScenesAdd_clicked()
|
||||
new QListWidgetItem(sceneName, ui->pauseScenes);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->pauseScenesSwitches.emplace_back(source);
|
||||
ui->pauseScenes->sortItems();
|
||||
}
|
||||
@@ -33,7 +33,7 @@ void SceneSwitcher::on_pauseScenesRemove_clicked()
|
||||
QString pauseScene = item->data(Qt::UserRole).toString();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->pauseScenesSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -66,7 +66,7 @@ void SceneSwitcher::on_pauseWindowsAdd_clicked()
|
||||
new QListWidgetItem(windowName, ui->pauseWindows);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->pauseWindowsSwitches.emplace_back(
|
||||
windowName.toUtf8().constData());
|
||||
ui->pauseWindows->sortItems();
|
||||
@@ -82,7 +82,7 @@ void SceneSwitcher::on_pauseWindowsRemove_clicked()
|
||||
QString windowName = item->data(Qt::UserRole).toString();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->pauseWindowsSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -109,9 +109,9 @@ void SceneSwitcher::on_pauseScenes_currentRowChanged(int idx)
|
||||
|
||||
QString scene = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->pauseScenesSwitches) {
|
||||
string name = GetWeakSourceName(s);
|
||||
std::string name = GetWeakSourceName(s);
|
||||
if (scene.compare(name.c_str()) == 0) {
|
||||
ui->pauseScenesScenes->setCurrentText(name.c_str());
|
||||
break;
|
||||
@@ -130,7 +130,7 @@ void SceneSwitcher::on_pauseWindows_currentRowChanged(int idx)
|
||||
|
||||
QString window = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->pauseWindowsSwitches) {
|
||||
if (window.compare(s.c_str()) == 0) {
|
||||
ui->pauseWindowsWindows->setCurrentText(s.c_str());
|
||||
@@ -190,12 +190,12 @@ bool SwitcherData::checkPause()
|
||||
obs_source_release(currentSource);
|
||||
obs_weak_source_release(ws);
|
||||
|
||||
string title;
|
||||
std::string title;
|
||||
if (!pause) {
|
||||
//lock.unlock();
|
||||
GetCurrentWindowTitle(title);
|
||||
//lock.lock();
|
||||
for (string &window : pauseWindowsSwitches) {
|
||||
for (std::string &window : pauseWindowsSwitches) {
|
||||
if (window == title) {
|
||||
pause = true;
|
||||
break;
|
||||
@@ -207,15 +207,15 @@ bool SwitcherData::checkPause()
|
||||
//lock.unlock();
|
||||
GetCurrentWindowTitle(title);
|
||||
//lock.lock();
|
||||
for (string &window : pauseWindowsSwitches) {
|
||||
for (std::string &window : pauseWindowsSwitches) {
|
||||
try {
|
||||
bool matches =
|
||||
regex_match(title, regex(window));
|
||||
bool matches = std::regex_match(
|
||||
title, std::regex(window));
|
||||
if (matches) {
|
||||
pause = true;
|
||||
break;
|
||||
}
|
||||
} catch (const regex_error &) {
|
||||
} catch (const std::regex_error &) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ void SceneSwitcher::on_threadPriority_currentTextChanged(const QString &text)
|
||||
ui->threadPriority->count() != switcher->threadPriorities.size())
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
for (auto p : switcher->threadPriorities) {
|
||||
if (p.name == text.toUtf8().constData()) {
|
||||
@@ -25,7 +25,7 @@ void SceneSwitcher::on_priorityUp_clicked()
|
||||
currentIndex - 1,
|
||||
ui->priorityList->takeItem(currentIndex));
|
||||
ui->priorityList->setCurrentRow(currentIndex - 1);
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
iter_swap(switcher->functionNamesByPriority.begin() +
|
||||
currentIndex,
|
||||
@@ -43,7 +43,7 @@ void SceneSwitcher::on_priorityDown_clicked()
|
||||
currentIndex + 1,
|
||||
ui->priorityList->takeItem(currentIndex));
|
||||
ui->priorityList->setCurrentRow(currentIndex + 1);
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
iter_swap(switcher->functionNamesByPriority.begin() +
|
||||
currentIndex,
|
||||
|
||||
@@ -12,7 +12,7 @@ void SceneSwitcher::on_randomScenesList_currentRowChanged(int idx)
|
||||
|
||||
QString randomSceneStr = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->randomSwitches) {
|
||||
if (randomSceneStr.compare(s.randomSwitchStr.c_str()) == 0) {
|
||||
QString sceneName = GetWeakSourceName(s.scene).c_str();
|
||||
@@ -59,7 +59,7 @@ void SceneSwitcher::on_randomAdd_clicked()
|
||||
int idx = randomFindByData(text);
|
||||
|
||||
if (idx == -1) {
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->randomSwitches.emplace_back(
|
||||
source, transition, delay, text.toUtf8().constData());
|
||||
|
||||
@@ -71,7 +71,7 @@ void SceneSwitcher::on_randomAdd_clicked()
|
||||
item->setText(text);
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->randomSwitches) {
|
||||
if (s.scene == source) {
|
||||
s.delay = delay;
|
||||
@@ -94,10 +94,11 @@ void SceneSwitcher::on_randomRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string text = item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
std::string text =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->randomSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -119,7 +120,7 @@ void SwitcherData::checkRandom(bool &match, OBSWeakSource &scene,
|
||||
if (randomSwitches.size() == 0)
|
||||
return;
|
||||
|
||||
vector<RandomSwitch> rs(randomSwitches);
|
||||
std::vector<RandomSwitch> rs(randomSwitches);
|
||||
std::random_device rng;
|
||||
std::mt19937 urng(rng());
|
||||
std::shuffle(rs.begin(), rs.end(), urng);
|
||||
|
||||
@@ -33,7 +33,7 @@ void SceneSwitcher::on_sceneRoundTripAdd_clicked()
|
||||
new QListWidgetItem(text, ui->sceneRoundTrips);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->sceneRoundTripSwitches.emplace_back(
|
||||
source1, source2, transition, int(delay * 1000),
|
||||
(scene2Name == QString(PREVIOUS_SCENE_NAME)),
|
||||
@@ -43,7 +43,7 @@ void SceneSwitcher::on_sceneRoundTripAdd_clicked()
|
||||
item->setText(text);
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->sceneRoundTripSwitches) {
|
||||
if (s.scene1 == source1) {
|
||||
s.scene2 = source2;
|
||||
@@ -69,10 +69,11 @@ void SceneSwitcher::on_sceneRoundTripRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string text = item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
std::string text =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->sceneRoundTripSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -93,7 +94,7 @@ void SceneSwitcher::on_autoStopSceneCheckBox_stateChanged(int state)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
if (!state) {
|
||||
ui->autoStopScenes->setDisabled(true);
|
||||
switcher->autoStopEnable = false;
|
||||
@@ -119,7 +120,7 @@ void SceneSwitcher::on_autoStopScenes_currentTextChanged(const QString &text)
|
||||
if (loading)
|
||||
return;
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
UpdateAutoStopScene(text);
|
||||
}
|
||||
|
||||
@@ -156,7 +157,7 @@ void SceneSwitcher::on_sceneRoundTripSave_clicked()
|
||||
|
||||
void SceneSwitcher::on_sceneRoundTripLoad_clicked()
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
QString directory = QFileDialog::getOpenFileName(
|
||||
this, tr("Select a file to read Scene Round Trip from ..."),
|
||||
@@ -167,9 +168,9 @@ void SceneSwitcher::on_sceneRoundTripLoad_clicked()
|
||||
return;
|
||||
|
||||
QTextStream in(&file);
|
||||
vector<QString> lines;
|
||||
std::vector<QString> lines;
|
||||
|
||||
vector<SceneRoundTripSwitch> newSceneRoundTripSwitch;
|
||||
std::vector<SceneRoundTripSwitch> newSceneRoundTripSwitch;
|
||||
|
||||
while (!in.atEnd()) {
|
||||
QString line = in.readLine();
|
||||
@@ -224,7 +225,7 @@ void SceneSwitcher::on_sceneRoundTripLoad_clicked()
|
||||
|
||||
void SwitcherData::checkSceneRoundTrip(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition,
|
||||
unique_lock<mutex> &lock)
|
||||
std::unique_lock<std::mutex> &lock)
|
||||
{
|
||||
bool sceneRoundTripActive = false;
|
||||
obs_source_t *currentSource = obs_frontend_get_current_scene();
|
||||
@@ -236,7 +237,8 @@ void SwitcherData::checkSceneRoundTrip(bool &match, OBSWeakSource &scene,
|
||||
int dur = s.delay - interval;
|
||||
if (dur > 0) {
|
||||
waitScene = currentSource;
|
||||
cv.wait_for(lock, chrono::milliseconds(dur));
|
||||
cv.wait_for(lock,
|
||||
std::chrono::milliseconds(dur));
|
||||
}
|
||||
obs_source_t *currentSource2 =
|
||||
obs_frontend_get_current_scene();
|
||||
@@ -267,12 +269,13 @@ void SceneSwitcher::on_sceneRoundTrips_currentRowChanged(int idx)
|
||||
|
||||
QString sceneRoundTrip = item->text();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->sceneRoundTripSwitches) {
|
||||
if (sceneRoundTrip.compare(s.sceneRoundTripStr.c_str()) == 0) {
|
||||
string scene1 = GetWeakSourceName(s.scene1);
|
||||
string scene2 = GetWeakSourceName(s.scene2);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string scene1 = GetWeakSourceName(s.scene1);
|
||||
std::string scene2 = GetWeakSourceName(s.scene2);
|
||||
std::string transitionName =
|
||||
GetWeakSourceName(s.transition);
|
||||
int delay = s.delay;
|
||||
ui->sceneRoundTripScenes1->setCurrentText(
|
||||
scene1.c_str());
|
||||
|
||||
@@ -27,7 +27,7 @@ void SceneSwitcher::on_transitionsAdd_clicked()
|
||||
new QListWidgetItem(text, ui->sceneTransitions);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->sceneTransitions.emplace_back(
|
||||
source1, source2, transition,
|
||||
text.toUtf8().constData());
|
||||
@@ -36,7 +36,7 @@ void SceneSwitcher::on_transitionsAdd_clicked()
|
||||
item->setText(text);
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->sceneTransitions) {
|
||||
if (s.scene1 == source1 &&
|
||||
s.scene2 == source2) {
|
||||
@@ -58,10 +58,11 @@ void SceneSwitcher::on_transitionsRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string text = item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
std::string text =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->sceneTransitions;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -100,7 +101,7 @@ void SceneSwitcher::on_defaultTransitionsAdd_clicked()
|
||||
new QListWidgetItem(text, ui->defaultTransitions);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->defaultSceneTransitions.emplace_back(
|
||||
source, transition, text.toUtf8().constData());
|
||||
} else {
|
||||
@@ -108,7 +109,7 @@ void SceneSwitcher::on_defaultTransitionsAdd_clicked()
|
||||
item->setText(text);
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->defaultSceneTransitions) {
|
||||
if (s.scene == source) {
|
||||
s.transition = transition;
|
||||
@@ -129,10 +130,11 @@ void SceneSwitcher::on_defaultTransitionsRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string text = item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
std::string text =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->defaultSceneTransitions;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -218,13 +220,14 @@ void SceneSwitcher::on_sceneTransitions_currentRowChanged(int idx)
|
||||
|
||||
QString sceneTransition = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->sceneTransitions) {
|
||||
if (sceneTransition.compare(s.sceneTransitionStr.c_str()) ==
|
||||
0) {
|
||||
string scene1 = GetWeakSourceName(s.scene1);
|
||||
string scene2 = GetWeakSourceName(s.scene2);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string scene1 = GetWeakSourceName(s.scene1);
|
||||
std::string scene2 = GetWeakSourceName(s.scene2);
|
||||
std::string transitionName =
|
||||
GetWeakSourceName(s.transition);
|
||||
ui->transitionsScene1->setCurrentText(scene1.c_str());
|
||||
ui->transitionsScene2->setCurrentText(scene2.c_str());
|
||||
ui->transitionsTransitions->setCurrentText(
|
||||
@@ -245,12 +248,13 @@ void SceneSwitcher::on_defaultTransitions_currentRowChanged(int idx)
|
||||
|
||||
QString sceneTransition = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->defaultSceneTransitions) {
|
||||
if (sceneTransition.compare(s.sceneTransitionStr.c_str()) ==
|
||||
0) {
|
||||
string scene = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string scene = GetWeakSourceName(s.scene);
|
||||
std::string transitionName =
|
||||
GetWeakSourceName(s.transition);
|
||||
ui->defaultTransitionsScene->setCurrentText(
|
||||
scene.c_str());
|
||||
ui->defaultTransitionsTransitions->setCurrentText(
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
void SwitcherData::checkScreenRegionSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
pair<int, int> cursorPos = getCursorPos();
|
||||
std::pair<int, int> cursorPos = getCursorPos();
|
||||
int minRegionSize = 99999;
|
||||
|
||||
for (auto &s : screenRegionSwitches) {
|
||||
@@ -22,9 +22,8 @@ void SwitcherData::checkScreenRegionSwitch(bool &match, OBSWeakSource &scene,
|
||||
|
||||
void SceneSwitcher::updateScreenRegionCursorPos()
|
||||
{
|
||||
pair<int, int> position = getCursorPos();
|
||||
std::pair<int, int> position = getCursorPos();
|
||||
ui->cursorXPosition->setText(QString::number(position.first));
|
||||
;
|
||||
ui->cursorYPosition->setText(QString::number(position.second));
|
||||
}
|
||||
|
||||
@@ -41,8 +40,9 @@ void SceneSwitcher::on_screenRegionAdd_clicked()
|
||||
int maxX = ui->screenRegionMaxX->value();
|
||||
int maxY = ui->screenRegionMaxY->value();
|
||||
|
||||
string regionStr = to_string(minX) + ", " + to_string(minY) + " x " +
|
||||
to_string(maxX) + ", " + to_string(maxY);
|
||||
std::string regionStr =
|
||||
std::to_string(minX) + ", " + std::to_string(minY) + " x " +
|
||||
std::to_string(maxX) + ", " + std::to_string(maxY);
|
||||
QString region = QString::fromStdString(regionStr);
|
||||
|
||||
OBSWeakSource source = GetWeakSourceByQString(sceneName);
|
||||
@@ -59,17 +59,17 @@ void SceneSwitcher::on_screenRegionAdd_clicked()
|
||||
new QListWidgetItem(text, ui->screenRegions);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->screenRegionSwitches.emplace_back(
|
||||
source, transition, minX, minY, maxX, maxY, regionStr);
|
||||
} else {
|
||||
QListWidgetItem *item = ui->screenRegions->item(idx);
|
||||
item->setText(text);
|
||||
|
||||
string curRegion = region.toUtf8().constData();
|
||||
std::string curRegion = region.toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->screenRegionSwitches) {
|
||||
if (s.regionStr == curRegion) {
|
||||
s.scene = source;
|
||||
@@ -89,11 +89,11 @@ void SceneSwitcher::on_screenRegionRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string region =
|
||||
std::string region =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->screenRegionSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -120,11 +120,12 @@ void SceneSwitcher::on_screenRegions_currentRowChanged(int idx)
|
||||
|
||||
QString region = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->screenRegionSwitches) {
|
||||
if (region.compare(s.regionStr.c_str()) == 0) {
|
||||
string name = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string name = GetWeakSourceName(s.scene);
|
||||
std::string transitionName =
|
||||
GetWeakSourceName(s.transition);
|
||||
ui->screenRegionScenes->setCurrentText(name.c_str());
|
||||
ui->screenRegionsTransitions->setCurrentText(
|
||||
transitionName.c_str());
|
||||
|
||||
@@ -11,7 +11,7 @@ void SceneSwitcher::on_timeSwitches_currentRowChanged(int idx)
|
||||
|
||||
QString timeScenestr = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->timeSwitches) {
|
||||
if (timeScenestr.compare(s.timeSwitchStr.c_str()) == 0) {
|
||||
QString sceneName = GetWeakSourceName(s.scene).c_str();
|
||||
@@ -59,7 +59,7 @@ void SceneSwitcher::on_timeAdd_clicked()
|
||||
int idx = timeFindByData(time.toString());
|
||||
|
||||
if (idx == -1) {
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->timeSwitches.emplace_back(
|
||||
source, transition, time,
|
||||
(sceneName == QString(PREVIOUS_SCENE_NAME)),
|
||||
@@ -73,7 +73,7 @@ void SceneSwitcher::on_timeAdd_clicked()
|
||||
item->setText(text);
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->timeSwitches) {
|
||||
if (s.time == time) {
|
||||
s.scene = source;
|
||||
@@ -99,10 +99,11 @@ void SceneSwitcher::on_timeRemove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string text = item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
std::string text =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->timeSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
|
||||
@@ -91,9 +91,9 @@ void GetCurrentWindowTitle(string &title)
|
||||
GetWindowTitle(window, title);
|
||||
}
|
||||
|
||||
pair<int, int> getCursorPos()
|
||||
std::pair<int, int> getCursorPos()
|
||||
{
|
||||
pair<int, int> pos(0, 0);
|
||||
std::pair<int, int> pos(0, 0);
|
||||
POINT cursorPos;
|
||||
if (GetPhysicalCursorPos(&cursorPos)) {
|
||||
pos.first = cursorPos.x;
|
||||
|
||||
@@ -17,7 +17,7 @@ bool isRunning(std::string &title)
|
||||
|
||||
bool isFocused(std::string &title)
|
||||
{
|
||||
string current;
|
||||
std::string current;
|
||||
|
||||
GetCurrentWindowTitle(current);
|
||||
// True if switch equals current window
|
||||
@@ -37,7 +37,7 @@ void SceneSwitcher::on_up_clicked()
|
||||
ui->switches->takeItem(index));
|
||||
ui->switches->setCurrentRow(index - 1);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
iter_swap(switcher->windowSwitches.begin() + index,
|
||||
switcher->windowSwitches.begin() + index - 1);
|
||||
@@ -52,7 +52,7 @@ void SceneSwitcher::on_down_clicked()
|
||||
ui->switches->takeItem(index));
|
||||
ui->switches->setCurrentRow(index + 1);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
iter_swap(switcher->windowSwitches.begin() + index,
|
||||
switcher->windowSwitches.begin() + index + 1);
|
||||
@@ -80,7 +80,7 @@ void SceneSwitcher::on_add_clicked()
|
||||
int idx = FindByData(windowName);
|
||||
|
||||
if (idx == -1) {
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->windowSwitches.emplace_back(
|
||||
source, windowName.toUtf8().constData(), transition,
|
||||
fullscreen, focus);
|
||||
@@ -91,10 +91,10 @@ void SceneSwitcher::on_add_clicked()
|
||||
QListWidgetItem *item = ui->switches->item(idx);
|
||||
item->setText(text);
|
||||
|
||||
string window = windowName.toUtf8().constData();
|
||||
std::string window = windowName.toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->windowSwitches) {
|
||||
if (s.window == window) {
|
||||
s.scene = source;
|
||||
@@ -114,11 +114,11 @@ void SceneSwitcher::on_remove_clicked()
|
||||
if (!item)
|
||||
return;
|
||||
|
||||
string window =
|
||||
std::string window =
|
||||
item->data(Qt::UserRole).toString().toUtf8().constData();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->windowSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -151,7 +151,7 @@ void SceneSwitcher::on_ignoreWindowsAdd_clicked()
|
||||
new QListWidgetItem(windowName, ui->ignoreWindows);
|
||||
item->setData(Qt::UserRole, v);
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
switcher->ignoreWindowsSwitches.emplace_back(
|
||||
windowName.toUtf8().constData());
|
||||
}
|
||||
@@ -166,7 +166,7 @@ void SceneSwitcher::on_ignoreWindowsRemove_clicked()
|
||||
QString windowName = item->data(Qt::UserRole).toString();
|
||||
|
||||
{
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
auto &switches = switcher->ignoreWindowsSwitches;
|
||||
|
||||
for (auto it = switches.begin(); it != switches.end(); ++it) {
|
||||
@@ -229,11 +229,12 @@ void SceneSwitcher::on_switches_currentRowChanged(int idx)
|
||||
|
||||
QString window = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->windowSwitches) {
|
||||
if (window.compare(s.window.c_str()) == 0) {
|
||||
string name = GetWeakSourceName(s.scene);
|
||||
string transitionName = GetWeakSourceName(s.transition);
|
||||
std::string name = GetWeakSourceName(s.scene);
|
||||
std::string transitionName =
|
||||
GetWeakSourceName(s.transition);
|
||||
ui->scenes->setCurrentText(name.c_str());
|
||||
ui->windows->setCurrentText(window);
|
||||
ui->transitions->setCurrentText(transitionName.c_str());
|
||||
@@ -255,7 +256,7 @@ void SceneSwitcher::on_ignoreWindows_currentRowChanged(int idx)
|
||||
|
||||
QString window = item->data(Qt::UserRole).toString();
|
||||
|
||||
lock_guard<mutex> lock(switcher->m);
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
for (auto &s : switcher->ignoreWindowsSwitches) {
|
||||
if (window.compare(s.c_str()) == 0) {
|
||||
ui->ignoreWindowsWindows->setCurrentText(s.c_str());
|
||||
@@ -267,7 +268,7 @@ void SceneSwitcher::on_ignoreWindows_currentRowChanged(int idx)
|
||||
void SwitcherData::checkWindowTitleSwitch(bool &match, OBSWeakSource &scene,
|
||||
OBSWeakSource &transition)
|
||||
{
|
||||
string title;
|
||||
std::string title;
|
||||
bool ignored = false;
|
||||
|
||||
// Check if current window is ignored
|
||||
|
||||
Reference in New Issue
Block a user