window-basic-main.hpp 29 KB

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