UI: Save project only on new changes
This commit is contained in:
parent
4b93b42ded
commit
da358da9a7
@ -3,6 +3,7 @@
|
|||||||
#include <QScrollArea>
|
#include <QScrollArea>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include "window-basic-adv-audio.hpp"
|
#include "window-basic-adv-audio.hpp"
|
||||||
|
#include "window-basic-main.hpp"
|
||||||
#include "adv-audio-control.hpp"
|
#include "adv-audio-control.hpp"
|
||||||
#include "obs-app.hpp"
|
#include "obs-app.hpp"
|
||||||
#include "qt-wrappers.hpp"
|
#include "qt-wrappers.hpp"
|
||||||
@ -86,8 +87,12 @@ OBSBasicAdvAudio::OBSBasicAdvAudio(QWidget *parent)
|
|||||||
|
|
||||||
OBSBasicAdvAudio::~OBSBasicAdvAudio()
|
OBSBasicAdvAudio::~OBSBasicAdvAudio()
|
||||||
{
|
{
|
||||||
|
OBSBasic *main = reinterpret_cast<OBSBasic*>(parent());
|
||||||
|
|
||||||
for (size_t i = 0; i < controls.size(); ++i)
|
for (size_t i = 0; i < controls.size(); ++i)
|
||||||
delete controls[i];
|
delete controls[i];
|
||||||
|
|
||||||
|
main->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OBSBasicAdvAudio::EnumSources(void *param, obs_source_t *source)
|
bool OBSBasicAdvAudio::EnumSources(void *param, obs_source_t *source)
|
||||||
|
@ -16,6 +16,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "window-namedialog.hpp"
|
#include "window-namedialog.hpp"
|
||||||
|
#include "window-basic-main.hpp"
|
||||||
#include "window-basic-filters.hpp"
|
#include "window-basic-filters.hpp"
|
||||||
#include "display-helpers.hpp"
|
#include "display-helpers.hpp"
|
||||||
#include "qt-wrappers.hpp"
|
#include "qt-wrappers.hpp"
|
||||||
@ -56,6 +57,8 @@ OBSBasicFilters::OBSBasicFilters(QWidget *parent, OBSSource source_)
|
|||||||
"rename",
|
"rename",
|
||||||
OBSBasicFilters::SourceRenamed, this)
|
OBSBasicFilters::SourceRenamed, this)
|
||||||
{
|
{
|
||||||
|
main = reinterpret_cast<OBSBasic*>(parent);
|
||||||
|
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
UpdateFilters();
|
UpdateFilters();
|
||||||
|
|
||||||
@ -199,6 +202,8 @@ void OBSBasicFilters::RemoveFilter(OBSSource filter)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
main->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FilterOrderInfo {
|
struct FilterOrderInfo {
|
||||||
@ -282,6 +287,8 @@ void OBSBasicFilters::UpdateFilters()
|
|||||||
|
|
||||||
window->AddFilter(filter);
|
window->AddFilter(filter);
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
|
main->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool filter_compatible(bool async, uint32_t sourceFlags,
|
static bool filter_compatible(bool async, uint32_t sourceFlags,
|
||||||
@ -404,6 +411,8 @@ void OBSBasicFilters::closeEvent(QCloseEvent *event)
|
|||||||
obs_display_remove_draw_callback(display,
|
obs_display_remove_draw_callback(display,
|
||||||
OBSBasicFilters::DrawPreview, this);
|
OBSBasicFilters::DrawPreview, this);
|
||||||
display = nullptr;
|
display = nullptr;
|
||||||
|
|
||||||
|
main->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasicFilters::timerEvent(QTimerEvent *event)
|
void OBSBasicFilters::timerEvent(QTimerEvent *event)
|
||||||
|
@ -345,6 +345,8 @@ static inline bool HasAudioDevices(const char *source_id)
|
|||||||
|
|
||||||
void OBSBasic::CreateDefaultScene()
|
void OBSBasic::CreateDefaultScene()
|
||||||
{
|
{
|
||||||
|
disableSaving++;
|
||||||
|
|
||||||
bool hasDesktopAudio = HasAudioDevices(App()->OutputAudioSource());
|
bool hasDesktopAudio = HasAudioDevices(App()->OutputAudioSource());
|
||||||
bool hasInputAudio = HasAudioDevices(App()->InputAudioSource());
|
bool hasInputAudio = HasAudioDevices(App()->InputAudioSource());
|
||||||
|
|
||||||
@ -375,6 +377,8 @@ void OBSBasic::CreateDefaultScene()
|
|||||||
if (hasInputAudio)
|
if (hasInputAudio)
|
||||||
ResetAudioDevice(App()->InputAudioSource(), "default",
|
ResetAudioDevice(App()->InputAudioSource(), "default",
|
||||||
Str("Basic.AuxDevice1"), 3);
|
Str("Basic.AuxDevice1"), 3);
|
||||||
|
|
||||||
|
disableSaving--;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ReorderItemByName(QListWidget *lw, const char *name, int newIndex)
|
static void ReorderItemByName(QListWidget *lw, const char *name, int newIndex)
|
||||||
@ -420,6 +424,8 @@ void OBSBasic::Load(const char *file)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
disableSaving++;
|
||||||
|
|
||||||
ClearSceneData();
|
ClearSceneData();
|
||||||
|
|
||||||
obs_data_t *data = obs_data_create_from_json(jsonData);
|
obs_data_t *data = obs_data_create_from_json(jsonData);
|
||||||
@ -447,6 +453,8 @@ void OBSBasic::Load(const char *file)
|
|||||||
obs_data_array_release(sources);
|
obs_data_array_release(sources);
|
||||||
obs_data_array_release(sceneOrder);
|
obs_data_array_release(sceneOrder);
|
||||||
obs_data_release(data);
|
obs_data_release(data);
|
||||||
|
|
||||||
|
disableSaving--;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define SERVICE_PATH "obs-studio/basic/service.json"
|
#define SERVICE_PATH "obs-studio/basic/service.json"
|
||||||
@ -745,7 +753,9 @@ void OBSBasic::OBSInit()
|
|||||||
|
|
||||||
InitPrimitives();
|
InitPrimitives();
|
||||||
|
|
||||||
|
disableSaving--;
|
||||||
Load(savePath);
|
Load(savePath);
|
||||||
|
disableSaving++;
|
||||||
|
|
||||||
TimedCheckForUpdates();
|
TimedCheckForUpdates();
|
||||||
loaded = true;
|
loaded = true;
|
||||||
@ -764,6 +774,8 @@ void OBSBasic::OBSInit()
|
|||||||
SetAeroEnabled(!disableAero);
|
SetAeroEnabled(!disableAero);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
disableSaving--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::InitHotkeys()
|
void OBSBasic::InitHotkeys()
|
||||||
@ -989,6 +1001,9 @@ OBSBasic::~OBSBasic()
|
|||||||
|
|
||||||
void OBSBasic::SaveProject()
|
void OBSBasic::SaveProject()
|
||||||
{
|
{
|
||||||
|
if (disableSaving)
|
||||||
|
return;
|
||||||
|
|
||||||
char savePath[512];
|
char savePath[512];
|
||||||
int ret = GetConfigPath(savePath, sizeof(savePath),
|
int ret = GetConfigPath(savePath, sizeof(savePath),
|
||||||
"obs-studio/basic/scenes.json");
|
"obs-studio/basic/scenes.json");
|
||||||
@ -1116,6 +1131,8 @@ void OBSBasic::AddScene(OBSSource source)
|
|||||||
|
|
||||||
item->setData(static_cast<int>(QtDataRole::OBSSignals),
|
item->setData(static_cast<int>(QtDataRole::OBSSignals),
|
||||||
QVariant::fromValue(handlers));
|
QVariant::fromValue(handlers));
|
||||||
|
|
||||||
|
SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::RemoveScene(OBSSource source)
|
void OBSBasic::RemoveScene(OBSSource source)
|
||||||
@ -1131,6 +1148,8 @@ void OBSBasic::RemoveScene(OBSSource source)
|
|||||||
ClearListItems(ui->sources);
|
ClearListItems(ui->sources);
|
||||||
delete sel;
|
delete sel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::AddSceneItem(OBSSceneItem item)
|
void OBSBasic::AddSceneItem(OBSSceneItem item)
|
||||||
@ -1142,6 +1161,7 @@ void OBSBasic::AddSceneItem(OBSSceneItem item)
|
|||||||
InsertSceneItem(item);
|
InsertSceneItem(item);
|
||||||
|
|
||||||
sourceSceneRefs[source] = sourceSceneRefs[source] + 1;
|
sourceSceneRefs[source] = sourceSceneRefs[source] + 1;
|
||||||
|
SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::RemoveSceneItem(OBSSceneItem item)
|
void OBSBasic::RemoveSceneItem(OBSSceneItem item)
|
||||||
@ -1168,6 +1188,8 @@ void OBSBasic::RemoveSceneItem(OBSSceneItem item)
|
|||||||
obs_source_remove(source);
|
obs_source_remove(source);
|
||||||
sourceSceneRefs.erase(source);
|
sourceSceneRefs.erase(source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::UpdateSceneSelection(OBSSource source)
|
void OBSBasic::UpdateSceneSelection(OBSSource source)
|
||||||
@ -1210,6 +1232,8 @@ void OBSBasic::RenameSources(QString newName, QString prevName)
|
|||||||
if (volumes[i]->GetName().compare(prevName) == 0)
|
if (volumes[i]->GetName().compare(prevName) == 0)
|
||||||
volumes[i]->SetName(newName);
|
volumes[i]->SetName(newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::SelectSceneItem(OBSScene scene, OBSSceneItem item, bool select)
|
void OBSBasic::SelectSceneItem(OBSScene scene, OBSSceneItem item, bool select)
|
||||||
@ -1507,6 +1531,8 @@ void OBSBasic::ReorderSources(OBSScene scene)
|
|||||||
info->idx++);
|
info->idx++);
|
||||||
return true;
|
return true;
|
||||||
}, &info);
|
}, &info);
|
||||||
|
|
||||||
|
SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* OBS Callbacks */
|
/* OBS Callbacks */
|
||||||
@ -1942,6 +1968,8 @@ void OBSBasic::CloseDialogs()
|
|||||||
|
|
||||||
void OBSBasic::ClearSceneData()
|
void OBSBasic::ClearSceneData()
|
||||||
{
|
{
|
||||||
|
disableSaving++;
|
||||||
|
|
||||||
CloseDialogs();
|
CloseDialogs();
|
||||||
|
|
||||||
ClearVolumeControls();
|
ClearVolumeControls();
|
||||||
@ -1965,6 +1993,8 @@ void OBSBasic::ClearSceneData()
|
|||||||
obs_enum_sources(cb, nullptr);
|
obs_enum_sources(cb, nullptr);
|
||||||
|
|
||||||
sourceSceneRefs.clear();
|
sourceSceneRefs.clear();
|
||||||
|
|
||||||
|
disableSaving--;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasic::closeEvent(QCloseEvent *event)
|
void OBSBasic::closeEvent(QCloseEvent *event)
|
||||||
@ -1996,6 +2026,7 @@ void OBSBasic::closeEvent(QCloseEvent *event)
|
|||||||
obs_remove_draw_callback(OBSBasic::RenderMain, this);
|
obs_remove_draw_callback(OBSBasic::RenderMain, this);
|
||||||
|
|
||||||
SaveProject();
|
SaveProject();
|
||||||
|
disableSaving++;
|
||||||
|
|
||||||
/* Clear all scene data (dialogs, widgets, widget sub-items, scenes,
|
/* Clear all scene data (dialogs, widgets, widget sub-items, scenes,
|
||||||
* sources, etc) so that all references are released before shutdown */
|
* sources, etc) so that all references are released before shutdown */
|
||||||
|
@ -74,6 +74,7 @@ private:
|
|||||||
std::vector<OBSSignal> signalHandlers;
|
std::vector<OBSSignal> signalHandlers;
|
||||||
|
|
||||||
bool loaded = false;
|
bool loaded = false;
|
||||||
|
long disableSaving = 1;
|
||||||
|
|
||||||
QPointer<QThread> updateCheckThread;
|
QPointer<QThread> updateCheckThread;
|
||||||
QPointer<QThread> logUploadThread;
|
QPointer<QThread> logUploadThread;
|
||||||
|
@ -103,6 +103,7 @@ OBSBasicProperties::OBSBasicProperties(QWidget *parent, OBSSource source_)
|
|||||||
OBSBasicProperties::~OBSBasicProperties()
|
OBSBasicProperties::~OBSBasicProperties()
|
||||||
{
|
{
|
||||||
obs_source_dec_showing(source);
|
obs_source_dec_showing(source);
|
||||||
|
main->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OBSBasicProperties::SourceRemoved(void *data, calldata_t *params)
|
void OBSBasicProperties::SourceRemoved(void *data, calldata_t *params)
|
||||||
|
@ -2159,6 +2159,7 @@ void OBSBasicSettings::SaveSettings()
|
|||||||
|
|
||||||
config_save(main->Config());
|
config_save(main->Config());
|
||||||
config_save(GetGlobalConfig());
|
config_save(GetGlobalConfig());
|
||||||
|
main->SaveProject();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OBSBasicSettings::QueryChanges()
|
bool OBSBasicSettings::QueryChanges()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user