Expose setting for external Python editor

Adds user visible option to set the external Python code editor,
from the Settings - Options - IDE - Python tab.
This commit is contained in:
Nyall Dawson 2024-06-17 09:21:51 +10:00
parent 73ff4adc7e
commit 970196c84a
2 changed files with 99 additions and 59 deletions

View File

@ -221,6 +221,8 @@ class ConsoleOptionsWidget(QWidget, Ui_SettingsDialogPythonConsole):
pythonSettingsTreeNode.childSetting("autopep8-level").setValue(self.autopep8Level.value())
pythonSettingsTreeNode.childSetting("black-normalize-quotes").setValue(self.blackNormalizeQuotes.isChecked())
pythonSettingsTreeNode.childSetting("max-line-length").setValue(self.maxLineLength.value())
pythonSettingsTreeNode.childSetting('external-editor').setValue(
self.externalEditor.text())
def restoreSettings(self):
settings = QgsSettings()
@ -263,6 +265,10 @@ class ConsoleOptionsWidget(QWidget, Ui_SettingsDialogPythonConsole):
elif settings.value("pythonConsole/autoCompleteSource") == 'fromDocAPI':
self.autoCompFromDocAPI.setChecked(True)
self.externalEditor.setText(
pythonSettingsTreeNode.childSetting('external-editor').value()
)
def onFormatterChanged(self):
""" Toggle formatter-specific options visibility when the formatter is changed """
if self.formatter.currentText() == 'autopep8':

View File

@ -52,9 +52,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>789</width>
<height>974</height>
<y>-192</y>
<width>775</width>
<height>1166</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
@ -173,6 +173,20 @@
<property name="verticalSpacing">
<number>2</number>
</property>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="sortImports">
<property name="text">
<string>Sort imports</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Maximum line length</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QgsSpinBox" name="maxLineLength">
<property name="minimum">
@ -186,51 +200,6 @@
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="formatOnSave">
<property name="text">
<string>Reformat on save</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="blackNormalizeQuotes">
<property name="text">
<string>Normalize quotes</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="formatter">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="sortImports">
<property name="text">
<string>Sort imports</string>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="autopep8LevelLabel">
<property name="text">
<string>Autopep8 level</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_8">
<property name="text">
<string>Maximum line length</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="label">
<property name="text">
@ -248,6 +217,37 @@
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="autopep8LevelLabel">
<property name="text">
<string>Autopep8 level</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="2">
<widget class="QCheckBox" name="blackNormalizeQuotes">
<property name="text">
<string>Normalize quotes</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QCheckBox" name="formatOnSave">
<property name="text">
<string>Reformat on save</string>
</property>
</widget>
</item>
<item row="3" column="1">
<widget class="QComboBox" name="formatter">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
</widget>
</item>
<item row="0" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
@ -265,7 +265,7 @@
</widget>
</item>
<item row="6" column="0">
<widget class="QGroupBox" name="groupBox">
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<property name="title">
<string>GitHub Access Token</string>
</property>
@ -322,6 +322,19 @@
</layout>
</widget>
</item>
<item row="8" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="5" column="0">
<widget class="QgsCollapsibleGroupBox" name="groupBoxApi">
<property name="title">
@ -564,17 +577,33 @@
</widget>
</item>
<item row="7" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
<widget class="QgsCollapsibleGroupBox" name="groupBox_2">
<property name="title">
<string>External Editor</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
<layout class="QGridLayout" name="gridLayout_8">
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;Command to launch an external Python code editor. If empty, the default system editor will be used.&lt;/p&gt;&lt;p&gt;Use the token &lt;span style=&quot; font-style:italic;&quot;&gt;&amp;lt;file&amp;gt;&lt;/span&gt; to insert the filename, &lt;span style=&quot; font-style:italic;&quot;&gt;&amp;lt;line&amp;gt;&lt;/span&gt; to insert line number, and &lt;span style=&quot; font-style:italic;&quot;&gt;&amp;lt;col&amp;gt;&lt;/span&gt; to insert the column number. For example:&lt;br/&gt;&lt;span style=&quot; font-family:'Noto Sans Mono';&quot;&gt;kate -l &amp;lt;line&amp;gt; -c &amp;lt;col&amp;gt; &amp;quot;&amp;lt;file&amp;gt;&amp;quot;&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::TextBrowserInteraction</set>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QgsFilterLineEdit" name="externalEditor">
<property name="placeholderText">
<string>Default</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
@ -594,6 +623,11 @@
<extends>QSpinBox</extends>
<header>qgis.gui</header>
</customwidget>
<customwidget>
<class>QgsFilterLineEdit</class>
<extends>QLineEdit</extends>
<header>qgis.gui</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>groupBoxAutoCompletion</tabstop>