def test_SERIALISABLE_TYPE_SHORTCUT(self):
        def test(obj, dupe_obj):

            self.assertEqual(dupe_obj.__hash__(),
                             (dupe_obj.shortcut_type, dupe_obj.shortcut_key,
                              dupe_obj.shortcut_press_type,
                              tuple(dupe_obj.modifiers)).__hash__())

            self.assertEqual(obj, dupe_obj)

        shortcuts = []

        shortcuts.append((ClientGUIShortcuts.Shortcut(), 'f7'))

        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_SPECIAL,
            ClientGUIShortcuts.SHORTCUT_KEY_SPECIAL_SPACE,
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, []), 'space'))
        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_CHARACTER, ord('a'),
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS,
            [ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL]), 'ctrl+a'))
        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_CHARACTER, ord('A'),
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS,
            [ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL]), 'ctrl+a'))
        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_SPECIAL,
            ClientGUIShortcuts.SHORTCUT_KEY_SPECIAL_HOME,
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [
                ClientGUIShortcuts.SHORTCUT_MODIFIER_ALT,
                ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL
            ]), 'ctrl+alt+home'))

        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE,
            ClientGUIShortcuts.SHORTCUT_MOUSE_LEFT,
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, []), 'left-click'))
        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE,
            ClientGUIShortcuts.SHORTCUT_MOUSE_MIDDLE,
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS,
            [ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL]), 'ctrl+middle-click'))
        shortcuts.append((ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE,
            ClientGUIShortcuts.SHORTCUT_MOUSE_SCROLL_DOWN,
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [
                ClientGUIShortcuts.SHORTCUT_MODIFIER_ALT,
                ClientGUIShortcuts.SHORTCUT_MODIFIER_SHIFT
            ]), 'alt+shift+scroll down'))

        for (shortcut, s) in shortcuts:

            self._dump_and_load_and_test(shortcut, test)

            if HC.PLATFORM_MACOS:

                s = s.replace('ctrl', 'command')

            self.assertEqual(shortcut.ToString(), s)
def ManageShortcuts(win: QW.QWidget):

    shortcuts_manager = ClientGUIShortcuts.shortcuts_manager()

    all_shortcuts = shortcuts_manager.GetShortcutSets()

    with ClientGUITopLevelWindowsPanels.DialogEdit(win,
                                                   'manage shortcuts') as dlg:

        panel = EditShortcutsPanel(dlg, all_shortcuts)

        dlg.SetPanel(panel)

        if dlg.exec() == QW.QDialog.Accepted:

            shortcut_sets = panel.GetValue()

            dupe_shortcut_sets = [
                shortcut_set.Duplicate() for shortcut_set in shortcut_sets
            ]

            HG.client_controller.Write(
                'serialisables_overwrite',
                [HydrusSerialisable.SERIALISABLE_TYPE_SHORTCUT_SET],
                dupe_shortcut_sets)

            shortcuts_manager.SetShortcutSets(shortcut_sets)
Exemplo n.º 3
0
    def __init__(self, parent):

        self._shortcut = ClientGUIShortcuts.Shortcut()

        QW.QLineEdit.__init__(self, parent)

        self._SetShortcutString()
Exemplo n.º 4
0
    def GetValue(self):

        name = self._name.text()

        if self._this_is_custom and name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            raise HydrusExceptions.VetoException(
                'That name is reserved--please pick another!')

        shortcut_set = ClientGUIShortcuts.ShortcutSet(name)

        for (shortcut, command) in self._shortcuts.GetData():

            dupe_command = shortcut_set.GetCommand(shortcut)

            if dupe_command is not None:

                message = 'The shortcut:'
                message += os.linesep * 2
                message += shortcut.ToString()
                message += os.linesep * 2
                message += 'is mapped twice:'
                message += os.linesep * 2
                message += command.ToString()
                message += os.linesep * 2
                message += dupe_command.ToString()
                message += os.linesep * 2
                message += 'The system only supports one command per shortcut in a set for now, please remove one.'

                raise HydrusExceptions.VetoException(message)

            shortcut_set.SetCommand(shortcut, command)

        return shortcut_set
