Skip to content

Commit

Permalink
Merged console and editor settings stuff
Browse files Browse the repository at this point in the history
So the Editor and Console etc share one set of settings:
- Merged Editor and Console settings-tabs in one Settings tab in the settings dialog
- Removed the Editor ui from the settings dialog
- Changed all names of settings in Editor so it uses the normal/console settings
  • Loading branch information
rduivenvoorde committed Aug 27, 2020
1 parent a48e85a commit 09fc2e6
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 408 deletions.
2 changes: 1 addition & 1 deletion python/console/console_base.py
Expand Up @@ -69,7 +69,7 @@ def __init__(self, parent=None):
self.setMarginWidth(0, "00000")
# Margin 1 is used for the '>>>' prompt (console input)
self.setMarginWidth(1, "0")
self.setMarginType(1, 5) # TextMarginRightJustified=5
self.setMarginType(1, 5) # TextMarginRightJustified=5
# Margin 2 is used for the 'folding' (editor)
self.setMarginWidth(2, "0")

Expand Down
16 changes: 8 additions & 8 deletions python/console/console_editor.py
Expand Up @@ -179,9 +179,9 @@ def settingsEditor(self):

# Set Python lexer
self.setLexers()
threshold = self.settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int)
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True, type=bool)
threshold = self.settings.value("pythonConsole/autoCompThreshold", 2, type=int)
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True, type=bool)
self.setAutoCompletionThreshold(threshold)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
Expand All @@ -199,8 +199,8 @@ def settingsEditor(self):
self.setCaretForegroundColor(cursorColor)

def autoCompleteKeyBinding(self):
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabledEditor", True, type=bool)
radioButtonSource = self.settings.value("pythonConsole/autoCompleteSource", 'fromAPI')
autoCompEnabled = self.settings.value("pythonConsole/autoCompleteEnabled", True, type=bool)
if autoCompEnabled:
if radioButtonSource == 'fromDoc':
self.autoCompleteFromDocument()
Expand Down Expand Up @@ -579,7 +579,7 @@ def syntaxCheck(self, filename=None, fromContextMenu=True):
if (eline) not in self.bufferMarkerLine:
self.bufferMarkerLine.append(eline)
self.markerAdd(eline, self.MARKER_NUM)
loadFont = self.settings.value("pythonConsole/fontfamilytextEditor",
loadFont = self.settings.value("pythonConsole/fontfamilytext",
"Monospace")
styleAnn = QsciStyle(-1, "Annotation",
QColor(255, 0, 0),
Expand All @@ -601,8 +601,8 @@ def keyPressEvent(self, e):
t = e.text()
startLine, _, endLine, endPos = self.getSelection()
line, pos = self.getCursorPosition()
self.autoCloseBracket = self.settings.value("pythonConsole/autoCloseBracketEditor", False, type=bool)
self.autoImport = self.settings.value("pythonConsole/autoInsertionImportEditor", True, type=bool)
self.autoCloseBracket = self.settings.value("pythonConsole/autoCloseBracket", False, type=bool)
self.autoImport = self.settings.value("pythonConsole/autoInsertionImport", True, type=bool)
txt = self.text(line)[:pos]
# Close bracket automatically
if t in self.opening and self.autoCloseBracket:
Expand Down
32 changes: 0 additions & 32 deletions python/console/console_settings.py
Expand Up @@ -147,35 +147,21 @@ def saveSettings(self):

fontFamilyText = self.fontComboBox.currentText()
settings.setValue("pythonConsole/fontfamilytext", fontFamilyText)
fontFamilyTextEditor = self.fontComboBoxEditor.currentText()
settings.setValue("pythonConsole/fontfamilytextEditor", fontFamilyTextEditor)

fontSize = self.spinBox.value()
fontSizeEditor = self.spinBoxEditor.value()

for i in range(0, self.tableWidget.rowCount()):
text = self.tableWidget.item(i, 1).text()
self.listPath.append(text)
settings.setValue("pythonConsole/fontsize", fontSize)
settings.setValue("pythonConsole/fontsizeEditor", fontSizeEditor)
settings.setValue("pythonConsole/userAPI", self.listPath)

settings.setValue("pythonConsole/autoCompThreshold", self.autoCompThreshold.value())
settings.setValue("pythonConsole/autoCompThresholdEditor", self.autoCompThresholdEditor.value())

settings.setValue("pythonConsole/autoCompleteEnabledEditor", self.groupBoxAutoCompletionEditor.isChecked())
settings.setValue("pythonConsole/autoCompleteEnabled", self.groupBoxAutoCompletion.isChecked())

settings.setValue("pythonConsole/usePreparedAPIFile", self.groupBoxPreparedAPI.isChecked())
settings.setValue("pythonConsole/preparedAPIFile", self.lineEdit.text())

if self.autoCompFromAPIEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", 'fromAPI')
elif self.autoCompFromDocEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", 'fromDoc')
elif self.autoCompFromDocAPIEditor.isChecked():
settings.setValue("pythonConsole/autoCompleteSourceEditor", 'fromDocAPI')

if self.autoCompFromAPI.isChecked():
settings.setValue("pythonConsole/autoCompleteSource", 'fromAPI')
elif self.autoCompFromDoc.isChecked():
Expand All @@ -185,9 +171,7 @@ def saveSettings(self):

settings.setValue("pythonConsole/enableObjectInsp", self.enableObjectInspector.isChecked())
settings.setValue("pythonConsole/autoCloseBracket", self.autoCloseBracket.isChecked())
settings.setValue("pythonConsole/autoCloseBracketEditor", self.autoCloseBracketEditor.isChecked())
settings.setValue("pythonConsole/autoInsertionImport", self.autoInsertionImport.isChecked())
settings.setValue("pythonConsole/autoInsertionImportEditor", self.autoInsertionImportEditor.isChecked())

settings.setValue("pythonConsole/defaultFontColor", self.defaultFontColor.color())
settings.setValue("pythonConsole/classFontColor", self.classFontColor.color())
Expand Down Expand Up @@ -219,11 +203,8 @@ def restoreSettings(self):
settings = QgsSettings()
font = QFontDatabase.systemFont(QFontDatabase.FixedFont)
self.spinBox.setValue(settings.value("pythonConsole/fontsize", font.pointSize(), type=int))
self.spinBoxEditor.setValue(settings.value("pythonConsole/fontsizeEditor", font.pointSize(), type=int))
self.fontComboBox.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytext",
font.family())))
self.fontComboBoxEditor.setCurrentFont(QFont(settings.value("pythonConsole/fontfamilytextEditor",
font.family())))
self.preloadAPI.setChecked(settings.value("pythonConsole/preloadAPI", True, type=bool))
self.lineEdit.setText(settings.value("pythonConsole/preparedAPIFile", "", type=str))
itemTable = settings.value("pythonConsole/userAPI", [])
Expand All @@ -239,16 +220,10 @@ def restoreSettings(self):
self.autoSaveScript.setChecked(settings.value("pythonConsole/autoSaveScript", False, type=bool))

