From 1b1e327cb73491c17972a33a07c3c9beafe7f938 Mon Sep 17 00:00:00 2001 From: aqua Date: Sun, 18 Sep 2022 09:57:29 +0300 Subject: Add Navigation and Tab toolbars --- src/tabbar/tabbar.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'src/tabbar/tabbar.cpp') diff --git a/src/tabbar/tabbar.cpp b/src/tabbar/tabbar.cpp index 849dfbc1..4cd39550 100644 --- a/src/tabbar/tabbar.cpp +++ b/src/tabbar/tabbar.cpp @@ -22,23 +22,8 @@ TabBar::TabBar(QWidget *parent) : QTabBar(parent) setMovable(true); setAcceptDrops(true); - connect(this, &QTabBar::currentChanged, this, [this](int index) { - if (index == -1) { - emit currentChanged(nullptr); - return; - } - auto view = m_views.at(index); - Q_ASSERT(!view.isNull()); - emit currentChanged(view); - }); connect(this, &QTabBar::tabMoved, this, [this](int from, int to) { m_views.move(from, to); }); - connect(this, &QTabBar::tabCloseRequested, this, [this](int index) { - removeTab(index); - emit removeView(m_views.at(index)); - m_views.removeAt(index); - }); - /* // context menu(s) setContextMenuPolicy(Qt::CustomContextMenu); @@ -62,10 +47,23 @@ int TabBar::addTab(RekonqView *view) const int index = m_views.indexOf(view); setTabText(index, title); }); + connect(view, &RekonqView::iconChanged, this, [this, view](const QIcon &icon) { + const int index = m_views.indexOf(view); + setTabIcon(index, icon); + }); return id; } +RekonqView *TabBar::removeTab(int index) +{ + RekonqView *view = m_views.at(index); + m_views.removeAt(index); + QTabBar::removeTab(index); + + return view; +} + // ------------------------------------------------------------------------------------ QSize TabBar::tabSizeHint(int index) const -- cgit v1.2.1