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, 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)
Exemple #3
0
    def __init__(self, parent):

        QW.QFrame.__init__(self, parent)

        self.setFrameStyle(QW.QFrame.Box | QW.QFrame.Raised)

        self._network_job = None
        self._download_started = False

        self._auto_override_bandwidth_rules = False

        self._left_text = ClientGUICommon.BetterStaticText(self,
                                                           ellipsize_end=True)
        self._right_text = ClientGUICommon.BetterStaticText(self)
        self._right_text.setAlignment(QC.Qt.AlignRight | QC.Qt.AlignVCenter)

        self._last_right_min_width = 0

        self._gauge = ClientGUICommon.Gauge(self)

        self._cog_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().cog, self._ShowCogMenu)
        self._cancel_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().stop, self.Cancel)

        #

        self._Update()

        #

        st_hbox = QP.HBoxLayout()

        QP.AddToLayout(st_hbox, self._left_text, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(st_hbox, self._right_text,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        left_vbox = QP.VBoxLayout()

        QP.AddToLayout(left_vbox, st_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(left_vbox, self._gauge, CC.FLAGS_EXPAND_BOTH_WAYS)

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, left_vbox, CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        QP.AddToLayout(hbox, self._cog_button, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._cancel_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)
    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, 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: 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 )
Exemple #8
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 )
Exemple #9
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 )
Exemple #10
0
 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 )
    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)
Exemple #12
0
    def __init__(self, parent, controller, page_key=None):

        QW.QFrame.__init__(self, parent)

        self.setFrameStyle(QW.QFrame.Box | QW.QFrame.Raised)

        self._controller = controller
        self._page_key = page_key

        self._file_seed_cache = None

        self._import_summary_st = ClientGUICommon.BetterStaticText(
            self, ellipsize_end=True)
        self._progress_st = ClientGUICommon.BetterStaticText(
            self, ellipsize_end=True)

        self._file_seed_cache_button = FileSeedCacheButton(
            self, self._controller, self._GetFileSeedCache)

        self._progress_gauge = ClientGUICommon.Gauge(self)

        #

        self._Update()

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._progress_st,
                       CC.FLAGS_CENTER_PERPENDICULAR_EXPAND_DEPTH)
        QP.AddToLayout(hbox, self._file_seed_cache_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._import_summary_st,
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, self._progress_gauge,
                       CC.FLAGS_EXPAND_PERPENDICULAR)

        self.setLayout(vbox)

        #

        HG.client_controller.gui.RegisterUIUpdateWindow(self)
Exemple #13
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)
    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)
Exemple #15
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()
 def __init__( self, parent, service_key, tags, expand_parents = True, message = '', show_sibling_text = False ):
     
     Dialog.__init__( self, parent, 'input tags' )
     
     self._service_key = service_key
     
     self._tags = ClientGUIListBoxes.ListBoxTagsStringsAddRemove( self, service_key = service_key, show_sibling_text = show_sibling_text )
     
     self._expand_parents = expand_parents
     
     self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsWrite( self, self.EnterTags, self._expand_parents, 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)
Exemple #17
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 )
     
     columns = [ ( 'description', -1 ), ( 'internal ip', 17 ), ( 'internal port', 7 ), ( 'external port', 7 ), ( 'prototcol', 5 ), ( 'lease', 12 ) ]
     
     self._mappings_list_ctrl = ClientGUIListCtrl.BetterListCtrl( listctrl_panel, 'manage_upnp_mappings', 12, 36, columns, 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_LONE_BUTTON )
     
     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( 0 )
     
     self._started_external_ip_fetch = False
     
     self._RefreshMappings()
