From 9ba1a2edc7bbda231f1544ba671b6ee205364759 Mon Sep 17 00:00:00 2001 From: mgrojo Date: Sun, 15 Aug 2021 17:35:37 +0200 Subject: [PATCH] Execute SQL editor: Use tabs for indentation The QScintilla property is used to provide a new setting. See issue #2800 --- src/ExtendedScintilla.cpp | 4 +++- src/PreferencesDialog.cpp | 2 ++ src/PreferencesDialog.ui | 46 ++++++++++++++++++++++++++++----------- src/Settings.cpp | 4 ++-- 4 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/ExtendedScintilla.cpp b/src/ExtendedScintilla.cpp index 0b861f384..a2f48f574 100644 --- a/src/ExtendedScintilla.cpp +++ b/src/ExtendedScintilla.cpp @@ -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(); diff --git a/src/PreferencesDialog.cpp b/src/PreferencesDialog.cpp index 844033a14..b4f326401 100644 --- a/src/PreferencesDialog.cpp +++ b/src/PreferencesDialog.cpp @@ -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()); @@ -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()); diff --git a/src/PreferencesDialog.ui b/src/PreferencesDialog.ui index 385406ff4..124df7ffd 100644 --- a/src/PreferencesDialog.ui +++ b/src/PreferencesDialog.ui @@ -1471,6 +1471,26 @@ Can be set to 0 for disabling completion. + + + Use tabs for indentation + + + checkAutoCompletion + + + + + + + When set, the Tab key will insert tab and space characters for indentation. Otherwise, just spaces will be used. + + + enabled + + + + &Wrap lines @@ -1480,7 +1500,7 @@ Can be set to 0 for disabling completion. - + @@ -1504,7 +1524,7 @@ Can be set to 0 for disabling completion. - + &Quotes for identifiers @@ -1514,7 +1534,7 @@ Can be set to 0 for disabling completion. - + Choose the quoting mechanism used by the application for identifiers in SQL code. @@ -1539,7 +1559,7 @@ Can be set to 0 for disabling completion. - + Code co&mpletion @@ -1549,14 +1569,14 @@ Can be set to 0 for disabling completion. - + enabled - + Keywords in &UPPER CASE @@ -1566,7 +1586,7 @@ Can be set to 0 for disabling completion. - + When set, the SQL keywords are completed in UPPER CASE letters. @@ -1576,7 +1596,7 @@ Can be set to 0 for disabling completion. - + Error indicators @@ -1586,7 +1606,7 @@ Can be set to 0 for disabling completion. - + 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 @@ -1596,7 +1616,7 @@ Can be set to 0 for disabling completion. - + Hori&zontal tiling @@ -1606,7 +1626,7 @@ Can be set to 0 for disabling completion. - + If enabled the SQL code editor and the result table view are shown side by side instead of one over the other. @@ -1616,7 +1636,7 @@ Can be set to 0 for disabling completion. - + Close button on tabs @@ -1626,7 +1646,7 @@ Can be set to 0 for disabling completion. - + 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. diff --git a/src/Settings.cpp b/src/Settings.cpp index 88d233c30..8c06cafe8 100644 --- a/src/Settings.cpp +++ b/src/Settings.cpp @@ -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