Exemplo n.º 5
0
 def __init__( self, parent ):
     
     QW.QWidget.__init__( self, parent )
     
     self._canvas_type = ClientGUICommon.CANVAS_PREVIEW
     
     self._stop_for_slideshow = False
     
     # This is necessary since PyQT stomps over the locale settings needed by libmpv.
     # This needs to happen after importing PyQT before creating the first mpv.MPV instance.
     locale.setlocale( locale.LC_NUMERIC, 'C' )
     
     self.setAttribute( QC.Qt.WA_DontCreateNativeAncestors )
     self.setAttribute( QC.Qt.WA_NativeWindow )
     
     # loglevels: fatal, error, debug
     self._player = mpv.MPV( wid = str( int( self.winId() ) ), log_handler = print, loglevel = 'fatal' )
     
     # hydev notes on OSC:
     # OSC is by default off, default input bindings are by default off
     # difficult to get this to intercept mouse/key events naturally, so you have to pipe them to the window with 'command', but this is not excellent
     # general recommendation when using libmpv is to just implement your own stuff anyway, so let's do that for prototype
     
     #self._player[ 'input-default-bindings' ] = True
     
     self.UpdateConf()
     
     self._player.loop = True
     
     # this makes black screen for audio (rather than transparent)
     self._player.force_window = True
     
     # this actually propagates up to the OS-level sound mixer lmao, otherwise defaults to ugly hydrus filename
     self._player.title = 'hydrus mpv player'
     
     # pass up un-button-pressed mouse moves to parent, which wants to do cursor show/hide
     self.setMouseTracking( True )
     #self.setFocusPolicy(QC.Qt.StrongFocus)#Needed to get key events
     self._player.input_cursor = False#Disable mpv mouse move/click event capture
     self._player.input_vo_keyboard = False#Disable mpv key event capture, might also need to set input_x11_keyboard
     
     self._media = None
     
     self._file_is_loaded = False
     self._disallow_seek_on_this_file = False
     
     self._times_to_play_gif = 0
     
     self._current_seek_to_start_count = 0
     
     self._InitialiseMPVCallbacks()
     
     self.destroyed.connect( self._player.terminate )
     
     HG.client_controller.sub( self, 'UpdateAudioMute', 'new_audio_mute' )
     HG.client_controller.sub( self, 'UpdateAudioVolume', 'new_audio_volume' )
     HG.client_controller.sub( self, 'UpdateConf', 'notify_new_options' )
     
     self._my_shortcut_handler = ClientGUIShortcuts.ShortcutsHandler( self, [], catch_mouse = True )
Exemplo n.º 6
0
    def __init__(self, parent, related_radio=None):

        self._shortcut = ClientGUIShortcuts.Shortcut()

        self._related_radio = related_radio

        QW.QLineEdit.__init__(self, parent)

        self._SetShortcutString()
 def keyPressEvent( self, event ):
     
     ( modifier, key ) = ClientGUIShortcuts.ConvertKeyEventToSimpleTuple( event )
     
     if key == QC.Qt.Key_Escape:
         
         self.done( QW.QDialog.Rejected )
         
     else:
         
         QP.Dialog.keyPressEvent( self, event )
Exemplo n.º 8
0
    def _GetSelectedShortcutSet(self) -> ClientGUIShortcuts.ShortcutSet:

        name = self._name.text()

        shortcut_set = ClientGUIShortcuts.ShortcutSet(name)

        for (shortcut, command) in self._shortcuts.GetData(only_selected=True):

            shortcut_set.SetCommand(shortcut, command)

        return shortcut_set
Exemplo n.º 9
0
    def keyPressEvent(self, event):

        shortcut = ClientGUIShortcuts.ConvertKeyEventToShortcut(event)

        if shortcut is not None:

            self._shortcut = shortcut

            self._SetShortcutString()

            self.valueChanged.emit()
