mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-05-06 20:09:54 -05:00
add an option for the tabsize in the sql editor (default 4)
This commit is contained in:
@@ -1361,6 +1361,7 @@ void MainWindow::reloadSettings()
|
||||
// Read settings
|
||||
int prefetch_size = PreferencesDialog::getSettingsValue("db", "prefetchsize").toInt();
|
||||
int edit_fontsize = PreferencesDialog::getSettingsValue("editor", "fontsize").toInt();
|
||||
int edit_tabsize = PreferencesDialog::getSettingsValue("editor", "tabsize").toInt();
|
||||
int log_fontsize = PreferencesDialog::getSettingsValue("log", "fontsize").toInt();
|
||||
|
||||
QFont logfont("Monospace");
|
||||
@@ -1377,7 +1378,10 @@ void MainWindow::reloadSettings()
|
||||
|
||||
QFont font = sqlArea->getEditor()->font();
|
||||
font.setPointSize(edit_fontsize);
|
||||
QFontMetrics fm(font);
|
||||
int tabpixelwidth = fm.width(" ") * edit_tabsize;
|
||||
sqlArea->getEditor()->setFont(font);
|
||||
sqlArea->getEditor()->setTabStopWidth(tabpixelwidth);
|
||||
}
|
||||
|
||||
// Set font for SQL logs
|
||||
|
||||
@@ -85,6 +85,7 @@ void PreferencesDialog::loadSettings()
|
||||
}
|
||||
}
|
||||
ui->spinEditorFontSize->setValue(getSettingsValue("editor", "fontsize").toInt());
|
||||
ui->spinTabSize->setValue(getSettingsValue("editor", "tabsize").toInt());
|
||||
ui->spinLogFontSize->setValue(getSettingsValue("log", "fontsize").toInt());
|
||||
|
||||
ui->listExtensions->addItems(getSettingsValue("extensions", "list").toStringList());
|
||||
@@ -117,6 +118,7 @@ void PreferencesDialog::saveSettings()
|
||||
setSettingsValue("syntaxhighlighter", name + "_underline", ui->treeSyntaxHighlighting->topLevelItem(i)->checkState(5) == Qt::Checked);
|
||||
}
|
||||
setSettingsValue("editor", "fontsize", ui->spinEditorFontSize->value());
|
||||
setSettingsValue("editor", "tabsize", ui->spinTabSize->value());
|
||||
setSettingsValue("log", "fontsize", ui->spinLogFontSize->value());
|
||||
|
||||
QStringList extList;
|
||||
@@ -262,6 +264,14 @@ QVariant PreferencesDialog::getSettingsDefaultValue(const QString& group, const
|
||||
if((group == "editor" || group == "log") && name == "fontsize")
|
||||
return 9;
|
||||
|
||||
if(group == "editor")
|
||||
{
|
||||
if(name == "tabsize")
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
}
|
||||
|
||||
// extensions/list?
|
||||
if(group == "extensions" && name == "list")
|
||||
return QStringList();
|
||||
|
||||
@@ -585,13 +585,6 @@ QGroupBox::title {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinLogFontSize">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
@@ -602,6 +595,33 @@ QGroupBox::title {
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="spinLogFontSize">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Tab size:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QSpinBox" name="spinTabSize">
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>16</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>4</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
@@ -28,6 +28,9 @@ SqlTextEdit::SqlTextEdit(QWidget* parent) :
|
||||
font.setPointSize(PreferencesDialog::getSettingsValue("editor", "fontsize").toInt());
|
||||
setFont(font);
|
||||
|
||||
QFontMetrics fm(font);
|
||||
setTabStopWidth(fm.width(" ") * PreferencesDialog::getSettingsValue("editor", "tabsize").toInt());
|
||||
|
||||
// Create syntax highlighter
|
||||
m_syntaxHighlighter = new SQLiteSyntaxHighlighter(document());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user