Esempio n. 1
0
        def __init__(self, parent, services, media):

            QW.QWidget.__init__(self, parent)

            self._services = services

            self._media = media

            self._service_keys_to_controls = {}
            self._service_keys_to_original_ratings_states = {}

            rows = []

            for service in self._services:

                name = service.GetName()

                service_key = service.GetServiceKey()

                rating_state = ClientRatings.GetLikeStateFromMedia(
                    self._media, service_key)

                control = ClientGUIRatings.RatingLikeDialog(self, service_key)

                control.SetRatingState(rating_state)

                self._service_keys_to_controls[service_key] = control
                self._service_keys_to_original_ratings_states[
                    service_key] = rating_state

                rows.append((name + ': ', control))

            gridbox = ClientGUICommon.WrapInGrid(self, rows, expand_text=True)

            self.setLayout(gridbox)
Esempio n. 2
0
def DrawLike( painter, x, y, service_key, rating_state ):
    
    shape = ClientRatings.GetShape( service_key )
    
    ( pen_colour, brush_colour ) = GetPenAndBrushColours( service_key, rating_state )
    
    painter.setPen( QG.QPen( pen_colour ) )
    painter.setBrush( QG.QBrush( brush_colour ) )

    if shape == ClientRatings.CIRCLE:
        
        painter.drawEllipse( QC.QPointF( x+7, y+7 ), 6, 6 )
        
    elif shape == ClientRatings.SQUARE:
        
        painter.drawRect( x+2, y+2, 12, 12 )
        
    elif shape == ClientRatings.STAR:

        offset = QC.QPoint( x + 1, y + 1 )
        
        painter.translate( offset )
        
        painter.drawPolygon( QG.QPolygonF( STAR_COORDS ) )
        
        painter.translate( -offset )