Exemple #18
0
 def __init__( self, parent, manager ):
     
     PopupWindow.__init__( self, parent, manager )
     
     hbox = QP.HBoxLayout()
     
     self._text = ClientGUICommon.BetterStaticText( self )
     
     self._expand_collapse = ClientGUICommon.BetterButton( self, '\u25bc', self.ExpandCollapse )
     
     dismiss_all = ClientGUICommon.BetterButton( self, 'dismiss all', self._manager.DismissAll )
     
     QP.AddToLayout( hbox, self._text, CC.FLAGS_VCENTER )
     QP.AddToLayout( hbox, (20,20), CC.FLAGS_EXPAND_BOTH_WAYS )
     QP.AddToLayout( hbox, dismiss_all, CC.FLAGS_VCENTER )
     QP.AddToLayout( hbox, self._expand_collapse, CC.FLAGS_VCENTER )
     
     self.setLayout( hbox )
    def __init__(self, parent, export_folders):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._export_folders_panel = ClientGUIListCtrl.BetterListCtrlPanel(
            self)

        columns = [('name', 20), ('path', -1), ('type', 12), ('query', 16),
                   ('paused', 8), ('period', 16), ('phrase', 20)]

        self._export_folders = ClientGUIListCtrl.BetterListCtrl(
            self._export_folders_panel,
            'export_folders',
            6,
            40,
            columns,
            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(0)

        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)
    def __init__(self, parent):

        ClientGUIScrolledPanels.ReviewPanel.__init__(self, parent)

        self._time_started = HydrusData.GetNow()

        self._api_permissions = None

        self._st = ClientGUICommon.BetterStaticText(
            self, label='waiting for request\u2026')

        vbox = QP.VBoxLayout()

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

        self.widget().setLayout(vbox)

        self._repeating_job = HG.client_controller.CallRepeatingQtSafe(
            self, 0.0, 0.5, self.REPEATINGUpdate)
    def __init__(self, parent):

        QW.QWidget.__init__(self, parent)

        self._mouse_radio = QW.QRadioButton('mouse', self)
        self._mouse_shortcut = MouseShortcutWidget(self)

        self._keyboard_radio = QW.QRadioButton('keyboard', self)
        self._keyboard_shortcut = KeyboardShortcutWidget(self)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(
            vbox,
            ClientGUICommon.BetterStaticText(
                self,
                'Mouse events only work for some windows, mostly media viewer stuff, atm!'
            ), CC.FLAGS_EXPAND_PERPENDICULAR)

        gridbox = QP.GridLayout(cols=2)

        gridbox.setColumnStretch(1, 1)

        QP.AddToLayout(gridbox, self._mouse_radio,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(gridbox, self._mouse_shortcut,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(gridbox, self._keyboard_radio,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(gridbox, self._keyboard_shortcut,
                       CC.FLAGS_EXPAND_BOTH_WAYS)

        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.setLayout(vbox)

        self._mouse_shortcut.valueChanged.connect(self._mouse_radio.click)
        self._keyboard_shortcut.valueChanged.connect(
            self._keyboard_radio.click)
Exemple #22
0
    def __init__(self, parent, manager):

        PopupWindow.__init__(self, parent, manager)

        hbox = QP.HBoxLayout()

        self._text = ClientGUICommon.BetterStaticText(self)

        self._expand_collapse = ClientGUICommon.BetterButton(
            self, '\u25bc', self.ExpandCollapse)

        dismiss_all = ClientGUICommon.BetterButton(self, 'dismiss all',
                                                   self._manager.DismissAll)

        QP.AddToLayout(hbox, self._text, CC.FLAGS_CENTER_PERPENDICULAR)
        hbox.addStretch(1)
        QP.AddToLayout(hbox, dismiss_all, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._expand_collapse,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self.setLayout(hbox)
    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, all_shortcuts):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        help_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().help, self._ShowHelp)
        help_button.setToolTip('Show help regarding editing shortcuts.')

        reserved_panel = ClientGUICommon.StaticBox(
            self, 'built-in hydrus shortcut sets')

        self._reserved_shortcuts = ClientGUIListCtrl.BetterListCtrl(
            reserved_panel,
            CGLC.COLUMN_LIST_SHORTCUT_SETS.ID,
            6,
            data_to_tuples_func=self._GetTuples,
            activation_callback=self._EditReserved)

        self._reserved_shortcuts.setMinimumSize(QC.QSize(320, 200))

        self._edit_reserved_button = ClientGUICommon.BetterButton(
            reserved_panel, 'edit', self._EditReserved)
        self._restore_defaults_button = ClientGUICommon.BetterButton(
            reserved_panel, 'restore defaults', self._RestoreDefaults)

        #

        custom_panel = ClientGUICommon.StaticBox(self, 'custom user sets')

        self._custom_shortcuts = ClientGUIListCtrl.BetterListCtrl(
            custom_panel,
            CGLC.COLUMN_LIST_SHORTCUT_SETS.ID,
            6,
            data_to_tuples_func=self._GetTuples,
            delete_key_callback=self._Delete,
            activation_callback=self._EditCustom)

        self._add_button = ClientGUICommon.BetterButton(
            custom_panel, 'add', self._Add)
        self._edit_custom_button = ClientGUICommon.BetterButton(
            custom_panel, 'edit', self._EditCustom)
        self._delete_button = ClientGUICommon.BetterButton(
            custom_panel, 'delete', self._Delete)

        if not HG.client_controller.new_options.GetBoolean('advanced_mode'):

            custom_panel.hide()

        #

        reserved_shortcuts = [
            shortcuts for shortcuts in all_shortcuts if shortcuts.GetName() in
            ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES
        ]
        custom_shortcuts = [
            shortcuts for shortcuts in all_shortcuts if shortcuts.GetName()
            not in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES
        ]

        self._reserved_shortcuts.AddDatas(reserved_shortcuts)

        self._reserved_shortcuts.Sort()

        self._original_custom_names = set()

        for shortcuts in custom_shortcuts:

            self._custom_shortcuts.AddDatas((shortcuts, ))

            self._original_custom_names.add(shortcuts.GetName())

        self._custom_shortcuts.Sort()

        #

        button_hbox = QP.HBoxLayout()

        QP.AddToLayout(button_hbox, self._edit_reserved_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._restore_defaults_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        reserved_panel.Add(self._reserved_shortcuts,
                           CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        reserved_panel.Add(button_hbox, CC.FLAGS_ON_RIGHT)

        #

        button_hbox = QP.HBoxLayout()

        QP.AddToLayout(button_hbox, self._add_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._edit_custom_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(button_hbox, self._delete_button,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        custom_panel_message = 'Custom shortcuts are advanced. They apply to the media viewer and must be turned on to take effect.'

        st = ClientGUICommon.BetterStaticText(custom_panel,
                                              custom_panel_message)
        st.setWordWrap(True)

        custom_panel.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        custom_panel.Add(self._custom_shortcuts,
                         CC.FLAGS_EXPAND_SIZER_BOTH_WAYS)
        custom_panel.Add(button_hbox, CC.FLAGS_ON_RIGHT)

        #

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, help_button, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, reserved_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, custom_panel, CC.FLAGS_EXPAND_BOTH_WAYS)

        self.widget().setLayout(vbox)
    def __init__(self,
                 parent,
                 share_key,
                 name,
                 text,
                 timeout,
                 hashes,
                 new_share=False):

        Dialog.__init__(self, parent, 'configure local booru share')

        self._name = QW.QLineEdit(self)

        self._text = QW.QPlainTextEdit(self)
        self._text.setMinimumHeight(100)

        message = 'expires in'

        self._timeout_number = ClientGUICommon.NoneableSpinCtrl(
            self,
            message,
            none_phrase='no expiration',
            max=1000000,
            multiplier=1)

        self._timeout_multiplier = ClientGUICommon.BetterChoice(self)
        self._timeout_multiplier.addItem('minutes', 60)
        self._timeout_multiplier.addItem('hours', 60 * 60)
        self._timeout_multiplier.addItem('days', 60 * 60 * 24)

        self._copy_internal_share_link = QW.QPushButton(
            'copy internal share link', self)
        self._copy_internal_share_link.clicked.connect(
            self.EventCopyInternalShareURL)

        self._copy_external_share_link = QW.QPushButton(
            'copy external share link', self)
        self._copy_external_share_link.clicked.connect(
            self.EventCopyExternalShareURL)

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

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

        #

        self._share_key = share_key
        self._name.setText(name)
        self._text.setPlainText(text)

        if timeout is None:

            self._timeout_number.SetValue(None)

            self._timeout_multiplier.SetValue(60)

        else:

            time_left = HydrusData.GetTimeDeltaUntilTime(timeout)

            if time_left < 60 * 60 * 12: time_value = 60
            elif time_left < 60 * 60 * 24 * 7: time_value = 60 * 60
            else: time_value = 60 * 60 * 24

            self._timeout_number.SetValue(time_left // time_value)

            self._timeout_multiplier.SetValue(time_value)

        self._hashes = hashes

        self._service = HG.client_controller.services_manager.GetService(
            CC.LOCAL_BOORU_SERVICE_KEY)

        internal_port = self._service.GetPort()

        if internal_port is None:

            self._copy_internal_share_link.setEnabled(False)
            self._copy_external_share_link.setEnabled(False)

        #

        rows = []

        rows.append(('share name: ', self._name))
        rows.append(('share text: ', self._text))

        gridbox = ClientGUICommon.WrapInGrid(self, rows)

        timeout_box = QP.HBoxLayout()
        QP.AddToLayout(timeout_box, self._timeout_number,
                       CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(timeout_box, self._timeout_multiplier,
                       CC.FLAGS_EXPAND_BOTH_WAYS)

        link_box = QP.HBoxLayout()
        QP.AddToLayout(link_box, self._copy_internal_share_link,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(link_box, self._copy_external_share_link,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        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 = 'Sharing ' + HydrusData.ToHumanInt(len(
            self._hashes)) + ' files.'
        intro += os.linesep + 'Title and text are optional.'

        if new_share:
            intro += os.linesep + 'The link will not work until you ok this dialog.'

        QP.AddToLayout(vbox, ClientGUICommon.BetterStaticText(self, intro),
                       CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, timeout_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        QP.AddToLayout(vbox, link_box, CC.FLAGS_ON_RIGHT)
        QP.AddToLayout(vbox, b_box, CC.FLAGS_ON_RIGHT)

        self.setLayout(vbox)

        size_hint = self.sizeHint()

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

        QP.SetInitialSize(self, size_hint)

        HG.client_controller.CallAfterQtSafe(self._ok, self._ok.setFocus,
                                             QC.Qt.OtherFocusReason)
    def __init__(self, parent, service_key):

        Dialog.__init__(self, parent, 'configure new accounts')

        self._service_key = service_key

        self._num = QP.MakeQSpinBox(self, min=1, max=10000, width=80)

        self._account_types = ClientGUICommon.BetterChoice(self)

        self._lifetime = ClientGUICommon.BetterChoice(self)

        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._num.setValue(1)

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

        response = service.Request(HC.GET, 'account_types')

        account_types = response['account_types']

        for account_type in account_types:

            self._account_types.addItem(account_type.GetTitle(), account_type)

        self._account_types.setCurrentIndex(0)

        for (s, value) in HC.lifetimes:

            self._lifetime.addItem(s, value)

        self._lifetime.setCurrentIndex(3)  # one year

        #

        ctrl_box = QP.HBoxLayout()

        QP.AddToLayout(ctrl_box,
                       ClientGUICommon.BetterStaticText(self, 'generate'),
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ctrl_box, self._num, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ctrl_box, self._account_types,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(
            ctrl_box,
            ClientGUICommon.BetterStaticText(self, 'accounts, to expire in'),
            CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(ctrl_box, self._lifetime, CC.FLAGS_CENTER_PERPENDICULAR)

        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, ctrl_box, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)
        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,
                 message,
                 default='',
                 placeholder=None,
                 allow_blank=False,
                 suggestions=None,
                 max_chars=None,
                 password_entry=False,
                 min_char_width=72):

        if suggestions is None:

            suggestions = []

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

        self._chosen_suggestion = None
        self._allow_blank = allow_blank
        self._max_chars = max_chars

        button_choices = []

        for text in suggestions:

            button_choices.append(
                ClientGUICommon.BetterButton(self, text, self.ButtonChoice,
                                             text))

        self._text = QW.QLineEdit(self)
        self._text.textChanged.connect(self.EventText)
        self._text.installEventFilter(
            ClientGUICommon.TextCatchEnterEventFilter(self._text,
                                                      self.EnterText))

        width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._text, min_char_width)

        self._text.setMinimumWidth(width)

        if password_entry:

            self._text.setEchoMode(QW.QLineEdit.Password)

        if self._max_chars is not None:

            self._text.setMaxLength(self._max_chars)

        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._text.setText(default)

        if placeholder is not None:

            self._text.setPlaceholderText(placeholder)

        if len(default) > 0:

            self._text.setSelection(0, len(default))

        self._CheckText()

        #

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._ok, CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(hbox, self._cancel, CC.FLAGS_CENTER_PERPENDICULAR)

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

        vbox = QP.VBoxLayout()

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

        for button in button_choices:

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

        QP.AddToLayout(vbox, self._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)
    def __init__(self, parent, manager, job_key):

        PopupWindow.__init__(self, parent, manager)

        self.setSizePolicy(QW.QSizePolicy.MinimumExpanding,
                           QW.QSizePolicy.Fixed)

        self._job_key = job_key

        vbox = QP.VBoxLayout()

        self._title = ClientGUICommon.BetterStaticText(self)
        self._title.setAlignment(QC.Qt.AlignHCenter | QC.Qt.AlignVCenter)

        font = self._title.font()
        font.setBold(True)
        self._title.setFont(font)

        popup_message_character_width = HG.client_controller.new_options.GetInteger(
            'popup_message_character_width')

        popup_char_width = ClientGUIFunctions.ConvertTextToPixelWidth(
            self._title, popup_message_character_width)

        if HG.client_controller.new_options.GetBoolean(
                'popup_message_force_min_width'):

            #QP.SetMinClientSize( self, ( wrap_width, -1 ) )
            self.setFixedWidth(popup_char_width)

        else:

            self.setMaximumWidth(popup_char_width)

        self._title.setWordWrap(True)
        self._title_ev = QP.WidgetEventFilter(self._title)
        self._title_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._title.hide()

        self._text_1 = ClientGUICommon.BetterStaticText(self)
        self._text_1.setWordWrap(True)
        self._text_1_ev = QP.WidgetEventFilter(self._text_1)
        self._text_1_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._text_1.hide()

        self._gauge_1 = ClientGUICommon.Gauge(self)
        self._gauge_1_ev = QP.WidgetEventFilter(self._gauge_1)
        self._gauge_1_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._gauge_1.setMinimumWidth(int(popup_char_width * 0.9))
        self._gauge_1.hide()

        self._text_2 = ClientGUICommon.BetterStaticText(self)
        self._text_2.setWordWrap(True)
        self._text_2_ev = QP.WidgetEventFilter(self._text_2)
        self._text_2_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._text_2.hide()

        self._gauge_2 = ClientGUICommon.Gauge(self)
        self._gauge_2_ev = QP.WidgetEventFilter(self._gauge_2)
        self._gauge_2_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._gauge_2.setMinimumWidth(int(popup_char_width * 0.9))
        self._gauge_2.hide()

        self._text_yes_no = ClientGUICommon.BetterStaticText(self)
        self._text_yes_no_ev = QP.WidgetEventFilter(self._text_yes_no)
        self._text_yes_no_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._text_yes_no.hide()

        self._yes = ClientGUICommon.BetterButton(self, 'yes', self._YesButton)
        self._yes.hide()

        self._no = ClientGUICommon.BetterButton(self, 'no', self._NoButton)
        self._no.hide()

        self._network_job_ctrl = ClientGUIControls.NetworkJobControl(self)
        self._network_job_ctrl.hide()

        self._copy_to_clipboard_button = ClientGUICommon.BetterButton(
            self, 'copy to clipboard', self.CopyToClipboard)
        self._copy_to_clipboard_button_ev = QP.WidgetEventFilter(
            self._copy_to_clipboard_button)
        self._copy_to_clipboard_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._copy_to_clipboard_button.hide()

        self._show_files_button = ClientGUICommon.BetterButton(
            self, 'show files', self.ShowFiles)
        self._show_files_button_ev = QP.WidgetEventFilter(
            self._show_files_button)
        self._show_files_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._show_files_button.hide()

        self._show_tb_button = ClientGUICommon.BetterButton(
            self, 'show traceback', self.ShowTB)
        self._show_tb_button_ev = QP.WidgetEventFilter(self._show_tb_button)
        self._show_tb_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._show_tb_button.hide()

        self._tb_text = ClientGUICommon.BetterStaticText(self)
        self._tb_text_ev = QP.WidgetEventFilter(self._tb_text)
        self._tb_text_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._tb_text.setWordWrap(True)
        self._tb_text.hide()

        self._copy_tb_button = ClientGUICommon.BetterButton(
            self, 'copy traceback information', self.CopyTB)
        self._copy_tb_button_ev = QP.WidgetEventFilter(self._copy_tb_button)
        self._copy_tb_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._copy_tb_button.hide()

        self._pause_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().pause, self.PausePlay)
        self._pause_button_ev = QP.WidgetEventFilter(self._pause_button)
        self._pause_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._pause_button.hide()

        self._cancel_button = ClientGUICommon.BetterBitmapButton(
            self,
            CC.global_pixmaps().stop, self.Cancel)
        self._cancel_button_ev = QP.WidgetEventFilter(self._cancel_button)
        self._cancel_button_ev.EVT_RIGHT_DOWN(self.EventDismiss)
        self._cancel_button.hide()

        hbox = QP.HBoxLayout()

        QP.AddToLayout(hbox, self._pause_button, CC.FLAGS_VCENTER)
        QP.AddToLayout(hbox, self._cancel_button, CC.FLAGS_VCENTER)

        yes_no_hbox = QP.HBoxLayout()

        QP.AddToLayout(yes_no_hbox, self._yes, CC.FLAGS_VCENTER)
        QP.AddToLayout(yes_no_hbox, self._no, CC.FLAGS_VCENTER)

        QP.AddToLayout(vbox, self._title, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._text_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._gauge_1, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._text_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._gauge_2, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._text_yes_no, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, yes_no_hbox)
        QP.AddToLayout(vbox, self._network_job_ctrl)
        QP.AddToLayout(vbox, self._copy_to_clipboard_button)
        QP.AddToLayout(vbox, self._show_files_button)
        QP.AddToLayout(vbox, self._show_tb_button)
        QP.AddToLayout(vbox, self._tb_text)
        QP.AddToLayout(vbox, self._copy_tb_button)
        QP.AddToLayout(vbox, hbox, CC.FLAGS_BUTTON_SIZER)

        self.setLayout(vbox)
    def __init__(self, parent, shortcuts: ClientGUIShortcuts.ShortcutSet):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._name = QW.QLineEdit(self)

        self._shortcuts_panel = ClientGUIListCtrl.BetterListCtrlPanel(self)

        self._shortcuts = ClientGUIListCtrl.BetterListCtrl(
            self._shortcuts_panel,
            CGLC.COLUMN_LIST_SHORTCUTS.ID,
            20,
            data_to_tuples_func=self._ConvertSortTupleToPrettyTuple,
            delete_key_callback=self.RemoveShortcuts,
            activation_callback=self.EditShortcuts)

        self._shortcuts_panel.SetListCtrl(self._shortcuts)

        self._shortcuts_panel.AddImportExportButtons(
            (ClientGUIShortcuts.ShortcutSet, ),
            self._AddShortcutSet,
            custom_get_callable=self._GetSelectedShortcutSet)

        self._shortcuts.setMinimumSize(QC.QSize(360, 480))

        self._add = QW.QPushButton('add', self)
        self._add.clicked.connect(self.AddShortcut)

        self._edit = QW.QPushButton('edit', self)
        self._edit.clicked.connect(self.EditShortcuts)

        self._remove = QW.QPushButton('remove', self)
        self._remove.clicked.connect(self.RemoveShortcuts)

        #

        name = shortcuts.GetName()

        self._name.setText(name)

        self._this_is_custom = True

        if name in ClientGUIShortcuts.SHORTCUTS_RESERVED_NAMES:

            self._this_is_custom = False

            self._name.setEnabled(False)

        self._shortcuts.AddDatas(shortcuts)

        self._shortcuts.Sort()

        #

        action_buttons = QP.HBoxLayout()

        QP.AddToLayout(action_buttons, self._add,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._edit,
                       CC.FLAGS_CENTER_PERPENDICULAR)
        QP.AddToLayout(action_buttons, self._remove,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox,
                       ClientGUICommon.WrapInText(self._name, self, 'name: '),
                       CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        if name in ClientGUIShortcuts.shortcut_names_to_descriptions:

            description_text = ClientGUIShortcuts.shortcut_names_to_descriptions[
                name]

            description = ClientGUICommon.BetterStaticText(
                self, description_text, description_text)

            description.setWordWrap(True)

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

        QP.AddToLayout(vbox, self._shortcuts_panel, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, action_buttons, CC.FLAGS_ON_RIGHT)

        self.widget().setLayout(vbox)
Exemple #30
0
    def __init__(self, parent, export_folder: ClientExporting.ExportFolder):

        ClientGUIScrolledPanels.EditPanel.__init__(self, parent)

        self._export_folder = export_folder

        (name, path, export_type, delete_from_client_after_export,
         file_search_context, run_regularly, period, phrase,
         self._last_checked, paused, run_now) = self._export_folder.ToTuple()

        self._path_box = ClientGUICommon.StaticBox(self, 'name and location')

        self._name = QW.QLineEdit(self._path_box)

        self._path = QP.DirPickerCtrl(self._path_box)

        #

        self._type_box = ClientGUICommon.StaticBox(self, 'type of export')

        self._type = ClientGUICommon.BetterChoice(self._type_box)
        self._type.addItem('regular', HC.EXPORT_FOLDER_TYPE_REGULAR)
        self._type.addItem('synchronise', HC.EXPORT_FOLDER_TYPE_SYNCHRONISE)

        self._delete_from_client_after_export = QW.QCheckBox(self._type_box)

        #

        self._query_box = ClientGUICommon.StaticBox(self, 'query to export')

        self._page_key = 'export folders placeholder'

        self._tag_autocomplete = ClientGUIACDropdown.AutoCompleteDropdownTagsRead(
            self._query_box,
            self._page_key,
            file_search_context,
            allow_all_known_files=False,
            force_system_everything=True)

        #

        self._period_box = ClientGUICommon.StaticBox(self, 'export period')

        self._period = ClientGUITime.TimeDeltaButton(self._period_box,
                                                     min=3 * 60,
                                                     days=True,
                                                     hours=True,
                                                     minutes=True)

        self._run_regularly = QW.QCheckBox(self._period_box)

        self._paused = QW.QCheckBox(self._period_box)

        self._run_now = QW.QCheckBox(self._period_box)

        #

        self._phrase_box = ClientGUICommon.StaticBox(self, 'filenames')

        self._pattern = QW.QLineEdit(self._phrase_box)

        self._examples = ClientGUICommon.ExportPatternButton(self._phrase_box)

        #

        self._name.setText(name)

        self._path.SetPath(path)

        self._type.SetValue(export_type)

        self._delete_from_client_after_export.setChecked(
            delete_from_client_after_export)

        self._period.SetValue(period)

        self._run_regularly.setChecked(run_regularly)

        self._paused.setChecked(paused)

        self._run_now.setChecked(run_now)

        self._pattern.setText(phrase)

        #

        rows = []

        rows.append(('name: ', self._name))
        rows.append(('folder path: ', self._path))

        gridbox = ClientGUICommon.WrapInGrid(self._path_box, rows)

        self._path_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        #

        text = '''regular - try to export the files to the directory, overwriting if the filesize if different

synchronise - try to export the files to the directory, overwriting if the filesize if different, and delete anything else in the directory

If you select synchronise, be careful!'''

        st = ClientGUICommon.BetterStaticText(self._type_box, label=text)
        st.setWordWrap(True)

        self._type_box.Add(st, CC.FLAGS_EXPAND_PERPENDICULAR)
        self._type_box.Add(self._type, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('delete files from client after export: ',
                     self._delete_from_client_after_export))

        gridbox = ClientGUICommon.WrapInGrid(self._type_box, rows)

        self._type_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        self._query_box.Add(self._tag_autocomplete)

        self._period_box.Add(self._period, CC.FLAGS_EXPAND_PERPENDICULAR)

        rows = []

        rows.append(('run regularly?: ', self._run_regularly))
        rows.append(('paused: ', self._paused))
        rows.append(('run on dialog ok: ', self._run_now))

        gridbox = ClientGUICommon.WrapInGrid(self._period_box, rows)

        self._period_box.Add(gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        phrase_hbox = QP.HBoxLayout()

        QP.AddToLayout(phrase_hbox, self._pattern, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(phrase_hbox, self._examples,
                       CC.FLAGS_CENTER_PERPENDICULAR)

        self._phrase_box.Add(phrase_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR)

        vbox = QP.VBoxLayout()

        QP.AddToLayout(vbox, self._path_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._type_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._query_box, CC.FLAGS_EXPAND_BOTH_WAYS)
        QP.AddToLayout(vbox, self._period_box, CC.FLAGS_EXPAND_PERPENDICULAR)
        QP.AddToLayout(vbox, self._phrase_box, CC.FLAGS_EXPAND_PERPENDICULAR)

        self.widget().setLayout(vbox)

        self._UpdateTypeDeleteUI()

        self._type.currentIndexChanged.connect(self._UpdateTypeDeleteUI)
        self._delete_from_client_after_export.clicked.connect(
            self.EventDeleteFilesAfterExport)