mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
Ladybird/Qt: Replace the default tab close icon with a vector icon
The default icon used by Qt is a bit jarring. Replace it with an icon that resembles our other homemade icons.
This commit is contained in:
parent
b577782247
commit
0234add5fa
Notes:
sideshowbarker
2024-07-17 02:42:21 +09:00
Author: https://github.com/trflynn89 Commit: https://github.com/SerenityOS/serenity/commit/0234add5fa Pull-request: https://github.com/SerenityOS/serenity/pull/23811 Reviewed-by: https://github.com/MacDue
4 changed files with 20 additions and 0 deletions
BIN
Ladybird/Icons/close.tvg
Normal file
BIN
Ladybird/Icons/close.tvg
Normal file
Binary file not shown.
|
@ -604,6 +604,7 @@ void BrowserWindow::initialize_tab(Tab* tab)
|
|||
};
|
||||
|
||||
m_tabs_container->setTabIcon(m_tabs_container->indexOf(tab), tab->favicon());
|
||||
create_close_button_for_tab(tab);
|
||||
|
||||
tab->focus_location_editor();
|
||||
}
|
||||
|
@ -658,6 +659,22 @@ void BrowserWindow::tab_favicon_changed(int index, QIcon const& icon)
|
|||
m_tabs_container->setTabIcon(index, icon);
|
||||
}
|
||||
|
||||
void BrowserWindow::create_close_button_for_tab(Tab* tab)
|
||||
{
|
||||
auto index = m_tabs_container->indexOf(tab);
|
||||
m_tabs_container->setTabIcon(index, tab->favicon());
|
||||
|
||||
auto* button = new TabBarButton(create_tvg_icon_with_theme_colors("close", palette()));
|
||||
auto position = audio_button_position_for_tab(index) == QTabBar::LeftSide ? QTabBar::RightSide : QTabBar::LeftSide;
|
||||
|
||||
connect(button, &QPushButton::clicked, this, [this, tab]() {
|
||||
auto index = m_tabs_container->indexOf(tab);
|
||||
close_tab(index);
|
||||
});
|
||||
|
||||
m_tabs_container->tabBar()->setTabButton(index, position, button);
|
||||
}
|
||||
|
||||
void BrowserWindow::tab_audio_play_state_changed(int index, Web::HTML::AudioPlayState play_state)
|
||||
{
|
||||
auto* tab = verify_cast<Tab>(m_tabs_container->widget(index));
|
||||
|
|
|
@ -129,6 +129,8 @@ private:
|
|||
}
|
||||
}
|
||||
|
||||
void create_close_button_for_tab(Tab*);
|
||||
|
||||
QIcon icon_for_page_mute_state(Tab&) const;
|
||||
QString tool_tip_for_page_mute_state(Tab&) const;
|
||||
QTabBar::ButtonPosition audio_button_position_for_tab(int tab_index) const;
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
<qresource>
|
||||
<file>../Icons/ladybird.png</file>
|
||||
<file>../Icons/back.tvg</file>
|
||||
<file>../Icons/close.tvg</file>
|
||||
<file>../Icons/forward.tvg</file>
|
||||
<file>../Icons/reload.tvg</file>
|
||||
</qresource>
|
||||
|
|
Loading…
Reference in a new issue