##// END OF EJS Templates
Fixed resize flicker and drag safety.
epatters -
Show More
@@ -150,6 +150,8 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
150 self._continuation_prompt = '> '
150 self._continuation_prompt = '> '
151 self._continuation_prompt_html = None
151 self._continuation_prompt_html = None
152 self._executing = False
152 self._executing = False
153 self._filter_drag = False
154 self._filter_resize = False
153 self._prompt = ''
155 self._prompt = ''
154 self._prompt_html = None
156 self._prompt_html = None
155 self._prompt_pos = 0
157 self._prompt_pos = 0
@@ -195,8 +197,12 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
195 return True
197 return True
196
198
197 # Manually adjust the scrollbars *after* a resize event is dispatched.
199 # Manually adjust the scrollbars *after* a resize event is dispatched.
198 elif etype == QtCore.QEvent.Resize:
200 elif etype == QtCore.QEvent.Resize and not self._filter_resize:
199 QtCore.QTimer.singleShot(0, self._adjust_scrollbars)
201 self._filter_resize = True
202 QtGui.qApp.sendEvent(obj, event)
203 self._adjust_scrollbars()
204 self._filter_resize = False
205 return True
200
206
201 # Override shortcuts for all filtered widgets.
207 # Override shortcuts for all filtered widgets.
202 elif etype == QtCore.QEvent.ShortcutOverride and \
208 elif etype == QtCore.QEvent.ShortcutOverride and \
@@ -205,6 +211,27 b' class ConsoleWidget(Configurable, QtGui.QWidget):'
205 event.key() in self._shortcuts:
211 event.key() in self._shortcuts:
206 event.accept()
212 event.accept()
207
213
214 # Ensure that drags are safe. The problem is that the drag starting
215 # logic, which determines whether the drag is a Copy or Move, is locked
216 # down in QTextControl. If the widget is editable, which it must be if
217 # we're not executing, the drag will be a Move. The following hack
218 # prevents QTextControl from deleting the text by clearing the selection
219 # when a drag leave event originating from this widget is dispatched.
220 # The fact that we have to clear the user's selection is unfortunate,
221 # but the alternative--trying to prevent Qt from using its hardwired
222 # drag logic and writing our own--is worse.
223 elif etype == QtCore.QEvent.DragEnter and \
224 obj == self._control.viewport() and \
225 event.source() == self._control.viewport():
226 self._filter_drag = True
227 elif etype == QtCore.QEvent.DragLeave and \
228 obj == self._control.viewport() and \
229 self._filter_drag:
230 cursor = self._control.textCursor()
231 cursor.clearSelection()
232 self._control.setTextCursor(cursor)
233 self._filter_drag = False
234
208 # Ensure that drops are safe.
235 # Ensure that drops are safe.
209 elif etype == QtCore.QEvent.Drop and obj == self._control.viewport():
236 elif etype == QtCore.QEvent.Drop and obj == self._control.viewport():
210 cursor = self._control.cursorForPosition(event.pos())
237 cursor = self._control.cursorForPosition(event.pos())
General Comments 0
You need to be logged in to leave comments. Login now