OBSBasic.cpp 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006
  1. /******************************************************************************
  2. Copyright (C) 2023 by Lain Bailey <[email protected]>
  3. Zachary Lund <[email protected]>
  4. Philippe Groarke <[email protected]>
  5. This program is free software: you can redistribute it and/or modify
  6. it under the terms of the GNU General Public License as published by
  7. the Free Software Foundation, either version 2 of the License, or
  8. (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. ******************************************************************************/
  16. #include "OBSBasic.hpp"
  17. #include "ui-config.h"
  18. #include "ColorSelect.hpp"
  19. #include "OBSBasicControls.hpp"
  20. #include "OBSBasicStats.hpp"
  21. #include "VolControl.hpp"
  22. #ifdef YOUTUBE_ENABLED
  23. #include <docks/YouTubeAppDock.hpp>
  24. #endif
  25. #include <dialogs/NameDialog.hpp>
  26. #include <dialogs/OBSAbout.hpp>
  27. #include <dialogs/OBSBasicAdvAudio.hpp>
  28. #include <dialogs/OBSBasicFilters.hpp>
  29. #include <dialogs/OBSBasicInteraction.hpp>
  30. #include <dialogs/OBSBasicProperties.hpp>
  31. #include <dialogs/OBSBasicTransform.hpp>
  32. #include <settings/OBSBasicSettings.hpp>
  33. #include <utility/QuickTransition.hpp>
  34. #include <utility/SceneRenameDelegate.hpp>
  35. #if defined(_WIN32) || defined(WHATSNEW_ENABLED)
  36. #include <utility/WhatsNewInfoThread.hpp>
  37. #endif
  38. #include <widgets/OBSProjector.hpp>
  39. #include <OBSStudioAPI.hpp>
  40. #ifdef BROWSER_AVAILABLE
  41. #include <browser-panel.hpp>
  42. #endif
  43. #ifdef ENABLE_WAYLAND
  44. #include <obs-nix-platform.h>
  45. #endif
  46. #include <qt-wrappers.hpp>
  47. #include <QActionGroup>
  48. #include <QThread>
  49. #include <QWidgetAction>
  50. #ifdef _WIN32
  51. #include <sstream>
  52. #endif
  53. #include <string>
  54. #include <unordered_set>
  55. #ifdef _WIN32
  56. #define WIN32_LEAN_AND_MEAN
  57. #include "Windows.h"
  58. #endif
  59. #include "moc_OBSBasic.cpp"
  60. using namespace std;
  61. extern bool portable_mode;
  62. extern bool disable_3p_plugins;
  63. extern bool opt_studio_mode;
  64. extern bool opt_always_on_top;
  65. extern bool opt_minimize_tray;
  66. extern std::string opt_starting_profile;
  67. extern std::string opt_starting_collection;
  68. extern bool safe_mode;
  69. extern bool opt_start_recording;
  70. extern bool opt_start_replaybuffer;
  71. extern bool opt_start_virtualcam;
  72. extern volatile long insideEventLoop;
  73. extern bool restart;
  74. extern bool EncoderAvailable(const char *encoder);
  75. extern void RegisterTwitchAuth();
  76. extern void RegisterRestreamAuth();
  77. #ifdef YOUTUBE_ENABLED
  78. extern void RegisterYoutubeAuth();
  79. #endif
  80. struct QCef;
  81. extern QCef *cef;
  82. extern bool cef_js_avail;
  83. extern void DestroyPanelCookieManager();
  84. extern void CheckExistingCookieId();
  85. static void AddExtraModulePaths()
  86. {
  87. string plugins_path, plugins_data_path;
  88. char *s;
  89. s = getenv("OBS_PLUGINS_PATH");
  90. if (s)
  91. plugins_path = s;
  92. s = getenv("OBS_PLUGINS_DATA_PATH");
  93. if (s)
  94. plugins_data_path = s;
  95. if (!plugins_path.empty() && !plugins_data_path.empty()) {
  96. #if defined(__APPLE__)
  97. plugins_path += "/%module%.plugin/Contents/MacOS";
  98. plugins_data_path += "/%module%.plugin/Contents/Resources";
  99. obs_add_module_path(plugins_path.c_str(), plugins_data_path.c_str());
  100. #else
  101. string data_path_with_module_suffix;
  102. data_path_with_module_suffix += plugins_data_path;
  103. data_path_with_module_suffix += "/%module%";
  104. obs_add_module_path(plugins_path.c_str(), data_path_with_module_suffix.c_str());
  105. #endif
  106. }
  107. if (portable_mode)
  108. return;
  109. char base_module_dir[512];
  110. #if defined(_WIN32)
  111. int ret = GetProgramDataPath(base_module_dir, sizeof(base_module_dir), "obs-studio/plugins/%module%");
  112. #elif defined(__APPLE__)
  113. int ret = GetAppConfigPath(base_module_dir, sizeof(base_module_dir), "obs-studio/plugins/%module%.plugin");
  114. #else
  115. int ret = GetAppConfigPath(base_module_dir, sizeof(base_module_dir), "obs-studio/plugins/%module%");
  116. #endif
  117. if (ret <= 0)
  118. return;
  119. string path = base_module_dir;
  120. #if defined(__APPLE__)
  121. /* User Application Support Search Path */
  122. obs_add_module_path((path + "/Contents/MacOS").c_str(), (path + "/Contents/Resources").c_str());
  123. #ifndef __aarch64__
  124. /* Legacy System Library Search Path */
  125. char system_legacy_module_dir[PATH_MAX];
  126. GetProgramDataPath(system_legacy_module_dir, sizeof(system_legacy_module_dir), "obs-studio/plugins/%module%");
  127. std::string path_system_legacy = system_legacy_module_dir;
  128. obs_add_module_path((path_system_legacy + "/bin").c_str(), (path_system_legacy + "/data").c_str());
  129. /* Legacy User Application Support Search Path */
  130. char user_legacy_module_dir[PATH_MAX];
  131. GetAppConfigPath(user_legacy_module_dir, sizeof(user_legacy_module_dir), "obs-studio/plugins/%module%");
  132. std::string path_user_legacy = user_legacy_module_dir;
  133. obs_add_module_path((path_user_legacy + "/bin").c_str(), (path_user_legacy + "/data").c_str());
  134. #endif
  135. #else
  136. #if ARCH_BITS == 64
  137. obs_add_module_path((path + "/bin/64bit").c_str(), (path + "/data").c_str());
  138. #else
  139. obs_add_module_path((path + "/bin/32bit").c_str(), (path + "/data").c_str());
  140. #endif
  141. #endif
  142. }
  143. /* First-party modules considered to be potentially unsafe to load in Safe Mode
  144. * due to them allowing external code (e.g. scripts) to modify OBS's state. */
  145. static const unordered_set<string> unsafe_modules = {
  146. "frontend-tools", // Scripting
  147. "obs-websocket", // Allows outside modifications
  148. };
  149. static void SetSafeModuleNames()
  150. {
  151. #ifndef SAFE_MODULES
  152. return;
  153. #else
  154. string module;
  155. stringstream modules(SAFE_MODULES);
  156. while (getline(modules, module, '|')) {
  157. /* When only disallowing third-party plugins, still add
  158. * "unsafe" bundled modules to the safe list. */
  159. if (disable_3p_plugins || !unsafe_modules.count(module))
  160. obs_add_safe_module(module.c_str());
  161. }
  162. #endif
  163. }
  164. extern void setupDockAction(QDockWidget *dock);
  165. OBSBasic::OBSBasic(QWidget *parent) : OBSMainWindow(parent), undo_s(ui), ui(new Ui::OBSBasic)
  166. {
  167. setAttribute(Qt::WA_NativeWindow);
  168. #ifdef TWITCH_ENABLED
  169. RegisterTwitchAuth();
  170. #endif
  171. #ifdef RESTREAM_ENABLED
  172. RegisterRestreamAuth();
  173. #endif
  174. #ifdef YOUTUBE_ENABLED
  175. RegisterYoutubeAuth();
  176. #endif
  177. setAcceptDrops(true);
  178. setContextMenuPolicy(Qt::CustomContextMenu);
  179. QEvent::registerEventType(QEvent::User + QEvent::Close);
  180. api = InitializeAPIInterface(this);
  181. ui->setupUi(this);
  182. ui->previewDisabledWidget->setVisible(false);
  183. /* Set up streaming connections */
  184. connect(
  185. this, &OBSBasic::StreamingStarting, this, [this] { this->streamingStarting = true; },
  186. Qt::DirectConnection);
  187. connect(
  188. this, &OBSBasic::StreamingStarted, this, [this] { this->streamingStarting = false; },
  189. Qt::DirectConnection);
  190. connect(
  191. this, &OBSBasic::StreamingStopped, this, [this] { this->streamingStarting = false; },
  192. Qt::DirectConnection);
  193. /* Set up recording connections */
  194. connect(
  195. this, &OBSBasic::RecordingStarted, this,
  196. [this]() {
  197. this->recordingStarted = true;
  198. this->recordingPaused = false;
  199. },
  200. Qt::DirectConnection);
  201. connect(
  202. this, &OBSBasic::RecordingPaused, this, [this]() { this->recordingPaused = true; },
  203. Qt::DirectConnection);
  204. connect(
  205. this, &OBSBasic::RecordingUnpaused, this, [this]() { this->recordingPaused = false; },
  206. Qt::DirectConnection);
  207. connect(
  208. this, &OBSBasic::RecordingStopped, this,
  209. [this]() {
  210. this->recordingStarted = false;
  211. this->recordingPaused = false;
  212. },
  213. Qt::DirectConnection);
  214. /* Add controls dock */
  215. OBSBasicControls *controls = new OBSBasicControls(this);
  216. controlsDock = new OBSDock(this);
  217. controlsDock->setObjectName(QString::fromUtf8("controlsDock"));
  218. controlsDock->setWindowTitle(QTStr("Basic.Main.Controls"));
  219. /* Parenting is done there so controls will be deleted alongside controlsDock */
  220. controlsDock->setWidget(controls);
  221. addDockWidget(Qt::BottomDockWidgetArea, controlsDock);
  222. connect(controls, &OBSBasicControls::StreamButtonClicked, this, &OBSBasic::StreamActionTriggered);
  223. connect(controls, &OBSBasicControls::StartStreamMenuActionClicked, this, &OBSBasic::StartStreaming);
  224. connect(controls, &OBSBasicControls::StopStreamMenuActionClicked, this, &OBSBasic::StopStreaming);
  225. connect(controls, &OBSBasicControls::ForceStopStreamMenuActionClicked, this, &OBSBasic::ForceStopStreaming);
  226. connect(controls, &OBSBasicControls::BroadcastButtonClicked, this, &OBSBasic::BroadcastButtonClicked);
  227. connect(controls, &OBSBasicControls::RecordButtonClicked, this, &OBSBasic::RecordActionTriggered);
  228. connect(controls, &OBSBasicControls::PauseRecordButtonClicked, this, &OBSBasic::RecordPauseToggled);
  229. connect(controls, &OBSBasicControls::ReplayBufferButtonClicked, this, &OBSBasic::ReplayBufferActionTriggered);
  230. connect(controls, &OBSBasicControls::SaveReplayBufferButtonClicked, this, &OBSBasic::ReplayBufferSave);
  231. connect(controls, &OBSBasicControls::VirtualCamButtonClicked, this, &OBSBasic::VirtualCamActionTriggered);
  232. connect(controls, &OBSBasicControls::VirtualCamConfigButtonClicked, this, &OBSBasic::OpenVirtualCamConfig);
  233. connect(controls, &OBSBasicControls::StudioModeButtonClicked, this, &OBSBasic::TogglePreviewProgramMode);
  234. connect(controls, &OBSBasicControls::SettingsButtonClicked, this, &OBSBasic::on_action_Settings_triggered);
  235. startingDockLayout = saveState();
  236. statsDock = new OBSDock();
  237. statsDock->setObjectName(QStringLiteral("statsDock"));
  238. statsDock->setFeatures(QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetMovable |
  239. QDockWidget::DockWidgetFloatable);
  240. statsDock->setWindowTitle(QTStr("Basic.Stats"));
  241. addDockWidget(Qt::BottomDockWidgetArea, statsDock);
  242. statsDock->setVisible(false);
  243. statsDock->setFloating(true);
  244. statsDock->resize(700, 200);
  245. copyActionsDynamicProperties();
  246. qRegisterMetaType<int64_t>("int64_t");
  247. qRegisterMetaType<uint32_t>("uint32_t");
  248. qRegisterMetaType<OBSScene>("OBSScene");
  249. qRegisterMetaType<OBSSceneItem>("OBSSceneItem");
  250. qRegisterMetaType<OBSSource>("OBSSource");
  251. qRegisterMetaType<obs_hotkey_id>("obs_hotkey_id");
  252. qRegisterMetaType<SavedProjectorInfo *>("SavedProjectorInfo *");
  253. ui->scenes->setAttribute(Qt::WA_MacShowFocusRect, false);
  254. ui->sources->setAttribute(Qt::WA_MacShowFocusRect, false);
  255. bool sceneGrid = config_get_bool(App()->GetUserConfig(), "BasicWindow", "gridMode");
  256. ui->scenes->SetGridMode(sceneGrid);
  257. if (sceneGrid)
  258. ui->actionSceneGridMode->setChecked(true);
  259. else
  260. ui->actionSceneListMode->setChecked(true);
  261. ui->scenes->setItemDelegate(new SceneRenameDelegate(ui->scenes));
  262. auto displayResize = [this]() {
  263. struct obs_video_info ovi;
  264. if (obs_get_video_info(&ovi))
  265. ResizePreview(ovi.base_width, ovi.base_height);
  266. UpdateContextBarVisibility();
  267. UpdatePreviewControls();
  268. dpi = devicePixelRatioF();
  269. };
  270. dpi = devicePixelRatioF();
  271. connect(windowHandle(), &QWindow::screenChanged, displayResize);
  272. connect(ui->preview, &OBSQTDisplay::DisplayResized, displayResize);
  273. /* TODO: Move these into window-basic-preview */
  274. /* Preview Scaling label */
  275. connect(ui->preview, &OBSBasicPreview::scalingChanged, ui->previewScalePercent,
  276. &OBSPreviewScalingLabel::PreviewScaleChanged);
  277. /* Preview Scaling dropdown */
  278. connect(ui->preview, &OBSBasicPreview::scalingChanged, ui->previewScalingMode,
  279. &OBSPreviewScalingComboBox::PreviewScaleChanged);
  280. connect(ui->preview, &OBSBasicPreview::fixedScalingChanged, ui->previewScalingMode,
  281. &OBSPreviewScalingComboBox::PreviewFixedScalingChanged);
  282. connect(ui->previewScalingMode, &OBSPreviewScalingComboBox::currentIndexChanged, this,
  283. &OBSBasic::PreviewScalingModeChanged);
  284. /* Preview Controls */
  285. connect(ui->previewXScrollBar, &QScrollBar::sliderMoved, ui->preview, &OBSBasicPreview::xScrollBarChanged);
  286. connect(ui->previewYScrollBar, &QScrollBar::valueChanged, ui->preview, &OBSBasicPreview::yScrollBarChanged);
  287. connect(ui->previewZoomInButton, &QPushButton::clicked, ui->preview, &OBSBasicPreview::increaseScalingLevel);
  288. connect(ui->previewZoomOutButton, &QPushButton::clicked, ui->preview, &OBSBasicPreview::decreaseScalingLevel);
  289. /* Preview Actions */
  290. connect(ui->actionScaleWindow, &QAction::triggered, this, &OBSBasic::setPreviewScalingWindow);
  291. connect(ui->actionScaleCanvas, &QAction::triggered, this, &OBSBasic::setPreviewScalingCanvas);
  292. connect(ui->actionScaleOutput, &QAction::triggered, this, &OBSBasic::setPreviewScalingOutput);
  293. connect(ui->actionPreviewZoomIn, &QAction::triggered, ui->preview, &OBSBasicPreview::increaseScalingLevel);
  294. connect(ui->actionPreviewZoomOut, &QAction::triggered, ui->preview, &OBSBasicPreview::decreaseScalingLevel);
  295. connect(ui->actionPreviewResetZoom, &QAction::triggered, ui->preview, &OBSBasicPreview::resetScalingLevel);
  296. connect(this, &OBSBasic::CanvasResized, ui->previewScalingMode, &OBSPreviewScalingComboBox::CanvasResized);
  297. connect(this, &OBSBasic::OutputResized, ui->previewScalingMode, &OBSPreviewScalingComboBox::OutputResized);
  298. delete shortcutFilter;
  299. shortcutFilter = CreateShortcutFilter();
  300. installEventFilter(shortcutFilter);
  301. stringstream name;
  302. name << "OBS " << App()->GetVersionString();
  303. blog(LOG_INFO, "%s", name.str().c_str());
  304. blog(LOG_INFO, "---------------------------------");
  305. UpdateTitleBar();
  306. connect(ui->scenes->itemDelegate(), &QAbstractItemDelegate::closeEditor, this, &OBSBasic::SceneNameEdited);
  307. cpuUsageInfo = os_cpu_usage_info_start();
  308. cpuUsageTimer = new QTimer(this);
  309. connect(cpuUsageTimer.data(), &QTimer::timeout, ui->statusbar, &OBSBasicStatusBar::UpdateCPUUsage);
  310. cpuUsageTimer->start(3000);
  311. diskFullTimer = new QTimer(this);
  312. connect(diskFullTimer, &QTimer::timeout, this, &OBSBasic::CheckDiskSpaceRemaining);
  313. renameScene = new QAction(QTStr("Rename"), ui->scenesDock);
  314. renameScene->setShortcutContext(Qt::WidgetWithChildrenShortcut);
  315. connect(renameScene, &QAction::triggered, this, &OBSBasic::EditSceneName);
  316. ui->scenesDock->addAction(renameScene);
  317. renameSource = new QAction(QTStr("Rename"), ui->sourcesDock);
  318. renameSource->setShortcutContext(Qt::WidgetWithChildrenShortcut);
  319. connect(renameSource, &QAction::triggered, this, &OBSBasic::EditSceneItemName);
  320. ui->sourcesDock->addAction(renameSource);
  321. #ifdef __APPLE__
  322. renameScene->setShortcut({Qt::Key_Return});
  323. renameSource->setShortcut({Qt::Key_Return});
  324. ui->actionRemoveSource->setShortcuts({Qt::Key_Backspace});
  325. ui->actionRemoveScene->setShortcuts({Qt::Key_Backspace});
  326. ui->actionCheckForUpdates->setMenuRole(QAction::AboutQtRole);
  327. ui->action_Settings->setMenuRole(QAction::PreferencesRole);
  328. ui->actionShowMacPermissions->setMenuRole(QAction::ApplicationSpecificRole);
  329. ui->actionE_xit->setMenuRole(QAction::QuitRole);
  330. #else
  331. renameScene->setShortcut({Qt::Key_F2});
  332. renameSource->setShortcut({Qt::Key_F2});
  333. #endif
  334. #ifdef __linux__
  335. ui->actionE_xit->setShortcut(Qt::CTRL | Qt::Key_Q);
  336. #endif
  337. auto addNudge = [this](const QKeySequence &seq, MoveDir direction, int distance) {
  338. QAction *nudge = new QAction(ui->preview);
  339. nudge->setShortcut(seq);
  340. nudge->setShortcutContext(Qt::WidgetShortcut);
  341. ui->preview->addAction(nudge);
  342. connect(nudge, &QAction::triggered, [this, distance, direction]() { Nudge(distance, direction); });
  343. };
  344. addNudge(Qt::Key_Up, MoveDir::Up, 1);
  345. addNudge(Qt::Key_Down, MoveDir::Down, 1);
  346. addNudge(Qt::Key_Left, MoveDir::Left, 1);
  347. addNudge(Qt::Key_Right, MoveDir::Right, 1);
  348. addNudge(Qt::SHIFT | Qt::Key_Up, MoveDir::Up, 10);
  349. addNudge(Qt::SHIFT | Qt::Key_Down, MoveDir::Down, 10);
  350. addNudge(Qt::SHIFT | Qt::Key_Left, MoveDir::Left, 10);
  351. addNudge(Qt::SHIFT | Qt::Key_Right, MoveDir::Right, 10);
  352. /* Setup dock toggle action
  353. * And hide all docks before restoring parent geometry */
  354. #define SETUP_DOCK(dock) \
  355. setupDockAction(dock); \
  356. ui->menuDocks->addAction(dock->toggleViewAction()); \
  357. dock->setVisible(false);
  358. SETUP_DOCK(ui->scenesDock);
  359. SETUP_DOCK(ui->sourcesDock);
  360. SETUP_DOCK(ui->mixerDock);
  361. SETUP_DOCK(ui->transitionsDock);
  362. SETUP_DOCK(controlsDock);
  363. SETUP_DOCK(statsDock);
  364. #undef SETUP_DOCK
  365. // Register shortcuts for Undo/Redo
  366. ui->actionMainUndo->setShortcut(Qt::CTRL | Qt::Key_Z);
  367. QList<QKeySequence> shrt;
  368. shrt << QKeySequence((Qt::CTRL | Qt::SHIFT) | Qt::Key_Z) << QKeySequence(Qt::CTRL | Qt::Key_Y);
  369. ui->actionMainRedo->setShortcuts(shrt);
  370. ui->actionMainUndo->setShortcutContext(Qt::ApplicationShortcut);
  371. ui->actionMainRedo->setShortcutContext(Qt::ApplicationShortcut);
  372. QPoint curPos;
  373. //restore parent window geometry
  374. const char *geometry = config_get_string(App()->GetUserConfig(), "BasicWindow", "geometry");
  375. if (geometry != NULL) {
  376. QByteArray byteArray = QByteArray::fromBase64(QByteArray(geometry));
  377. restoreGeometry(byteArray);
  378. QRect windowGeometry = normalGeometry();
  379. if (!WindowPositionValid(windowGeometry)) {
  380. QRect rect = QGuiApplication::primaryScreen()->geometry();
  381. setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), rect));
  382. }
  383. curPos = pos();
  384. } else {
  385. QRect desktopRect = QGuiApplication::primaryScreen()->geometry();
  386. QSize adjSize = desktopRect.size() / 2 - size() / 2;
  387. curPos = QPoint(adjSize.width(), adjSize.height());
  388. }
  389. QPoint curSize(width(), height());
  390. QPoint statsDockSize(statsDock->width(), statsDock->height());
  391. QPoint statsDockPos = curSize / 2 - statsDockSize / 2;
  392. QPoint newPos = curPos + statsDockPos;
  393. statsDock->move(newPos);
  394. #ifdef HAVE_OBSCONFIG_H
  395. ui->actionReleaseNotes->setVisible(true);
  396. #endif
  397. ui->previewDisabledWidget->setContextMenuPolicy(Qt::CustomContextMenu);
  398. connect(ui->enablePreviewButton, &QPushButton::clicked, this, &OBSBasic::TogglePreview);
  399. connect(ui->scenes, &SceneTree::scenesReordered, []() { OBSProjector::UpdateMultiviewProjectors(); });
  400. connect(App(), &OBSApp::StyleChanged, this, [this]() { OnEvent(OBS_FRONTEND_EVENT_THEME_CHANGED); });
  401. QActionGroup *actionGroup = new QActionGroup(this);
  402. actionGroup->addAction(ui->actionSceneListMode);
  403. actionGroup->addAction(ui->actionSceneGridMode);
  404. UpdatePreviewSafeAreas();
  405. UpdatePreviewSpacingHelpers();
  406. UpdatePreviewOverflowSettings();
  407. }
  408. static const double scaled_vals[] = {1.0, 1.25, (1.0 / 0.75), 1.5, (1.0 / 0.6), 1.75, 2.0, 2.25, 2.5, 2.75, 3.0, 0.0};
  409. #ifdef __APPLE__
  410. #define DEFAULT_CONTAINER "fragmented_mov"
  411. #elif OBS_RELEASE_CANDIDATE == 0 && OBS_BETA == 0
  412. #define DEFAULT_CONTAINER "mkv"
  413. #else
  414. #define DEFAULT_CONTAINER "hybrid_mp4"
  415. #endif
  416. bool OBSBasic::InitBasicConfigDefaults()
  417. {
  418. QList<QScreen *> screens = QGuiApplication::screens();
  419. if (!screens.size()) {
  420. OBSErrorBox(NULL, "There appears to be no monitors. Er, this "
  421. "technically shouldn't be possible.");
  422. return false;
  423. }
  424. QScreen *primaryScreen = QGuiApplication::primaryScreen();
  425. uint32_t cx = primaryScreen->size().width();
  426. uint32_t cy = primaryScreen->size().height();
  427. cx *= devicePixelRatioF();
  428. cy *= devicePixelRatioF();
  429. bool oldResolutionDefaults = config_get_bool(App()->GetUserConfig(), "General", "Pre19Defaults");
  430. /* use 1920x1080 for new default base res if main monitor is above
  431. * 1920x1080, but don't apply for people from older builds -- only to
  432. * new users */
  433. if (!oldResolutionDefaults && (cx * cy) > (1920 * 1080)) {
  434. cx = 1920;
  435. cy = 1080;
  436. }
  437. bool changed = false;
  438. /* ----------------------------------------------------- */
  439. /* move over old FFmpeg track settings */
  440. if (config_has_user_value(activeConfiguration, "AdvOut", "FFAudioTrack") &&
  441. !config_has_user_value(activeConfiguration, "AdvOut", "Pre22.1Settings")) {
  442. int track = (int)config_get_int(activeConfiguration, "AdvOut", "FFAudioTrack");
  443. config_set_int(activeConfiguration, "AdvOut", "FFAudioMixes", 1LL << (track - 1));
  444. config_set_bool(activeConfiguration, "AdvOut", "Pre22.1Settings", true);
  445. changed = true;
  446. }
  447. /* ----------------------------------------------------- */
  448. /* move over mixer values in advanced if older config */
  449. if (config_has_user_value(activeConfiguration, "AdvOut", "RecTrackIndex") &&
  450. !config_has_user_value(activeConfiguration, "AdvOut", "RecTracks")) {
  451. uint64_t track = config_get_uint(activeConfiguration, "AdvOut", "RecTrackIndex");
  452. track = 1ULL << (track - 1);
  453. config_set_uint(activeConfiguration, "AdvOut", "RecTracks", track);
  454. config_remove_value(activeConfiguration, "AdvOut", "RecTrackIndex");
  455. changed = true;
  456. }
  457. /* ----------------------------------------------------- */
  458. /* set twitch chat extensions to "both" if prev version */
  459. /* is under 24.1 */
  460. if (config_get_bool(App()->GetUserConfig(), "General", "Pre24.1Defaults") &&
  461. !config_has_user_value(activeConfiguration, "Twitch", "AddonChoice")) {
  462. config_set_int(activeConfiguration, "Twitch", "AddonChoice", 3);
  463. changed = true;
  464. }
  465. /* ----------------------------------------------------- */
  466. /* move bitrate enforcement setting to new value */
  467. if (config_has_user_value(activeConfiguration, "SimpleOutput", "EnforceBitrate") &&
  468. !config_has_user_value(activeConfiguration, "Stream1", "IgnoreRecommended") &&
  469. !config_has_user_value(activeConfiguration, "Stream1", "MovedOldEnforce")) {
  470. bool enforce = config_get_bool(activeConfiguration, "SimpleOutput", "EnforceBitrate");
  471. config_set_bool(activeConfiguration, "Stream1", "IgnoreRecommended", !enforce);
  472. config_set_bool(activeConfiguration, "Stream1", "MovedOldEnforce", true);
  473. changed = true;
  474. }
  475. /* ----------------------------------------------------- */
  476. /* enforce minimum retry delay of 1 second prior to 27.1 */
  477. if (config_has_user_value(activeConfiguration, "Output", "RetryDelay")) {
  478. int retryDelay = config_get_uint(activeConfiguration, "Output", "RetryDelay");
  479. if (retryDelay < 1) {
  480. config_set_uint(activeConfiguration, "Output", "RetryDelay", 1);
  481. changed = true;
  482. }
  483. }
  484. /* ----------------------------------------------------- */
  485. /* Migrate old container selection (if any) to new key. */
  486. auto MigrateFormat = [&](const char *section) {
  487. bool has_old_key = config_has_user_value(activeConfiguration, section, "RecFormat");
  488. bool has_new_key = config_has_user_value(activeConfiguration, section, "RecFormat2");
  489. if (!has_new_key && !has_old_key)
  490. return;
  491. string old_format =
  492. config_get_string(activeConfiguration, section, has_new_key ? "RecFormat2" : "RecFormat");
  493. string new_format = old_format;
  494. if (old_format == "ts")
  495. new_format = "mpegts";
  496. else if (old_format == "m3u8")
  497. new_format = "hls";
  498. else if (old_format == "fmp4")
  499. new_format = "fragmented_mp4";
  500. else if (old_format == "fmov")
  501. new_format = "fragmented_mov";
  502. if (new_format != old_format || !has_new_key) {
  503. config_set_string(activeConfiguration, section, "RecFormat2", new_format.c_str());
  504. changed = true;
  505. }
  506. };
  507. MigrateFormat("AdvOut");
  508. MigrateFormat("SimpleOutput");
  509. /* ----------------------------------------------------- */
  510. /* Migrate output scale setting to GPU scaling options. */
  511. if (config_get_bool(activeConfiguration, "AdvOut", "Rescale") &&
  512. !config_has_user_value(activeConfiguration, "AdvOut", "RescaleFilter")) {
  513. config_set_int(activeConfiguration, "AdvOut", "RescaleFilter", OBS_SCALE_BILINEAR);
  514. }
  515. if (config_get_bool(activeConfiguration, "AdvOut", "RecRescale") &&
  516. !config_has_user_value(activeConfiguration, "AdvOut", "RecRescaleFilter")) {
  517. config_set_int(activeConfiguration, "AdvOut", "RecRescaleFilter", OBS_SCALE_BILINEAR);
  518. }
  519. /* ----------------------------------------------------- */
  520. if (changed) {
  521. activeConfiguration.SaveSafe("tmp");
  522. }
  523. /* ----------------------------------------------------- */
  524. config_set_default_string(activeConfiguration, "Output", "Mode", "Simple");
  525. config_set_default_bool(activeConfiguration, "Stream1", "IgnoreRecommended", false);
  526. config_set_default_bool(activeConfiguration, "Stream1", "EnableMultitrackVideo", false);
  527. config_set_default_bool(activeConfiguration, "Stream1", "MultitrackVideoMaximumAggregateBitrateAuto", true);
  528. config_set_default_bool(activeConfiguration, "Stream1", "MultitrackVideoMaximumVideoTracksAuto", true);
  529. config_set_default_string(activeConfiguration, "SimpleOutput", "FilePath", GetDefaultVideoSavePath().c_str());
  530. config_set_default_string(activeConfiguration, "SimpleOutput", "RecFormat2", DEFAULT_CONTAINER);
  531. config_set_default_uint(activeConfiguration, "SimpleOutput", "VBitrate", 2500);
  532. config_set_default_uint(activeConfiguration, "SimpleOutput", "ABitrate", 160);
  533. config_set_default_bool(activeConfiguration, "SimpleOutput", "UseAdvanced", false);
  534. config_set_default_string(activeConfiguration, "SimpleOutput", "Preset", "veryfast");
  535. config_set_default_string(activeConfiguration, "SimpleOutput", "NVENCPreset2", "p5");
  536. config_set_default_string(activeConfiguration, "SimpleOutput", "RecQuality", "Stream");
  537. config_set_default_bool(activeConfiguration, "SimpleOutput", "RecRB", false);
  538. config_set_default_int(activeConfiguration, "SimpleOutput", "RecRBTime", 20);
  539. config_set_default_int(activeConfiguration, "SimpleOutput", "RecRBSize", 512);
  540. config_set_default_string(activeConfiguration, "SimpleOutput", "RecRBPrefix", "Replay");
  541. config_set_default_string(activeConfiguration, "SimpleOutput", "StreamAudioEncoder", "aac");
  542. config_set_default_string(activeConfiguration, "SimpleOutput", "RecAudioEncoder", "aac");
  543. config_set_default_uint(activeConfiguration, "SimpleOutput", "RecTracks", (1 << 0));
  544. config_set_default_bool(activeConfiguration, "AdvOut", "ApplyServiceSettings", true);
  545. config_set_default_bool(activeConfiguration, "AdvOut", "UseRescale", false);
  546. config_set_default_uint(activeConfiguration, "AdvOut", "TrackIndex", 1);
  547. config_set_default_uint(activeConfiguration, "AdvOut", "VodTrackIndex", 2);
  548. config_set_default_string(activeConfiguration, "AdvOut", "Encoder", "obs_x264");
  549. config_set_default_string(activeConfiguration, "AdvOut", "RecType", "Standard");
  550. config_set_default_string(activeConfiguration, "AdvOut", "RecFilePath", GetDefaultVideoSavePath().c_str());
  551. config_set_default_string(activeConfiguration, "AdvOut", "RecFormat2", DEFAULT_CONTAINER);
  552. config_set_default_bool(activeConfiguration, "AdvOut", "RecUseRescale", false);
  553. config_set_default_uint(activeConfiguration, "AdvOut", "RecTracks", (1 << 0));
  554. config_set_default_string(activeConfiguration, "AdvOut", "RecEncoder", "none");
  555. config_set_default_uint(activeConfiguration, "AdvOut", "FLVTrack", 1);
  556. config_set_default_uint(activeConfiguration, "AdvOut", "StreamMultiTrackAudioMixes", 1);
  557. config_set_default_bool(activeConfiguration, "AdvOut", "FFOutputToFile", true);
  558. config_set_default_string(activeConfiguration, "AdvOut", "FFFilePath", GetDefaultVideoSavePath().c_str());
  559. config_set_default_string(activeConfiguration, "AdvOut", "FFExtension", "mp4");
  560. config_set_default_uint(activeConfiguration, "AdvOut", "FFVBitrate", 2500);
  561. config_set_default_uint(activeConfiguration, "AdvOut", "FFVGOPSize", 250);
  562. config_set_default_bool(activeConfiguration, "AdvOut", "FFUseRescale", false);
  563. config_set_default_bool(activeConfiguration, "AdvOut", "FFIgnoreCompat", false);
  564. config_set_default_uint(activeConfiguration, "AdvOut", "FFABitrate", 160);
  565. config_set_default_uint(activeConfiguration, "AdvOut", "FFAudioMixes", 1);
  566. config_set_default_uint(activeConfiguration, "AdvOut", "Track1Bitrate", 160);
  567. config_set_default_uint(activeConfiguration, "AdvOut", "Track2Bitrate", 160);
  568. config_set_default_uint(activeConfiguration, "AdvOut", "Track3Bitrate", 160);
  569. config_set_default_uint(activeConfiguration, "AdvOut", "Track4Bitrate", 160);
  570. config_set_default_uint(activeConfiguration, "AdvOut", "Track5Bitrate", 160);
  571. config_set_default_uint(activeConfiguration, "AdvOut", "Track6Bitrate", 160);
  572. config_set_default_uint(activeConfiguration, "AdvOut", "RecSplitFileTime", 15);
  573. config_set_default_uint(activeConfiguration, "AdvOut", "RecSplitFileSize", 2048);
  574. config_set_default_bool(activeConfiguration, "AdvOut", "RecRB", false);
  575. config_set_default_uint(activeConfiguration, "AdvOut", "RecRBTime", 20);
  576. config_set_default_int(activeConfiguration, "AdvOut", "RecRBSize", 512);
  577. config_set_default_uint(activeConfiguration, "Video", "BaseCX", cx);
  578. config_set_default_uint(activeConfiguration, "Video", "BaseCY", cy);
  579. /* don't allow BaseCX/BaseCY to be susceptible to defaults changing */
  580. if (!config_has_user_value(activeConfiguration, "Video", "BaseCX") ||
  581. !config_has_user_value(activeConfiguration, "Video", "BaseCY")) {
  582. config_set_uint(activeConfiguration, "Video", "BaseCX", cx);
  583. config_set_uint(activeConfiguration, "Video", "BaseCY", cy);
  584. config_save_safe(activeConfiguration, "tmp", nullptr);
  585. }
  586. config_set_default_string(activeConfiguration, "Output", "FilenameFormatting", "%CCYY-%MM-%DD %hh-%mm-%ss");
  587. config_set_default_bool(activeConfiguration, "Output", "DelayEnable", false);
  588. config_set_default_uint(activeConfiguration, "Output", "DelaySec", 20);
  589. config_set_default_bool(activeConfiguration, "Output", "DelayPreserve", true);
  590. config_set_default_bool(activeConfiguration, "Output", "Reconnect", true);
  591. config_set_default_uint(activeConfiguration, "Output", "RetryDelay", 2);
  592. config_set_default_uint(activeConfiguration, "Output", "MaxRetries", 25);
  593. config_set_default_string(activeConfiguration, "Output", "BindIP", "default");
  594. config_set_default_string(activeConfiguration, "Output", "IPFamily", "IPv4+IPv6");
  595. config_set_default_bool(activeConfiguration, "Output", "NewSocketLoopEnable", false);
  596. config_set_default_bool(activeConfiguration, "Output", "LowLatencyEnable", false);
  597. int i = 0;
  598. uint32_t scale_cx = cx;
  599. uint32_t scale_cy = cy;
  600. /* use a default scaled resolution that has a pixel count no higher
  601. * than 1280x720 */
  602. while (((scale_cx * scale_cy) > (1280 * 720)) && scaled_vals[i] > 0.0) {
  603. double scale = scaled_vals[i++];
  604. scale_cx = uint32_t(double(cx) / scale);
  605. scale_cy = uint32_t(double(cy) / scale);
  606. }
  607. config_set_default_uint(activeConfiguration, "Video", "OutputCX", scale_cx);
  608. config_set_default_uint(activeConfiguration, "Video", "OutputCY", scale_cy);
  609. /* don't allow OutputCX/OutputCY to be susceptible to defaults
  610. * changing */
  611. if (!config_has_user_value(activeConfiguration, "Video", "OutputCX") ||
  612. !config_has_user_value(activeConfiguration, "Video", "OutputCY")) {
  613. config_set_uint(activeConfiguration, "Video", "OutputCX", scale_cx);
  614. config_set_uint(activeConfiguration, "Video", "OutputCY", scale_cy);
  615. config_save_safe(activeConfiguration, "tmp", nullptr);
  616. }
  617. config_set_default_uint(activeConfiguration, "Video", "FPSType", 0);
  618. config_set_default_string(activeConfiguration, "Video", "FPSCommon", "30");
  619. config_set_default_uint(activeConfiguration, "Video", "FPSInt", 30);
  620. config_set_default_uint(activeConfiguration, "Video", "FPSNum", 30);
  621. config_set_default_uint(activeConfiguration, "Video", "FPSDen", 1);
  622. config_set_default_string(activeConfiguration, "Video", "ScaleType", "bicubic");
  623. config_set_default_string(activeConfiguration, "Video", "ColorFormat", "NV12");
  624. config_set_default_string(activeConfiguration, "Video", "ColorSpace", "709");
  625. config_set_default_string(activeConfiguration, "Video", "ColorRange", "Partial");
  626. config_set_default_uint(activeConfiguration, "Video", "SdrWhiteLevel", 300);
  627. config_set_default_uint(activeConfiguration, "Video", "HdrNominalPeakLevel", 1000);
  628. config_set_default_string(activeConfiguration, "Audio", "MonitoringDeviceId", "default");
  629. config_set_default_string(activeConfiguration, "Audio", "MonitoringDeviceName",
  630. Str("Basic.Settings.Advanced.Audio.MonitoringDevice"
  631. ".Default"));
  632. config_set_default_uint(activeConfiguration, "Audio", "SampleRate", 48000);
  633. config_set_default_string(activeConfiguration, "Audio", "ChannelSetup", "Stereo");
  634. config_set_default_double(activeConfiguration, "Audio", "MeterDecayRate", VOLUME_METER_DECAY_FAST);
  635. config_set_default_uint(activeConfiguration, "Audio", "PeakMeterType", 0);
  636. CheckExistingCookieId();
  637. return true;
  638. }
  639. void OBSBasic::InitBasicConfigDefaults2()
  640. {
  641. bool oldEncDefaults = config_get_bool(App()->GetUserConfig(), "General", "Pre23Defaults");
  642. bool useNV = EncoderAvailable("ffmpeg_nvenc") && !oldEncDefaults;
  643. config_set_default_string(activeConfiguration, "SimpleOutput", "StreamEncoder",
  644. useNV ? SIMPLE_ENCODER_NVENC : SIMPLE_ENCODER_X264);
  645. config_set_default_string(activeConfiguration, "SimpleOutput", "RecEncoder",
  646. useNV ? SIMPLE_ENCODER_NVENC : SIMPLE_ENCODER_X264);
  647. const char *aac_default = "ffmpeg_aac";
  648. if (EncoderAvailable("CoreAudio_AAC"))
  649. aac_default = "CoreAudio_AAC";
  650. else if (EncoderAvailable("libfdk_aac"))
  651. aac_default = "libfdk_aac";
  652. config_set_default_string(activeConfiguration, "AdvOut", "AudioEncoder", aac_default);
  653. config_set_default_string(activeConfiguration, "AdvOut", "RecAudioEncoder", aac_default);
  654. }
  655. bool OBSBasic::InitBasicConfig()
  656. {
  657. ProfileScope("OBSBasic::InitBasicConfig");
  658. RefreshProfiles(true);
  659. const std::string currentProfileName{config_get_string(App()->GetUserConfig(), "Basic", "Profile")};
  660. const std::optional<OBSProfile> currentProfile = GetProfileByName(currentProfileName);
  661. const std::optional<OBSProfile> foundProfile = GetProfileByName(opt_starting_profile);
  662. try {
  663. if (foundProfile) {
  664. ActivateProfile(foundProfile.value());
  665. } else if (currentProfile) {
  666. ActivateProfile(currentProfile.value());
  667. } else {
  668. const OBSProfile &newProfile = CreateProfile(currentProfileName);
  669. ActivateProfile(newProfile);
  670. }
  671. } catch (const std::logic_error &) {
  672. OBSErrorBox(NULL, "Failed to open basic.ini: %d", -1);
  673. return false;
  674. }
  675. return true;
  676. }
  677. void OBSBasic::InitOBSCallbacks()
  678. {
  679. ProfileScope("OBSBasic::InitOBSCallbacks");
  680. signalHandlers.reserve(signalHandlers.size() + 9);
  681. signalHandlers.emplace_back(obs_get_signal_handler(), "source_create", OBSBasic::SourceCreated, this);
  682. signalHandlers.emplace_back(obs_get_signal_handler(), "source_remove", OBSBasic::SourceRemoved, this);
  683. signalHandlers.emplace_back(obs_get_signal_handler(), "source_activate", OBSBasic::SourceActivated, this);
  684. signalHandlers.emplace_back(obs_get_signal_handler(), "source_deactivate", OBSBasic::SourceDeactivated, this);
  685. signalHandlers.emplace_back(obs_get_signal_handler(), "source_audio_activate", OBSBasic::SourceAudioActivated,
  686. this);
  687. signalHandlers.emplace_back(obs_get_signal_handler(), "source_audio_deactivate",
  688. OBSBasic::SourceAudioDeactivated, this);
  689. signalHandlers.emplace_back(obs_get_signal_handler(), "source_rename", OBSBasic::SourceRenamed, this);
  690. signalHandlers.emplace_back(
  691. obs_get_signal_handler(), "source_filter_add",
  692. [](void *data, calldata_t *) {
  693. QMetaObject::invokeMethod(static_cast<OBSBasic *>(data), "UpdateEditMenu",
  694. Qt::QueuedConnection);
  695. },
  696. this);
  697. signalHandlers.emplace_back(
  698. obs_get_signal_handler(), "source_filter_remove",
  699. [](void *data, calldata_t *) {
  700. QMetaObject::invokeMethod(static_cast<OBSBasic *>(data), "UpdateEditMenu",
  701. Qt::QueuedConnection);
  702. },
  703. this);
  704. }
  705. #define STARTUP_SEPARATOR "==== Startup complete ==============================================="
  706. #define SHUTDOWN_SEPARATOR "==== Shutting down =================================================="
  707. #define UNSUPPORTED_ERROR \
  708. "Failed to initialize video:\n\nRequired graphics API functionality " \
  709. "not found. Your GPU may not be supported."
  710. #define UNKNOWN_ERROR \
  711. "Failed to initialize video. Your GPU may not be supported, " \
  712. "or your graphics drivers may need to be updated."
  713. static inline void LogEncoders()
  714. {
  715. constexpr uint32_t hide_flags = OBS_ENCODER_CAP_DEPRECATED | OBS_ENCODER_CAP_INTERNAL;
  716. auto list_encoders = [](obs_encoder_type type) {
  717. size_t idx = 0;
  718. const char *encoder_type;
  719. while (obs_enum_encoder_types(idx++, &encoder_type)) {
  720. if (obs_get_encoder_caps(encoder_type) & hide_flags ||
  721. obs_get_encoder_type(encoder_type) != type) {
  722. continue;
  723. }
  724. blog(LOG_INFO, "\t- %s (%s)", encoder_type, obs_encoder_get_display_name(encoder_type));
  725. }
  726. };
  727. blog(LOG_INFO, "---------------------------------");
  728. blog(LOG_INFO, "Available Encoders:");
  729. blog(LOG_INFO, " Video Encoders:");
  730. list_encoders(OBS_ENCODER_VIDEO);
  731. blog(LOG_INFO, " Audio Encoders:");
  732. list_encoders(OBS_ENCODER_AUDIO);
  733. }
  734. void OBSBasic::OBSInit()
  735. {
  736. ProfileScope("OBSBasic::OBSInit");
  737. if (!InitBasicConfig())
  738. throw "Failed to load basic.ini";
  739. if (!ResetAudio())
  740. throw "Failed to initialize audio";
  741. int ret = 0;
  742. ret = ResetVideo();
  743. switch (ret) {
  744. case OBS_VIDEO_MODULE_NOT_FOUND:
  745. throw "Failed to initialize video: Graphics module not found";
  746. case OBS_VIDEO_NOT_SUPPORTED:
  747. throw UNSUPPORTED_ERROR;
  748. case OBS_VIDEO_INVALID_PARAM:
  749. throw "Failed to initialize video: Invalid parameters";
  750. default:
  751. if (ret != OBS_VIDEO_SUCCESS)
  752. throw UNKNOWN_ERROR;
  753. }
  754. /* load audio monitoring */
  755. if (obs_audio_monitoring_available()) {
  756. const char *device_name = config_get_string(activeConfiguration, "Audio", "MonitoringDeviceName");
  757. const char *device_id = config_get_string(activeConfiguration, "Audio", "MonitoringDeviceId");
  758. obs_set_audio_monitoring_device(device_name, device_id);
  759. blog(LOG_INFO, "Audio monitoring device:\n\tname: %s\n\tid: %s", device_name, device_id);
  760. }
  761. InitOBSCallbacks();
  762. InitHotkeys();
  763. ui->preview->Init();
  764. /* hack to prevent elgato from loading its own QtNetwork that it tries
  765. * to ship with */
  766. #if defined(_WIN32) && !defined(_DEBUG)
  767. LoadLibraryW(L"Qt6Network");
  768. #endif
  769. struct obs_module_failure_info mfi;
  770. /* Safe Mode disables third-party plugins so we don't need to add earch
  771. * paths outside the OBS bundle/installation. */
  772. if (safe_mode || disable_3p_plugins) {
  773. SetSafeModuleNames();
  774. } else {
  775. AddExtraModulePaths();
  776. }
  777. /* Modules can access frontend information (i.e. profile and scene collection data) during their initialization, and some modules (e.g. obs-websockets) are known to use the filesystem location of the current profile in their own code.
  778. Thus the profile and scene collection discovery needs to happen before any access to that information (but after intializing global settings) to ensure legacy code gets valid path information.
  779. */
  780. RefreshSceneCollections(true);
  781. blog(LOG_INFO, "---------------------------------");
  782. obs_load_all_modules2(&mfi);
  783. blog(LOG_INFO, "---------------------------------");
  784. obs_log_loaded_modules();
  785. blog(LOG_INFO, "---------------------------------");
  786. obs_post_load_modules();
  787. BPtr<char *> failed_modules = mfi.failed_modules;
  788. #ifdef BROWSER_AVAILABLE
  789. cef = obs_browser_init_panel();
  790. cef_js_avail = cef && obs_browser_qcef_version() >= 3;
  791. #endif
  792. vcamEnabled = (obs_get_output_flags(VIRTUAL_CAM_ID) & OBS_OUTPUT_VIDEO) != 0;
  793. if (vcamEnabled) {
  794. emit VirtualCamEnabled();
  795. }
  796. UpdateProfileEncoders();
  797. LogEncoders();
  798. blog(LOG_INFO, STARTUP_SEPARATOR);
  799. if (!InitService())
  800. throw "Failed to initialize service";
  801. ResetOutputs();
  802. CreateHotkeys();
  803. InitPrimitives();
  804. sceneDuplicationMode = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SceneDuplicationMode");
  805. swapScenesMode = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SwapScenesMode");
  806. editPropertiesMode = config_get_bool(App()->GetUserConfig(), "BasicWindow", "EditPropertiesMode");
  807. if (!opt_studio_mode) {
  808. SetPreviewProgramMode(config_get_bool(App()->GetUserConfig(), "BasicWindow", "PreviewProgramMode"));
  809. } else {
  810. SetPreviewProgramMode(true);
  811. opt_studio_mode = false;
  812. }
  813. #define SET_VISIBILITY(name, control) \
  814. do { \
  815. if (config_has_user_value(App()->GetUserConfig(), "BasicWindow", name)) { \
  816. bool visible = config_get_bool(App()->GetUserConfig(), "BasicWindow", name); \
  817. ui->control->setChecked(visible); \
  818. } \
  819. } while (false)
  820. SET_VISIBILITY("ShowListboxToolbars", toggleListboxToolbars);
  821. SET_VISIBILITY("ShowStatusBar", toggleStatusBar);
  822. #undef SET_VISIBILITY
  823. bool sourceIconsVisible = config_get_bool(App()->GetUserConfig(), "BasicWindow", "ShowSourceIcons");
  824. ui->toggleSourceIcons->setChecked(sourceIconsVisible);
  825. bool contextVisible = config_get_bool(App()->GetUserConfig(), "BasicWindow", "ShowContextToolbars");
  826. ui->toggleContextBar->setChecked(contextVisible);
  827. ui->contextContainer->setVisible(contextVisible);
  828. if (contextVisible)
  829. UpdateContextBar(true);
  830. UpdateEditMenu();
  831. {
  832. ProfileScope("OBSBasic::Load");
  833. const std::string sceneCollectionName{
  834. config_get_string(App()->GetUserConfig(), "Basic", "SceneCollection")};
  835. const std::optional<OBSSceneCollection> configuredCollection =
  836. GetSceneCollectionByName(sceneCollectionName);
  837. const std::optional<OBSSceneCollection> foundCollection =
  838. GetSceneCollectionByName(opt_starting_collection);
  839. if (foundCollection) {
  840. ActivateSceneCollection(foundCollection.value());
  841. } else if (configuredCollection) {
  842. ActivateSceneCollection(configuredCollection.value());
  843. } else {
  844. disableSaving--;
  845. SetupNewSceneCollection(sceneCollectionName);
  846. disableSaving++;
  847. }
  848. if (foundCollection || configuredCollection) {
  849. disableSaving--;
  850. OnEvent(OBS_FRONTEND_EVENT_SCENE_COLLECTION_LIST_CHANGED);
  851. OnEvent(OBS_FRONTEND_EVENT_SCENE_COLLECTION_CHANGED);
  852. OnEvent(OBS_FRONTEND_EVENT_SCENE_CHANGED);
  853. OnEvent(OBS_FRONTEND_EVENT_PREVIEW_SCENE_CHANGED);
  854. disableSaving++;
  855. }
  856. }
  857. loaded = true;
  858. previewEnabled = config_get_bool(App()->GetUserConfig(), "BasicWindow", "PreviewEnabled");
  859. if (!previewEnabled && !IsPreviewProgramMode())
  860. QMetaObject::invokeMethod(this, "EnablePreviewDisplay", Qt::QueuedConnection,
  861. Q_ARG(bool, previewEnabled));
  862. else if (!previewEnabled && IsPreviewProgramMode())
  863. QMetaObject::invokeMethod(this, "EnablePreviewDisplay", Qt::QueuedConnection, Q_ARG(bool, true));
  864. disableSaving--;
  865. auto addDisplay = [this](OBSQTDisplay *window) {
  866. obs_display_add_draw_callback(window->GetDisplay(), OBSBasic::RenderMain, this);
  867. struct obs_video_info ovi;
  868. if (obs_get_video_info(&ovi))
  869. ResizePreview(ovi.base_width, ovi.base_height);
  870. };
  871. connect(ui->preview, &OBSQTDisplay::DisplayCreated, addDisplay);
  872. /* Show the main window, unless the tray icon isn't available
  873. * or neither the setting nor flag for starting minimized is set. */
  874. bool sysTrayEnabled = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SysTrayEnabled");
  875. bool sysTrayWhenStarted = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SysTrayWhenStarted");
  876. bool hideWindowOnStart = QSystemTrayIcon::isSystemTrayAvailable() && sysTrayEnabled &&
  877. (opt_minimize_tray || sysTrayWhenStarted);
  878. #ifdef _WIN32
  879. SetWin32DropStyle(this);
  880. if (!hideWindowOnStart)
  881. show();
  882. #endif
  883. bool alwaysOnTop = config_get_bool(App()->GetUserConfig(), "BasicWindow", "AlwaysOnTop");
  884. #ifdef ENABLE_WAYLAND
  885. bool isWayland = obs_get_nix_platform() == OBS_NIX_PLATFORM_WAYLAND;
  886. #else
  887. bool isWayland = false;
  888. #endif
  889. if (!isWayland && (alwaysOnTop || opt_always_on_top)) {
  890. SetAlwaysOnTop(this, true);
  891. ui->actionAlwaysOnTop->setChecked(true);
  892. } else if (isWayland) {
  893. if (opt_always_on_top)
  894. blog(LOG_INFO, "Always On Top not available on Wayland, ignoring.");
  895. ui->actionAlwaysOnTop->setEnabled(false);
  896. ui->actionAlwaysOnTop->setVisible(false);
  897. }
  898. #ifndef _WIN32
  899. if (!hideWindowOnStart)
  900. show();
  901. #endif
  902. /* setup stats dock */
  903. OBSBasicStats *statsDlg = new OBSBasicStats(statsDock, false);
  904. statsDock->setWidget(statsDlg);
  905. /* ----------------------------- */
  906. /* add custom browser docks */
  907. #if defined(BROWSER_AVAILABLE) && defined(YOUTUBE_ENABLED)
  908. YouTubeAppDock::CleanupYouTubeUrls();
  909. #endif
  910. #ifdef BROWSER_AVAILABLE
  911. if (cef) {
  912. QAction *action = new QAction(QTStr("Basic.MainMenu.Docks."
  913. "CustomBrowserDocks"),
  914. this);
  915. ui->menuDocks->insertAction(ui->scenesDock->toggleViewAction(), action);
  916. connect(action, &QAction::triggered, this, &OBSBasic::ManageExtraBrowserDocks);
  917. ui->menuDocks->insertSeparator(ui->scenesDock->toggleViewAction());
  918. LoadExtraBrowserDocks();
  919. }
  920. #endif
  921. #ifdef YOUTUBE_ENABLED
  922. /* setup YouTube app dock */
  923. if (YouTubeAppDock::IsYTServiceSelected())
  924. NewYouTubeAppDock();
  925. #endif
  926. const char *dockStateStr = config_get_string(App()->GetUserConfig(), "BasicWindow", "DockState");
  927. if (!dockStateStr) {
  928. on_resetDocks_triggered(true);
  929. } else {
  930. QByteArray dockState = QByteArray::fromBase64(QByteArray(dockStateStr));
  931. if (!restoreState(dockState))
  932. on_resetDocks_triggered(true);
  933. }
  934. bool pre23Defaults = config_get_bool(App()->GetUserConfig(), "General", "Pre23Defaults");
  935. if (pre23Defaults) {
  936. bool resetDockLock23 = config_get_bool(App()->GetUserConfig(), "General", "ResetDockLock23");
  937. if (!resetDockLock23) {
  938. config_set_bool(App()->GetUserConfig(), "General", "ResetDockLock23", true);
  939. config_remove_value(App()->GetUserConfig(), "BasicWindow", "DocksLocked");
  940. config_save_safe(App()->GetUserConfig(), "tmp", nullptr);
  941. }
  942. }
  943. bool docksLocked = config_get_bool(App()->GetUserConfig(), "BasicWindow", "DocksLocked");
  944. on_lockDocks_toggled(docksLocked);
  945. ui->lockDocks->blockSignals(true);
  946. ui->lockDocks->setChecked(docksLocked);
  947. ui->lockDocks->blockSignals(false);
  948. bool sideDocks = config_get_bool(App()->GetUserConfig(), "BasicWindow", "SideDocks");
  949. on_sideDocks_toggled(sideDocks);
  950. ui->sideDocks->blockSignals(true);
  951. ui->sideDocks->setChecked(sideDocks);
  952. ui->sideDocks->blockSignals(false);
  953. SystemTray(true);
  954. TaskbarOverlayInit();
  955. #ifdef __APPLE__
  956. disableColorSpaceConversion(this);
  957. #endif
  958. bool has_last_version = config_has_user_value(App()->GetAppConfig(), "General", "LastVersion");
  959. bool first_run = config_get_bool(App()->GetUserConfig(), "General", "FirstRun");
  960. if (!first_run) {
  961. config_set_bool(App()->GetUserConfig(), "General", "FirstRun", true);
  962. config_save_safe(App()->GetUserConfig(), "tmp", nullptr);
  963. }
  964. if (!first_run && !has_last_version && !Active())
  965. QMetaObject::invokeMethod(this, "on_autoConfigure_triggered", Qt::QueuedConnection);
  966. #if (defined(_WIN32) || defined(__APPLE__)) && (OBS_RELEASE_CANDIDATE > 0 || OBS_BETA > 0)
  967. /* Automatically set branch to "beta" the first time a pre-release build is run. */
  968. if (!config_get_bool(App()->GetAppConfig(), "General", "AutoBetaOptIn")) {
  969. config_set_string(App()->GetAppConfig(), "General", "UpdateBranch", "beta");
  970. config_set_bool(App()->GetAppConfig(), "General", "AutoBetaOptIn", true);
  971. config_save_safe(App()->GetAppConfig(), "tmp", nullptr);
  972. }
  973. #endif
  974. TimedCheckForUpdates();
  975. ToggleMixerLayout(config_get_bool(App()->GetUserConfig(), "BasicWindow", "VerticalVolControl"));
  976. if (config_get_bool(activeConfiguration, "General", "OpenStatsOnStartup"))
  977. on_stats_triggered();
  978. OBSBasicStats::InitializeValues();
  979. /* ----------------------- */
  980. /* Add multiview menu */
  981. ui->viewMenu->addSeparator();
  982. AddProjectorMenuMonitors(ui->multiviewProjectorMenu, this, &OBSBasic::OpenMultiviewProjector);
  983. connect(ui->viewMenu->menuAction(), &QAction::hovered, this, &OBSBasic::UpdateMultiviewProjectorMenu);
  984. ui->sources->UpdateIcons();
  985. #if !defined(_WIN32)
  986. delete ui->actionShowCrashLogs;
  987. delete ui->actionUploadLastCrashLog;
  988. delete ui->menuCrashLogs;
  989. delete ui->actionRepair;
  990. ui->actionShowCrashLogs = nullptr;
  991. ui->actionUploadLastCrashLog = nullptr;
  992. ui->menuCrashLogs = nullptr;
  993. ui->actionRepair = nullptr;
  994. #if !defined(__APPLE__)
  995. delete ui->actionCheckForUpdates;
  996. ui->actionCheckForUpdates = nullptr;
  997. #endif
  998. #endif
  999. #ifdef __APPLE__
  1000. /* Remove OBS' Fullscreen Interface menu in favor of the one macOS adds by default */
  1001. delete ui->actionFullscreenInterface;
  1002. ui->actionFullscreenInterface = nullptr;
  1003. #else
  1004. /* Don't show menu to raise macOS-only permissions dialog */
  1005. delete ui->actionShowMacPermissions;
  1006. ui->actionShowMacPermissions = nullptr;
  1007. #endif
  1008. #if defined(_WIN32) || defined(__APPLE__)
  1009. if (App()->IsUpdaterDisabled()) {
  1010. ui->actionCheckForUpdates->setEnabled(false);
  1011. #if defined(_WIN32)
  1012. ui->actionRepair->setEnabled(false);
  1013. #endif
  1014. }
  1015. #endif
  1016. #ifndef WHATSNEW_ENABLED
  1017. delete ui->actionShowWhatsNew;
  1018. ui->actionShowWhatsNew = nullptr;
  1019. #endif
  1020. if (safe_mode) {
  1021. ui->actionRestartSafe->setText(QTStr("Basic.MainMenu.Help.RestartNormal"));
  1022. }
  1023. UpdatePreviewProgramIndicators();
  1024. OnFirstLoad();
  1025. if (!hideWindowOnStart)
  1026. activateWindow();
  1027. /* ------------------------------------------- */
  1028. /* display warning message for failed modules */
  1029. if (mfi.count) {
  1030. QString failed_plugins;
  1031. char **plugin = mfi.failed_modules;
  1032. while (*plugin) {
  1033. failed_plugins += *plugin;
  1034. failed_plugins += "\n";
  1035. plugin++;
  1036. }
  1037. QString failed_msg = QTStr("PluginsFailedToLoad.Text").arg(failed_plugins);
  1038. OBSMessageBox::warning(this, QTStr("PluginsFailedToLoad.Title"), failed_msg);
  1039. }
  1040. }
  1041. void OBSBasic::OnFirstLoad()
  1042. {
  1043. OnEvent(OBS_FRONTEND_EVENT_FINISHED_LOADING);
  1044. #ifdef WHATSNEW_ENABLED
  1045. /* Attempt to load init screen if available */
  1046. if (cef) {
  1047. WhatsNewInfoThread *wnit = new WhatsNewInfoThread();
  1048. connect(wnit, &WhatsNewInfoThread::Result, this, &OBSBasic::ReceivedIntroJson, Qt::QueuedConnection);
  1049. introCheckThread.reset(wnit);
  1050. introCheckThread->start();
  1051. }
  1052. #endif
  1053. Auth::Load();
  1054. bool showLogViewerOnStartup = config_get_bool(App()->GetUserConfig(), "LogViewer", "ShowLogStartup");
  1055. if (showLogViewerOnStartup)
  1056. on_actionViewCurrentLog_triggered();
  1057. }
  1058. OBSBasic::~OBSBasic()
  1059. {
  1060. /* clear out UI event queue */
  1061. QApplication::sendPostedEvents(nullptr);
  1062. QApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete);
  1063. if (updateCheckThread && updateCheckThread->isRunning())
  1064. updateCheckThread->wait();
  1065. if (patronJsonThread && patronJsonThread->isRunning())
  1066. patronJsonThread->wait();
  1067. delete screenshotData;
  1068. delete previewProjector;
  1069. delete studioProgramProjector;
  1070. delete previewProjectorSource;
  1071. delete previewProjectorMain;
  1072. delete sourceProjector;
  1073. delete sceneProjectorMenu;
  1074. delete scaleFilteringMenu;
  1075. delete blendingModeMenu;
  1076. delete colorMenu;
  1077. delete colorWidgetAction;
  1078. delete colorSelect;
  1079. delete deinterlaceMenu;
  1080. delete perSceneTransitionMenu;
  1081. delete shortcutFilter;
  1082. delete trayMenu;
  1083. delete programOptions;
  1084. delete program;
  1085. /* XXX: any obs data must be released before calling obs_shutdown.
  1086. * currently, we can't automate this with C++ RAII because of the
  1087. * delicate nature of obs_shutdown needing to be freed before the UI
  1088. * can be freed, and we have no control over the destruction order of
  1089. * the Qt UI stuff, so we have to manually clear any references to
  1090. * libobs. */
  1091. delete cpuUsageTimer;
  1092. os_cpu_usage_info_destroy(cpuUsageInfo);
  1093. obs_hotkey_set_callback_routing_func(nullptr, nullptr);
  1094. ClearHotkeys();
  1095. service = nullptr;
  1096. outputHandler.reset();
  1097. delete interaction;
  1098. delete properties;
  1099. delete filters;
  1100. delete transformWindow;
  1101. delete advAudioWindow;
  1102. delete about;
  1103. delete remux;
  1104. obs_display_remove_draw_callback(ui->preview->GetDisplay(), OBSBasic::RenderMain, this);
  1105. obs_enter_graphics();
  1106. gs_vertexbuffer_destroy(box);
  1107. gs_vertexbuffer_destroy(boxLeft);
  1108. gs_vertexbuffer_destroy(boxTop);
  1109. gs_vertexbuffer_destroy(boxRight);
  1110. gs_vertexbuffer_destroy(boxBottom);
  1111. gs_vertexbuffer_destroy(circle);
  1112. gs_vertexbuffer_destroy(actionSafeMargin);
  1113. gs_vertexbuffer_destroy(graphicsSafeMargin);
  1114. gs_vertexbuffer_destroy(fourByThreeSafeMargin);
  1115. gs_vertexbuffer_destroy(leftLine);
  1116. gs_vertexbuffer_destroy(topLine);
  1117. gs_vertexbuffer_destroy(rightLine);
  1118. obs_leave_graphics();
  1119. /* When shutting down, sometimes source references can get in to the
  1120. * event queue, and if we don't forcibly process those events they
  1121. * won't get processed until after obs_shutdown has been called. I
  1122. * really wish there were a more elegant way to deal with this via C++,
  1123. * but Qt doesn't use C++ in a normal way, so you can't really rely on
  1124. * normal C++ behavior for your data to be freed in the order that you
  1125. * expect or want it to. */
  1126. QApplication::sendPostedEvents(nullptr);
  1127. config_set_int(App()->GetAppConfig(), "General", "LastVersion", LIBOBS_API_VER);
  1128. config_save_safe(App()->GetAppConfig(), "tmp", nullptr);
  1129. config_set_bool(App()->GetUserConfig(), "BasicWindow", "PreviewEnabled", previewEnabled);
  1130. config_set_bool(App()->GetUserConfig(), "BasicWindow", "AlwaysOnTop", ui->actionAlwaysOnTop->isChecked());
  1131. config_set_bool(App()->GetUserConfig(), "BasicWindow", "SceneDuplicationMode", sceneDuplicationMode);
  1132. config_set_bool(App()->GetUserConfig(), "BasicWindow", "SwapScenesMode", swapScenesMode);
  1133. config_set_bool(App()->GetUserConfig(), "BasicWindow", "EditPropertiesMode", editPropertiesMode);
  1134. config_set_bool(App()->GetUserConfig(), "BasicWindow", "PreviewProgramMode", IsPreviewProgramMode());
  1135. config_set_bool(App()->GetUserConfig(), "BasicWindow", "DocksLocked", ui->lockDocks->isChecked());
  1136. config_set_bool(App()->GetUserConfig(), "BasicWindow", "SideDocks", ui->sideDocks->isChecked());
  1137. config_save_safe(App()->GetUserConfig(), "tmp", nullptr);
  1138. #ifdef BROWSER_AVAILABLE
  1139. DestroyPanelCookieManager();
  1140. delete cef;
  1141. cef = nullptr;
  1142. #endif
  1143. }
  1144. static inline int AttemptToResetVideo(struct obs_video_info *ovi)
  1145. {
  1146. return obs_reset_video(ovi);
  1147. }
  1148. static inline enum obs_scale_type GetScaleType(ConfigFile &activeConfiguration)
  1149. {
  1150. const char *scaleTypeStr = config_get_string(activeConfiguration, "Video", "ScaleType");
  1151. if (astrcmpi(scaleTypeStr, "bilinear") == 0)
  1152. return OBS_SCALE_BILINEAR;
  1153. else if (astrcmpi(scaleTypeStr, "lanczos") == 0)
  1154. return OBS_SCALE_LANCZOS;
  1155. else if (astrcmpi(scaleTypeStr, "area") == 0)
  1156. return OBS_SCALE_AREA;
  1157. else
  1158. return OBS_SCALE_BICUBIC;
  1159. }
  1160. static inline enum video_format GetVideoFormatFromName(const char *name)
  1161. {
  1162. if (astrcmpi(name, "I420") == 0)
  1163. return VIDEO_FORMAT_I420;
  1164. else if (astrcmpi(name, "NV12") == 0)
  1165. return VIDEO_FORMAT_NV12;
  1166. else if (astrcmpi(name, "I444") == 0)
  1167. return VIDEO_FORMAT_I444;
  1168. else if (astrcmpi(name, "I010") == 0)
  1169. return VIDEO_FORMAT_I010;
  1170. else if (astrcmpi(name, "P010") == 0)
  1171. return VIDEO_FORMAT_P010;
  1172. else if (astrcmpi(name, "P216") == 0)
  1173. return VIDEO_FORMAT_P216;
  1174. else if (astrcmpi(name, "P416") == 0)
  1175. return VIDEO_FORMAT_P416;
  1176. #if 0 //currently unsupported
  1177. else if (astrcmpi(name, "YVYU") == 0)
  1178. return VIDEO_FORMAT_YVYU;
  1179. else if (astrcmpi(name, "YUY2") == 0)
  1180. return VIDEO_FORMAT_YUY2;
  1181. else if (astrcmpi(name, "UYVY") == 0)
  1182. return VIDEO_FORMAT_UYVY;
  1183. #endif
  1184. else
  1185. return VIDEO_FORMAT_BGRA;
  1186. }
  1187. static inline enum video_colorspace GetVideoColorSpaceFromName(const char *name)
  1188. {
  1189. enum video_colorspace colorspace = VIDEO_CS_SRGB;
  1190. if (strcmp(name, "601") == 0)
  1191. colorspace = VIDEO_CS_601;
  1192. else if (strcmp(name, "709") == 0)
  1193. colorspace = VIDEO_CS_709;
  1194. else if (strcmp(name, "2100PQ") == 0)
  1195. colorspace = VIDEO_CS_2100_PQ;
  1196. else if (strcmp(name, "2100HLG") == 0)
  1197. colorspace = VIDEO_CS_2100_HLG;
  1198. return colorspace;
  1199. }
  1200. int OBSBasic::ResetVideo()
  1201. {
  1202. if (outputHandler && outputHandler->Active())
  1203. return OBS_VIDEO_CURRENTLY_ACTIVE;
  1204. ProfileScope("OBSBasic::ResetVideo");
  1205. struct obs_video_info ovi;
  1206. int ret;
  1207. GetConfigFPS(ovi.fps_num, ovi.fps_den);
  1208. const char *colorFormat = config_get_string(activeConfiguration, "Video", "ColorFormat");
  1209. const char *colorSpace = config_get_string(activeConfiguration, "Video", "ColorSpace");
  1210. const char *colorRange = config_get_string(activeConfiguration, "Video", "ColorRange");
  1211. ovi.graphics_module = App()->GetRenderModule();
  1212. ovi.base_width = (uint32_t)config_get_uint(activeConfiguration, "Video", "BaseCX");
  1213. ovi.base_height = (uint32_t)config_get_uint(activeConfiguration, "Video", "BaseCY");
  1214. ovi.output_width = (uint32_t)config_get_uint(activeConfiguration, "Video", "OutputCX");
  1215. ovi.output_height = (uint32_t)config_get_uint(activeConfiguration, "Video", "OutputCY");
  1216. ovi.output_format = GetVideoFormatFromName(colorFormat);
  1217. ovi.colorspace = GetVideoColorSpaceFromName(colorSpace);
  1218. ovi.range = astrcmpi(colorRange, "Full") == 0 ? VIDEO_RANGE_FULL : VIDEO_RANGE_PARTIAL;
  1219. ovi.adapter = config_get_uint(App()->GetUserConfig(), "Video", "AdapterIdx");
  1220. ovi.gpu_conversion = true;
  1221. ovi.scale_type = GetScaleType(activeConfiguration);
  1222. if (ovi.base_width < 32 || ovi.base_height < 32) {
  1223. ovi.base_width = 1920;
  1224. ovi.base_height = 1080;
  1225. config_set_uint(activeConfiguration, "Video", "BaseCX", 1920);
  1226. config_set_uint(activeConfiguration, "Video", "BaseCY", 1080);
  1227. }
  1228. if (ovi.output_width < 32 || ovi.output_height < 32) {
  1229. ovi.output_width = ovi.base_width;
  1230. ovi.output_height = ovi.base_height;
  1231. config_set_uint(activeConfiguration, "Video", "OutputCX", ovi.base_width);
  1232. config_set_uint(activeConfiguration, "Video", "OutputCY", ovi.base_height);
  1233. }
  1234. ret = AttemptToResetVideo(&ovi);
  1235. if (ret == OBS_VIDEO_CURRENTLY_ACTIVE) {
  1236. blog(LOG_WARNING, "Tried to reset when already active");
  1237. return ret;
  1238. }
  1239. if (ret == OBS_VIDEO_SUCCESS) {
  1240. ResizePreview(ovi.base_width, ovi.base_height);
  1241. if (program)
  1242. ResizeProgram(ovi.base_width, ovi.base_height);
  1243. const float sdr_white_level = (float)config_get_uint(activeConfiguration, "Video", "SdrWhiteLevel");
  1244. const float hdr_nominal_peak_level =
  1245. (float)config_get_uint(activeConfiguration, "Video", "HdrNominalPeakLevel");
  1246. obs_set_video_levels(sdr_white_level, hdr_nominal_peak_level);
  1247. OBSBasicStats::InitializeValues();
  1248. OBSProjector::UpdateMultiviewProjectors();
  1249. bool canMigrate = usingAbsoluteCoordinates ||
  1250. (migrationBaseResolution && (migrationBaseResolution->first != ovi.base_width ||
  1251. migrationBaseResolution->second != ovi.base_height));
  1252. ui->actionRemigrateSceneCollection->setEnabled(canMigrate);
  1253. emit CanvasResized(ovi.base_width, ovi.base_height);
  1254. emit OutputResized(ovi.output_width, ovi.output_height);
  1255. }
  1256. return ret;
  1257. }
  1258. bool OBSBasic::ResetAudio()
  1259. {
  1260. ProfileScope("OBSBasic::ResetAudio");
  1261. struct obs_audio_info2 ai = {};
  1262. ai.samples_per_sec = config_get_uint(activeConfiguration, "Audio", "SampleRate");
  1263. const char *channelSetupStr = config_get_string(activeConfiguration, "Audio", "ChannelSetup");
  1264. if (strcmp(channelSetupStr, "Mono") == 0)
  1265. ai.speakers = SPEAKERS_MONO;
  1266. else if (strcmp(channelSetupStr, "2.1") == 0)
  1267. ai.speakers = SPEAKERS_2POINT1;
  1268. else if (strcmp(channelSetupStr, "4.0") == 0)
  1269. ai.speakers = SPEAKERS_4POINT0;
  1270. else if (strcmp(channelSetupStr, "4.1") == 0)
  1271. ai.speakers = SPEAKERS_4POINT1;
  1272. else if (strcmp(channelSetupStr, "5.1") == 0)
  1273. ai.speakers = SPEAKERS_5POINT1;
  1274. else if (strcmp(channelSetupStr, "7.1") == 0)
  1275. ai.speakers = SPEAKERS_7POINT1;
  1276. else
  1277. ai.speakers = SPEAKERS_STEREO;
  1278. bool lowLatencyAudioBuffering = config_get_bool(App()->GetUserConfig(), "Audio", "LowLatencyAudioBuffering");
  1279. if (lowLatencyAudioBuffering) {
  1280. ai.max_buffering_ms = 20;
  1281. ai.fixed_buffering = true;
  1282. }
  1283. return obs_reset_audio2(&ai);
  1284. }
  1285. void OBSBasic::closeEvent(QCloseEvent *event)
  1286. {
  1287. /* Wait for multitrack video stream to start/finish processing in the background */
  1288. if (setupStreamingGuard.valid() &&
  1289. setupStreamingGuard.wait_for(std::chrono::seconds{0}) != std::future_status::ready) {
  1290. QTimer::singleShot(1000, this, &OBSBasic::close);
  1291. event->ignore();
  1292. return;
  1293. }
  1294. /* Do not close window if inside of a temporary event loop because we
  1295. * could be inside of an Auth::LoadUI call. Keep trying once per
  1296. * second until we've exit any known sub-loops. */
  1297. if (os_atomic_load_long(&insideEventLoop) != 0) {
  1298. QTimer::singleShot(1000, this, &OBSBasic::close);
  1299. event->ignore();
  1300. return;
  1301. }
  1302. #ifdef YOUTUBE_ENABLED
  1303. /* Also don't close the window if the youtube stream check is active */
  1304. if (youtubeStreamCheckThread) {
  1305. QTimer::singleShot(1000, this, &OBSBasic::close);
  1306. event->ignore();
  1307. return;
  1308. }
  1309. #endif
  1310. if (isVisible())
  1311. config_set_string(App()->GetUserConfig(), "BasicWindow", "geometry",
  1312. saveGeometry().toBase64().constData());
  1313. bool confirmOnExit = config_get_bool(App()->GetUserConfig(), "General", "ConfirmOnExit");
  1314. if (confirmOnExit && outputHandler && outputHandler->Active() && !clearingFailed) {
  1315. SetShowing(true);
  1316. QMessageBox::StandardButton button =
  1317. OBSMessageBox::question(this, QTStr("ConfirmExit.Title"), QTStr("ConfirmExit.Text"));
  1318. if (button == QMessageBox::No) {
  1319. event->ignore();
  1320. restart = false;
  1321. return;
  1322. }
  1323. }
  1324. if (remux && !remux->close()) {
  1325. event->ignore();
  1326. restart = false;
  1327. return;
  1328. }
  1329. QWidget::closeEvent(event);
  1330. if (!event->isAccepted())
  1331. return;
  1332. blog(LOG_INFO, SHUTDOWN_SEPARATOR);
  1333. closing = true;
  1334. /* While closing, a resize event to OBSQTDisplay could be triggered.
  1335. * The graphics thread on macOS dispatches a lambda function to be
  1336. * executed asynchronously in the main thread. However, the display is
  1337. * sometimes deleted before the lambda function is actually executed.
  1338. * To avoid such a case, destroy displays earlier than others such as
  1339. * deleting browser docks. */
  1340. ui->preview->DestroyDisplay();
  1341. if (program)
  1342. program->DestroyDisplay();
  1343. if (outputHandler->VirtualCamActive())
  1344. outputHandler->StopVirtualCam();
  1345. if (introCheckThread)
  1346. introCheckThread->wait();
  1347. if (whatsNewInitThread)
  1348. whatsNewInitThread->wait();
  1349. if (updateCheckThread)
  1350. updateCheckThread->wait();
  1351. if (logUploadThread)
  1352. logUploadThread->wait();
  1353. if (devicePropertiesThread && devicePropertiesThread->isRunning()) {
  1354. devicePropertiesThread->wait();
  1355. devicePropertiesThread.reset();
  1356. }
  1357. QApplication::sendPostedEvents(nullptr);
  1358. signalHandlers.clear();
  1359. Auth::Save();
  1360. SaveProjectNow();
  1361. auth.reset();
  1362. delete extraBrowsers;
  1363. config_set_string(App()->GetUserConfig(), "BasicWindow", "DockState", saveState().toBase64().constData());
  1364. #ifdef BROWSER_AVAILABLE
  1365. if (cef)
  1366. SaveExtraBrowserDocks();
  1367. ClearExtraBrowserDocks();
  1368. #endif
  1369. OnEvent(OBS_FRONTEND_EVENT_SCRIPTING_SHUTDOWN);
  1370. disableSaving++;
  1371. /* Clear all scene data (dialogs, widgets, widget sub-items, scenes,
  1372. * sources, etc) so that all references are released before shutdown */
  1373. ClearSceneData();
  1374. OnEvent(OBS_FRONTEND_EVENT_EXIT);
  1375. // Destroys the frontend API so plugins can't continue calling it
  1376. obs_frontend_set_callbacks_internal(nullptr);
  1377. api = nullptr;
  1378. QMetaObject::invokeMethod(App(), "quit", Qt::QueuedConnection);
  1379. }
  1380. bool OBSBasic::nativeEvent(const QByteArray &, void *message, qintptr *)
  1381. {
  1382. #ifdef _WIN32
  1383. const MSG &msg = *static_cast<MSG *>(message);
  1384. switch (msg.message) {
  1385. case WM_MOVE:
  1386. for (OBSQTDisplay *const display : findChildren<OBSQTDisplay *>()) {
  1387. display->OnMove();
  1388. }
  1389. break;
  1390. case WM_DISPLAYCHANGE:
  1391. for (OBSQTDisplay *const display : findChildren<OBSQTDisplay *>()) {
  1392. display->OnDisplayChange();
  1393. }
  1394. }
  1395. #else
  1396. UNUSED_PARAMETER(message);
  1397. #endif
  1398. return false;
  1399. }
  1400. void OBSBasic::changeEvent(QEvent *event)
  1401. {
  1402. if (event->type() == QEvent::WindowStateChange) {
  1403. QWindowStateChangeEvent *stateEvent = (QWindowStateChangeEvent *)event;
  1404. if (isMinimized()) {
  1405. if (trayIcon && trayIcon->isVisible() && sysTrayMinimizeToTray()) {
  1406. ToggleShowHide();
  1407. return;
  1408. }
  1409. if (previewEnabled)
  1410. EnablePreviewDisplay(false);
  1411. } else if (stateEvent->oldState() & Qt::WindowMinimized && isVisible()) {
  1412. if (previewEnabled)
  1413. EnablePreviewDisplay(true);
  1414. }
  1415. }
  1416. }
  1417. void OBSBasic::GetFPSCommon(uint32_t &num, uint32_t &den) const
  1418. {
  1419. const char *val = config_get_string(activeConfiguration, "Video", "FPSCommon");
  1420. if (strcmp(val, "10") == 0) {
  1421. num = 10;
  1422. den = 1;
  1423. } else if (strcmp(val, "20") == 0) {
  1424. num = 20;
  1425. den = 1;
  1426. } else if (strcmp(val, "24 NTSC") == 0) {
  1427. num = 24000;
  1428. den = 1001;
  1429. } else if (strcmp(val, "25 PAL") == 0) {
  1430. num = 25;
  1431. den = 1;
  1432. } else if (strcmp(val, "29.97") == 0) {
  1433. num = 30000;
  1434. den = 1001;
  1435. } else if (strcmp(val, "48") == 0) {
  1436. num = 48;
  1437. den = 1;
  1438. } else if (strcmp(val, "50 PAL") == 0) {
  1439. num = 50;
  1440. den = 1;
  1441. } else if (strcmp(val, "59.94") == 0) {
  1442. num = 60000;
  1443. den = 1001;
  1444. } else if (strcmp(val, "60") == 0) {
  1445. num = 60;
  1446. den = 1;
  1447. } else {
  1448. num = 30;
  1449. den = 1;
  1450. }
  1451. }
  1452. void OBSBasic::GetFPSInteger(uint32_t &num, uint32_t &den) const
  1453. {
  1454. num = (uint32_t)config_get_uint(activeConfiguration, "Video", "FPSInt");
  1455. den = 1;
  1456. }
  1457. void OBSBasic::GetFPSFraction(uint32_t &num, uint32_t &den) const
  1458. {
  1459. num = (uint32_t)config_get_uint(activeConfiguration, "Video", "FPSNum");
  1460. den = (uint32_t)config_get_uint(activeConfiguration, "Video", "FPSDen");
  1461. }
  1462. void OBSBasic::GetFPSNanoseconds(uint32_t &num, uint32_t &den) const
  1463. {
  1464. num = 1000000000;
  1465. den = (uint32_t)config_get_uint(activeConfiguration, "Video", "FPSNS");
  1466. }
  1467. void OBSBasic::GetConfigFPS(uint32_t &num, uint32_t &den) const
  1468. {
  1469. uint32_t type = config_get_uint(activeConfiguration, "Video", "FPSType");
  1470. if (type == 1) //"Integer"
  1471. GetFPSInteger(num, den);
  1472. else if (type == 2) //"Fraction"
  1473. GetFPSFraction(num, den);
  1474. /*
  1475. * else if (false) //"Nanoseconds", currently not implemented
  1476. * GetFPSNanoseconds(num, den);
  1477. */
  1478. else
  1479. GetFPSCommon(num, den);
  1480. }
  1481. config_t *OBSBasic::Config() const
  1482. {
  1483. return activeConfiguration;
  1484. }
  1485. void OBSBasic::UpdateEditMenu()
  1486. {
  1487. QModelIndexList items = GetAllSelectedSourceItems();
  1488. int totalCount = items.count();
  1489. size_t filter_count = 0;
  1490. if (totalCount == 1) {
  1491. OBSSceneItem sceneItem = ui->sources->Get(GetTopSelectedSourceItem());
  1492. OBSSource source = obs_sceneitem_get_source(sceneItem);
  1493. filter_count = obs_source_filter_count(source);
  1494. }
  1495. bool allowPastingDuplicate = !!clipboard.size();
  1496. for (size_t i = clipboard.size(); i > 0; i--) {
  1497. const size_t idx = i - 1;
  1498. OBSWeakSource &weak = clipboard[idx].weak_source;
  1499. if (obs_weak_source_expired(weak)) {
  1500. clipboard.erase(clipboard.begin() + idx);
  1501. continue;
  1502. }
  1503. OBSSourceAutoRelease strong = obs_weak_source_get_source(weak.Get());
  1504. if (allowPastingDuplicate && obs_source_get_output_flags(strong) & OBS_SOURCE_DO_NOT_DUPLICATE)
  1505. allowPastingDuplicate = false;
  1506. }
  1507. int videoCount = 0;
  1508. bool canTransformMultiple = false;
  1509. for (int i = 0; i < totalCount; i++) {
  1510. OBSSceneItem item = ui->sources->Get(items.value(i).row());
  1511. OBSSource source = obs_sceneitem_get_source(item);
  1512. const uint32_t flags = obs_source_get_output_flags(source);
  1513. const bool hasVideo = (flags & OBS_SOURCE_VIDEO) != 0;
  1514. if (hasVideo && !obs_sceneitem_locked(item))
  1515. canTransformMultiple = true;
  1516. if (hasVideo)
  1517. videoCount++;
  1518. }
  1519. const bool canTransformSingle = videoCount == 1 && totalCount == 1;
  1520. OBSSceneItem curItem = GetCurrentSceneItem();
  1521. bool locked = curItem && obs_sceneitem_locked(curItem);
  1522. ui->actionCopySource->setEnabled(totalCount > 0);
  1523. ui->actionEditTransform->setEnabled(canTransformSingle && !locked);
  1524. ui->actionCopyTransform->setEnabled(canTransformSingle);
  1525. ui->actionPasteTransform->setEnabled(canTransformMultiple && hasCopiedTransform && videoCount > 0);
  1526. ui->actionCopyFilters->setEnabled(filter_count > 0);
  1527. ui->actionPasteFilters->setEnabled(!obs_weak_source_expired(copyFiltersSource) && totalCount > 0);
  1528. ui->actionPasteRef->setEnabled(!!clipboard.size());
  1529. ui->actionPasteDup->setEnabled(allowPastingDuplicate);
  1530. ui->actionMoveUp->setEnabled(totalCount > 0);
  1531. ui->actionMoveDown->setEnabled(totalCount > 0);
  1532. ui->actionMoveToTop->setEnabled(totalCount > 0);
  1533. ui->actionMoveToBottom->setEnabled(totalCount > 0);
  1534. ui->actionResetTransform->setEnabled(canTransformMultiple);
  1535. ui->actionRotate90CW->setEnabled(canTransformMultiple);
  1536. ui->actionRotate90CCW->setEnabled(canTransformMultiple);
  1537. ui->actionRotate180->setEnabled(canTransformMultiple);
  1538. ui->actionFlipHorizontal->setEnabled(canTransformMultiple);
  1539. ui->actionFlipVertical->setEnabled(canTransformMultiple);
  1540. ui->actionFitToScreen->setEnabled(canTransformMultiple);
  1541. ui->actionStretchToScreen->setEnabled(canTransformMultiple);
  1542. ui->actionCenterToScreen->setEnabled(canTransformMultiple);
  1543. ui->actionVerticalCenter->setEnabled(canTransformMultiple);
  1544. ui->actionHorizontalCenter->setEnabled(canTransformMultiple);
  1545. }
  1546. void OBSBasic::UpdateTitleBar()
  1547. {
  1548. stringstream name;
  1549. const char *profile = config_get_string(App()->GetUserConfig(), "Basic", "Profile");
  1550. const char *sceneCollection = config_get_string(App()->GetUserConfig(), "Basic", "SceneCollection");
  1551. name << "OBS ";
  1552. if (previewProgramMode)
  1553. name << "Studio ";
  1554. name << App()->GetVersionString(false);
  1555. if (safe_mode)
  1556. name << " (" << Str("TitleBar.SafeMode") << ")";
  1557. if (App()->IsPortableMode())
  1558. name << " - " << Str("TitleBar.PortableMode");
  1559. name << " - " << Str("TitleBar.Profile") << ": " << profile;
  1560. name << " - " << Str("TitleBar.Scenes") << ": " << sceneCollection;
  1561. setWindowTitle(QT_UTF8(name.str().c_str()));
  1562. }
  1563. OBSBasic *OBSBasic::Get()
  1564. {
  1565. return reinterpret_cast<OBSBasic *>(App()->GetMainWindow());
  1566. }
  1567. void OBSBasic::UpdatePatronJson(const QString &text, const QString &error)
  1568. {
  1569. if (!error.isEmpty())
  1570. return;
  1571. patronJson = QT_TO_UTF8(text);
  1572. }
  1573. void OBSBasic::SetDisplayAffinity(QWindow *window)
  1574. {
  1575. if (!SetDisplayAffinitySupported())
  1576. return;
  1577. bool hideFromCapture = config_get_bool(App()->GetUserConfig(), "BasicWindow", "HideOBSWindowsFromCapture");
  1578. // Don't hide projectors, those are designed to be visible / captured
  1579. if (window->property("isOBSProjectorWindow") == true)
  1580. return;
  1581. #ifdef _WIN32
  1582. HWND hwnd = (HWND)window->winId();
  1583. DWORD curAffinity;
  1584. if (GetWindowDisplayAffinity(hwnd, &curAffinity)) {
  1585. if (hideFromCapture && curAffinity != WDA_EXCLUDEFROMCAPTURE)
  1586. SetWindowDisplayAffinity(hwnd, WDA_EXCLUDEFROMCAPTURE);
  1587. else if (!hideFromCapture && curAffinity != WDA_NONE)
  1588. SetWindowDisplayAffinity(hwnd, WDA_NONE);
  1589. }
  1590. #else
  1591. // TODO: Implement for other platforms if possible. Don't forget to
  1592. // implement SetDisplayAffinitySupported too!
  1593. UNUSED_PARAMETER(hideFromCapture);
  1594. #endif
  1595. }
  1596. void OBSBasic::OnEvent(enum obs_frontend_event event)
  1597. {
  1598. if (api)
  1599. api->on_event(event);
  1600. }
  1601. OBSPromptResult OBSBasic::PromptForName(const OBSPromptRequest &request, const OBSPromptCallback &callback)
  1602. {
  1603. OBSPromptResult result;
  1604. for (;;) {
  1605. result.success = false;
  1606. if (request.withOption && !request.optionPrompt.empty()) {
  1607. result.optionValue = request.optionValue;
  1608. result.success = NameDialog::AskForNameWithOption(
  1609. this, request.title.c_str(), request.prompt.c_str(), result.promptValue,
  1610. request.optionPrompt.c_str(), result.optionValue,
  1611. (request.promptValue.empty() ? nullptr : request.promptValue.c_str()));
  1612. } else {
  1613. result.success = NameDialog::AskForName(
  1614. this, request.title.c_str(), request.prompt.c_str(), result.promptValue,
  1615. (request.promptValue.empty() ? nullptr : request.promptValue.c_str()));
  1616. }
  1617. if (!result.success) {
  1618. break;
  1619. }
  1620. if (result.promptValue.empty()) {
  1621. OBSMessageBox::warning(this, QTStr("NoNameEntered.Title"), QTStr("NoNameEntered.Text"));
  1622. continue;
  1623. }
  1624. if (!callback(result)) {
  1625. OBSMessageBox::warning(this, QTStr("NameExists.Title"), QTStr("NameExists.Text"));
  1626. continue;
  1627. }
  1628. break;
  1629. }
  1630. return result;
  1631. }