Ladybird/Qt: Support muting an entire page
We already display a speaker icon on tabs which are playing audio. This allows the user to click that icon to mute the tab, at which point the icon is replaced with a muted speaker icon. We would previously hide the icon when audio stopped playing. We now do this only if the tab isn't muted. If it is muted, the muted speaker icon remains on the tab so that the page isn't stuck in a muted state.
This commit is contained in:
parent
f61f55d397
commit
45b03bf75d
2 changed files with 30 additions and 6 deletions
|
|
@ -651,24 +651,46 @@ void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlay
|
|||
{
|
||||
switch (play_state) {
|
||||
case Web::HTML::AudioPlayState::Paused:
|
||||
m_tabs_container->tabBar()->setTabButton(index, QTabBar::LeftSide, nullptr);
|
||||
if (view().page_mute_state() == Web::HTML::MuteState::Unmuted)
|
||||
m_tabs_container->tabBar()->setTabButton(index, QTabBar::LeftSide, nullptr);
|
||||
break;
|
||||
|
||||
case Web::HTML::AudioPlayState::Playing:
|
||||
auto icon = style()->standardIcon(QStyle::SP_MediaVolume);
|
||||
|
||||
auto* button = new QPushButton(icon, {});
|
||||
auto* button = new QPushButton(icon_for_page_mute_state(), {});
|
||||
button->setFlat(true);
|
||||
button->resize({ 20, 20 });
|
||||
|
||||
// FIXME: Add a click handler to mute the tab.
|
||||
button->setEnabled(false);
|
||||
connect(button, &QPushButton::clicked, this, [this, index]() {
|
||||
view().toggle_page_mute_state();
|
||||
|
||||
switch (view().audio_play_state()) {
|
||||
case Web::HTML::AudioPlayState::Paused:
|
||||
m_tabs_container->tabBar()->setTabButton(index, QTabBar::LeftSide, nullptr);
|
||||
break;
|
||||
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());
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
m_tabs_container->tabBar()->setTabButton(index, QTabBar::LeftSide, button);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
QIcon BrowserWindow::icon_for_page_mute_state() const
|
||||
{
|
||||
switch (view().page_mute_state()) {
|
||||
case Web::HTML::MuteState::Muted:
|
||||
return style()->standardIcon(QStyle::SP_MediaVolumeMuted);
|
||||
case Web::HTML::MuteState::Unmuted:
|
||||
return style()->standardIcon(QStyle::SP_MediaVolume);
|
||||
}
|
||||
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
void BrowserWindow::open_next_tab()
|
||||
{
|
||||
if (m_tabs_container->count() <= 1)
|
||||
|
|
|
|||
|
|
@ -128,6 +128,8 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
QIcon icon_for_page_mute_state() const;
|
||||
|
||||
QScreen* m_current_screen;
|
||||
double m_device_pixel_ratio { 0 };
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue