Skip to content

Commit f1194d8

Browse files
committed
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.
1 parent e6390b4 commit f1194d8

18 files changed

Lines changed: 167 additions & 166 deletions

src/Application.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Application::Application(int& argc, char** argv) :
2222

2323
// Load translations
2424
bool ok;
25-
QString name = Settings::getSettingsValue("General", "language").toString();
25+
QString name = Settings::getValue("General", "language").toString();
2626

2727
// First of all try to load the application translation file.
2828
m_translatorApp = new QTranslator(this);
@@ -34,7 +34,7 @@ Application::Application(int& argc, char** argv) :
3434
}
3535

3636
if (ok == true) {
37-
Settings::setSettingsValue("General", "language", name);
37+
Settings::setValue("General", "language", name);
3838
installTranslator(m_translatorApp);
3939

4040
// The application translation file has been found and loaded.
@@ -54,7 +54,7 @@ Application::Application(int& argc, char** argv) :
5454
// Set the correct locale so that the program won't erroneously detect
5555
// a language change when the user toggles settings for the first time.
5656
// (it also prevents the program from always looking for a translation on launch)
57-
Settings::setSettingsValue("General", "language", "en_US");
57+
Settings::setValue("General", "language", "en_US");
5858
}
5959

6060
// Parse command line

