1
0

window-basic-main.hpp 33 KB

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