window-basic-main.hpp 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /******************************************************************************
  2. Copyright (C) 2013-2014 by Hugh Bailey <[email protected]>
  3. This program is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 2 of the License, or
  6. (at your option) any later version.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. ******************************************************************************/
  14. #pragma once
  15. #include <obs.hpp>
  16. #include <unordered_map>
  17. #include <memory>
  18. #include "window-main.hpp"
  19. #include <util/util.hpp>
  20. class QListWidgetItem;
  21. #include "ui_OBSBasic.h"
  22. class OBSBasic : public OBSMainWindow {
  23. Q_OBJECT
  24. private:
  25. std::unordered_map<obs_source_t, int> sourceSceneRefs;
  26. obs_output_t outputTest;
  27. bool sceneChanging;
  28. int previewX, previewY;
  29. float previewScale;
  30. int resizeTimer;
  31. ConfigFile basicConfig;
  32. void GetFPSCommon(uint32_t &num, uint32_t &den) const;
  33. void GetFPSInteger(uint32_t &num, uint32_t &den) const;
  34. void GetFPSFraction(uint32_t &num, uint32_t &den) const;
  35. void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const;
  36. void GetConfigFPS(uint32_t &num, uint32_t &den) const;
  37. bool InitBasicConfigDefaults();
  38. bool InitBasicConfig();
  39. OBSScene GetCurrentScene();
  40. OBSSceneItem GetCurrentSceneItem();
  41. void UpdateSources(OBSScene scene);
  42. void InsertSceneItem(obs_sceneitem_t item);
  43. private slots:
  44. void AddSceneItem(OBSSceneItem item);
  45. void RemoveSceneItem(OBSSceneItem item);
  46. void AddScene(OBSSource source);
  47. void RemoveScene(OBSSource source);
  48. void UpdateSceneSelection(OBSSource source);
  49. private:
  50. /* OBS Callbacks */
  51. static void SceneItemAdded(void *data, calldata_t params);
  52. static void SceneItemRemoved(void *data, calldata_t params);
  53. static void SourceAdded(void *data, calldata_t params);
  54. static void SourceRemoved(void *data, calldata_t params);
  55. static void ChannelChanged(void *data, calldata_t params);
  56. static void RenderMain(void *data, uint32_t cx, uint32_t cy);
  57. void ResizePreview(uint32_t cx, uint32_t cy);
  58. void AddSource(obs_scene_t scene, const char *id);
  59. void AddSourcePopupMenu(const QPoint &pos);
  60. public:
  61. bool ResetVideo();
  62. bool ResetAudio();
  63. void ResetAudioDevice(const char *sourceId, const char *deviceName,
  64. int channel);
  65. void ResetAudioDevices();
  66. void NewProject();
  67. void SaveProject();
  68. void LoadProject();
  69. protected:
  70. virtual void closeEvent(QCloseEvent *event) override;
  71. virtual void changeEvent(QEvent *event) override;
  72. virtual void resizeEvent(QResizeEvent *event) override;
  73. virtual void timerEvent(QTimerEvent *event) override;
  74. private slots:
  75. void on_action_New_triggered();
  76. void on_action_Open_triggered();
  77. void on_action_Save_triggered();
  78. void on_scenes_currentItemChanged(QListWidgetItem *current,
  79. QListWidgetItem *prev);
  80. void on_scenes_customContextMenuRequested(const QPoint &pos);
  81. void on_actionAddScene_triggered();
  82. void on_actionRemoveScene_triggered();
  83. void on_actionSceneProperties_triggered();
  84. void on_actionSceneUp_triggered();
  85. void on_actionSceneDown_triggered();
  86. void on_sources_currentItemChanged(QListWidgetItem *current,
  87. QListWidgetItem *prev);
  88. void on_sources_customContextMenuRequested(const QPoint &pos);
  89. void on_actionAddSource_triggered();
  90. void on_actionRemoveSource_triggered();
  91. void on_actionSourceProperties_triggered();
  92. void on_actionSourceUp_triggered();
  93. void on_actionSourceDown_triggered();
  94. void on_recordButton_clicked();
  95. void on_settingsButton_clicked();
  96. public:
  97. explicit OBSBasic(QWidget *parent = 0);
  98. virtual ~OBSBasic();
  99. virtual void OBSInit() override;
  100. virtual config_t Config() const override;
  101. private:
  102. std::unique_ptr<Ui::OBSBasic> ui;
  103. };