Ladybird/Qt: Display a tool tip on the tab mute button

This commit is contained in:
Timothy Flynn 2024-03-30 11:10:11 -04:00 committed by Andreas Kling
parent 45b03bf75d
commit 0da5d5a0d0
Notes: sideshowbarker 2024-07-17 09:49:33 +09:00
2 changed files with 15 additions and 0 deletions

View file

@ -657,6 +657,7 @@ void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlay
case Web::HTML::AudioPlayState::Playing:
auto* button = new QPushButton(icon_for_page_mute_state(), {});
button->setToolTip(tool_tip_for_page_mute_state());
button->setFlat(true);
button->resize({ 20, 20 });
@ -670,6 +671,7 @@ void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlay
case Web::HTML::AudioPlayState::Playing:
auto* button = m_tabs_container->tabBar()->tabButton(index, QTabBar::LeftSide);
verify_cast<QPushButton>(button)->setIcon(icon_for_page_mute_state());
button->setToolTip(tool_tip_for_page_mute_state());
break;
}
});
@ -691,6 +693,18 @@ QIcon BrowserWindow::icon_for_page_mute_state() const
VERIFY_NOT_REACHED();
}
QString BrowserWindow::tool_tip_for_page_mute_state() const
{
switch (view().page_mute_state()) {
case Web::HTML::MuteState::Muted:
return "Unmute tab";
case Web::HTML::MuteState::Unmuted:
return "Mute tab";
}
VERIFY_NOT_REACHED();
}
void BrowserWindow::open_next_tab()
{
if (m_tabs_container->count() <= 1)

View file

@ -129,6 +129,7 @@ private:
}
QIcon icon_for_page_mute_state() const;
QString tool_tip_for_page_mute_state() const;
QScreen* m_current_screen;
double m_device_pixel_ratio { 0 };