def __init__( self, parent, tag_filter: HydrusTags.TagFilter, tag_display_type: int ):
     
     ClientGUIScrolledPanels.EditPanel.__init__( self, parent )
     
     #
     
     message = 'Filter the tags you want to export here. Anything that passes this filter is exported.'
     
     self._tag_filter = ClientGUITags.TagFilterButton( self, message, tag_filter )
     
     self._tag_display_type = ClientGUICommon.BetterChoice( self )
     
     self._tag_display_type.addItem( 'with siblings and parents applied', ClientTags.TAG_DISPLAY_ACTUAL )
     self._tag_display_type.addItem( 'as the tags are actually stored', ClientTags.TAG_DISPLAY_STORAGE )
     
     #
     
     self._tag_display_type.SetValue( tag_display_type )
     
     #
     
     vbox = QP.VBoxLayout()
     
     rows = []
     
     rows.append( ( 'Tags to export: ', self._tag_filter ) )
     rows.append( ( 'Type to export: ', self._tag_display_type ) )
     
     gridbox = ClientGUICommon.WrapInGrid( self, rows )
     
     QP.AddToLayout( vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     self.widget().setLayout( vbox )
Example #2
0
 def __init__( self, parent, label ):
     
     ClientGUIScrolledPanels.ResizingScrolledPanel.__init__( self, parent )
     
     self._commit = ClientGUICommon.BetterButton( self, 'commit', self.parentWidget().done, QW.QDialog.Accepted )
     self._commit.setObjectName( 'HydrusAccept' )
     
     self._forget = ClientGUICommon.BetterButton( self, 'forget', self.parentWidget().done, QW.QDialog.Rejected )
     self._forget.setObjectName( 'HydrusCancel' )
     
     def cancel_callback( parent ):
         
         parent.SetCancelled( True )
         parent.done( QW.QDialog.Rejected )
         
     
     self._back = ClientGUICommon.BetterButton( self, 'back to filtering', cancel_callback, parent )
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._commit, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, self._forget, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     vbox = QP.VBoxLayout()
     
     QP.AddToLayout( vbox, QP.MakeQLabelWithAlignment( label, self, QC.Qt.AlignVCenter | QC.Qt.AlignHCenter ), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, hbox, 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 )
     
     ClientGUIFunctions.SetFocusLater( self._commit )
    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, 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)
