示例#1
0
 def ProcessApplicationCommand( self, command: CAC.ApplicationCommand ):
     
     command_processed = True
     
     data = command.GetData()
     
     if command.IsSimpleCommand():
         
         action = data
         
         if action in self._ok_on_these_commands:
             
             self._OKParent()
             
         else:
             
             command_processed = False
             
         
     else:
         
         command_processed = False
         
     
     return command_processed
示例#2
0
 def ProcessApplicationCommand( self, command: CAC.ApplicationCommand ):
     
     command_processed = True
     
     if command.IsSimpleCommand():
         
         action = command.GetSimpleAction()
         
         if action == CAC.SIMPLE_PAUSE_MEDIA:
             
             self.Pause()
             
         elif action == CAC.SIMPLE_PAUSE_PLAY_MEDIA:
             
             self.PausePlay()
             
         elif action == CAC.SIMPLE_MEDIA_SEEK_DELTA:
             
             ( direction, duration_ms ) = command.GetSimpleData()
             
             self.SeekDelta( direction, duration_ms )
             
         elif action == CAC.SIMPLE_OPEN_FILE_IN_EXTERNAL_PROGRAM:
             
             if self._media is not None:
                 
                 ClientGUIMedia.OpenExternally( self._media )
                 
             
         elif action == CAC.SIMPLE_CLOSE_MEDIA_VIEWER and self._canvas_type in CC.CANVAS_MEDIA_VIEWER_TYPES:
             
             self.window().close()
             
         elif action == CAC.SIMPLE_LAUNCH_MEDIA_VIEWER and self._canvas_type == CC.CANVAS_PREVIEW:
             
             self.launchMediaViewer.emit()
             
         else:
             
             command_processed = False
             
         
     else:
         
         command_processed = False
         
     
     return command_processed
示例#3
0
 def ProcessApplicationCommand( self, command: CAC.ApplicationCommand ):
     
     command_processed = True
     
     data = command.GetData()
     
     if command.IsSimpleCommand():
         
         action = data
         
         if action == CAC.SIMPLE_PAUSE_MEDIA:
             
             self.Pause()
             
         elif action == CAC.SIMPLE_PAUSE_PLAY_MEDIA:
             
             self.PausePlay()
             
         elif action == CAC.SIMPLE_OPEN_FILE_IN_EXTERNAL_PROGRAM:
             
             if self._media is not None:
                 
                 ClientGUIMedia.OpenExternally( self._media )
                 
             
         elif action == CAC.SIMPLE_CLOSE_MEDIA_VIEWER and self._canvas_type == ClientGUICommon.CANVAS_MEDIA_VIEWER:
             
             self.window().close()
             
         elif action == CAC.SIMPLE_LAUNCH_MEDIA_VIEWER and self._canvas_type == ClientGUICommon.CANVAS_PREVIEW:
             
             self.launchMediaViewer.emit()
             
         else:
             
             command_processed = False
             
         
     else:
         
         command_processed = False
         
     
     return command_processed
