window-basic-main.hpp 33 KB

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