window-basic-main.hpp 29 KB

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