Skip to content

Commit

Permalink
Merge pull request OpenShot#3006 from ferdnyc/blender-qplaintextedit
Browse files Browse the repository at this point in the history
Animated Titles: Use QPlainTextEdit for multi-line
  • Loading branch information
jonoomph authored Nov 17, 2019
2 parents ec0cd97 + 10e47f2 commit b0a074f
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions src/windows/views/blender_listview.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,6 @@

import json

class QBlenderEvent(QEvent):
""" A custom Blender QEvent, which can safely be sent from the Blender thread to the Qt thread (to communicate) """

def __init__(self, id, data=None, *args):
# Invoke parent init
QEvent.__init__(self, id)
self.data = data
self.id = id


class BlenderListView(QListView):
""" A TreeView QWidget used on the animated title window """
Expand Down Expand Up @@ -127,8 +118,8 @@ def currentChanged(self, selected, deselected):
self.params[param["name"]] = _(param["default"])

# create spinner
widget = QTextEdit()
widget.setText(_(param["default"]).replace("\\n", "\n"))
widget = QPlainTextEdit()
widget.setPlainText(_(param["default"]).replace("\\n", "\n"))
widget.textChanged.connect(functools.partial(self.text_value_changed, widget, param))

elif param["type"] == "dropdown":
Expand Down Expand Up @@ -199,11 +190,11 @@ def spinner_value_changed(self, param, value):

def text_value_changed(self, widget, param, value=None):
try:
# Attempt to load value from QTextEdit (i.e. multi-line)
# Attempt to load value from QPlainTextEdit (i.e. multi-line)
if not value:
value = widget.toPlainText()
except:
pass
except Exception:
return
self.params[param["name"]] = value.replace("\n", "\\n")
# XXX: This will log every individual KEYPRESS in the text field.
# log.info('Animation param %s set to %s' % (param["name"], value))
Expand Down

0 comments on commit b0a074f

Please sign in to comment.