mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
Ladybird/Qt: Prevent adding multiple audio state buttons
If the left-hand side of the tab is already occupied with an audio state button, we would add a second button to the right-hand side. Prevent that by checking if the occupant is our audio state button.
This commit is contained in:
parent
de97497d26
commit
c1c1ad8678
Notes:
sideshowbarker
2024-07-17 08:13:43 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/c1c1ad8678 Pull-request: https://github.com/SerenityOS/serenity/pull/23808
@ -671,6 +671,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(*tab), {});
|
||||
button->setToolTip(tool_tip_for_page_mute_state(*tab));
|
||||
button->setObjectName("LadybirdAudioState");
|
||||
button->setFlat(true);
|
||||
button->resize({ 20, 20 });
|
||||
|
||||
@ -721,8 +722,11 @@ QString BrowserWindow::tool_tip_for_page_mute_state(Tab& tab) const
|
||||
|
||||
QTabBar::ButtonPosition BrowserWindow::audio_button_position_for_tab(int tab_index) const
|
||||
{
|
||||
if (m_tabs_container->tabBar()->tabButton(tab_index, QTabBar::LeftSide))
|
||||
return QTabBar::RightSide;
|
||||
if (auto* button = m_tabs_container->tabBar()->tabButton(tab_index, QTabBar::LeftSide)) {
|
||||
if (button->objectName() != "LadybirdAudioState")
|
||||
return QTabBar::RightSide;
|
||||
}
|
||||
|
||||
return QTabBar::LeftSide;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user