예제 #1
0
 def helpEvent(self, event, view, option, index):
     if event is not None and view is not None and event.type() == QEvent.ToolTip:
         try:
             db = index.model().db
         except AttributeError:
             return False
         try:
             book_id = db.id(index.row())
         except (ValueError, IndexError, KeyError):
             return False
         db = db.new_api
         device_connected = self.parent().gui.device_connected
         on_device = device_connected is not None and db.field_for('ondevice', book_id)
         p = prepare_string_for_xml
         title = db.field_for('title', book_id)
         authors = db.field_for('authors', book_id)
         if title and authors:
             title = '<b>%s</b>' % ('<br>'.join(wrap(p(title), 120)))
             authors = '<br>'.join(wrap(p(' & '.join(authors)), 120))
             tt = '%s<br><br>%s' % (title, authors)
             series = db.field_for('series', book_id)
             if series:
                 use_roman_numbers=config['use_roman_numerals_for_series_number']
                 val = _('Book %(sidx)s of <span class="series_name">%(series)s</span>')%dict(
                     sidx=fmt_sidx(db.field_for('series_index', book_id), use_roman=use_roman_numbers),
                     series=p(series))
                 tt += '<br><br>' + val
             if on_device:
                 val = _('This book is on the device in %s') % on_device
                 tt += '<br><br>' + val
             QToolTip.showText(event.globalPos(), tt, view)
             return True
     return False
예제 #2
0
 def helpEvent(self, event, view, option, index):
     if event is not None and view is not None and event.type() == QEvent.ToolTip:
         try:
             db = index.model().db
         except AttributeError:
             return False
         try:
             book_id = db.id(index.row())
         except (ValueError, IndexError, KeyError):
             return False
         db = db.new_api
         device_connected = self.parent().gui.device_connected
         on_device = device_connected is not None and db.field_for('ondevice', book_id)
         p = prepare_string_for_xml
         title = db.field_for('title', book_id)
         authors = db.field_for('authors', book_id)
         if title and authors:
             title = '<b>%s</b>' % ('<br>'.join(wrap(p(title), 120)))
             authors = '<br>'.join(wrap(p(' & '.join(authors)), 120))
             tt = '%s<br><br>%s' % (title, authors)
             series = db.field_for('series', book_id)
             if series:
                 use_roman_numbers=config['use_roman_numerals_for_series_number']
                 val = _('Book %(sidx)s of <span class="series_name">%(series)s</span>')%dict(
                     sidx=fmt_sidx(db.field_for('series_index', book_id), use_roman=use_roman_numbers),
                     series=p(series))
                 tt += '<br><br>' + val
             if on_device:
                 val = _('This book is on the device in %s') % on_device
                 tt += '<br><br>' + val
             QToolTip.showText(event.globalPos(), tt, view)
             return True
     return False
예제 #3
0
    def init_ui(self):
        QToolTip.setFont(QFont('SansSerif', 10))

        self.statusBar().showMessage('Ready')

        self.create_widgets()

        self.setGeometry(300, 300, 250, 150)
        self.setWindowTitle('Chat')
        self.show()
예제 #4
0
파일: toc.py 프로젝트: j-howell/calibre
 def helpEvent(self, ev, view, option, index):
     # Show a tooltip only if the item is truncated
     if not ev or not view:
         return False
     if ev.type() == ev.ToolTip:
         rect = view.visualRect(index)
         size = self.sizeHint(option, index)
         if rect.width() < size.width():
             tooltip = index.data(Qt.DisplayRole)
             QToolTip.showText(ev.globalPos(), tooltip, view)
             return True
     return QStyledItemDelegate.helpEvent(self, ev, view, option, index)
예제 #5
0
 def helpEvent(self, ev, view, option, index):
     # Show a tooltip only if the item is truncated
     if not ev or not view:
         return False
     if ev.type() == ev.ToolTip:
         rect = view.visualRect(index)
         size = self.sizeHint(option, index)
         if rect.width() < size.width():
             tooltip = index.data(Qt.DisplayRole)
             QToolTip.showText(ev.globalPos(), tooltip, view)
             return True
     return QStyledItemDelegate.helpEvent(self, ev, view, option, index)
예제 #6
0
 def event(self, event):
     '''
     @param: event QEvent
     '''
     if event.type() == QEvent.ToolTip:
         # QHelpEvent
         if self._audioIconDisplayed and self._audioIconRect.contains(
                 event.pos()):
             QToolTip.showText(
                 event.globalPos(),
                 self._tab.isMuted() and _('Unmute Tab') or _('Mute Tab'),
                 self)
             event.accept()
             return True
     return super().event(event)
예제 #7
0
파일: text.py 프로젝트: timpalpant/calibre
 def show_tooltip(self, ev):
     c = self.cursorForPosition(ev.pos())
     fmt = self.syntax_format_for_cursor(c)
     if fmt is not None:
         tt = unicode(fmt.toolTip())
         if tt:
             QToolTip.setFont(self.tooltip_font)
             QToolTip.setPalette(self.tooltip_palette)
             QToolTip.showText(ev.globalPos(), textwrap.fill(tt))
             return
     QToolTip.hideText()
     ev.ignore()
