Show More
@@ -188,6 +188,15 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
188 | 188 | elif obj == self._page_control: |
|
189 | 189 | return self._event_filter_page_keypress(event) |
|
190 | 190 | |
|
191 | # Make middle-click paste safe. | |
|
192 | elif etype == QtCore.QEvent.MouseButtonRelease and \ | |
|
193 | event.button() == QtCore.Qt.MidButton and \ | |
|
194 | obj == self._control.viewport(): | |
|
195 | cursor = self._control.cursorForPosition(event.pos()); | |
|
196 | self._control.setTextCursor(cursor) | |
|
197 | self.paste(QtGui.QClipboard.Selection) | |
|
198 | return True | |
|
199 | ||
|
191 | 200 | # Override shortucts for all filtered widgets. Note that on Mac OS it is |
|
192 | 201 | # always unnecessary to override shortcuts, hence the check below (users |
|
193 | 202 | # should just use the Control key instead of the Command key). |
@@ -415,12 +424,20 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
415 | 424 | |
|
416 | 425 | font = property(_get_font, _set_font) |
|
417 | 426 | |
|
418 | def paste(self): | |
|
427 | def paste(self, mode=QtGui.QClipboard.Clipboard): | |
|
419 | 428 | """ Paste the contents of the clipboard into the input region. |
|
429 | ||
|
430 | Parameters: | |
|
431 | ----------- | |
|
432 | mode : QClipboard::Mode, optional [default QClipboard::Clipboard] | |
|
433 | ||
|
434 | Controls which part of the system clipboard is used. This can be | |
|
435 | used to access the selection clipboard in X11 and the Find buffer | |
|
436 | in Mac OS. By default, the regular clipboard is used. | |
|
420 | 437 | """ |
|
421 | 438 | if self._control.textInteractionFlags() & QtCore.Qt.TextEditable: |
|
422 | 439 | try: |
|
423 | text = str(QtGui.QApplication.clipboard().text()) | |
|
440 | text = str(QtGui.QApplication.clipboard().text(mode)) | |
|
424 | 441 | except UnicodeEncodeError: |
|
425 | 442 | pass |
|
426 | 443 | else: |
@@ -631,18 +648,27 b' class ConsoleWidget(Configurable, QtGui.QWidget):' | |||
|
631 | 648 | def _create_control(self): |
|
632 | 649 | """ Creates and connects the underlying text widget. |
|
633 | 650 | """ |
|
651 | # Create the underlying control. | |
|
634 | 652 | if self.kind == 'plain': |
|
635 | 653 | control = ConsolePlainTextEdit() |
|
636 | 654 | elif self.kind == 'rich': |
|
637 | 655 | control = ConsoleTextEdit() |
|
638 | 656 | control.setAcceptRichText(False) |
|
657 | ||
|
658 | # Install event filters. The filter on the viewport is needed for | |
|
659 | # mouse events. | |
|
639 | 660 | control.installEventFilter(self) |
|
640 | control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) | |
|
661 | control.viewport().installEventFilter(self) | |
|
662 | ||
|
663 | # Connect signals. | |
|
641 | 664 | control.cursorPositionChanged.connect(self._cursor_position_changed) |
|
642 | 665 | control.customContextMenuRequested.connect(self._show_context_menu) |
|
643 | 666 | control.copyAvailable.connect(self.copy_available) |
|
644 | 667 | control.redoAvailable.connect(self.redo_available) |
|
645 | 668 | control.undoAvailable.connect(self.undo_available) |
|
669 | ||
|
670 | # Configure the control. | |
|
671 | control.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) | |
|
646 | 672 | control.setReadOnly(True) |
|
647 | 673 | control.setUndoRedoEnabled(False) |
|
648 | 674 | control.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn) |
General Comments 0
You need to be logged in to leave comments.
Login now