##// END OF EJS Templates
Fixed bug in ConsoleWidget where text could be dragged and dropped.
epatters -
Show More
@@ -11,6 +11,27 b' from ansi_code_processor import QtAnsiCodeProcessor'
11 from completion_widget import CompletionWidget
11 from completion_widget import CompletionWidget
12
12
13
13
14 class ConsolePlainTextEdit(QtGui.QPlainTextEdit):
15 """ A QPlainTextEdit suitable for use with ConsoleWidget.
16 """
17 # Prevents text from being moved by drag and drop. Note that is not, for
18 # some reason, sufficient to catch drag events in the ConsoleWidget's
19 # event filter.
20 def dragEnterEvent(self, event): pass
21 def dragLeaveEvent(self, event): pass
22 def dragMoveEvent(self, event): pass
23 def dropEvent(self, event): pass
24
25 class ConsoleTextEdit(QtGui.QTextEdit):
26 """ A QTextEdit suitable for use with ConsoleWidget.
27 """
28 # See above.
29 def dragEnterEvent(self, event): pass
30 def dragLeaveEvent(self, event): pass
31 def dragMoveEvent(self, event): pass
32 def dropEvent(self, event): pass
33
34
14 class ConsoleWidget(QtGui.QWidget):
35 class ConsoleWidget(QtGui.QWidget):
15 """ An abstract base class for console-type widgets. This class has
36 """ An abstract base class for console-type widgets. This class has
16 functionality for:
37 functionality for:
@@ -161,16 +182,10 b' class ConsoleWidget(QtGui.QWidget):'
161 event.accept()
182 event.accept()
162 return False
183 return False
163
184
164 elif obj == self._control:
185 elif etype == QtCore.QEvent.KeyPress:
165 # Disable moving text by drag and drop.
186 if obj == self._control:
166 if etype == QtCore.QEvent.DragMove:
167 return True
168
169 elif etype == QtCore.QEvent.KeyPress:
170 return self._event_filter_console_keypress(event)
187 return self._event_filter_console_keypress(event)
171
188 elif obj == self._page_control:
172 elif obj == self._page_control:
173 if etype == QtCore.QEvent.KeyPress:
174 return self._event_filter_page_keypress(event)
189 return self._event_filter_page_keypress(event)
175
190
176 return super(ConsoleWidget, self).eventFilter(obj, event)
191 return super(ConsoleWidget, self).eventFilter(obj, event)
@@ -546,9 +561,9 b' class ConsoleWidget(QtGui.QWidget):'
546 """ Creates and connects the underlying text widget.
561 """ Creates and connects the underlying text widget.
547 """
562 """
548 if kind == 'plain':
563 if kind == 'plain':
549 control = QtGui.QPlainTextEdit()
564 control = ConsolePlainTextEdit()
550 elif kind == 'rich':
565 elif kind == 'rich':
551 control = QtGui.QTextEdit()
566 control = ConsoleTextEdit()
552 control.setAcceptRichText(False)
567 control.setAcceptRichText(False)
553 else:
568 else:
554 raise ValueError("Kind %s unknown." % repr(kind))
569 raise ValueError("Kind %s unknown." % repr(kind))
@@ -566,7 +581,7 b' class ConsoleWidget(QtGui.QWidget):'
566 def _create_page_control(self):
581 def _create_page_control(self):
567 """ Creates and connects the underlying paging widget.
582 """ Creates and connects the underlying paging widget.
568 """
583 """
569 control = QtGui.QPlainTextEdit()
584 control = ConsolePlainTextEdit()
570 control.installEventFilter(self)
585 control.installEventFilter(self)
571 control.setReadOnly(True)
586 control.setReadOnly(True)
572 control.setUndoRedoEnabled(False)
587 control.setUndoRedoEnabled(False)
General Comments 0
You need to be logged in to leave comments. Login now