Skip to content

Commit 9ba1a2e

Browse files
committed
Execute SQL editor: Use tabs for indentation
The QScintilla property is used to provide a new setting. See issue #2800
1 parent f4416c2 commit 9ba1a2e

File tree

4 files changed

+40
-16
lines changed

4 files changed

+40
-16
lines changed

src/ExtendedScintilla.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,10 @@ void ExtendedScintilla::reloadLexerSettings(QsciLexer *lexer)
205205
setCaretLineBackgroundColor(QColor(Settings::getValue("syntaxhighlighter", "currentline_colour").toString()));
206206
setCaretForegroundColor(foreground);
207207

208-
// Set tab width
208+
// Set tab settings
209209
setTabWidth(Settings::getValue("editor", "tabsize").toInt());
210+
setIndentationsUseTabs(Settings::getValue("editor", "indentation_use_tabs").toBool());
211+
210212
if(lexer)
211213
lexer->refreshProperties();
212214

src/PreferencesDialog.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ void PreferencesDialog::loadSettings()
190190

191191
ui->spinEditorFontSize->setValue(Settings::getValue("editor", "fontsize").toInt());
192192
ui->spinTabSize->setValue(Settings::getValue("editor", "tabsize").toInt());
193+
ui->checkIndentationUseTabs->setChecked(Settings::getValue("editor", "indentation_use_tabs").toBool());
193194
ui->spinLogFontSize->setValue(Settings::getValue("log", "fontsize").toInt());
194195
ui->wrapComboBox->setCurrentIndex(Settings::getValue("editor", "wrap_lines").toInt());
195196
ui->quoteComboBox->setCurrentIndex(Settings::getValue("editor", "identifier_quotes").toInt());
@@ -257,6 +258,7 @@ void PreferencesDialog::saveSettings(bool accept)
257258
Settings::setValue("editor", "font", ui->comboEditorFont->currentText());
258259
Settings::setValue("editor", "fontsize", ui->spinEditorFontSize->value());
259260
Settings::setValue("editor", "tabsize", ui->spinTabSize->value());
261+
Settings::setValue("editor", "indentation_use_tabs", ui->checkIndentationUseTabs->isChecked());
260262
Settings::setValue("log", "fontsize", ui->spinLogFontSize->value());
261263
Settings::setValue("editor", "wrap_lines", ui->wrapComboBox->currentIndex());
262264
Settings::setValue("editor", "identifier_quotes", ui->quoteComboBox->currentIndex());

