window-basic-main.hpp 32 KB

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