]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/widgets/TabWidget.cpp
Open new tabs adjacent to the current tab. https://redmine.stoutner.com/issues/1110
[PrivacyBrowserPC.git] / src / widgets / TabWidget.cpp
index bd3882dcbeadd35dae184850d2e07d6e3b0d915a..efd677d73e636d37f9018839a019edaf54c1feb8 100644 (file)
@@ -178,7 +178,7 @@ void TabWidget::addFirstTab()
     qTabWidgetPointer->currentWidget()->setFocus();
 }
 
-PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool backgroundTab, const QString urlString)
+PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool adjacent, const bool backgroundTab, const QString urlString)
 {
     // Create a splitter widget.
     QSplitter *splitterPointer = new QSplitter();
@@ -197,8 +197,14 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
     splitterPointer->addWidget(privacyWebEngineViewPointer);
     splitterPointer->addWidget(devToolsWebEngineViewPointer);
 
+    // Initialize the new tab index.
+    int newTabIndex = 0;
+
     // Add a new tab.
-    int newTabIndex = qTabWidgetPointer->addTab(splitterPointer, i18nc("New tab label.", "New Tab"));
+    if (adjacent)  // Add the new tab adjacent to the current tab.
+        newTabIndex = qTabWidgetPointer->insertTab((qTabWidgetPointer->currentIndex() + 1), splitterPointer, i18nc("New tab label.", "New Tab"));
+    else  // Add the new tab at the end of the list.
+        newTabIndex = qTabWidgetPointer->addTab(splitterPointer, i18nc("New tab label.", "New Tab"));
 
     // Set the default tab icon.
     qTabWidgetPointer->setTabIcon(newTabIndex, defaultFavoriteIcon);