Beispiel #1
0
 def __init__( self, parent, controller, read_only, can_generate_more_pages, gallery_seed_log ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._controller = controller
     self._read_only = read_only
     self._can_generate_more_pages = can_generate_more_pages
     self._gallery_seed_log = gallery_seed_log
     
     self._text = ClientGUICommon.BetterStaticText( self, 'initialising' )
     
     # add index control row here, hide it if needed and hook into showing/hiding and postsizechangedevent on gallery_seed add/remove
     
     self._list_ctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_GALLERY_SEED_LOG.ID, 30, self._ConvertGallerySeedToListCtrlTuples )
     
     #
     
     self._list_ctrl.AddDatas( self._gallery_seed_log.GetGallerySeeds() )
     
     self._list_ctrl.Sort()
     
     #
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._text, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._list_ctrl, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     self.widget().setLayout( vbox )
     
     self._list_ctrl.AddMenuCallable( self._GetListCtrlMenu )
     
     self._controller.sub( self, 'NotifyGallerySeedsUpdated', 'gallery_seed_log_gallery_seeds_updated' )
     
     QP.CallAfter( self._UpdateText )
    def __init__(self, parent, shortcut, command, shortcuts_name):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        #

        self._shortcut_panel = ClientGUICommon.StaticBox(self, 'shortcut')

        self._shortcut = ShortcutWidget(self._shortcut_panel)

        self._command_panel = ClientGUICommon.StaticBox(self, 'command')

        self._command = ClientGUIApplicationCommand.ApplicationCommandWidget(
            self._command_panel, command, shortcuts_name)

        #

        self._shortcut.SetValue(shortcut)

        #

        self._shortcut_panel.Add(self._shortcut, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._command_panel.Add(self._command, CC.FLAGS_EXPAND_BOTH_WAYS)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._shortcut_panel,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, ClientGUICommon.BetterStaticText(self, '\u2192'),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._command_panel, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.widget().setLayout(hbox)
 def __init__( self, parent, external_port, protocol_type, internal_port, description, duration ):
     
     Dialog.__init__( self, parent, 'configure upnp mapping' )
     
     self._external_port = QP.MakeQSpinBox( self, min=0, max=65535 )
     
     self._protocol_type = ClientGUICommon.BetterChoice( self )
     self._protocol_type.addItem( 'TCP', 'TCP' )
     self._protocol_type.addItem( 'UDP', 'UDP' )
     
     self._internal_port = QP.MakeQSpinBox( self, min=0, max=65535 )
     self._description = QW.QLineEdit( self )
     self._duration = QP.MakeQSpinBox( self, min=0, max=86400 )
     
     self._ok = ClientGUICommon.BetterButton( self, 'OK', self.done, QW.QDialog.Accepted )
     self._ok.setObjectName( 'HydrusAccept' )
     
     self._cancel = QW.QPushButton( 'Cancel', self )
     self._cancel.clicked.connect( self.reject )
     self._cancel.setObjectName( 'HydrusCancel' )
     
     #
     
     self._external_port.setValue( external_port )
     
     if protocol_type == 'TCP': self._protocol_type.setCurrentIndex( 0 )
     elif protocol_type == 'UDP': self._protocol_type.setCurrentIndex( 1 )
     
     self._internal_port.setValue( internal_port )
     self._description.setText( description )
     self._duration.setValue( duration )
     
     #
     
     rows = []
     
     rows.append( ( 'external port: ', self._external_port ) )
     rows.append( ( 'protocol type: ', self._protocol_type ) )
     rows.append( ( 'internal port: ', self._internal_port ) )
     rows.append( ( 'description: ', self._description ) )
     rows.append( ( 'duration (0 = indefinite): ', self._duration ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     b_box = QP.HBoxLayout()
     QP.AddToLayout( b_box, self._ok, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( b_box, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, gridbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
     QP.AddToLayout( vbox, b_box, CC.FLAGS_ON_RIGHT )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     QP.SetInitialSize( self, size_hint )
     
     HG.client_controller.CallAfterQtSafe( self._ok, self._ok.setFocus, QC.Qt.OtherFocusReason)
    def __init__(self, parent, label):

        ClientGUIScrolledPanels.ResizingScrolledPanel.__init__(self, parent)

        self._commit = ClientGUICommon.BetterButton(self,
                                                    'commit and continue',
                                                    self.parentWidget().done,
                                                    QW.QDialog.Accepted)
        self._commit.setObjectName('HydrusAccept')

        self._back = ClientGUICommon.BetterButton(self, 'go back',
                                                  self.parentWidget().done,
                                                  QW.QDialog.Rejected)

        vbox = QP.VBoxLayout()

        st = ClientGUICommon.BetterStaticText(self, label)

        st.setAlignment(QC.Qt.AlignCenter)

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._commit, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        st = ClientGUICommon.BetterStaticText(self, '-or-')

        st.setAlignment(QC.Qt.AlignCenter)

        QP.AddToLayout(vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._back, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        ClientGUIFunctions.SetFocusLater(self._commit)
Beispiel #5
0
 def __init__( self, parent, service_type, account_types ):
     
     self._service_type = service_type
     self._original_account_types = account_types
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._deletee_account_type_keys_to_new_account_type_keys = {}
     
     self._account_types_listctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_ACCOUNT_TYPES.ID, 20, self._ConvertAccountTypeToTuples, delete_key_callback = self._Delete, activation_callback = self._Edit )
     
     self._add_button = ClientGUICommon.BetterButton( self, 'add', self._Add )
     self._edit_button = ClientGUICommon.BetterButton( self, 'edit', self._Edit )
     self._delete_button = ClientGUICommon.BetterButton( self, 'delete', self._Delete )
     
     self._account_types_listctrl.AddDatas( self._original_account_types )
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._add_button, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._edit_button, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( hbox, self._delete_button, CC.FLAGS_CENTER_PERPENDICULAR )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._account_types_listctrl, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT )
     
     self.widget().setLayout( vbox )
    def __init__(self, parent, initial_value=65536, none_label='no limit'):

        QW.QWidget.__init__(self, parent)

        self._bytes = BytesControl(self)

        self._none_checkbox = QW.QCheckBox(none_label, self)

        #

        self.SetValue(initial_value)

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._bytes, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._none_checkbox,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)

        #

        self._none_checkbox.clicked.connect(self._UpdateEnabled)

        self._bytes.valueChanged.connect(self._HandleValueChanged)
        self._none_checkbox.clicked.connect(self._HandleValueChanged)
 def __init__( self, parent ):
     
     Dialog.__init__( self, parent, 'how to set up the account?', position = 'center' )
     
     register_message = 'I want to initialise a new account with the server. I have a registration key (a key starting with \'r\').'
     
     self._register = QW.QPushButton( register_message, self )
     self._register.clicked.connect( self.EventRegister )
     
     setup_message = 'The account is already initialised; I just want to add it to this client. I have a normal access key.'
     
     self._setup = QW.QPushButton( setup_message, self )
     self._setup.clicked.connect( self.accept )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._register, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment('-or-', self, QC.Qt.AlignHCenter | QC.Qt.AlignVCenter ), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._setup, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     QP.SetInitialSize( self, size_hint )
     
     self._should_register = False
     
     HG.client_controller.CallAfterQtSafe( self._register, self._register.setFocus, QC.Qt.OtherFocusReason )
Beispiel #8
0
    def __init__(self, parent, service_key, media, activate_callable):

        QW.QWidget.__init__(self, parent)

        self._service_key = service_key
        self._media = media

        self._last_fetched_tags = []

        self._new_options = HG.client_controller.new_options

        vbox = QP.VBoxLayout()

        clear_button = QW.QPushButton('clear', self)
        clear_button.clicked.connect(self.EventClear)

        self._recent_tags = ListBoxTagsSuggestionsFavourites(self,
                                                             self._service_key,
                                                             activate_callable,
                                                             sort_tags=False)

        QP.AddToLayout(vbox, clear_button, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._recent_tags, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        self._RefreshRecentTags()

        self._recent_tags.mouseActivationOccurred.connect(
            self.mouseActivationOccurred)
    def __init__(self, parent, initial_value=65536):

        QW.QWidget.__init__(self, parent)

        self._spin = QP.MakeQSpinBox(self, min=0, max=1048576)

        self._unit = ClientGUICommon.BetterChoice(self)

        self._unit.addItem('B', 1)
        self._unit.addItem('KB', 1024)
        self._unit.addItem('MB', 1024 * 1024)
        self._unit.addItem('GB', 1024 * 1024 * 1024)

        #

        self.SetValue(initial_value)

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._spin, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._unit, CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)

        self._spin.valueChanged.connect(self._HandleValueChanged)
        self._unit.currentIndexChanged.connect(self._HandleValueChanged)
Beispiel #10
0
 def __init__( self, parent, controller, file_seed_cache ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._controller = controller
     self._file_seed_cache = file_seed_cache
     
     self._text = ClientGUICommon.BetterStaticText( self, 'initialising' )
     
     # add index control row here, hide it if needed and hook into showing/hiding and postsizechangedevent on file_seed add/remove
     
     self._list_ctrl = ClientGUIListCtrl.BetterListCtrl( self, CGLC.COLUMN_LIST_FILE_SEED_CACHE.ID, 30, self._ConvertFileSeedToListCtrlTuples, activation_callback = self._ShowSelectionInNewPage, delete_key_callback = self._DeleteSelected )
     
     #
     
     self._list_ctrl.AddDatas( self._file_seed_cache.GetFileSeeds() )
     
     self._list_ctrl.Sort()
     
     #
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._text, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._list_ctrl, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     self.widget().setLayout( vbox )
     
     self._list_ctrl.AddMenuCallable( self._GetListCtrlMenu )
     
     self._controller.sub( self, 'NotifyFileSeedsUpdated', 'file_seed_cache_file_seeds_updated' )
     
     QP.CallAfter( self._UpdateText )
Beispiel #11
0
 def __init__( self, parent, controller, read_only, can_generate_more_pages, page_key = None ):
     
     QW.QFrame.__init__( self, parent )
     self.setFrameStyle( QW.QFrame.Box | QW.QFrame.Raised )
     
     self._controller = controller
     self._read_only = read_only
     self._can_generate_more_pages = can_generate_more_pages
     self._page_key = page_key
     
     self._gallery_seed_log = None
     
     self._log_summary_st = ClientGUICommon.BetterStaticText( self, ellipsize_end = True )
     
     self._gallery_seed_log_button = GallerySeedLogButton( self, self._controller, self._read_only, self._can_generate_more_pages, self._GetGallerySeedLog )
     
     #
     
     self._Update()
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._log_summary_st, CC.FLAGS_VCENTER_EXPAND_DEPTH_ONLY )
     QP.AddToLayout( hbox, self._gallery_seed_log_button, CC.FLAGS_VCENTER )
     
     self.setLayout( hbox )
     
     #
     
     HG.client_controller.gui.RegisterUIUpdateWindow( self )
    def __init__(self, parent, message, yes_label='yes', no_label='no'):

        ClientGUIScrolledPanels.ResizingScrolledPanel.__init__(self, parent)

        self._yes = ClientGUICommon.BetterButton(self, yes_label,
                                                 self.parentWidget().done,
                                                 QW.QDialog.Accepted)
        self._yes.setObjectName('HydrusAccept')
        self._yes.setText(yes_label)

        self._no = ClientGUICommon.BetterButton(self, no_label,
                                                self.parentWidget().done,
                                                QW.QDialog.Rejected)
        self._no.setObjectName('HydrusCancel')
        self._no.setText(no_label)

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._yes)
        QP.AddToLayout(hbox, self._no)

        vbox = QP.VBoxLayout()

        text = ClientGUICommon.BetterStaticText(self, message)
        text.setWordWrap(True)

        QP.AddToLayout(vbox, text)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_BUTTON_SIZER)

        self.widget().setLayout(vbox)

        HG.client_controller.CallAfterQtSafe(self._yes, self._yes.setFocus,
                                             QC.Qt.OtherFocusReason)
        def __init__(self, parent, predicate_panel_class, predicate):

            QW.QWidget.__init__(self, parent)

            self._defaults_button = ClientGUICommon.BetterBitmapButton(
                self,
                CC.global_pixmaps().star, self._DefaultsMenu)
            self._defaults_button.setToolTip('Set a new default.')

            self._predicate_panel = predicate_panel_class(self, predicate)
            self._parent = parent

            self._ok = QW.QPushButton('ok', self)
            self._ok.clicked.connect(self._DoOK)
            self._ok.setObjectName('HydrusAccept')

            hbox = QP.HBoxLayout()

            QP.AddToLayout(hbox, self._defaults_button,
                           CC.FLAGS_CENTER_PERPENDICULAR)
            QP.AddToLayout(hbox, self._predicate_panel,
                           CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
            QP.AddToLayout(hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR)

            self.setLayout(hbox)

            HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus,
                                                 QC.Qt.OtherFocusReason)
    def __init__(self, parent, add_callable, allow_empty_input=False):

        self._add_callable = add_callable
        self._allow_empty_input = allow_empty_input

        QW.QWidget.__init__(self, parent)

        self._text_input = QW.QLineEdit(self)
        self._text_input.installEventFilter(
            ClientGUICommon.TextCatchEnterEventFilter(self._text_input,
                                                      self.EnterText))

        self._paste_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().paste, self._Paste)
        self._paste_button.setToolTip(
            'Paste multiple inputs from the clipboard. Assumes the texts are newline-separated.'
        )

        self.setFocusProxy(self._text_input)

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._text_input, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(hbox, self._paste_button, CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)
 def __init__( self, parent, export_folders ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     self._export_folders_panel = ClientGUIListCtrl.BetterListCtrlPanel( self )
     
     self._export_folders = ClientGUIListCtrl.BetterListCtrl( self._export_folders_panel, CGLC.COLUMN_LIST_EXPORT_FOLDERS.ID, 6, self._ConvertExportFolderToListCtrlTuples, use_simple_delete = True, activation_callback = self._Edit )
     
     self._export_folders_panel.SetListCtrl( self._export_folders )
     
     self._export_folders_panel.AddButton( 'add', self._AddFolder )
     self._export_folders_panel.AddButton( 'edit', self._Edit, enabled_only_on_selection = True )
     self._export_folders_panel.AddDeleteButton()
     
     #
     
     self._export_folders.AddDatas( export_folders )
     
     self._export_folders.Sort()
     
     vbox = QP.VBoxLayout()
     
     intro = 'Here you can set the client to regularly export a certain query to a particular location.'
     
     QP.AddToLayout( vbox, ClientGUICommon.BetterStaticText(self,intro), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._export_folders_panel, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     self.widget().setLayout( vbox )
Beispiel #16
0
 def __init__( self, parent, message, yes_label = 'yes', no_label = 'no' ):
     
     ClientGUIScrolledPanels.ResizingScrolledPanel.__init__( self, parent )
     
     self._yes = ClientGUICommon.BetterButton( self, yes_label, self.parentWidget().done, QW.QDialog.Accepted )
     self._yes.setObjectName( 'HydrusAccept' )
     self._yes.setText( yes_label )
     
     self._no = ClientGUICommon.BetterButton( self, no_label, self.parentWidget().done, QW.QDialog.Rejected )
     self._no.setObjectName( 'HydrusCancel' )
     self._no.setText( no_label )
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._yes )
     QP.AddToLayout( hbox, self._no )
     
     vbox = QP.VBoxLayout()
     
     text = ClientGUICommon.BetterStaticText( self, message )
     text.setWordWrap( True )
     
     QP.AddToLayout( vbox, text )
     QP.AddToLayout( vbox, hbox, CC.FLAGS_ON_RIGHT )
     
     self.widget().setLayout( vbox )
     
     ClientGUIFunctions.SetFocusLater( self._yes )
    def __init__(self, parent, label):

        ClientGUIScrolledPanels.ResizingScrolledPanel.__init__(self, parent)

        self._commit = ClientGUICommon.BetterButton(self,
                                                    'commit and continue',
                                                    self.parentWidget().done,
                                                    QW.QDialog.Accepted)
        self._commit.setObjectName('HydrusAccept')

        self._back = ClientGUICommon.BetterButton(self, 'go back',
                                                  self.parentWidget().done,
                                                  QW.QDialog.Rejected)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(
            vbox,
            QP.MakeQLabelWithAlignment(label, self, QC.Qt.AlignVCenter
                                       | QC.Qt.AlignHCenter),
            CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._commit, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(
            vbox,
            QP.MakeQLabelWithAlignment('-or-', self, QC.Qt.AlignVCenter
                                       | QC.Qt.AlignHCenter),
            CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._back, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        HG.client_controller.CallAfterQtSafe(self._commit,
                                             self._commit.setFocus,
                                             QC.Qt.OtherFocusReason)
Beispiel #18
0
 def __init__( self, parent: QW.QWidget ):
     
     QW.QWidget.__init__( self, parent )
     
     self._add_or_move_action = ClientGUICommon.BetterChoice( self )
     
     self._add_or_move_action.addItem( 'add to', HC.CONTENT_UPDATE_ADD )
     self._add_or_move_action.addItem( 'move to', HC.CONTENT_UPDATE_MOVE )
     
     self._add_or_move_action.SetValue( HC.CONTENT_UPDATE_ADD )
     
     self._service_keys = ClientGUICommon.BetterChoice( self )
     
     #
     
     services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_FILE_DOMAIN, ) )
     
     for service in services:
         
         service_name = service.GetName()
         service_key = service.GetServiceKey()
         
         self._service_keys.addItem( service_name, service_key )
         
     
     #
     
     vbox = QP.VBoxLayout()
     
     ratings_numerical_hbox = QP.HBoxLayout()
     
     QP.AddToLayout( vbox, self._add_or_move_action, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, self._service_keys, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.setLayout( vbox )
 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 )
 def __init__( self, parent, min_unit_value, max_unit_value, min_time_delta, days = False, hours = False, minutes = False, seconds = False, per_phrase = 'per', unit = None ):
     
     QW.QWidget.__init__( self, parent )
     
     self._num = QP.MakeQSpinBox( self, min=min_unit_value, max=max_unit_value, width = 60 )
     
     self._times = TimeDeltaCtrl( self, min = min_time_delta, days = days, hours = hours, minutes = minutes, seconds = seconds )
     
     #
     
     hbox = QP.HBoxLayout( margin = 0 )
     
     QP.AddToLayout( hbox, self._num, CC.FLAGS_CENTER_PERPENDICULAR )
     
     mid_text = per_phrase
     
     if unit is not None:
         
         mid_text = '{} {}'.format( unit, mid_text )
         
     
     QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,mid_text), CC.FLAGS_CENTER_PERPENDICULAR )
     
     QP.AddToLayout( hbox, self._times, CC.FLAGS_CENTER_PERPENDICULAR )
     
     self.setLayout( hbox )
