window-basic-main.hpp 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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 <QBuffer>
  16. #include <QAction>
  17. #include <QWidgetAction>
  18. #include <QSystemTrayIcon>
  19. #include <QStyledItemDelegate>
  20. #include <obs.hpp>
  21. #include <vector>
  22. #include <memory>
  23. #include "window-main.hpp"
  24. #include "window-basic-interaction.hpp"
  25. #include "window-basic-properties.hpp"
  26. #include "window-basic-transform.hpp"
  27. #include "window-basic-adv-audio.hpp"
  28. #include "window-basic-filters.hpp"
  29. #include "window-projector.hpp"
  30. #include "window-basic-about.hpp"
  31. #include "auth-base.hpp"
  32. #include "log-viewer.hpp"
  33. #include <obs-frontend-internal.hpp>
  34. #include <util/platform.h>
  35. #include <util/threading.h>
  36. #include <util/util.hpp>
  37. #include <QPointer>
  38. class QMessageBox;
  39. class QListWidgetItem;
  40. class VolControl;
  41. class OBSBasicStats;
  42. #include "ui_OBSBasic.h"
  43. #include "ui_ColorSelect.h"
  44. #define DESKTOP_AUDIO_1 Str("DesktopAudioDevice1")
  45. #define DESKTOP_AUDIO_2 Str("DesktopAudioDevice2")
  46. #define AUX_AUDIO_1 Str("AuxAudioDevice1")
  47. #define AUX_AUDIO_2 Str("AuxAudioDevice2")
  48. #define AUX_AUDIO_3 Str("AuxAudioDevice3")
  49. #define AUX_AUDIO_4 Str("AuxAudioDevice4")
  50. #define SIMPLE_ENCODER_X264 "x264"
  51. #define SIMPLE_ENCODER_X264_LOWCPU "x264_lowcpu"
  52. #define SIMPLE_ENCODER_QSV "qsv"
  53. #define SIMPLE_ENCODER_NVENC "nvenc"
  54. #define SIMPLE_ENCODER_AMD "amd"
  55. #define PREVIEW_EDGE_SIZE 10
  56. struct BasicOutputHandler;
  57. enum class QtDataRole {
  58. OBSRef = Qt::UserRole,
  59. OBSSignals,
  60. };
  61. struct SavedProjectorInfo {
  62. ProjectorType type;
  63. int monitor;
  64. std::string geometry;
  65. std::string name;
  66. bool alwaysOnTop;
  67. bool alwaysOnTopOverridden;
  68. };
  69. struct QuickTransition {
  70. QPushButton *button = nullptr;
  71. OBSSource source;
  72. obs_hotkey_id hotkey = OBS_INVALID_HOTKEY_ID;
  73. int duration = 0;
  74. int id = 0;
  75. bool fadeToBlack = false;
  76. inline QuickTransition() {}
  77. inline QuickTransition(OBSSource source_, int duration_, int id_,
  78. bool fadeToBlack_ = false)
  79. : source(source_),
  80. duration(duration_),
  81. id(id_),
  82. fadeToBlack(fadeToBlack_),
  83. renamedSignal(std::make_shared<OBSSignal>(
  84. obs_source_get_signal_handler(source), "rename",
  85. SourceRenamed, this))
  86. {
  87. }
  88. private:
  89. static void SourceRenamed(void *param, calldata_t *data);
  90. std::shared_ptr<OBSSignal> renamedSignal;
  91. };
  92. class ColorSelect : public QWidget {
  93. public:
  94. explicit ColorSelect(QWidget *parent = 0);
  95. private:
  96. std::unique_ptr<Ui::ColorSelect> ui;
  97. };
  98. class OBSBasic : public OBSMainWindow {
  99. Q_OBJECT
  100. Q_PROPERTY(QIcon imageIcon READ GetImageIcon WRITE SetImageIcon
  101. DESIGNABLE true)
  102. Q_PROPERTY(QIcon colorIcon READ GetColorIcon WRITE SetColorIcon
  103. DESIGNABLE true)
  104. Q_PROPERTY(QIcon slideshowIcon READ GetSlideshowIcon WRITE
  105. SetSlideshowIcon DESIGNABLE true)
  106. Q_PROPERTY(QIcon audioInputIcon READ GetAudioInputIcon WRITE
  107. SetAudioInputIcon DESIGNABLE true)
  108. Q_PROPERTY(QIcon audioOutputIcon READ GetAudioOutputIcon WRITE
  109. SetAudioOutputIcon DESIGNABLE true)
  110. Q_PROPERTY(QIcon desktopCapIcon READ GetDesktopCapIcon WRITE
  111. SetDesktopCapIcon DESIGNABLE true)
  112. Q_PROPERTY(QIcon windowCapIcon READ GetWindowCapIcon WRITE
  113. SetWindowCapIcon DESIGNABLE true)
  114. Q_PROPERTY(QIcon gameCapIcon READ GetGameCapIcon WRITE SetGameCapIcon
  115. DESIGNABLE true)
  116. Q_PROPERTY(QIcon cameraIcon READ GetCameraIcon WRITE SetCameraIcon
  117. DESIGNABLE true)
  118. Q_PROPERTY(QIcon textIcon READ GetTextIcon WRITE SetTextIcon
  119. DESIGNABLE true)
  120. Q_PROPERTY(QIcon mediaIcon READ GetMediaIcon WRITE SetMediaIcon
  121. DESIGNABLE true)
  122. Q_PROPERTY(QIcon browserIcon READ GetBrowserIcon WRITE SetBrowserIcon
  123. DESIGNABLE true)
  124. Q_PROPERTY(QIcon groupIcon READ GetGroupIcon WRITE SetGroupIcon
  125. DESIGNABLE true)
  126. Q_PROPERTY(QIcon sceneIcon READ GetSceneIcon WRITE SetSceneIcon
  127. DESIGNABLE true)
  128. Q_PROPERTY(QIcon defaultIcon READ GetDefaultIcon WRITE SetDefaultIcon
  129. DESIGNABLE true)
  130. friend class OBSAbout;
  131. friend class OBSBasicPreview;
  132. friend class OBSBasicStatusBar;
  133. friend class OBSBasicSourceSelect;
  134. friend class OBSBasicSettings;
  135. friend class Auth;
  136. friend class AutoConfig;
  137. friend class AutoConfigStreamPage;
  138. friend class RecordButton;
  139. friend class ReplayBufferButton;
  140. friend class ExtraBrowsersModel;
  141. friend class ExtraBrowsersDelegate;
  142. friend class DeviceCaptureToolbar;
  143. friend class DeviceToolbarPropertiesThread;
  144. friend struct BasicOutputHandler;
  145. friend struct OBSStudioAPI;
  146. enum class MoveDir { Up, Down, Left, Right };
  147. enum DropType {
  148. DropType_RawText,
  149. DropType_Text,
  150. DropType_Image,
  151. DropType_Media,
  152. DropType_Html,
  153. DropType_Url,
  154. };
  155. private:
  156. obs_frontend_callbacks *api = nullptr;
  157. std::shared_ptr<Auth> auth;
  158. std::vector<VolControl *> volumes;
  159. std::vector<OBSSignal> signalHandlers;
  160. QList<QPointer<QDockWidget>> extraDocks;
  161. bool loaded = false;
  162. long disableSaving = 1;
  163. bool projectChanged = false;
  164. bool previewEnabled = true;
  165. std::list<const char *> copyStrings;
  166. const char *copyFiltersString = nullptr;
  167. bool copyVisible = true;
  168. bool closing = false;
  169. QScopedPointer<QThread> devicePropertiesThread;
  170. QScopedPointer<QThread> whatsNewInitThread;
  171. QScopedPointer<QThread> updateCheckThread;
  172. QScopedPointer<QThread> introCheckThread;
  173. QScopedPointer<QThread> logUploadThread;
  174. QPointer<OBSBasicInteraction> interaction;
  175. QPointer<OBSBasicProperties> properties;
  176. QPointer<OBSBasicTransform> transformWindow;
  177. QPointer<OBSBasicAdvAudio> advAudioWindow;
  178. QPointer<OBSBasicFilters> filters;
  179. QPointer<QDockWidget> statsDock;
  180. QPointer<OBSAbout> about;
  181. OBSLogViewer *logView = nullptr;
  182. QPointer<QTimer> cpuUsageTimer;
  183. QPointer<QTimer> diskFullTimer;
  184. os_cpu_usage_info_t *cpuUsageInfo = nullptr;
  185. OBSService service;
  186. std::unique_ptr<BasicOutputHandler> outputHandler;
  187. bool streamingStopping = false;
  188. bool recordingStopping = false;
  189. bool replayBufferStopping = false;
  190. gs_vertbuffer_t *box = nullptr;
  191. gs_vertbuffer_t *boxLeft = nullptr;
  192. gs_vertbuffer_t *boxTop = nullptr;
  193. gs_vertbuffer_t *boxRight = nullptr;
  194. gs_vertbuffer_t *boxBottom = nullptr;
  195. gs_vertbuffer_t *circle = nullptr;
  196. bool sceneChanging = false;
  197. int previewX = 0, previewY = 0;
  198. int previewCX = 0, previewCY = 0;
  199. float previewScale = 0.0f;
  200. ConfigFile basicConfig;
  201. std::vector<SavedProjectorInfo *> savedProjectorsArray;
  202. std::vector<OBSProjector *> projectors;
  203. QPointer<QWidget> stats;
  204. QPointer<QWidget> remux;
  205. QPointer<QWidget> extraBrowsers;
  206. QPointer<QWidget> importer;
  207. QPointer<QMenu> startStreamMenu;
  208. QPointer<QPushButton> transitionButton;
  209. QPointer<QPushButton> replayBufferButton;
  210. QPointer<QHBoxLayout> replayLayout;
  211. QScopedPointer<QPushButton> pause;
  212. QScopedPointer<QPushButton> replay;
  213. QPointer<QPushButton> vcamButton;
  214. bool vcamEnabled = false;
  215. QScopedPointer<QSystemTrayIcon> trayIcon;
  216. QPointer<QAction> sysTrayStream;
  217. QPointer<QAction> sysTrayRecord;
  218. QPointer<QAction> sysTrayReplayBuffer;
  219. QPointer<QAction> showHide;
  220. QPointer<QAction> exit;
  221. QPointer<QMenu> trayMenu;
  222. QPointer<QMenu> previewProjector;
  223. QPointer<QMenu> studioProgramProjector;
  224. QPointer<QMenu> multiviewProjectorMenu;
  225. QPointer<QMenu> previewProjectorSource;
  226. QPointer<QMenu> previewProjectorMain;
  227. QPointer<QMenu> sceneProjectorMenu;
  228. QPointer<QMenu> sourceProjector;
  229. QPointer<QMenu> scaleFilteringMenu;
  230. QPointer<QMenu> colorMenu;
  231. QPointer<QWidgetAction> colorWidgetAction;
  232. QPointer<ColorSelect> colorSelect;
  233. QPointer<QMenu> deinterlaceMenu;
  234. QPointer<QMenu> perSceneTransitionMenu;
  235. QPointer<QObject> shortcutFilter;
  236. QPointer<QAction> renameScene;
  237. QPointer<QAction> renameSource;
  238. QPointer<QWidget> programWidget;
  239. QPointer<QVBoxLayout> programLayout;
  240. QPointer<QLabel> programLabel;
  241. QScopedPointer<QThread> patronJsonThread;
  242. std::string patronJson;
  243. void UpdateMultiviewProjectorMenu();
  244. void DrawBackdrop(float cx, float cy);
  245. void SetupEncoders();
  246. void CreateFirstRunSources();
  247. void CreateDefaultScene(bool firstStart);
  248. void UpdateVolumeControlsDecayRate();
  249. void UpdateVolumeControlsPeakMeterType();
  250. void ClearVolumeControls();
  251. void UploadLog(const char *subdir, const char *file, const bool crash);
  252. void Save(const char *file);
  253. void Load(const char *file);
  254. void InitHotkeys();
  255. void CreateHotkeys();
  256. void ClearHotkeys();
  257. bool InitService();
  258. bool InitBasicConfigDefaults();
  259. void InitBasicConfigDefaults2();
  260. bool InitBasicConfig();
  261. void InitOBSCallbacks();
  262. void InitPrimitives();
  263. void OnFirstLoad();
  264. OBSSceneItem GetSceneItem(QListWidgetItem *item);
  265. OBSSceneItem GetCurrentSceneItem();
  266. bool QueryRemoveSource(obs_source_t *source);
  267. void TimedCheckForUpdates();
  268. void CheckForUpdates(bool manualUpdate);
  269. void GetFPSCommon(uint32_t &num, uint32_t &den) const;
  270. void GetFPSInteger(uint32_t &num, uint32_t &den) const;
  271. void GetFPSFraction(uint32_t &num, uint32_t &den) const;
  272. void GetFPSNanoseconds(uint32_t &num, uint32_t &den) const;
  273. void GetConfigFPS(uint32_t &num, uint32_t &den) const;
  274. void UpdatePreviewScalingMenu();
  275. void LoadSceneListOrder(obs_data_array_t *array);
  276. obs_data_array_t *SaveSceneListOrder();
  277. void ChangeSceneIndex(bool relative, int idx, int invalidIdx);
  278. void TempFileOutput(const char *path, int vBitrate, int aBitrate);
  279. void TempStreamOutput(const char *url, const char *key, int vBitrate,
  280. int aBitrate);
  281. void CloseDialogs();
  282. void ClearSceneData();
  283. void ClearProjectors();
  284. void Nudge(int dist, MoveDir dir);
  285. OBSProjector *OpenProjector(obs_source_t *source, int monitor,
  286. ProjectorType type);
  287. void GetAudioSourceFilters();
  288. void GetAudioSourceProperties();
  289. void VolControlContextMenu();
  290. void ToggleVolControlLayout();
  291. void ToggleMixerLayout(bool vertical);
  292. void RefreshSceneCollections();
  293. void ChangeSceneCollection();
  294. void LogScenes();
  295. void LoadProfile();
  296. void ResetProfileData();
  297. bool AddProfile(bool create_new, const char *title, const char *text,
  298. const char *init_text = nullptr, bool rename = false);
  299. void DeleteProfile(const char *profile_name, const char *profile_dir);
  300. void RefreshProfiles();
  301. void ChangeProfile();
  302. void CheckForSimpleModeX264Fallback();
  303. void SaveProjectNow();
  304. int GetTopSelectedSourceItem();
  305. QModelIndexList GetAllSelectedSourceItems();
  306. obs_hotkey_pair_id streamingHotkeys, recordingHotkeys, pauseHotkeys,
  307. replayBufHotkeys, vcamHotkeys, togglePreviewHotkeys,
  308. contextBarHotkeys;
  309. obs_hotkey_id forceStreamingStopHotkey;
  310. void InitDefaultTransitions();
  311. void InitTransition(obs_source_t *transition);
  312. obs_source_t *FindTransition(const char *name);
  313. OBSSource GetCurrentTransition();
  314. obs_data_array_t *SaveTransitions();
  315. void LoadTransitions(obs_data_array_t *transitions);
  316. obs_source_t *fadeTransition;
  317. obs_source_t *cutTransition;
  318. void CreateProgramDisplay();
  319. void CreateProgramOptions();
  320. void AddQuickTransitionId(int id);
  321. void AddQuickTransition();
  322. void AddQuickTransitionHotkey(QuickTransition *qt);
  323. void RemoveQuickTransitionHotkey(QuickTransition *qt);
  324. void LoadQuickTransitions(obs_data_array_t *array);
  325. obs_data_array_t *SaveQuickTransitions();
  326. void ClearQuickTransitionWidgets();
  327. void RefreshQuickTransitions();
  328. void DisableQuickTransitionWidgets();
  329. void EnableTransitionWidgets(bool enable);
  330. void CreateDefaultQuickTransitions();
  331. QMenu *CreatePerSceneTransitionMenu();
  332. QuickTransition *GetQuickTransition(int id);
  333. int GetQuickTransitionIdx(int id);
  334. QMenu *CreateTransitionMenu(QWidget *parent, QuickTransition *qt);
  335. void ClearQuickTransitions();
  336. void QuickTransitionClicked();
  337. void QuickTransitionChange();
  338. void QuickTransitionChangeDuration(int value);
  339. void QuickTransitionRemoveClicked();
  340. void SetPreviewProgramMode(bool enabled);
  341. void ResizeProgram(uint32_t cx, uint32_t cy);
  342. void SetCurrentScene(obs_scene_t *scene, bool force = false);
  343. static void RenderProgram(void *data, uint32_t cx, uint32_t cy);
  344. std::vector<QuickTransition> quickTransitions;
  345. QPointer<QWidget> programOptions;
  346. QPointer<OBSQTDisplay> program;
  347. OBSWeakSource lastScene;
  348. OBSWeakSource swapScene;
  349. OBSWeakSource programScene;
  350. bool editPropertiesMode = false;
  351. bool sceneDuplicationMode = true;
  352. bool swapScenesMode = true;
  353. volatile bool previewProgramMode = false;
  354. obs_hotkey_id togglePreviewProgramHotkey = 0;
  355. obs_hotkey_id transitionHotkey = 0;
  356. obs_hotkey_id statsHotkey = 0;
  357. obs_hotkey_id screenshotHotkey = 0;
  358. obs_hotkey_id sourceScreenshotHotkey = 0;
  359. int quickTransitionIdCounter = 1;
  360. bool overridingTransition = false;
  361. int programX = 0, programY = 0;
  362. int programCX = 0, programCY = 0;
  363. float programScale = 0.0f;
  364. int disableOutputsRef = 0;
  365. inline void OnActivate();
  366. inline void OnDeactivate();
  367. void AddDropSource(const char *file, DropType image);
  368. void AddDropURL(const char *url, QString &name, obs_data_t *settings,
  369. const obs_video_info &ovi);
  370. void ConfirmDropUrl(const QString &url);
  371. void dragEnterEvent(QDragEnterEvent *event) override;
  372. void dragLeaveEvent(QDragLeaveEvent *event) override;
  373. void dragMoveEvent(QDragMoveEvent *event) override;
  374. void dropEvent(QDropEvent *event) override;
  375. void ReplayBufferClicked();
  376. bool sysTrayMinimizeToTray();
  377. void EnumDialogs();
  378. QList<QDialog *> visDialogs;
  379. QList<QDialog *> modalDialogs;
  380. QList<QMessageBox *> visMsgBoxes;
  381. QList<QPoint> visDlgPositions;
  382. QByteArray startingDockLayout;
  383. obs_data_array_t *SaveProjectors();
  384. void LoadSavedProjectors(obs_data_array_t *savedProjectors);
  385. void ReceivedIntroJson(const QString &text);
  386. void ShowWhatsNew(const QString &url);
  387. #ifdef BROWSER_AVAILABLE
  388. QList<QSharedPointer<QDockWidget>> extraBrowserDocks;
  389. QList<QSharedPointer<QAction>> extraBrowserDockActions;
  390. QStringList extraBrowserDockTargets;
  391. void ClearExtraBrowserDocks();
  392. void LoadExtraBrowserDocks();
  393. void SaveExtraBrowserDocks();
  394. void ManageExtraBrowserDocks();
  395. void AddExtraBrowserDock(const QString &title, const QString &url,
  396. bool firstCreate);
  397. #endif
  398. QIcon imageIcon;
  399. QIcon colorIcon;
  400. QIcon slideshowIcon;
  401. QIcon audioInputIcon;
  402. QIcon audioOutputIcon;
  403. QIcon desktopCapIcon;
  404. QIcon windowCapIcon;
  405. QIcon gameCapIcon;
  406. QIcon cameraIcon;
  407. QIcon textIcon;
  408. QIcon mediaIcon;
  409. QIcon browserIcon;
  410. QIcon groupIcon;
  411. QIcon sceneIcon;
  412. QIcon defaultIcon;
  413. QIcon GetImageIcon() const;
  414. QIcon GetColorIcon() const;
  415. QIcon GetSlideshowIcon() const;
  416. QIcon GetAudioInputIcon() const;
  417. QIcon GetAudioOutputIcon() const;
  418. QIcon GetDesktopCapIcon() const;
  419. QIcon GetWindowCapIcon() const;
  420. QIcon GetGameCapIcon() const;
  421. QIcon GetCameraIcon() const;
  422. QIcon GetTextIcon() const;
  423. QIcon GetMediaIcon() const;
  424. QIcon GetBrowserIcon() const;
  425. QIcon GetDefaultIcon() const;
  426. QSlider *tBar;
  427. bool tBarActive = false;
  428. OBSSource GetOverrideTransition(OBSSource source);
  429. int GetOverrideTransitionDuration(OBSSource source);
  430. void UpdateProjectorHideCursor();
  431. void UpdateProjectorAlwaysOnTop(bool top);
  432. void ResetProjectors();
  433. QPointer<QObject> screenshotData;
  434. public slots:
  435. void DeferSaveBegin();
  436. void DeferSaveEnd();
  437. void StartStreaming();
  438. void StopStreaming();
  439. void ForceStopStreaming();
  440. void StreamDelayStarting(int sec);
  441. void StreamDelayStopping(int sec);
  442. void StreamingStart();
  443. void StreamStopping();
  444. void StreamingStop(int errorcode, QString last_error);
  445. void StartRecording();
  446. void StopRecording();
  447. void RecordingStart();
  448. void RecordStopping();
  449. void RecordingStop(int code, QString last_error);
  450. void ShowReplayBufferPauseWarning();
  451. void StartReplayBuffer();
  452. void StopReplayBuffer();
  453. void ReplayBufferStart();
  454. void ReplayBufferSave();
  455. void ReplayBufferStopping();
  456. void ReplayBufferStop(int code);
  457. void StartVirtualCam();
  458. void StopVirtualCam();
  459. void OnVirtualCamStart();
  460. void OnVirtualCamStop(int code);
  461. void SaveProjectDeferred();
  462. void SaveProject();
  463. void SetTransition(OBSSource transition);
  464. void OverrideTransition(OBSSource transition);
  465. void TransitionToScene(OBSScene scene, bool force = false);
  466. void TransitionToScene(OBSSource scene, bool force = false,
  467. bool quickTransition = false,
  468. int quickDuration = 0, bool black = false,
  469. bool manual = false);
  470. void SetCurrentScene(OBSSource scene, bool force = false);
  471. bool AddSceneCollection(bool create_new,
  472. const QString &name = QString());
  473. void UpdatePatronJson(const QString &text, const QString &error);
  474. void ShowContextBar();
  475. void HideContextBar();
  476. void PauseRecording();
  477. void UnpauseRecording();
  478. private slots:
  479. void AddSceneItem(OBSSceneItem item);
  480. void AddScene(OBSSource source);
  481. void RemoveScene(OBSSource source);
  482. void RenameSources(OBSSource source, QString newName, QString prevName);
  483. void ActivateAudioSource(OBSSource source);
  484. void DeactivateAudioSource(OBSSource source);
  485. void DuplicateSelectedScene();
  486. void RemoveSelectedScene();
  487. void RemoveSelectedSceneItem();
  488. void ToggleAlwaysOnTop();
  489. void ReorderSources(OBSScene scene);
  490. void RefreshSources(OBSScene scene);
  491. void ProcessHotkey(obs_hotkey_id id, bool pressed);
  492. void AddTransition(QString id);
  493. void RenameTransition();
  494. void TransitionClicked();
  495. void TransitionStopped();
  496. void TransitionFullyStopped();
  497. void TriggerQuickTransition(int id);
  498. void SetDeinterlacingMode();
  499. void SetDeinterlacingOrder();
  500. void SetScaleFilter();
  501. void IconActivated(QSystemTrayIcon::ActivationReason reason);
  502. void SetShowing(bool showing);
  503. void ToggleShowHide();
  504. void HideAudioControl();
  505. void UnhideAllAudioControls();
  506. void ToggleHideMixer();
  507. void MixerRenameSource();
  508. void on_vMixerScrollArea_customContextMenuRequested();
  509. void on_hMixerScrollArea_customContextMenuRequested();
  510. void on_actionCopySource_triggered();
  511. void on_actionPasteRef_triggered();
  512. void on_actionPasteDup_triggered();
  513. void on_actionCopyFilters_triggered();
  514. void on_actionPasteFilters_triggered();
  515. void ColorChange();
  516. SourceTreeItem *GetItemWidgetFromSceneItem(obs_sceneitem_t *sceneItem);
  517. void on_actionShowAbout_triggered();
  518. void AudioMixerCopyFilters();
  519. void AudioMixerPasteFilters();
  520. void EnablePreview();
  521. void DisablePreview();
  522. void SceneCopyFilters();
  523. void ScenePasteFilters();
  524. void CheckDiskSpaceRemaining();
  525. void OpenSavedProjector(SavedProjectorInfo *info);
  526. void ScenesReordered();
  527. void ResetStatsHotkey();
  528. void SetImageIcon(const QIcon &icon);
  529. void SetColorIcon(const QIcon &icon);
  530. void SetSlideshowIcon(const QIcon &icon);
  531. void SetAudioInputIcon(const QIcon &icon);
  532. void SetAudioOutputIcon(const QIcon &icon);
  533. void SetDesktopCapIcon(const QIcon &icon);
  534. void SetWindowCapIcon(const QIcon &icon);
  535. void SetGameCapIcon(const QIcon &icon);
  536. void SetCameraIcon(const QIcon &icon);
  537. void SetTextIcon(const QIcon &icon);
  538. void SetMediaIcon(const QIcon &icon);
  539. void SetBrowserIcon(const QIcon &icon);
  540. void SetGroupIcon(const QIcon &icon);
  541. void SetSceneIcon(const QIcon &icon);
  542. void SetDefaultIcon(const QIcon &icon);
  543. void TBarChanged(int value);
  544. void TBarReleased();
  545. void LockVolumeControl(bool lock);
  546. private:
  547. /* OBS Callbacks */
  548. static void SceneReordered(void *data, calldata_t *params);
  549. static void SceneRefreshed(void *data, calldata_t *params);
  550. static void SceneItemAdded(void *data, calldata_t *params);
  551. static void SourceCreated(void *data, calldata_t *params);
  552. static void SourceRemoved(void *data, calldata_t *params);
  553. static void SourceActivated(void *data, calldata_t *params);
  554. static void SourceDeactivated(void *data, calldata_t *params);
  555. static void SourceAudioActivated(void *data, calldata_t *params);
  556. static void SourceAudioDeactivated(void *data, calldata_t *params);
  557. static void SourceRenamed(void *data, calldata_t *params);
  558. static void RenderMain(void *data, uint32_t cx, uint32_t cy);
  559. void ResizePreview(uint32_t cx, uint32_t cy);
  560. void AddSource(const char *id);
  561. QMenu *CreateAddSourcePopupMenu();
  562. void AddSourcePopupMenu(const QPoint &pos);
  563. void copyActionsDynamicProperties();
  564. static void HotkeyTriggered(void *data, obs_hotkey_id id, bool pressed);
  565. void AutoRemux();
  566. void UpdatePause(bool activate = true);
  567. void UpdateReplayBuffer(bool activate = true);
  568. bool OutputPathValid();
  569. void OutputPathInvalidMessage();
  570. bool LowDiskSpace();
  571. void DiskSpaceMessage();
  572. OBSSource prevFTBSource = nullptr;
  573. public:
  574. OBSSource GetProgramSource();
  575. OBSScene GetCurrentScene();
  576. void SysTrayNotify(const QString &text, QSystemTrayIcon::MessageIcon n);
  577. inline OBSSource GetCurrentSceneSource()
  578. {
  579. OBSScene curScene = GetCurrentScene();
  580. return OBSSource(obs_scene_get_source(curScene));
  581. }
  582. obs_service_t *GetService();
  583. void SetService(obs_service_t *service);
  584. int GetTransitionDuration();
  585. inline bool IsPreviewProgramMode() const
  586. {
  587. return os_atomic_load_bool(&previewProgramMode);
  588. }
  589. inline bool VCamEnabled() const { return vcamEnabled; }
  590. bool StreamingActive() const;
  591. bool Active() const;
  592. void ResetUI();
  593. int ResetVideo();
  594. bool ResetAudio();
  595. void AddVCamButton();
  596. void ResetOutputs();
  597. void ResetAudioDevice(const char *sourceId, const char *deviceId,
  598. const char *deviceDesc, int channel);
  599. void NewProject();
  600. void LoadProject();
  601. inline void GetDisplayRect(int &x, int &y, int &cx, int &cy)
  602. {
  603. x = previewX;
  604. y = previewY;
  605. cx = previewCX;
  606. cy = previewCY;
  607. }
  608. inline bool SavingDisabled() const { return disableSaving; }
  609. inline double GetCPUUsage() const
  610. {
  611. return os_cpu_usage_info_query(cpuUsageInfo);
  612. }
  613. void SaveService();
  614. bool LoadService();
  615. inline Auth *GetAuth() { return auth.get(); }
  616. inline void EnableOutputs(bool enable)
  617. {
  618. if (enable) {
  619. if (--disableOutputsRef < 0)
  620. disableOutputsRef = 0;
  621. } else {
  622. disableOutputsRef++;
  623. }
  624. }
  625. QMenu *AddDeinterlacingMenu(QMenu *menu, obs_source_t *source);
  626. QMenu *AddScaleFilteringMenu(QMenu *menu, obs_sceneitem_t *item);
  627. QMenu *AddBackgroundColorMenu(QMenu *menu, QWidgetAction *widgetAction,
  628. ColorSelect *select,
  629. obs_sceneitem_t *item);
  630. void CreateSourcePopupMenu(int idx, bool preview);
  631. void UpdateTitleBar();
  632. void UpdateSceneSelection(OBSSource source);
  633. void SystemTrayInit();
  634. void SystemTray(bool firstStarted);
  635. void OpenSavedProjectors();
  636. void CreateInteractionWindow(obs_source_t *source);
  637. void CreatePropertiesWindow(obs_source_t *source);
  638. void CreateFiltersWindow(obs_source_t *source);
  639. QAction *AddDockWidget(QDockWidget *dock);
  640. static OBSBasic *Get();
  641. const char *GetCurrentOutputPath();
  642. void DeleteProjector(OBSProjector *projector);
  643. void AddProjectorMenuMonitors(QMenu *parent, QObject *target,
  644. const char *slot);
  645. QIcon GetSourceIcon(const char *id) const;
  646. QIcon GetGroupIcon() const;
  647. QIcon GetSceneIcon() const;
  648. protected:
  649. virtual void closeEvent(QCloseEvent *event) override;
  650. virtual void changeEvent(QEvent *event) override;
  651. private slots:
  652. void on_actionFullscreenInterface_triggered();
  653. void on_actionShow_Recordings_triggered();
  654. void on_actionRemux_triggered();
  655. void on_action_Settings_triggered();
  656. void on_actionAdvAudioProperties_triggered();
  657. void on_advAudioProps_clicked();
  658. void on_advAudioProps_destroyed();
  659. void on_actionShowLogs_triggered();
  660. void on_actionUploadCurrentLog_triggered();
  661. void on_actionUploadLastLog_triggered();
  662. void on_actionViewCurrentLog_triggered();
  663. void on_actionCheckForUpdates_triggered();
  664. void on_actionShowCrashLogs_triggered();
  665. void on_actionUploadLastCrashLog_triggered();
  666. void on_actionEditTransform_triggered();
  667. void on_actionCopyTransform_triggered();
  668. void on_actionPasteTransform_triggered();
  669. void on_actionRotate90CW_triggered();
  670. void on_actionRotate90CCW_triggered();
  671. void on_actionRotate180_triggered();
  672. void on_actionFlipHorizontal_triggered();
  673. void on_actionFlipVertical_triggered();
  674. void on_actionFitToScreen_triggered();
  675. void on_actionStretchToScreen_triggered();
  676. void on_actionCenterToScreen_triggered();
  677. void on_actionVerticalCenter_triggered();
  678. void on_actionHorizontalCenter_triggered();
  679. void on_customContextMenuRequested(const QPoint &pos);
  680. void on_scenes_currentItemChanged(QListWidgetItem *current,
  681. QListWidgetItem *prev);
  682. void on_scenes_customContextMenuRequested(const QPoint &pos);
  683. void on_actionGridMode_triggered();
  684. void on_actionAddScene_triggered();
  685. void on_actionRemoveScene_triggered();
  686. void on_actionSceneUp_triggered();
  687. void on_actionSceneDown_triggered();
  688. void on_sources_customContextMenuRequested(const QPoint &pos);
  689. void on_scenes_itemDoubleClicked(QListWidgetItem *item);
  690. void on_actionAddSource_triggered();
  691. void on_actionRemoveSource_triggered();
  692. void on_actionInteract_triggered();
  693. void on_actionSourceProperties_triggered();
  694. void on_actionSourceUp_triggered();
  695. void on_actionSourceDown_triggered();
  696. void on_actionMoveUp_triggered();
  697. void on_actionMoveDown_triggered();
  698. void on_actionMoveToTop_triggered();
  699. void on_actionMoveToBottom_triggered();
  700. void on_actionLockPreview_triggered();
  701. void on_scalingMenu_aboutToShow();
  702. void on_actionScaleWindow_triggered();
  703. void on_actionScaleCanvas_triggered();
  704. void on_actionScaleOutput_triggered();
  705. void on_streamButton_clicked();
  706. void on_recordButton_clicked();
  707. void VCamButtonClicked();
  708. void on_settingsButton_clicked();
  709. void Screenshot(OBSSource source_ = nullptr);
  710. void ScreenshotSelectedSource();
  711. void ScreenshotProgram();
  712. void ScreenshotScene();
  713. void on_actionHelpPortal_triggered();
  714. void on_actionWebsite_triggered();
  715. void on_actionDiscord_triggered();
  716. void on_preview_customContextMenuRequested(const QPoint &pos);
  717. void on_program_customContextMenuRequested(const QPoint &pos);
  718. void PreviewDisabledMenu(const QPoint &pos);
  719. void on_actionNewSceneCollection_triggered();
  720. void on_actionDupSceneCollection_triggered();
  721. void on_actionRenameSceneCollection_triggered();
  722. void on_actionRemoveSceneCollection_triggered();
  723. void on_actionImportSceneCollection_triggered();
  724. void on_actionExportSceneCollection_triggered();
  725. void on_actionNewProfile_triggered();
  726. void on_actionDupProfile_triggered();
  727. void on_actionRenameProfile_triggered();
  728. void on_actionRemoveProfile_triggered();
  729. void on_actionImportProfile_triggered();
  730. void on_actionExportProfile_triggered();
  731. void on_actionShowSettingsFolder_triggered();
  732. void on_actionShowProfileFolder_triggered();
  733. void on_actionAlwaysOnTop_triggered();
  734. void on_toggleListboxToolbars_toggled(bool visible);
  735. void on_toggleContextBar_toggled(bool visible);
  736. void on_toggleStatusBar_toggled(bool visible);
  737. void on_toggleSourceIcons_toggled(bool visible);
  738. void on_transitions_currentIndexChanged(int index);
  739. void on_transitionRemove_clicked();
  740. void on_transitionProps_clicked();
  741. void on_transitionDuration_valueChanged(int value);
  742. void on_modeSwitch_clicked();
  743. // Source Context Buttons
  744. void on_sourcePropertiesButton_clicked();
  745. void on_sourceFiltersButton_clicked();
  746. void on_autoConfigure_triggered();
  747. void on_stats_triggered();
  748. void on_resetUI_triggered();
  749. void on_lockUI_toggled(bool lock);
  750. void PauseToggled();
  751. void logUploadFinished(const QString &text, const QString &error);
  752. void crashUploadFinished(const QString &text, const QString &error);
  753. void openLogDialog(const QString &text, const bool crash);
  754. void updateCheckFinished();
  755. void AddSourceFromAction();
  756. void MoveSceneToTop();
  757. void MoveSceneToBottom();
  758. void EditSceneName();
  759. void EditSceneItemName();
  760. void SceneNameEdited(QWidget *editor,
  761. QAbstractItemDelegate::EndEditHint endHint);
  762. void OpenSceneFilters();
  763. void OpenFilters();
  764. void EnablePreviewDisplay(bool enable);
  765. void TogglePreview();
  766. void NudgeUp();
  767. void NudgeDown();
  768. void NudgeLeft();
  769. void NudgeRight();
  770. void OpenStudioProgramProjector();
  771. void OpenPreviewProjector();
  772. void OpenSourceProjector();
  773. void OpenMultiviewProjector();
  774. void OpenSceneProjector();
  775. void OpenStudioProgramWindow();
  776. void OpenPreviewWindow();
  777. void OpenSourceWindow();
  778. void OpenMultiviewWindow();
  779. void OpenSceneWindow();
  780. void DeferredSysTrayLoad(int requeueCount);
  781. void StackedMixerAreaContextMenuRequested();
  782. void ResizeOutputSizeOfSource();
  783. public slots:
  784. void on_actionResetTransform_triggered();
  785. bool StreamingActive();
  786. bool RecordingActive();
  787. bool ReplayBufferActive();
  788. void ClearContextBar();
  789. void UpdateContextBar();
  790. public:
  791. explicit OBSBasic(QWidget *parent = 0);
  792. virtual ~OBSBasic();
  793. virtual void OBSInit() override;
  794. virtual config_t *Config() const override;
  795. virtual int GetProfilePath(char *path, size_t size,
  796. const char *file) const override;
  797. static void InitBrowserPanelSafeBlock();
  798. private:
  799. std::unique_ptr<Ui::OBSBasic> ui;
  800. };
  801. class SceneRenameDelegate : public QStyledItemDelegate {
  802. Q_OBJECT
  803. public:
  804. SceneRenameDelegate(QObject *parent);
  805. virtual void setEditorData(QWidget *editor,
  806. const QModelIndex &index) const override;
  807. protected:
  808. virtual bool eventFilter(QObject *editor, QEvent *event) override;
  809. };