summaryrefslogtreecommitdiff
path: root/src/tabbar
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabbar')
-rw-r--r--src/tabbar/tabbar.cpp28
-rw-r--r--src/tabbar/tabbar.h5
2 files changed, 14 insertions, 19 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
diff --git a/src/tabbar/tabbar.h b/src/tabbar/tabbar.h
index 793e2acf..db2e6d1c 100644
--- a/src/tabbar/tabbar.h
+++ b/src/tabbar/tabbar.h
@@ -23,6 +23,7 @@ public:
explicit TabBar(QWidget *parent = nullptr);
int addTab(RekonqView *view);
+ RekonqView *removeTab(int index);
[[nodiscard]] RekonqView *view(int index) { return m_views.at(index); }
/*
void setTabHighlighted(int index, bool b);
@@ -35,10 +36,6 @@ public:
setCurrentIndex(index);
}
-signals:
- void currentChanged(RekonqView *view);
- void removeView(RekonqView *);
-
protected:
[[nodiscard]] QSize tabSizeHint(int index) const override;
/*