Beispiel #21
0
 def __init__( self, parent: QW.QWidget, service_key: bytes, accounts: typing.Collection[ HydrusNetwork.Account ] ):
     
     ClientGUIScrolledPanels.ReviewPanel.__init__( self, parent )
     
     self._service_key = service_key
     self._service = HG.client_controller.services_manager.GetService( self._service_key )
     self._accounts = accounts
     
     self._accounts_box = ClientGUICommon.StaticBox( self, 'accounts' )
     
     self._account_list = ClientGUIListBoxes.BetterQListWidget( self._accounts_box )
     self._account_list.setSelectionMode( QW.QListWidget.ExtendedSelection )
     
     ( min_width, min_height ) = ClientGUIFunctions.ConvertTextToPixels( self._account_list, ( 74, 16 ) )
     
     self._account_list.setMinimumSize( min_width, min_height )
     
     modify_button = ClientGUICommon.BetterButton( self._accounts_box, 'modify selected', self._ModifyAccounts )
     
     #
     
     my_admin_account_key = self._service.GetAccount().GetAccountKey()
     
     accounts.sort( key = lambda a: ( a.GetAccountType().GetTitle(), a.GetAccountKey().hex() ) )
     
     for account in accounts:
         
         item = QW.QListWidgetItem()
         
         account_key = account.GetAccountKey()
         
         text = account.GetSingleLineTitle()
         
         if account_key == my_admin_account_key:
             
             text = 'THIS IS YOU: {}'.format( text )
             
         
         item.setText( text )
         
         item.setData( QC.Qt.UserRole, account )
         
         self._account_list.addItem( item )
         
     
     #
     
     self._accounts_box.Add( self._account_list, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, self._accounts_box, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, modify_button, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.widget().setLayout( vbox )
     
     #
     
     self._account_list.itemDoubleClicked.connect( self._ModifyAccounts )
 def __init__( self, parent, min = 1, days = False, hours = False, minutes = False, seconds = False, monthly_allowed = False, monthly_label = 'monthly' ):
     
     QW.QWidget.__init__( self, parent )
     
     self._min = min
     self._show_days = days
     self._show_hours = hours
     self._show_minutes = minutes
     self._show_seconds = seconds
     self._monthly_allowed = monthly_allowed
     
     hbox = QP.HBoxLayout( margin = 0 )
     
     if self._show_days:
         
         self._days = QP.MakeQSpinBox( self, min=0, max=3653, width = 50 )
         self._days.valueChanged.connect( self.EventChange )
         
         QP.AddToLayout( hbox, self._days, CC.FLAGS_CENTER_PERPENDICULAR )
         QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'days'), CC.FLAGS_CENTER_PERPENDICULAR )
         
     
     if self._show_hours:
         
         self._hours = QP.MakeQSpinBox( self, min=0, max=23, width = 45 )
         self._hours.valueChanged.connect( self.EventChange )
         
         QP.AddToLayout( hbox, self._hours, CC.FLAGS_CENTER_PERPENDICULAR )
         QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'hours'), CC.FLAGS_CENTER_PERPENDICULAR )
         
     
     if self._show_minutes:
         
         self._minutes = QP.MakeQSpinBox( self, min=0, max=59, width = 45 )
         self._minutes.valueChanged.connect( self.EventChange )
         
         QP.AddToLayout( hbox, self._minutes, CC.FLAGS_CENTER_PERPENDICULAR )
         QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'minutes'), CC.FLAGS_CENTER_PERPENDICULAR )
         
     
     if self._show_seconds:
         
         self._seconds = QP.MakeQSpinBox( self, min=0, max=59, width = 45 )
         self._seconds.valueChanged.connect( self.EventChange )
         
         QP.AddToLayout( hbox, self._seconds, CC.FLAGS_CENTER_PERPENDICULAR )
         QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,'seconds'), CC.FLAGS_CENTER_PERPENDICULAR )
         
     
     if self._monthly_allowed:
         
         self._monthly = QW.QCheckBox( self )
         self._monthly.clicked.connect( self.EventChange )
         
         QP.AddToLayout( hbox, self._monthly, CC.FLAGS_CENTER_PERPENDICULAR )
         QP.AddToLayout( hbox, ClientGUICommon.BetterStaticText(self,monthly_label), CC.FLAGS_CENTER_PERPENDICULAR )
         
     
     self.setLayout( hbox )
        def __init__(self, parent, canvas_type, direction='down'):

            QW.QFrame.__init__(self, parent)

            self._canvas_type = canvas_type

            self._direction = direction

            self.setWindowFlags(QC.Qt.Tool | QC.Qt.FramelessWindowHint)

            self.setAttribute(QC.Qt.WA_ShowWithoutActivating)

            if self._canvas_type == ClientGUICommon.CANVAS_MEDIA_VIEWER:

                option_to_use = 'media_viewer_uses_its_own_audio_volume'
                volume_type = AUDIO_MEDIA_VIEWER

            else:

                option_to_use = 'preview_uses_its_own_audio_volume'
                volume_type = AUDIO_PREVIEW

            self._specific_mute = AudioMuteButton(self, volume_type)

            self._specific_mute.setToolTip('Mute/unmute: {}'.format(
                ClientGUICommon.canvas_str_lookup[self._canvas_type]))

            if HG.client_controller.new_options.GetBoolean(option_to_use):

                slider_volume_type = volume_type

            else:

                slider_volume_type = AUDIO_GLOBAL

            self._volume = VolumeSlider(self, slider_volume_type)

            vbox = QP.VBoxLayout()

            if self._direction == 'down':

                QP.AddToLayout(vbox, self._specific_mute,
                               CC.FLAGS_SMALL_INDENT)
                QP.AddToLayout(vbox, self._volume, CC.FLAGS_SMALL_INDENT)

            else:

                QP.AddToLayout(vbox, self._volume, CC.FLAGS_SMALL_INDENT)
                QP.AddToLayout(vbox, self._specific_mute,
                               CC.FLAGS_SMALL_INDENT)

            vbox.setAlignment(self._volume, QC.Qt.AlignHCenter)
            vbox.setAlignment(self._specific_mute, QC.Qt.AlignHCenter)

            self.setLayout(vbox)

            self.hide()

            self.adjustSize()
 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 )
