Ejemplo n.º 1
0
 def isFileSame(self, file_):
     if(not self.file):
         return False
     sameName = utils.sameFilename(self.file['name'], file_['name'])
     sameSize = utils.sameFilesize(self.file['size'], file_['size'])
     sameDuration = utils.sameFileduration(self.file['duration'], file_['duration'])
     return sameName and sameSize and sameDuration
Ejemplo n.º 2
0
 def __showUserChangeMessage(self, username, room, file_, oldRoom=None):
     if(room):
         if self.isRoomSame(room) or self.isRoomSame(oldRoom):
             showOnOSD = constants.SHOW_SAME_ROOM_OSD
         else:
             showOnOSD = constants.SHOW_DIFFERENT_ROOM_OSD
         hideFromOSD = not showOnOSD
     if(room and not file_):
         message = getMessage("en", "room-join-notification").format(username, room)
         self.ui.showMessage(message, hideFromOSD)
     elif (room and file_):
         duration = utils.formatTime(file_['duration'])
         message = getMessage("en", "playing-notification").format(username, file_['name'], duration)
         if(self.currentUser.room <> room or self.currentUser.username == username):
             message += getMessage("en", "playing-notification/room-addendum").format(room)
         self.ui.showMessage(message, hideFromOSD)
         if(self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room):
             message = getMessage("en", "file-different-notification").format(username)
             self.ui.showMessage(message, not constants.SHOW_OSD_WARNINGS)
             differences = []
             differentName = not utils.sameFilename(self.currentUser.file['name'], file_['name'])
             differentSize = not utils.sameFilesize(self.currentUser.file['size'], file_['size'])
             differentDuration = not utils.sameFileduration(self.currentUser.file['duration'], file_['duration'])
             if(differentName):
                 differences.append("filename")
             if(differentSize):
                 differences.append("size")
             if(differentDuration):
                 differences.append("duration")
             message = getMessage("en", "file-differences-notification") + ", ".join(differences)
             self.ui.showMessage(message, not constants.SHOW_OSD_WARNINGS)
Ejemplo n.º 3
0
 def __showUserChangeMessage(self, username, room, file_):
     if(room and not file_):
         message = getMessage("en", "room-join-notification").format(username, room)
         self.ui.showMessage(message)
     elif (room and file_):
         duration = utils.formatTime(file_['duration'])
         message = getMessage("en", "playing-notification").format(username, file_['name'], duration)
         if(self.currentUser.room <> room or self.currentUser.username == username):
             message += getMessage("en", "playing-notification/room-addendum").format(room)
         self.ui.showMessage(message)
         if(self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room):
             message = getMessage("en", "file-different-notification").format(username)
             self.ui.showMessage(message)
             differences = []
             differentName = not utils.sameFilename(self.currentUser.file['name'], file_['name'])
             differentSize = not utils.sameFilesize(self.currentUser.file['size'], file_['size'])
             differentDuration = not utils.sameFileduration(self.currentUser.file['duration'], file_['duration'])
             if(differentName):
                 differences.append("filename")
             if(differentSize):
                 differences.append("size")
             if(differentDuration):
                 differences.append("duration")
             message = getMessage("en", "file-differences-notification") + ", ".join(differences)
             self.ui.showMessage(message)
Ejemplo n.º 4
0
 def __showUserChangeMessage(self, username, room, file_):
     if(room and not file_):
         message = getMessage("en", "room-join-notification").format(username, room)
         self.ui.showMessage(message)
     elif (room and file_):
         duration = utils.formatTime(file_['duration'])
         message = getMessage("en", "playing-notification").format(username, file_['name'], duration)
         if(self.currentUser.room <> room or self.currentUser.username == username):
             message += getMessage("en", "playing-notification/room-addendum").format(room)
         self.ui.showMessage(message)
         if(self.currentUser.file and not self.currentUser.isFileSame(file_) and self.currentUser.room == room):
             message = getMessage("en", "file-different-notification").format(username)
             self.ui.showMessage(message)
             differences = []
             differentName = not utils.sameFilename(self.currentUser.file['name'], file_['name'])
             differentSize = not utils.sameFilesize(self.currentUser.file['size'], file_['size'])
             differentDuration = not utils.sameFileduration(self.currentUser.file['duration'], file_['duration'])
             if(differentName):
                 differences.append("filename") 
             if(differentSize):
                 differences.append("size")
             if(differentDuration):
                 differences.append("duration")
             message = getMessage("en", "file-differences-notification") + ", ".join(differences)
             self.ui.showMessage(message)
