Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[processing] allow changing font size in script editor
fixes #11328
  • Loading branch information
volaya committed Jul 3, 2015
1 parent de72874 commit 7d8e188
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 2 deletions.
8 changes: 6 additions & 2 deletions python/plugins/processing/gui/ScriptEdit.py
Expand Up @@ -59,7 +59,7 @@ def setCommonOptions(self):
font = QFont()
font.setFamily('Courier')
font.setFixedPitch(True)
font.setPointSize(10)
font.setPointSize(20)
self.setFont(font)
self.setMarginsFont(font)

Expand Down Expand Up @@ -105,10 +105,14 @@ def setCommonOptions(self):
self.setAutoCompletionThreshold(2)
self.setAutoCompletionSource(QsciScintilla.AcsAPIs)

self.setFonts(10)

def setFonts(self, size):

# Load font from Python console settings
settings = QSettings()
fontName = settings.value('pythonConsole/fontfamilytext', 'Monospace')
fontSize = int(settings.value('pythonConsole/fontsize', 10))
fontSize = int(settings.value('pythonConsole/fontsize', size))

self.defaultFont = QFont(fontName)
self.defaultFont.setFixedPitch(True)
Expand Down
12 changes: 12 additions & 0 deletions python/plugins/processing/gui/ScriptEditorDialog.py
Expand Up @@ -97,6 +97,8 @@ def __init__(self, algType, alg):
self.btnPaste.clicked.connect(self.editor.paste)
self.btnUndo.clicked.connect(self.editor.undo)
self.btnRedo.clicked.connect(self.editor.redo)
self.btnIncreaseFont.clicked.connect(self.increaseFontSize)
self.btnDecreaseFont.clicked.connect(self.decreaseFontSize)
self.editor.textChanged.connect(lambda: self.setHasChanged(True))

self.alg = alg
Expand Down Expand Up @@ -136,6 +138,16 @@ def __init__(self, algType, alg):

self.editor.setLexerType(self.algType)

def increaseFontSize(self):
font = self.editor.defaultFont
self.editor.setFonts(font.pointSize() + 1)
self.editor.initLexer()

def decreaseFontSize(self):
font = self.editor.defaultFont
self.editor.setFonts(font.pointSize() - 1)
self.editor.initLexer()

def showSnippets(self, evt):
popupmenu = QMenu()
for name, snippet in self.snippets.iteritems():
Expand Down
27 changes: 27 additions & 0 deletions python/plugins/processing/ui/DlgScriptEditor.ui
Expand Up @@ -236,6 +236,33 @@
</property>
</widget>
</item>
<item>
<widget class="Line" name="line_6">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnIncreaseFont">
<property name="text">
<string>A+</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="btnDecreaseFont">
<property name="text">
<string>A-</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
Expand Down

0 comments on commit 7d8e188

Please sign in to comment.