From d86b45e7e6a296b0e3ff0fb48329ee9809944af0 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Wed, 12 Dec 2018 14:10:28 +0100 Subject: [PATCH] dbhub: Open Preferences dialog on the correct tab When opening the Preferences dialog from the Remote dock, we now show the Remote tab by default. --- src/MainWindow.h | 5 +++-- src/PreferencesDialog.cpp | 5 ++++- src/PreferencesDialog.h | 12 +++++++++++- src/RemoteDock.cpp | 9 +++++++-- 4 files changed, 25 insertions(+), 6 deletions(-) diff --git a/src/MainWindow.h b/src/MainWindow.h index 295c9abe..6ee24495 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -203,7 +203,8 @@ public slots: void jumpToRow(const sqlb::ObjectIdentifier& table, QString column, const QByteArray& value); void switchToBrowseDataTab(QString tableToBrowse = QString()); void populateStructure(const QString& old_table = QString()); - void openPreferences(); + void reloadSettings(); + private slots: void createTreeContextMenu(const QPoint & qPoint); @@ -257,7 +258,6 @@ private slots: void saveSqlResultsAsCsv(); void saveSqlResultsAsView(); void loadExtension(); - void reloadSettings(); void checkNewVersion(const QString& versionstring, const QString& url); void on_actionWiki_triggered(); void on_actionBug_report_triggered(); @@ -297,6 +297,7 @@ private slots: void runSqlNewTab(const QString& query, const QString& title); void printDbStructure(); void updateDatabaseBusyStatus(bool busy, const QString& user); + void openPreferences(); }; #endif diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index a87f64b6..8206bad1 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -13,7 +13,7 @@ #include #include -PreferencesDialog::PreferencesDialog(QWidget* parent) +PreferencesDialog::PreferencesDialog(QWidget* parent, Tabs tab) : QDialog(parent), ui(new Ui::PreferencesDialog), m_dbFileExtensions(Settings::getValue("General", "DBFileExtensions").toString().split(";;")) @@ -43,6 +43,9 @@ PreferencesDialog::PreferencesDialog(QWidget* parent) // Avoid different heights due to having check boxes or not ui->treeSyntaxHighlighting->setUniformRowHeights(true); + + // Set current tab + ui->tabWidget->setCurrentIndex(tab); } /* diff --git a/src/PreferencesDialog.h b/src/PreferencesDialog.h index 9b18cb68..b3aa4550 100644 --- a/src/PreferencesDialog.h +++ b/src/PreferencesDialog.h @@ -19,7 +19,17 @@ class PreferencesDialog : public QDialog Q_OBJECT public: - explicit PreferencesDialog(QWidget* parent = nullptr); + enum Tabs + { + TabGeneral, + TabDatabase, + TabDataBrowser, + TabSql, + TabExtensions, + TabRemote + }; + + explicit PreferencesDialog(QWidget* parent = nullptr, Tabs tab = TabGeneral); ~PreferencesDialog() override; private slots: diff --git a/src/RemoteDock.cpp b/src/RemoteDock.cpp index 1467f931..b4671c72 100644 --- a/src/RemoteDock.cpp +++ b/src/RemoteDock.cpp @@ -9,6 +9,7 @@ #include "RemoteModel.h" #include "MainWindow.h" #include "RemotePushDialog.h" +#include "PreferencesDialog.h" RemoteDock::RemoteDock(MainWindow* parent) : QDialog(parent), @@ -32,9 +33,13 @@ RemoteDock::RemoteDock(MainWindow* parent) // just open them in a web browser connect(ui->labelNoCert, &QLabel::linkActivated, [this](const QString& link) { if(link == "#preferences") - mainWindow->openPreferences(); - else + { + PreferencesDialog dialog(mainWindow, PreferencesDialog::TabRemote); + if(dialog.exec()) + mainWindow->reloadSettings(); + } else { QDesktopServices::openUrl(QUrl(link)); + } }); // Initial setup