فهرست منبع

Ladybird: Hide TabBar if count <= 1

Filiph Sandström 3 سال پیش
والد
کامیت
ace44dc13b
2فایلهای تغییر یافته به همراه11 افزوده شده و 0 حذف شده
  1. 9 0
      Ladybird/BrowserWindow.cpp
  2. 2 0
      Ladybird/BrowserWindow.h

+ 9 - 0
Ladybird/BrowserWindow.cpp

@@ -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)

+ 2 - 0
Ladybird/BrowserWindow.h

@@ -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 };