diff options
author | aqua <aqua@iserlohn-fortress.net> | 2022-09-18 09:57:29 +0300 |
---|---|---|
committer | aqua <aqua@iserlohn-fortress.net> | 2022-09-18 09:57:29 +0300 |
commit | 1b1e327cb73491c17972a33a07c3c9beafe7f938 (patch) | |
tree | 57fa4bc121fc2e172db42288fec7cdd7ff95399c /src/tabbar/tabbar.cpp | |
parent | Add Bookmarks toolbar (diff) | |
download | rekonq-1b1e327cb73491c17972a33a07c3c9beafe7f938.tar.xz |
Add Navigation and Tab toolbars
Diffstat (limited to 'src/tabbar/tabbar.cpp')
-rw-r--r-- | src/tabbar/tabbar.cpp | 28 |
1 files changed, 13 insertions, 15 deletions
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 |