window-basic-main.hpp 33 KB

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