frontend: Use OBSBasic::Get() in all places
This reduces duplicated code when getting the OBSBasic context.
This commit is contained in:
parent
a562b8bf52
commit
4e8b131509
@ -1216,7 +1216,7 @@ bool OBSApp::notify(QObject *receiver, QEvent *e)
|
||||
|
||||
if (windowType == Qt::WindowType::Dialog || windowType == Qt::WindowType::Window ||
|
||||
windowType == Qt::WindowType::Tool) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
if (main)
|
||||
main->SetDisplayAffinity(window);
|
||||
}
|
||||
@ -1355,7 +1355,7 @@ string GetFormatExt(const char *container)
|
||||
|
||||
string GetOutputFilename(const char *path, const char *container, bool noSpace, bool overwrite, const char *format)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
os_dir_t *dir = path && path[0] ? os_opendir(path) : nullptr;
|
||||
|
||||
@ -1558,7 +1558,7 @@ void OBSApp::ProcessSigInt(void)
|
||||
char tmp;
|
||||
recv(sigintFd[1], &tmp, sizeof(tmp), 0);
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
if (main)
|
||||
main->close();
|
||||
#endif
|
||||
|
@ -73,7 +73,7 @@ OBSAdvAudioCtrl::OBSAdvAudioCtrl(QGridLayout *, obs_source_t *source_) : source(
|
||||
labelL->setText("L");
|
||||
labelR->setText("R");
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
QIcon sourceIcon = main->GetSourceIcon(obs_source_get_id(source));
|
||||
QPixmap pixmap = sourceIcon.pixmap(QSize(16, 16));
|
||||
|
@ -27,7 +27,7 @@ void SourceToolbar::SetUndoProperties(obs_source_t *source, bool repeatable)
|
||||
return;
|
||||
}
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSSource currentSceneSource = main->GetCurrentSceneSource();
|
||||
if (!currentSceneSource)
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
static inline OBSScene GetCurrentScene()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
return main->GetCurrentScene();
|
||||
}
|
||||
|
||||
@ -560,7 +560,7 @@ bool SourceTree::GroupedItemsSelected() const
|
||||
|
||||
void SourceTree::Remove(OBSSceneItem item, OBSScene scene)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
GetStm()->Remove(item);
|
||||
main->SaveProject();
|
||||
|
||||
|
@ -13,7 +13,7 @@
|
||||
|
||||
static inline OBSScene GetCurrentScene()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
return main->GetCurrentScene();
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ SourceTreeItem::SourceTreeItem(SourceTree *tree_, OBSSceneItem sceneitem_) : tre
|
||||
setStyleSheet("background: none");
|
||||
}
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
const char *id = obs_source_get_id(source);
|
||||
|
||||
bool sourceVisible = obs_sceneitem_visible(sceneitem);
|
||||
@ -268,7 +268,7 @@ void SourceTreeItem::mouseDoubleClickEvent(QMouseEvent *event)
|
||||
expand->setChecked(!expand->isChecked());
|
||||
} else {
|
||||
obs_source_t *source = obs_sceneitem_get_source(sceneitem);
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
if (obs_source_configurable(source)) {
|
||||
main->CreatePropertiesWindow(source);
|
||||
}
|
||||
@ -337,7 +337,7 @@ void SourceTreeItem::ExitEditModeInternal(bool save)
|
||||
return;
|
||||
}
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
newName = QT_TO_UTF8(editor->text());
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
static inline OBSScene GetCurrentScene()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
return main->GetCurrentScene();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent) : QDialog(parent), ui(new Ui
|
||||
|
||||
OBSBasicAdvAudio::~OBSBasicAdvAudio()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(parent());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
for (size_t i = 0; i < controls.size(); ++i)
|
||||
delete controls[i];
|
||||
|
@ -51,7 +51,7 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_)
|
||||
renameSourceSignal(obs_source_get_signal_handler(source), "rename", OBSBasicFilters::SourceRenamed, this),
|
||||
noPreviewMargin(13)
|
||||
{
|
||||
main = reinterpret_cast<OBSBasic *>(parent);
|
||||
main = OBSBasic::Get();
|
||||
|
||||
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
|
||||
|
||||
@ -248,7 +248,7 @@ void OBSBasicFilters::UpdatePropertiesView(int row, bool async)
|
||||
OBSDataAutoRelease settings = obs_source_get_settings(filter);
|
||||
|
||||
auto disabled_undo = [](void *vp, obs_data_t *settings) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
main->undo_s.disable();
|
||||
obs_source_t *source = reinterpret_cast<obs_source_t *>(vp);
|
||||
obs_source_update(source, settings);
|
||||
@ -542,8 +542,7 @@ void OBSBasicFilters::AddNewFilter(const char *id)
|
||||
}
|
||||
|
||||
std::string parent_uuid(obs_source_get_uuid(source));
|
||||
std::string scene_uuid = obs_source_get_uuid(
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->GetCurrentSceneSource());
|
||||
std::string scene_uuid = obs_source_get_uuid(OBSBasic::Get()->GetCurrentSceneSource());
|
||||
/* In order to ensure that the UUID persists through undo/redo,
|
||||
* we save the source data rather than just recreating the
|
||||
* source from scratch. */
|
||||
@ -556,7 +555,7 @@ void OBSBasicFilters::AddNewFilter(const char *id)
|
||||
|
||||
auto undo = [scene_uuid](const std::string &data) {
|
||||
OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(ssource.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(ssource.Get(), true);
|
||||
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "suuid"));
|
||||
@ -567,7 +566,7 @@ void OBSBasicFilters::AddNewFilter(const char *id)
|
||||
|
||||
auto redo = [scene_uuid](const std::string &data) {
|
||||
OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(ssource.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(ssource.Get(), true);
|
||||
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "undo_uuid"));
|
||||
@ -971,11 +970,10 @@ void OBSBasicFilters::FilterNameEdited(QWidget *editor, QListWidget *list)
|
||||
listItem->setText(QT_UTF8(name.c_str()));
|
||||
obs_source_set_name(filter, name.c_str());
|
||||
|
||||
std::string scene_uuid = obs_source_get_uuid(
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->GetCurrentSceneSource());
|
||||
std::string scene_uuid = obs_source_get_uuid(OBSBasic::Get()->GetCurrentSceneSource());
|
||||
auto undo = [scene_uuid, prev = std::string(prevName), name](const std::string &uuid) {
|
||||
OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(ssource.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(ssource.Get(), true);
|
||||
|
||||
OBSSourceAutoRelease filter = obs_get_source_by_uuid(uuid.c_str());
|
||||
obs_source_set_name(filter, prev.c_str());
|
||||
@ -983,7 +981,7 @@ void OBSBasicFilters::FilterNameEdited(QWidget *editor, QListWidget *list)
|
||||
|
||||
auto redo = [scene_uuid, prev = std::string(prevName), name](const std::string &uuid) {
|
||||
OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(ssource.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(ssource.Get(), true);
|
||||
|
||||
OBSSourceAutoRelease filter = obs_get_source_by_uuid(uuid.c_str());
|
||||
obs_source_set_name(filter, name.c_str());
|
||||
@ -1069,11 +1067,10 @@ void OBSBasicFilters::delete_filter(OBSSource filter)
|
||||
std::string parent_uuid(obs_source_get_uuid(source));
|
||||
obs_data_set_string(wrapper, "undo_uuid", parent_uuid.c_str());
|
||||
|
||||
std::string scene_uuid =
|
||||
obs_source_get_uuid(reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->GetCurrentSceneSource());
|
||||
std::string scene_uuid = obs_source_get_uuid(OBSBasic::Get()->GetCurrentSceneSource());
|
||||
auto undo = [scene_uuid](const std::string &data) {
|
||||
OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(ssource.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(ssource.Get(), true);
|
||||
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "undo_uuid"));
|
||||
@ -1086,7 +1083,7 @@ void OBSBasicFilters::delete_filter(OBSSource filter)
|
||||
obs_data_set_string(rwrapper, "suuid", parent_uuid.c_str());
|
||||
auto redo = [scene_uuid](const std::string &data) {
|
||||
OBSSourceAutoRelease ssource = obs_get_source_by_uuid(scene_uuid.c_str());
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(ssource.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(ssource.Get(), true);
|
||||
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "suuid"));
|
||||
|
@ -56,7 +56,7 @@ bool OBSBasicSourceSelect::EnumGroups(void *data, obs_source_t *source)
|
||||
const char *id = obs_source_get_unversioned_id(source);
|
||||
|
||||
if (strcmp(id, window->id) == 0) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
obs_sceneitem_t *existing = obs_scene_get_group(scene, name);
|
||||
@ -152,7 +152,7 @@ char *get_new_source_name(const char *name, const char *format)
|
||||
static void AddExisting(OBSSource source, bool visible, bool duplicate, obs_transform_info *transform,
|
||||
obs_sceneitem_crop *crop, obs_blending_method *blend_method, obs_blending_type *blend_mode)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
if (!scene)
|
||||
return;
|
||||
@ -193,7 +193,7 @@ static void AddExisting(const char *name, bool visible, bool duplicate, obs_tran
|
||||
bool AddNew(QWidget *parent, const char *id, const char *name, const bool visible, OBSSource &newSource,
|
||||
OBSSceneItem &newSceneItem)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
bool success = false;
|
||||
if (!scene)
|
||||
@ -245,7 +245,7 @@ void OBSBasicSourceSelect::on_buttonBox_accepted()
|
||||
QString source_name = item->text();
|
||||
AddExisting(QT_TO_UTF8(source_name), visible, false, nullptr, nullptr, nullptr, nullptr);
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
const char *scene_name = obs_source_get_name(main->GetCurrentSceneSource());
|
||||
|
||||
auto undo = [scene_name, main](const std::string &) {
|
||||
@ -377,7 +377,7 @@ OBSBasicSourceSelect::OBSBasicSourceSelect(OBSBasic *parent, const char *id_, un
|
||||
});
|
||||
|
||||
if (strcmp(id_, "scene") == 0) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSSource curSceneSource = main->GetCurrentSceneSource();
|
||||
|
||||
ui->selectExisting->setChecked(true);
|
||||
|
@ -88,7 +88,7 @@ OBSBasicTransform::~OBSBasicTransform()
|
||||
auto undo_redo = [](const std::string &data) {
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid"));
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(source.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(source.Get(), true);
|
||||
obs_scene_load_transform_states(data.c_str());
|
||||
};
|
||||
|
||||
|
@ -144,7 +144,7 @@ void OBSImporter::browseImport()
|
||||
|
||||
bool GetUnusedName(std::string &name)
|
||||
{
|
||||
OBSBasic *basic = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *basic = OBSBasic::Get();
|
||||
|
||||
if (!basic->GetSceneCollectionByName(name)) {
|
||||
return false;
|
||||
|
@ -1852,7 +1852,7 @@ OBSPropertiesView *OBSBasicSettings::CreateEncoderPropertyView(const char *encod
|
||||
OBSPropertiesView *view;
|
||||
|
||||
if (path) {
|
||||
const OBSBasic *basic = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
const OBSBasic *basic = OBSBasic::Get();
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(path);
|
||||
@ -3233,7 +3233,7 @@ static void WriteJsonData(OBSPropertiesView *view, const char *path)
|
||||
if (!view || !WidgetChanged(view))
|
||||
return;
|
||||
|
||||
const OBSBasic *basic = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
const OBSBasic *basic = OBSBasic::Get();
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(path);
|
||||
|
@ -10,7 +10,7 @@ using namespace std;
|
||||
|
||||
static OBSData GetDataFromJsonFile(const char *jsonFile)
|
||||
{
|
||||
const OBSBasic *basic = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
const OBSBasic *basic = OBSBasic::Get();
|
||||
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
|
@ -99,7 +99,7 @@ QVariant MissingFilesModel::data(const QModelIndex &index, int role) const
|
||||
break;
|
||||
}
|
||||
} else if (role == Qt::DecorationRole && index.column() == MissingFilesColumn::Source) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSSourceAutoRelease source = obs_get_source_by_name(files[index.row()].source.toStdString().c_str());
|
||||
|
||||
if (source) {
|
||||
|
@ -40,7 +40,7 @@ void OBSBasicPreview::Init()
|
||||
|
||||
vec2 OBSBasicPreview::GetMouseEventPos(QMouseEvent *event)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
float pixelRatio = main->GetDevicePixelRatio();
|
||||
float scale = pixelRatio / main->previewScale;
|
||||
QPoint qtPos = event->pos();
|
||||
@ -166,7 +166,7 @@ static inline vec2 GetOBSScreenSize()
|
||||
|
||||
vec3 OBSBasicPreview::GetSnapOffset(const vec3 &tl, const vec3 &br)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
vec2 screenSize = GetOBSScreenSize();
|
||||
vec3 clampOffset;
|
||||
|
||||
@ -211,7 +211,7 @@ vec3 OBSBasicPreview::GetSnapOffset(const vec3 &tl, const vec3 &br)
|
||||
|
||||
OBSSceneItem OBSBasicPreview::GetItemAtPos(const vec2 &pos, bool selectBelow)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
if (!scene)
|
||||
@ -267,7 +267,7 @@ static bool CheckItemSelected(obs_scene_t * /* scene */, obs_sceneitem_t *item,
|
||||
|
||||
bool OBSBasicPreview::SelectedAtPos(const vec2 &pos)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
if (!scene)
|
||||
@ -428,7 +428,7 @@ static vec2 GetItemSize(obs_sceneitem_t *item)
|
||||
|
||||
void OBSBasicPreview::GetStretchHandleData(const vec2 &pos, bool ignoreGroup)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
if (!scene)
|
||||
@ -556,7 +556,7 @@ void OBSBasicPreview::mousePressEvent(QMouseEvent *event)
|
||||
return;
|
||||
}
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
float pixelRatio = main->GetDevicePixelRatio();
|
||||
float x = pos.x() - main->previewX / pixelRatio;
|
||||
float y = pos.y() - main->previewY / pixelRatio;
|
||||
@ -678,7 +678,7 @@ static bool select_one(obs_scene_t * /* scene */, obs_sceneitem_t *item, void *p
|
||||
|
||||
void OBSBasicPreview::DoSelect(const vec2 &pos)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
OBSSceneItem item = GetItemAtPos(pos, true);
|
||||
@ -769,13 +769,13 @@ void OBSBasicPreview::mouseReleaseEvent(QMouseEvent *event)
|
||||
hoveredPreviewItems.push_back(item);
|
||||
selectedItems.clear();
|
||||
}
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSDataAutoRelease rwrapper = obs_scene_save_transform_states(main->GetCurrentScene(), true);
|
||||
|
||||
auto undo_redo = [](const std::string &data) {
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid"));
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(source.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(source.Get(), true);
|
||||
|
||||
obs_scene_load_transform_states(data.c_str());
|
||||
};
|
||||
@ -902,7 +902,7 @@ static bool GetSourceSnapOffset(obs_scene_t * /* scene */, obs_sceneitem_t *item
|
||||
|
||||
void OBSBasicPreview::SnapItemMovement(vec2 &offset)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
SelectedItemBounds data;
|
||||
@ -978,7 +978,7 @@ static bool move_items(obs_scene_t * /* scene */, obs_sceneitem_t *item, void *p
|
||||
void OBSBasicPreview::MoveItems(const vec2 &pos)
|
||||
{
|
||||
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
vec2 offset, moveOffset;
|
||||
@ -1146,7 +1146,7 @@ static bool FindItemsInBox(obs_scene_t * /* scene */, obs_sceneitem_t *item, voi
|
||||
|
||||
void OBSBasicPreview::BoxItems(const vec2 &startPos, const vec2 &pos)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
if (!scene)
|
||||
@ -1473,7 +1473,7 @@ void OBSBasicPreview::StretchItem(const vec2 &pos)
|
||||
|
||||
void OBSBasicPreview::RotateItem(const vec2 &pos)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
Qt::KeyboardModifiers modifiers = QGuiApplication::keyboardModifiers();
|
||||
bool shiftDown = (modifiers & Qt::ShiftModifier);
|
||||
@ -1521,7 +1521,7 @@ void OBSBasicPreview::RotateItem(const vec2 &pos)
|
||||
|
||||
void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
changed = true;
|
||||
|
||||
QPointF qtPos = event->position();
|
||||
@ -1601,7 +1601,7 @@ void OBSBasicPreview::mouseMoveEvent(QMouseEvent *event)
|
||||
|
||||
if (!mouseMoved && hoveredPreviewItems.size() > 0) {
|
||||
mousePos = pos;
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
float scale = main->GetDevicePixelRatio();
|
||||
float x = qtPos.x() - main->previewX / scale;
|
||||
float y = qtPos.y() - main->previewY / scale;
|
||||
@ -2084,7 +2084,7 @@ void OBSBasicPreview::DrawOverflow()
|
||||
overflow = gs_texture_create_from_file(path.c_str());
|
||||
}
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSScene scene = main->GetCurrentScene();
|
||||
|
||||
@ -2107,7 +2107,7 @@ void OBSBasicPreview::DrawSceneEditing()
|
||||
|
||||
GS_DEBUG_MARKER_BEGIN(GS_DEBUG_COLOR_DEFAULT, "DrawSceneEditing");
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
gs_effect_t *solid = obs_get_base_effect(OBS_EFFECT_SOLID);
|
||||
gs_technique_t *tech = gs_effect_get_technique(solid, "Solid");
|
||||
|
@ -189,7 +189,7 @@ OBSBasicStats::OBSBasicStats(QWidget *parent, bool closable)
|
||||
QObject::connect(&recTimeLeft, &QTimer::timeout, this, &OBSBasicStats::RecordingTimeLeft);
|
||||
recTimeLeft.setInterval(REC_TIME_LEFT_INTERVAL);
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
const char *geometry = config_get_string(main->Config(), "Stats", "geometry");
|
||||
if (geometry != NULL) {
|
||||
@ -211,7 +211,7 @@ OBSBasicStats::OBSBasicStats(QWidget *parent, bool closable)
|
||||
|
||||
void OBSBasicStats::closeEvent(QCloseEvent *event)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
if (isVisible()) {
|
||||
config_set_string(main->Config(), "Stats", "geometry", saveGeometry().toBase64().constData());
|
||||
config_save_safe(main->Config(), "tmp", nullptr);
|
||||
@ -265,7 +265,7 @@ void OBSBasicStats::InitializeValues()
|
||||
|
||||
void OBSBasicStats::Update()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
/* TODO: Un-hardcode */
|
||||
|
||||
|
@ -39,13 +39,13 @@ void OBSBasic::on_actionCopyTransform_triggered()
|
||||
void OBSBasic::on_actionPasteTransform_triggered()
|
||||
{
|
||||
OBSDataAutoRelease wrapper = obs_scene_save_transform_states(GetCurrentScene(), false);
|
||||
auto func = [](obs_scene_t *, obs_sceneitem_t *item, void *data) {
|
||||
auto func = [](obs_scene_t *, obs_sceneitem_t *item, void *) {
|
||||
if (!obs_sceneitem_selected(item))
|
||||
return true;
|
||||
if (obs_sceneitem_locked(item))
|
||||
return true;
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(data);
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
obs_sceneitem_defer_update_begin(item);
|
||||
obs_sceneitem_set_info2(item, &main->copiedTransformInfo);
|
||||
@ -55,7 +55,7 @@ void OBSBasic::on_actionPasteTransform_triggered()
|
||||
return true;
|
||||
};
|
||||
|
||||
obs_scene_enum_items(GetCurrentScene(), func, this);
|
||||
obs_scene_enum_items(GetCurrentScene(), func, nullptr);
|
||||
|
||||
OBSDataAutoRelease rwrapper = obs_scene_save_transform_states(GetCurrentScene(), false);
|
||||
|
||||
|
@ -122,7 +122,7 @@ void OBSBasic::AddDropURL(const char *url, QString &name, obs_data_t *settings,
|
||||
|
||||
void OBSBasic::AddDropSource(const char *data, DropType image)
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSDataAutoRelease settings = obs_data_create();
|
||||
const char *type = nullptr;
|
||||
QString name;
|
||||
|
@ -360,7 +360,7 @@ void OBSBasic::RefreshSceneCollections(bool refreshCache)
|
||||
|
||||
ui->actionRemoveSceneCollection->setEnabled(numAddedCollections > 1);
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
main->ui->actionPasteFilters->setEnabled(false);
|
||||
main->ui->actionPasteRef->setEnabled(false);
|
||||
|
@ -1029,7 +1029,7 @@ void undo_redo(const std::string &data)
|
||||
{
|
||||
OBSDataAutoRelease dat = obs_data_create_from_json(data.c_str());
|
||||
OBSSourceAutoRelease source = obs_get_source_by_uuid(obs_data_get_string(dat, "scene_uuid"));
|
||||
reinterpret_cast<OBSBasic *>(App()->GetMainWindow())->SetCurrentScene(source.Get(), true);
|
||||
OBSBasic::Get()->SetCurrentScene(source.Get(), true);
|
||||
|
||||
obs_scene_load_transform_states(data.c_str());
|
||||
}
|
||||
|
@ -101,7 +101,7 @@ void OBSBasic::AddScene(OBSSource source)
|
||||
obs_hotkey_register_source(
|
||||
source, "OBSBasic.SelectScene", Str("Basic.Hotkeys.SelectScene"),
|
||||
[](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
auto potential_source = static_cast<obs_source_t *>(data);
|
||||
OBSSourceAutoRelease source = obs_source_get_ref(potential_source);
|
||||
|
@ -83,7 +83,7 @@ void OBSBasic::AddQuickTransitionHotkey(QuickTransition *qt)
|
||||
|
||||
auto quickTransition = [](void *data, obs_hotkey_id, obs_hotkey_t *, bool pressed) {
|
||||
int id = (int)(uintptr_t)data;
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
if (pressed)
|
||||
QMetaObject::invokeMethod(main, "TriggerQuickTransition", Qt::QueuedConnection, Q_ARG(int, id));
|
||||
@ -891,7 +891,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible)
|
||||
duration->setValue(curDuration);
|
||||
|
||||
auto setTransition = [this](QAction *action, bool visible) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
QString id = action->property("transition_id").toString();
|
||||
OBSSceneItem sceneItem = main->GetCurrentSceneItem();
|
||||
@ -940,7 +940,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible)
|
||||
undo_redo, undo_redo, undo_data, redo_data);
|
||||
};
|
||||
auto setDuration = [visible](int duration) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
OBSSceneItem item = main->GetCurrentSceneItem();
|
||||
obs_sceneitem_set_transition_duration(item, visible, duration);
|
||||
@ -976,7 +976,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible)
|
||||
}
|
||||
|
||||
auto copyTransition = [this](QAction *, bool visible) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSSceneItem item = main->GetCurrentSceneItem();
|
||||
obs_source_t *tr = obs_sceneitem_get_transition(item, visible);
|
||||
int trDur = obs_sceneitem_get_transition_duration(item, visible);
|
||||
@ -989,7 +989,7 @@ QMenu *OBSBasic::CreateVisibilityTransitionMenu(bool visible)
|
||||
connect(action, &QAction::triggered, std::bind(copyTransition, action, visible));
|
||||
|
||||
auto pasteTransition = [this](QAction *, bool show) {
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSSource tr = OBSGetStrongRef(main->copySourceTransition);
|
||||
int trDuration = main->copySourceTransitionDuration;
|
||||
if (!tr)
|
||||
|
@ -157,7 +157,7 @@ void OBSProjector::OBSRender(void *data, uint32_t cx, uint32_t cy)
|
||||
if (!window->ready)
|
||||
return;
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
OBSSource source = window->GetSource();
|
||||
|
||||
uint32_t targetCX;
|
||||
@ -297,7 +297,7 @@ void OBSProjector::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
void OBSProjector::EscapeTriggered()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
main->DeleteProjector(this);
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ enum class ListOpt : int {
|
||||
|
||||
static OBSData OpenServiceSettings(std::string &type)
|
||||
{
|
||||
const OBSBasic *basic = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
const OBSBasic *basic = OBSBasic::Get();
|
||||
const OBSProfile ¤tProfile = basic->GetCurrentProfile();
|
||||
|
||||
const std::filesystem::path jsonFilePath = currentProfile.path / std::filesystem::u8path(OBSServiceFileName);
|
||||
@ -66,7 +66,7 @@ AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent)
|
||||
proc_handler_call(ph, "amazon_ivs_ingests_refresh", &cd);
|
||||
calldata_free(&cd);
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(parent);
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
main->EnableOutputs(false);
|
||||
|
||||
installEventFilter(CreateShortcutFilter());
|
||||
@ -205,7 +205,7 @@ AutoConfig::AutoConfig(QWidget *parent) : QWizard(parent)
|
||||
|
||||
AutoConfig::~AutoConfig()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
main->EnableOutputs(true);
|
||||
EnableThreadedMessageBoxes(false);
|
||||
}
|
||||
@ -292,7 +292,7 @@ inline const char *AutoConfig::GetEncoderId(Encoder enc)
|
||||
|
||||
void AutoConfig::SaveStreamSettings()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
/* ---------------------------------- */
|
||||
/* save service */
|
||||
@ -356,7 +356,7 @@ void AutoConfig::SaveStreamSettings()
|
||||
|
||||
void AutoConfig::SaveSettings()
|
||||
{
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
|
||||
if (recordingEncoder != Encoder::Stream)
|
||||
config_set_string(main->Config(), "SimpleOutput", "RecEncoder", GetEncoderId(recordingEncoder));
|
||||
|
@ -157,7 +157,7 @@ void AutoConfigTestPage::TestBandwidthThread()
|
||||
|
||||
obs_data_set_int(aencoder_settings, "bitrate", 32);
|
||||
|
||||
OBSBasic *main = reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
|
||||
OBSBasic *main = OBSBasic::Get();
|
||||
const char *bind_ip = config_get_string(main->Config(), "Output", "BindIP");
|
||||
obs_data_set_string(output_settings, "bind_ip", bind_ip);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user