Esempio n. 1
0
 def item_activated(self, index):
     try:
         char_code = int(self.model().data(index, Qt.UserRole))
     except (TypeError, ValueError):
         pass
     else:
         self.char_selected.emit(chr(char_code))
Esempio n. 2
0
 def item_activated(self, index):
     try:
         char_code = int(self.model().data(index, Qt.UserRole))
     except (TypeError, ValueError):
         pass
     else:
         self.char_selected.emit(chr(char_code))
Esempio n. 3
0
 def paint_normal(self, painter, option, charcode):
     f = option.font
     f.setPixelSize(option.rect.height() - 8)
     painter.setFont(f)
     painter.drawText(option.rect,
                      Qt.AlignHCenter | Qt.AlignBottom | Qt.TextSingleLine,
                      chr(charcode))
Esempio n. 4
0
 def context_menu(self, pos):
     index = self.indexAt(pos)
     if index.isValid():
         char_code, ok = self.model().data(index, Qt.UserRole).toInt()
         if ok:
             m = QMenu(self)
             m.addAction(QIcon(I('edit-copy.png')),
                         _('Copy %s to clipboard') % chr(char_code),
                         partial(self.copy_to_clipboard, char_code))
             m.addAction(
                 QIcon(I('rating.png')),
                 (_('Remove %s from favorites') if self.showing_favorites
                  else _('Add %s to favorites')) % chr(char_code),
                 partial(self.remove_from_favorites, char_code))
             if self.showing_favorites:
                 m.addAction(_('Restore favorites to defaults'),
                             self.restore_defaults)
             m.exec_(self.mapToGlobal(pos))
Esempio n. 5
0
 def context_menu(self, pos):
     index = self.indexAt(pos)
     if index.isValid():
         char_code, ok = self.model().data(index, Qt.UserRole).toInt()
         if ok:
             m = QMenu(self)
             m.addAction(QIcon(I('edit-copy.png')), _('Copy %s to clipboard') % chr(char_code), partial(self.copy_to_clipboard, char_code))
             m.addAction(QIcon(I('rating.png')),
                         (_('Remove %s from favorites') if self.showing_favorites else _('Add %s to favorites')) % chr(char_code),
                         partial(self.remove_from_favorites, char_code))
             if self.showing_favorites:
                 m.addAction(_('Restore favorites to defaults'), self.restore_defaults)
             m.exec_(self.mapToGlobal(pos))
Esempio n. 6
0
 def context_menu(self, pos):
     index = self.indexAt(pos)
     if index.isValid():
         try:
             char_code = int(self.model().data(index, Qt.UserRole))
         except (TypeError, ValueError):
             pass
         else:
             m = QMenu(self)
             m.addAction(
                 QIcon(I("edit-copy.png")),
                 _("Copy %s to clipboard") % chr(char_code),
                 partial(self.copy_to_clipboard, char_code),
             )
             m.addAction(
                 QIcon(I("rating.png")),
                 (_("Remove %s from favorites") if self.showing_favorites else _("Add %s to favorites"))
                 % chr(char_code),
                 partial(self.remove_from_favorites, char_code),
             )
             if self.showing_favorites:
                 m.addAction(_("Restore favorites to defaults"), self.restore_defaults)
             m.exec_(self.mapToGlobal(pos))
Esempio n. 7
0
 def copy_to_clipboard(self, char_code):
     c = QApplication.clipboard()
     c.setText(chr(char_code))
Esempio n. 8
0
 def copy_to_clipboard(self, char_code):
     c = QApplication.clipboard()
     c.setText(chr(char_code))
Esempio n. 9
0
 def paint_normal(self, painter, option, charcode):
     f = option.font
     f.setPixelSize(option.rect.height() - 8)
     painter.setFont(f)
     painter.drawText(option.rect, Qt.AlignHCenter | Qt.AlignBottom | Qt.TextSingleLine, chr(charcode))
Esempio n. 10
0
 def item_activated(self, index):
     char_code, ok = self.model().data(index, Qt.UserRole).toInt()
     if ok:
         self.char_selected.emit(chr(char_code))
Esempio n. 11
0
 def item_activated(self, index):
     char_code, ok = self.model().data(index, Qt.UserRole).toInt()
     if ok:
         self.char_selected.emit(chr(char_code))