Ejemplo n.º 5
0
 def isFileSame(self, file_):       
     if(not self.file):
         return False
     sameName = utils.sameFilename(self.file['name'], file_['name'])
     sameSize = utils.sameFilesize(self.file['size'], file_['size'])
     sameDuration = utils.sameFileduration(self.file['duration'], file_['duration'])
     return sameName and sameSize and sameDuration
Ejemplo n.º 6
0
 def showUserList(self, currentUser, rooms):
     self._usertreebuffer = QtGui.QStandardItemModel()
     self._usertreebuffer.setColumnCount(2)
     self._usertreebuffer.setHorizontalHeaderLabels(("Room / User","File being played"))
     usertreeRoot = self._usertreebuffer.invisibleRootItem()
     
     for room in rooms:
         roomitem = QtGui.QStandardItem(room)
         if (room == currentUser.room):
             font = QtGui.QFont()
             font.setWeight(QtGui.QFont.Bold)
             roomitem.setFont(font)
         blankitem = QtGui.QStandardItem("")
         roomitem.setFlags(roomitem.flags()  & ~Qt.ItemIsEditable) 
         blankitem.setFlags(blankitem.flags() & ~Qt.ItemIsEditable)
         usertreeRoot.appendRow((roomitem, blankitem))
         for user in rooms[room]:
             useritem = QtGui.QStandardItem(user.username)
             fileitem = QtGui.QStandardItem("")
             if (user.file):
                 fileitem = QtGui.QStandardItem(user.file['name'] + " ("+formatTime(user.file['duration'])+")")
                 if (currentUser.file):                     
                     sameName = sameFilename(user.file['name'], currentUser.file['name'])
                     sameSize = sameFilesize(user.file['size'], currentUser.file['size'])
                     sameDuration = sameFileduration(user.file['duration'], currentUser.file['duration'])
                     sameRoom = room == currentUser.room
                     differentName = not sameName
                     differentSize = not sameSize
                     differentDuration = not sameDuration
                     if (sameName or sameRoom):
                         if (differentSize and sameDuration):
                             fileitem = QtGui.QStandardItem(user.file['name'] + " ("+formatTime(user.file['duration'])+")" + " (Different size!)")
                         elif (differentSize and differentDuration):
                             fileitem = QtGui.QStandardItem(user.file['name'] + " ("+formatTime(user.file['duration'])+")" + " (Different size and duration!)")
                         elif (differentDuration):
                             fileitem = QtGui.QStandardItem(user.file['name'] + " ("+formatTime(user.file['duration'])+")" + " (Different duration!)")
                         if (sameRoom and (differentName or differentSize or differentDuration)):
                             fileitem.setForeground(QtGui.QBrush(QtGui.QColor('red')))
             else:
                 fileitem = QtGui.QStandardItem("(No file being played)")
                 if (room == currentUser.room):
                     fileitem.setForeground(QtGui.QBrush(QtGui.QColor('blue')))
             if(currentUser.username == user.username):
                 font = QtGui.QFont()
                 font.setWeight(QtGui.QFont.Bold)
                 useritem.setFont(font)
             useritem.setFlags(useritem.flags()  & ~Qt.ItemIsEditable)
             fileitem.setFlags(fileitem.flags()  & ~Qt.ItemIsEditable)
             roomitem.appendRow((useritem, fileitem))
    
     self.listTreeModel = self._usertreebuffer
     self.listTreeView.setModel(self.listTreeModel)
     self.listTreeView.setItemsExpandable(False)
     self.listTreeView.expandAll()
     self.listTreeView.resizeColumnToContents(0)
     self.listTreeView.resizeColumnToContents(1)