src/DbStructureModel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ QVariant DbStructureModel::data(const QModelIndex& index, int role) const
4040
switch(role)
4141
{
4242
case Qt::DisplayRole:
43-
return Settings::getSettingsValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
43+
return Settings::getValue("db", "hideschemalinebreaks").toBool() ? item->text(index.column()).replace("\n", " ").simplified() : item->text(index.column());
4444
case Qt::EditRole:
4545
case Qt::ToolTipRole: // Don't modify the text when it's supposed to be shown in a tooltip
4646
return item->text(index.column());

src/EditDialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,8 @@ QString EditDialog::humanReadableSize(double byteCount)
544544
void EditDialog::reloadSettings()
545545
{
546546
// Set the font for the text and hex editors
547-
QFont editorFont(Settings::getSettingsValue("databrowser", "font").toString());
548-
editorFont.setPointSize(Settings::getSettingsValue("databrowser", "fontsize").toInt());
547+
QFont editorFont(Settings::getValue("databrowser", "font").toString());
548+
editorFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
549549
ui->editorText->setFont(editorFont);
550550
hexEdit->setFont(editorFont);
551551
}

src/EditTableDialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ void EditTableDialog::addField()
513513
typeBox->setEditable(true);
514514
typeBox->addItems(sqlb::Field::Datatypes);
515515

516-
int defaultFieldTypeIndex = Settings::getSettingsValue("db", "defaultfieldtype").toInt();
516+
int defaultFieldTypeIndex = Settings::getValue("db", "defaultfieldtype").toInt();
517517

518518
if (defaultFieldTypeIndex < sqlb::Field::Datatypes.count())
519519
{

src/ExportDataDialog.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ ExportDataDialog::ExportDataDialog(DBBrowserDB& db, ExportFormats format, QWidge
2626
ui->stackFormat->setCurrentIndex(format);
2727

2828
// Retrieve the saved dialog preferences
29-
ui->checkHeader->setChecked(Settings::getSettingsValue("exportcsv", "firstrowheader").toBool());
30-
setSeparatorChar(Settings::getSettingsValue("exportcsv", "separator").toInt());
31-
setQuoteChar(Settings::getSettingsValue("exportcsv", "quotecharacter").toInt());
32-
setNewLineString(Settings::getSettingsValue("exportcsv", "newlinecharacters").toString());
33-
ui->checkPrettyPrint->setChecked(Settings::getSettingsValue("exportjson", "prettyprint").toBool());
29+
ui->checkHeader->setChecked(Settings::getValue("exportcsv", "firstrowheader").toBool());
30+
setSeparatorChar(Settings::getValue("exportcsv", "separator").toInt());
31+
setQuoteChar(Settings::getValue("exportcsv", "quotecharacter").toInt());
32+
setNewLineString(Settings::getValue("exportcsv", "newlinecharacters").toString());
33+
ui->checkPrettyPrint->setChecked(Settings::getValue("exportjson", "prettyprint").toBool());
3434

3535
// Update the visible/hidden status of the "Other" line edit fields
3636
showCustomCharEdits();
@@ -316,11 +316,11 @@ void ExportDataDialog::accept()
316316
}
317317

318318
// Save the dialog preferences for future use
319-
Settings::setSettingsValue("exportcsv", "firstrowheader", ui->checkHeader->isChecked());
320-
Settings::setSettingsValue("exportjson", "prettyprint", ui->checkPrettyPrint->isChecked());
321-
Settings::setSettingsValue("exportcsv", "separator", currentSeparatorChar());
322-
Settings::setSettingsValue("exportcsv", "quotecharacter", currentQuoteChar());
323-
Settings::setSettingsValue("exportcsv", "newlinecharacters", currentNewLineString());
319+
Settings::setValue("exportcsv", "firstrowheader", ui->checkHeader->isChecked());
320+
Settings::setValue("exportjson", "prettyprint", ui->checkPrettyPrint->isChecked());
321+
Settings::setValue("exportcsv", "separator", currentSeparatorChar());
322+
Settings::setValue("exportcsv", "quotecharacter", currentQuoteChar());
323+
Settings::setValue("exportcsv", "newlinecharacters", currentNewLineString());
324324

325325
// Notify the user the export has completed
326326
QMessageBox::information(this, QApplication::applicationName(), tr("Export completed."));

src/FileDialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ QString FileDialog::getExistingDirectory(QWidget* parent, const QString& caption
3131

3232
QString FileDialog::getFileDialogPath()
3333
{
34-
switch(Settings::getSettingsValue("db", "savedefaultlocation").toInt())
34+
switch(Settings::getValue("db", "savedefaultlocation").toInt())
3535
{
3636
case 0: // Remember last location
3737
case 2: // Remember last location for current session only
38-
return Settings::getSettingsValue("db", "lastlocation").toString();
38+
return Settings::getValue("db", "lastlocation").toString();
3939
case 1: // Always use this locations
40-
return Settings::getSettingsValue("db", "defaultlocation").toString();
40+
return Settings::getValue("db", "defaultlocation").toString();
4141
default:
4242
return "";
4343
}
@@ -47,13 +47,13 @@ void FileDialog::setFileDialogPath(const QString& new_path)
4747
{
4848
QString dir = QFileInfo(new_path).absolutePath();
4949

50-
switch(Settings::getSettingsValue("db", "savedefaultlocation").toInt())
50+
switch(Settings::getValue("db", "savedefaultlocation").toInt())
5151
{
5252
case 0: // Remember last location
53-
Settings::setSettingsValue("db", "lastlocation", dir);
53+
Settings::setValue("db", "lastlocation", dir);
5454
break;
5555
case 2: // Remember last location for current session only
56-
Settings::setSettingsValue("db", "lastlocation", dir, true);
56+
Settings::setValue("db", "lastlocation", dir, true);
5757
break;
5858
case 1: // Always use this locations
5959
break; // Do nothing

src/FilterLineEdit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ FilterLineEdit::FilterLineEdit(QWidget* parent, QList<FilterLineEdit*>* filters,
1616
// is (re)started. As soon as the user stops typing the timer has a chance to trigger and call the
1717
// delayedSignalTimerTriggered() method which then stops the timer and emits the delayed signal.
1818
delaySignalTimer = new QTimer(this);
19-
delaySignalTimer->setInterval(Settings::getSettingsValue("databrowser", "filter_delay").toInt()); // This is the milliseconds of not-typing we want to wait before triggering
19+
delaySignalTimer->setInterval(Settings::getValue("databrowser", "filter_delay").toInt()); // This is the milliseconds of not-typing we want to wait before triggering
2020
connect(this, SIGNAL(textChanged(QString)), delaySignalTimer, SLOT(start()));
2121
connect(delaySignalTimer, SIGNAL(timeout()), this, SLOT(delayedSignalTimerTriggered()));
2222

src/MainWindow.cpp

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
MainWindow::MainWindow(QWidget* parent)
5151
: QMainWindow(parent),
5252
ui(new Ui::MainWindow),
53-
m_browseTableModel(new SqliteTableModel(db, this, Settings::getSettingsValue("db", "prefetchsize").toInt())),
53+
m_browseTableModel(new SqliteTableModel(db, this, Settings::getValue("db", "prefetchsize").toInt())),
5454
m_currentTabTableModel(m_browseTableModel),
5555
m_remoteDb(new RemoteDatabase),
5656
editDock(new EditDialog(this)),
@@ -111,11 +111,11 @@ void MainWindow::init()
111111
ui->dockRemote->setWidget(remoteDock);
112112

113113
// Restore window geometry
114-
restoreGeometry(Settings::getSettingsValue("MainWindow", "geometry").toByteArray());
115-
restoreState(Settings::getSettingsValue("MainWindow", "windowState").toByteArray());
114+
restoreGeometry(Settings::getValue("MainWindow", "geometry").toByteArray());
115+
restoreState(Settings::getValue("MainWindow", "windowState").toByteArray());
116116

117117
// Restore dock state settings
118-
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(Settings::getSettingsValue("SQLLogDock", "Log").toString()));
118+
ui->comboLogSubmittedBy->setCurrentIndex(ui->comboLogSubmittedBy->findText(Settings::getValue("SQLLogDock", "Log").toString()));
119119

120120
// Add keyboard shortcuts
121121
QList<QKeySequence> shortcuts = ui->actionExecuteSql->shortcuts();
@@ -255,7 +255,7 @@ void MainWindow::init()
255255

256256
#ifdef CHECKNEWVERSION
257257
// Check for a new version if automatic update check aren't disabled in the settings dialog
258-
if(Settings::getSettingsValue("checkversion", "enabled").toBool())
258+
if(Settings::getValue("checkversion", "enabled").toBool())
259259
{
260260
m_remoteDb->fetch("https://raw.githubusercontent.com/sqlitebrowser/sqlitebrowser/master/currentrelease",
261261
RemoteDatabase::RequestTypeNewVersionCheck);
@@ -569,9 +569,9 @@ void MainWindow::closeEvent( QCloseEvent* event )
569569
{
570570
if(db.close())
571571
{
572-
Settings::setSettingsValue("MainWindow", "geometry", saveGeometry());
573-
Settings::setSettingsValue("MainWindow", "windowState", saveState());
574-
Settings::setSettingsValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
572+
Settings::setValue("MainWindow", "geometry", saveGeometry());
573+
Settings::setValue("MainWindow", "windowState", saveState());
574+
Settings::setValue("SQLLogDock", "Log", ui->comboLogSubmittedBy->currentText());
575575
QMainWindow::closeEvent(event);
576576
} else {
577577
event->ignore();
@@ -1314,7 +1314,7 @@ void MainWindow::openRecentFile()
13141314
void MainWindow::updateRecentFileActions()
13151315
{
13161316
// Get recent files list from settings
1317-
QStringList files = Settings::getSettingsValue("General", "recentFileList").toStringList();
1317+
QStringList files = Settings::getValue("General", "recentFileList").toStringList();
13181318

13191319
// Check if files still exist and remove any non-existant file
13201320
for(int i=0;i<files.size();i++)
@@ -1328,7 +1328,7 @@ void MainWindow::updateRecentFileActions()
13281328
}
13291329

13301330
// Store updated list
1331-
Settings::setSettingsValue("General", "recentFileList", files);
1331+
Settings::setValue("General", "recentFileList", files);
13321332

13331333
int numRecentFiles = qMin(files.size(), (int)MaxRecentFiles);
13341334

@@ -1358,15 +1358,15 @@ void MainWindow::setCurrentFile(const QString &fileName)
13581358

13591359
void MainWindow::addToRecentFilesMenu(const QString& filename)
13601360
{
1361-
QStringList files = Settings::getSettingsValue("General", "recentFileList").toStringList();
1361+
QStringList files = Settings::getValue("General", "recentFileList").toStringList();
13621362
QFileInfo info(filename);
13631363

13641364
files.removeAll(info.absoluteFilePath());
13651365
files.prepend(info.absoluteFilePath());
13661366
while (files.size() > MaxRecentFiles)
13671367
files.removeLast();
13681368

1369-
Settings::setSettingsValue("General", "recentFileList", files);
1369+
Settings::setValue("General", "recentFileList", files);
13701370

13711371
foreach (QWidget *widget, QApplication::topLevelWidgets()) {
13721372
MainWindow *mainWin = qobject_cast<MainWindow *>(widget);
@@ -1679,7 +1679,7 @@ void MainWindow::loadExtensionsFromSettings()
16791679
if(!db.isOpen())
16801680
return;
16811681

1682-
QStringList list = Settings::getSettingsValue("extensions", "list").toStringList();
1682+
QStringList list = Settings::getValue("extensions", "list").toStringList();
16831683
foreach(QString ext, list)
16841684
{
16851685
if(db.loadExtension(ext) == false)
@@ -1690,19 +1690,19 @@ void MainWindow::loadExtensionsFromSettings()
16901690
void MainWindow::reloadSettings()
16911691
{
16921692
// Set data browser font
1693-
QFont dataBrowserFont(Settings::getSettingsValue("databrowser", "font").toString());
1694-
dataBrowserFont.setPointSize(Settings::getSettingsValue("databrowser", "fontsize").toInt());
1693+
QFont dataBrowserFont(Settings::getValue("databrowser", "font").toString());
1694+
dataBrowserFont.setPointSize(Settings::getValue("databrowser", "fontsize").toInt());
16951695
ui->dataTable->setFont(dataBrowserFont);
16961696

16971697
// Set prefetch sizes for lazy population of table models
1698-
m_browseTableModel->setChunkSize(Settings::getSettingsValue("db", "prefetchsize").toInt());
1698+
m_browseTableModel->setChunkSize(Settings::getValue("db", "prefetchsize").toInt());
16991699
for(int i=0;i<ui->tabSqlAreas->count();++i)
17001700
qobject_cast<SqlExecutionArea*>(ui->tabSqlAreas->widget(i))->reloadSettings();
17011701

17021702
// Prepare log font
17031703
QFont logfont("Monospace");
17041704
logfont.setStyleHint(QFont::TypeWriter);
1705-
logfont.setPointSize(Settings::getSettingsValue("log", "fontsize").toInt());
1705+
logfont.setPointSize(Settings::getValue("log", "fontsize").toInt());
17061706

17071707
// Set font for SQL logs and edit dialog
17081708
ui->editLogApplication->reloadSettings();
@@ -1719,7 +1719,7 @@ void MainWindow::reloadSettings()
17191719
populateTable();
17201720

17211721
// Hide or show the File → Remote menu as needed
1722-
bool showRemoteActions = Settings::getSettingsValue("remote", "active").toBool();
1722+
bool showRemoteActions = Settings::getValue("remote", "active").toBool();
17231723
ui->menuRemote->menuAction()->setVisible(showRemoteActions);
17241724
ui->viewMenu->actions().at(4)->setVisible(showRemoteActions);
17251725
if(!showRemoteActions)
@@ -1795,7 +1795,7 @@ void MainWindow::on_actionSave_Remote_triggered()
17951795
QString url = QInputDialog::getText(this, qApp->applicationName(), tr("Please enter the URL of the database file to save."));
17961796
if(!url.isEmpty())
17971797
{
1798-
QStringList certs = Settings::getSettingsValue("remote", "client_certificates").toStringList();
1798+
QStringList certs = Settings::getValue("remote", "client_certificates").toStringList();
17991799
m_remoteDb->push(db.currentFile(), url, (certs.size() ? certs.at(0) : ""));
18001800
}
18011801
}

src/PlotDock.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ PlotDock::PlotDock(QWidget* parent)
1717
ui->treePlotColumns->setSelectionMode(QAbstractItemView::NoSelection);
1818

1919
// Restore state
20-
ui->splitterForPlot->restoreState(Settings::getSettingsValue("PlotDock", "splitterSize").toByteArray());
21-
ui->comboLineType->setCurrentIndex(Settings::getSettingsValue("PlotDock", "lineType").toInt());
22-
ui->comboPointShape->setCurrentIndex(Settings::getSettingsValue("PlotDock", "pointShape").toInt());
20+
ui->splitterForPlot->restoreState(Settings::getValue("PlotDock", "splitterSize").toByteArray());
21+
ui->comboLineType->setCurrentIndex(Settings::getValue("PlotDock", "lineType").toInt());
22+
ui->comboPointShape->setCurrentIndex(Settings::getValue("PlotDock", "pointShape").toInt());
2323
}
2424

2525
PlotDock::~PlotDock()
2626
{
2727
// Save state
28-
Settings::setSettingsValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
29-
Settings::setSettingsValue("PlotDock", "lineType", ui->comboLineType->currentIndex());
30-
Settings::setSettingsValue("PlotDock", "pointShape", ui->comboPointShape->currentIndex());
28+
Settings::setValue("PlotDock", "splitterSize", ui->splitterForPlot->saveState());
29+
Settings::setValue("PlotDock", "lineType", ui->comboLineType->currentIndex());
30+
Settings::setValue("PlotDock", "pointShape", ui->comboPointShape->currentIndex());
3131

3232
// Finally, delete all widgets
3333
delete ui;

0 commit comments

Comments
 (0)