self.autoCompThreshold.setValue(settings.value("pythonConsole/autoCompThreshold", 2, type=int))
self.autoCompThresholdEditor.setValue(settings.value("pythonConsole/autoCompThresholdEditor", 2, type=int))
self.groupBoxAutoCompletionEditor.setChecked(
settings.value("pythonConsole/autoCompleteEnabledEditor", True, type=bool))
self.groupBoxAutoCompletion.setChecked(settings.value("pythonConsole/autoCompleteEnabled", True, type=bool))

self.enableObjectInspector.setChecked(settings.value("pythonConsole/enableObjectInsp", False, type=bool))
self.autoCloseBracketEditor.setChecked(settings.value("pythonConsole/autoCloseBracketEditor", False, type=bool))
self.autoCloseBracket.setChecked(settings.value("pythonConsole/autoCloseBracket", False, type=bool))
self.autoInsertionImportEditor.setChecked(
settings.value("pythonConsole/autoInsertionImportEditor", True, type=bool))
self.autoInsertionImport.setChecked(settings.value("pythonConsole/autoInsertionImport", True, type=bool))

if settings.value("pythonConsole/autoCompleteSource") == 'fromDoc':
Expand All @@ -258,13 +233,6 @@ def restoreSettings(self):
elif settings.value("pythonConsole/autoCompleteSource") == 'fromDocAPI':
self.autoCompFromDocAPI.setChecked(True)

if settings.value("pythonConsole/autoCompleteSourceEditor") == 'fromDoc':
self.autoCompFromDocEditor.setChecked(True)
elif settings.value("pythonConsole/autoCompleteSourceEditor") == 'fromAPI':
self.autoCompFromAPIEditor.setChecked(True)
elif settings.value("pythonConsole/autoCompleteSourceEditor") == 'fromDocAPI':
self.autoCompFromDocAPIEditor.setChecked(True)

# Setting font lexer color
self.defaultFontColor.setColor(QColor(settings.value("pythonConsole/defaultFontColor", QColor(QgsQsciScintillaBase.DEFAULT_COLOR))))
self.keywordFontColor.setColor(QColor(settings.value("pythonConsole/keywordFontColor", QColor(QgsQsciScintillaBase.KEYWORD_COLOR))))
Expand Down

0 comments on commit 09fc2e6

Please sign in to comment.