]> 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 a8f59b4800e6671ad167a3319574773c80c6c094..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);
@@ -907,7 +913,7 @@ void TabWidget::reloadAndBypassCache() const
 void TabWidget::saveArchive()
 {
     // Get the suggested file name.
-    QString suggestedFileName = currentPrivacyWebEngineViewPointer->url().host() + ".mht";
+    QString suggestedFileName = currentPrivacyWebEngineViewPointer->title() + ".mht";
 
     // Get the download directory.
     QString downloadDirectory = Settings::downloadLocation();