Skip to content

Commit

Permalink
[processing] fix button font size in script editor
Browse files Browse the repository at this point in the history
fixes the zooming of the font size in script editor dialog using another method
  • Loading branch information
ghtmtt committed Oct 18, 2016
1 parent 76eb086 commit 7f3b10b
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions python/plugins/processing/gui/ScriptEditorDialog.py
Expand Up @@ -16,7 +16,6 @@
* *
***************************************************************************
"""
from builtins import str

__author__ = 'Alexander Bruy'
__date__ = 'December 2012'
Expand Down Expand Up @@ -98,8 +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.btnIncreaseFont.clicked.connect(self.editor.zoomIn)
self.btnDecreaseFont.clicked.connect(self.editor.zoomOut)
self.editor.textChanged.connect(lambda: self.setHasChanged(True))

self.alg = alg
Expand Down Expand Up @@ -139,19 +138,10 @@ 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 list(self.snippets.items()):
for name, snippet in self.snippets.iteritems():
action = QAction(self.tr(name), self.btnSnippets)
action.triggered[()].connect(lambda snippet=snippet: self.editor.insert(snippet))
popupmenu.addAction(action)
Expand All @@ -173,9 +163,9 @@ def closeEvent(self, evt):
def editHelp(self):
if self.alg is None:
if self.algType == self.SCRIPT_PYTHON:
alg = ScriptAlgorithm(None, str(self.editor.text()))
alg = ScriptAlgorithm(None, unicode(self.editor.text()))
elif self.algType == self.SCRIPT_R:
alg = RAlgorithm(None, str(self.editor.text()))
alg = RAlgorithm(None, unicode(self.editor.text()))
else:
alg = self.alg

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

self.filename, selected_filter = QFileDialog.getOpenFileName(
self.filename = QFileDialog.getOpenFileName(
self, self.tr('Open script'), scriptDir, filterName)

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

self.filename, filter = QFileDialog.getSaveFileName(self,
self.filename = unicode(QFileDialog.getSaveFileName(self,
self.tr('Save script'), scriptDir,
filterName)
filterName))

if self.filename:
if self.algType == self.SCRIPT_PYTHON and \
Expand All @@ -243,7 +233,7 @@ def saveScript(self, saveAs):
not self.filename.lower().endswith('.rsx'):
self.filename += '.rsx'

text = str(self.editor.text())
text = unicode(self.editor.text())
if self.alg is not None:
self.alg.script = text
try:
Expand All @@ -252,7 +242,7 @@ def saveScript(self, saveAs):
except IOError:
QMessageBox.warning(self, self.tr('I/O error'),
self.tr('Unable to save edits. Reason:\n %s')
% str(sys.exc_info()[1])
% unicode(sys.exc_info()[1])
)
return
self.update = True
Expand All @@ -273,10 +263,10 @@ def setHasChanged(self, hasChanged):

def runAlgorithm(self):
if self.algType == self.SCRIPT_PYTHON:
alg = ScriptAlgorithm(None, str(self.editor.text()))
alg = ScriptAlgorithm(None, unicode(self.editor.text()))
alg.provider = algList.getProviderFromName('script')
if self.algType == self.SCRIPT_R:
alg = RAlgorithm(None, str(self.editor.text()))
alg = RAlgorithm(None, unicode(self.editor.text()))
alg.provider = algList.getProviderFromName('r')

dlg = alg.getCustomParametersDialog()
Expand Down

0 comments on commit 7f3b10b

Please sign in to comment.