mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-07-14 23:34:08 +00:00
UI: Make GetUnusedSceneCollectionFile usable elsewhere
This commit is contained in:
parent
535f6b0adc
commit
9b1d1c1b3d
|
@ -2293,6 +2293,36 @@ bool GetClosestUnusedFileName(std::string &path, const char *extension)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool GetUnusedSceneCollectionFile(std::string &name, std::string &file)
|
||||||
|
{
|
||||||
|
char path[512];
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
if (!GetFileSafeName(name.c_str(), file)) {
|
||||||
|
blog(LOG_WARNING, "Failed to create safe file name for '%s'",
|
||||||
|
name.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/scenes/");
|
||||||
|
if (ret <= 0) {
|
||||||
|
blog(LOG_WARNING, "Failed to get scene collection config path");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.insert(0, path);
|
||||||
|
|
||||||
|
if (!GetClosestUnusedFileName(file, "json")) {
|
||||||
|
blog(LOG_WARNING, "Failed to get closest file name for %s",
|
||||||
|
file.c_str());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
file.erase(file.size() - 5, 5);
|
||||||
|
file.erase(0, strlen(path));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool WindowPositionValid(QRect rect)
|
bool WindowPositionValid(QRect rect)
|
||||||
{
|
{
|
||||||
for (QScreen *screen : QGuiApplication::screens()) {
|
for (QScreen *screen : QGuiApplication::screens()) {
|
||||||
|
|
|
@ -213,6 +213,7 @@ inline const char *Str(const char *lookup)
|
||||||
|
|
||||||
bool GetFileSafeName(const char *name, std::string &file);
|
bool GetFileSafeName(const char *name, std::string &file);
|
||||||
bool GetClosestUnusedFileName(std::string &path, const char *extension);
|
bool GetClosestUnusedFileName(std::string &path, const char *extension);
|
||||||
|
bool GetUnusedSceneCollectionFile(std::string &name, std::string &file);
|
||||||
|
|
||||||
bool WindowPositionValid(QRect rect);
|
bool WindowPositionValid(QRect rect);
|
||||||
|
|
||||||
|
|
|
@ -89,36 +89,6 @@ static bool SceneCollectionExists(const char *findName)
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool GetUnusedSceneCollectionFile(std::string &name, std::string &file)
|
|
||||||
{
|
|
||||||
char path[512];
|
|
||||||
int ret;
|
|
||||||
|
|
||||||
if (!GetFileSafeName(name.c_str(), file)) {
|
|
||||||
blog(LOG_WARNING, "Failed to create safe file name for '%s'",
|
|
||||||
name.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = GetConfigPath(path, sizeof(path), "obs-studio/basic/scenes/");
|
|
||||||
if (ret <= 0) {
|
|
||||||
blog(LOG_WARNING, "Failed to get scene collection config path");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.insert(0, path);
|
|
||||||
|
|
||||||
if (!GetClosestUnusedFileName(file, "json")) {
|
|
||||||
blog(LOG_WARNING, "Failed to get closest file name for %s",
|
|
||||||
file.c_str());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
file.erase(file.size() - 5, 5);
|
|
||||||
file.erase(0, strlen(path));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
static bool GetSceneCollectionName(QWidget *parent, std::string &name,
|
||||||
std::string &file,
|
std::string &file,
|
||||||
const char *oldName = nullptr)
|
const char *oldName = nullptr)
|
||||||
|
|
Loading…
Reference in a new issue