DecklinkOutputUI.cpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "DecklinkOutputUI.h"
  2. #include <obs-module.h>
  3. #include <util/platform.h>
  4. #include <util/util.hpp>
  5. #include "decklink-ui-main.h"
  6. DecklinkOutputUI::DecklinkOutputUI(QWidget *parent)
  7. : QDialog(parent),
  8. ui(new Ui_Output)
  9. {
  10. ui->setupUi(this);
  11. propertiesView = nullptr;
  12. connect(ui->startOutput, SIGNAL(released()), this, SLOT(StartOutput()));
  13. connect(ui->stopOutput, SIGNAL(released()), this, SLOT(StopOutput()));
  14. }
  15. void DecklinkOutputUI::ShowHideDialog()
  16. {
  17. SetupPropertiesView();
  18. setVisible(!isVisible());
  19. }
  20. void DecklinkOutputUI::SetupPropertiesView()
  21. {
  22. if (propertiesView)
  23. delete propertiesView;
  24. obs_data_t *settings = obs_data_create();
  25. OBSData data = load_settings();
  26. if (data)
  27. obs_data_apply(settings, data);
  28. propertiesView = new OBSPropertiesView(settings,
  29. "decklink_output",
  30. (PropertiesReloadCallback) obs_get_output_properties,
  31. 170);
  32. ui->propertiesLayout->addWidget(propertiesView);
  33. obs_data_release(settings);
  34. connect(propertiesView, SIGNAL(Changed()), this, SLOT(PropertiesChanged()));
  35. }
  36. void DecklinkOutputUI::SaveSettings()
  37. {
  38. BPtr<char> modulePath = obs_module_get_config_path(obs_current_module(), "");
  39. os_mkdirs(modulePath);
  40. BPtr<char> path = obs_module_get_config_path(obs_current_module(),
  41. "decklinkOutputProps.json");
  42. obs_data_t *settings = propertiesView->GetSettings();
  43. if (settings)
  44. obs_data_save_json_safe(settings, path, "tmp", "bak");
  45. }
  46. void DecklinkOutputUI::StartOutput()
  47. {
  48. SaveSettings();
  49. output_start();
  50. }
  51. void DecklinkOutputUI::StopOutput()
  52. {
  53. output_stop();
  54. }
  55. void DecklinkOutputUI::PropertiesChanged()
  56. {
  57. SaveSettings();
  58. }