mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb: Add motion preference
This adds a motion preference to the browser UI similar to the existing ones for color scheme and contrast. Both AppKit UI and Qt UI has this new preference. The auto value is currently the same as NoPreference, follow-ups can address wiring that up to the actual preference for the OS.
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <Ladybird/Utilities.h>
|
||||
#include <LibWeb/CSS/PreferredColorScheme.h>
|
||||
#include <LibWeb/CSS/PreferredContrast.h>
|
||||
#include <LibWeb/CSS/PreferredMotion.h>
|
||||
#include <LibWeb/Loader/UserAgent.h>
|
||||
#include <LibWebView/CookieJar.h>
|
||||
#include <LibWebView/UserAgent.h>
|
||||
@@ -278,6 +279,30 @@ BrowserWindow::BrowserWindow(Vector<URL::URL> const& initial_urls, WebView::Cook
|
||||
|
||||
auto_contrast->setChecked(true);
|
||||
|
||||
auto* motion_menu = view_menu->addMenu("&Motion");
|
||||
|
||||
auto* motion_group = new QActionGroup(this);
|
||||
|
||||
auto* auto_motion = new QAction("&Auto", this);
|
||||
auto_motion->setCheckable(true);
|
||||
motion_group->addAction(auto_motion);
|
||||
motion_menu->addAction(auto_motion);
|
||||
QObject::connect(auto_motion, &QAction::triggered, this, &BrowserWindow::enable_auto_motion);
|
||||
|
||||
auto* reduce_motion = new QAction("&Reduce", this);
|
||||
reduce_motion->setCheckable(true);
|
||||
motion_group->addAction(reduce_motion);
|
||||
motion_menu->addAction(reduce_motion);
|
||||
QObject::connect(reduce_motion, &QAction::triggered, this, &BrowserWindow::enable_reduce_motion);
|
||||
|
||||
auto* no_preference_motion = new QAction("&No Preference", this);
|
||||
no_preference_motion->setCheckable(true);
|
||||
motion_group->addAction(no_preference_motion);
|
||||
motion_menu->addAction(no_preference_motion);
|
||||
QObject::connect(no_preference_motion, &QAction::triggered, this, &BrowserWindow::enable_no_preference_motion);
|
||||
|
||||
auto_motion->setChecked(true);
|
||||
|
||||
auto* show_menubar = new QAction("Show &Menubar", this);
|
||||
show_menubar->setCheckable(true);
|
||||
show_menubar->setChecked(Settings::the()->show_menubar());
|
||||
@@ -975,6 +1000,27 @@ void BrowserWindow::enable_no_preference_contrast()
|
||||
});
|
||||
}
|
||||
|
||||
void BrowserWindow::enable_auto_motion()
|
||||
{
|
||||
for_each_tab([](auto& tab) {
|
||||
tab.view().set_preferred_motion(Web::CSS::PreferredMotion::Auto);
|
||||
});
|
||||
}
|
||||
|
||||
void BrowserWindow::enable_no_preference_motion()
|
||||
{
|
||||
for_each_tab([](auto& tab) {
|
||||
tab.view().set_preferred_motion(Web::CSS::PreferredMotion::NoPreference);
|
||||
});
|
||||
}
|
||||
|
||||
void BrowserWindow::enable_reduce_motion()
|
||||
{
|
||||
for_each_tab([](auto& tab) {
|
||||
tab.view().set_preferred_motion(Web::CSS::PreferredMotion::Reduce);
|
||||
});
|
||||
}
|
||||
|
||||
void BrowserWindow::zoom_in()
|
||||
{
|
||||
if (!m_current_tab)
|
||||
|
||||
Reference in New Issue
Block a user