Ejemplo n.º 7
0
Archivo: gui.py Proyecto: ion1/syncplay
 def showUserList(self, currentUser, rooms):
     self._usertreebuffer = QtGui.QStandardItemModel()
     self._usertreebuffer.setColumnCount(2)
     self._usertreebuffer.setHorizontalHeaderLabels((getMessage("roomuser-heading-label"),getMessage("fileplayed-heading-label")))
     usertreeRoot = self._usertreebuffer.invisibleRootItem()
     
     for room in rooms:
         roomitem = QtGui.QStandardItem(room)
         if room == currentUser.room:
             font = QtGui.QFont()
             font.setWeight(QtGui.QFont.Bold)
             roomitem.setFont(font)
         blankitem = QtGui.QStandardItem("")
         roomitem.setFlags(roomitem.flags()  & ~Qt.ItemIsEditable) 
         blankitem.setFlags(blankitem.flags() & ~Qt.ItemIsEditable)
         usertreeRoot.appendRow((roomitem, blankitem))
         for user in rooms[room]:
             useritem = QtGui.QStandardItem(user.username)
             fileitem = QtGui.QStandardItem("")
             if user.file:
                 fileitem = QtGui.QStandardItem(u"{} ({})".format(user.file['name'], formatTime(user.file['duration'])))
                 if currentUser.file:
                     sameName = sameFilename(user.file['name'], currentUser.file['name'])
                     sameSize = sameFilesize(user.file['size'], currentUser.file['size'])
                     sameDuration = sameFileduration(user.file['duration'], currentUser.file['duration'])
                     sameRoom = room == currentUser.room
                     differentName = not sameName
                     differentSize = not sameSize
                     differentDuration = not sameDuration
                     if sameName or sameRoom:
                         if differentSize and sameDuration:
                             fileitem = QtGui.QStandardItem(u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']), getMessage("differentsize-note")))
                         elif differentSize and differentDuration:
                             fileitem = QtGui.QStandardItem(u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']), getMessage("differentsizeandduration-note")))
                         elif differentDuration:
                             fileitem = QtGui.QStandardItem(u"{} ({}) ({})".format(user.file['name'], formatTime(user.file['duration']), getMessage("differentduration-note")))
                         if sameRoom and (differentName or differentSize or differentDuration):
                             fileitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
             else:
                 fileitem = QtGui.QStandardItem(getMessage("nofile-note"))
                 if room == currentUser.room:
                     fileitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_NOFILEITEM_COLOR)))
             if currentUser.username == user.username:
                 font = QtGui.QFont()
                 font.setWeight(QtGui.QFont.Bold)
                 useritem.setFont(font)
             useritem.setFlags(useritem.flags()  & ~Qt.ItemIsEditable)
             fileitem.setFlags(fileitem.flags()  & ~Qt.ItemIsEditable)
             roomitem.appendRow((useritem, fileitem))
    
     self.listTreeModel = self._usertreebuffer
     self.listTreeView.setModel(self.listTreeModel)
     self.listTreeView.setItemsExpandable(False)
     self.listTreeView.expandAll()
     self.listTreeView.resizeColumnToContents(0)
     self.listTreeView.resizeColumnToContents(1)
