Skip to content

Commit

Permalink
Edit Pragmas: allow translation of values
Browse files Browse the repository at this point in the history
* Use internal list of values to allow translation
* Add status tip with links to the help icon
* Update translation files with the new strings (pragma names and values)
* Add es_ES translation for the new strings
  • Loading branch information
mgrojo committed Aug 9, 2024
1 parent ad00ad4 commit bf62f3a
Show file tree
Hide file tree
Showing 25 changed files with 13,448 additions and 9,672 deletions.
14 changes: 10 additions & 4 deletions src/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1971,9 +1971,9 @@ void MainWindow::updatePragmaUi()
ui->checkboxPragmaForeignKeys->setChecked(pragmaValues.foreign_keys);
ui->checkboxPragmaFullFsync->setChecked(pragmaValues.fullfsync);
ui->checkboxPragmaIgnoreCheckConstraints->setChecked(pragmaValues.ignore_check_constraints);
ui->comboboxPragmaJournalMode->setCurrentIndex(ui->comboboxPragmaJournalMode->findText(pragmaValues.journal_mode, Qt::MatchFixedString));
ui->comboboxPragmaJournalMode->setCurrentIndex(DBBrowserDB::journalModeValues.indexOf(pragmaValues.journal_mode));
ui->spinPragmaJournalSizeLimit->setValue(pragmaValues.journal_size_limit);
ui->comboboxPragmaLockingMode->setCurrentIndex(ui->comboboxPragmaLockingMode->findText(pragmaValues.locking_mode, Qt::MatchFixedString));
ui->comboboxPragmaLockingMode->setCurrentIndex(DBBrowserDB::lockingModeValues.indexOf(pragmaValues.locking_mode));
ui->spinPragmaMaxPageCount->setValue(pragmaValues.max_page_count);
ui->comboPragmaPageSize->setCurrentIndex(ui->comboPragmaPageSize->findText(QString::number(pragmaValues.page_size), Qt::MatchFixedString));
ui->checkboxPragmaRecursiveTriggers->setChecked(pragmaValues.recursive_triggers);
Expand Down Expand Up @@ -2001,9 +2001,15 @@ void MainWindow::savePragmas()
db.setPragma("foreign_keys", ui->checkboxPragmaForeignKeys->isChecked(), pragmaValues.foreign_keys);
db.setPragma("fullfsync", ui->checkboxPragmaFullFsync->isChecked(), pragmaValues.fullfsync);
db.setPragma("ignore_check_constraints", ui->checkboxPragmaIgnoreCheckConstraints->isChecked(), pragmaValues.ignore_check_constraints);
db.setPragma("journal_mode", ui->comboboxPragmaJournalMode->currentText().toUpper(), pragmaValues.journal_mode);

// Since we allow translation of UI combobox text and journal_mode and locking_mode pragmas
// need text values, we get the text value according to index.
// For this to work, order in journalModeValues and combo-box have to follow the order
// determined by SQLite documentation.
db.setPragma("journal_mode", DBBrowserDB::journalModeValues.at(ui->comboboxPragmaJournalMode->currentIndex()), pragmaValues.journal_mode);
db.setPragma("journal_size_limit", ui->spinPragmaJournalSizeLimit->value(), pragmaValues.journal_size_limit);
db.setPragma("locking_mode", ui->comboboxPragmaLockingMode->currentText().toUpper(), pragmaValues.locking_mode);
db.setPragma("locking_mode", DBBrowserDB::lockingModeValues.at(ui->comboboxPragmaLockingMode->currentIndex()), pragmaValues.locking_mode);

db.setPragma("max_page_count", ui->spinPragmaMaxPageCount->value(), pragmaValues.max_page_count);
db.setPragma("page_size", ui->comboPragmaPageSize->currentText().toInt(), pragmaValues.page_size);
db.setPragma("recursive_triggers", ui->checkboxPragmaRecursiveTriggers->isChecked(), pragmaValues.recursive_triggers);
Expand Down
253 changes: 145 additions & 108 deletions src/MainWindow.ui

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/sqlitedb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#include <cstring>
#include <functional>

const QStringList DBBrowserDB::journalModeValues = {"DELETE", "TRUNCATE", "PERSIST", "MEMORY", "WAL", "OFF"};
const QStringList DBBrowserDB::lockingModeValues = {"NORMAL", "EXCLUSIVE"};

QStringList DBBrowserDB::Datatypes = {"INTEGER", "TEXT", "BLOB", "REAL", "NUMERIC"};
QStringList DBBrowserDB::DatatypesStrict = {"INT", "INTEGER", "TEXT", "BLOB", "REAL", "ANY"};

Expand Down
6 changes: 6 additions & 0 deletions src/sqlitedb.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ class DBBrowserDB : public QObject
bool setPragma(const std::string& pragma, const QString& value, QString& originalvalue);
bool setPragma(const std::string& pragma, int value, int& originalvalue);

// These are the two pragmas in SQLite which require values passed as text.
// Values follow the order of the SQLite documentation.
// Use these values for setPragma().
static const QStringList journalModeValues;
static const QStringList lockingModeValues;

bool loadExtension(const QString& filename);
void loadExtensionsFromSettings();

Expand Down
1,135 changes: 657 additions & 478 deletions src/translations/sqlb_ar_SA.ts

Large diffs are not rendered by default.

Loading

0 comments on commit bf62f3a

Please sign in to comment.