فهرست منبع

UI: Make GetUnusedSceneCollectionFile usable elsewhere

Ryan Foster 4 سال پیش
والد
کامیت
9b1d1c1b3d
3فایلهای تغییر یافته به همراه31 افزوده شده و 30 حذف شده
  1. 30 0
      UI/obs-app.cpp
  2. 1 0
      UI/obs-app.hpp
  3. 0 30
      UI/window-basic-main-scene-collections.cpp

+ 30 - 0
UI/obs-app.cpp

@@ -2293,6 +2293,36 @@ bool GetClosestUnusedFileName(std::string &path, const char *extension)
 	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)
 {
 	for (QScreen *screen : QGuiApplication::screens()) {

+ 1 - 0
UI/obs-app.hpp

@@ -213,6 +213,7 @@ inline const char *Str(const char *lookup)
 
 bool GetFileSafeName(const char *name, std::string &file);
 bool GetClosestUnusedFileName(std::string &path, const char *extension);
+bool GetUnusedSceneCollectionFile(std::string &name, std::string &file);
 
 bool WindowPositionValid(QRect rect);
 

+ 0 - 30
UI/window-basic-main-scene-collections.cpp

@@ -89,36 +89,6 @@ static bool SceneCollectionExists(const char *findName)
 	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,
 				   std::string &file,
 				   const char *oldName = nullptr)