Ejemplo n.º 8
0
    def showUserList(self, currentUser, rooms):
        self._usertreebuffer = QtGui.QStandardItemModel()
        self._usertreebuffer.setHorizontalHeaderLabels(
            (getMessage("roomuser-heading-label"), getMessage("size-heading-label"), getMessage("duration-heading-label"), getMessage("filename-heading-label") ))
        usertreeRoot = self._usertreebuffer.invisibleRootItem()

        for room in rooms:
            roomitem = QtGui.QStandardItem(room)
            font = QtGui.QFont()
            font.setItalic(True)
            if room == currentUser.room:
                font.setWeight(QtGui.QFont.Bold)
            roomitem.setFont(font)
            roomitem.setFlags(roomitem.flags() & ~Qt.ItemIsEditable)
            usertreeRoot.appendRow(roomitem)
            isControlledRoom = RoomPasswordProvider.isControlledRoom(room)

            if isControlledRoom:
                if room == currentUser.room and currentUser.isController():
                    roomitem.setIcon(QtGui.QIcon(self.resourcespath + 'lock_open.png'))
                else:
                    roomitem.setIcon(QtGui.QIcon(self.resourcespath + 'lock.png'))
            else:
                roomitem.setIcon(QtGui.QIcon(self.resourcespath + 'chevrons_right.png'))

            for user in rooms[room]:
                useritem = QtGui.QStandardItem(user.username)
                isController = user.isController()
                sameRoom = room == currentUser.room
                if sameRoom:
                    isReadyWithFile = user.isReadyWithFile()
                else:
                    isReadyWithFile = None
                useritem.setData(isController, Qt.UserRole + constants.USERITEM_CONTROLLER_ROLE)
                useritem.setData(isReadyWithFile, Qt.UserRole + constants.USERITEM_READY_ROLE)
                if user.file:
                    filesizeitem = QtGui.QStandardItem(formatSize(user.file['size']))
                    filedurationitem = QtGui.QStandardItem("({})".format(formatTime(user.file['duration'])))
                    filenameitem = QtGui.QStandardItem((user.file['name']))
                    if currentUser.file:
                        sameName = sameFilename(user.file['name'], currentUser.file['name'])
                        sameSize = sameFilesize(user.file['size'], currentUser.file['size'])
                        sameDuration = sameFileduration(user.file['duration'], currentUser.file['duration'])
                        underlinefont = QtGui.QFont()
                        underlinefont.setUnderline(True)
                        if sameRoom:
                            if not sameName:
                                filenameitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
                                filenameitem.setFont(underlinefont)
                            if not sameSize:
                                if currentUser.file is not None and formatSize(user.file['size']) == formatSize(currentUser.file['size']):
                                    filesizeitem = QtGui.QStandardItem(formatSize(user.file['size'],precise=True))
                                filesizeitem.setFont(underlinefont)
                                filesizeitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
                            if not sameDuration:
                                filedurationitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_DIFFERENTITEM_COLOR)))
                                filedurationitem.setFont(underlinefont)
                else:
                    filenameitem = QtGui.QStandardItem(getMessage("nofile-note"))
                    filedurationitem = QtGui.QStandardItem("")
                    filesizeitem = QtGui.QStandardItem("")
                    if room == currentUser.room:
                        filenameitem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_NOFILEITEM_COLOR)))
                font = QtGui.QFont()
                if currentUser.username == user.username:
                    font.setWeight(QtGui.QFont.Bold)
                    self.updateReadyState(currentUser.isReadyWithFile())
                if isControlledRoom and not isController:
                    useritem.setForeground(QtGui.QBrush(QtGui.QColor(constants.STYLE_NOTCONTROLLER_COLOR)))
                useritem.setFont(font)
                useritem.setFlags(useritem.flags() & ~Qt.ItemIsEditable & ~Qt.ItemIsSelectable)
                filenameitem.setFlags(filenameitem.flags() & ~Qt.ItemIsEditable & ~Qt.ItemIsSelectable)
                filesizeitem.setFlags(filesizeitem.flags() & ~Qt.ItemIsEditable & ~Qt.ItemIsSelectable)
                filedurationitem.setFlags(filedurationitem.flags() & ~Qt.ItemIsEditable & ~Qt.ItemIsSelectable)
                roomitem.appendRow((useritem, filesizeitem, filedurationitem, filenameitem))
        self.listTreeModel = self._usertreebuffer
        self.listTreeView.setModel(self.listTreeModel)
        self.listTreeView.setItemDelegate(UserlistItemDelegate())
        self.listTreeView.setItemsExpandable(False)
        self.listTreeView.setRootIsDecorated(False)
        self.listTreeView.expandAll()
        self.updateListGeometry()
