Ejemplo n.º 1
0
 def update_warning(self):
     """ """
     widget = self._button_warning
     if not self.is_valid():
         tip = _('Array dimensions not valid')
         widget.setIcon(ima.icon('MessageBoxWarning'))
         widget.setToolTip(tip)
         QToolTip.showText(self._widget.mapToGlobal(QPoint(0, 5)), tip)
     else:
         self._button_warning.setToolTip('')
Ejemplo n.º 2
0
 def update_warning(self):
     """ """
     widget = self._button_warning
     if not self.is_valid():
         tip = _('Array dimensions not valid')
         widget.setIcon(ima.icon('MessageBoxWarning'))
         widget.setToolTip(tip)
         QToolTip.showText(self._widget.mapToGlobal(QPoint(0, 5)), tip)
     else:
         self._button_warning.setToolTip('')
Ejemplo n.º 3
0
 def hide_tooltip_if_necessary(self, key):
     """Hide calltip when necessary"""
     try:
         calltip_char = self.get_character(self.calltip_position)
         before = self.is_cursor_before(self.calltip_position, char_offset=1)
         other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
         if calltip_char not in ("?", "(") or before or other:
             QToolTip.hideText()
     except (IndexError, TypeError):
         QToolTip.hideText()
Ejemplo n.º 4
0
 def hide_tooltip_if_necessary(self, key):
     """Hide calltip when necessary"""
     try:
         calltip_char = self.get_character(self.calltip_position)
         before = self.is_cursor_before(self.calltip_position,
                                        char_offset=1)
         other = key in (Qt.Key_ParenRight, Qt.Key_Period, Qt.Key_Tab)
         if calltip_char not in ('?', '(') or before or other:
             QToolTip.hideText()
     except (IndexError, TypeError):
         QToolTip.hideText()
Ejemplo n.º 5
0
    def keyPressEvent(self, event):
        """Override Qt method"""
        QToolTip.hideText()
        ctrl = event.modifiers() & Qt.ControlModifier

        if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
            if ctrl:
                self.process_text(array=False)
            else:
                self.process_text(array=True)
            self.accept()
        else:
            QDialog.keyPressEvent(self, event)
Ejemplo n.º 6
0
    def keyPressEvent(self, event):
        """Override Qt method"""
        QToolTip.hideText()
        ctrl = event.modifiers() & Qt.ControlModifier

        if event.key() in [Qt.Key_Enter, Qt.Key_Return]:
            if ctrl:
                self.process_text(array=False)
            else:
                self.process_text(array=True)
            self.accept()
        else:
            QDialog.keyPressEvent(self, event)
Ejemplo n.º 7
0
    def show_calltip(self,
                     title,
                     text,
                     signature=False,
                     color='#2D62FF',
                     at_line=None,
                     at_position=None):
        """Show calltip"""
        if text is None or len(text) == 0:
            return

        # Saving cursor position:
        if at_position is None:
            at_position = self.get_position('cursor')
        self.calltip_position = at_position

        # Preparing text:
        if signature:
            text, wrapped_textlines = self._format_signature(text)
        else:
            if isinstance(text, list):
                text = "\n    ".join(text)
            text = text.replace('\n', '<br>')
            if len(text) > self.calltip_size:
                text = text[:self.calltip_size] + " ..."

        # Formatting text
        font = self.font()
        size = font.pointSize()
        family = font.family()
        format1 = '<div style=\'font-family: "%s"; font-size: %spt; color: %s\'>'\
                  % (family, size, color)
        format2 = '<div style=\'font-family: "%s"; font-size: %spt\'>'\
                  % (family, size-1 if size > 9 else size)
        tiptext = format1 + ('<b>%s</b></div>' % title) + '<hr>' + \
                  format2 + text + "</div>"

        # Showing tooltip at cursor position:
        cx, cy = self.get_coordinates('cursor')
        if at_line is not None:
            cx = 5
            cursor = QTextCursor(self.document().findBlockByNumber(at_line -
                                                                   1))
            cy = self.cursorRect(cursor).top()
        point = self.mapToGlobal(QPoint(cx, cy))
        point.setX(point.x() + self.get_linenumberarea_width())
        point.setY(point.y() + font.pointSize() + 5)
        if signature:
            self.calltip_widget.show_tip(point, tiptext, wrapped_textlines)
        else:
            QToolTip.showText(point, tiptext)
