mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-12-11 17:00:37 +00:00
Ladybird: Hide TabBar if count <= 1
This commit is contained in:
parent
74c71804c7
commit
ace44dc13b
Notes:
sideshowbarker
2024-07-17 17:40:13 +09:00
Author: https://github.com/filiphsps Commit: https://github.com/SerenityOS/serenity/commit/ace44dc13b Pull-request: https://github.com/SerenityOS/serenity/pull/16583 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/awesomekling ✅ Reviewed-by: https://github.com/linusg
2 changed files with 11 additions and 0 deletions
|
@ -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)
|
||||
|
|
|
@ -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 };
|
||||
|
||||
|
|
Loading…
Reference in a new issue