Skip to content

Commit

Permalink
Rename all the settings accessor functions
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
MKleusberg committed Mar 20, 2017
1 parent e6390b4 commit f1194d8
Show file tree
Hide file tree
Showing 18 changed files with 167 additions and 166 deletions.
6 changes: 3 additions & 3 deletions src/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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.
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/DbStructureModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
4 changes: 2 additions & 2 deletions src/EditDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion src/EditTableDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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())
{
Expand Down
20 changes: 10 additions & 10 deletions src/ExportDataDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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."));
Expand Down
12 changes: 6 additions & 6 deletions src/FileDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 "";
}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/FilterLineEdit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()));

Expand Down
38 changes: 19 additions & 19 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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++)
Expand All @@ -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);

Expand Down Expand Up @@ -1358,15 +1358,15 @@ 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());
files.prepend(info.absoluteFilePath());
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);
Expand Down Expand Up @@ -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)
Expand All @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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) : ""));
}
}
Expand Down
12 changes: 6 additions & 6 deletions src/PlotDock.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading

0 comments on commit f1194d8

Please sign in to comment.