Skip to content

Commit

Permalink
Execute SQL editor: Use tabs for indentation
Browse files Browse the repository at this point in the history
The QScintilla property is used to provide a new setting.

See issue sqlitebrowser#2800
  • Loading branch information
mgrojo committed Aug 15, 2021
1 parent f4416c2 commit 9ba1a2e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
4 changes: 3 additions & 1 deletion src/ExtendedScintilla.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,10 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
setCaretLineBackgroundColor(QColor(Settings::getValue("syntaxhighlighter", "currentline_colour").toString()));
setCaretForegroundColor(foreground);

// Set tab width
// Set tab settings
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
setIndentationsUseTabs(Settings::getValue("editor", "indentation_use_tabs").toBool());

if(lexer)
lexer->refreshProperties();

Expand Down
2 changes: 2 additions & 0 deletions src/PreferencesDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ void PreferencesDialog::loadSettings()

ui->spinEditorFontSize->setValue(Settings::getValue("editor", "fontsize").toInt());
ui->spinTabSize->setValue(Settings::getValue("editor", "tabsize").toInt());
ui->checkIndentationUseTabs->setChecked(Settings::getValue("editor", "indentation_use_tabs").toBool());
ui->spinLogFontSize->setValue(Settings::getValue("log", "fontsize").toInt());
ui->wrapComboBox->setCurrentIndex(Settings::getValue("editor", "wrap_lines").toInt());
ui->quoteComboBox->setCurrentIndex(Settings::getValue("editor", "identifier_quotes").toInt());
Expand Down Expand Up @@ -257,6 +258,7 @@ void PreferencesDialog::saveSettings(bool accept)
Settings::setValue("editor", "font", ui->comboEditorFont->currentText());
Settings::setValue("editor", "fontsize", ui->spinEditorFontSize->value());
Settings::setValue("editor", "tabsize", ui->spinTabSize->value());
Settings::setValue("editor", "indentation_use_tabs", ui->checkIndentationUseTabs->isChecked());
Settings::setValue("log", "fontsize", ui->spinLogFontSize->value());
Settings::setValue("editor", "wrap_lines", ui->wrapComboBox->currentIndex());
Settings::setValue("editor", "identifier_quotes", ui->quoteComboBox->currentIndex());
Expand Down
46 changes: 33 additions & 13 deletions src/PreferencesDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1471,6 +1471,26 @@ Can be set to 0 for disabling completion.</string>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_28">
<property name="text">
<string>Use tabs for indentation</string>
</property>
<property name="buddy">
<cstring>checkAutoCompletion</cstring>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QCheckBox" name="checkIndentationUseTabs">
<property name="toolTip">
<string>When set, the Tab key will insert tab and space characters for indentation. Otherwise, just spaces will be used.</string>
</property>
<property name="text">
<string>enabled</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="wrapLabel">
<property name="text">
<string>&amp;Wrap lines</string>
Expand All @@ -1480,7 +1500,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="3" column="1">
<item row="4" column="1">
<widget class="QComboBox" name="wrapComboBox">
<item>
<property name="text">
Expand All @@ -1504,7 +1524,7 @@ Can be set to 0 for disabling completion.</string>
</item>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_25">
<property name="text">
<string>&amp;Quotes for identifiers</string>
Expand All @@ -1514,7 +1534,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="4" column="1">
<item row="5" column="1">
<widget class="QComboBox" name="quoteComboBox">
<property name="toolTip">
<string>Choose the quoting mechanism used by the application for identifiers in SQL code.</string>
Expand All @@ -1539,7 +1559,7 @@ Can be set to 0 for disabling completion.</string>
</item>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="label_20">
<property name="text">
<string>Code co&amp;mpletion</string>
Expand All @@ -1549,14 +1569,14 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="5" column="1">
<item row="6" column="1">
<widget class="QCheckBox" name="checkAutoCompletion">
<property name="text">
<string>enabled</string>
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="label_24">
<property name="text">
<string>Keywords in &amp;UPPER CASE</string>
Expand All @@ -1566,7 +1586,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="6" column="1">
<item row="7" column="1">
<widget class="QCheckBox" name="checkCompleteUpper">
<property name="toolTip">
<string>When set, the SQL keywords are completed in UPPER CASE letters.</string>
Expand All @@ -1576,7 +1596,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QLabel" name="label_15">
<property name="text">
<string>Error indicators</string>
Expand All @@ -1586,7 +1606,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="7" column="1">
<item row="8" column="1">
<widget class="QCheckBox" name="checkErrorIndicators">
<property name="toolTip">
<string>When set, the SQL code lines that caused errors during the last execution are highlighted and the results frame indicates the error in the background</string>
Expand All @@ -1596,7 +1616,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QLabel" name="label_10">
<property name="text">
<string>Hori&amp;zontal tiling</string>
Expand All @@ -1606,7 +1626,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QCheckBox" name="checkHorizontalTiling">
<property name="toolTip">
<string>If enabled the SQL code editor and the result table view are shown side by side instead of one over the other.</string>
Expand All @@ -1616,7 +1636,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QLabel" name="labelCloseButtonOnTabs">
<property name="text">
<string>Close button on tabs</string>
Expand All @@ -1626,7 +1646,7 @@ Can be set to 0 for disabling completion.</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QCheckBox" name="checkCloseButtonOnTabs">
<property name="toolTip">
<string>If enabled, SQL editor tabs will have a close button. In any case, you can use the contextual menu or the keyboard shortcut to close them.</string>
Expand Down
4 changes: 2 additions & 2 deletions src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,9 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string&
if(group == "editor")
{
if(name == "tabsize")
{
return 4;
}
if(name == "indentation_use_tabs")
return true;
}

// editor/wrap_lines
Expand Down

0 comments on commit 9ba1a2e

Please sign in to comment.