Beispiel #25
0
    def _GetButtonBox(self):

        buttonbox = QP.HBoxLayout()

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

        return buttonbox
    def __init__(self,
                 parent,
                 message,
                 title='Are you sure?',
                 yes_tuples=None,
                 no_label='no'):

        if yes_tuples is None:

            yes_tuples = [('yes', 'yes')]

        Dialog.__init__(self, parent, title, position='center')

        self._value = None

        yes_buttons = []

        for (label, data) in yes_tuples:

            yes_button = ClientGUICommon.BetterButton(self, label, self._DoYes,
                                                      data)
            yes_button.setObjectName('HydrusAccept')

            yes_buttons.append(yes_button)

        self._no = ClientGUICommon.BetterButton(self, no_label, self.done,
                                                QW.QDialog.Rejected)
        self._no.setObjectName('HydrusCancel')

        #

        hbox = QP.HBoxLayout()

        for yes_button in yes_buttons:

            QP.AddToLayout(hbox, yes_button, CC.FLAGS_CENTER_PERPENDICULAR)

        QP.AddToLayout(hbox, self._no, CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        text = ClientGUICommon.BetterStaticText(self, message)
        text.setWordWrap(True)

        QP.AddToLayout(vbox, text, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 250))

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(yes_buttons[0],
                                             yes_buttons[0].setFocus,
                                             QC.Qt.OtherFocusReason)
