mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-03-22 01:44:49 -05:00
implement export/import of settings
This commit is contained in:
parent
4bd8cdf5a0
commit
560044bbbf
|
|
@ -452,7 +452,7 @@
|
|||
<item>
|
||||
<widget class="QPushButton" name="exportSettings">
|
||||
<property name="text">
|
||||
<string>Export settings from file</string>
|
||||
<string>Export settings to file</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
|
|
|
|||
|
|
@ -37,6 +37,11 @@ SceneSwitcher::SceneSwitcher(QWidget *parent)
|
|||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
switcher->Prune();
|
||||
loadUI();
|
||||
}
|
||||
|
||||
void SceneSwitcher::loadUI()
|
||||
{
|
||||
|
||||
BPtr<char *> scenes = obs_frontend_get_scene_names();
|
||||
char **temp = scenes;
|
||||
|
|
@ -626,7 +631,7 @@ void switchScene(OBSWeakSource &scene, OBSWeakSource &transition,
|
|||
|
||||
if (switcher->verbose)
|
||||
blog(LOG_INFO,
|
||||
"Advanced Scene Switcher switched scene");
|
||||
"Advanced Scene Switcher switched scene");
|
||||
|
||||
obs_weak_source_release(nextTransitionWs);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
#include "headers/advanced-scene-switcher.hpp"
|
||||
#include <obs-module.h>
|
||||
#include <QFileDialog>
|
||||
#include <QTextStream>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "headers/advanced-scene-switcher.hpp"
|
||||
|
||||
void SceneSwitcher::on_close_clicked()
|
||||
{
|
||||
|
|
@ -162,6 +166,86 @@ void SceneSwitcher::on_verboseLogging_stateChanged(int state)
|
|||
switcher->verbose = state;
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_exportSettings_clicked()
|
||||
{
|
||||
QString directory = QFileDialog::getSaveFileName(
|
||||
this, tr("Export Advanced Scene Switcher settings to file ..."),
|
||||
QDir::currentPath(), tr("Text files (*.txt)"));
|
||||
if (!directory.isEmpty()) {
|
||||
QFile file(directory);
|
||||
if (!file.open(QIODevice::WriteOnly | QIODevice::Text))
|
||||
return;
|
||||
|
||||
obs_data_t *obj = obs_data_create();
|
||||
|
||||
switcher->saveWindowTitleSwitches(obj);
|
||||
switcher->saveScreenRegionSwitches(obj);
|
||||
switcher->savePauseSwitches(obj);
|
||||
switcher->saveSceneRoundTripSwitches(obj);
|
||||
switcher->saveSceneTransitions(obj);
|
||||
switcher->saveIdleSwitches(obj);
|
||||
switcher->saveExecutableSwitches(obj);
|
||||
switcher->saveRandomSwitches(obj);
|
||||
switcher->saveFileSwitches(obj);
|
||||
switcher->saveMediaSwitches(obj);
|
||||
switcher->saveTimeSwitches(obj);
|
||||
switcher->saveGeneralSettings(obj);
|
||||
|
||||
obs_data_save_json(obj, file.fileName().toUtf8().constData());
|
||||
|
||||
obs_data_release(obj);
|
||||
}
|
||||
}
|
||||
|
||||
void SceneSwitcher::on_importSettings_clicked()
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(switcher->m);
|
||||
|
||||
QString directory = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Import Advanced Scene Switcher settings from file ..."),
|
||||
QDir::currentPath(), tr("Text files (*.txt)"));
|
||||
if (!directory.isEmpty()) {
|
||||
QFile file(directory);
|
||||
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||
return;
|
||||
|
||||
QTextStream in(&file);
|
||||
|
||||
obs_data_t *obj = obs_data_create_from_json_file(
|
||||
file.fileName().toUtf8().constData());
|
||||
|
||||
if (!obj) {
|
||||
QMessageBox Msgbox;
|
||||
Msgbox.setText(
|
||||
"Advanced Scene Switcher failed to import settings");
|
||||
Msgbox.exec();
|
||||
return;
|
||||
}
|
||||
|
||||
switcher->loadWindowTitleSwitches(obj);
|
||||
switcher->loadScreenRegionSwitches(obj);
|
||||
switcher->loadPauseSwitches(obj);
|
||||
switcher->loadSceneRoundTripSwitches(obj);
|
||||
switcher->loadSceneTransitions(obj);
|
||||
switcher->loadIdleSwitches(obj);
|
||||
switcher->loadExecutableSwitches(obj);
|
||||
switcher->loadRandomSwitches(obj);
|
||||
switcher->loadFileSwitches(obj);
|
||||
switcher->loadMediaSwitches(obj);
|
||||
switcher->loadTimeSwitches(obj);
|
||||
switcher->loadGeneralSettings(obj);
|
||||
|
||||
obs_data_release(obj);
|
||||
|
||||
QMessageBox Msgbox;
|
||||
Msgbox.setText(
|
||||
"Advanced Scene Switcher settings imported successfully");
|
||||
Msgbox.exec();
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
void SwitcherData::saveGeneralSettings(obs_data_t *obj)
|
||||
{
|
||||
obs_data_set_int(obj, "interval", switcher->interval);
|
||||
|
|
|
|||
|
|
@ -49,6 +49,8 @@ public:
|
|||
void UpdateIdleDataTransition(const QString &name);
|
||||
void UpdateIdleDataScene(const QString &name);
|
||||
|
||||
void loadUI();
|
||||
|
||||
public slots:
|
||||
void on_switches_currentRowChanged(int idx);
|
||||
void on_up_clicked();
|
||||
|
|
@ -90,6 +92,9 @@ public slots:
|
|||
|
||||
void on_verboseLogging_stateChanged(int state);
|
||||
|
||||
void on_exportSettings_clicked();
|
||||
void on_importSettings_clicked();
|
||||
|
||||
void on_sceneTransitions_currentRowChanged(int idx);
|
||||
void on_transitionsAdd_clicked();
|
||||
void on_transitionsRemove_clicked();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user