mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-04 10:33:30 +00:00
UI: Add obs_frontend_add_scene_collection API call
Allows the ability to add a new scene collection via the frontend API. Blocks until the scene collection has been successfully added to ensure synchronization between the calling thread and the UI thread. (Jim: Added detailed description to commit message) Closes obsproject/obs-studio#1232
This commit is contained in:
parent
3eec139b2e
commit
c768f703ad
|
@ -167,6 +167,19 @@ struct OBSStudioAPI : obs_frontend_callbacks {
|
|||
}
|
||||
}
|
||||
|
||||
bool obs_frontend_add_scene_collection(
|
||||
const char *name) override
|
||||
{
|
||||
bool success = false;
|
||||
QMetaObject::invokeMethod(main,
|
||||
"AddSceneCollection",
|
||||
WaitConnection(),
|
||||
Q_RETURN_ARG(bool, success),
|
||||
Q_ARG(bool, true),
|
||||
Q_ARG(QString, QT_UTF8(name)));
|
||||
return success;
|
||||
}
|
||||
|
||||
void obs_frontend_get_profiles(
|
||||
std::vector<std::string> &strings) override
|
||||
{
|
||||
|
|
|
@ -148,6 +148,13 @@ void obs_frontend_set_current_scene_collection(const char *collection)
|
|||
c->obs_frontend_set_current_scene_collection(collection);
|
||||
}
|
||||
|
||||
bool obs_frontend_add_scene_collection(const char *name)
|
||||
{
|
||||
return callbacks_valid()
|
||||
? c->obs_frontend_add_scene_collection(name)
|
||||
: false;
|
||||
}
|
||||
|
||||
char **obs_frontend_get_profiles(void)
|
||||
{
|
||||
if (!callbacks_valid())
|
||||
|
|
|
@ -95,6 +95,7 @@ EXPORT void obs_frontend_set_current_transition(obs_source_t *transition);
|
|||
EXPORT char **obs_frontend_get_scene_collections(void);
|
||||
EXPORT char *obs_frontend_get_current_scene_collection(void);
|
||||
EXPORT void obs_frontend_set_current_scene_collection(const char *collection);
|
||||
EXPORT bool obs_frontend_add_scene_collection(const char *name);
|
||||
|
||||
EXPORT char **obs_frontend_get_profiles(void);
|
||||
EXPORT char *obs_frontend_get_current_profile(void);
|
||||
|
|
|
@ -26,6 +26,7 @@ struct obs_frontend_callbacks {
|
|||
virtual char *obs_frontend_get_current_scene_collection(void)=0;
|
||||
virtual void obs_frontend_set_current_scene_collection(
|
||||
const char *collection)=0;
|
||||
virtual bool obs_frontend_add_scene_collection(const char *name)=0;
|
||||
|
||||
virtual void obs_frontend_get_profiles(
|
||||
std::vector<std::string> &strings)=0;
|
||||
|
|
|
@ -154,13 +154,19 @@ static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
|||
return true;
|
||||
}
|
||||
|
||||
void OBSBasic::AddSceneCollection(bool create_new)
|
||||
bool OBSBasic::AddSceneCollection(bool create_new, const QString &qname)
|
||||
{
|
||||
std::string name;
|
||||
std::string file;
|
||||
|
||||
if (!GetSceneCollectionName(this, name, file))
|
||||
return;
|
||||
if (qname.isEmpty()) {
|
||||
if (!GetSceneCollectionName(this, name, file))
|
||||
return false;
|
||||
} else {
|
||||
name = QT_TO_UTF8(qname);
|
||||
if (SceneCollectionExists(name.c_str()))
|
||||
return false;
|
||||
}
|
||||
|
||||
SaveProjectNow();
|
||||
|
||||
|
@ -185,6 +191,8 @@ void OBSBasic::AddSceneCollection(bool create_new)
|
|||
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED);
|
||||
api->on_event(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void OBSBasic::RefreshSceneCollections()
|
||||
|
|
|
@ -259,7 +259,6 @@ private:
|
|||
void GetAudioSourceProperties();
|
||||
void VolControlContextMenu();
|
||||
|
||||
void AddSceneCollection(bool create_new);
|
||||
void RefreshSceneCollections();
|
||||
void ChangeSceneCollection();
|
||||
void LogScenes();
|
||||
|
@ -407,6 +406,10 @@ public slots:
|
|||
void SetCurrentScene(OBSSource scene, bool force = false,
|
||||
bool direct = false);
|
||||
|
||||
bool AddSceneCollection(
|
||||
bool create_new,
|
||||
const QString &name = QString());
|
||||
|
||||
private slots:
|
||||
void AddSceneItem(OBSSceneItem item);
|
||||
void RemoveSceneItem(OBSSceneItem item);
|
||||
|
|
Loading…
Reference in a new issue