Beispiel #27
0
        def __init__(self, parent, rule):

            ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

            self._bandwidth_type = ClientGUICommon.BetterChoice(self)

            self._bandwidth_type.addItem('data', HC.BANDWIDTH_TYPE_DATA)
            self._bandwidth_type.addItem('requests',
                                         HC.BANDWIDTH_TYPE_REQUESTS)

            self._bandwidth_type.currentIndexChanged.connect(
                self._UpdateEnabled)

            self._max_allowed_bytes = BytesControl(self)
            self._max_allowed_requests = QP.MakeQSpinBox(self,
                                                         min=1,
                                                         max=1048576)

            self._time_delta = ClientGUITime.TimeDeltaButton(
                self,
                min=1,
                days=True,
                hours=True,
                minutes=True,
                seconds=True,
                monthly_allowed=True)

            #

            (bandwidth_type, time_delta, max_allowed) = rule

            self._bandwidth_type.SetValue(bandwidth_type)

            self._time_delta.SetValue(time_delta)

            if bandwidth_type == HC.BANDWIDTH_TYPE_DATA:

                self._max_allowed_bytes.SetValue(max_allowed)

            else:

                self._max_allowed_requests.setValue(max_allowed)

            self._UpdateEnabled()

            #

            hbox = QP.HBoxLayout()

            QP.AddToLayout(hbox, self._max_allowed_bytes, CC.FLAGS_VCENTER)
            QP.AddToLayout(hbox, self._max_allowed_requests, CC.FLAGS_VCENTER)
            QP.AddToLayout(hbox, self._bandwidth_type, CC.FLAGS_VCENTER)
            QP.AddToLayout(hbox,
                           ClientGUICommon.BetterStaticText(self, ' every '),
                           CC.FLAGS_VCENTER)
            QP.AddToLayout(hbox, self._time_delta, CC.FLAGS_VCENTER)

            self.widget().setLayout(hbox)
