Show More
@@ -98,6 +98,7 b' class CallTipWidget(QtGui.QLabel):' | |||||
98 | def show_tip(self, tip): |
|
98 | def show_tip(self, tip): | |
99 | """ Attempts to show the specified tip at the current cursor location. |
|
99 | """ Attempts to show the specified tip at the current cursor location. | |
100 | """ |
|
100 | """ | |
|
101 | # Attempt to find the cursor position at which to show the call tip. | |||
101 | text_edit = self.parent() |
|
102 | text_edit = self.parent() | |
102 | document = text_edit.document() |
|
103 | document = text_edit.document() | |
103 | cursor = text_edit.textCursor() |
|
104 | cursor = text_edit.textCursor() | |
@@ -106,12 +107,22 b' class CallTipWidget(QtGui.QLabel):' | |||||
106 | forward=False) |
|
107 | forward=False) | |
107 | if self._start_position == -1: |
|
108 | if self._start_position == -1: | |
108 | return False |
|
109 | return False | |
109 |
|
110 | |||
110 | point = text_edit.cursorRect(cursor).bottomRight() |
|
111 | # Set the text and resize the widget accordingly. | |
111 | point = text_edit.mapToGlobal(point) |
|
|||
112 | self.move(point) |
|
|||
113 | self.setText(tip) |
|
112 | self.setText(tip) | |
114 | self.resize(self.sizeHint()) |
|
113 | self.resize(self.sizeHint()) | |
|
114 | ||||
|
115 | # Locate and show the widget. Place the tip below the current line | |||
|
116 | # unless it would be off the screen. In that case, place it above | |||
|
117 | # the current line. | |||
|
118 | cursor_rect = text_edit.cursorRect(cursor) | |||
|
119 | screen_rect = QtGui.qApp.desktop().screenGeometry(text_edit) | |||
|
120 | point = text_edit.mapToGlobal(cursor_rect.bottomRight()) | |||
|
121 | tip_height = self.size().height() | |||
|
122 | if point.y() + tip_height > screen_rect.height(): | |||
|
123 | point = text_edit.mapToGlobal(cursor_rect.topRight()) | |||
|
124 | point.setY(point.y() - tip_height) | |||
|
125 | self.move(point) | |||
115 | self.show() |
|
126 | self.show() | |
116 | return True |
|
127 | return True | |
117 |
|
128 |
General Comments 0
You need to be logged in to leave comments.
Login now