示例#4
0
    def ProcessApplicationCommand(self, command: CAC.ApplicationCommand):

        command_processed = True

        data = command.GetData()

        if command.IsSimpleCommand():

            action = data

            if action == CAC.SIMPLE_MANAGE_FILE_RATINGS:

                self.EventOK()

            else:

                command_processed = False

        else:

            command_processed = False

        return command_processed
    def __init__(self, parent: QW.QWidget, command: CAC.ApplicationCommand,
                 shortcuts_name: str):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        #

        is_custom_or_media = shortcuts_name not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES or shortcuts_name == 'media'

        self._panel_choice = ClientGUICommon.BetterChoice(self)

        self._panel_choice.addItem('simple command', self.PANEL_SIMPLE)

        if is_custom_or_media:

            self._panel_choice.addItem('tag command', self.PANEL_TAG)
            self._panel_choice.addItem('like/dislike rating command',
                                       self.PANEL_RATING_LIKE)
            self._panel_choice.addItem('numerical rating command',
                                       self.PANEL_RATING_NUMERICAL)
            self._panel_choice.addItem(
                'numerical rating increment/decrement command',
                self.PANEL_RATING_NUMERICAL_INCDEC)

        else:

            self._panel_choice.hide()

        self._simple_sub_panel = SimpleSubPanel(self, shortcuts_name)

        self._tag_sub_panel = TagSubPanel(self)

        self._rating_like_sub_panel = RatingLikeSubPanel(self)

        self._rating_numerical_sub_panel = RatingNumericalSubPanel(self)

        self._rating_numerical_inc_dec_sub_panel = RatingNumericalIncDecSubPanel(
            self)

        #

        data = command.GetData()

        if command.IsSimpleCommand():

            action = data

            self._simple_sub_panel.SetValue(action)

            self._panel_choice.SetValue(self.PANEL_SIMPLE)

        elif command.IsContentCommand():

            service_key = command.GetContentServiceKey()

            if HG.client_controller.services_manager.ServiceExists(
                    service_key):

                service = HG.client_controller.services_manager.GetService(
                    service_key)

                action = command.GetContentAction()
                value = command.GetContentValue()

            else:

                QW.QMessageBox.warning(
                    self, 'Warning',
                    'The service that this command relies upon no longer exists! This command will reset to a default form.'
                )

                local_tag_services = list(
                    HG.client_controller.services_manager.GetServices(
                        (HC.LOCAL_TAG, )))

                service = local_tag_services[0]

                service_key = service.GetServiceKey()
                action = HC.CONTENT_UPDATE_SET
                value = 'tag'

            service_type = service.GetServiceType()

            if service_type in HC.REAL_TAG_SERVICES:

                tag = value

                self._tag_sub_panel.SetValue(action, service_key, tag)

                self._panel_choice.SetValue(self.PANEL_TAG)

            elif service_type == HC.LOCAL_RATING_LIKE:

                rating = value

                self._rating_like_sub_panel.SetValue(action, service_key,
                                                     rating)

                self._panel_choice.SetValue(self.PANEL_RATING_LIKE)

            elif service_type == HC.LOCAL_RATING_NUMERICAL:

                if action in (HC.CONTENT_UPDATE_SET, HC.CONTENT_UPDATE_FLIP):

                    rating = value

                    self._rating_numerical_sub_panel.SetValue(
                        action, service_key, rating)

                    self._panel_choice.SetValue(self.PANEL_RATING_NUMERICAL)

                elif action in (HC.CONTENT_UPDATE_INCREMENT,
                                HC.CONTENT_UPDATE_DECREMENT):

                    distance = 1

                    self._rating_numerical_inc_dec_sub_panel.SetValue(
                        action, service_key, distance)

                    self._panel_choice.SetValue(
                        self.PANEL_RATING_NUMERICAL_INCDEC)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._panel_choice, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._simple_sub_panel,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._tag_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._rating_like_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._rating_numerical_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._rating_numerical_inc_dec_sub_panel,
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        vbox.addStretch(1)

        self.widget().setLayout(vbox)

        self._UpdateVisibleControls()

        #

        self._panel_choice.currentIndexChanged.connect(
            self._UpdateVisibleControls)
示例#6
0
    def ProcessApplicationCommand(self, command: CAC.ApplicationCommand):

        command_processed = True

        data = command.GetData()

        if command.IsSimpleCommand():

            action = data

            if action == CAC.SIMPLE_EXIT_APPLICATION:

                HG.client_controller.gui.TryToExit()

            elif action == CAC.SIMPLE_EXIT_APPLICATION_FORCE_MAINTENANCE:

                HG.client_controller.gui.TryToExit(
                    force_shutdown_maintenance=True)

            elif action == CAC.SIMPLE_RESTART_APPLICATION:

                HG.client_controller.gui.TryToExit(restart=True)

            elif action == CAC.SIMPLE_HIDE_TO_SYSTEM_TRAY:

                HG.client_controller.gui.HideToSystemTray()

            elif action == CAC.SIMPLE_CLOSE_MEDIA_VIEWER:

                self.close()

            elif action == CAC.SIMPLE_SWITCH_BETWEEN_FULLSCREEN_BORDERLESS_AND_REGULAR_FRAMED_WINDOW:

                self.FullscreenSwitch()

            elif action == CAC.SIMPLE_FLIP_DARKMODE:

                HG.client_controller.gui.FlipDarkmode()

            elif action == CAC.SIMPLE_GLOBAL_AUDIO_MUTE:

                ClientGUIMediaControls.SetMute(
                    ClientGUIMediaControls.AUDIO_GLOBAL, True)

            elif action == CAC.SIMPLE_GLOBAL_AUDIO_UNMUTE:

                ClientGUIMediaControls.SetMute(
                    ClientGUIMediaControls.AUDIO_GLOBAL, False)

            elif action == CAC.SIMPLE_GLOBAL_AUDIO_MUTE_FLIP:

                ClientGUIMediaControls.FlipMute(
                    ClientGUIMediaControls.AUDIO_GLOBAL)

            else:

                command_processed = False

        else:

            command_processed = False

        return command_processed