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: QW.QWidget, service_type: int, account_type: HydrusNetwork.AccountType ): ClientGUIScrolledPanels.EditPanel.__init__( self, parent ) self._account_type_key = account_type.GetAccountTypeKey() title = account_type.GetTitle() permissions = account_type.GetPermissions() bandwidth_rules = account_type.GetBandwidthRules() auto_create_velocity = account_type.GetAutoCreateAccountVelocity() self._auto_create_history = account_type.GetAutoCreateAccountHistory() self._title = QW.QLineEdit( self ) permission_choices = self._GeneratePermissionChoices( service_type ) self._permission_controls = [] self._permissions_panel = ClientGUICommon.StaticBox( self, 'permissions' ) gridbox_rows = [] for ( content_type, action_rows ) in permission_choices: choice_control = ClientGUICommon.BetterChoice( self._permissions_panel ) for ( label, action ) in action_rows: choice_control.addItem( label, (content_type, action) ) if content_type in permissions: selection_row = ( content_type, permissions[ content_type ] ) else: selection_row = ( content_type, None ) try: choice_control.SetValue( selection_row ) except: choice_control.SetValue( ( content_type, None ) ) self._permission_controls.append( choice_control ) gridbox_label = HC.content_type_string_lookup[ content_type ] gridbox_rows.append( ( gridbox_label, choice_control ) ) gridbox = ClientGUICommon.WrapInGrid( self._permissions_panel, gridbox_rows ) self._bandwidth_rules_control = ClientGUIControls.BandwidthRulesCtrl( self, bandwidth_rules ) self._auto_creation_box = ClientGUICommon.StaticBox( self, 'automatic account creation' ) min_unit_value = 0 max_unit_value = 65565 min_time_delta = 60 * 60 self._auto_create_velocity_control = ClientGUITime.VelocityCtrl( self._auto_creation_box, min_unit_value, max_unit_value, min_time_delta, days = True, hours = True, unit = 'accounts' ) self._auto_create_history_st = ClientGUICommon.BetterStaticText( self._auto_creation_box, label = 'initialising' ) # self._title.setText( title ) self._auto_create_velocity_control.SetValue( auto_create_velocity ) # intro = 'If you wish, you can allow new users to create their own accounts. They will be limited to a certain number over a particular time.' intro += os.linesep * 2 intro += 'Set to 0 to disable auto-creation.' st = ClientGUICommon.BetterStaticText( self._auto_creation_box, label = intro ) st.setWordWrap( True ) self._auto_creation_box.Add( st, CC.FLAGS_EXPAND_PERPENDICULAR ) self._auto_creation_box.Add( self._auto_create_history_st, CC.FLAGS_EXPAND_PERPENDICULAR ) self._auto_creation_box.Add( self._auto_create_velocity_control, CC.FLAGS_EXPAND_PERPENDICULAR ) t_hbox = ClientGUICommon.WrapInText( self._title, self, 'title: ' ) self._permissions_panel.Add( gridbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) vbox = QP.VBoxLayout() QP.AddToLayout( vbox, t_hbox, CC.FLAGS_EXPAND_SIZER_PERPENDICULAR ) QP.AddToLayout( vbox, self._permissions_panel, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._bandwidth_rules_control, CC.FLAGS_EXPAND_PERPENDICULAR ) QP.AddToLayout( vbox, self._auto_creation_box, CC.FLAGS_EXPAND_PERPENDICULAR ) self.widget().setLayout( vbox ) # self._UpdateAutoCreationHistoryText() self._auto_create_velocity_control.velocityChanged.connect( self._UpdateAutoCreationHistoryText )
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)