Skip to content

Commit

Permalink
Clean up tab bar autohide
Browse files Browse the repository at this point in the history
Qt has this feature built-in, so there's no need to create a custom implementation
  • Loading branch information
AaronDewes authored and awesomekling committed Sep 22, 2022
1 parent 6145b99 commit d41ea63
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
10 changes: 1 addition & 9 deletions BrowserWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ BrowserWindow::BrowserWindow()
m_tabs_container->setMovable(true);
m_tabs_container->setTabsClosable(true);
m_tabs_container->setDocumentMode(true);

m_tabs_bar = m_tabs_container->findChild<QTabBar*>();
m_tabs_bar->hide();
m_tabs_container->setTabBarAutoHide(true);

auto* menu = menuBar()->addMenu("&File");

Expand Down Expand Up @@ -251,9 +249,6 @@ 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();

tab_ptr->focus_location_editor();
}

Expand All @@ -264,9 +259,6 @@ 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();
}

void BrowserWindow::close_current_tab()
Expand Down
2 changes: 0 additions & 2 deletions BrowserWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <QLineEdit>
#include <QMainWindow>
#include <QMenuBar>
#include <QTabBar>
#include <QTabWidget>
#include <QToolBar>

Expand Down Expand Up @@ -44,7 +43,6 @@ public slots:
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 };
};

0 comments on commit d41ea63

Please sign in to comment.