Add ability to choose focus state to window title switcher

This commit is contained in:
Myned
2020-05-21 00:34:22 -04:00
parent a4de8c0c59
commit e4b640903d
6 changed files with 85 additions and 23 deletions

View File

@@ -134,6 +134,7 @@ public slots:
* Windowtitle helper
********************************************************************************/
void GetWindowList(std::vector<std::string> &windows);
void GetWindowList(QStringList &windows); // Overloaded
void GetCurrentWindowTitle(std::string &title);
bool isFullscreen();

View File

@@ -42,13 +42,15 @@ struct WindowSceneSwitch {
string window;
OBSWeakSource transition;
bool fullscreen;
bool focus;
inline WindowSceneSwitch(OBSWeakSource scene_, const char *window_,
OBSWeakSource transition_, bool fullscreen_)
OBSWeakSource transition_, bool fullscreen_, bool focus_)
: scene(scene_),
window(window_),
transition(transition_),
fullscreen(fullscreen_)
fullscreen(fullscreen_),
focus(focus_)
{
}
};

View File

@@ -14,14 +14,26 @@ static inline bool WeakSourceValid(obs_weak_source_t* ws)
}
static inline QString MakeSwitchName(const QString &scene, const QString &value,
const QString &transition, bool fullscreen)
const QString &transition, bool fullscreen, bool focus)
{
if (!fullscreen)
return QStringLiteral("[") + scene + QStringLiteral(", ") +
transition + QStringLiteral("]: ") + value;
return QStringLiteral("[") + scene + QStringLiteral(", ") + transition +
QStringLiteral("]: ") + value +
QStringLiteral(" (only if window is fullscreen)");
QString name = QStringLiteral("[") + scene + QStringLiteral(", ") +
transition + QStringLiteral("]: ") + value;
if (fullscreen || focus)
{
name += QStringLiteral(" (only if");
if (fullscreen)
name += QStringLiteral(" fullscreen");
if (fullscreen && focus)
name += QStringLiteral(" and");
if (focus)
name += QStringLiteral(" focused");
name += QStringLiteral(")");
}
return name;
}
static inline QString MakeSwitchNameExecutable(const QString &scene,