Exemplo n.º 10
0
 def keyPressEvent( self, event ):
     
     ( modifier, key ) = ClientGUIShortcuts.ConvertKeyEventToSimpleTuple( event )
     
     if key == QC.Qt.Key_Escape:
         
         self.close()
         
     else:
         
         event.ignore()
Exemplo n.º 11
0
    def __init__(self, parent):

        self._shortcut = ClientGUIShortcuts.Shortcut(
            ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE,
            ClientGUIShortcuts.SHORTCUT_MOUSE_LEFT,
            ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [])

        self._press_instead_of_release = True

        QW.QPushButton.__init__(self, parent)

        self._SetShortcutString()
Exemplo n.º 12
0
 def __init__( self, parent ):            
     
     # Parent is set to None here so that this window shows up as a separate entry on the taskbar
     ClientGUITopLevelWindows.FrameThatResizesWithHovers.__init__( self, None, 'hydrus client media viewer', 'media_viewer' )
     
     self._canvas_window = None
     
     self._my_shortcut_handler = ClientGUIShortcuts.ShortcutsHandler( self, [ 'global', 'media_viewer' ] )
     
     HG.client_controller.gui.RegisterCanvasFrameReference( self )
     
     self.destroyed.connect( HG.client_controller.gui.MaintainCanvasFrameReferences )
Exemplo n.º 13
0
        def keyPressEvent(self, event):

            (modifier,
             key) = ClientGUIShortcuts.ConvertKeyEventToSimpleTuple(event)

            if key in (QC.Qt.Key_Enter, QC.Qt.Key_Return):

                self._DoOK()

            else:

                event.ignore()
Exemplo n.º 14
0
    def keyPressEvent(self, event):

        shortcut = ClientGUIShortcuts.ConvertKeyEventToShortcut(event)

        if shortcut is not None:

            self._shortcut = shortcut

            if self._related_radio is not None:

                self._related_radio.setChecked(True)

            self._SetShortcutString()
Exemplo n.º 15
0
    def _ProcessMouseEvent(self, event):

        self.setFocus(QC.Qt.OtherFocusReason)

        shortcut = ClientGUIShortcuts.ConvertMouseEventToShortcut(event)

        if shortcut is not None:

            self._shortcut = shortcut

            self._SetShortcutString()

            self.valueChanged.emit()
Exemplo n.º 16
0
def ManageShortcuts(win: QW.QWidget):

    shortcuts_manager = ClientGUIShortcuts.shortcuts_manager()

    call_mouse_buttons_primary_secondary = HG.client_controller.new_options.GetBoolean(
        'call_mouse_buttons_primary_secondary')

    all_shortcuts = shortcuts_manager.GetShortcutSets()

    with ClientGUITopLevelWindowsPanels.DialogEdit(win,
                                                   'manage shortcuts') as dlg:

        panel = EditShortcutsPanel(dlg, call_mouse_buttons_primary_secondary,
                                   all_shortcuts)

        dlg.SetPanel(panel)

        if dlg.exec() == QW.QDialog.Accepted:

            (call_mouse_buttons_primary_secondary,
             shortcut_sets) = panel.GetValue()

            HG.client_controller.new_options.SetBoolean(
                'call_mouse_buttons_primary_secondary',
                call_mouse_buttons_primary_secondary)

            ClientGUIShortcuts.SetMouseLabels(
                call_mouse_buttons_primary_secondary)

            dupe_shortcut_sets = [
                shortcut_set.Duplicate() for shortcut_set in shortcut_sets
            ]

            HG.client_controller.Write(
                'serialisables_overwrite',
                [HydrusSerialisable.SERIALISABLE_TYPE_SHORTCUT_SET],
                dupe_shortcut_sets)

            shortcuts_manager.SetShortcutSets(shortcut_sets)
