UI: Add an option to enable autoplay globally

This commit is contained in:
Tim Ledbetter
2024-09-22 23:12:36 +01:00
committed by Tim Ledbetter
parent 973f774e56
commit 63632159ce
18 changed files with 98 additions and 0 deletions

View File

@@ -103,6 +103,12 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, IsPopupWindow
});
});
QObject::connect(Settings::the(), &Settings::enable_autoplay_changed, this, [this](bool enable) {
for_each_tab([enable](auto& tab) {
tab.set_enable_autoplay(enable);
});
});
QObject::connect(Settings::the(), &Settings::preferred_languages_changed, this, [this](QStringList languages) {
Vector<String> preferred_languages;
preferred_languages.ensure_capacity(languages.length());
@@ -818,6 +824,7 @@ void BrowserWindow::initialize_tab(Tab* tab)
tab->set_preferred_languages(preferred_languages);
tab->set_navigator_compatibility_mode(navigator_compatibility_mode());
tab->set_enable_do_not_track(Settings::the()->enable_do_not_track());
tab->set_enable_autoplay(WebView::Application::web_content_options().enable_autoplay == WebView::EnableAutoplay::Yes || Settings::the()->enable_autoplay());
tab->view().set_preferred_color_scheme(m_preferred_color_scheme);
}