Example #5
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):

        QW.QWidget.__init__(self, parent)

        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._ratings_like_like = QW.QRadioButton('like', self)
        self._ratings_like_dislike = QW.QRadioButton('dislike', self)
        self._ratings_like_remove = QW.QRadioButton('remove rating', self)

        #

        services = HG.client_controller.services_manager.GetServices(
            (HC.LOCAL_RATING_LIKE, ))

        if len(services) == 0:

            self._service_keys.addItem(
                'you have no like/dislike 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._ratings_like_like.setChecked(True)

        #

        vbox = QP.VBoxLayout()

        ratings_like_hbox = QP.HBoxLayout()

        QP.AddToLayout(ratings_like_hbox, self._service_keys,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(ratings_like_hbox, self._ratings_like_like,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ratings_like_hbox, self._ratings_like_dislike,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ratings_like_hbox, self._ratings_like_remove,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        QP.AddToLayout(vbox, self._flip_or_set_action,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, ratings_like_hbox, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.setLayout(vbox)

        self._ratings_like_remove.toggled.connect(self._UpdateFlipAllowed)
    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)
Example #8
0
 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 = ClientGUICommon.BetterSpinBox( 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 )
     
     self._num.valueChanged.connect( self.velocityChanged )
     self._times.timeDeltaChanged.connect( self.velocityChanged )
    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)
    def __init__(self, parent: QW.QWidget, service_key: bytes,
                 account_identifiers: typing.Collection[
                     HydrusNetwork.AccountIdentifier]):

        QW.QWidget.__init__(self, parent)

        self._service_key = service_key
        self._service = HG.client_controller.services_manager.GetService(
            self._service_key)
        self._account_identifiers = account_identifiers

        self._done_first_fetch = False
        self._accounts_loaded = False
        self._account_keys_to_accounts = {}
        self._account_keys_to_account_info = {}

        self._accounts_box = ClientGUICommon.StaticBox(self, 'accounts')

        self._status_st = ClientGUICommon.BetterStaticText(self._accounts_box)

        self._account_list = ClientGUICommon.BetterCheckBoxList(
            self._accounts_box)
        self._account_list.setSelectionMode(
            QW.QAbstractItemView.SingleSelection)

        (min_width, min_height) = ClientGUIFunctions.ConvertTextToPixels(
            self._account_list, (74, 6))

        self._account_list.setMinimumSize(min_width, min_height)

        self._account_info_box = QW.QTextEdit(self._accounts_box)
        self._account_info_box.setReadOnly(True)

        (min_width, min_height) = ClientGUIFunctions.ConvertTextToPixels(
            self._account_info_box, (16, 8))

        self._account_info_box.setMinimumHeight(min_height)

        self._copy_checked_account_keys_button = ClientGUICommon.BetterButton(
            self._accounts_box, 'copy checked account ids',
            self._CopyCheckedAccountKeys)

        #

        self._accounts_box.Add(self._status_st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._accounts_box.Add(self._account_list, CC.FLAGS_EXPAND_BOTH_WAYS)
        self._accounts_box.Add(self._account_info_box,
                               CC.FLAGS_EXPAND_BOTH_WAYS)
        self._accounts_box.Add(self._copy_checked_account_keys_button,
                               CC.FLAGS_EXPAND_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._accounts_box, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        #

        self._account_list.itemClicked.connect(self._AccountClicked)
Example #11
0
 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)
Example #12
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 )
Example #13
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 )
Example #14
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,
                 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)