Exemplo n.º 17
0
 def test_SERIALISABLE_TYPE_SHORTCUT_SET( self ):
     
     def test( obj, dupe_obj ):
         
         for ( shortcut, command ) in obj:
             
             self.assertEqual( dupe_obj.GetCommand( shortcut ).GetData(), command.GetData() )
             
         
     
     default_shortcuts = ClientDefaults.GetDefaultShortcuts()
     
     for shortcuts in default_shortcuts:
         
         self._dump_and_load_and_test( shortcuts, test )
         
     
     command_1 = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_SIMPLE, 'archive_file' )
     command_2 = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_CONTENT, ( HydrusData.GenerateKey(), HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_FLIP, 'test' ) )
     command_3 = ClientData.ApplicationCommand( CC.APPLICATION_COMMAND_TYPE_CONTENT, ( CC.DEFAULT_LOCAL_TAG_SERVICE_KEY, HC.CONTENT_TYPE_MAPPINGS, HC.CONTENT_UPDATE_FLIP, 'test' ) )
     
     k_shortcut_1 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_SPECIAL, ClientGUIShortcuts.SHORTCUT_KEY_SPECIAL_SPACE, ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [] )
     k_shortcut_2 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_CHARACTER, ord( 'a' ), ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [ ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL ] )
     k_shortcut_3 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_CHARACTER, ord( 'A' ), ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [ ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL ] )
     k_shortcut_4 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_KEYBOARD_SPECIAL, ClientGUIShortcuts.SHORTCUT_KEY_SPECIAL_HOME, ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [ ClientGUIShortcuts.SHORTCUT_MODIFIER_ALT, ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL ] )
     
     m_shortcut_1 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE, ClientGUIShortcuts.SHORTCUT_MOUSE_LEFT, ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [] )
     m_shortcut_2 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE, ClientGUIShortcuts.SHORTCUT_MOUSE_MIDDLE, ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [ ClientGUIShortcuts.SHORTCUT_MODIFIER_CTRL ] )
     m_shortcut_3 = ClientGUIShortcuts.Shortcut( ClientGUIShortcuts.SHORTCUT_TYPE_MOUSE, ClientGUIShortcuts.SHORTCUT_MOUSE_SCROLL_DOWN, ClientGUIShortcuts.SHORTCUT_PRESS_TYPE_PRESS, [ ClientGUIShortcuts.SHORTCUT_MODIFIER_ALT, ClientGUIShortcuts.SHORTCUT_MODIFIER_SHIFT ] )
     
     shortcut_set = ClientGUIShortcuts.ShortcutSet( 'test' )
     
     shortcut_set.SetCommand( k_shortcut_1, command_1 )
     shortcut_set.SetCommand( k_shortcut_2, command_2 )
     shortcut_set.SetCommand( k_shortcut_3, command_2 )
     shortcut_set.SetCommand( k_shortcut_4, command_3 )
     
     shortcut_set.SetCommand( m_shortcut_1, command_1 )
     shortcut_set.SetCommand( m_shortcut_2, command_2 )
     shortcut_set.SetCommand( m_shortcut_3, command_3 )
     
     self._dump_and_load_and_test( shortcut_set, test )
     
     self.assertEqual( shortcut_set.GetCommand( k_shortcut_1 ).GetData(), command_1.GetData() )
     
     shortcut_set.SetCommand( k_shortcut_1, command_3 )
     
     self.assertEqual( shortcut_set.GetCommand( k_shortcut_1 ).GetData(), command_3.GetData() )
 def keyPressEvent( self, event ):
     
     ( modifier, key ) = ClientGUIShortcuts.ConvertKeyEventToSimpleTuple( event )
     
     current_focus = QW.QApplication.focusWidget()
     
     event_from_us = current_focus is not None and ClientGUIFunctions.IsQtAncestor( current_focus, self )
     
     if event_from_us and key == QC.Qt.Key_Escape:
         
         self._TryEndModal( QW.QDialog.Rejected )
         
     else:
         
         QP.Dialog.keyPressEvent( self, event )
Exemplo n.º 19
0
    def _ProcessMouseEvent(self, event):

        self.setFocus(QC.Qt.OtherFocusReason)

        shortcut = ClientGUIShortcuts.ConvertMouseEventToShortcut(event)

        if shortcut is not None:

            self._shortcut = shortcut

            if self._related_radio is not None:

                self._related_radio.setChecked(True)

            self._SetShortcutString()