Beispiel #28
0
    def __init__(self, parent):

        title = 'manage local upnp'

        ClientGUIDialogs.Dialog.__init__(self, parent, title)

        self._status_st = ClientGUICommon.BetterStaticText(self)

        listctrl_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._mappings_list_ctrl = ClientGUIListCtrl.BetterListCtrl(
            listctrl_panel,
            CGLC.COLUMN_LIST_MANAGE_UPNP_MAPPINGS.ID,
            12,
            self._ConvertDataToListCtrlTuples,
            delete_key_callback=self._Remove,
            activation_callback=self._Edit)

        listctrl_panel.SetListCtrl(self._mappings_list_ctrl)

        listctrl_panel.AddButton('add custom mapping', self._Add)
        listctrl_panel.AddButton('edit mapping',
                                 self._Edit,
                                 enabled_only_on_selection=True)
        listctrl_panel.AddButton('remove mapping',
                                 self._Remove,
                                 enabled_only_on_selection=True)

        self._ok = QW.QPushButton('ok', self)
        self._ok.clicked.connect(self.EventOK)
        self._ok.setObjectName('HydrusAccept')

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, listctrl_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._ok, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

        size_hint.setWidth(max(size_hint.width(), 760))

        QP.SetInitialSize(self, size_hint)

        #

        self._mappings = []

        self._mappings_list_ctrl.Sort()

        self._started_external_ip_fetch = False

        self._RefreshMappings()
