diff options
Diffstat (limited to 'src/subwindow')
-rw-r--r-- | src/subwindow/subwindow.cpp | 2 | ||||
-rw-r--r-- | src/subwindow/tabwidget.cpp | 17 | ||||
-rw-r--r-- | src/subwindow/tabwidget.h | 4 |
3 files changed, 11 insertions, 12 deletions
diff --git a/src/subwindow/subwindow.cpp b/src/subwindow/subwindow.cpp index a83cf14..76eddb3 100644 --- a/src/subwindow/subwindow.cpp +++ b/src/subwindow/subwindow.cpp @@ -168,7 +168,7 @@ int SubWindow::addTab(const QUrl &url, WebProfile *profile) void SubWindow::closeTab(int index) { - tabWidget->deleteTab(index); + tabWidget->removeTab(index); } void SubWindow::setCurrentTab(int index) diff --git a/src/subwindow/tabwidget.cpp b/src/subwindow/tabwidget.cpp index 58e9b03..6951b7b 100644 --- a/src/subwindow/tabwidget.cpp +++ b/src/subwindow/tabwidget.cpp @@ -36,7 +36,7 @@ TabWidget::TabWidget(QWidget *parent) setElideMode(Qt::ElideRight); setMovable(true); - connect(this, &TabWidget::tabCloseRequested, this, &TabWidget::deleteTab); + connect(this, &TabWidget::tabCloseRequested, this, &TabWidget::removeTab); // when changing tabs, give focus to the widget // otherwise when closing tabs, the tabwidget will retain focus @@ -49,14 +49,14 @@ TabWidget::TabWidget(QWidget *parent) tabContextMenu = new QMenu(this); auto *closeTab = tabContextMenu->addAction(tr("Close Tab")); connect(closeTab, &QAction::triggered, this, [this]() { - deleteTab(this->tabBar()->tabAt(mapFromGlobal(tabContextMenu->pos()))); + removeTab(this->tabBar()->tabAt(mapFromGlobal(tabContextMenu->pos()))); }); auto *closeTabsLeft = tabContextMenu->addAction(tr("Close Tabs left")); connect(closeTabsLeft, &QAction::triggered, this, [this]() { int idx = this->tabBar()->tabAt(mapFromGlobal(tabContextMenu->pos())); for(int i = idx - 1; i >= 0; --i) { - deleteTab(i); + removeTab(i); } }); @@ -64,7 +64,7 @@ TabWidget::TabWidget(QWidget *parent) connect(closeTabsRight, &QAction::triggered, this, [this]() { int idx = this->tabBar()->tabAt(mapFromGlobal(tabContextMenu->pos())); for(int i = count() - 1; i > idx; --i) { - deleteTab(i); + removeTab(i); } }); } @@ -100,7 +100,7 @@ int TabWidget::addTab(WebView *view) return idx; } -void TabWidget::deleteTab(int index) +void TabWidget::removeTab(int index) { // deleting the widget automatically removes the tab? WebView *w = qobject_cast<WebView *>(widget(index)); @@ -117,11 +117,8 @@ void TabWidget::deleteTab(int index) m_closedTabs.dequeue(); } - disconnect(w); + QTabWidget::removeTab(index); delete w; - - if(count() == 0) - parentWidget()->close(); } int TabWidget::restoreLastTab() @@ -171,7 +168,7 @@ void TabWidget::mousePressEvent(QMouseEvent *event) if(event->button() == Qt::MiddleButton) { int index = tabBar()->tabAt(event->pos()); if(index >= 0) { - deleteTab(index); + removeTab(index); } event->accept(); return; diff --git a/src/subwindow/tabwidget.h b/src/subwindow/tabwidget.h index ef1930d..d615bcb 100644 --- a/src/subwindow/tabwidget.h +++ b/src/subwindow/tabwidget.h @@ -36,7 +36,7 @@ public: public slots: int addTab(WebView *view); - void deleteTab(int index); + void removeTab(int index); int restoreLastTab(); void restoreTabMenu(QMenu *menu); @@ -45,6 +45,8 @@ protected: void contextMenuEvent(QContextMenuEvent *event) override; void mousePressEvent(QMouseEvent *event) override; + + private: QMenu *tabContextMenu; QQueue<TabInformation> m_closedTabs; |