コード例 #1
0
 def paint(self, painter, option, index):
     painter.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform 
                         | QtGui.QPainter.TextAntialiasing)
     
     model = index.model()
     instance = index.data(model.instanceRole)
     
     
     imageWidth = 80
     imageRect = QtCore.QRect(option.rect.x(), option.rect.y() + (option.rect.height() - imageWidth) / 2, imageWidth, imageWidth)
     image = avatarManager.get_avatar(instance.friendJid)
     drawCornerImage(painter, image, imageRect)
     dummyRect = option.rect.adjusted(imageWidth, 0, -imageWidth, 0)
     
     
     path, rect = drawRectWidthCorner(painter, dummyRect, marginWidth=5)
     painter.fillPath(path, QtGui.QColor(82, 60, 145))
     
     # draw body
     doc = self.textDocument
     doc.setHtml(instance.body)
     doc.setTextWidth(rect.width())
     ctx = QtGui.QAbstractTextDocumentLayout.PaintContext()
     painter.save()
     painter.translate(rect.topLeft());
     painter.setClipRect(option.rect.translated(-rect.topLeft()))
     dl = doc.documentLayout()
     dl.draw(painter, ctx)
     painter.restore()        
コード例 #2
0
ファイル: chat.py プロジェクト: binyuj/deepin-talk
 def __init__(self, model, jid, parent=None):
     super(ChatWindow, self).__init__(parent)
     self.setMinimumSize(QtCore.QSize(600, 620))        
     self.model = model
     self.jid = jid
     self.setContextProperty("messageModel", self.model)
     self.setSource(QtCore.QUrl.fromLocalFile(get_qml('ChatFrame','ChatWindow.qml')))
     self.setIcon(QtGui.QIcon(avatarManager.get_avatar(jid, raw=True)))
     self.setTitle("和{0}聊天中".format(model.jidInfo.displayName))
コード例 #3
0
ファイル: _models.py プロジェクト: binyuj/deepin-talk
 def attach_attrs(cls, instance):
     resources = sorted(instance.resources, key=lambda item: item.priority, reverse=True)
     if len(resources) >= 1:
         resource = resources[0]
     else:    
         resource = Resource.get_dummy_data()
     avatar = avatarManager.get_avatar(instance.jid)    
     setattr(instance, "avatar", avatar)
     setattr(instance, "resource", resource)                    
コード例 #4
0
 def __init__(self, model, jid, parent=None):
     super(ChatWindow, self).__init__(parent)
     self.setMinimumSize(QtCore.QSize(600, 620))
     self.model = model
     self.jid = jid
     self.setContextProperty("messageModel", self.model)
     self.setSource(
         QtCore.QUrl.fromLocalFile(get_qml('ChatFrame', 'ChatWindow.qml')))
     self.setIcon(QtGui.QIcon(avatarManager.get_avatar(jid, raw=True)))
     self.setTitle("和{0}聊天中".format(model.jidInfo.displayName))
コード例 #5
0
ファイル: _models.py プロジェクト: disda/deepin-talk
 def attach_attrs(cls, instance):
     resources = sorted(instance.resources,
                        key=lambda item: item.priority,
                        reverse=True)
     if len(resources) >= 1:
         resource = resources[0]
     else:
         resource = Resource.get_dummy_data()
     avatar = avatarManager.get_avatar(instance.jid)
     setattr(instance, "avatar", avatar)
     setattr(instance, "resource", resource)
コード例 #6
0
ファイル: _models.py プロジェクト: disda/deepin-talk
    def data(self, index, role):
        if not index.isValid() or index.row() > self.size():
            return QtCore.QVariant()
        try:
            item = self._data[index.row()]
        except:
            return QtCore.QVariant()

        roleName = self._roles[role]
        if hasattr(item, roleName):
            return getattr(item, roleName)
        elif roleName == "groupName":
            return item.group.name
        elif roleName == "avatar":
            return avatarManager.get_avatar(item.jid)
        elif roleName == "displayName":
            return getDisplayName(item)
        return QtCore.QVariant()
コード例 #7
0
ファイル: _models.py プロジェクト: binyuj/deepin-talk
 def data(self, index, role):
     if not index.isValid() or index.row() > self.size():
         return QtCore.QVariant()
     try:
         item = self._data[index.row()]
     except:    
         return QtCore.QVariant()
     
     roleName = self._roles[role]
     if hasattr(item, roleName):
         return getattr(item, roleName)
     elif roleName == "groupName":
         return item.group.name
     elif roleName == "avatar":
         return avatarManager.get_avatar(item.jid)
     elif roleName == "displayName":
         return getDisplayName(item)
     return QtCore.QVariant()