Backup setting on exit to plugin config dir

Only one version of the settings file will be kept per scene collection
and plugin version combination
This commit is contained in:
WarmUpTill
2024-02-27 21:19:49 +01:00
committed by WarmUpTill
parent f50f31ec4c
commit 2b2bab8fbc
6 changed files with 106 additions and 30 deletions

View File

@@ -1,4 +1,5 @@
#include "advanced-scene-switcher.hpp"
#include "backup.hpp"
#include "curl-helper.hpp"
#include "log-helper.hpp"
#include "macro-helpers.hpp"
@@ -17,7 +18,6 @@
#include <obs-frontend-api.h>
#include <QAction>
#include <QDirIterator>
#include <QFileDialog>
#include <QMainWindow>
#include <QTextStream>
#include <regex>
@@ -143,7 +143,6 @@ bool AdvSceneSwitcher::eventFilter(QObject *obj, QEvent *event)
/******************************************************************************
* Saving and loading
******************************************************************************/
static void AskForBackup(const QString &json);
static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
{
@@ -192,34 +191,6 @@ static void SaveSceneSwitcher(obs_data_t *save_data, bool saving, void *)
}
}
static void AskForBackup(const QString &json)
{
const bool backupWasConfirmed = DisplayMessage(
obs_module_text("AdvSceneSwitcher.askBackup"), true, false);
if (!backupWasConfirmed) {
return;
}
QString path = QFileDialog::getSaveFileName(
nullptr,
obs_module_text(
"AdvSceneSwitcher.generalTab.saveOrLoadsettings.exportWindowTitle"),
GetDefaultSettingsSaveLocation(),
obs_module_text(
"AdvSceneSwitcher.generalTab.saveOrLoadsettings.textType"));
if (path.isEmpty()) {
return;
}
QFile file(path);
if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) {
return;
}
auto out = QTextStream(&file);
out << json;
}
/******************************************************************************
* Main switcher thread
******************************************************************************/
@@ -635,6 +606,8 @@ static void handleShutdown()
// TODO: Look for a way to possibly resolve this
obs_frontend_save();
}
BackupSettingsOfCurrentVersion();
}
static void handleSceneCollectionChanging()