Skip to content

Commit 7d8e188

Browse files
committed
[processing] allow changing font size in script editor
fixes #11328
1 parent de72874 commit 7d8e188

File tree

3 files changed

+45
-2
lines changed

3 files changed

+45
-2
lines changed

python/plugins/processing/gui/ScriptEdit.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def setCommonOptions(self):
5959
font = QFont()
6060
font.setFamily('Courier')
6161
font.setFixedPitch(True)
62-
font.setPointSize(10)
62+
font.setPointSize(20)
6363
self.setFont(font)
6464
self.setMarginsFont(font)
6565

@@ -105,10 +105,14 @@ def setCommonOptions(self):
105105
self.setAutoCompletionThreshold(2)
106106
self.setAutoCompletionSource(QsciScintilla.AcsAPIs)
107107

108+
self.setFonts(10)
109+
110+
def setFonts(self, size):
111+
108112
# Load font from Python console settings
109113
settings = QSettings()
110114
fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
111-
fontSize = int(settings.value('pythonConsole/fontsize', 10))
115+
fontSize = int(settings.value('pythonConsole/fontsize', size))
112116

113117
self.defaultFont = QFont(fontName)
114118
self.defaultFont.setFixedPitch(True)

python/plugins/processing/gui/ScriptEditorDialog.py

+12
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@ def __init__(self, algType, alg):
9797
self.btnPaste.clicked.connect(self.editor.paste)
9898
self.btnUndo.clicked.connect(self.editor.undo)
9999
self.btnRedo.clicked.connect(self.editor.redo)
100+
self.btnIncreaseFont.clicked.connect(self.increaseFontSize)
101+
self.btnDecreaseFont.clicked.connect(self.decreaseFontSize)
100102
self.editor.textChanged.connect(lambda: self.setHasChanged(True))
101103

102104
self.alg = alg
@@ -136,6 +138,16 @@ def __init__(self, algType, alg):
136138

137139
self.editor.setLexerType(self.algType)
138140

141+
def increaseFontSize(self):
142+
font = self.editor.defaultFont
143+
self.editor.setFonts(font.pointSize() + 1)
144+
self.editor.initLexer()
145+
146+
def decreaseFontSize(self):
147+
font = self.editor.defaultFont
148+
self.editor.setFonts(font.pointSize() - 1)
149+
self.editor.initLexer()
150+
139151
def showSnippets(self, evt):
140152
popupmenu = QMenu()
141153
for name, snippet in self.snippets.iteritems():

python/plugins/processing/ui/DlgScriptEditor.ui

+27
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,33 @@
236236
</property>
237237
</widget>
238238
</item>
239+
<item>
240+
<widget class="Line" name="line_6">
241+
<property name="orientation">
242+
<enum>Qt::Vertical</enum>
243+
</property>
244+
</widget>
245+
</item>
246+
<item>
247+
<widget class="QToolButton" name="btnIncreaseFont">
248+
<property name="text">
249+
<string>A+</string>
250+
</property>
251+
<property name="autoRaise">
252+
<bool>true</bool>
253+
</property>
254+
</widget>
255+
</item>
256+
<item>
257+
<widget class="QToolButton" name="btnDecreaseFont">
258+
<property name="text">
259+
<string>A-</string>
260+
</property>
261+
<property name="autoRaise">
262+
<bool>true</bool>
263+
</property>
264+
</widget>
265+
</item>
239266
<item>
240267
<spacer name="horizontalSpacer">
241268
<property name="orientation">

0 commit comments

Comments
 (0)