Example #16
0
 def __init__( self, parent: QW.QWidget ):
     
     QW.QWidget.__init__( self, parent )
     
     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._tag_value = QW.QLineEdit( self )
     self._tag_value.setReadOnly( True )
     
     default_location_context = HG.client_controller.new_options.GetDefaultLocalLocationContext()
     
     self._tag_input = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.SetTags, default_location_context, CC.COMBINED_TAG_SERVICE_KEY )
     
     #
     
     services = HG.client_controller.services_manager.GetServices( ( HC.LOCAL_TAG, HC.TAG_REPOSITORY ) )
     
     for service in services:
         
         service_name = service.GetName()
         service_key = service.GetServiceKey()
         
         self._service_keys.addItem( service_name, service_key )
         
     
     self._tag_input.SetTagServiceKey( self._service_keys.GetValue() )
     
     #
     
     vbox = QP.VBoxLayout()
     
     tag_sub_vbox = QP.VBoxLayout()
     
     QP.AddToLayout( tag_sub_vbox, self._tag_value, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( tag_sub_vbox, self._tag_input, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
     
     tag_hbox = QP.HBoxLayout()
     
     QP.AddToLayout( tag_hbox, self._service_keys, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH )
     QP.AddToLayout( tag_hbox, tag_sub_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS )
     
     QP.AddToLayout( vbox, self._flip_or_set_action, CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, tag_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     
     self.setLayout( vbox )
     
     #
     
     self._service_keys.currentIndexChanged.connect( self._NewServiceKey )
Example #17
0
 def __init__( self, parent, namespace = '', regex = '' ):
     
     Dialog.__init__( self, parent, 'configure quick namespace' )
     
     self._namespace = QW.QLineEdit( self )
     
     self._regex = QW.QLineEdit( self )
     
     self._shortcuts = ClientGUICommon.RegexButton( self )
     
     self._regex_intro_link = ClientGUICommon.BetterHyperLink( self, 'a good regex introduction', 'https://www.aivosto.com/vbtips/regex.html' )
     self._regex_practise_link = ClientGUICommon.BetterHyperLink( self, 'regex practice', 'https://regexr.com/3cvmf' )
     
     self._ok = QW.QPushButton( 'OK', self )
     self._ok.clicked.connect( self.EventOK )
     self._ok.setObjectName( 'HydrusAccept' )
     
     self._cancel = QW.QPushButton( 'Cancel', self )
     self._cancel.clicked.connect( self.reject )
     self._cancel.setObjectName( 'HydrusCancel' )
     
     #
 
     self._namespace.setText( namespace )
     self._regex.setText( regex )
     
     #
     
     control_box = QP.HBoxLayout()
     
     QP.AddToLayout( control_box, self._namespace, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( control_box, ClientGUICommon.BetterStaticText(self,':'), CC.FLAGS_CENTER_PERPENDICULAR )
     QP.AddToLayout( control_box, self._regex, CC.FLAGS_EXPAND_BOTH_WAYS )
     
     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()
     
     intro = r'Put the namespace (e.g. page) on the left.' + os.linesep + r'Put the regex (e.g. [1-9]+\d*(?=.{4}$)) on the right.' + os.linesep + r'All files will be tagged with "namespace:regex".'
     
     QP.AddToLayout( vbox, ClientGUICommon.BetterStaticText(self,intro), CC.FLAGS_EXPAND_PERPENDICULAR )
     QP.AddToLayout( vbox, control_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR )
     QP.AddToLayout( vbox, self._shortcuts, CC.FLAGS_ON_RIGHT )
     QP.AddToLayout( vbox, self._regex_intro_link, CC.FLAGS_ON_RIGHT )
     QP.AddToLayout( vbox, self._regex_practise_link, CC.FLAGS_ON_RIGHT )
     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)
Example #18
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 )
Example #19
0
 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 = ClientGUICommon.BetterSpinBox( 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 = ClientGUICommon.BetterSpinBox( 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 = ClientGUICommon.BetterSpinBox( 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 = ClientGUICommon.BetterSpinBox( 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 )
Example #20
0
 def __init__( self, parent, service_key, tag_display_type, tags, message = '' ):
     
     Dialog.__init__( self, parent, 'input tags' )
     
     self._service_key = service_key
     
     self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove( self, service_key, tag_display_type )
     
     self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.EnterTags, CC.LOCAL_FILE_SERVICE_KEY, service_key, null_entry_callable = self.OK, show_paste_button = True )
     
     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._tags.SetTags( tags )
     
     #
     
     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()
     
     if message != '':
         
         st = ClientGUICommon.BetterStaticText( self, message )
         
         st.setWordWrap( True )
         
         QP.AddToLayout( vbox, st, CC.FLAGS_EXPAND_PERPENDICULAR )
         
     
     QP.AddToLayout( vbox, self._tags, CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( vbox, self._tag_autocomplete )
     QP.AddToLayout( vbox, b_box, CC.FLAGS_ON_RIGHT )
     
     self.setLayout( vbox )
     
     size_hint = self.sizeHint()
     
     size_hint.setWidth( max( size_hint.width(), 300 ) )
     
     QP.SetInitialSize( self, size_hint )
     
     HG.client_controller.CallAfterQtSafe( self._tag_autocomplete, self._tag_autocomplete.setFocus, QC.Qt.OtherFocusReason)
    def __init__(self, parent, controller, frame_splash_status):

        QW.QWidget.__init__(self, parent)

        self._controller = controller

        self._my_status = frame_splash_status

        self._my_status.SetWindow(self)

        width = ClientGUIFunctions.ConvertTextToPixelWidth(self, 64)

        self.setMinimumWidth(width)

        self.setMaximumWidth(width * 2)

        self._drag_last_pos = None
        self._initial_position = self.parentWidget().pos()

        # this is 124 x 166
        self._hydrus_pixmap = QG.QPixmap(
            os.path.join(HC.STATIC_DIR, 'hydrus_splash.png'))

        self._image_label = QW.QLabel(self)

        self._image_label.setPixmap(self._hydrus_pixmap)

        self._image_label.setAlignment(QC.Qt.AlignCenter)

        self._title_label = ClientGUICommon.BetterStaticText(self, label=' ')
        self._status_label = ClientGUICommon.BetterStaticText(self, label=' ')
        self._status_sub_label = ClientGUICommon.BetterStaticText(self,
                                                                  label=' ')

        self._title_label.setAlignment(QC.Qt.AlignCenter)
        self._status_label.setAlignment(QC.Qt.AlignCenter)
        self._status_sub_label.setAlignment(QC.Qt.AlignCenter)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._image_label, CC.FLAGS_CENTER)
        QP.AddToLayout(vbox, self._title_label, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._status_label, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._status_sub_label,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        margin = ClientGUIFunctions.ConvertTextToPixelWidth(self, 3)

        self._image_label.setMargin(margin)

        self.setLayout(vbox)
    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._script_choice = ClientGUICommon.BetterChoice(self)

        self._script_choice.setEnabled(False)

        self._have_fetched = False

        self._fetch_button = ClientGUICommon.BetterButton(
            self, 'fetch tags', self.FetchTags)

        self._fetch_button.setEnabled(False)

        self._script_management = ClientGUIParsing.ScriptManagementControl(
            self)

        self._tags = ListBoxTagsSuggestionsFavourites(self,
                                                      self._service_key,
                                                      activate_callable,
                                                      sort_tags=True)

        self._add_all = ClientGUICommon.BetterButton(self, 'add all',
                                                     self._tags.ActivateAll)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._script_choice,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._fetch_button, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._script_management,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._add_all, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._tags, CC.FLAGS_EXPAND_BOTH_WAYS)

        self._SetTags([])

        self.setLayout(vbox)

        self._FetchScripts()

        self._tags.mouseActivationOccurred.connect(
            self.mouseActivationOccurred)
    def __init__(self, parent: QW.QWidget, shortcuts_name: str):

        QW.QWidget.__init__(self, parent)

        if shortcuts_name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            simple_types = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[
                shortcuts_name]

        else:

            simple_types = ClientGUIShortcuts.simple_shortcut_name_to_action_lookup[
                'custom']

        choices = sorted([(CAC.simple_enum_to_str_lookup[simple_type],
                           simple_type) for simple_type in simple_types])

        self._simple_actions = ClientGUICommon.BetterChoice(self)

        for (display_string, data) in choices:

            self._simple_actions.addItem(display_string, data)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._simple_actions,
                       CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)

        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, 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, 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)
Example #27
0
 def _GetCheckManager( self, value_index ):
     
     # in a sub-call so lambda works
     
     check_manager = ClientGUICommon.CheckboxManagerCalls( lambda: self._SetValueIndex( value_index ), lambda: self._value_index == value_index )
     
     return check_manager
Example #28
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)
Example #29
0
        def __init__(self, parent: QW.QWidget, dictionary):

            ClientGUICommon.StaticBox.__init__(self, parent, 'file repository')

            self._log_uploader_ips = QW.QCheckBox(self)
            self._max_storage = ClientGUIControls.NoneableBytesControl(
                self, initial_value=5 * 1024 * 1024 * 1024)

            #

            log_uploader_ips = dictionary['log_uploader_ips']
            max_storage = dictionary['max_storage']

            self._log_uploader_ips.setChecked(log_uploader_ips)
            self._max_storage.SetValue(max_storage)

            #

            rows = []

            rows.append(
                ('log file uploader IP addresses?: ', self._log_uploader_ips))
            rows.append(('max file storage: ', self._max_storage))

            gridbox = ClientGUICommon.WrapInGrid(self, rows)

            self.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
Example #30
0
 def __init__( self, parent, controller, read_only, can_generate_more_pages, gallery_type_string, 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_type_string = gallery_type_string
     
     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, gallery_type_string, self._GetGallerySeedLog )
     
     #
     
     self._Update()
     
     #
     
     hbox = QP.HBoxLayout()
     
     QP.AddToLayout( hbox, self._log_summary_st, CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH )
     QP.AddToLayout( hbox, self._gallery_seed_log_button, CC.FLAGS_CENTER_PERPENDICULAR )
     
     self.setLayout( hbox )
     
     #
     
     HG.client_controller.gui.RegisterUIUpdateWindow( self )