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