window-basic-main.hpp 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143
  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 StreamingActive() const;
  646. bool Active() const;
  647. void ResetUI();
  648. int ResetVideo();
  649. bool ResetAudio();
  650. void AddVCamButton();
  651. void ResetOutputs();
  652. void ResetAudioDevice(const char *sourceId, const char *deviceId,
  653. const char *deviceDesc, int channel);
  654. void NewProject();
  655. void LoadProject();
  656. inline void GetDisplayRect(int &x, int &y, int &cx, int &cy)
  657. {
  658. x = previewX;
  659. y = previewY;
  660. cx = previewCX;
  661. cy = previewCY;
  662. }
  663. inline bool SavingDisabled() const { return disableSaving; }
  664. inline double GetCPUUsage() const
  665. {
  666. return os_cpu_usage_info_query(cpuUsageInfo);
  667. }
  668. void SaveService();
  669. bool LoadService();
  670. inline Auth *GetAuth() { return auth.get(); }
  671. inline void EnableOutputs(bool enable)
  672. {
  673. if (enable) {
  674. if (--disableOutputsRef < 0)
  675. disableOutputsRef = 0;
  676. } else {
  677. disableOutputsRef++;
  678. }
  679. }
  680. QMenu *AddDeinterlacingMenu(QMenu *menu, obs_source_t *source);
  681. QMenu *AddScaleFilteringMenu(QMenu *menu, obs_sceneitem_t *item);
  682. QMenu *AddBackgroundColorMenu(QMenu *menu, QWidgetAction *widgetAction,
  683. ColorSelect *select,
  684. obs_sceneitem_t *item);
  685. void CreateSourcePopupMenu(int idx, bool preview);
  686. void UpdateTitleBar();
  687. void SystemTrayInit();
  688. void SystemTray(bool firstStarted);
  689. void OpenSavedProjectors();
  690. void CreateInteractionWindow(obs_source_t *source);
  691. void CreatePropertiesWindow(obs_source_t *source);
  692. void CreateFiltersWindow(obs_source_t *source);
  693. QAction *AddDockWidget(QDockWidget *dock);
  694. static OBSBasic *Get();
  695. const char *GetCurrentOutputPath();
  696. void DeleteProjector(OBSProjector *projector);
  697. void AddProjectorMenuMonitors(QMenu *parent, QObject *target,
  698. const char *slot);
  699. QIcon GetSourceIcon(const char *id) const;
  700. QIcon GetGroupIcon() const;
  701. QIcon GetSceneIcon() const;
  702. OBSWeakSource copyFilter;
  703. void ShowStatusBarMessage(const QString &message);
  704. static OBSData
  705. BackupScene(obs_scene_t *scene,
  706. std::vector<obs_source_t *> *sources = nullptr);
  707. void CreateSceneUndoRedoAction(const QString &action_name,
  708. OBSData undo_data, OBSData redo_data);
  709. static inline OBSData
  710. BackupScene(obs_source_t *scene_source,
  711. std::vector<obs_source_t *> *sources = nullptr)
  712. {
  713. obs_scene_t *scene = obs_scene_from_source(scene_source);
  714. return BackupScene(scene, sources);
  715. }
  716. void CreateFilterPasteUndoRedoAction(const QString &text,
  717. obs_source_t *source,
  718. obs_data_array_t *undo_array,
  719. obs_data_array_t *redo_array);
  720. void UpdateEditMenu();
  721. protected:
  722. virtual void closeEvent(QCloseEvent *event) override;
  723. virtual void changeEvent(QEvent *event) override;
  724. private slots:
  725. void on_actionFullscreenInterface_triggered();
  726. void on_actionShow_Recordings_triggered();
  727. void on_actionRemux_triggered();
  728. void on_action_Settings_triggered();
  729. void on_actionShowMissingFiles_triggered();
  730. void on_actionAdvAudioProperties_triggered();
  731. void on_actionShowLogs_triggered();
  732. void on_actionUploadCurrentLog_triggered();
  733. void on_actionUploadLastLog_triggered();
  734. void on_actionViewCurrentLog_triggered();
  735. void on_actionCheckForUpdates_triggered();
  736. void on_actionShowCrashLogs_triggered();
  737. void on_actionUploadLastCrashLog_triggered();
  738. void on_menuBasic_MainMenu_Edit_aboutToShow();
  739. void on_actionEditTransform_triggered();
  740. void on_actionCopyTransform_triggered();
  741. void on_actionPasteTransform_triggered();
  742. void on_actionRotate90CW_triggered();
  743. void on_actionRotate90CCW_triggered();
  744. void on_actionRotate180_triggered();
  745. void on_actionFlipHorizontal_triggered();
  746. void on_actionFlipVertical_triggered();
  747. void on_actionFitToScreen_triggered();
  748. void on_actionStretchToScreen_triggered();
  749. void on_actionCenterToScreen_triggered();
  750. void on_actionVerticalCenter_triggered();
  751. void on_actionHorizontalCenter_triggered();
  752. void on_customContextMenuRequested(const QPoint &pos);
  753. void on_scenes_currentItemChanged(QListWidgetItem *current,
  754. QListWidgetItem *prev);
  755. void on_scenes_customContextMenuRequested(const QPoint &pos);
  756. void GridActionClicked();
  757. void on_actionAddScene_triggered();
  758. void on_actionRemoveScene_triggered();
  759. void on_actionSceneUp_triggered();
  760. void on_actionSceneDown_triggered();
  761. void on_sources_customContextMenuRequested(const QPoint &pos);
  762. void on_scenes_itemDoubleClicked(QListWidgetItem *item);
  763. void on_actionAddSource_triggered();
  764. void on_actionRemoveSource_triggered();
  765. void on_actionInteract_triggered();
  766. void on_actionSourceProperties_triggered();
  767. void on_actionSourceUp_triggered();
  768. void on_actionSourceDown_triggered();
  769. void on_actionMoveUp_triggered();
  770. void on_actionMoveDown_triggered();
  771. void on_actionMoveToTop_triggered();
  772. void on_actionMoveToBottom_triggered();
  773. void on_actionLockPreview_triggered();
  774. void on_scalingMenu_aboutToShow();
  775. void on_actionScaleWindow_triggered();
  776. void on_actionScaleCanvas_triggered();
  777. void on_actionScaleOutput_triggered();
  778. void on_streamButton_clicked();
  779. void on_recordButton_clicked();
  780. void VCamButtonClicked();
  781. void on_settingsButton_clicked();
  782. void Screenshot(OBSSource source_ = nullptr);
  783. void ScreenshotSelectedSource();
  784. void ScreenshotProgram();
  785. void ScreenshotScene();
  786. void on_actionHelpPortal_triggered();
  787. void on_actionWebsite_triggered();
  788. void on_actionDiscord_triggered();
  789. void on_preview_customContextMenuRequested(const QPoint &pos);
  790. void ProgramViewContextMenuRequested(const QPoint &pos);
  791. void PreviewDisabledMenu(const QPoint &pos);
  792. void on_actionNewSceneCollection_triggered();
  793. void on_actionDupSceneCollection_triggered();
  794. void on_actionRenameSceneCollection_triggered();
  795. void on_actionRemoveSceneCollection_triggered();
  796. void on_actionImportSceneCollection_triggered();
  797. void on_actionExportSceneCollection_triggered();
  798. void on_actionNewProfile_triggered();
  799. void on_actionDupProfile_triggered();
  800. void on_actionRenameProfile_triggered();
  801. void on_actionRemoveProfile_triggered(bool skipConfirmation = false);
  802. void on_actionImportProfile_triggered();
  803. void on_actionExportProfile_triggered();
  804. void on_actionShowSettingsFolder_triggered();
  805. void on_actionShowProfileFolder_triggered();
  806. void on_actionAlwaysOnTop_triggered();
  807. void on_toggleListboxToolbars_toggled(bool visible);
  808. void on_toggleContextBar_toggled(bool visible);
  809. void on_toggleStatusBar_toggled(bool visible);
  810. void on_toggleSourceIcons_toggled(bool visible);
  811. void on_transitions_currentIndexChanged(int index);
  812. void RemoveTransitionClicked();
  813. void on_transitionProps_clicked();
  814. void on_transitionDuration_valueChanged(int value);
  815. void on_tbar_position_valueChanged(int value);
  816. void on_actionShowTransitionProperties_triggered();
  817. void on_actionHideTransitionProperties_triggered();
  818. void on_modeSwitch_clicked();
  819. // Source Context Buttons
  820. void on_sourcePropertiesButton_clicked();
  821. void on_sourceFiltersButton_clicked();
  822. void on_sourceInteractButton_clicked();
  823. void on_autoConfigure_triggered();
  824. void on_stats_triggered();
  825. void on_resetUI_triggered();
  826. void on_lockUI_toggled(bool lock);
  827. void PauseToggled();
  828. void logUploadFinished(const QString &text, const QString &error);
  829. void crashUploadFinished(const QString &text, const QString &error);
  830. void openLogDialog(const QString &text, const bool crash);
  831. void updateCheckFinished();
  832. void AddSourceFromAction();
  833. void MoveSceneToTop();
  834. void MoveSceneToBottom();
  835. void EditSceneName();
  836. void EditSceneItemName();
  837. void SceneNameEdited(QWidget *editor,
  838. QAbstractItemDelegate::EndEditHint endHint);
  839. void OpenSceneFilters();
  840. void OpenFilters(OBSSource source = nullptr);
  841. void OpenProperties(OBSSource source = nullptr);
  842. void EnablePreviewDisplay(bool enable);
  843. void TogglePreview();
  844. void NudgeUp();
  845. void NudgeDown();
  846. void NudgeLeft();
  847. void NudgeRight();
  848. void OpenStudioProgramProjector();
  849. void OpenPreviewProjector();
  850. void OpenSourceProjector();
  851. void OpenMultiviewProjector();
  852. void OpenSceneProjector();
  853. void OpenStudioProgramWindow();
  854. void OpenPreviewWindow();
  855. void OpenSourceWindow();
  856. void OpenMultiviewWindow();
  857. void OpenSceneWindow();
  858. void DeferredSysTrayLoad(int requeueCount);
  859. void StackedMixerAreaContextMenuRequested();
  860. void ResizeOutputSizeOfSource();
  861. public slots:
  862. void on_actionResetTransform_triggered();
  863. bool StreamingActive();
  864. bool RecordingActive();
  865. bool ReplayBufferActive();
  866. void ClearContextBar();
  867. void UpdateContextBar(bool force = false);
  868. void UpdateContextBarDeferred(bool force = false);
  869. public:
  870. explicit OBSBasic(QWidget *parent = 0);
  871. virtual ~OBSBasic();
  872. virtual void OBSInit() override;
  873. virtual config_t *Config() const override;
  874. virtual int GetProfilePath(char *path, size_t size,
  875. const char *file) const override;
  876. static void InitBrowserPanelSafeBlock();
  877. private:
  878. std::unique_ptr<Ui::OBSBasic> ui;
  879. };
  880. class SceneRenameDelegate : public QStyledItemDelegate {
  881. Q_OBJECT
  882. public:
  883. SceneRenameDelegate(QObject *parent);
  884. virtual void setEditorData(QWidget *editor,
  885. const QModelIndex &index) const override;
  886. protected:
  887. virtual bool eventFilter(QObject *editor, QEvent *event) override;
  888. };