window-basic-main.hpp 32 KB

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