window-basic-main.hpp 32 KB

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