window-basic-main.hpp 29 KB

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