Ladybird: Hide TabBar if count <= 1

This commit is contained in:
Filiph Sandström 2022-07-12 11:41:11 +02:00 committed by Andrew Kaster
parent 74c71804c7
commit ace44dc13b
Notes: sideshowbarker 2024-07-17 17:40:13 +09:00
2 changed files with 11 additions and 0 deletions

View file

@ -22,6 +22,9 @@ BrowserWindow::BrowserWindow(Core::EventLoop& event_loop)
m_tabs_container->setMovable(true);
m_tabs_container->setTabsClosable(true);
m_tabs_bar = m_tabs_container->findChild<QTabBar*>();
m_tabs_bar->hide();
auto* menu = menuBar()->addMenu("&File");
auto* new_tab_action = new QAction("New &Tab");
@ -181,6 +184,9 @@ void BrowserWindow::new_tab()
QObject::connect(tab_ptr, &Tab::title_changed, this, &BrowserWindow::tab_title_changed);
QObject::connect(tab_ptr, &Tab::favicon_changed, this, &BrowserWindow::tab_favicon_changed);
if (m_tabs_container->count() > 1)
m_tabs_bar->show();
}
void BrowserWindow::close_tab(int index)
@ -190,6 +196,9 @@ void BrowserWindow::close_tab(int index)
m_tabs.remove_first_matching([&](auto& entry) {
return entry == tab;
});
if (m_tabs_container->count() <= 1)
m_tabs_bar->hide();
}
int BrowserWindow::tab_index(Tab* tab)

View file

@ -11,6 +11,7 @@
#include <QLineEdit>
#include <QMainWindow>
#include <QMenuBar>
#include <QTabBar>
#include <QTabWidget>
#include <QToolBar>
@ -39,6 +40,7 @@ private:
void debug_request(String const& request, String const& argument = "");
QTabWidget* m_tabs_container { nullptr };
QTabBar* m_tabs_bar { nullptr };
NonnullOwnPtrVector<Tab> m_tabs;
Tab* m_current_tab { nullptr };