Show More
@@ -265,7 +265,6 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
265 | 265 | elif self.gui_completion == 'plain': |
|
266 | 266 | self._completion_widget = CompletionPlain(self) |
|
267 | 267 | |
|
268 | self._anchor = None | |
|
269 | 268 | self._continuation_prompt = '> ' |
|
270 | 269 | self._continuation_prompt_html = None |
|
271 | 270 | self._executing = False |
@@ -437,12 +436,7 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
437 | 436 | |
|
438 | 437 | elif etype == QtCore.QEvent.MouseMove: |
|
439 | 438 | anchor = self._control.anchorAt(event.pos()) |
|
440 | if len(anchor) == 0: | |
|
441 | self._anchor = None | |
|
442 | QtGui.QToolTip.hideText() | |
|
443 | elif anchor != self._anchor: | |
|
444 | self._anchor = anchor | |
|
445 | QtGui.QToolTip.showText(event.globalPos(), self._anchor) | |
|
439 | QtGui.QToolTip.showText(event.globalPos(), anchor) | |
|
446 | 440 | |
|
447 | 441 | return super(ConsoleWidget, self).eventFilter(obj, event) |
|
448 | 442 | |
@@ -523,11 +517,10 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
523 | 517 | """ |
|
524 | 518 | self.layout().currentWidget().copy() |
|
525 | 519 | |
|
526 | def copy_anchor(self): | |
|
520 | def copy_anchor(self, anchor): | |
|
527 | 521 | """ Copy anchor text to the clipboard |
|
528 | 522 | """ |
|
529 | if self._anchor: | |
|
530 | QtGui.QApplication.clipboard().setText(self._anchor) | |
|
523 | QtGui.QApplication.clipboard().setText(anchor) | |
|
531 | 524 | |
|
532 | 525 | def cut(self): |
|
533 | 526 | """ Copy the currently selected text to the clipboard and delete it |
@@ -696,11 +689,10 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
696 | 689 | |
|
697 | 690 | font = property(_get_font, _set_font) |
|
698 | 691 | |
|
699 | def open_anchor(self): | |
|
692 | def open_anchor(self, anchor): | |
|
700 | 693 | """ Open selected anchor in the default webbrowser |
|
701 | 694 | """ |
|
702 | if self._anchor: | |
|
703 | webbrowser.open( self._anchor ) | |
|
695 | webbrowser.open( anchor ) | |
|
704 | 696 | |
|
705 | 697 | def paste(self, mode=QtGui.QClipboard.Clipboard): |
|
706 | 698 | """ Paste the contents of the clipboard into the input region. |
@@ -995,12 +987,13 b' class ConsoleWidget(LoggingConfigurable, QtGui.QWidget):' | |||
|
995 | 987 | self.paste_action.setEnabled(self.can_paste()) |
|
996 | 988 | self.paste_action.setShortcut(QtGui.QKeySequence.Paste) |
|
997 | 989 | |
|
998 |
|
|
|
990 | anchor = self._control.anchorAt(pos) | |
|
991 | if anchor: | |
|
999 | 992 | menu.addSeparator() |
|
1000 |
self.copy_link_action = menu.addAction( |
|
|
1001 | self.copy_anchor) | |
|
1002 |
self.open_link_action = menu.addAction( |
|
|
1003 | self.open_anchor) | |
|
993 | self.copy_link_action = menu.addAction( | |
|
994 | 'Copy Link Address', lambda: self.copy_anchor(anchor=anchor)) | |
|
995 | self.open_link_action = menu.addAction( | |
|
996 | 'Open Link', lambda: self.open_anchor(anchor=anchor)) | |
|
1004 | 997 | |
|
1005 | 998 | menu.addSeparator() |
|
1006 | 999 | menu.addAction(self.select_all_action) |
@@ -53,21 +53,28 b' class TestConsoleWidget(unittest.TestCase):' | |||
|
53 | 53 | cursor = w._get_prompt_cursor() |
|
54 | 54 | w._insert_html(cursor, '<a href="http://python.org">written in</a>') |
|
55 | 55 | obj = w._control |
|
56 | self.assertEqual(w._anchor, None) | |
|
56 | tip = QtGui.QToolTip | |
|
57 | self.assertEqual(tip.text(), u'') | |
|
57 | 58 | |
|
59 | # should be somewhere else | |
|
60 | elsewhereEvent = QMouseEvent(MouseMove, QtCore.QPoint(50,50), | |
|
61 | noButton, noButtons, noModifiers) | |
|
62 | w.eventFilter(obj, elsewhereEvent) | |
|
63 | self.assertEqual(tip.isVisible(), False) | |
|
64 | self.assertEqual(tip.text(), u'') | |
|
65 | ||
|
66 | #self.assertEqual(tip.text(), u'') | |
|
58 | 67 | # should be over text |
|
59 | 68 | overTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5), |
|
60 | 69 | noButton, noButtons, noModifiers) |
|
61 | 70 | w.eventFilter(obj, overTextEvent) |
|
62 | self.assertEqual(w._anchor, "http://python.org") | |
|
71 | self.assertEqual(tip.isVisible(), True) | |
|
72 | self.assertEqual(tip.text(), "http://python.org") | |
|
63 | 73 | |
|
64 | 74 | # should still be over text |
|
65 | 75 | stillOverTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5), |
|
66 | 76 | noButton, noButtons, noModifiers) |
|
67 | 77 | w.eventFilter(obj, stillOverTextEvent) |
|
78 | self.assertEqual(tip.isVisible(), True) | |
|
79 | self.assertEqual(tip.text(), "http://python.org") | |
|
68 | 80 | |
|
69 | # should be somewhere else | |
|
70 | elsewhereEvent = QMouseEvent(MouseMove, QtCore.QPoint(50,50), | |
|
71 | noButton, noButtons, noModifiers) | |
|
72 | w.eventFilter(obj, elsewhereEvent) | |
|
73 | self.assertEqual(w._anchor, None) |
General Comments 0
You need to be logged in to leave comments.
Login now