diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index bf55ec07f..45262e5c3 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -42,6 +42,10 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Tabs tab) ui->checkUpdates->setVisible(false); #endif +#ifndef Q_OS_MACX + ui->checkSqleanExtensionAutoload->setVisible(false); +#endif + loadSettings(); connect(ui->appStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(adjustColorsToStyle(int))); @@ -208,6 +212,9 @@ void PreferencesDialog::loadSettings() ui->listExtensions->addItems(Settings::getValue("extensions", "list").toStringList()); ui->checkRegexDisabled->setChecked(Settings::getValue("extensions", "disableregex").toBool()); ui->checkAllowLoadExtension->setChecked(Settings::getValue("extensions", "enable_load_extension").toBool()); + #ifdef Q_OS_MACX + ui->checkSqleanExtensionAutoload->setChecked(Settings::getValue("extensions", "autoload_sqlean_extension").toBool()); + #endif fillLanguageBox(); ui->appStyleCombo->setCurrentIndex(Settings::getValue("General", "appStyle").toInt()); ui->toolbarStyleComboMain->setCurrentIndex(Settings::getValue("General", "toolbarStyle").toInt()); @@ -280,6 +287,9 @@ void PreferencesDialog::saveSettings(bool accept) Settings::setValue("extensions", "list", extList); Settings::setValue("extensions", "disableregex", ui->checkRegexDisabled->isChecked()); Settings::setValue("extensions", "enable_load_extension", ui->checkAllowLoadExtension->isChecked()); + #ifdef Q_OS_MACX + Settings::setValue("extensions", "autoload_sqlean_extension", ui->checkSqleanExtensionAutoload->isChecked()); + #endif // Save remote settings Settings::setValue("remote", "active", ui->checkUseRemotes->isChecked()); diff --git a/src/PreferencesDialog.ui b/src/PreferencesDialog.ui index 8a8e42c15..6d5363b8d 100644 --- a/src/PreferencesDialog.ui +++ b/src/PreferencesDialog.ui @@ -7,7 +7,7 @@ 0 0 756 - 625 + 666 @@ -20,7 +20,7 @@ - 0 + 4 @@ -1866,6 +1866,16 @@ Can be set to 0 for disabling completion. + + + + <html><head/><body><p>Automatically load the 'nalgeon/sqlean' extension at program startup.</p></body></html> + + + Automatically load the 'sqlean' extension + + + diff --git a/src/sqlitedb.cpp b/src/sqlitedb.cpp index 37f1e6fe3..613bfeafa 100644 --- a/src/sqlitedb.cpp +++ b/src/sqlitedb.cpp @@ -2170,6 +2170,15 @@ void DBBrowserDB::loadExtensionsFromSettings() if(loadExtension(ext) == false) QMessageBox::warning(nullptr, QApplication::applicationName(), tr("Error loading extension: %1").arg(lastError())); } + + if (Settings::getValue("extensions", "autoload_sqlean_extension").toBool()) + { + const QString sqleanExtensionPath = qApp->applicationDirPath() + "/../Extensions/sqlean.dylib"; + if (loadExtension(sqleanExtensionPath) == false) { + QMessageBox::warning(nullptr, QApplication::applicationName(), tr("Error loading 'sqlean' extension. Option is disabled.")); + Settings::setValue("extensions", "autoload_sqlean_extension", false); + } + } } std::vector> DBBrowserDB::queryColumnInformation(const std::string& schema_name, const std::string& object_name) const