frontend: Migrate scene collection usage to new SceneCollection class

This commit is contained in:
PatTheMav
2025-04-21 15:17:11 -04:00
committed by Ryan Foster
parent ca44e3037d
commit cce189011e
6 changed files with 290 additions and 212 deletions
+21 -7
View File
@@ -34,6 +34,7 @@
#include <dialogs/OBSBasicInteraction.hpp>
#include <dialogs/OBSBasicProperties.hpp>
#include <dialogs/OBSBasicTransform.hpp>
#include <models/SceneCollection.hpp>
#include <settings/OBSBasicSettings.hpp>
#include <utility/QuickTransition.hpp>
#include <utility/SceneRenameDelegate.hpp>
@@ -198,6 +199,8 @@ extern void setupDockAction(QDockWidget *dock);
OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new Ui::OBSBasic)
{
collections = {};
setAttribute(Qt::WA_NativeWindow);
#ifdef TWITCH_ENABLED
@@ -1034,10 +1037,9 @@ void OBSBasic::OBSInit()
ProfileScope("OBSBasic::Load");
const std::string sceneCollectionName{
config_get_string(App()->GetUserConfig(), "Basic", "SceneCollection")};
const std::optional<OBSSceneCollection> configuredCollection =
std::optional<OBS::SceneCollection> configuredCollection =
GetSceneCollectionByName(sceneCollectionName);
const std::optional<OBSSceneCollection> foundCollection =
GetSceneCollectionByName(opt_starting_collection);
std::optional<OBS::SceneCollection> foundCollection = GetSceneCollectionByName(opt_starting_collection);
if (foundCollection) {
ActivateSceneCollection(foundCollection.value());
@@ -1537,10 +1539,22 @@ int OBSBasic::ResetVideo()
OBSBasicStats::InitializeValues();
OBSProjector::UpdateMultiviewProjectors();
bool canMigrate = usingAbsoluteCoordinates ||
(migrationBaseResolution && (migrationBaseResolution->first != ovi.base_width ||
migrationBaseResolution->second != ovi.base_height));
ui->actionRemigrateSceneCollection->setEnabled(canMigrate);
if (!collections.empty()) {
const OBS::SceneCollection currentSceneCollection = OBSBasic::GetCurrentSceneCollection();
bool usingAbsoluteCoordinates = currentSceneCollection.getCoordinateMode() ==
OBS::SceneCoordinateMode::Absolute;
OBS::Rect migrationResolution = currentSceneCollection.getMigrationResolution();
OBS::Rect videoResolution = OBS::Rect(ovi.base_width, ovi.base_height);
bool canMigrate = usingAbsoluteCoordinates ||
(!migrationResolution.isZero() && migrationResolution != videoResolution);
ui->actionRemigrateSceneCollection->setEnabled(canMigrate);
} else {
ui->actionRemigrateSceneCollection->setEnabled(false);
}
emit CanvasResized(ovi.base_width, ovi.base_height);
emit OutputResized(ovi.output_width, ovi.output_height);