window-basic-main.hpp 32 KB

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