Skip to content

Commit 7f3b10b

Browse files
authored
[processing] fix button font size in script editor
fixes the zooming of the font size in script editor dialog using another method
1 parent 76eb086 commit 7f3b10b

File tree

1 file changed

+12
-22
lines changed

1 file changed

+12
-22
lines changed

python/plugins/processing/gui/ScriptEditorDialog.py

+12-22
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
* *
1717
***************************************************************************
1818
"""
19-
from builtins import str
2019

2120
__author__ = 'Alexander Bruy'
2221
__date__ = 'December 2012'
@@ -98,8 +97,8 @@ def __init__(self, algType, alg):
9897
self.btnPaste.clicked.connect(self.editor.paste)
9998
self.btnUndo.clicked.connect(self.editor.undo)
10099
self.btnRedo.clicked.connect(self.editor.redo)
101-
self.btnIncreaseFont.clicked.connect(self.increaseFontSize)
102-
self.btnDecreaseFont.clicked.connect(self.decreaseFontSize)
100+
self.btnIncreaseFont.clicked.connect(self.editor.zoomIn)
101+
self.btnDecreaseFont.clicked.connect(self.editor.zoomOut)
103102
self.editor.textChanged.connect(lambda: self.setHasChanged(True))
104103

105104
self.alg = alg
@@ -139,19 +138,10 @@ def __init__(self, algType, alg):
139138

140139
self.editor.setLexerType(self.algType)
141140

142-
def increaseFontSize(self):
143-
font = self.editor.defaultFont
144-
self.editor.setFonts(font.pointSize() + 1)
145-
self.editor.initLexer()
146-
147-
def decreaseFontSize(self):
148-
font = self.editor.defaultFont
149-
self.editor.setFonts(font.pointSize() - 1)
150-
self.editor.initLexer()
151141

152142
def showSnippets(self, evt):
153143
popupmenu = QMenu()
154-
for name, snippet in list(self.snippets.items()):
144+
for name, snippet in self.snippets.iteritems():
155145
action = QAction(self.tr(name), self.btnSnippets)
156146
action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet))
157147
popupmenu.addAction(action)
@@ -173,9 +163,9 @@ def closeEvent(self, evt):
173163
def editHelp(self):
174164
if self.alg is None:
175165
if self.algType == self.SCRIPT_PYTHON:
176-
alg = ScriptAlgorithm(None, str(self.editor.text()))
166+
alg = ScriptAlgorithm(None, unicode(self.editor.text()))
177167
elif self.algType == self.SCRIPT_R:
178-
alg = RAlgorithm(None, str(self.editor.text()))
168+
alg = RAlgorithm(None, unicode(self.editor.text()))
179169
else:
180170
alg = self.alg
181171

@@ -200,7 +190,7 @@ def openScript(self):
200190
scriptDir = RUtils.RScriptsFolders()[0]
201191
filterName = self.tr('Processing R script (*.rsx)')
202192

203-
self.filename, selected_filter = QFileDialog.getOpenFileName(
193+
self.filename = QFileDialog.getOpenFileName(
204194
self, self.tr('Open script'), scriptDir, filterName)
205195

206196
if self.filename == '':
@@ -231,9 +221,9 @@ def saveScript(self, saveAs):
231221
scriptDir = RUtils.RScriptsFolders()[0]
232222
filterName = self.tr('Processing R script (*.rsx)')
233223

234-
self.filename, filter = QFileDialog.getSaveFileName(self,
224+
self.filename = unicode(QFileDialog.getSaveFileName(self,
235225
self.tr('Save script'), scriptDir,
236-
filterName)
226+
filterName))
237227

238228
if self.filename:
239229
if self.algType == self.SCRIPT_PYTHON and \
@@ -243,7 +233,7 @@ def saveScript(self, saveAs):
243233
not self.filename.lower().endswith('.rsx'):
244234
self.filename += '.rsx'
245235

246-
text = str(self.editor.text())
236+
text = unicode(self.editor.text())
247237
if self.alg is not None:
248238
self.alg.script = text
249239
try:
@@ -252,7 +242,7 @@ def saveScript(self, saveAs):
252242
except IOError:
253243
QMessageBox.warning(self, self.tr('I/O error'),
254244
self.tr('Unable to save edits. Reason:\n %s')
255-
% str(sys.exc_info()[1])
245+
% unicode(sys.exc_info()[1])
256246
)
257247
return
258248
self.update = True
@@ -273,10 +263,10 @@ def setHasChanged(self, hasChanged):
273263

274264
def runAlgorithm(self):
275265
if self.algType == self.SCRIPT_PYTHON:
276-
alg = ScriptAlgorithm(None, str(self.editor.text()))
266+
alg = ScriptAlgorithm(None, unicode(self.editor.text()))
277267
alg.provider = algList.getProviderFromName('script')
278268
if self.algType == self.SCRIPT_R:
279-
alg = RAlgorithm(None, str(self.editor.text()))
269+
alg = RAlgorithm(None, unicode(self.editor.text()))
280270
alg.provider = algList.getProviderFromName('r')
281271

282272
dlg = alg.getCustomParametersDialog()

0 commit comments

Comments
 (0)