Exemplo n.º 20
0
 def EventKeyDown( self, event ):
     
     ( modifier, key ) = ClientGUIShortcuts.ConvertKeyEventToSimpleTuple( event )
     
     if key in ClientGUIShortcuts.DELETE_KEYS:
         
         self.ProcessDeleteAction()
         
     elif key in ( ord( 'A' ), ord( 'a' ) ) and modifier == QC.Qt.ControlModifier:
         
         self.selectAll()
         
     else:
         
         return True # was: event.ignore()
Exemplo n.º 21
0
    def _Add(self):

        shortcut_set = ClientGUIShortcuts.ShortcutSet('new shortcuts')

        with ClientGUITopLevelWindowsPanels.DialogEdit(
                self, 'edit shortcuts') as dlg:

            panel = EditShortcutSetPanel(dlg, shortcut_set)

            dlg.SetPanel(panel)

            if dlg.exec() == QW.QDialog.Accepted:

                new_shortcuts = panel.GetValue()

                self._custom_shortcuts.AddDatas((new_shortcuts, ))
    def GetValue(self):

        name = self._name.text()

        if self._this_is_custom and name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            raise HydrusExceptions.VetoException(
                'That name is reserved--please pick another!')

        shortcut_set = ClientGUIShortcuts.ShortcutSet(name)

        for (shortcut, command) in self._shortcuts.GetData():

            shortcut_set.SetCommand(shortcut, command)

        return shortcut_set
Exemplo n.º 23
0
    def __init__(self, parent, ok_on_these_commands=None):

        EditPanel.__init__(self, parent)

        self._control = None

        if ok_on_these_commands is None:

            ok_on_these_commands = set()

        self._ok_on_these_commands = set(ok_on_these_commands)

        #

        self._vbox = QP.VBoxLayout(margin=0)

        self.widget().setLayout(self._vbox)

        self._my_shortcuts_handler = ClientGUIShortcuts.ShortcutsHandler(
            self, ['media'])
Exemplo n.º 24
0
    def AddShortcut(self):

        shortcut = ClientGUIShortcuts.Shortcut()
        command = CAC.ApplicationCommand()
        name = self._name.text()

        with ClientGUITopLevelWindowsPanels.DialogEdit(
                self, 'edit shortcut command') as dlg:

            panel = EditShortcutAndCommandPanel(dlg, shortcut, command, name)

            dlg.SetPanel(panel)

            if dlg.exec() == QW.QDialog.Accepted:

                (shortcut, command) = panel.GetValue()

                data = (shortcut, command)

                self._shortcuts.AddDatas((data, ))
