Skip to content

Truly independent web browser

LibWebView+UI/Qt: Add advanced settings for vertical tab delay times

Timothy Flynn56c86b5f46c5
diff --git a/Libraries/LibWebView/Settings.cpp b/Libraries/LibWebView/Settings.cpp
index 0f176071926..84028e2644a 100644
--- a/Libraries/LibWebView/Settings.cpp
+++ b/Libraries/LibWebView/Settings.cpp
@@ -133,6 +133,22 @@ static auto const& CONFIG_VARIABLE_DEFINITIONS = *new Array<ConfigVariableDefini
.default_value = true,
.array_element_type = {},
},
+ {
+ .id = ConfigVariableID::VerticalTabsHoverExpandDelay,
+ .name = "ui.tabs.vertical_tabs_hover_expand_delay_ms"sv,
+ .title = "Vertical tab hover expansion delay"sv,
+ .description = "Delay in milliseconds before collapsed vertical tabs begin expanding on hover. Set to 0 to expand immediately."sv,
+ .default_value = 100,
+ .array_element_type = {},
+ },
+ {
+ .id = ConfigVariableID::VerticalTabsHoverExpandAnimationDuration,
+ .name = "ui.tabs.vertical_tabs_hover_expand_animation_duration_ms"sv,
+ .title = "Vertical tab hover expansion animation duration"sv,
+ .description = "Duration in milliseconds of the vertical tab hover expansion animation. Set to 0 to disable the animation."sv,
+ .default_value = 100,
+ .array_element_type = {},
+ },
{
.id = ConfigVariableID::MaximumConnectionsPerDownload,
.name = "downloads.maximum_connections_per_download"sv,
@@ -236,6 +252,11 @@ static bool config_variable_value_is_valid(ConfigVariableDefinition const& varia
if (!json_value_matches_type(value, variable.default_value.type()))
return false;
+ if (variable.id == ConfigVariableID::VerticalTabsHoverExpandDelay || variable.id == ConfigVariableID::VerticalTabsHoverExpandAnimationDuration) {
+ auto milliseconds = value.get_int();
+ return milliseconds.has_value() && *milliseconds >= 0 && value.get_double_with_precision_loss().value() == *milliseconds;
+ }
+
if (variable.default_value.is_array() && variable.array_element_type.has_value())
return json_array_contains_only_type(value.as_array(), *variable.array_element_type);
diff --git a/Libraries/LibWebView/Settings.h b/Libraries/LibWebView/Settings.h
index 9b66d11b556..97f872769df 100644
--- a/Libraries/LibWebView/Settings.h
+++ b/Libraries/LibWebView/Settings.h
@@ -87,6 +87,8 @@ enum class ConfigVariableID : u8 {
ShowAdvancedDebugMenu,
ShowTabPerformanceMonitor,
UseClientSideWindowDecorations,
+ VerticalTabsHoverExpandDelay,
+ VerticalTabsHoverExpandAnimationDuration,
MaximumConnectionsPerDownload,
SplitDownloadsWithoutValidators,
RestartStalledConnections,
diff --git a/Libraries/LibWebView/WebUI/SettingsUI.cpp b/Libraries/LibWebView/WebUI/SettingsUI.cpp
index c6a9ba86591..77113229192 100644
--- a/Libraries/LibWebView/WebUI/SettingsUI.cpp
+++ b/Libraries/LibWebView/WebUI/SettingsUI.cpp
@@ -43,6 +43,8 @@ static bool should_show_config_variable(ConfigVariableID id)
{
if (id == ConfigVariableID::UseClientSideWindowDecorations)
return Application::the().supports_client_side_window_decorations();
+ if (id == ConfigVariableID::VerticalTabsHoverExpandDelay || id == ConfigVariableID::VerticalTabsHoverExpandAnimationDuration)
+ return Application::the().supports_vertical_tabs();
return true;
}
diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cpp
index 535ea374ec9..02b607b65d0 100644
--- a/UI/Qt/TabBar.cpp
+++ b/UI/Qt/TabBar.cpp
@@ -80,8 +80,6 @@ static constexpr qreal HORIZONTAL_TAB_CARD_SHAPE_HORIZONTAL_INSET = 4.0;
static constexpr int TAB_CARD_SHAPE_VERTICAL_INSET = 3;
static constexpr int HORIZONTAL_NEW_TAB_BUTTON_SHAPE_SIZE = 32;
static constexpr int TAB_CONTENT_HORIZONTAL_INSET = 8;
-static constexpr int VERTICAL_TABS_HOVER_EXPAND_DELAY_MS = 100;
-static constexpr int VERTICAL_TABS_HOVER_EXPAND_ANIMATION_DURATION_MS = 100;
static constexpr int VERTICAL_TABS_HOVER_COLLAPSE_POLL_INTERVAL_MS = 250;
static constexpr int TAB_PREVIEW_HOVER_DELAY_MS = 350;
static constexpr int TAB_PREVIEW_THUMBNAIL_WIDTH = 320;
@@ -1605,14 +1603,12 @@ TabWidget::TabWidget(QWidget* parent)
m_vertical_tabs_hover_expand_timer = new QTimer(this);
m_vertical_tabs_hover_expand_timer->setSingleShot(true);
m_vertical_tabs_hover_expand_timer->setTimerType(Qt::PreciseTimer);
- m_vertical_tabs_hover_expand_timer->setInterval(VERTICAL_TABS_HOVER_EXPAND_DELAY_MS);
connect(m_vertical_tabs_hover_expand_timer, &QTimer::timeout, this, [this]() {
if (cursor_is_over_vertical_tabs())
set_vertical_tabs_hover_expanded(true);
});
m_vertical_tabs_hover_expand_animation = new QVariantAnimation(this);
- m_vertical_tabs_hover_expand_animation->setDuration(VERTICAL_TABS_HOVER_EXPAND_ANIMATION_DURATION_MS);
m_vertical_tabs_hover_expand_animation->setEasingCurve(QEasingCurve::OutCubic);
m_vertical_tabs_hover_expand_animation->setStartValue(0.0);
m_vertical_tabs_hover_expand_animation->setEndValue(1.0);
@@ -1938,8 +1934,10 @@ bool TabWidget::eventFilter(QObject* watched, QEvent* event)
if (is_vertical_tabs_hover_target) {
if (event->type() == QEvent::Enter) {
- if (can_expand_vertical_tabs_on_hover() && !m_vertical_tabs_hover_expanded && !m_vertical_tabs_hover_expand_timer->isActive())
- m_vertical_tabs_hover_expand_timer->start();
+ if (can_expand_vertical_tabs_on_hover() && !m_vertical_tabs_hover_expanded && !m_vertical_tabs_hover_expand_timer->isActive()) {
+ auto delay = Application::settings().config_variable_as_integer<int>(WebView::ConfigVariableID::VerticalTabsHoverExpandDelay);
+ m_vertical_tabs_hover_expand_timer->start(delay);
+ }
} else if (event->type() == QEvent::Leave) {
defer_update_vertical_tabs_hover_expanded();
}
@@ -2449,7 +2447,12 @@ void TabWidget::set_vertical_tabs_hover_expanded(bool expanded)
m_vertical_tabs_hover_expanded = expanded;
m_vertical_tabs_hover_expand_animation->stop();
- m_vertical_tabs_hover_expand_progress = 0.0;
+
+ auto duration = m_vertical_tabs_hover_expanded
+ ? Application::settings().config_variable_as_integer<int>(WebView::ConfigVariableID::VerticalTabsHoverExpandAnimationDuration)
+ : 0;
+ m_vertical_tabs_hover_expand_progress = m_vertical_tabs_hover_expanded && duration == 0 ? 1.0 : 0.0;
+
if (m_vertical_tabs_hover_expanded)
m_vertical_tabs_hover_collapse_timer->start();
else
@@ -2458,8 +2461,10 @@ void TabWidget::set_vertical_tabs_hover_expanded(bool expanded)
update_vertical_tabs_hover_layout();
update_vertical_tabs_content_overlay();
- if (m_vertical_tabs_hover_expanded)
+ if (m_vertical_tabs_hover_expanded && duration > 0) {
+ m_vertical_tabs_hover_expand_animation->setDuration(duration);
m_vertical_tabs_hover_expand_animation->start();
+ }
}
void TabWidget::update_vertical_tabs_content_overlay()