Add autoSurround setting

This commit is contained in:
Yoann Quenach de Quivillic 2023-01-10 00:56:00 +01:00 committed by Nyall Dawson
parent 59332e0984
commit e6f2fc1288
3 changed files with 13 additions and 2 deletions

View File

@ -203,6 +203,7 @@ class ConsoleOptionsWidget(QWidget, Ui_SettingsDialogPythonConsole):
settings.setValue("pythonConsole/enableObjectInsp", self.enableObjectInspector.isChecked())
settings.setValue("pythonConsole/autoCloseBracket", self.autoCloseBracket.isChecked())
settings.setValue("pythonConsole/autoSurround", self.autoSurround.isChecked())
settings.setValue("pythonConsole/autoInsertImport", self.autoInsertImport.isChecked())
def restoreSettings(self):
@ -227,6 +228,7 @@ class ConsoleOptionsWidget(QWidget, Ui_SettingsDialogPythonConsole):
self.enableObjectInspector.setChecked(settings.value("pythonConsole/enableObjectInsp", False, type=bool))
self.autoCloseBracket.setChecked(settings.value("pythonConsole/autoCloseBracket", True, type=bool))
self.autoSurround.setChecked(settings.value("pythonConsole/autoSurround", True, type=bool))
self.autoInsertImport.setChecked(settings.value("pythonConsole/autoInsertImport", False, type=bool))
if settings.value("pythonConsole/autoCompleteSource") == 'fromDoc':

View File

@ -90,7 +90,14 @@
</property>
</widget>
</item>
<item row="1" column="0">
<item row="1" column="0">
<widget class="QCheckBox" name="autoSurround">
<property name="text">
<string>Automatically surround selection when typing quotes or brackets</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="autoInsertImport">
<property name="text">
<string>Automatic insertion of the 'import' string on 'from xxx'</string>
@ -464,6 +471,7 @@
<tabstop>autoCompFromAPI</tabstop>
<tabstop>autoCompFromDocAPI</tabstop>
<tabstop>autoCloseBracket</tabstop>
<tabstop>autoSurround</tabstop>
<tabstop>autoInsertImport</tabstop>
<tabstop>enableObjectInspector</tabstop>
<tabstop>autoSaveScript</tabstop>

View File

@ -221,6 +221,7 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
const QgsSettings settings;
bool autoCloseBracket = settings.value( QStringLiteral( "/pythonConsole/autoCloseBracket" ), true ).toBool();
bool autoSurround = settings.value( QStringLiteral( "/pythonConsole/autoSurround" ), true ).toBool();
bool autoInsertImport = settings.value( QStringLiteral( "/pythonConsole/autoInsertImport" ), false ).toBool();
// Update calltips when cursor position changes with left and right keys
@ -241,7 +242,7 @@ void QgsCodeEditorPython::keyPressEvent( QKeyEvent *event )
// If some text is selected and user presses an opening character
// surround the selection with the opening-closing pair
if ( hasSelectedText() )
if ( hasSelectedText() && autoSurround )
{
if ( PAIRS.contains( eText ) )
{