Exemplo n.º 25
0
 def __init__( self, parent ):
     
     QW.QWidget.__init__( self, parent )
     
     self._canvas_type = ClientGUICommon.CANVAS_PREVIEW
     
     self._stop_for_slideshow = False
     
     # This is necessary since PyQT stomps over the locale settings needed by libmpv.
     # This needs to happen after importing PyQT before creating the first mpv.MPV instance.
     locale.setlocale( locale.LC_NUMERIC, 'C' )
     
     self.setAttribute( QC.Qt.WA_DontCreateNativeAncestors )
     self.setAttribute( QC.Qt.WA_NativeWindow )
     
     # loglevels: fatal, error, debug
     self._player = mpv.MPV( wid = str( int( self.winId() ) ), log_handler = print, loglevel = 'fatal' )
     
     # hydev notes on OSC:
     # OSC is by default off, default input bindings are by default off
     # difficult to get this to intercept mouse/key events naturally, so you have to pipe them to the window with 'command', but this is not excellent
     # general recommendation when using libmpv is to just implement your own stuff anyway, so let's do that for prototype
     
     #self._player[ 'input-default-bindings' ] = True
     
     self.UpdateConf()
     
     #self._player.osc = True #Set to enable the mpv UI. Requires that mpv captures mouse/key events, otherwise it won't work.
     
     self._player.loop = True
     
     # this makes black screen for audio (rather than transparent)
     self._player.force_window = True
     
     # this actually propagates up to the OS-level sound mixer lmao, otherwise defaults to ugly hydrus filename
     self._player.title = 'hydrus mpv player'
     
     # this is telling ffmpeg to do audio normalization. play with it more and put it in default mpv.conf
     # it doesn't seem to apply at all for some files--maybe a vp9 issue or something?
     #self._player.af = 'lavfi=[dynaudnorm=p=0.9]'
     
     self.setMouseTracking( True )#Needed to get mouse move events
     #self.setFocusPolicy(QC.Qt.StrongFocus)#Needed to get key events
     self._player.input_cursor = False#Disable mpv mouse move/click event capture
     self._player.input_vo_keyboard = False#Disable mpv key event capture, might also need to set input_x11_keyboard
     
     self._media = None
     
     self._times_to_play_gif = 0
     
     self._current_seek_to_start_count = 0
     
     player = self._player
     
     def qt_seek_event():
         
         if not QP.isValid( self ):
             
             return
             
         
         if self._media is not None and self._player.time_pos <= 1.0:
             
             self._current_seek_to_start_count += 1
             
             if self._stop_for_slideshow:
                 
                 self.Pause()
                 
             
             if self._times_to_play_gif != 0 and self._current_seek_to_start_count >= self._times_to_play_gif:
                 
                 self.Pause()
                 
             
         
         
     
     @player.event_callback( mpv.MpvEventID.SEEK )
     def seek_event( event ):
         
         QP.CallAfter( qt_seek_event )
         
     
     self.destroyed.connect( self._player.terminate )
     
     HG.client_controller.sub( self, 'UpdateAudioMute', 'new_audio_mute' )
     HG.client_controller.sub( self, 'UpdateAudioVolume', 'new_audio_volume' )
     HG.client_controller.sub( self, 'UpdateConf', 'notify_new_options' )
     
     self._my_shortcut_handler = ClientGUIShortcuts.ShortcutsHandler( self, [], catch_mouse = True )
Exemplo n.º 26
0
    def _UpdateMouseLabels(self):

        swap_labels = self._call_mouse_buttons_primary_secondary.isChecked()

        ClientGUIShortcuts.SetMouseLabels(swap_labels)
Exemplo n.º 27
0
    def __init__(self, parent, media):

        self._hashes = set()

        for m in media:

            self._hashes.update(m.GetHashes())

        ClientGUIDialogs.Dialog.__init__(
            self,
            parent,
            'manage ratings for ' + HydrusData.ToHumanInt(len(self._hashes)) +
            ' files',
            position='topleft')

        #

        like_services = HG.client_controller.services_manager.GetServices(
            (HC.LOCAL_RATING_LIKE, ))
        numerical_services = HG.client_controller.services_manager.GetServices(
            (HC.LOCAL_RATING_NUMERICAL, ))

        self._panels = []

        if len(like_services) > 0:

            self._panels.append(self._LikePanel(self, like_services, media))

        if len(numerical_services) > 0:

            self._panels.append(
                self._NumericalPanel(self, numerical_services, media))

        self._apply = QW.QPushButton('apply', self)
        self._apply.clicked.connect(self.EventOK)
        self._apply.setObjectName('HydrusAccept')

        self._cancel = QW.QPushButton('cancel', self)
        self._cancel.clicked.connect(self.reject)
        self._cancel.setObjectName('HydrusCancel')

        #

        buttonbox = QP.HBoxLayout()

        QP.AddToLayout(buttonbox, self._apply, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(buttonbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        for panel in self._panels:

            QP.AddToLayout(vbox, panel, CC.FLAGS_EXPAND_PERPENDICULAR)

        QP.AddToLayout(vbox, buttonbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        QP.SetInitialSize(self, size_hint)

        #

        self._my_shortcut_handler = ClientGUIShortcuts.ShortcutsHandler(
            self, ['global', 'media'])