Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,14 @@
<x>0</x>
<y>0</y>
<width>635</width>
<height>349</height>
<height>350</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DB Browser for SQLite is an open source, freeware visual tool used to create, design and edit SQLite database files.&lt;/p&gt;&lt;p&gt;It is bi-licensed under the Mozilla Public License Version 2, as well as the GNU General Public License Version 3 or later. You can modify or redistribute it under the conditions of these licenses.&lt;/p&gt;&lt;p&gt;See &lt;a href=&quot;https://www.gnu.org/licenses/gpl.html&quot;&gt;https://www.gnu.org/licenses/gpl.html&lt;/a&gt; and &lt;a href=&quot;https://www.mozilla.org/MPL/2.0/index.txt&quot;&gt;https://www.mozilla.org/MPL/2.0/index.txt&lt;/a&gt; for details.&lt;/p&gt;&lt;p&gt;For more information on this program please visit our website at: &lt;a href=&quot;https://sqlitebrowser.org&quot;&gt;https://sqlitebrowser.org&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:small;&quot;&gt;This software uses the GPL/LGPL Qt Toolkit from &lt;/span&gt;&lt;a href=&quot;https://qt-project.org/&quot;&gt;&lt;span style=&quot; font-size:small;&quot;&gt;https://qt-project.org/&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:small;&quot;&gt;&lt;br/&gt;See &lt;/span&gt;&lt;a href=&quot;https://doc.qt.io/qt-5/licensing.html&quot;&gt;&lt;span style=&quot; font-size:small;&quot;&gt;https://doc.qt.io/qt-5/licensing.html&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:small;&quot;&gt; for licensing terms and information.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:small;&quot;&gt;It also uses the Pastel SVG icon set by Michael Buckley under a Creative Commons
Attribution Share Alike 4.0 license.&lt;br/&gt;See &lt;/span&gt;&lt;a href=&quot;https://codefisher.org/pastel-svg/&quot;&gt;&lt;span style=&quot; font-size:small;&quot;&gt;https://codefisher.org/pastel-svg/&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:small;&quot;&gt; for details.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;DB Browser for SQLite is an open source, freeware visual tool used to create, design and edit SQLite database files.&lt;/p&gt;&lt;p&gt;It is bi-licensed under the Mozilla Public License Version 2, as well as the GNU General Public License Version 3 or later. You can modify or redistribute it under the conditions of these licenses.&lt;/p&gt;&lt;p&gt;See &lt;a href=&quot;https://www.gnu.org/licenses/gpl.html&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.gnu.org/licenses/gpl.html&lt;/span&gt;&lt;/a&gt; and &lt;a href=&quot;https://www.mozilla.org/MPL/2.0/index.txt&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;https://www.mozilla.org/MPL/2.0/index.txt&lt;/span&gt;&lt;/a&gt; for details.&lt;/p&gt;&lt;p&gt;For more information on this program please visit our website at: &lt;a href=&quot;https://sqlitebrowser.org&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;http://sqlitebrowser.org&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:small;&quot;&gt;This software uses the GPL/LGPL Qt Toolkit from &lt;/span&gt;&lt;a href=&quot;http://qt-project.org/&quot;&gt;&lt;span style=&quot; font-size:small; text-decoration: underline; color:#0000ff;&quot;&gt;https://qt-project.org/&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:small;&quot;&gt;&lt;br/&gt;See &lt;/span&gt;&lt;a href=&quot;https://doc.qt.io/qt-5/licensing.html&quot;&gt;&lt;span style=&quot; font-size:small; text-decoration: underline; color:#0000ff;&quot;&gt;https://qt-project.org/doc/qt-5/licensing.html&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:small;&quot;&gt; for licensing terms and information.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:8pt;&quot;&gt;We use the nalgeon/sqlean library for SQLite extensions support.&lt;br/&gt;This library is licensed under the MIT license, see the following for more information:&lt;br/&gt;&lt;/span&gt;&lt;a href=&quot;https://github.com/nalgeon/sqlean&quot;&gt;&lt;span style=&quot; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;https://github.com/nalgeon/sqlean&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;span style=&quot; font-size:small;&quot;&gt;It also uses the Pastel SVG icon set by Michael Buckley under a Creative Commons Attribution Share Alike 4.0 license.&lt;br/&gt;See &lt;/span&gt;&lt;a href=&quot;https://codefisher.org/pastel-svg/&quot;&gt;&lt;span style=&quot; font-size:small; text-decoration: underline; color:#0000ff;&quot;&gt;https://codefisher.org/pastel-svg/&lt;/span&gt;&lt;/a&gt;&lt;span style=&quot; font-size:small;&quot;&gt; for details.&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
Expand Down
69 changes: 69 additions & 0 deletions src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <QKeyEvent>
#include <QStandardPaths>
#include <QStyledItemDelegate>
#include <QSysInfo>

PreferencesDialog::PreferencesDialog(QWidget* parent, Tabs tab)
: QDialog(parent),
Expand Down Expand Up @@ -42,6 +43,8 @@ PreferencesDialog::PreferencesDialog(QWidget* parent, Tabs tab)
ui->checkUpdates->setVisible(false);
#endif

createBuiltinExtensionList();

loadSettings();

connect(ui->appStyleCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(adjustColorsToStyle(int)));
Expand Down Expand Up @@ -206,6 +209,11 @@ void PreferencesDialog::loadSettings()
ui->checkCloseButtonOnTabs->setChecked(Settings::getValue("editor", "close_button_on_tabs").toBool());