src/PreferencesDialog.ui

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,6 +1471,26 @@ Can be set to 0 for disabling completion.</string>
14711471
</widget>
14721472
</item>
14731473
<item row="3" column="0">
1474+
<widget class="QLabel" name="label_28">
1475+
<property name="text">
1476+
<string>Use tabs for indentation</string>
1477+
</property>
1478+
<property name="buddy">
1479+
<cstring>checkAutoCompletion</cstring>
1480+
</property>
1481+
</widget>
1482+
</item>
1483+
<item row="3" column="1">
1484+
<widget class="QCheckBox" name="checkIndentationUseTabs">
1485+
<property name="toolTip">
1486+
<string>When set, the Tab key will insert tab and space characters for indentation. Otherwise, just spaces will be used.</string>
1487+
</property>
1488+
<property name="text">
1489+
<string>enabled</string>
1490+
</property>
1491+
</widget>
1492+
</item>
1493+
<item row="4" column="0">
14741494
<widget class="QLabel" name="wrapLabel">
14751495
<property name="text">
14761496
<string>&amp;Wrap lines</string>
@@ -1480,7 +1500,7 @@ Can be set to 0 for disabling completion.</string>
14801500
</property>
14811501
</widget>
14821502
</item>
1483-
<item row="3" column="1">
1503+
<item row="4" column="1">
14841504
<widget class="QComboBox" name="wrapComboBox">
14851505
<item>
14861506
<property name="text">
@@ -1504,7 +1524,7 @@ Can be set to 0 for disabling completion.</string>
15041524
</item>
15051525
</widget>
15061526
</item>
1507-
<item row="4" column="0">
1527+
<item row="5" column="0">
15081528
<widget class="QLabel" name="label_25">
15091529
<property name="text">
15101530
<string>&amp;Quotes for identifiers</string>
@@ -1514,7 +1534,7 @@ Can be set to 0 for disabling completion.</string>
15141534
</property>
15151535
</widget>
15161536
</item>
1517-
<item row="4" column="1">
1537+
<item row="5" column="1">
15181538
<widget class="QComboBox" name="quoteComboBox">
15191539
<property name="toolTip">
15201540
<string>Choose the quoting mechanism used by the application for identifiers in SQL code.</string>
@@ -1539,7 +1559,7 @@ Can be set to 0 for disabling completion.</string>
15391559
</item>
15401560
</widget>
15411561
</item>
1542-
<item row="5" column="0">
1562+
<item row="6" column="0">
15431563
<widget class="QLabel" name="label_20">
15441564
<property name="text">
15451565
<string>Code co&amp;mpletion</string>
@@ -1549,14 +1569,14 @@ Can be set to 0 for disabling completion.</string>
15491569
</property>
15501570
</widget>
15511571
</item>
1552-
<item row="5" column="1">
1572+
<item row="6" column="1">
15531573
<widget class="QCheckBox" name="checkAutoCompletion">
15541574
<property name="text">
15551575
<string>enabled</string>
15561576
</property>
15571577
</widget>
15581578
</item>
1559-
<item row="6" column="0">
1579+
<item row="7" column="0">
15601580
<widget class="QLabel" name="label_24">
15611581
<property name="text">
15621582
<string>Keywords in &amp;UPPER CASE</string>
@@ -1566,7 +1586,7 @@ Can be set to 0 for disabling completion.</string>
15661586
</property>
15671587
</widget>
15681588
</item>
1569-
<item row="6" column="1">
1589+
<item row="7" column="1">
15701590
<widget class="QCheckBox" name="checkCompleteUpper">
15711591
<property name="toolTip">
15721592
<string>When set, the SQL keywords are completed in UPPER CASE letters.</string>
@@ -1576,7 +1596,7 @@ Can be set to 0 for disabling completion.</string>
15761596
</property>
15771597
</widget>
15781598
</item>
1579-
<item row="7" column="0">
1599+
<item row="8" column="0">
15801600
<widget class="QLabel" name="label_15">
15811601
<property name="text">
15821602
<string>Error indicators</string>
@@ -1586,7 +1606,7 @@ Can be set to 0 for disabling completion.</string>
15861606
</property>
15871607
</widget>
15881608
</item>
1589-
<item row="7" column="1">
1609+
<item row="8" column="1">
15901610
<widget class="QCheckBox" name="checkErrorIndicators">
15911611
<property name="toolTip">
15921612
<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>
@@ -1596,7 +1616,7 @@ Can be set to 0 for disabling completion.</string>
15961616
</property>
15971617
</widget>
15981618
</item>
1599-
<item row="8" column="0">
1619+
<item row="9" column="0">
16001620
<widget class="QLabel" name="label_10">
16011621
<property name="text">
16021622
<string>Hori&amp;zontal tiling</string>
@@ -1606,7 +1626,7 @@ Can be set to 0 for disabling completion.</string>
16061626
</property>
16071627
</widget>
16081628
</item>
1609-
<item row="8" column="1">
1629+
<item row="9" column="1">
16101630
<widget class="QCheckBox" name="checkHorizontalTiling">
16111631
<property name="toolTip">
16121632
<string>If enabled the SQL code editor and the result table view are shown side by side instead of one over the other.</string>
@@ -1616,7 +1636,7 @@ Can be set to 0 for disabling completion.</string>
16161636
</property>
16171637
</widget>
16181638
</item>
1619-
<item row="9" column="0">
1639+
<item row="10" column="0">
16201640
<widget class="QLabel" name="labelCloseButtonOnTabs">
16211641
<property name="text">
16221642
<string>Close button on tabs</string>
@@ -1626,7 +1646,7 @@ Can be set to 0 for disabling completion.</string>
16261646
</property>
16271647
</widget>
16281648
</item>
1629-
<item row="9" column="1">
1649+
<item row="10" column="1">
16301650
<widget class="QCheckBox" name="checkCloseButtonOnTabs">
16311651
<property name="toolTip">
16321652
<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>

src/Settings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,9 +356,9 @@ QVariant Settings::getDefaultValue(const std::string& group, const std::string&
356356
if(group == "editor")
357357
{
358358
if(name == "tabsize")
359-
{
360359
return 4;
361-
}
360+
if(name == "indentation_use_tabs")
361+
return true;
362362
}
363363

364364
// editor/wrap_lines

0 commit comments

Comments
 (0)