def _ShowCogMenu( self ):
     
     menu = QW.QMenu()
     
     if self._network_job is not None:
         
         if self._network_job.CurrentlyWaitingOnConnectionError():
             
             ClientGUIMenus.AppendMenuItem( menu, 'reattempt connection now', 'Stop waiting on a connection error and reattempt the job now.', self._network_job.OverrideConnectionErrorWait )
             
         
         if self._network_job.CurrentlyWaitingOnServersideBandwidth():
             
             ClientGUIMenus.AppendMenuItem( menu, 'reattempt request now (server reports low bandwidth)', 'Stop waiting on a serverside bandwidth delay and reattempt the job now.', self._network_job.OverrideServersideBandwidthWait )
             
         
         if self._network_job.ObeysBandwidth():
             
             ClientGUIMenus.AppendMenuItem( menu, 'override bandwidth rules for this job', 'Tell the current job to ignore existing bandwidth rules and go ahead anyway.', self._network_job.OverrideBandwidth )
             
         
         if not self._network_job.TokensOK():
             
             ClientGUIMenus.AppendMenuItem( menu, 'override gallery slot requirements for this job', 'Force-allow this download to proceed, ignoring the normal gallery wait times.', self._network_job.OverrideToken )
             
         
         ClientGUIMenus.AppendSeparator( menu )
         
     
     ClientGUIMenus.AppendMenuCheckItem( menu, 'auto-override bandwidth rules for all jobs here after five seconds', 'Ignore existing bandwidth rules for all jobs under this control, instead waiting a flat five seconds.', self._auto_override_bandwidth_rules, self.FlipAutoOverrideBandwidth )
     
     CGC.core().PopupMenu( self._cog_button, menu )
Example #2
0
 def _PopulateMenu( self, menu, menu_items ):
     
     for ( item_type, title, description, data ) in menu_items:
         
         if item_type == 'normal':
             
             func = data
             
             ClientGUIMenus.AppendMenuItem( menu, title, description, func )
             
         elif item_type == 'check':
             
             check_manager = data
             
             current_value = check_manager.GetCurrentValue()
             func = check_manager.Invert
             
             if current_value is not None:
                 
                 ClientGUIMenus.AppendMenuCheckItem( menu, title, description, current_value, func )
                 
             
         elif item_type == 'separator':
             
             ClientGUIMenus.AppendSeparator( menu )
             
         elif item_type == 'submenu':
             
             submenu = QW.QMenu( menu )
             
             self._PopulateMenu( submenu, data )
             
             ClientGUIMenus.AppendMenu( menu, submenu, title )
             
         elif item_type == 'label':
             
             ClientGUIMenus.AppendMenuLabel( menu, title, description = description )
Example #3
0
 def _ShowCogMenu( self ):
     
     menu = QW.QMenu()
     
     if self._network_job is not None and self._network_job.engine is not None:
         
         url = self._network_job.GetURL()
         
         ClientGUIMenus.AppendMenuLabel( menu, url, description = 'copy URL to the clipboard' )
         
         ClientGUIMenus.AppendSeparator( menu )
         
         network_contexts = self._network_job.GetNetworkContexts()
         
         if len( network_contexts ) > 0:
             
             bandwidth_manager = self._network_job.engine.bandwidth_manager
             
             submenu = QW.QMenu( menu )
             
             menu_network_contexts = []
             
             network_contexts_used = set()
             
             for network_context in network_contexts:
                 
                 uses_default = False
                 
                 if bandwidth_manager.UsesDefaultRules( network_context ):
                     
                     uses_default = True
                     
                     default_network_context = network_context.GetDefault()
                     
                     if default_network_context not in network_contexts_used:
                         
                         menu_network_contexts.append( ( False, default_network_context, network_context ) )
                         
                         network_contexts_used.add( default_network_context )
                         
                     
                 
                 if not network_context.IsEphemeral():
                     
                     menu_network_contexts.append( ( uses_default, network_context, network_context ) )
                     
                 
             
             for ( uses_default, network_context_to_edit, network_context_to_test ) in menu_network_contexts:
                 
                 network_context_text = network_context_to_edit.ToString()
                 
                 if uses_default:
                     
                     network_context_text = 'set rules for {}'.format( network_context_text )
                     
                 else:
                     
                     ( waiting_estimate, gumpf ) = bandwidth_manager.GetWaitingEstimateAndContext( [ network_context_to_test ] )
                     
                     if waiting_estimate > 0:
                         
                         network_context_text = '{} ({})'.format( network_context_text, HydrusData.TimeDeltaToPrettyTimeDelta( waiting_estimate ) )
                         
                     
                 
                 ClientGUIMenus.AppendMenuItem( submenu, network_context_text, 'edit the bandwidth rules for this network context', self._EditBandwidthRules, network_context_to_edit )
                 
             
             ClientGUIMenus.AppendMenu( menu, submenu, 'edit bandwidth rules' )
             
             ClientGUIMenus.AppendSeparator( menu )
             
         
         if self._network_job.CurrentlyWaitingOnConnectionError():
             
             ClientGUIMenus.AppendMenuItem( menu, 'reattempt connection now', 'Stop waiting on a connection error and reattempt the job now.', self._network_job.OverrideConnectionErrorWait )
             
         
         if not self._network_job.DomainOK():
             
             ClientGUIMenus.AppendMenuItem( menu, 'scrub domain errors', 'Clear recent domain errors and allow this job to go now.', self._network_job.ScrubDomainErrors )
             
         
         if self._network_job.CurrentlyWaitingOnServersideBandwidth():
             
             ClientGUIMenus.AppendMenuItem( menu, 'reattempt request now (server reports low bandwidth)', 'Stop waiting on a serverside bandwidth delay and reattempt the job now.', self._network_job.OverrideServersideBandwidthWait )
             
         
         if self._network_job.ObeysBandwidth():
             
             ClientGUIMenus.AppendMenuItem( menu, 'override bandwidth rules for this job', 'Tell the current job to ignore existing bandwidth rules and go ahead anyway.', self._network_job.OverrideBandwidth )
             
         
         if not self._network_job.TokensOK():
             
             ClientGUIMenus.AppendMenuItem( menu, 'override forced gallery wait times for this job', 'Force-allow this download to proceed, ignoring the normal gallery wait times.', self._network_job.OverrideToken )
             
         
         ClientGUIMenus.AppendSeparator( menu )
         
     
     ClientGUIMenus.AppendMenuCheckItem( menu, 'auto-override bandwidth rules for all jobs here after five seconds', 'Ignore existing bandwidth rules for all jobs under this control, instead waiting a flat five seconds.', self._auto_override_bandwidth_rules, self.FlipAutoOverrideBandwidth )
     
     CGC.core().PopupMenu( self._cog_button, menu )