mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-20 02:50:46 -06:00
Rename all the settings accessor functions
Rename the settings accessor functions from Settings::getSettingsValue() (and similar) to Settings::getValue() (and similar). The 'Settings' bit seems a bit redundant and costs a lot of screen space.
This commit is contained in:
@@ -22,7 +22,7 @@ Application::Application(int& argc, char** argv) :
|
||||
|
||||
// Load translations
|
||||
bool ok;
|
||||
QString name = Settings::getSettingsValue("General", "language").toString();
|
||||
QString name = Settings::getValue("General", "language").toString();
|
||||
|
||||
// First of all try to load the application translation file.
|
||||
m_translatorApp = new QTranslator(this);
|
||||
@@ -34,7 +34,7 @@ Application::Application(int& argc, char** argv) :
|
||||
}
|
||||
|
||||
if (ok == true) {
|
||||
Settings::setSettingsValue("General", "language", name);
|
||||
Settings::setValue("General", "language", name);
|
||||
installTranslator(m_translatorApp);
|
||||
|
||||
// The application translation file has been found and loaded.
|
||||
@@ -54,7 +54,7 @@ Application::Application(int& argc, char** argv) :
|
||||
// Set the correct locale so that the program won't erroneously detect
|
||||
// a language change when the user toggles settings for the first time.
|
||||
// (it also prevents the program from always looking for a translation on launch)
|
||||
Settings::setSettingsValue("General", "language", "en_US");
|
||||
Settings::setValue("General", "language", "en_US");
|
||||
}
|
||||
|
||||
// Parse command line
|
||||
|
||||
@@ -40,7 +40,7 @@ QVariant DbStructureModel::data(const QModelIndex& index, int role) const
|
||||
switch(role)
|
||||
{
|
||||
case Qt::DisplayRole:
|
||||
return Settings::getSettingsValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
|
||||
return Settings::getValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
|
||||
case Qt::EditRole:
|
||||
case Qt::ToolTipRole: // Don't modify the text when it's supposed to be shown in a tooltip
|
||||
return item->text(index.column());
|
||||
|
||||
@@ -544,8 +544,8 @@ QString EditDialog::humanReadableSize(double byteCount)
|
||||
void EditDialog::reloadSettings()
|
||||
{
|
||||
// Set the font for the text and hex editors
|
||||
QFont editorFont(Settings::getSettingsValue("databrowser", "font").toString());
|
||||
editorFont.setPointSize(Settings::getSettingsValue("databrowser", "fontsize").toInt());
|
||||
QFont editorFont(Settings::getValue("databrowser", "font").toString());
|
||||
editorFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
|
||||
ui->editorText->setFont(editorFont);
|
||||
hexEdit->setFont(editorFont);
|
||||
}
|
||||
|
||||
@@ -513,7 +513,7 @@ void EditTableDialog::addField()
|
||||
typeBox->setEditable(true);
|
||||
typeBox->addItems(sqlb::Field::Datatypes);
|
||||
|
||||
int defaultFieldTypeIndex = Settings::getSettingsValue("db", "defaultfieldtype").toInt();
|
||||
int defaultFieldTypeIndex = Settings::getValue("db", "defaultfieldtype").toInt();
|
||||
|
||||
if (defaultFieldTypeIndex < sqlb::Field::Datatypes.count())
|
||||
{
|
||||
|
||||
@@ -26,11 +26,11 @@ ExportDataDialog::ExportDataDialog(DBBrowserDB& db, ExportFormats format, QWidge
|
||||
ui->stackFormat->setCurrentIndex(format);
|
||||
|
||||
// Retrieve the saved dialog preferences
|
||||
ui->checkHeader->setChecked(Settings::getSettingsValue("exportcsv", "firstrowheader").toBool());
|
||||
setSeparatorChar(Settings::getSettingsValue("exportcsv", "separator").toInt());
|
||||
setQuoteChar(Settings::getSettingsValue("exportcsv", "quotecharacter").toInt());
|
||||
setNewLineString(Settings::getSettingsValue("exportcsv", "newlinecharacters").toString());
|
||||
ui->checkPrettyPrint->setChecked(Settings::getSettingsValue("exportjson", "prettyprint").toBool());
|
||||
ui->checkHeader->setChecked(Settings::getValue("exportcsv", "firstrowheader").toBool());
|
||||
setSeparatorChar(Settings::getValue("exportcsv", "separator").toInt());
|
||||
setQuoteChar(Settings::getValue("exportcsv", "quotecharacter").toInt());
|
||||
setNewLineString(Settings::getValue("exportcsv", "newlinecharacters").toString());
|
||||
ui->checkPrettyPrint->setChecked(Settings::getValue("exportjson", "prettyprint").toBool());
|
||||
|
||||
// Update the visible/hidden status of the "Other" line edit fields
|
||||
showCustomCharEdits();
|
||||
@@ -316,11 +316,11 @@ void ExportDataDialog::accept()
|
||||
}
|
||||
|
||||
// Save the dialog preferences for future use
|
||||
Settings::setSettingsValue("exportcsv", "firstrowheader", ui->checkHeader->isChecked());
|
||||
Settings::setSettingsValue("exportjson", "prettyprint", ui->checkPrettyPrint->isChecked());
|
||||
Settings::setSettingsValue("exportcsv", "separator", currentSeparatorChar());
|
||||
Settings::setSettingsValue("exportcsv", "quotecharacter", currentQuoteChar());
|
||||
Settings::setSettingsValue("exportcsv", "newlinecharacters", currentNewLineString());
|
||||
Settings::setValue("exportcsv", "firstrowheader", ui->checkHeader->isChecked());
|
||||
Settings::setValue("exportjson", "prettyprint", ui->checkPrettyPrint->isChecked());
|
||||
Settings::setValue("exportcsv", "separator", currentSeparatorChar());
|
||||
Settings::setValue("exportcsv", "quotecharacter", currentQuoteChar());
|
||||
Settings::setValue("exportcsv", "newlinecharacters", currentNewLineString());
|
||||
|
||||
// Notify the user the export has completed
|
||||
QMessageBox::information(this, QApplication::applicationName(), tr("Export completed."));
|
||||
|
||||
@@ -31,13 +31,13 @@ QString FileDialog::getExistingDirectory(QWidget* parent, const QString& caption
|
||||
|
||||
QString FileDialog::getFileDialogPath()
|
||||
{
|
||||
switch(Settings::getSettingsValue("db", "savedefaultlocation").toInt())
|
||||
switch(Settings::getValue("db", "savedefaultlocation").toInt())
|
||||
{
|
||||
case 0: // Remember last location
|
||||
case 2: // Remember last location for current session only
|
||||
return Settings::getSettingsValue("db", "lastlocation").toString();
|
||||
return Settings::getValue("db", "lastlocation").toString();
|
||||
case 1: // Always use this locations
|
||||
return Settings::getSettingsValue("db", "defaultlocation").toString();
|
||||
return Settings::getValue("db", "defaultlocation").toString();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
@@ -47,13 +47,13 @@ void FileDialog::setFileDialogPath(const QString& new_path)
|
||||
{
|
||||
QString dir = QFileInfo(new_path).absolutePath();
|
||||
|
||||
switch(Settings::getSettingsValue("db", "savedefaultlocation").toInt())
|
||||
switch(Settings::getValue("db", "savedefaultlocation").toInt())
|
||||
{
|
||||
case 0: // Remember last location
|
||||
Settings::setSettingsValue("db", "lastlocation", dir);
|
||||
Settings::setValue("db", "lastlocation", dir);
|
||||
break;
|
||||
case 2: // Remember last location for current session only
|
||||
Settings::setSettingsValue("db", "lastlocation", dir, true);
|
||||
Settings::setValue("db", "lastlocation", dir, true);
|
||||
break;
|
||||
case 1: // Always use this locations
|
||||
break; // Do nothing
|
||||
|
||||
@@ -16,7 +16,7 @@ FilterLineEdit::FilterLineEdit(QWidget* parent, QList<FilterLineEdit*>* filters,
|
||||
// is (re)started. As soon as the user stops typing the timer has a chance to trigger and call the
|
||||
// delayedSignalTimerTriggered() method which then stops the timer and emits the delayed signal.
|
||||
delaySignalTimer = new QTimer(this);
|
||||
delaySignalTimer->setInterval(Settings::getSettingsValue("databrowser", "filter_delay").toInt()); // This is the milliseconds of not-typing we want to wait before triggering
|
||||
delaySignalTimer->setInterval(Settings::getValue("databrowser", "filter_delay").toInt()); // This is the milliseconds of not-typing we want to wait before triggering
|
||||
connect(this, SIGNAL(textChanged(QString)), delaySignalTimer, SLOT(start()));
|
||||
connect(delaySignalTimer, SIGNAL(timeout()), this, SLOT(delayedSignalTimerTriggered()));
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
MainWindow::MainWindow(QWidget* parent)
|
||||
: QMainWindow(parent),
|
||||
ui(new Ui::MainWindow),
|
||||
m_browseTableModel(new SqliteTableModel(db, this, Settings::getSettingsValue("db", "prefetchsize").toInt())),
|
||||
m_browseTableModel(new SqliteTableModel(db, this, Settings::getValue("db", "prefetchsize").toInt())),
|
||||
m_currentTabTableModel(m_browseTableModel),
|
||||
m_remoteDb(new RemoteDatabase),
|
||||
editDock(new EditDialog(this)),
|
||||
@@ -111,11 +111,11 @@ void MainWindow::init()
|
||||
ui->dockRemote->setWidget(remoteDock);
|
||||
|
||||
// Restore window geometry
|
||||
restoreGeometry(Settings::getSettingsValue("MainWindow", "geometry").toByteArray());
|
||||
restoreState(Settings::getSettingsValue("MainWindow", "windowState").toByteArray());
|
||||
restoreGeometry(Settings::getValue("MainWindow", "geometry").toByteArray());
|
||||
restoreState(Settings::getValue("MainWindow", "windowState").toByteArray());
|
||||
|
||||
// Restore dock state settings
|
||||
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(Settings::getSettingsValue("SQLLogDock", "Log").toString()));
|
||||
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(Settings::getValue("SQLLogDock", "Log").toString()));
|
||||
|
||||
// Add keyboard shortcuts
|
||||
QList<QKeySequence> shortcuts = ui->actionExecuteSql->shortcuts();
|
||||
@@ -255,7 +255,7 @@ void MainWindow::init()
|
||||
|
||||
#ifdef CHECKNEWVERSION
|
||||
// Check for a new version if automatic update check aren't disabled in the settings dialog
|
||||
if(Settings::getSettingsValue("checkversion", "enabled").toBool())
|
||||
if(Settings::getValue("checkversion", "enabled").toBool())
|
||||
{
|
||||
m_remoteDb->fetch("https://raw.githubusercontent.com/sqlitebrowser/sqlitebrowser/master/currentrelease",
|
||||
RemoteDatabase::RequestTypeNewVersionCheck);
|
||||
@@ -569,9 +569,9 @@ void MainWindow::closeEvent( QCloseEvent* event )
|
||||
{
|
||||
if(db.close())
|
||||
{
|
||||
Settings::setSettingsValue("MainWindow", "geometry", saveGeometry());
|
||||
Settings::setSettingsValue("MainWindow", "windowState", saveState());
|
||||
Settings::setSettingsValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
|
||||
Settings::setValue("MainWindow", "geometry", saveGeometry());
|
||||
Settings::setValue("MainWindow", "windowState", saveState());
|
||||
Settings::setValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
|
||||
QMainWindow::closeEvent(event);
|
||||
} else {
|
||||
event->ignore();
|
||||
@@ -1314,7 +1314,7 @@ void MainWindow::openRecentFile()
|
||||
void MainWindow::updateRecentFileActions()
|
||||
{
|
||||
// Get recent files list from settings
|
||||
QStringList files = Settings::getSettingsValue("General", "recentFileList").toStringList();
|
||||
QStringList files = Settings::getValue("General", "recentFileList").toStringList();
|
||||
|
||||
// Check if files still exist and remove any non-existant file
|
||||
for(int i=0;i<files.size();i++)
|
||||
@@ -1328,7 +1328,7 @@ void MainWindow::updateRecentFileActions()
|
||||
}
|
||||
|
||||
// Store updated list
|
||||
Settings::setSettingsValue("General", "recentFileList", files);
|
||||
Settings::setValue("General", "recentFileList", files);
|
||||
|
||||
int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
|
||||
|
||||
@@ -1358,7 +1358,7 @@ void MainWindow::setCurrentFile(const QString &fileName)
|
||||
|
||||
void MainWindow::addToRecentFilesMenu(const QString& filename)
|
||||
{
|
||||
QStringList files = Settings::getSettingsValue("General", "recentFileList").toStringList();
|
||||
QStringList files = Settings::getValue("General", "recentFileList").toStringList();
|
||||
QFileInfo info(filename);
|
||||
|
||||
files.removeAll(info.absoluteFilePath());
|
||||
@@ -1366,7 +1366,7 @@ void MainWindow::addToRecentFilesMenu(const QString& filename)
|
||||
while (files.size() > MaxRecentFiles)
|
||||
files.removeLast();
|
||||
|
||||
Settings::setSettingsValue("General", "recentFileList", files);
|
||||
Settings::setValue("General", "recentFileList", files);
|
||||
|
||||
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
|
||||
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
|
||||
@@ -1679,7 +1679,7 @@ void MainWindow::loadExtensionsFromSettings()
|
||||
if(!db.isOpen())
|
||||
return;
|
||||
|
||||
QStringList list = Settings::getSettingsValue("extensions", "list").toStringList();
|
||||
QStringList list = Settings::getValue("extensions", "list").toStringList();
|
||||
foreach(QString ext, list)
|
||||
{
|
||||
if(db.loadExtension(ext) == false)
|
||||
@@ -1690,19 +1690,19 @@ void MainWindow::loadExtensionsFromSettings()
|
||||
void MainWindow::reloadSettings()
|
||||
{
|
||||
// Set data browser font
|
||||
QFont dataBrowserFont(Settings::getSettingsValue("databrowser", "font").toString());
|
||||
dataBrowserFont.setPointSize(Settings::getSettingsValue("databrowser", "fontsize").toInt());
|
||||
QFont dataBrowserFont(Settings::getValue("databrowser", "font").toString());
|
||||
dataBrowserFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
|
||||
ui->dataTable->setFont(dataBrowserFont);
|
||||
|
||||
// Set prefetch sizes for lazy population of table models
|
||||
m_browseTableModel->setChunkSize(Settings::getSettingsValue("db", "prefetchsize").toInt());
|
||||
m_browseTableModel->setChunkSize(Settings::getValue("db", "prefetchsize").toInt());
|
||||
for(int i=0;i<ui->tabSqlAreas->count();++i)
|
||||
qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(i))->reloadSettings();
|
||||
|
||||
// Prepare log font
|
||||
QFont logfont("Monospace");
|
||||
logfont.setStyleHint(QFont::TypeWriter);
|
||||
logfont.setPointSize(Settings::getSettingsValue("log", "fontsize").toInt());
|
||||
logfont.setPointSize(Settings::getValue("log", "fontsize").toInt());
|
||||
|
||||
// Set font for SQL logs and edit dialog
|
||||
ui->editLogApplication->reloadSettings();
|
||||
@@ -1719,7 +1719,7 @@ void MainWindow::reloadSettings()
|
||||
populateTable();
|
||||
|
||||
// Hide or show the File → Remote menu as needed
|
||||
bool showRemoteActions = Settings::getSettingsValue("remote", "active").toBool();
|
||||
bool showRemoteActions = Settings::getValue("remote", "active").toBool();
|
||||
ui->menuRemote->menuAction()->setVisible(showRemoteActions);
|
||||
ui->viewMenu->actions().at(4)->setVisible(showRemoteActions);
|
||||
if(!showRemoteActions)
|
||||
@@ -1795,7 +1795,7 @@ void MainWindow::on_actionSave_Remote_triggered()
|
||||
QString url = QInputDialog::getText(this, qApp->applicationName(), tr("Please enter the URL of the database file to save."));
|
||||
if(!url.isEmpty())
|
||||
{
|
||||
QStringList certs = Settings::getSettingsValue("remote", "client_certificates").toStringList();
|
||||
QStringList certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
m_remoteDb->push(db.currentFile(), url, (certs.size() ? certs.at(0) : ""));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,17 +17,17 @@ PlotDock::PlotDock(QWidget* parent)
|
||||
ui->treePlotColumns->setSelectionMode(QAbstractItemView::NoSelection);
|
||||
|
||||
// Restore state
|
||||
ui->splitterForPlot->restoreState(Settings::getSettingsValue("PlotDock", "splitterSize").toByteArray());
|
||||
ui->comboLineType->setCurrentIndex(Settings::getSettingsValue("PlotDock", "lineType").toInt());
|
||||
ui->comboPointShape->setCurrentIndex(Settings::getSettingsValue("PlotDock", "pointShape").toInt());
|
||||
ui->splitterForPlot->restoreState(Settings::getValue("PlotDock", "splitterSize").toByteArray());
|
||||
ui->comboLineType->setCurrentIndex(Settings::getValue("PlotDock", "lineType").toInt());
|
||||
ui->comboPointShape->setCurrentIndex(Settings::getValue("PlotDock", "pointShape").toInt());
|
||||
}
|
||||
|
||||
PlotDock::~PlotDock()
|
||||
{
|
||||
// Save state
|
||||
Settings::setSettingsValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
|
||||
Settings::setSettingsValue("PlotDock", "lineType", ui->comboLineType->currentIndex());
|
||||
Settings::setSettingsValue("PlotDock", "pointShape", ui->comboPointShape->currentIndex());
|
||||
Settings::setValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
|
||||
Settings::setValue("PlotDock", "lineType", ui->comboLineType->currentIndex());
|
||||
Settings::setValue("PlotDock", "pointShape", ui->comboPointShape->currentIndex());
|
||||
|
||||
// Finally, delete all widgets
|
||||
delete ui;
|
||||
|
||||
@@ -57,19 +57,19 @@ void PreferencesDialog::chooseLocation()
|
||||
|
||||
void PreferencesDialog::loadSettings()
|
||||
{
|
||||
ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(Settings::getSettingsValue("db", "defaultencoding").toString(), Qt::MatchFixedString));
|
||||
ui->comboDefaultLocation->setCurrentIndex(Settings::getSettingsValue("db", "savedefaultlocation").toInt());
|
||||
ui->locationEdit->setText(Settings::getSettingsValue("db", "defaultlocation").toString());
|
||||
ui->checkUpdates->setChecked(Settings::getSettingsValue("checkversion", "enabled").toBool());
|
||||
ui->encodingComboBox->setCurrentIndex(ui->encodingComboBox->findText(Settings::getValue("db", "defaultencoding").toString(), Qt::MatchFixedString));
|
||||
ui->comboDefaultLocation->setCurrentIndex(Settings::getValue("db", "savedefaultlocation").toInt());
|
||||
ui->locationEdit->setText(Settings::getValue("db", "defaultlocation").toString());
|
||||
ui->checkUpdates->setChecked(Settings::getValue("checkversion", "enabled").toBool());
|
||||
|
||||
ui->checkHideSchemaLinebreaks->setChecked(Settings::getSettingsValue("db", "hideschemalinebreaks").toBool());
|
||||
ui->foreignKeysCheckBox->setChecked(Settings::getSettingsValue("db", "foreignkeys").toBool());
|
||||
ui->spinPrefetchSize->setValue(Settings::getSettingsValue("db", "prefetchsize").toInt());
|
||||
ui->editDatabaseDefaultSqlText->setText(Settings::getSettingsValue("db", "defaultsqltext").toString());
|
||||
ui->checkHideSchemaLinebreaks->setChecked(Settings::getValue("db", "hideschemalinebreaks").toBool());
|
||||
ui->foreignKeysCheckBox->setChecked(Settings::getValue("db", "foreignkeys").toBool());
|
||||
ui->spinPrefetchSize->setValue(Settings::getValue("db", "prefetchsize").toInt());
|
||||
ui->editDatabaseDefaultSqlText->setText(Settings::getValue("db", "defaultsqltext").toString());
|
||||
|
||||
ui->defaultFieldTypeComboBox->addItems(sqlb::Field::Datatypes);
|
||||
|
||||
int defaultFieldTypeIndex = Settings::getSettingsValue("db", "defaultfieldtype").toInt();
|
||||
int defaultFieldTypeIndex = Settings::getValue("db", "defaultfieldtype").toInt();
|
||||
|
||||
if (defaultFieldTypeIndex < sqlb::Field::Datatypes.count())
|
||||
{
|
||||
@@ -77,12 +77,12 @@ void PreferencesDialog::loadSettings()
|
||||
}
|
||||
|
||||
// Gracefully handle the preferred Data Browser font not being available
|
||||
int matchingFont = ui->comboDataBrowserFont->findText(Settings::getSettingsValue("databrowser", "font").toString(), Qt::MatchExactly);
|
||||
int matchingFont = ui->comboDataBrowserFont->findText(Settings::getValue("databrowser", "font").toString(), Qt::MatchExactly);
|
||||
if (matchingFont == -1)
|
||||
matchingFont = ui->comboDataBrowserFont->findText(Settings::getSettingsDefaultValue("databrowser", "font").toString());
|
||||
matchingFont = ui->comboDataBrowserFont->findText(Settings::getDefaultValue("databrowser", "font").toString());
|
||||
ui->comboDataBrowserFont->setCurrentIndex(matchingFont);
|
||||
|
||||
ui->spinDataBrowserFontSize->setValue(Settings::getSettingsValue("databrowser", "fontsize").toInt());
|
||||
ui->spinDataBrowserFontSize->setValue(Settings::getValue("databrowser", "fontsize").toInt());
|
||||
loadColorSetting(ui->fr_null_fg, "null_fg");
|
||||
loadColorSetting(ui->fr_null_bg, "null_bg");
|
||||
loadColorSetting(ui->fr_reg_fg, "reg_fg");
|
||||
@@ -90,28 +90,28 @@ void PreferencesDialog::loadSettings()
|
||||
loadColorSetting(ui->fr_bin_fg, "bin_fg");
|
||||
loadColorSetting(ui->fr_bin_bg, "bin_bg");
|
||||
|
||||
ui->spinSymbolLimit->setValue(Settings::getSettingsValue("databrowser", "symbol_limit").toInt());
|
||||
ui->txtNull->setText(Settings::getSettingsValue("databrowser", "null_text").toString());
|
||||
ui->editFilterEscape->setText(Settings::getSettingsValue("databrowser", "filter_escape").toString());
|
||||
ui->spinFilterDelay->setValue(Settings::getSettingsValue("databrowser", "filter_delay").toInt());
|
||||
ui->spinSymbolLimit->setValue(Settings::getValue("databrowser", "symbol_limit").toInt());
|
||||
ui->txtNull->setText(Settings::getValue("databrowser", "null_text").toString());
|
||||
ui->editFilterEscape->setText(Settings::getValue("databrowser", "filter_escape").toString());
|
||||
ui->spinFilterDelay->setValue(Settings::getValue("databrowser", "filter_delay").toInt());
|
||||
|
||||
for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i)
|
||||
{
|
||||
QString name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0);
|
||||
QString colorname = Settings::getSettingsValue("syntaxhighlighter", name + "_colour").toString();
|
||||
QString colorname = Settings::getValue("syntaxhighlighter", name + "_colour").toString();
|
||||
QColor color = QColor(colorname);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setTextColor(2, color);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setBackgroundColor(2, color);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setText(2, colorname);
|
||||
if (name != "null") {
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(3, Settings::getSettingsValue("syntaxhighlighter", name + "_bold").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(4, Settings::getSettingsValue("syntaxhighlighter", name + "_italic").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(5, Settings::getSettingsValue("syntaxhighlighter", name + "_underline").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(3, Settings::getValue("syntaxhighlighter", name + "_bold").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(4, Settings::getValue("syntaxhighlighter", name + "_italic").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
ui->treeSyntaxHighlighting->topLevelItem(i)->setCheckState(5, Settings::getValue("syntaxhighlighter", name + "_underline").toBool() ? Qt::Checked : Qt::Unchecked);
|
||||
}
|
||||
}
|
||||
|
||||
// Remote settings
|
||||
ui->checkUseRemotes->setChecked(Settings::getSettingsValue("remote", "active").toBool());
|
||||
ui->checkUseRemotes->setChecked(Settings::getValue("remote", "active").toBool());
|
||||
{
|
||||
auto ca_certs = static_cast<Application*>(qApp)->mainWindow()->getRemote().caCertificates();
|
||||
ui->tableCaCerts->setRowCount(ca_certs.size());
|
||||
@@ -141,7 +141,7 @@ void PreferencesDialog::loadSettings()
|
||||
}
|
||||
}
|
||||
{
|
||||
QStringList client_certs = Settings::getSettingsValue("remote", "client_certificates").toStringList();
|
||||
QStringList client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
foreach(const QString& file, client_certs)
|
||||
{
|
||||
auto certs = QSslCertificate::fromPath(file);
|
||||
@@ -149,78 +149,78 @@ void PreferencesDialog::loadSettings()
|
||||
addClientCertToTable(file, cert);
|
||||
}
|
||||
}
|
||||
ui->editRemoteCloneDirectory->setText(Settings::getSettingsValue("remote", "clonedirectory").toString());
|
||||
ui->editRemoteCloneDirectory->setText(Settings::getValue("remote", "clonedirectory").toString());
|
||||
|
||||
// Gracefully handle the preferred Editor font not being available
|
||||
matchingFont = ui->comboEditorFont->findText(Settings::getSettingsValue("editor", "font").toString(), Qt::MatchExactly);
|
||||
matchingFont = ui->comboEditorFont->findText(Settings::getValue("editor", "font").toString(), Qt::MatchExactly);
|
||||
if (matchingFont == -1)
|
||||
matchingFont = ui->comboDataBrowserFont->findText(Settings::getSettingsDefaultValue("editor", "font").toString());
|
||||
matchingFont = ui->comboDataBrowserFont->findText(Settings::getDefaultValue("editor", "font").toString());
|
||||
ui->comboEditorFont->setCurrentIndex(matchingFont);
|
||||
|
||||
ui->spinEditorFontSize->setValue(Settings::getSettingsValue("editor", "fontsize").toInt());
|
||||
ui->spinTabSize->setValue(Settings::getSettingsValue("editor", "tabsize").toInt());
|
||||
ui->spinLogFontSize->setValue(Settings::getSettingsValue("log", "fontsize").toInt());
|
||||
ui->checkAutoCompletion->setChecked(Settings::getSettingsValue("editor", "auto_completion").toBool());
|
||||
ui->checkErrorIndicators->setChecked(Settings::getSettingsValue("editor", "error_indicators").toBool());
|
||||
ui->checkHorizontalTiling->setChecked(Settings::getSettingsValue("editor", "horizontal_tiling").toBool());
|
||||
ui->spinEditorFontSize->setValue(Settings::getValue("editor", "fontsize").toInt());
|
||||
ui->spinTabSize->setValue(Settings::getValue("editor", "tabsize").toInt());
|
||||
ui->spinLogFontSize->setValue(Settings::getValue("log", "fontsize").toInt());
|
||||
ui->checkAutoCompletion->setChecked(Settings::getValue("editor", "auto_completion").toBool());
|
||||
ui->checkErrorIndicators->setChecked(Settings::getValue("editor", "error_indicators").toBool());
|
||||
ui->checkHorizontalTiling->setChecked(Settings::getValue("editor", "horizontal_tiling").toBool());
|
||||
|
||||
ui->listExtensions->addItems(Settings::getSettingsValue("extensions", "list").toStringList());
|
||||
ui->checkRegexDisabled->setChecked(Settings::getSettingsValue("extensions", "disableregex").toBool());
|
||||
ui->listExtensions->addItems(Settings::getValue("extensions", "list").toStringList());
|
||||
ui->checkRegexDisabled->setChecked(Settings::getValue("extensions", "disableregex").toBool());
|
||||
fillLanguageBox();
|
||||
}
|
||||
|
||||
void PreferencesDialog::saveSettings()
|
||||
{
|
||||
Settings::setSettingsValue("db", "defaultencoding", ui->encodingComboBox->currentText());
|
||||
Settings::setSettingsValue("db", "defaultlocation", ui->locationEdit->text());
|
||||
Settings::setSettingsValue("db", "savedefaultlocation", ui->comboDefaultLocation->currentIndex());
|
||||
Settings::setSettingsValue("db", "hideschemalinebreaks", ui->checkHideSchemaLinebreaks->isChecked());
|
||||
Settings::setSettingsValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked());
|
||||
Settings::setSettingsValue("db", "prefetchsize", ui->spinPrefetchSize->value());
|
||||
Settings::setSettingsValue("db", "defaultsqltext", ui->editDatabaseDefaultSqlText->text());
|
||||
Settings::setValue("db", "defaultencoding", ui->encodingComboBox->currentText());
|
||||
Settings::setValue("db", "defaultlocation", ui->locationEdit->text());
|
||||
Settings::setValue("db", "savedefaultlocation", ui->comboDefaultLocation->currentIndex());
|
||||
Settings::setValue("db", "hideschemalinebreaks", ui->checkHideSchemaLinebreaks->isChecked());
|
||||
Settings::setValue("db", "foreignkeys", ui->foreignKeysCheckBox->isChecked());
|
||||
Settings::setValue("db", "prefetchsize", ui->spinPrefetchSize->value());
|
||||
Settings::setValue("db", "defaultsqltext", ui->editDatabaseDefaultSqlText->text());
|
||||
|
||||
Settings::setSettingsValue("db", "defaultfieldtype", ui->defaultFieldTypeComboBox->currentIndex());
|
||||
Settings::setValue("db", "defaultfieldtype", ui->defaultFieldTypeComboBox->currentIndex());
|
||||
|
||||
Settings::setSettingsValue("checkversion", "enabled", ui->checkUpdates->isChecked());
|
||||
Settings::setValue("checkversion", "enabled", ui->checkUpdates->isChecked());
|
||||
|
||||
Settings::setSettingsValue("databrowser", "font", ui->comboDataBrowserFont->currentText());
|
||||
Settings::setSettingsValue("databrowser", "fontsize", ui->spinDataBrowserFontSize->value());
|
||||
Settings::setValue("databrowser", "font", ui->comboDataBrowserFont->currentText());
|
||||
Settings::setValue("databrowser", "fontsize", ui->spinDataBrowserFontSize->value());
|
||||
saveColorSetting(ui->fr_null_fg, "null_fg");
|
||||
saveColorSetting(ui->fr_null_bg, "null_bg");
|
||||
saveColorSetting(ui->fr_reg_fg, "reg_fg");
|
||||
saveColorSetting(ui->fr_reg_bg, "reg_bg");
|
||||
saveColorSetting(ui->fr_bin_fg, "bin_fg");
|
||||
saveColorSetting(ui->fr_bin_bg, "bin_bg");
|
||||
Settings::setSettingsValue("databrowser", "symbol_limit", ui->spinSymbolLimit->value());
|
||||
Settings::setSettingsValue("databrowser", "null_text", ui->txtNull->text());
|
||||
Settings::setSettingsValue("databrowser", "filter_escape", ui->editFilterEscape->text());
|
||||
Settings::setSettingsValue("databrowser", "filter_delay", ui->spinFilterDelay->value());
|
||||
Settings::setValue("databrowser", "symbol_limit", ui->spinSymbolLimit->value());
|
||||
Settings::setValue("databrowser", "null_text", ui->txtNull->text());
|
||||
Settings::setValue("databrowser", "filter_escape", ui->editFilterEscape->text());
|
||||
Settings::setValue("databrowser", "filter_delay", ui->spinFilterDelay->value());
|
||||
|
||||
for(int i=0; i < ui->treeSyntaxHighlighting->topLevelItemCount(); ++i)
|
||||
{
|
||||
QString name = ui->treeSyntaxHighlighting->topLevelItem(i)->text(0);
|
||||
Settings::setSettingsValue("syntaxhighlighter", name + "_colour", ui->treeSyntaxHighlighting->topLevelItem(i)->text(2));
|
||||
Settings::setSettingsValue("syntaxhighlighter", name + "_bold", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(3) == Qt::Checked);
|
||||
Settings::setSettingsValue("syntaxhighlighter", name + "_italic", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(4) == Qt::Checked);
|
||||
Settings::setSettingsValue("syntaxhighlighter", name + "_underline", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(5) == Qt::Checked);
|
||||
Settings::setValue("syntaxhighlighter", name + "_colour", ui->treeSyntaxHighlighting->topLevelItem(i)->text(2));
|
||||
Settings::setValue("syntaxhighlighter", name + "_bold", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(3) == Qt::Checked);
|
||||
Settings::setValue("syntaxhighlighter", name + "_italic", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(4) == Qt::Checked);
|
||||
Settings::setValue("syntaxhighlighter", name + "_underline", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(5) == Qt::Checked);
|
||||
}
|
||||
Settings::setSettingsValue("editor", "font", ui->comboEditorFont->currentText());
|
||||
Settings::setSettingsValue("editor", "fontsize", ui->spinEditorFontSize->value());
|
||||
Settings::setSettingsValue("editor", "tabsize", ui->spinTabSize->value());
|
||||
Settings::setSettingsValue("log", "fontsize", ui->spinLogFontSize->value());
|
||||
Settings::setSettingsValue("editor", "auto_completion", ui->checkAutoCompletion->isChecked());
|
||||
Settings::setSettingsValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());
|
||||
Settings::setSettingsValue("editor", "horizontal_tiling", ui->checkHorizontalTiling->isChecked());
|
||||
Settings::setValue("editor", "font", ui->comboEditorFont->currentText());
|
||||
Settings::setValue("editor", "fontsize", ui->spinEditorFontSize->value());
|
||||
Settings::setValue("editor", "tabsize", ui->spinTabSize->value());
|
||||
Settings::setValue("log", "fontsize", ui->spinLogFontSize->value());
|
||||
Settings::setValue("editor", "auto_completion", ui->checkAutoCompletion->isChecked());
|
||||
Settings::setValue("editor", "error_indicators", ui->checkErrorIndicators->isChecked());
|
||||
Settings::setValue("editor", "horizontal_tiling", ui->checkHorizontalTiling->isChecked());
|
||||
|
||||
QStringList extList;
|
||||
foreach(QListWidgetItem* item, ui->listExtensions->findItems(QString("*"), Qt::MatchWrap | Qt::MatchWildcard))
|
||||
extList.append(item->text());
|
||||
Settings::setSettingsValue("extensions", "list", extList);
|
||||
Settings::setSettingsValue("extensions", "disableregex", ui->checkRegexDisabled->isChecked());
|
||||
Settings::setValue("extensions", "list", extList);
|
||||
Settings::setValue("extensions", "disableregex", ui->checkRegexDisabled->isChecked());
|
||||
|
||||
// Save remote settings
|
||||
Settings::setSettingsValue("remote", "active", ui->checkUseRemotes->isChecked());
|
||||
QStringList old_client_certs = Settings::getSettingsValue("remote", "client_certificates").toStringList();
|
||||
Settings::setValue("remote", "active", ui->checkUseRemotes->isChecked());
|
||||
QStringList old_client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
QStringList new_client_certs;
|
||||
for(int i=0;i<ui->tableClientCerts->rowCount();i++)
|
||||
{
|
||||
@@ -258,16 +258,16 @@ void PreferencesDialog::saveSettings()
|
||||
// Now only the deleted client certs are still in the old list. Delete the cert files associated with them.
|
||||
QFile::remove(file);
|
||||
}
|
||||
Settings::setSettingsValue("remote", "client_certificates", new_client_certs);
|
||||
Settings::setSettingsValue("remote", "clonedirectory", ui->editRemoteCloneDirectory->text());
|
||||
Settings::setValue("remote", "client_certificates", new_client_certs);
|
||||
Settings::setValue("remote", "clonedirectory", ui->editRemoteCloneDirectory->text());
|
||||
|
||||
// Warn about restarting to change language
|
||||
QVariant newLanguage = ui->languageComboBox->itemData(ui->languageComboBox->currentIndex());
|
||||
if (newLanguage != Settings::getSettingsValue("General", "language"))
|
||||
if (newLanguage != Settings::getValue("General", "language"))
|
||||
QMessageBox::information(this, QApplication::applicationName(),
|
||||
tr("The language will change after you restart the application."));
|
||||
|
||||
Settings::setSettingsValue("General", "language", newLanguage);
|
||||
Settings::setValue("General", "language", newLanguage);
|
||||
|
||||
accept();
|
||||
}
|
||||
@@ -391,7 +391,7 @@ void PreferencesDialog::fillLanguageBox()
|
||||
ui->languageComboBox->model()->sort(0);
|
||||
|
||||
// Try to select the language for the stored locale
|
||||
int index = ui->languageComboBox->findData(Settings::getSettingsValue("General", "language"),
|
||||
int index = ui->languageComboBox->findData(Settings::getValue("General", "language"),
|
||||
Qt::UserRole, Qt::MatchExactly);
|
||||
|
||||
// If there's no translation for the current locale, default to English
|
||||
@@ -412,13 +412,13 @@ void PreferencesDialog::loadColorSetting(QFrame *frame, const QString & settingN
|
||||
{
|
||||
QPalette palette = frame->palette();
|
||||
palette.setColor(frame->backgroundRole(),
|
||||
QColor(Settings::getSettingsValue("databrowser", settingName + "_colour").toString()));
|
||||
QColor(Settings::getValue("databrowser", settingName + "_colour").toString()));
|
||||
frame->setPalette(palette);
|
||||
}
|
||||
|
||||
void PreferencesDialog::saveColorSetting(QFrame *frame, const QString & settingName)
|
||||
{
|
||||
Settings::setSettingsValue("databrowser", settingName + "_colour",
|
||||
Settings::setValue("databrowser", settingName + "_colour",
|
||||
frame->palette().color(frame->backgroundRole()));
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ void RemoteDatabase::reloadSettings()
|
||||
{
|
||||
// Load all configured client certificates
|
||||
m_clientCertFiles.clear();
|
||||
auto client_certs = Settings::getSettingsValue("remote", "client_certificates").toStringList();
|
||||
auto client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
foreach(const QString& path, client_certs)
|
||||
{
|
||||
QFile file(path);
|
||||
@@ -121,7 +121,7 @@ void RemoteDatabase::gotReply(QNetworkReply* reply)
|
||||
// It's a database file.
|
||||
|
||||
// Generate a unique file name to save the file under
|
||||
QString saveFileAs = Settings::getSettingsValue("remote", "clonedirectory").toString() +
|
||||
QString saveFileAs = Settings::getValue("remote", "clonedirectory").toString() +
|
||||
QString("/%2_%1.remotedb").arg(QDateTime::currentMSecsSinceEpoch()).arg(reply->url().fileName());
|
||||
|
||||
// Save the downloaded data under the generated file name
|
||||
|
||||
@@ -31,7 +31,7 @@ void RemoteDock::reloadSettings()
|
||||
{
|
||||
// Load list of client certs
|
||||
ui->comboUser->clear();
|
||||
QStringList client_certs = Settings::getSettingsValue("remote", "client_certificates").toStringList();
|
||||
QStringList client_certs = Settings::getValue("remote", "client_certificates").toStringList();
|
||||
foreach(const QString& file, client_certs)
|
||||
{
|
||||
auto certs = QSslCertificate::fromPath(file);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
QHash<QString, QVariant> Settings::m_hCache;
|
||||
|
||||
QVariant Settings::getSettingsValue(const QString& group, const QString& name)
|
||||
QVariant Settings::getValue(const QString& group, const QString& name)
|
||||
{
|
||||
// Have a look in the cache first
|
||||
auto cacheIndex = m_hCache.find(group + name);
|
||||
@@ -19,7 +19,7 @@ QVariant Settings::getSettingsValue(const QString& group, const QString& name)
|
||||
} else {
|
||||
// Nothing found in the cache, so get the value from the settings file or get the default value if there is no value set yet
|
||||
QSettings settings(QApplication::organizationName(), QApplication::organizationName());
|
||||
QVariant value = settings.value(group + "/" + name, getSettingsDefaultValue(group, name));
|
||||
QVariant value = settings.value(group + "/" + name, getDefaultValue(group, name));
|
||||
|
||||
// Store this value in the cache for further usage and return it afterwards
|
||||
m_hCache.insert(group + name, value);
|
||||
@@ -27,7 +27,7 @@ QVariant Settings::getSettingsValue(const QString& group, const QString& name)
|
||||
}
|
||||
}
|
||||
|
||||
void Settings::setSettingsValue(const QString& group, const QString& name, const QVariant& value, bool dont_save_to_disk)
|
||||
void Settings::setValue(const QString& group, const QString& name, const QVariant& value, bool dont_save_to_disk)
|
||||
{
|
||||
// Sometime the value has to be saved for the current session only but get discarded when the application exits.
|
||||
// In order to achieve this this flag can be set which disables the save to disk mechanism and only leaves the save to cache part active.
|
||||
@@ -44,7 +44,7 @@ void Settings::setSettingsValue(const QString& group, const QString& name, const
|
||||
m_hCache[group + name] = value;
|
||||
}
|
||||
|
||||
QVariant Settings::getSettingsDefaultValue(const QString& group, const QString& name)
|
||||
QVariant Settings::getDefaultValue(const QString& group, const QString& name)
|
||||
{
|
||||
// db/defaultencoding?
|
||||
if(group == "db" && name == "defaultencoding")
|
||||
@@ -60,7 +60,7 @@ QVariant Settings::getSettingsDefaultValue(const QString& group, const QString&
|
||||
|
||||
// db/lastlocation?
|
||||
if(group == "db" && name == "lastlocation")
|
||||
return getSettingsValue("db", "defaultlocation");
|
||||
return getValue("db", "defaultlocation");
|
||||
|
||||
// db/hideschemalinebreaks?
|
||||
if(group == "db" && name == "hideschemalinebreaks")
|
||||
|
||||
@@ -8,15 +8,16 @@
|
||||
class Settings
|
||||
{
|
||||
friend class PreferencesDialog;
|
||||
|
||||
public:
|
||||
static QVariant getSettingsValue(const QString& group, const QString& name);
|
||||
static void setSettingsValue(const QString& group, const QString& name, const QVariant& value, bool dont_save_to_disk = false);
|
||||
static QVariant getValue(const QString& group, const QString& name);
|
||||
static void setValue(const QString& group, const QString& name, const QVariant& value, bool dont_save_to_disk = false);
|
||||
|
||||
private:
|
||||
Settings() { } // class is fully static
|
||||
|
||||
// This works similar to getSettingsValue but returns the default value instead of the value set by the user
|
||||
static QVariant getSettingsDefaultValue(const QString& group, const QString& name);
|
||||
static QVariant getDefaultValue(const QString& group, const QString& name);
|
||||
|
||||
// Cache for storing the settings to avoid repeatedly reading the settings file all the time
|
||||
static QHash<QString, QVariant> m_hCache;
|
||||
|
||||
@@ -19,7 +19,7 @@ SqlExecutionArea::SqlExecutionArea(DBBrowserDB& _db, QWidget* parent) :
|
||||
ui->setupUi(this);
|
||||
|
||||
// Create model
|
||||
model = new SqliteTableModel(db, this, Settings::getSettingsValue("db", "prefetchsize").toInt());
|
||||
model = new SqliteTableModel(db, this, Settings::getValue("db", "prefetchsize").toInt());
|
||||
ui->tableResult->setModel(model);
|
||||
|
||||
// Create popup menu for save button
|
||||
@@ -109,17 +109,17 @@ void SqlExecutionArea::reloadSettings()
|
||||
ui->editEditor->reloadSettings();
|
||||
|
||||
// Set font
|
||||
QFont logfont(Settings::getSettingsValue("editor", "font").toString());
|
||||
QFont logfont(Settings::getValue("editor", "font").toString());
|
||||
logfont.setStyleHint(QFont::TypeWriter);
|
||||
logfont.setPointSize(Settings::getSettingsValue("log", "fontsize").toInt());
|
||||
logfont.setPointSize(Settings::getValue("log", "fontsize").toInt());
|
||||
ui->editErrors->setFont(logfont);
|
||||
|
||||
// Apply horizontal/vertical tiling option
|
||||
if(Settings::getSettingsValue("editor", "horizontal_tiling").toBool())
|
||||
if(Settings::getValue("editor", "horizontal_tiling").toBool())
|
||||
ui->splitter->setOrientation(Qt::Horizontal);
|
||||
else
|
||||
ui->splitter->setOrientation(Qt::Vertical);
|
||||
|
||||
// Set prefetch settings
|
||||
model->setChunkSize(Settings::getSettingsValue("db", "prefetchsize").toInt());
|
||||
model->setChunkSize(Settings::getValue("db", "prefetchsize").toInt());
|
||||
}
|
||||
|
||||
@@ -125,14 +125,14 @@ bool DBBrowserDB::open(const QString& db, bool readOnly)
|
||||
sqlite3_collation_needed(_db, NULL, collation_needed);
|
||||
|
||||
// Set foreign key settings as requested in the preferences
|
||||
bool foreignkeys = Settings::getSettingsValue("db", "foreignkeys").toBool();
|
||||
bool foreignkeys = Settings::getValue("db", "foreignkeys").toBool();
|
||||
setPragma("foreign_keys", foreignkeys ? "1" : "0");
|
||||
|
||||
// Enable extension loading
|
||||
sqlite3_enable_load_extension(_db, 1);
|
||||
|
||||
// Register REGEXP function
|
||||
if(Settings::getSettingsValue("extensions", "disableregex").toBool() == false)
|
||||
if(Settings::getValue("extensions", "disableregex").toBool() == false)
|
||||
sqlite3_create_function(_db, "REGEXP", 2, SQLITE_UTF8, NULL, regexp, NULL, NULL);
|
||||
|
||||
// Check if file is read only
|
||||
@@ -143,7 +143,7 @@ bool DBBrowserDB::open(const QString& db, bool readOnly)
|
||||
// Execute default SQL
|
||||
if(!isReadOnly)
|
||||
{
|
||||
QString default_sql = Settings::getSettingsValue("db", "defaultsqltext").toString();
|
||||
QString default_sql = Settings::getValue("db", "defaultsqltext").toString();
|
||||
if(!default_sql.isEmpty())
|
||||
executeMultiSQL(default_sql, false, true);
|
||||
}
|
||||
@@ -360,7 +360,7 @@ bool DBBrowserDB::create ( const QString & db)
|
||||
if (isOpen()) close();
|
||||
|
||||
// read encoding from settings and open with sqlite3_open for utf8 and sqlite3_open16 for utf16
|
||||
QString sEncoding = Settings::getSettingsValue("db", "defaultencoding").toString();
|
||||
QString sEncoding = Settings::getValue("db", "defaultencoding").toString();
|
||||
|
||||
int openresult = SQLITE_OK;
|
||||
|
||||
@@ -379,14 +379,14 @@ bool DBBrowserDB::create ( const QString & db)
|
||||
if (_db)
|
||||
{
|
||||
// Set foreign key settings as requested in the preferences
|
||||
bool foreignkeys = Settings::getSettingsValue("db", "foreignkeys").toBool();
|
||||
bool foreignkeys = Settings::getValue("db", "foreignkeys").toBool();
|
||||
setPragma("foreign_keys", foreignkeys ? "1" : "0");
|
||||
|
||||
// Enable extension loading
|
||||
sqlite3_enable_load_extension(_db, 1);
|
||||
|
||||
// Register REGEXP function
|
||||
if(Settings::getSettingsValue("extensions", "disableregex").toBool() == false)
|
||||
if(Settings::getValue("extensions", "disableregex").toBool() == false)
|
||||
sqlite3_create_function(_db, "REGEXP", 2, SQLITE_UTF8, NULL, regexp, NULL, NULL);
|
||||
|
||||
// force sqlite3 do write proper file header
|
||||
@@ -400,7 +400,7 @@ bool DBBrowserDB::create ( const QString & db)
|
||||
}
|
||||
|
||||
// Execute default SQL
|
||||
QString default_sql = Settings::getSettingsValue("db", "defaultsqltext").toString();
|
||||
QString default_sql = Settings::getValue("db", "defaultsqltext").toString();
|
||||
if(!default_sql.isEmpty())
|
||||
executeMultiSQL(default_sql, false, true);
|
||||
|
||||
|
||||
@@ -222,11 +222,11 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const
|
||||
|
||||
if(role == Qt::DisplayRole && m_data.at(index.row()).at(index.column()).isNull())
|
||||
{
|
||||
return Settings::getSettingsValue("databrowser", "null_text").toString();
|
||||
return Settings::getValue("databrowser", "null_text").toString();
|
||||
} else if(role == Qt::DisplayRole && isBinary(index)) {
|
||||
return "BLOB";
|
||||
} else if(role == Qt::DisplayRole) {
|
||||
int limit = Settings::getSettingsValue("databrowser", "symbol_limit").toInt();
|
||||
int limit = Settings::getValue("databrowser", "symbol_limit").toInt();
|
||||
QByteArray displayText = m_data.at(index.row()).at(index.column());
|
||||
if (displayText.length() > limit) {
|
||||
// Add "..." to the end of truncated strings
|
||||
@@ -244,16 +244,16 @@ QVariant SqliteTableModel::data(const QModelIndex &index, int role) const
|
||||
return font;
|
||||
} else if(role == Qt::ForegroundRole) {
|
||||
if(m_data.at(index.row()).at(index.column()).isNull())
|
||||
return QColor(Settings::getSettingsValue("databrowser", "null_fg_colour").toString());
|
||||
return QColor(Settings::getValue("databrowser", "null_fg_colour").toString());
|
||||
else if (isBinary(index))
|
||||
return QColor(Settings::getSettingsValue("databrowser", "bin_fg_colour").toString());
|
||||
return QColor(Settings::getSettingsValue("databrowser", "reg_fg_colour").toString());
|
||||
return QColor(Settings::getValue("databrowser", "bin_fg_colour").toString());
|
||||
return QColor(Settings::getValue("databrowser", "reg_fg_colour").toString());
|
||||
} else if (role == Qt::BackgroundRole) {
|
||||
if(m_data.at(index.row()).at(index.column()).isNull())
|
||||
return QColor(Settings::getSettingsValue("databrowser", "null_bg_colour").toString());
|
||||
return QColor(Settings::getValue("databrowser", "null_bg_colour").toString());
|
||||
else if (isBinary(index))
|
||||
return QColor(Settings::getSettingsValue("databrowser", "bin_bg_colour").toString());
|
||||
return QColor(Settings::getSettingsValue("databrowser", "reg_bg_colour").toString());
|
||||
return QColor(Settings::getValue("databrowser", "bin_bg_colour").toString());
|
||||
return QColor(Settings::getValue("databrowser", "reg_bg_colour").toString());
|
||||
} else if(role == Qt::ToolTipRole) {
|
||||
sqlb::ForeignKeyClause fk = getForeignKeyClause(index.column()-1);
|
||||
if(fk.isSet())
|
||||
@@ -652,7 +652,7 @@ void SqliteTableModel::updateFilter(int column, const QString& value)
|
||||
// Keep the default LIKE operator
|
||||
|
||||
// Set the escape character if one has been specified in the settings dialog
|
||||
QString escape_character = Settings::getSettingsValue("databrowser", "filter_escape").toString();
|
||||
QString escape_character = Settings::getValue("databrowser", "filter_escape").toString();
|
||||
if(escape_character == "'") escape_character = "''";
|
||||
if(escape_character.length())
|
||||
escape = QString("ESCAPE '%1'").arg(escape_character);
|
||||
|
||||
@@ -82,13 +82,13 @@ void SqlTextEdit::dropEvent(QDropEvent* e)
|
||||
|
||||
void SqlTextEdit::setupSyntaxHighlightingFormat(const QString& settings_name, int style)
|
||||
{
|
||||
sqlLexer->setColor(QColor(Settings::getSettingsValue("syntaxhighlighter", settings_name + "_colour").toString()), style);
|
||||
sqlLexer->setColor(QColor(Settings::getValue("syntaxhighlighter", settings_name + "_colour").toString()), style);
|
||||
|
||||
QFont font(Settings::getSettingsValue("editor", "font").toString());
|
||||
font.setPointSize(Settings::getSettingsValue("editor", "fontsize").toInt());
|
||||
font.setBold(Settings::getSettingsValue("syntaxhighlighter", settings_name + "_bold").toBool());
|
||||
font.setItalic(Settings::getSettingsValue("syntaxhighlighter", settings_name + "_italic").toBool());
|
||||
font.setUnderline(Settings::getSettingsValue("syntaxhighlighter", settings_name + "_underline").toBool());
|
||||
QFont font(Settings::getValue("editor", "font").toString());
|
||||
font.setPointSize(Settings::getValue("editor", "fontsize").toInt());
|
||||
font.setBold(Settings::getValue("syntaxhighlighter", settings_name + "_bold").toBool());
|
||||
font.setItalic(Settings::getValue("syntaxhighlighter", settings_name + "_italic").toBool());
|
||||
font.setUnderline(Settings::getValue("syntaxhighlighter", settings_name + "_underline").toBool());
|
||||
sqlLexer->setFont(font, style);
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ void SqlTextEdit::reloadKeywords()
|
||||
void SqlTextEdit::reloadSettings()
|
||||
{
|
||||
// Enable auto completion if it hasn't been disabled
|
||||
if(Settings::getSettingsValue("editor", "auto_completion").toBool())
|
||||
if(Settings::getValue("editor", "auto_completion").toBool())
|
||||
{
|
||||
setAutoCompletionThreshold(3);
|
||||
setAutoCompletionCaseSensitivity(false);
|
||||
@@ -112,9 +112,9 @@ void SqlTextEdit::reloadSettings()
|
||||
}
|
||||
|
||||
// Set syntax highlighting settings
|
||||
QFont defaultfont(Settings::getSettingsValue("editor", "font").toString());
|
||||
QFont defaultfont(Settings::getValue("editor", "font").toString());
|
||||
defaultfont.setStyleHint(QFont::TypeWriter);
|
||||
defaultfont.setPointSize(Settings::getSettingsValue("editor", "fontsize").toInt());
|
||||
defaultfont.setPointSize(Settings::getValue("editor", "fontsize").toInt());
|
||||
sqlLexer->setColor(Qt::black, QsciLexerSQL::Default);
|
||||
sqlLexer->setFont(defaultfont);
|
||||
setupSyntaxHighlightingFormat("comment", QsciLexerSQL::Comment);
|
||||
@@ -129,13 +129,13 @@ void SqlTextEdit::reloadSettings()
|
||||
setupSyntaxHighlightingFormat("identifier", QsciLexerSQL::QuotedIdentifier);
|
||||
|
||||
// Set font
|
||||
QFont font(Settings::getSettingsValue("editor", "font").toString());
|
||||
QFont font(Settings::getValue("editor", "font").toString());
|
||||
font.setStyleHint(QFont::TypeWriter);
|
||||
font.setPointSize(Settings::getSettingsValue("editor", "fontsize").toInt());
|
||||
font.setPointSize(Settings::getValue("editor", "fontsize").toInt());
|
||||
setFont(font);
|
||||
|
||||
// Show line numbers
|
||||
QFont marginsfont(QFont(Settings::getSettingsValue("editor", "font").toString()));
|
||||
QFont marginsfont(QFont(Settings::getValue("editor", "font").toString()));
|
||||
marginsfont.setPointSize(font.pointSize());
|
||||
setMarginsFont(marginsfont);
|
||||
setMarginLineNumbers(0, true);
|
||||
@@ -144,13 +144,13 @@ void SqlTextEdit::reloadSettings()
|
||||
|
||||
// Highlight current line
|
||||
setCaretLineVisible(true);
|
||||
setCaretLineBackgroundColor(QColor(Settings::getSettingsValue("syntaxhighlighter", "currentline_colour").toString()));
|
||||
setCaretLineBackgroundColor(QColor(Settings::getValue("syntaxhighlighter", "currentline_colour").toString()));
|
||||
|
||||
// Set tab width
|
||||
setTabWidth(Settings::getSettingsValue("editor", "tabsize").toInt());
|
||||
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
|
||||
|
||||
// Check if error indicators are enabled and clear them if they just got disabled
|
||||
showErrorIndicators = Settings::getSettingsValue("editor", "error_indicators").toBool();
|
||||
showErrorIndicators = Settings::getValue("editor", "error_indicators").toBool();
|
||||
if(!showErrorIndicators)
|
||||
clearErrorIndicators();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user