DecklinkOutputUI.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
  12. propertiesView = nullptr;
  13. connect(ui->startOutput, SIGNAL(released()), this, SLOT(StartOutput()));
  14. connect(ui->stopOutput, SIGNAL(released()), this, SLOT(StopOutput()));
  15. }
  16. void DecklinkOutputUI::ShowHideDialog()
  17. {
  18. SetupPropertiesView();
  19. setVisible(!isVisible());
  20. }
  21. void DecklinkOutputUI::SetupPropertiesView()
  22. {
  23. if (propertiesView)
  24. delete propertiesView;
  25. obs_data_t *settings = obs_data_create();
  26. OBSData data = load_settings();
  27. if (data)
  28. obs_data_apply(settings, data);
  29. propertiesView = new OBSPropertiesView(settings,
  30. "decklink_output",
  31. (PropertiesReloadCallback) obs_get_output_properties,
  32. 170);
  33. ui->propertiesLayout->addWidget(propertiesView);
  34. obs_data_release(settings);
  35. connect(propertiesView, SIGNAL(Changed()), this, SLOT(PropertiesChanged()));
  36. }
  37. void DecklinkOutputUI::SaveSettings()
  38. {
  39. BPtr<char> modulePath = obs_module_get_config_path(obs_current_module(), "");
  40. os_mkdirs(modulePath);
  41. BPtr<char> path = obs_module_get_config_path(obs_current_module(),
  42. "decklinkOutputProps.json");
  43. obs_data_t *settings = propertiesView->GetSettings();
  44. if (settings)
  45. obs_data_save_json_safe(settings, path, "tmp", "bak");
  46. }
  47. void DecklinkOutputUI::StartOutput()
  48. {
  49. SaveSettings();
  50. output_start();
  51. }
  52. void DecklinkOutputUI::StopOutput()
  53. {
  54. output_stop();
  55. }
  56. void DecklinkOutputUI::PropertiesChanged()
  57. {
  58. SaveSettings();
  59. }