mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
Add direct matching to window, executable, and ignored switches
Reverts part of commit 5f87a61177
Direct matching occurs in the same loop as regex in order to allow the list order to function as indicated in the UI
This commit is contained in:
parent
f0aa76517a
commit
d5052c94ca
|
|
@ -133,32 +133,40 @@ void SwitcherData::checkExeSwitch(bool& match, OBSWeakSource& scene, OBSWeakSour
|
|||
GetCurrentWindowTitle(title);
|
||||
for (auto& window : ignoreWindowsSwitches)
|
||||
{
|
||||
// True if ignored switch equals title
|
||||
bool equals = (title == window);
|
||||
// True if ignored switch matches title
|
||||
bool matches = QString::fromStdString(title).contains(QRegularExpression(window.c_str()));
|
||||
if (matches)
|
||||
|
||||
if (equals || matches)
|
||||
{
|
||||
ignored = true;
|
||||
title = lastTitle;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
lastTitle = title;
|
||||
|
||||
// Check for regex match
|
||||
// Check for match
|
||||
GetProcessList(runningProcesses);
|
||||
for (ExecutableSceneSwitch& s : executableSwitches)
|
||||
{
|
||||
// True if executable switch is running
|
||||
bool running = (runningProcesses.indexOf(QRegularExpression(s.mExe)) != -1);
|
||||
// True if executable switch is running (direct)
|
||||
bool equals = runningProcesses.contains(s.mExe);
|
||||
// True if executable switch is running (regex)
|
||||
bool matches = (runningProcesses.indexOf(QRegularExpression(s.mExe)) != -1);
|
||||
// True if focus is disabled OR window in focus
|
||||
bool focus = (!s.mInFocus || isInFocus(s.mExe));
|
||||
// True if current window is ignored AND executable switch matches last window
|
||||
bool ignore = (ignored && QString::fromStdString(title).contains(QRegularExpression(s.mExe)));
|
||||
if (running && (focus || ignore))
|
||||
|
||||
if ((equals || matches) && (focus || ignore))
|
||||
{
|
||||
match = true;
|
||||
scene = s.mScene;
|
||||
transition = s.mTransition;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,7 +295,12 @@ bool isInFocus(const QString &exeToCheck)
|
|||
string curWindow;
|
||||
GetCurrentWindowTitle(curWindow);
|
||||
|
||||
return QString::fromStdString(curWindow).contains(QRegularExpression(exeToCheck));
|
||||
// True if executable switch equals current window
|
||||
bool equals = (exeToCheck.toStdString() == curWindow);
|
||||
// True if executable switch matches current window
|
||||
bool matches = QString::fromStdString(curWindow).contains(QRegularExpression(exeToCheck));
|
||||
|
||||
return (equals || matches);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -234,28 +234,36 @@ void SwitcherData::checkWindowTitleSwitch(bool& match, OBSWeakSource& scene, OBS
|
|||
GetCurrentWindowTitle(title);
|
||||
for (auto& window : ignoreWindowsSwitches)
|
||||
{
|
||||
// True if ignored switch equals title
|
||||
bool equals = (title == window);
|
||||
// True if ignored switch matches title
|
||||
bool matches = QString::fromStdString(title).contains(QRegularExpression(window.c_str()));
|
||||
if (matches)
|
||||
|
||||
if (equals || matches)
|
||||
{
|
||||
title = lastTitle;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
lastTitle = title;
|
||||
|
||||
// Check for regex match
|
||||
// Check for match
|
||||
for (WindowSceneSwitch& s : windowSwitches)
|
||||
{
|
||||
// True if window switch equals title
|
||||
bool equals = (title == s.window);
|
||||
// True if window switch matches title
|
||||
bool matches = QString::fromStdString(title).contains(QRegularExpression(s.window.c_str()));
|
||||
// True if fullscreen is disabled OR window is fullscreen
|
||||
bool fullscreen = (!s.fullscreen || isFullscreen());
|
||||
if (matches && fullscreen)
|
||||
|
||||
if ((equals || matches) && fullscreen)
|
||||
{
|
||||
match = true;
|
||||
scene = s.scene;
|
||||
transition = s.transition;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user