diff --git a/python/console/console_settings.py b/python/console/console_settings.py index 230eb164801..095cf14f78b 100644 --- a/python/console/console_settings.py +++ b/python/console/console_settings.py @@ -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': diff --git a/python/console/console_settings.ui b/python/console/console_settings.ui index faeea10c49f..381fb5d5880 100644 --- a/python/console/console_settings.ui +++ b/python/console/console_settings.ui @@ -90,7 +90,14 @@ - + + + + Automatically surround selection when typing quotes or brackets + + + + Automatic insertion of the 'import' string on 'from xxx' @@ -464,6 +471,7 @@ autoCompFromAPI autoCompFromDocAPI autoCloseBracket + autoSurround autoInsertImport enableObjectInspector autoSaveScript diff --git a/src/gui/codeeditors/qgscodeeditorpython.cpp b/src/gui/codeeditors/qgscodeeditorpython.cpp index 476732d1308..7fed193183c 100644 --- a/src/gui/codeeditors/qgscodeeditorpython.cpp +++ b/src/gui/codeeditors/qgscodeeditorpython.cpp @@ -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 ) ) {