window-basic-main.hpp 29 KB

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