mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
PreferencesDialog: Add new tab for extension loading
Add new settings to preferences dialog for automated loading of extensions for all databases.
This commit is contained in:
@@ -148,6 +148,7 @@ void MainWindow::fileOpen(const QString & fileName)
|
||||
resetBrowser();
|
||||
if(ui->mainTab->currentIndex() == 2)
|
||||
loadPragmas();
|
||||
loadExtensionsFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -848,6 +849,7 @@ void MainWindow::openPreferences()
|
||||
createSyntaxHighlighters();
|
||||
populateStructure();
|
||||
resetBrowser();
|
||||
loadExtensionsFromSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1176,3 +1178,13 @@ void MainWindow::loadExtension()
|
||||
else
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastErrorMessage));
|
||||
}
|
||||
|
||||
void MainWindow::loadExtensionsFromSettings()
|
||||
{
|
||||
QStringList list = PreferencesDialog::getSettingsValue("extensions", "list").toStringList();
|
||||
foreach(QString ext, list)
|
||||
{
|
||||
if(db.loadExtension(ext) == false)
|
||||
QMessageBox::warning(this, QApplication::applicationName(), tr("Error loading extension: %1").arg(db.lastErrorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,6 +80,7 @@ private:
|
||||
void updateRecentFileActions();
|
||||
void setCurrentFile(const QString& fileName);
|
||||
void activateFields(bool enable = true);
|
||||
void loadExtensionsFromSettings();
|
||||
|
||||
protected:
|
||||
void closeEvent(QCloseEvent *);
|
||||
|
||||
@@ -57,6 +57,8 @@ void PreferencesDialog::loadSettings()
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(4, getSettingsValue("syntaxhighlighter", name + "_italic").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(5, getSettingsValue("syntaxhighlighter", name + "_underline").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
|
||||
ui->listExtensions->addItems(getSettingsValue("extensions", "list").toStringList());
|
||||
}
|
||||
|
||||
void PreferencesDialog::saveSettings()
|
||||
@@ -75,6 +77,11 @@ void PreferencesDialog::saveSettings()
|
||||
setSettingsValue("syntaxhighlighter", name + "_underline", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(5) == Qt::Checked);
|
||||
}
|
||||
|
||||
QStringList extList;
|
||||
foreach(QListWidgetItem* item, ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
|
||||
extList.append(item->text());
|
||||
setSettingsValue("extensions", "list", extList);
|
||||
|
||||
accept();
|
||||
}
|
||||
|
||||
@@ -173,6 +180,10 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
|
||||
}
|
||||
}
|
||||
|
||||
// extensions/list?
|
||||
if(group == "extensions" && name == "list")
|
||||
return QStringList();
|
||||
|
||||
// Unknown combination of group and name? Return an invalid QVariant!
|
||||
return QVariant();
|
||||
}
|
||||
@@ -190,3 +201,21 @@ void PreferencesDialog::showColourDialog(QTreeWidgetItem* item, int column)
|
||||
item->setText(column, colour.name());
|
||||
}
|
||||
}
|
||||
|
||||
void PreferencesDialog::addExtension()
|
||||
{
|
||||
QString file = QFileDialog::getOpenFileName(
|
||||
this,
|
||||
tr("Select extension file"),
|
||||
PreferencesDialog::getSettingsValue("db", "defaultlocation").toString(),
|
||||
tr("Extensions(*.so *.dll);;All files(*)"));
|
||||
|
||||
if(QFile::exists(file))
|
||||
ui->listExtensions->addItem(file);
|
||||
}
|
||||
|
||||
void PreferencesDialog::removeExtension()
|
||||
{
|
||||
if(ui->listExtensions->currentIndex().isValid())
|
||||
ui->listExtensions->takeItem(ui->listExtensions->currentIndex().row());
|
||||
}
|
||||
|
||||
@@ -23,10 +23,13 @@ public:
|
||||
static void setSettingsValue(const QString& group, const QString& name, const QVariant& value);
|
||||
|
||||
private slots:
|
||||
virtual void chooseLocation();
|
||||
virtual void loadSettings();
|
||||
virtual void saveSettings();
|
||||
|
||||
virtual void chooseLocation();
|
||||
virtual void showColourDialog(QTreeWidgetItem* item, int column);
|
||||
virtual void addExtension();
|
||||
virtual void removeExtension();
|
||||
|
||||
private:
|
||||
Ui::PreferencesDialog *ui;
|
||||
|
||||
@@ -271,6 +271,73 @@
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<attribute name="title">
|
||||
<string>&Extensions</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Select extensions to load for every database:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QListWidget" name="listExtensions">
|
||||
<property name="editTriggers">
|
||||
<set>QAbstractItemView::NoEditTriggers</set>
|
||||
</property>
|
||||
<property name="showDropIndicator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonAddExtension">
|
||||
<property name="toolTip">
|
||||
<string>Add extension</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/icons.qrc">
|
||||
<normaloff>:/icons/load_extension</normaloff>:/icons/load_extension</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="buttonRemoveExtension">
|
||||
<property name="toolTip">
|
||||
<string>Remove extension</string>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="icons/icons.qrc">
|
||||
<normaloff>:/icons/remove_extension</normaloff>:/icons/remove_extension</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
@@ -295,7 +362,9 @@
|
||||
<tabstop>treeSyntaxHighlighting</tabstop>
|
||||
<tabstop>buttonBox</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<resources>
|
||||
<include location="icons/icons.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
@@ -361,10 +430,44 @@
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonAddExtension</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PreferencesDialog</receiver>
|
||||
<slot>addExtension()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>464</x>
|
||||
<y>64</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>245</x>
|
||||
<y>137</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonRemoveExtension</sender>
|
||||
<signal>clicked()</signal>
|
||||
<receiver>PreferencesDialog</receiver>
|
||||
<slot>removeExtension()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>464</x>
|
||||
<y>93</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>245</x>
|
||||
<y>137</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
<slots>
|
||||
<slot>saveSettings()</slot>
|
||||
<slot>chooseLocation()</slot>
|
||||
<slot>showColourDialog(QTreeWidgetItem*,int)</slot>
|
||||
<slot>addExtension()</slot>
|
||||
<slot>removeExtension()</slot>
|
||||
</slots>
|
||||
</ui>
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
<file alias="save_sql">page_save.png</file>
|
||||
<file alias="open_sql">page_white_database.png</file>
|
||||
<file alias="load_extension">plugin_add.png</file>
|
||||
<file alias="remove_extension">plugin_delete.png</file>
|
||||
</qresource>
|
||||
<qresource prefix="/oldimages">
|
||||
<file alias="128">oldimages/128.png</file>
|
||||
|
||||
BIN
src/icons/plugin_delete.png
Normal file
BIN
src/icons/plugin_delete.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 692 B |
Reference in New Issue
Block a user