Beispiel #29
0
 def __init__( self, parent ):
     
     QW.QWidget.__init__( self, parent )
     
     self.setWindowFlags( QC.Qt.Tool | QC.Qt.FramelessWindowHint )
     
     self.setAttribute( QC.Qt.WA_ShowWithoutActivating )
     
     self.setSizePolicy( QW.QSizePolicy.MinimumExpanding, QW.QSizePolicy.Preferred )
     
     self._last_best_size_i_fit_on = ( 0, 0 )
     
     self._max_messages_to_display = 10
     
     vbox = QP.VBoxLayout()
     
     self._message_panel = QW.QWidget( self )
     
     self._message_vbox = QP.VBoxLayout( margin = 0 )
     
     vbox.setSizeConstraint( QW.QLayout.SetFixedSize )
     
     self._message_panel.setLayout( self._message_vbox )
     self._message_panel.setSizePolicy( QW.QSizePolicy.MinimumExpanding, QW.QSizePolicy.Preferred )
     
     self._summary_bar = PopupMessageSummaryBar( self, self )
     self._summary_bar.setSizePolicy( QW.QSizePolicy.MinimumExpanding, QW.QSizePolicy.Preferred )
     
     QP.AddToLayout( vbox, self._message_panel )
     QP.AddToLayout( vbox, self._summary_bar )
     
     self.setLayout( vbox )
     
     self._pending_job_keys = []
     
     self._gui_event_filter = QP.WidgetEventFilter( parent )
     self._gui_event_filter.EVT_SIZE( self.EventParentMovedOrResized )
     self._gui_event_filter.EVT_MOVE( self.EventParentMovedOrResized )
     
     HG.client_controller.sub( self, 'AddMessage', 'message' )
     
     self._old_excepthook = sys.excepthook
     self._old_show_exception = HydrusData.ShowException
     
     sys.excepthook = ClientData.CatchExceptionClient
     HydrusData.ShowException = ClientData.ShowExceptionClient
     HydrusData.ShowText = ClientData.ShowTextClient
     
     job_key = ClientThreading.JobKey()
     
     job_key.SetVariable( 'popup_text_1', 'initialising popup message manager\u2026' )
     
     self._update_job = HG.client_controller.CallRepeatingQtSafe( self, 0.25, 0.5, self.REPEATINGUpdate )
     
     HG.client_controller.CallLaterQtSafe(self, 0.5, self.AddMessage, job_key)
     
     HG.client_controller.CallLaterQtSafe(self, 1.0, job_key.Delete)
