diff --git a/src/MainWindow.cpp b/src/MainWindow.cpp
index 37e875ad..d291e2e0 100644
--- a/src/MainWindow.cpp
+++ b/src/MainWindow.cpp
@@ -222,6 +222,19 @@ void MainWindow::init()
restoreGeometry(Settings::getValue("MainWindow", "geometry").toByteArray());
restoreState(Settings::getValue("MainWindow", "windowState").toByteArray());
+ // Restore open tab order if the openTabs setting is saved.
+ // Clear the tabs and then add them in the order specified by the setting.
+ // Use the statusTip attribute for restoring the tab label.
+ if (!Settings::getValue("MainWindow", "openTabs").toString().isEmpty()) {
+ ui->mainTab->clear();
+ for (QString objectName : Settings::getValue("MainWindow", "openTabs").toString().split(' ')) {
+ for (QWidget* widget : {ui->structure, ui->browser, ui->pragmas, ui->query})
+ if (widget->objectName() == objectName) {
+ ui->mainTab->addTab(widget, widget->statusTip());
+ break;
+ }
+ }
+ }
// Restore dock state settings
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(Settings::getValue("SQLLogDock", "Log").toString()));
@@ -335,6 +348,25 @@ void MainWindow::init()
// Add separator between docks and toolbars
ui->viewMenu->insertSeparator(ui->viewDBToolbarAction);
+ // Connect the tabCloseRequested to the actual closeTab function.
+ // This must be done before the connections for checking the actions in the View menu so
+ // they are updated accordingly.
+ connect(ui->mainTab, &QTabWidget::tabCloseRequested, this, &MainWindow::closeTab);
+
+ // Add entries for toggling the visibility of main tabs
+ for (QWidget* widget : {ui->structure, ui->browser, ui->pragmas, ui->query}) {
+ QAction* action = ui->viewMenu->addAction(QIcon(":/icons/tab"), widget->statusTip());
+ action->setCheckable(true);
+ action->setChecked(ui->mainTab->indexOf(widget) != -1);
+ connect(action, &QAction::toggled, [=](bool show) { toggleTabVisible(widget, show); });
+ // Connect tabCloseRequested for setting checked the appropiate menu entry.
+ // Note these are called after the actual tab is closed only because they are connected
+ // after connecting closeTab.
+ connect(ui->mainTab, &QTabWidget::tabCloseRequested, [=](int index) {
+ action->setChecked(ui->mainTab->indexOf(widget) != -1);
+ });
+ }
+
// If we're not compiling in SQLCipher, hide its FAQ link in the help menu
#ifndef ENABLE_SQLCIPHER
ui->actionSqlCipherFaq->setVisible(false);
@@ -896,6 +928,12 @@ void MainWindow::closeEvent( QCloseEvent* event )
{
Settings::setValue("MainWindow", "geometry", saveGeometry());
Settings::setValue("MainWindow", "windowState", saveState());
+
+ QString openTabs;
+ for (int i=0; i < ui->mainTab->count(); i++)
+ openTabs.append(ui->mainTab->widget(i)->objectName() + ' ');
+ Settings::setValue("MainWindow", "openTabs", openTabs);
+
Settings::setValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
Settings::setValue("SchemaDock", "dropQualifiedNames", ui->actionDropQualifiedCheck->isChecked());
Settings::setValue("SchemaDock", "dropEnquotedNames", ui->actionEnquoteNamesCheck->isChecked());
@@ -3694,3 +3732,17 @@ void MainWindow::updateDatabaseBusyStatus(bool busy, const QString& user)
statusBusyLabel->setVisible(busy);
statusStopButton->setVisible(busy);
}
+
+
+void MainWindow::closeTab(int index)
+{
+ ui->mainTab->removeTab(index);
+}
+
+void MainWindow::toggleTabVisible(QWidget* tabWidget, bool show)
+{
+ if (show)
+ ui->mainTab->addTab(tabWidget, tabWidget->statusTip());
+ else
+ ui->mainTab->removeTab(ui->mainTab->indexOf(tabWidget));
+}
diff --git a/src/MainWindow.h b/src/MainWindow.h
index 6ee24495..ed14b837 100644
--- a/src/MainWindow.h
+++ b/src/MainWindow.h
@@ -187,6 +187,7 @@ private:
sqlb::ObjectIdentifier currentlyBrowsedTableName() const;
void applyBrowseTableSettings(BrowseDataTableSettings storedData, bool skipFilters = false);
+ void toggleTabVisible(QWidget* tabWidget, bool show);
protected:
void closeEvent(QCloseEvent *) override;
@@ -298,6 +299,7 @@ private slots:
void printDbStructure();
void updateDatabaseBusyStatus(bool busy, const QString& user);
void openPreferences();
+ void closeTab(int index);
};
#endif
diff --git a/src/MainWindow.ui b/src/MainWindow.ui
index 19a04311..be5dc129 100644
--- a/src/MainWindow.ui
+++ b/src/MainWindow.ui
@@ -24,10 +24,19 @@
0
+
+ true
+
true
+
+ true
+
+
+ Database Structure
+
Database Structure
@@ -93,6 +102,9 @@ You can drag SQL statements from an object row and drop them into other applicat
+
+ Browse Data
+
Browse Data
@@ -431,6 +443,9 @@ You can drag SQL statements from an object row and drop them into other applicat
+
+ Edit Pragmas
+
Edit Pragmas
@@ -445,8 +460,8 @@ You can drag SQL statements from an object row and drop them into other applicat
0
0
- 601
- 484
+ 572
+ 510
@@ -946,6 +961,9 @@ You can drag SQL statements from an object row and drop them into other applicat
+
+ Execute SQL
+
Execute SQL
@@ -1056,6 +1074,7 @@ You can drag SQL statements from an object row and drop them into other applicat
+