Beispiel #1
0
	def data(self, index, role):
		if not index.isValid():
			return None
		track = self.tracks[index.row()]
		if role == Qt.DisplayRole:
			if index.column() == 1:
				return self.tracks[index.row()].title
			elif index.column() == 2:
				return self.tracks[index.row()].album
			elif index.column() == 3:
				return self.tracks[index.row()].artist
			elif index.column() == 4:
				return self.tracks[index.row()].length
			elif index.column() == 5:
				return self.tracks[index.row()].playcount
			elif index.column() == 6:
				return self.tracks[index.row()].rating
		elif role == Qt.FontRole:
			if 'play' in self.tracks[index.row()].flags:
				font = QtGui.QFont()
				font.setBold(True)
				return font
		elif role == Qt.DecorationRole and index.column() == 0:
			if 'play' in self.tracks[index.row()].flags:
				return QtGui.QIcon.fromTheme('media-playback-start')
			elif 'permjump' in self.tracks[index.row()].flags:
				return icons.pixmapFromText(str(self.tracks[index.row()].priority), (18, 18))
			elif 'tempjump' in self.tracks[index.row()].flags:
				return icons.pixmapFromText(str(self.tracks[index.row()].priority), (18, 18), '#FFCC00', '#000', '#000')
			elif track.bridgeSrc != None:
				if(track.bridgeDest != None):
					return icons.pixmapFromText(u'← ' + track.bridgeDest + ' - ' + track.bridgeSrc + u' →', (64, 18), ('#58FA58', '#CC2EFA'), '#000', '#000')
				else:
					return icons.pixmapFromText(track.bridgeSrc + u' →', (32, 18), '#58FA58', '#000', '#000')
			elif track.bridgeDest != None:
				return icons.pixmapFromText(u'← ' + track.bridgeDest, (32, 18), '#CC2EFA')
			elif 'stop' in self.tracks[index.row()].flags:
				return QtGui.QIcon.fromTheme('media-playback-stop')
		return None
Beispiel #2
0
	def contextMenuEvent(self, event):
		track = self.getTrackAt(self.rowAt(event.y()))
		jumpListSize = str(len(self.manager.playerWidget.jumpList))
		self.popMenu = QtGui.QMenu( self )
		removeAction = self.popMenu.addAction(QtGui.QIcon.fromTheme('list-remove'), _('Remove from queue'))
		stopAction = self.popMenu.addAction(QtGui.QIcon.fromTheme('media-playback-stop'), _('Set stop cursor'))
		permAction = self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(jumpListSize, (18, 18))), _('Add to perm jump list'))
		tempAction = self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(jumpListSize, (18, 18), '#FFCC00', '#000', '#000')), _('Add to temp jump list'))
		self.popMenu.addSeparator()
		self.popMenu.addAction(u'José Long')
		tagsEdit = self.popMenu.addAction(QtGui.QIcon.fromTheme('document-edit'), _('Edit tags'))
		#self.popMenu.setStyleSheet(" QMenu {    icon-size: 128px; } " )
		
		# --- BRIDGES SOURCES ---
		dic = self.manager.playerWidget.bridgesSrc
		if(track.bridgeSrc != None):
			def remove_bridge_src(*args):
				dic.pop(track.bridgeSrc)
				track.bridgeSrc = None
				self.refreshView(track)
				
			self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(track.bridgeSrc, (18, 18), '#FF0000')), _("Unset bridge source"), remove_bridge_src)
		else:
			def add_bridge_src(*args):
				self.manager.playerWidget.addBridgeTrack(self, track, True)
			
			letter = chr(65 + len(dic))
			#bridgeSrcAction = self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(letter + ' →', (24, 18), '#58FA58', '#000', '#000')), _("Add bridge source"), add_bridge_src)
			bridgeSrcAction = self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(letter, (18, 18), '#58FA58', '#000', '#000')), _("Add bridge source"), add_bridge_src)
		
		
		
		# --- BRIDGES DESTINATIONS --- 
		dicDest = self.manager.playerWidget.bridgesDest
		
		if(track.bridgeDest != None):
			def remove_bridge_dest(*args):
				self.manager.playerWidget.bridgesDest.pop(track.bridgeDest)
				track.bridgeDest = None
				self.refreshView(track)
				
			self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(track.bridgeDest, (18, 18), '#FF0000')), _("Unset bridge dest"), remove_bridge_dest)

		else:
			def add_bridge_dest(*args):
				self.manager.playerWidget.addBridgeTrack(self, track, False)
			
			letterDest = chr(65 + len(dicDest))
			#self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText('← ' + letterDest, (24, 18), '#CC2EFA')), _("Add bridge dest"), add_bridge_dest)
			self.popMenu.addAction(QtGui.QIcon(icons.pixmapFromText(letterDest, (18, 18), '#CC2EFA')), _("Add bridge dest"), add_bridge_dest)
			
			
		action = self.popMenu.exec_(self.mapToGlobal(event.pos()))
		if action == removeAction:
			self.model.removeTrack(track)
		elif action == stopAction:
			self.toggleStopFlag(track)
		elif action == permAction:
			self.manager.playerWidget.addToJumpList(self, track, False)
		elif action == tempAction:
			self.manager.playerWidget.addToJumpList(self, track, True)
		elif action == tagsEdit:
			d = TagsEditor(track.ID)
			d.exec_()