Ejemplo n.º 9
0
    def showUserList(self, currentUser, rooms):
        self._usertreebuffer = QtGui.QStandardItemModel()
        self._usertreebuffer.setColumnCount(2)
        self._usertreebuffer.setHorizontalHeaderLabels(
            ("Room / User", "File being played"))
        usertreeRoot = self._usertreebuffer.invisibleRootItem()

        for room in rooms:
            roomitem = QtGui.QStandardItem(room)
            if (room == currentUser.room):
                font = QtGui.QFont()
                font.setWeight(QtGui.QFont.Bold)
                roomitem.setFont(font)
            blankitem = QtGui.QStandardItem("")
            roomitem.setFlags(roomitem.flags() & ~Qt.ItemIsEditable)
            blankitem.setFlags(blankitem.flags() & ~Qt.ItemIsEditable)
            usertreeRoot.appendRow((roomitem, blankitem))
            for user in rooms[room]:
                useritem = QtGui.QStandardItem(user.username)
                fileitem = QtGui.QStandardItem("")
                if (user.file):
                    fileitem = QtGui.QStandardItem(
                        user.file['name'] + " (" +
                        formatTime(user.file['duration']) + ")")
                    if (currentUser.file):
                        sameName = sameFilename(user.file['name'],
                                                currentUser.file['name'])
                        sameSize = sameFilesize(user.file['size'],
                                                currentUser.file['size'])
                        sameDuration = sameFileduration(
                            user.file['duration'],
                            currentUser.file['duration'])
                        sameRoom = room == currentUser.room
                        differentName = not sameName
                        differentSize = not sameSize
                        differentDuration = not sameDuration
                        if (sameName or sameRoom):
                            if (differentSize and sameDuration):
                                fileitem = QtGui.QStandardItem(
                                    user.file['name'] + " (" +
                                    formatTime(user.file['duration']) + ")" +
                                    " (Different size!)")
                            elif (differentSize and differentDuration):
                                fileitem = QtGui.QStandardItem(
                                    user.file['name'] + " (" +
                                    formatTime(user.file['duration']) + ")" +
                                    " (Different size and duration!)")
                            elif (differentDuration):
                                fileitem = QtGui.QStandardItem(
                                    user.file['name'] + " (" +
                                    formatTime(user.file['duration']) + ")" +
                                    " (Different duration!)")
                            if (sameRoom and (differentName or differentSize
                                              or differentDuration)):
                                fileitem.setForeground(
                                    QtGui.QBrush(QtGui.QColor('red')))
                else:
                    fileitem = QtGui.QStandardItem("(No file being played)")
                    if (room == currentUser.room):
                        fileitem.setForeground(
                            QtGui.QBrush(QtGui.QColor('blue')))
                if (currentUser.username == user.username):
                    font = QtGui.QFont()
                    font.setWeight(QtGui.QFont.Bold)
                    useritem.setFont(font)
                useritem.setFlags(useritem.flags() & ~Qt.ItemIsEditable)
                fileitem.setFlags(fileitem.flags() & ~Qt.ItemIsEditable)
                roomitem.appendRow((useritem, fileitem))

        self.listTreeModel = self._usertreebuffer
        self.listTreeView.setModel(self.listTreeModel)
        self.listTreeView.setItemsExpandable(False)
        self.listTreeView.expandAll()
        self.listTreeView.resizeColumnToContents(0)
        self.listTreeView.resizeColumnToContents(1)