ui->listExtensions->addItems(Settings::getValue("extensions", "list").toStringList());
for (int i=0;i<ui->listBuiltinExtensions->count();++i)
{
QListWidgetItem* item = ui->listBuiltinExtensions->item(i);
item->setCheckState(Settings::getValue("extensions", "builtin").toMap().value(item->text()).toBool() ? Qt::Checked : Qt::Unchecked);
}
ui->checkRegexDisabled->setChecked(Settings::getValue("extensions", "disableregex").toBool());
ui->checkAllowLoadExtension->setChecked(Settings::getValue("extensions", "enable_load_extension").toBool());
fillLanguageBox();
Expand Down Expand Up @@ -281,6 +289,11 @@ void PreferencesDialog::saveSettings(bool accept)
Settings::setValue("extensions", "disableregex", ui->checkRegexDisabled->isChecked());
Settings::setValue("extensions", "enable_load_extension", ui->checkAllowLoadExtension->isChecked());

QVariantMap builtinExtList;
for (int i=0;i<ui->listBuiltinExtensions->count();++i)
builtinExtList.insert(ui->listBuiltinExtensions->item(i)->text(), ui->listBuiltinExtensions->item(i)->checkState());
Settings::setValue("extensions", "builtin", QVariant::fromValue(builtinExtList));

// Save remote settings
Settings::setValue("remote", "active", ui->checkUseRemotes->isChecked());
QStringList old_client_certs = Settings::getValue("remote", "client_certificates").toStringList();
Expand Down Expand Up @@ -434,6 +447,62 @@ void PreferencesDialog::removeExtension()
ui->listExtensions->takeItem(ui->listExtensions->currentIndex().row());
}

void PreferencesDialog::createBuiltinExtensionList()
{
QDir dir;
QStringList files;

// If we upgrade Qt framework version to 6.x at some point, use 'macos' instead of 'osx.'
// For further information, see the https://doc.qt.io/qt-6/qsysinfo.html
if (QSysInfo::productType() == "osx") {
dir.setPath(qApp->applicationDirPath() + "/../Extensions/");
files = dir.entryList(QStringList() << "*.dylib", QDir::Files);
}
else if (QSysInfo::productType() == "windows") {
dir.setPath(qApp->applicationDirPath() + "/extensions/");
files = dir.entryList(QStringList() << "*.dll", QDir::Files);
}
else {
const QString productType (QSysInfo::productType());
const QString cpuArchitecture (QSysInfo::currentCpuArchitecture());
if (productType == "fedora" || productType == "redhat") {
if (cpuArchitecture.contains("64"))
dir.setPath("/usr/lib64/");
else
dir.setPath("/usr/lib/");
} else {
if (cpuArchitecture == "arm") {
dir.setPath("/usr/lib/aarch-linux-gnu/");
} else if (cpuArchitecture == "arm64") {
dir.setPath("/usr/lib/aarch64-linux-gnu/");
} else if (cpuArchitecture == "i386") {
dir.setPath("/usr/lib/i386-linux-gnu/");
} else if (cpuArchitecture == "x86_64") {
dir.setPath("/usr/lib/x86_64-linux-gnu/");
} else {
dir.setPath("/usr/lib/");
}
}
// There is no single naming convention for SQLite extension libraries,
// but this gives good results, at least on Debian based systems.
// The patterns have to exclude "libsqlite3.so", which is the SQLite3
// library, not an extension.
files = dir.entryList(QStringList()
<< "libsqlite3[!.]*.so"
<< "mod_*.so"
<< "lib?*sqlite*.so", QDir::Files);
}

for (const QString& file: files) {
QString absoluteFilePath = dir.absoluteFilePath(file);
QListWidgetItem* item = new QListWidgetItem(absoluteFilePath, ui->listBuiltinExtensions);
item->setFlags(item->flags() | Qt::ItemIsUserCheckable);
// The check state is redetermined after the 'loadSettings()' function call.
item->setCheckState(Qt::Unchecked);
ui->listBuiltinExtensions->addItem(item);
}
}

void PreferencesDialog::fillLanguageBox()
{
QDir translationsDir(QCoreApplication::applicationDirPath() + "/translations",
Expand Down
1 change: 1 addition & 0 deletions src/PreferencesDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ private slots:
void chooseLocation();
void showColourDialog(QTreeWidgetItem* item, int column);
void addExtension();
void createBuiltinExtensionList();
void removeExtension();
void activateRemoteTab(bool active);
void addClientCertificate();
Expand Down
14 changes: 14 additions & 0 deletions src/PreferencesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1846,6 +1846,20 @@ Can be set to 0 for disabling completion.</string>
</item>
</layout>
</item>
<item>
<widget class="QLabel" name="labelBuiltinExtensions">
<property name="text">
<string>Select built-in extensions to load for every database:</string>
</property>
</widget>
</item>
<item>
<widget class="QListWidget" name="listBuiltinExtensions">
<property name="enabled">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="checkRegexDisabled">
<property name="toolTip">
Expand Down
10 changes: 10 additions & 0 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2167,6 +2167,16 @@ void DBBrowserDB::loadExtensionsFromSettings()
if(loadExtension(ext) == false)
QMessageBox::warning(nullptr, QApplication::applicationName(), tr("Error loading extension: %1").arg(lastError()));
}

const QVariantMap builtinList = Settings::getValue("extensions", "builtin").toMap();
for(const QString& ext : builtinList.keys())
{
if(builtinList.value(ext).toBool())
{
if(loadExtension(ext) == false)
QMessageBox::warning(nullptr, QApplication::applicationName(), tr("Error loading built-in extension: %1").arg(lastError()));
}
}
}

std::vector<std::pair<std::string, std::string>> DBBrowserDB::queryColumnInformation(const std::string& schema_name, const std::string& object_name) const
Expand Down