window-basic-main.hpp 29 KB

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