Ejemplo n.º 8
0
    def show_calltip(self, title, text, signature=False, color='#2D62FF',
                     at_line=None, at_position=None):
        """Show calltip"""
        if text is None or len(text) == 0:
            return

        # Saving cursor position:
        if at_position is None:
            at_position = self.get_position('cursor')
        self.calltip_position = at_position

        # Preparing text:
        if signature:
            text, wrapped_textlines = self._format_signature(text)
        else:
            if isinstance(text, list):
                text = "\n    ".join(text)
            text = text.replace('\n', '<br>')
            if len(text) > self.calltip_size:
                text = text[:self.calltip_size] + " ..."

        # Formatting text
        font = self.font()
        size = font.pointSize()
        family = font.family()
        format1 = '<div style=\'font-family: "%s"; font-size: %spt; color: %s\'>'\
                  % (family, size, color)
        format2 = '<div style=\'font-family: "%s"; font-size: %spt\'>'\
                  % (family, size-1 if size > 9 else size)
        tiptext = format1 + ('<b>%s</b></div>' % title) + '<hr>' + \
                  format2 + text + "</div>"

        # Showing tooltip at cursor position:
        cx, cy = self.get_coordinates('cursor')
        if at_line is not None:
            cx = 5
            cursor = QTextCursor(self.document().findBlockByNumber(at_line-1))
            cy = self.cursorRect(cursor).top()
        point = self.mapToGlobal(QPoint(cx, cy))
        point.setX(point.x()+self.get_linenumberarea_width())
        point.setY(point.y()+font.pointSize()+5)
        if signature:
            self.calltip_widget.show_tip(point, tiptext, wrapped_textlines)
        else:
            QToolTip.showText(point, tiptext)
Ejemplo n.º 9
0
    def update_warning(self, reset=False):
        """ """
        conflicts = self.check_conflicts()
        if reset:
            conflicts = []

        widget = self.helper_button

        if conflicts:
            tip_title = _('The new entered shorcut conflicts with:') + '\n'
            tip_body = ''
            for s in conflicts:
                tip_body += ' - {0}: {1}\n'.format(s.context, s.name)
            tip = '{0}{1}'.format(tip_title, tip_body)
            widget.setIcon(get_std_icon('MessageBoxWarning'))
            widget.setToolTip(tip)
            QToolTip.showText(widget.mapToGlobal(QPoint(0, 5)), tip)
        else:
            widget.setToolTip('')
            QToolTip.hideText()
            widget.setIcon(get_std_icon('DialogApplyButton'))
Ejemplo n.º 10
0
 def mouseReleaseEvent(self, event):
     """ """
     QToolTip.showText(self.mapToGlobal(QPoint(0, 0)), self._tip_text)
Ejemplo n.º 11
0
 def show_tip(self, tip=""):
     """Show tip"""
     QToolTip.showText(self.mapToGlobal(self.pos()), tip, self)
Ejemplo n.º 12
0
 def postprocess_keyevent(self, event):
     """Process keypress event"""
     ShellBaseWidget.postprocess_keyevent(self, event)
     if QToolTip.isVisible():
         _event, _text, key, _ctrl, _shift = restore_keyevent(event)
         self.hide_tooltip_if_necessary(key)
Ejemplo n.º 13
0
 def postprocess_keyevent(self, event):
     """Process keypress event"""
     ShellBaseWidget.postprocess_keyevent(self, event)
     if QToolTip.isVisible():
         _event, _text, key, _ctrl, _shift = restore_keyevent(event)
         self.hide_tooltip_if_necessary(key)
Ejemplo n.º 14
0
 def show_tip(self, tip=""):
     """Show tip"""
     QToolTip.showText(self.mapToGlobal(self.pos()), tip, self)
Ejemplo n.º 15
0
 def mouseReleaseEvent(self, event):
     QToolTip.showText(self.mapToGlobal(QPoint(0, self.height())),
                       self._tip_text)
Ejemplo n.º 16
0
 def mousePressEvent(self, event):
     QToolTip.hideText()
Ejemplo n.º 17
0
 def mouseReleaseEvent(self, event):
     QToolTip.showText(self.mapToGlobal(QPoint(0, self.height())),
                       self._tip_text)
Ejemplo n.º 18
0
 def mousePressEvent(self, event):
     """ """
     QToolTip.hideText()
Ejemplo n.º 19
0
 def mouseReleaseEvent(self, event):
     """ """
     QToolTip.showText(self.mapToGlobal(QPoint(0, 0)), self._tip_text)