Beispiel #30
0
 def __init__( self, parent: QW.QWidget ):
     
     QW.QWidget.__init__( self, parent )
     
     self._current_ratings_numerical_service = None
     
     self._flip_or_set_action = ClientGUICommon.BetterChoice( self )
     
     self._flip_or_set_action.addItem( 'set', HC.CONTENT_UPDATE_SET )
     self._flip_or_set_action.addItem( 'flip on and off', HC.CONTENT_UPDATE_FLIP )
     
     self._flip_or_set_action.SetValue( HC.CONTENT_UPDATE_SET )
     
     self._service_keys = ClientGUICommon.BetterChoice( self )
     self._service_keys.currentIndexChanged.connect( self._UpdateSliderRange )
     self._ratings_numerical_slider = QP.LabelledSlider( self )
     self._ratings_numerical_remove = QW.QCheckBox( 'remove rating', self )
     
     #
     
     services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_RATING_NUMERICAL, ) )
     
     if len( services ) == 0:
         
         self._service_keys.addItem( 'you have no numerical rating services', None )
         
     else:
         
         for service in services:
             
             service_name = service.GetName()
             service_key = service.GetServiceKey()
             
             self._service_keys.addItem( service_name, service_key )
             
         
     
     self._UpdateSliderRange()
     
     #
     
     vbox = QP.VBoxLayout()
     
     ratings_numerical_hbox = QP.HBoxLayout()
     
     QP.AddToLayout( ratings_numerical_hbox, self._service_keys, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH )
     QP.AddToLayout( ratings_numerical_hbox, self._ratings_numerical_slider, CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( ratings_numerical_hbox, self._ratings_numerical_remove, CC.FLAGS_CENTER_PERPENDICULAR )
     
     QP.AddToLayout( vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, ratings_numerical_hbox, CC.FLAGS_EXPAND_PERPENDICULAR )
     
     self.setLayout( vbox )
     
     self._ratings_numerical_remove.toggled.connect( self._UpdateFlipAllowed )