예제 #8
0
 def show_tooltip(self, ev):
     c = self.cursorForPosition(ev.pos())
     fmt = self.syntax_format_for_cursor(c)
     if fmt is not None:
         tt = unicode(fmt.toolTip())
         if tt:
             QToolTip.setFont(self.tooltip_font)
             QToolTip.setPalette(self.tooltip_palette)
             QToolTip.showText(ev.globalPos(), textwrap.fill(tt))
             return
     QToolTip.hideText()
     ev.ignore()
예제 #9
0
    def __init__(self, parent=None):
        super(MessageLabel, self).__init__(parent)

        palette = QToolTip.palette()
        color = QColor(Qt.yellow)
        palette.setColor(QPalette.Window, color)

        self.setPalette(palette)
        self.setAutoFillBackground(True)
        self.setFrameStyle(QFrame.Box | QFrame.Plain)

        self.setWordWrap(True)

        self.hide()
예제 #10
0
파일: WebTab.py 프로젝트: jsoffer/eilat
    def __init__(self, parent=None):
        super(MessageLabel, self).__init__(parent)

        palette = QToolTip.palette()
        color = QColor(Qt.yellow)
        palette.setColor(QPalette.Window, color)

        self.setPalette(palette)
        self.setAutoFillBackground(True)
        self.setFrameStyle(QFrame.Box | QFrame.Plain)

        self.setWordWrap(True)

        self.hide()
예제 #11
0
    def make_labels(self, target):
        """ Create labels for the web nodes in 'source'; if not defined,
        find all visible anchor nodes first

        TODO pass a color? for 'title' tags

        NAV11 DOM01

        """

        if target == "links":
            source = self.__find_visible(navigables=True)
            self.attr.clear('find_titles')
        elif target == "titles":
            source = self.__find_visible(navigables=False)
            self.attr.insert('find_titles')

        self.map_tags = dict(zip(ALL_TAGS, source))

        for tag, node in self.map_tags.items():
            label = QLabel(tag, parent=self)
            self.__labels.append(label)

            palette = QToolTip.palette()

            color = QColor(Qt.yellow)

            color = color.lighter(160)
            color.setAlpha(196)
            palette.setColor(QPalette.Window, color)

            label.setPalette(palette)
            label.setAutoFillBackground(True)
            label.setFrameStyle(QFrame.Box | QFrame.Plain)

            point = QPoint(
                node.geometry().left(),
                node.geometry().center().y())
            point -= self.page().mainFrame().scrollPosition()
            label.move(point)
            label.show()
            label.move(label.x(), label.y() + label.height() // 4)
예제 #12
0
    def __init__(self, parent=None):
        super(NotifyLabel, self).__init__(parent)

        print("NOTIFYLABEL", self, parent)

        palette = QToolTip.palette()
        color = QColor(Qt.blue)
        color = color.lighter(170)
        color.setAlpha(128)
        palette.setColor(QPalette.Window, color)

        self.setPalette(palette)
        self.setAutoFillBackground(True)
        self.setFrameStyle(QFrame.Box | QFrame.Plain)

        self.setFont(QFont(None, 20, QFont.Bold))

        self.hide()

        self.content = deque(maxlen=4)
예제 #13
0
파일: MainWin.py 프로젝트: jsoffer/eilat
    def __init__(self, parent=None):
        super(NotifyLabel, self).__init__(parent)

        print("NOTIFYLABEL", self, parent)

        palette = QToolTip.palette()
        color = QColor(Qt.blue)
        color = color.lighter(170)
        color.setAlpha(128)
        palette.setColor(QPalette.Window, color)

        self.setPalette(palette)
        self.setAutoFillBackground(True)
        self.setFrameStyle(QFrame.Box | QFrame.Plain)

        self.setFont(QFont(None, 20, QFont.Bold))

        self.hide()

        self.content = deque(maxlen=4)
예제 #14
0
 def collapse_menu_hovered(self, action):
     tip = action.toolTip()
     if tip == '*':
         tip = ''
     QToolTip.showText(QCursor.pos(), tip)
예제 #15
0
파일: jobs.py 프로젝트: ziyuyouming/calibre
 def show_tooltip(self, arg):
     widget, pos = arg
     QToolTip.showText(pos, self.get_tooltip())
예제 #16
0
 def collapse_menu_hovered(self, action):
     tip = action.toolTip()
     if tip == '*':
         tip = ''
     QToolTip.showText(QCursor.pos(), tip)
예제 #17
0
파일: jobs.py 프로젝트: kba/calibre
 def show_tooltip(self, arg):
     widget, pos = arg
     QToolTip.showText(pos, self.get_tooltip())