def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ):
     
     QW.QWidget.__init__( self, parent )
     
     self._service_key = service_key
     
     service = HG.client_controller.services_manager.GetService( self._service_key )
     
     name = service.GetName()
     
     name_st = ClientGUICommon.BetterStaticText( self, name )
     
     name_st.setAlignment( QC.Qt.AlignLeft | QC.Qt.AlignVCenter )
     
     self._rated_checkbox = QW.QCheckBox( 'rated', self )
     self._not_rated_checkbox = QW.QCheckBox( 'not rated', self )
     self._rating_control = ClientGUIRatings.RatingLikeDialog( self, service_key )
     
     #
     
     if predicate is not None:
         
         value = predicate.GetValue()
         
         if value is not None:
             
             ( operator, rating, service_key ) = value
             
             if rating == 'rated':
                 
                 self._rated_checkbox.setChecked( True )
                 
             elif rating == 'not rated':
                 
                 self._not_rated_checkbox.setChecked( True )
                 
             else:
                 
                 if rating == 0:
                     
                     self._rating_control.SetRatingState( ClientRatings.DISLIKE )
                     
                 else:
                     
                     self._rating_control.SetRatingState( ClientRatings.LIKE )
                     
                 
             
         
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, name_st, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, self._rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._not_rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._rating_control, CC.FLAGS_CENTER_PERPENDICULAR )
     
     self.setLayout( hbox )
Ejemplo n.º 2
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)
 def __init__( self, parent: QW.QWidget, service_key: bytes, predicate: typing.Optional[ ClientSearch.Predicate ] ):
     
     QW.QWidget.__init__( self, parent )
     
     self._service_key = service_key
     
     service = HG.client_controller.services_manager.GetService( self._service_key )
     
     name = service.GetName()
     
     name_st = ClientGUICommon.BetterStaticText( self, name )
     
     name_st.setAlignment( QC.Qt.AlignLeft | QC.Qt.AlignVCenter )
     
     self._rated_checkbox = QW.QCheckBox( 'rated', self )
     self._not_rated_checkbox = QW.QCheckBox( 'not rated', self )
     self._operator = QP.RadioBox( self, choices = [ '>', '<', '=', CC.UNICODE_ALMOST_EQUAL_TO ] )
     self._rating_control = ClientGUIRatings.RatingNumericalDialog( self, service_key )
     
     self._operator.Select( 2 )
     
     #
     
     if predicate is not None:
         
         value = predicate.GetValue()
         
         if value is not None:
             
             ( operator, rating, service_key ) = value
             
             if rating == 'rated':
                 
                 self._rated_checkbox.setChecked( True )
                 
             elif rating == 'not rated':
                 
                 self._not_rated_checkbox.setChecked( True )
                 
             else:
                 
                 self._operator.SetStringSelection( operator )
                 
                 self._rating_control.SetRating( rating )
                 
             
         
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, name_st, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, self._rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._not_rated_checkbox, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._operator, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._rating_control, CC.FLAGS_CENTER_PERPENDICULAR )
     
     self.setLayout( hbox )