Truly independent web browser
UI/Qt: Show which tabs are using the microphone
Luke Wilde3b98705c5abc
diff --git a/Documentation/UI/QuietDesign.md b/Documentation/UI/QuietDesign.mdindex f16e2a8a2f2..e51d8bb78ac 100644--- a/Documentation/UI/QuietDesign.md+++ b/Documentation/UI/QuietDesign.md@@ -97,9 +97,9 @@ All sizes are in logical pixels.| Active tab | 30 px tall | 8 px top radius plus an 8 px inverted "foot" on each side where it joins the toolbar. 5 px of strip shows above it. Its contents are vertically centered in it, which puts them on the shared center line. || End insets | Favicon 7 px from the left edge; × glyph 11 px from the right edge | Rule: each end item is as far from the tab's side as it is from the tab's top (the 16 px favicon sits 7 px down, the 8 px × glyph 11 px down). Padding: active 0 6 px 0 7 px; inactive 3 px inset + 0 3 px 0 4 px, so favicons and × never move when a tab becomes active. || Favicon to title | 8 px | |-| Close button | 18 px hover square, 7 px × (14 px glyph box); click area extends to the full tab height | The × is always visible on every tab except pinned tabs, in `muted`; its hover square appears on hover. Indicators like the speaker sit to its left. |+| Close button | 18 px hover square, 7 px × (14 px glyph box); click area extends to the full tab height | The × is always visible on every tab except pinned tabs, in `muted`; its hover square appears on hover. Indicators like the speaker and the microphone sit to its left. || Tab width | 20 to 232 px | Tabs shrink until only the favicon is left, giving up their padding below 32 px, then the strip scrolls. A tab too narrow for its favicon beside its × shows only the favicon; the active one shows its × in the favicon's place. |-| Pinned tab | 44 px wide | Favicon only, always first |+| Pinned tab | 44 px wide | Favicon only, always first. While the tab plays audio or uses the microphone, those indicators take the favicon's place. || New tab (+) | 26 px button, 14 px glyph | Follows the last tab directly, 8 px after it (just clear of the active tab's foot), centered on the tab row; with few tabs it does not move to the end of the strip. Click area at least 32 px. || Separators | 1 × 16 px | Between inactive tabs only, hidden next to hovered or active tabs |@@ -131,7 +131,7 @@ All sizes are in logical pixels.|---|---|| Sidebar width | 236 px || Tab rows | 30 px, 6 px radius. Selected: toolbar color with a soft shadow in light; white 15% fill only in dark and private, with no ring: on the dark sidebar the fill is enough, and stacked outlines (Ladybird button, focused field, row) make the column busy. The × on each row is lighter at rest (`#9C9CA3` light, `#7A7A81` dark) and takes the `muted` color on the hovered and selected rows, so a full list does not draw a dark stripe down the sidebar. It is always there; only its tone changes. |-| Collapsed rail | 52 px. Tiles are 36 × 32 with the favicon centered. Badges sit on the favicon's corners, 18 px round on a toolbar-colored backing with a hairline ring: × top left (on hover only), speaker bottom right (while playing or muted). Both are buttons, and opposite corners keep them apart. |+| Collapsed rail | 52 px. Tiles are 36 × 32 with the favicon centered. Badges sit on the favicon's corners, 18 px round on a toolbar-colored backing with a hairline ring: × top left (on hover only), speaker bottom right (while playing or muted), microphone bottom left (while in use). The × and the speaker are buttons, and opposite corners keep them apart. The microphone is not a button; it sits 2 px from the speaker and touches the × while that shows on hover. || Header | Traffic lights, Ladybird button, all tabs, then empty space, then the hide-sidebar toggle at the sidebar's right edge. With the sidebar collapsed, the toolbar starts the same way: traffic lights, Ladybird button, all tabs, show-sidebar toggle. || Background | `sidebar` token: the strip color in light, the toolbar color in dark and private. The page must never sit directly against near-black chrome. || Sidebar on the right | Only the sidebar moves: tab list, rail and the hide/show toggle, which sits at the sidebar's inner edge (facing the page). The traffic lights, Ladybird button and All tabs button stay top left, at the start of the toolbar row, exactly as in collapsed mode. Rail badges keep their corners (× top left, speaker bottom right). Dragging a tab out of the sidebar goes sideways toward the page. On Windows, the sidebar header holds the minimize, maximize and close buttons, with the toggle to their left. Settings → Appearance → Layout shows "Sidebar on: Left / Right" below the layout cards, only while Tabs on the side is selected. |@@ -421,6 +421,7 @@ Don't invent new shadows. Pick a level.- Warning pills ("Not secure", "Not wikipedia.org") use `warning-fill` with `warning-ink`text and icon.- The zoom chip is a neutral chip shown only while the zoom isn't 100%.+- The location and microphone chips are neutral chips with a 16 px icon before their words.### Focus@@ -440,9 +441,10 @@ Don't invent new shadows. Pick a level.| Active | Joins the toolbar; title in full `text` color, weight 400 || Dragging | Stays in the strip with a Lift shadow, flat (no tilt), slides sideways only || Loading | Accent ring (20 px, 1.5 px line) around the favicon, reaching only 2 px past the favicon slot so the title keeps about 6 px of room and nothing moves. The favicon shrinks to 10 px inside the ring so square icons never touch it. |-| Playing audio / muted | 20 px speaker button left of the close slot; click to mute. Muted keeps the struck speaker. In sidebar rows (13 px titles) the speaker is a 16 px glyph in a 22 px button, in the `icon` color, so it matches the × in weight. In the collapsed sidebar rail, the speaker is an 18 px round badge with a 13 px glyph, overlapping the favicon's bottom-right corner by about 7 px, on an opaque toolbar-colored backing with a hairline ring; it is clickable. |+| Playing audio / muted | 20 px speaker button left of the close slot, shown while the tab was heard in the last 3.5 s; click to mute. Muted keeps the struck speaker. In sidebar rows (13 px titles) the speaker is a 16 px glyph in a 22 px button, in the `icon` color, so it matches the × in weight. In the collapsed sidebar rail, the speaker is an 18 px round badge with a 13 px glyph, overlapping the favicon's bottom-right corner by about 7 px, on an opaque toolbar-colored backing with a hairline ring; it is clickable. |+| Using the microphone | A 14 px microphone glyph left of the speaker, or in the speaker's slot without it, in the speaker's color, shown while the page holds a capture stream and for 3 s after, whether or not the stream carries sound. It is not a button: a click on it goes to the tab, and its tooltip says "Using your microphone". In sidebar rows it is a 16 px glyph like the speaker. A tab too narrow for both shows only the microphone, so it never hides which tabs use the microphone. || Needs attention | A 7 px accent dot on the favicon's corner; clears on visit |-| Pinned | Favicon only, 44 px wide |+| Pinned | Favicon only, 44 px wide. The microphone and the speaker take the favicon's place, side by side and centered (14 + 20 px). || Crashed | Warning glyph replaces the favicon |### Address field@@ -458,6 +460,7 @@ Don't invent new shadows. Pick a level.| Bookmarked | Filled star in the `icon` color || Permission requested | The permission's icon replaces the site settings icon, on the accent tint || Zoomed | Zoom chip before the star |+| Using location / microphone | "Using your location" chip before the zoom chip, and "Using your microphone" chip before that. Each says its words for 4 s after it appears, on its own timer, then shrinks to its 30 px icon. While the field has no room for a chip's words, it shows only its icon, keeping its tooltip and accessible name; resizing never restarts the timers. The field asks for room for the icons only, so a chip's words never widen the window. A click opens site settings. || Blank tab | Empty and focused, placeholder "Search or enter address", no site settings icon or star |There is no content-blocker shield in the field. Content blocking is controlled from sitediff --git a/UI/Qt/BrowserWindow.cpp b/UI/Qt/BrowserWindow.cppindex 4b007b15f41..6ceb00c5616 100644--- a/UI/Qt/BrowserWindow.cpp+++ b/UI/Qt/BrowserWindow.cpp@@ -924,6 +924,9 @@ void BrowserWindow::initialize_tab(Tab* tab)QObject::connect(tab, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);QObject::connect(tab, &Tab::favicon_changed, this, &BrowserWindow::tab_favicon_changed);QObject::connect(tab, &Tab::playing_audio_indicator_changed, this, &BrowserWindow::tab_playing_audio_indicator_changed);+ QObject::connect(tab, &Tab::microphone_in_use_changed, this, [this] {+ m_tabs_container->tab_bar()->update_microphone_indicators();+ });QObject::connect(tab, &Tab::loading_changed, this, [this] {m_tabs_container->tab_bar()->update_loading_ring_animation();});diff --git a/UI/Qt/ChromeStyle.cpp b/UI/Qt/ChromeStyle.cppindex d0c1c1b2636..31d708a8b04 100644--- a/UI/Qt/ChromeStyle.cpp+++ b/UI/Qt/ChromeStyle.cpp@@ -599,7 +599,7 @@ QToolButton#LadybirdLocationZoomIndicator:pressed {{background: {16};}}-QToolButton#LadybirdLocationInUse {{+QToolButton#LadybirdInUseChip {{color: {13};background: {14};border: 0;@@ -608,11 +608,11 @@ QToolButton#LadybirdLocationInUse {{font-size: 12px;}}-QToolButton#LadybirdLocationInUse:hover {{+QToolButton#LadybirdInUseChip:hover {{background: {15};}}-QToolButton#LadybirdLocationInUse:pressed {{+QToolButton#LadybirdInUseChip:pressed {{background: {16};}}@@ -2267,6 +2267,12 @@ void paint_control_frame(QPainter& painter, QAbstractButton const& button, Contrpainter.restore();}+void paint_tab_badge_frame(QPainter& painter, QWidget const& badge)+{+ auto const& palette = badge.window()->palette();+ paint_circular_control_frame(painter, badge.rect(), badge.devicePixelRatioF(), chrome_active_tab_surface(palette), Theme::chrome(palette).separator);+}+// A ring around a favicon, with an arc in the accent color going around it, to show that the page is loading. Every// ring follows the same clock, so the rings on screen turn in step.// NB: The radii are to the middle of the 1.5 px line, so the ring's outer edge is 0.75 px further out.diff --git a/UI/Qt/ChromeStyle.h b/UI/Qt/ChromeStyle.hindex 32b4657fd48..c40d0457d4e 100644--- a/UI/Qt/ChromeStyle.h+++ b/UI/Qt/ChromeStyle.h@@ -127,6 +127,8 @@ constexpr inline qreal CONTROL_FRAME_RADIUS = 6;// The colors of a button's frame in the button's current state, or nothing while it shows no frame.Optional<ControlFrameColors> control_frame_colors(QAbstractButton const&, ControlFrameStyle = ControlFrameStyle::InteractionOnly);void paint_control_frame(QPainter&, QAbstractButton const&, ControlFrameStyle = ControlFrameStyle::InteractionOnly);+// The frame of a badge over a collapsed sidebar's tab that is not a button, as a button's frame looks at rest.+void paint_tab_badge_frame(QPainter&, QWidget const&);void paint_focus_ring(QPainter&, QRectF const&, qreal radius);void paint_loading_ring(QPainter&, QPalette const&, QPointF center, LoadingRingSize, LoadingPhase = LoadingPhase::Receiving);diff --git a/UI/Qt/LocationEdit.cpp b/UI/Qt/LocationEdit.cppindex 693deba863b..68cb98e97fe 100644--- a/UI/Qt/LocationEdit.cpp+++ b/UI/Qt/LocationEdit.cpp@@ -189,9 +189,114 @@ static constexpr int LOCATION_PILL_HORIZONTAL_PADDING = 16;// The zoom chip is at least wide enough for any zoom level up to 999%, so it keeps its width as the level changes.static constexpr int LOCATION_ZOOM_CHIP_MIN_WIDTH = 54;static constexpr int LOCATION_ZOOM_CHIP_GAP = 3;-// The location chip says what it means at first, then shrinks to its icon.-static constexpr int LOCATION_IN_USE_CHIP_COLLAPSE_DELAY_MS = 4000;-static constexpr int LOCATION_IN_USE_CHIP_ICON_ONLY_WIDTH = 30;+static constexpr int IN_USE_CHIP_COLLAPSE_DELAY_MS = 4000;+static constexpr int IN_USE_CHIP_ICON_ONLY_WIDTH = 30;+static constexpr int IN_USE_CHIP_ICON_SIZE = 16;+static constexpr int IN_USE_CHIP_ICON_TEXT_GAP = 4;++// A chip that says the page is using something of the user's, such as their location. It says so in words at first,+// then shrinks to its icon. While the field has no room for its words, it shows only its icon, and its text stays its+// accessible name.+class InUseChip final : public QToolButton {+public:+ AK_ALLOC_WITH_KMALLOC;++ InUseChip(QWidget* parent, ChromeIcon icon, QString const& text, QString const& tool_tip)+ : QToolButton(parent)+ , m_icon(icon)+ , m_collapse_timer(new QTimer(this))+ {+ setObjectName("LadybirdInUseChip");+ setIconSize({ IN_USE_CHIP_ICON_SIZE, IN_USE_CHIP_ICON_SIZE });+ setText(text);+ setToolTip(tool_tip);+ setFixedHeight(LOCATION_PILL_HEIGHT);+ setAutoRaise(true);+ setFocusPolicy(Qt::NoFocus);+ setCursor(Qt::ArrowCursor);+ update_form();+ hide();++ m_collapse_timer->setSingleShot(true);+ m_collapse_timer->setInterval(IN_USE_CHIP_COLLAPSE_DELAY_MS);+ QObject::connect(m_collapse_timer, &QTimer::timeout, this, [this] {+ m_says_in_words = false;+ update_form();+ if (on_size_change)+ on_size_change();+ });+ }++ void set_in_use(bool in_use)+ {+ if (in_use == !isHidden())+ return;++ m_says_in_words = in_use;+ update_form();+ setVisible(in_use);+ if (in_use)+ m_collapse_timer->start();+ else+ m_collapse_timer->stop();++ if (on_size_change)+ on_size_change();+ }++ void set_words_fit(bool words_fit)+ {+ m_words_fit = words_fit;+ update_form();+ }++ // How much wider the chip would be, were it to say what it means in words where it now shows only its icon.+ int width_missing_for_words() const+ {+ if (isHidden() || !m_says_in_words)+ return 0;+ return width_in_words() - width();+ }++ // How much wider the chip is than its icon alone.+ int width_beyond_icon() const+ {+ if (isHidden())+ return 0;+ return width() - IN_USE_CHIP_ICON_ONLY_WIDTH;+ }++ void update_icon(QPalette const& palette)+ {+ setIcon(create_chrome_icon(m_icon, palette));+ }++ // Asks the field to make room for the chip as it shows, shrinks or hides.+ Function<void()> on_size_change;++private:+ int width_in_words() const+ {+ ensurePolished();+ return fontMetrics().horizontalAdvance(text()) + IN_USE_CHIP_ICON_SIZE + IN_USE_CHIP_ICON_TEXT_GAP + LOCATION_PILL_HORIZONTAL_PADDING;+ }++ void update_form()+ {+ if (m_says_in_words && m_words_fit) {+ setToolButtonStyle(Qt::ToolButtonTextBesideIcon);+ setFixedWidth(width_in_words());+ } else {+ setToolButtonStyle(Qt::ToolButtonIconOnly);+ setFixedWidth(IN_USE_CHIP_ICON_ONLY_WIDTH);+ }+ }++ ChromeIcon m_icon;+ QTimer* m_collapse_timer { nullptr };+ bool m_says_in_words { false };+ bool m_words_fit { true };+};LocationEdit::LocationEdit(QWidget* parent, WebView::IsPrivate is_private): NativeTextEditingLineEdit(parent)@@ -287,32 +392,21 @@ LocationEdit::LocationEdit(QWidget* parent, WebView::IsPrivate is_private)on_zoom_requested();});- m_location_in_use_button = new QToolButton(this);- m_location_in_use_button->setObjectName("LadybirdLocationInUse");- m_location_in_use_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);- m_location_in_use_button->setIconSize({ 16, 16 });- m_location_in_use_button->setText("Using your location");- m_location_in_use_button->setToolTip("This page is using your location");- m_location_in_use_button->setFixedHeight(LOCATION_PILL_HEIGHT);- m_location_in_use_button->setAutoRaise(true);- m_location_in_use_button->setFocusPolicy(Qt::NoFocus);- m_location_in_use_button->setCursor(Qt::ArrowCursor);- m_location_in_use_button->hide();- connect(m_location_in_use_button, &QToolButton::clicked, this, [this] {- if (on_site_settings_requested)- on_site_settings_requested();- });- m_location_in_use_collapse_timer = new QTimer(this);- m_location_in_use_collapse_timer->setSingleShot(true);- m_location_in_use_collapse_timer->setInterval(LOCATION_IN_USE_CHIP_COLLAPSE_DELAY_MS);- connect(m_location_in_use_collapse_timer, &QTimer::timeout, this, [this] {- m_location_in_use_button->setToolButtonStyle(Qt::ToolButtonIconOnly);- update_location_in_use_chip();- update_text_margins();- update_trailing_item_positions();- });+ m_location_in_use_chip = new InUseChip(this, ChromeIcon::Location, "Using your location", "This page is using your location");+ m_microphone_in_use_chip = new InUseChip(this, ChromeIcon::Microphone, "Using your microphone", "This page is using your microphone");+ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip }) {+ chip->on_size_change = [this] {+ update_text_margins();+ update_trailing_item_positions();+ };+ connect(chip, &QToolButton::clicked, this, [this] {+ if (on_site_settings_requested)+ on_site_settings_requested();+ });+ }+ update_in_use_chip_icons();- for (auto* button : { m_leading_icon_button, m_trailing_action_button, m_translate_button, m_zoom_indicator_button, m_location_in_use_button })+ for (auto* button : { m_leading_icon_button, m_trailing_action_button, m_translate_button, m_zoom_indicator_button, static_cast<QToolButton*>(m_location_in_use_chip), static_cast<QToolButton*>(m_microphone_in_use_chip) })button->installEventFilter(this);update_text_margins();@@ -926,9 +1020,49 @@ void LocationEdit::resizeEvent(QResizeEvent* event){QLineEdit::resizeEvent(event);+ update_text_margins();update_trailing_item_positions();}+// The field asks only for room for the chips' icons, as the chips fall back to them when their words don't fit, so a+// page using something of the user's never widens the window to fit those words.+QSize LocationEdit::sizeHint() const+{+ auto hint = NativeTextEditingLineEdit::sizeHint();+ hint.rwidth() -= in_use_chips_width_beyond_icons();+ return hint;+}++QSize LocationEdit::minimumSizeHint() const+{+ auto hint = NativeTextEditingLineEdit::minimumSizeHint();+ hint.rwidth() -= in_use_chips_width_beyond_icons();+ return hint;+}++int LocationEdit::in_use_chips_width_beyond_icons() const+{+ auto width = 0;+ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip }) {+ if (chip)+ width += chip->width_beyond_icon();+ }+ return width;+}++// The chips say what they mean in words while the field is as wide as its minimum would be with those words in it.+// NB: Resizing the field never restarts a chip's timer, so its words only ever show within its first few seconds.+void LocationEdit::fit_in_use_chips()+{+ auto margins = textMargins();+ auto width_for_words = NativeTextEditingLineEdit::minimumSizeHint().width() - margins.left() - margins.right() + m_text_leading_margin + trailing_text_margin();+ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip })+ width_for_words += chip->width_missing_for_words();++ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip })+ chip->set_words_fit(width() >= width_for_words);+}+// The "Not secure" pill is inset as far from the field's leading edge as from its top and bottom.static int leading_indicator_inset(QWidget const& field, QWidget const& indicator){@@ -964,13 +1098,18 @@ void LocationEdit::update_trailing_item_positions()m_zoom_indicator_button->move(items_x - LOCATION_ZOOM_CHIP_GAP - zoom_button_size.width(), zoom_y);m_zoom_indicator_button->raise();- // The location chip stands before the zoom chip, when there is one.- auto location_chip_x = items_x;+ // The location chip stands before the zoom chip, when there is one, and the microphone chip before the location+ // chip, when there is one.+ auto chip_x = items_x;if (!m_zoom_indicator_button->isHidden())- location_chip_x -= LOCATION_ZOOM_CHIP_GAP + zoom_button_size.width();- auto location_chip_size = m_location_in_use_button->size();- m_location_in_use_button->move(location_chip_x - LOCATION_ZOOM_CHIP_GAP - location_chip_size.width(), (height() - location_chip_size.height()) / 2);- m_location_in_use_button->raise();+ chip_x -= LOCATION_ZOOM_CHIP_GAP + zoom_button_size.width();+ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip }) {+ auto chip_size = chip->size();+ chip->move(chip_x - LOCATION_ZOOM_CHIP_GAP - chip_size.width(), (height() - chip_size.height()) / 2);+ chip->raise();+ if (!chip->isHidden())+ chip_x -= LOCATION_ZOOM_CHIP_GAP + chip_size.width();+ }m_trailing_action_button->raise();}@@ -981,6 +1120,8 @@ void LocationEdit::search_engine_settings_changed()void LocationEdit::update_text_margins(){+ if (m_location_in_use_chip && m_microphone_in_use_chip)+ fit_in_use_chips();setTextMargins(m_text_leading_margin, 0, trailing_text_margin(), 0);}@@ -994,8 +1135,10 @@ int LocationEdit::trailing_text_margin() constmargin += m_translate_button->width();if (m_zoom_indicator_button && !m_zoom_indicator_button->isHidden())margin += m_zoom_indicator_button->width() + LOCATION_ZOOM_CHIP_GAP;- if (m_location_in_use_button && !m_location_in_use_button->isHidden())- margin += m_location_in_use_button->width() + LOCATION_ZOOM_CHIP_GAP;+ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip }) {+ if (chip && !chip->isHidden())+ margin += chip->width() + LOCATION_ZOOM_CHIP_GAP;+ }return margin;}@@ -1010,7 +1153,7 @@ void LocationEdit::update_chrome_style()setStyleSheet(ChromeStyle::location_edit_style_sheet(Theme::chrome_palette(*this)));m_is_updating_chrome_style = false;update_zoom_indicator();- update_location_in_use_chip();+ update_in_use_chip_icons();}void LocationEdit::schedule_chrome_style_update()@@ -1162,35 +1305,20 @@ void LocationEdit::update_zoom_indicator()void LocationEdit::set_location_in_use(bool in_use){- if (in_use == !m_location_in_use_button->isHidden())- return;-- if (in_use) {- m_location_in_use_button->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);- update_location_in_use_chip();- m_location_in_use_button->show();- m_location_in_use_collapse_timer->start();- } else {- m_location_in_use_collapse_timer->stop();- m_location_in_use_button->hide();- }-- update_text_margins();- update_trailing_item_positions();+ m_location_in_use_chip->set_in_use(in_use);}-void LocationEdit::update_location_in_use_chip()+void LocationEdit::set_microphone_in_use(bool in_use){- if (!m_location_in_use_button)- return;+ m_microphone_in_use_chip->set_in_use(in_use);+}- m_location_in_use_button->setIcon(create_chrome_icon(ChromeIcon::Location, Theme::chrome_palette(*this)));- if (m_location_in_use_button->toolButtonStyle() == Qt::ToolButtonIconOnly) {- m_location_in_use_button->setFixedWidth(LOCATION_IN_USE_CHIP_ICON_ONLY_WIDTH);- return;+void LocationEdit::update_in_use_chip_icons()+{+ for (auto* chip : { m_location_in_use_chip, m_microphone_in_use_chip }) {+ if (chip)+ chip->update_icon(Theme::chrome_palette(*this));}- auto width = m_location_in_use_button->fontMetrics().horizontalAdvance(m_location_in_use_button->text()) + 16 + 4 + LOCATION_PILL_HORIZONTAL_PADDING;- m_location_in_use_button->setFixedWidth(width);}void LocationEdit::highlight_location()diff --git a/UI/Qt/LocationEdit.h b/UI/Qt/LocationEdit.hindex 2b7f0660715..21028a615ef 100644--- a/UI/Qt/LocationEdit.h+++ b/UI/Qt/LocationEdit.h@@ -24,13 +24,13 @@ class QGraphicsOpacityEffect;class QLabel;class QMouseEvent;class QResizeEvent;-class QTimer;class QToolButton;class QVariantAnimation;namespace Ladybird {class Autocomplete;+class InUseChip;class LocationEdit final: public NativeTextEditingLineEdit@@ -58,8 +58,9 @@ public:// The translate button stands in the field, before the bookmark star, while the page can be translated.void set_translate_action(QAction*);QWidget& translate_button() const;- // Shows, while the page uses the user's location, a chip that says so.+ // Shows, while the page uses the user's location or microphone, a chip that says so.void set_location_in_use(bool);+ void set_microphone_in_use(bool);Optional<URL::URL const&> url() const { return m_url; }void set_url(Optional<URL::URL>);@@ -102,19 +103,23 @@ private:virtual void native_text_editing_command_will_execute(Web::TextEditingCommand const&) override;virtual void mouseReleaseEvent(QMouseEvent* event) override;virtual void resizeEvent(QResizeEvent* event) override;+ virtual QSize sizeHint() const override;+ virtual QSize minimumSizeHint() const override;virtual void search_engine_settings_changed() override;void show_full_url_preserving_display_selection();int serialized_url_position_for_display_position(int) const;void update_text_margins();+ void fit_in_use_chips();+ int in_use_chips_width_beyond_icons() const;int trailing_text_margin() const;void update_trailing_item_positions();void update_chrome_style();void update_location_icon();void update_zoom_indicator();void update_translate_button();- void update_location_in_use_chip();+ void update_in_use_chip_icons();void update_focus_ring(qreal opacity);void set_field_hovered(bool);void schedule_chrome_style_update();@@ -145,8 +150,8 @@ private:QToolButton* m_zoom_indicator_button { nullptr };QGraphicsOpacityEffect* m_zoom_indicator_opacity { nullptr };QVariantAnimation* m_zoom_indicator_fade { nullptr };- QToolButton* m_location_in_use_button { nullptr };- QTimer* m_location_in_use_collapse_timer { nullptr };+ InUseChip* m_location_in_use_chip { nullptr };+ InUseChip* m_microphone_in_use_chip { nullptr };QLabel* m_completion_title { nullptr };QVariantAnimation* m_focus_ring_animation { nullptr };QGraphicsEffect* m_focus_ring_effect { nullptr };diff --git a/UI/Qt/Tab.cpp b/UI/Qt/Tab.cppindex cf122b064c2..f1bd0ef3038 100644--- a/UI/Qt/Tab.cpp+++ b/UI/Qt/Tab.cpp@@ -593,6 +593,8 @@ void Tab::initialize(Optional<WebView::CanonicalTraversable&> traversable)m_location_edit->set_location_in_use(visible);break;case WebView::TabIndicator::UsingMicrophone:+ m_location_edit->set_microphone_in_use(visible);+ emit microphone_in_use_changed();break;}};diff --git a/UI/Qt/Tab.h b/UI/Qt/Tab.hindex 2bfd8b5205d..78097b442cb 100644--- a/UI/Qt/Tab.h+++ b/UI/Qt/Tab.h@@ -189,6 +189,7 @@ signals:void title_changed(int id, QString const&);void favicon_changed(int id, QIcon const&);void playing_audio_indicator_changed(int id);+ void microphone_in_use_changed();void loading_changed();void performance_stats_changed();void loaded();diff --git a/UI/Qt/TabBar.cpp b/UI/Qt/TabBar.cppindex 400f89231fa..7c5be58a9ce 100644--- a/UI/Qt/TabBar.cpp+++ b/UI/Qt/TabBar.cpp@@ -416,10 +416,11 @@ static bool horizontal_tab_has_room_for_favicon_before(qreal close_button_left,}// The selected tab, once it is too narrow for its favicon beside its close button, shows the close button in its-// favicon's place, so that it can still be closed with a click. A tab playing audio shows its speaker there instead.-static bool horizontal_tab_close_button_replaces_favicon(QRectF const& content_rect, QWidget const& close_button, bool is_selected, bool has_audio_button)+// favicon's place, so that it can still be closed with a click. A tab playing audio or using the microphone shows that+// there instead.+static bool horizontal_tab_close_button_replaces_favicon(QRectF const& content_rect, QWidget const& close_button, bool is_selected, bool has_media_indicator){- if (!is_selected || has_audio_button)+ if (!is_selected || has_media_indicator)return false;auto has_room_for_both = horizontal_tab_has_room_for_favicon_before(content_rect.right() - close_button.width(), content_rect.left());return !has_room_for_both && content_rect.width() >= close_button.width();@@ -1148,6 +1149,19 @@ void TabBar::resizeEvent(QResizeEvent* event)update_tab_button_geometry();}+// A tab moved between windows takes its microphone indicator with it.+void TabBar::tabInserted(int index)+{+ QTabBar::tabInserted(index);+ update_microphone_indicators();+}++void TabBar::tabRemoved(int index)+{+ QTabBar::tabRemoved(index);+ update_microphone_indicators();+}+void TabBar::tabLayoutChange(){QTabBar::tabLayoutChange();@@ -1427,8 +1441,8 @@ void TabBar::paintEvent(QPaintEvent*)};if (is_collapsed_vertical || is_pinned_tile) {- // The audio button takes the favicon's place on a pinned tile.- if (is_pinned_tile && tabButton(index, QTabBar::LeftSide))+ // The speaker and the microphone take the favicon's place on a pinned tile.+ if (is_pinned_tile && (tabButton(index, QTabBar::LeftSide) || microphone_indicator(index)))continue;auto icon_center = shape_rect.center();@@ -1452,9 +1466,11 @@ void TabBar::paintEvent(QPaintEvent*)auto contents_rect = is_vertical? shape_rect.toAlignedRect().adjusted(VERTICAL_TAB_CONTENT_LEADING_INSET, 0, -TAB_CONTENT_HORIZONTAL_INSET, 0): horizontal_tab_contents_rect(index, layout_rect).toAlignedRect();- // The speaker sits after the title, with the close button.- if (auto* left_button = tabButton(index, QTabBar::LeftSide); left_button && left_button->isVisible())- contents_rect.setRight(min(contents_rect.right(), left_button->geometry().left() - 6));+ // The microphone and the speaker sit after the title, with the close button.+ for (auto* indicator : { static_cast<QWidget*>(microphone_indicator(index)), tabButton(index, QTabBar::LeftSide) }) {+ if (indicator && indicator->isVisible())+ contents_rect.setRight(min(contents_rect.right(), indicator->geometry().left() - 6));+ }// NB: A horizontal tab keeps its close button's slot whether the button shows or not, so that the title ends at// the same place either way.if (auto* right_button = tabButton(index, QTabBar::RightSide)) {@@ -1469,7 +1485,7 @@ void TabBar::paintEvent(QPaintEvent*)if (contents_rect.width() < TAB_ICON_SIZE)continue;if (auto* close_button = tabButton(index, QTabBar::RightSide); close_button && close_button->isVisible()- && horizontal_tab_close_button_replaces_favicon(horizontal_tab_contents_rect(index, layout_rect), *close_button, is_selected, tabButton(index, QTabBar::LeftSide))) {+ && horizontal_tab_close_button_replaces_favicon(horizontal_tab_contents_rect(index, layout_rect), *close_button, is_selected, tabButton(index, QTabBar::LeftSide) || microphone_indicator(index))) {continue;}QRect icon_rect {@@ -1658,9 +1674,11 @@ void TabBar::dropEvent(QDropEvent* event)bool TabBar::eventFilter(QObject* watched, QEvent* event){+ // NB: Qt drops the pointer's moves over the microphone indicator rather than passing them on to the tab bar, so the+ // indicator keeps its tab hovered like the buttons do.auto hovered_tab_for_button = [this](QObject* button) {for (int index = 0; index < count(); ++index) {- if (tabButton(index, QTabBar::LeftSide) == button || tabButton(index, QTabBar::RightSide) == button)+ if (tabButton(index, QTabBar::LeftSide) == button || tabButton(index, QTabBar::RightSide) == button || microphone_indicator(index) == button)return index;}return -1;@@ -2582,6 +2600,39 @@ void TabBar::update_loading_ring_animation()update();}+void TabBar::update_microphone_indicators()+{+ HashTable<Tab const*> capturing_tabs;+ for (int index = 0; index < count(); ++index) {+ if (auto* tab = m_tab_widget ? m_tab_widget->tab(index) : nullptr; tab && tab->is_loaded() && tab->view().tab_indicator_visible(WebView::TabIndicator::UsingMicrophone))+ capturing_tabs.set(tab);+ }++ m_microphone_indicators.remove_all_matching([&](Tab const* tab, TabMicrophoneIndicator* indicator) {+ if (capturing_tabs.contains(tab))+ return false;+ indicator->hide();+ indicator->deleteLater();+ return true;+ });++ for (auto const* tab : capturing_tabs) {+ if (!m_microphone_indicators.contains(tab))+ m_microphone_indicators.set(tab, new TabMicrophoneIndicator(this));+ }++ update_tab_button_geometry();+ update();+}++TabMicrophoneIndicator* TabBar::microphone_indicator(int index) const+{+ auto* tab = m_tab_widget ? m_tab_widget->tab(index) : nullptr;+ if (!tab)+ return nullptr;+ return m_microphone_indicators.get(tab).value_or(nullptr);+}+void TabBar::schedule_tab_preview(int index){if (!m_tab_preview_timer || !m_tab_preview_popup)@@ -2945,15 +2996,24 @@ void TabBar::update_tab_button_geometry()button->installEventFilter(this);if (auto* tab_bar_button = qobject_cast<TabBarButton*>(button))tab_bar_button->set_placement(placement);+ else if (auto* microphone = qobject_cast<TabMicrophoneIndicator*>(button))+ microphone->set_placement(placement);};- // The audio button takes the favicon's place, in the middle of a pinned tile's card.- auto center_button_in = [](QWidget* button, QRectF const& card) {- auto button_size = button->size().isEmpty() ? button->sizeHint() : button->size();- auto center = card.center();- QRect button_geometry { qRound(center.x() - (button_size.width() / 2.0)), qRound(center.y() - (button_size.height() / 2.0)), button_size.width(), button_size.height() };- if (button->geometry() != button_geometry)- button->setGeometry(button_geometry);+ // The speaker and the microphone take the favicon's place, side by side in the middle of a pinned tile's card.+ auto center_indicators_in = [](TabMicrophoneIndicator* microphone, QWidget* speaker, QRectF const& card) {+ auto size_of = [](QWidget const& widget) { return widget.size().isEmpty() ? widget.sizeHint() : widget.size(); };+ auto total_width = (microphone ? size_of(*microphone).width() : 0) + (speaker ? size_of(*speaker).width() : 0);+ auto left = card.center().x() - (total_width / 2.0);+ for (auto* indicator : { static_cast<QWidget*>(microphone), speaker }) {+ if (!indicator)+ continue;+ auto indicator_size = size_of(*indicator);+ QRect indicator_geometry { qRound(left), qRound(card.center().y() - (indicator_size.height() / 2.0)), indicator_size.width(), indicator_size.height() };+ if (indicator->geometry() != indicator_geometry)+ indicator->setGeometry(indicator_geometry);+ left += indicator_size.width();+ }};// The buttons of a horizontal tab are centered on its card, rather than on the whole tab.@@ -2979,13 +3039,17 @@ void TabBar::update_tab_button_geometry()auto shape_rect = horizontal_tab_card_shape_rect(QRectF(tab_rect), horizontal_tab_end_room(index));auto* left_button = tabButton(index, QTabBar::LeftSide);prepare_button(left_button, TabBarButton::Placement::Tab);+ auto* microphone = microphone_indicator(index);+ prepare_button(microphone, TabBarButton::Placement::Tab);if (index < pinned_count) {- if (!left_button)- continue;- center_button_in(left_button, shape_rect);- if (auto visible = !is_dragged && is_in_view(left_button); left_button->isVisible() != visible)- left_button->setVisible(visible);+ center_indicators_in(microphone, left_button, shape_rect);+ for (auto* indicator : { static_cast<QWidget*>(microphone), left_button }) {+ if (!indicator)+ continue;+ if (auto visible = !is_dragged && is_in_view(indicator); indicator->isVisible() != visible)+ indicator->setVisible(visible);+ }continue;}@@ -3005,7 +3069,7 @@ void TabBar::update_tab_button_geometry()// of many in a full strip, has none, unless it is selected (see// horizontal_tab_close_button_replaces_favicon()).auto has_room = horizontal_tab_has_room_for_favicon_before(close_button_position.x(), content_rect.left());- auto replaces_favicon = horizontal_tab_close_button_replaces_favicon(content_rect, *close_button, is_selected, left_button);+ auto replaces_favicon = horizontal_tab_close_button_replaces_favicon(content_rect, *close_button, is_selected, left_button || microphone);if (replaces_favicon)close_button_position.setX(qRound(content_rect.center().x() - (close_button->width() / 2.0)));if (close_button->pos() != close_button_position)@@ -3023,14 +3087,27 @@ void TabBar::update_tab_button_geometry()trailing_edge = close_button_position.x() - 2;}- // The speaker of a tab playing audio sits left of the close button's slot.+ // The speaker of a tab playing audio sits left of the close button's slot, and the microphone of a tab using+ // it sits left of the speaker, or in the speaker's slot without it. A tab too narrow for both shows only the+ // microphone, in the speaker's slot, so that it never hides which tabs use the microphone.+ auto speaker_slot_left = trailing_edge - TAB_AUDIO_BUTTON_SIZE;+ auto has_room_for_microphone_before_speaker = !microphone || speaker_slot_left - microphone->width() >= content_rect.left();+ auto shows_speaker = left_button && has_room_for_microphone_before_speaker;if (left_button) {QPoint position { trailing_edge - left_button->width(), button_y_in(left_button, shape_rect) };if (left_button->pos() != position)left_button->move(position);- if (auto visible = !is_dragged && !is_growing && is_in_view(left_button); left_button->isVisible() != visible)+ if (auto visible = shows_speaker && !is_dragged && !is_growing && is_in_view(left_button); left_button->isVisible() != visible)left_button->setVisible(visible);}+ if (microphone) {+ auto x = shows_speaker ? left_button->x() - microphone->width() : speaker_slot_left + ((TAB_AUDIO_BUTTON_SIZE - microphone->width()) / 2);+ QPoint position { x, button_y_in(microphone, shape_rect) };+ if (microphone->pos() != position)+ microphone->move(position);+ if (auto visible = !is_dragged && !is_growing && is_in_view(microphone); microphone->isVisible() != visible)+ microphone->setVisible(visible);+ }}return;}@@ -3038,8 +3115,7 @@ void TabBar::update_tab_button_geometry()// Keep this out of paintEvent(): setVisible(), setGeometry(), and raise()// dirty child widgets, and doing that while painting can schedule another// tab bar repaint before the current one has finished flushing.- auto place_expanded_button = [&](int index, QTabBar::ButtonPosition position, QRect shape_rect) {- auto* button = tabButton(index, position);+ auto place_expanded_button = [&](int index, QWidget* button, QRect shape_rect) {if (!button)return;prepare_button(button, TabBarButton::Placement::SidebarRow);@@ -3053,14 +3129,17 @@ void TabBar::update_tab_button_geometry()return;// The close button's circle shares its center with the round end of the card it sits in. The speaker sits- // before the close button while it shows, and in its place otherwise.+ // before the close button while it shows, and in its place otherwise. The microphone sits before the speaker+ // while it shows, and in the speaker's place otherwise.// NB: A QRect's right() is its last column, one short of its right edge.+ auto* close_button = tabButton(index, QTabBar::RightSide);+ auto* speaker = tabButton(index, QTabBar::LeftSide);auto end_radius = shape_rect.height() / 2;auto x = shape_rect.right() + 1 - end_radius - (button_size.width() / 2);- if (position == QTabBar::LeftSide) {- if (auto* close_button = tabButton(index, QTabBar::RightSide); close_button && close_button->isVisible())- x = close_button->x() - SIDEBAR_ROW_BUTTON_GAP - button_size.width();- }+ if (button != close_button && close_button && close_button->isVisible())+ x = close_button->x() - SIDEBAR_ROW_BUTTON_GAP - ((SIDEBAR_ROW_AUDIO_BUTTON_SIZE + button_size.width()) / 2);+ if (button == microphone_indicator(index) && speaker && speaker->isVisible())+ x = speaker->x() - button_size.width();// The expanded layout is also used at narrow widths during hover expansion. Keep buttons from covering the// favicon while the sidebar grows.@@ -3079,7 +3158,7 @@ void TabBar::update_tab_button_geometry()// NB: Every row shows its close button, but for while the sidebar opens or closes, as the titles fade.auto is_toggling = m_tab_widget && m_tab_widget->vertical_tabs_are_toggling();- auto should_be_visible = index != dragged_index && has_room_for_icon && (position != QTabBar::RightSide || !is_toggling);+ auto should_be_visible = index != dragged_index && has_room_for_icon && (button != close_button || !is_toggling);if (button->isVisible() != should_be_visible) {button->setVisible(should_be_visible);did_update_button = true;@@ -3089,8 +3168,7 @@ void TabBar::update_tab_button_geometry()button->raise();};- auto place_collapsed_button = [&](int index, QTabBar::ButtonPosition position, QRect shape_rect) {- auto* button = tabButton(index, position);+ auto place_collapsed_button = [&](int index, QWidget* button, QRect shape_rect) {if (!button)return;prepare_button(button, TabBarButton::Placement::RailBadge);@@ -3101,12 +3179,16 @@ void TabBar::update_tab_button_geometry()if (button_size.isEmpty())return;- // The close button sits on the favicon's top left corner, and the speaker on its bottom right corner.+ // The close button sits on the favicon's top left corner, the speaker on its bottom right corner, and the+ // microphone on its bottom left corner.auto icon_center = QRectF(shape_rect).center();QPoint icon_top_left { qRound(icon_center.x()) - (TAB_ICON_SIZE / 2), qRound(icon_center.y()) - (TAB_ICON_SIZE / 2) };- auto badge_center = position == QTabBar::RightSide- ? icon_top_left - RAIL_BADGE_CORNER_OUTSET- : icon_top_left + QPoint(TAB_ICON_SIZE, TAB_ICON_SIZE) + RAIL_BADGE_CORNER_OUTSET;+ auto is_close_button = button == tabButton(index, QTabBar::RightSide);+ auto badge_center = icon_top_left + QPoint(TAB_ICON_SIZE, TAB_ICON_SIZE) + RAIL_BADGE_CORNER_OUTSET;+ if (is_close_button)+ badge_center = icon_top_left - RAIL_BADGE_CORNER_OUTSET;+ else if (button == microphone_indicator(index))+ badge_center = icon_top_left + QPoint(-RAIL_BADGE_CORNER_OUTSET.x(), TAB_ICON_SIZE + RAIL_BADGE_CORNER_OUTSET.y());auto button_position = badge_center - QPoint(button_size.width() / 2, button_size.height() / 2);// NB: As above, move the button before showing it.@@ -3118,7 +3200,7 @@ void TabBar::update_tab_button_geometry()}auto should_be_visible = index != dragged_index- && (position == QTabBar::LeftSide || (index == m_hovered_tab_index && !m_tab_widget->can_expand_vertical_tabs_on_hover()));+ && (!is_close_button || (index == m_hovered_tab_index && !m_tab_widget->can_expand_vertical_tabs_on_hover()));if (button->isVisible() != should_be_visible) {button->setVisible(should_be_visible);did_update_button = true;@@ -3134,10 +3216,14 @@ void TabBar::update_tab_button_geometry()if (!tab_rect.isValid())continue;+ auto* close_button = tabButton(index, QTabBar::RightSide);+ auto* speaker = tabButton(index, QTabBar::LeftSide);+ auto* microphone = microphone_indicator(index);+// An unpinned tab scrolled under the pinned tabs keeps its buttons out of sight.if (region.count > 0 && !region.scrolls && index >= region.count && tab_rect.top() < region.height) {- for (auto position : { QTabBar::LeftSide, QTabBar::RightSide }) {- if (auto* button = tabButton(index, position); button && button->isVisible())+ for (auto* button : { close_button, speaker, static_cast<QWidget*>(microphone) }) {+ if (button && button->isVisible())button->setVisible(false);}continue;@@ -3145,19 +3231,22 @@ void TabBar::update_tab_button_geometry()if (tab_layout() == TabLayout::VerticalCollapsed) {auto shape_rect = collapsed_vertical_tab_shape_rect(tab_rect);- place_collapsed_button(index, QTabBar::LeftSide, shape_rect);- place_collapsed_button(index, QTabBar::RightSide, shape_rect);+ place_collapsed_button(index, speaker, shape_rect);+ place_collapsed_button(index, close_button, shape_rect);+ place_collapsed_button(index, microphone, shape_rect);} else if (index < region.count && pinned_tabs_are_tiles()) {- if (auto* button = tabButton(index, QTabBar::LeftSide)) {- prepare_button(button, TabBarButton::Placement::Tab);- center_button_in(button, tab_rect);- if (button->isVisible() != (index != dragged_index))- button->setVisible(index != dragged_index);+ prepare_button(speaker, TabBarButton::Placement::Tab);+ prepare_button(microphone, TabBarButton::Placement::Tab);+ center_indicators_in(microphone, speaker, tab_rect);+ for (auto* indicator : { static_cast<QWidget*>(microphone), speaker }) {+ if (indicator && indicator->isVisible() != (index != dragged_index))+ indicator->setVisible(index != dragged_index);}} else {auto shape_rect = tab_card_shape_rect(tab_rect);- place_expanded_button(index, QTabBar::RightSide, shape_rect);- place_expanded_button(index, QTabBar::LeftSide, shape_rect);+ place_expanded_button(index, close_button, shape_rect);+ place_expanded_button(index, speaker, shape_rect);+ place_expanded_button(index, microphone, shape_rect);}}}@@ -5433,4 +5522,57 @@ void TabBarButton::paintEvent(QPaintEvent*)painter.drawPixmap(QStyle::alignedRect(layoutDirection(), Qt::AlignCenter, iconSize(), rect()).topLeft(), icon_pixmap);}+TabMicrophoneIndicator::TabMicrophoneIndicator(QWidget* parent)+ : QLabel(parent)+{+ setObjectName("LadybirdTabMicrophone");+ setToolTip("Using your microphone");+ setAccessibleName("Using your microphone");+ setFocusPolicy(Qt::NoFocus);+ set_placement(m_placement);+ hide();+}++// The microphone has no button around it, so it is only as wide as its glyph beside the speaker, except as a badge.+void TabMicrophoneIndicator::set_placement(TabBarButton::Placement placement)+{+ m_placement = placement;+ switch (placement) {+ case TabBarButton::Placement::Tab:+ setFixedSize(TAB_BUTTON_ICON_SIZE, TAB_AUDIO_BUTTON_SIZE);+ break;+ case TabBarButton::Placement::SidebarRow:+ setFixedSize(SIDEBAR_ROW_AUDIO_ICON_SIZE, SIDEBAR_ROW_AUDIO_BUTTON_SIZE);+ break;+ case TabBarButton::Placement::RailBadge:+ setFixedSize(RAIL_BADGE_SIZE, RAIL_BADGE_SIZE);+ break;+ }+ update();+}++// The microphone is drawn like the speaker in each place, in the same color and at the same size.+void TabMicrophoneIndicator::paintEvent(QPaintEvent*)+{+ QPainter painter(this);++ auto glyph_size = TAB_BUTTON_ICON_SIZE;+ switch (m_placement) {+ case TabBarButton::Placement::Tab:+ break;+ case TabBarButton::Placement::SidebarRow:+ glyph_size = SIDEBAR_ROW_AUDIO_ICON_SIZE;+ break;+ case TabBarButton::Placement::RailBadge:+ ChromeStyle::paint_tab_badge_frame(painter, *this);+ glyph_size = RAIL_BADGE_AUDIO_ICON_SIZE;+ break;+ }++ auto const& chrome = Theme::chrome(*this);+ auto takes_icon_color = m_placement != TabBarButton::Placement::Tab && ChromeStyle::window_activity(*this) == ChromeStyle::WindowActivity::Active;+ QRect glyph_rect { (width() - glyph_size) / 2, (height() - glyph_size) / 2, glyph_size, glyph_size };+ create_chrome_icon(ChromeIcon::Microphone, takes_icon_color ? chrome.icon : chrome.muted).paint(&painter, glyph_rect);+}+}diff --git a/UI/Qt/TabBar.h b/UI/Qt/TabBar.hindex 207409a68f8..837dd6424b4 100644--- a/UI/Qt/TabBar.h+++ b/UI/Qt/TabBar.h@@ -22,6 +22,7 @@#include <UI/Qt/WindowToolbar.h>#include <QHash>+#include <QLabel>#include <QPixmap>#include <QPointer>#include <QPushButton>@@ -54,6 +55,7 @@ namespace Ladybird {class AllTabsPopover;class LadybirdButton;+class TabMicrophoneIndicator;class TabPreviewPopup;class TabWidget;class WindowControlsReveal;@@ -100,6 +102,7 @@ public:int pinned_tab_count() const;void update_loading_ring_animation();+ void update_microphone_indicators();// How far the end of the horizontal tabs is from where it settles, while tabs open and close.int horizontal_tabs_end_offset() const;// A horizontal tab that closes shrinks away as the others close the gap.@@ -116,6 +119,8 @@ private:virtual void resizeEvent(QResizeEvent*) override;virtual void tabLayoutChange() override;+ virtual void tabInserted(int index) override;+ virtual void tabRemoved(int index) override;virtual bool event(QEvent*) override;virtual void paintEvent(QPaintEvent*) override;@@ -218,6 +223,7 @@ private:qreal loading_ring_opacity(int index) const;void ensure_tab_visible(int index);void update_tab_button_geometry();+ TabMicrophoneIndicator* microphone_indicator(int index) const;QPointer<TabWidget> m_tab_widget;@@ -263,6 +269,9 @@ private:int m_settled_tab_count { 0 };QVariantAnimation* m_loading_ring_animation { nullptr };+ // NB: QTabBar has room for only two widgets on each tab, the speaker and the close button, so the tab bar keeps the+ // microphone indicators itself.+ HashMap<Tab const*, TabMicrophoneIndicator*> m_microphone_indicators;QIcon m_fallback_tab_icon;QHash<QString, QStaticText> m_tab_title_texts;// The tabs whose titles were too long to show in full when last painted.@@ -536,4 +545,21 @@ private:QVariantAnimation* m_reveal_animation { nullptr };};+// Shows that a tab's page is using the microphone. It is not a control, so a press on it goes to the tab beneath.+// NB: It is a label so that assistive technology reads it as text.+class TabMicrophoneIndicator final : public QLabel {+ Q_OBJECT++public:+ AK_ALLOC_WITH_KMALLOC;++ explicit TabMicrophoneIndicator(QWidget* parent);+ void set_placement(TabBarButton::Placement);++private:+ virtual void paintEvent(QPaintEvent*) override;++ TabBarButton::Placement m_placement { TabBarButton::Placement::Tab };+};+}