📄 abcoption.py
字号:
Read = self.utility.config.Read
self.dir.SetValue(Read('defaultfolder'))
self.torrentbackup.SetValue(Read('removetorrent', "boolean"))
self.defaultdir.SetValue(Read('setdefaultfolder', "boolean"))
self.movecompleted.SetValue(Read('movecompleted', "boolean"))
self.movedir.SetValue(Read('defaultmovedir'))
diskfullthreshold = Read('diskfullthreshold', "int")
if diskfullthreshold > 0:
self.diskfullcheckbox.SetValue(True)
self.diskfullthreshold.SetValue(diskfullthreshold)
# self.forcenewdir.SetValue(Read('forcenewdir', "boolean"))
def apply(self):
self.utility.config.Write('removetorrent', self.torrentbackup.GetValue(), "boolean")
self.utility.config.Write('setdefaultfolder', self.defaultdir.GetValue(), "boolean")
self.utility.config.Write('defaultfolder', self.dir.GetValue())
self.utility.config.Write('movecompleted', self.movecompleted.GetValue(), "boolean")
self.utility.config.Write('defaultmovedir', self.movedir.GetValue())
if self.diskfullcheckbox.GetValue():
diskfullthreshold = self.diskfullthreshold.GetValue()
else:
diskfullthreshold = 0
self.utility.config.Write('diskfullthreshold', diskfullthreshold)
# self.utility.config.Write('forcenewdir', self.forcenewdir.GetValue(), "boolean")
def onBrowseMoveDir(self, event = None):
dlg = wx.DirDialog(self.utility.frame,
self.utility.lang.get('choosemovedir'),
style = wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
if dlg.ShowModal() == wx.ID_OK:
self.movedir.SetValue(dlg.GetPath())
dlg.Destroy()
def onBrowseDir(self, event = None):
dlg = wx.DirDialog(self.utility.frame,
self.utility.lang.get('choosedefaultdownloadfolder'),
style = wx.DD_DEFAULT_STYLE | wx.DD_NEW_DIR_BUTTON)
if dlg.ShowModal() == wx.ID_OK:
self.dir.SetValue(dlg.GetPath())
dlg.Destroy()
################################################################
#
# Class: SchedulerRulePanel
#
# Contains settings related to timeouts
#
################################################################
class SchedulerRulePanel(ABCOptionPanel):
def __init__(self, parent, dialog):
ABCOptionPanel.__init__(self, parent, dialog)
sizer = self.sizer
# GUI dialog for Global upload setting
########################################
sizer.Add(wx.StaticText(self, -1, self.utility.lang.get('setrule')), 0, wx.ALL, 5)
# Timeout for contacting tracker
tracker_val = ['oo', '5', '10', '15', '30', '45', '60', '120', '180'] #minute
self.cb_tracker = wx.ComboBox(self, -1, "", wx.Point(-1, -1),
wx.Size(48, -1), tracker_val, wx.CB_DROPDOWN|wx.CB_READONLY)
tracker_box = wx.BoxSizer(wx.HORIZONTAL)
tracker_box.Add(wx.StaticText(self, -1, self.utility.lang.get('timeout_tracker')), 0, wx.ALIGN_CENTER_VERTICAL)
tracker_box.Add(self.cb_tracker, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
tracker_box.Add(wx.StaticText(self, -1, self.utility.lang.get('minute_long')), 0, wx.ALIGN_CENTER_VERTICAL)
sizer.Add(tracker_box, 0, wx.ALL, 5)
# Timeout for downloading
download_val = ['oo', '10', '20', '30', '60', '90', '120', '150', '180', '210', '240'] #minute
self.cb_download = wx.ComboBox(self, -1, "", wx.Point(-1, -1),
wx.Size(48, -1), download_val, wx.CB_DROPDOWN|wx.CB_READONLY)
download_box = wx.BoxSizer(wx.HORIZONTAL)
download_box.Add(wx.StaticText(self, -1, self.utility.lang.get('timeout_download')), 0, wx.ALIGN_CENTER_VERTICAL)
download_box.Add(self.cb_download, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
download_box.Add(wx.StaticText(self, -1, self.utility.lang.get('minute_long')), 0, wx.ALIGN_CENTER_VERTICAL)
sizer.Add(download_box, 0, wx.ALL, 5)
# Timeout for seeding
upload_val = ['oo', '0.5', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'] #hour
self.cb_upload = wx.ComboBox(self, -1, "", wx.Point(-1, -1),
wx.Size(48, -1), upload_val, wx.CB_DROPDOWN|wx.CB_READONLY)
upload_box = wx.BoxSizer(wx.HORIZONTAL)
upload_box.Add(wx.StaticText(self, -1, self.utility.lang.get('timeout_upload')), 0, wx.ALIGN_CENTER_VERTICAL)
upload_box.Add(self.cb_upload, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
upload_box.Add(wx.StaticText(self, -1, self.utility.lang.get('hour_long')), 0, wx.ALIGN_CENTER_VERTICAL)
sizer.Add(upload_box, 0, wx.ALL, 5)
self.initTasks()
def loadValues(self, Read = None):
if Read is None:
Read = self.utility.config.Read
self.cb_tracker.SetStringSelection(Read('timeouttracker'))
self.cb_download.SetStringSelection(Read('timeoutdownload'))
self.cb_upload.SetStringSelection(Read('timeoutupload'))
def apply(self):
# Set values for timeouts
self.utility.config.Write('timeouttracker', self.cb_tracker.GetValue())
self.utility.config.Write('timeoutdownload', self.cb_download.GetValue())
self.utility.config.Write('timeoutupload', self.cb_upload.GetValue())
################################################################
#
# Class: RateLimitPanel
#
# Contains settings related to setting limits on upload and
# download rates
#
################################################################
class RateLimitPanel(ABCOptionPanel):
def __init__(self, parent, dialog):
ABCOptionPanel.__init__(self, parent, dialog)
sizer = self.sizer
# GUI dialog for Global upload setting
########################################
# Upload settings
########################################
uploadsection_title = wx.StaticBox(self, -1, self.utility.lang.get('uploadsetting'))
uploadsection = wx.StaticBoxSizer(uploadsection_title, wx.VERTICAL)
self.maxupload = wx.SpinCtrl(self, size = wx.Size(60, -1))
self.maxupload.SetRange(2, 100)
maxuploadsbox = wx.BoxSizer(wx.HORIZONTAL)
maxuploadsbox.Add(wx.StaticText(self, -1, self.utility.lang.get('maxuploads')), 0, wx.ALIGN_CENTER_VERTICAL)
maxuploadsbox.Add(self.maxupload, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
uploadsection.Add(maxuploadsbox, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
maxoverall_down_label = wx.BoxSizer(wx.VERTICAL)
maxoverall_down_label.Add(wx.StaticText(self, -1, self.utility.lang.get('maxoveralluploadrate')), 0, wx.ALIGN_CENTER_VERTICAL)
maxoverall_down_label.Add(wx.StaticText(self, -1, self.utility.lang.get('whendownload')), 0, wx.ALIGN_CENTER_VERTICAL)
self.uploadrate = self.utility.makeNumCtrl(self, 0, integerWidth = 4)
self.uploadrate.SetToolTipString(self.utility.lang.get('global_uprate_hint'))
maxoverall_down = wx.BoxSizer(wx.HORIZONTAL)
maxoverall_down.Add(maxoverall_down_label, 0, wx.ALIGN_CENTER_VERTICAL)
maxoverall_down.Add(self.uploadrate, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
maxoverall_down.Add(wx.StaticText(self, -1, self.utility.lang.get('KB') + "/" + self.utility.lang.get('l_second')), 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 3)
uploadsection.Add(maxoverall_down, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
maxoverall_nodown_label = wx.BoxSizer(wx.VERTICAL)
maxoverall_nodown_label.Add(wx.StaticText(self, -1, self.utility.lang.get('maxoveralluploadrate')), 0, wx.ALIGN_CENTER_VERTICAL)
maxoverall_nodown_label.Add(wx.StaticText(self, -1, self.utility.lang.get('whennodownload')), 0, wx.ALIGN_CENTER_VERTICAL)
self.seeduploadrate = self.utility.makeNumCtrl(self, 0, integerWidth = 4)
self.seeduploadrate.SetToolTipString(self.utility.lang.get('global_uprate_hint'))
maxoverall_nodown = wx.BoxSizer(wx.HORIZONTAL)
maxoverall_nodown.Add(maxoverall_nodown_label, 0, wx.ALIGN_CENTER_VERTICAL)
maxoverall_nodown.Add(self.seeduploadrate, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
maxoverall_nodown.Add(wx.StaticText(self, -1, self.utility.lang.get('KB') + "/" + self.utility.lang.get('l_second')), 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 3)
uploadsection.Add(maxoverall_nodown, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
uploadsection.Add(wx.StaticText(self, -1, self.utility.lang.get('zeroisunlimited')), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5)
sizer.Add(uploadsection, 0, wx.EXPAND|wx.ALL, 5)
# Download Section
downloadsection_title = wx.StaticBox(self, -1, self.utility.lang.get('downloadsetting'))
downloadsection = wx.StaticBoxSizer(downloadsection_title, wx.VERTICAL)
self.downloadrate = self.utility.makeNumCtrl(self, 0, integerWidth = 4)
maxdownoverall_down = wx.BoxSizer(wx.HORIZONTAL)
maxdownoverall_down.Add(wx.StaticText(self, -1, self.utility.lang.get('maxoveralldownloadrate')), 0, wx.ALIGN_CENTER_VERTICAL)
maxdownoverall_down.Add(self.downloadrate, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
maxdownoverall_down.Add(wx.StaticText(self, -1, self.utility.lang.get('KB') + "/" + self.utility.lang.get('l_second')), 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 3)
downloadsection.Add(maxdownoverall_down, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
downloadsection.Add(wx.StaticText(self, -1, self.utility.lang.get('zeroisunlimited')), 0, wx.ALIGN_CENTER_VERTICAL|wx.ALIGN_RIGHT|wx.ALL, 5)
sizer.Add(downloadsection, 0, wx.EXPAND|wx.ALL, 5)
# Prioritize Local
self.prioritizelocal = wx.CheckBox(self, -1, self.utility.lang.get('prioritizelocal'))
sizer.Add(self.prioritizelocal, 0, wx.ALL, 5)
self.initTasks()
def loadValues(self, Read = None):
if Read is None:
Read = self.utility.config.Read
self.maxupload.SetValue(Read('maxupload', "int"))
self.uploadrate.SetValue(Read('maxuploadrate', "int"))
self.downloadrate.SetValue(Read('maxdownloadrate', "int"))
self.seeduploadrate.SetValue(Read('maxseeduploadrate', "int"))
self.prioritizelocal.SetValue(Read('prioritizelocal', "boolean"))
def apply(self):
# Check max upload rate input must be integer
##############################################
upload_rate = int(self.uploadrate.GetValue())
seedupload_rate = int(self.seeduploadrate.GetValue())
download_rate = int(self.downloadrate.GetValue())
# Check max upload rate must not be less than 3 kB/s
######################################################
if (upload_rate < 3 and upload_rate != 0) or (seedupload_rate < 3 and seedupload_rate != 0):
#display warning
dlg = wx.MessageDialog(self, self.utility.lang.get('uploadrateminwarning'), self.utility.lang.get('error'), wx.ICON_ERROR)
dlg.ShowModal()
dlg.Destroy()
return False
self.utility.config.Write('prioritizelocal', self.prioritizelocal.GetValue(), "boolean")
# Set new value to parameters
##############################
self.utility.config.Write('maxupload', self.maxupload.GetValue())
self.utility.config.Write('maxuploadrate', upload_rate)
self.utility.config.Write('maxseeduploadrate', seedupload_rate)
self.utility.config.Write('maxdownloadrate', download_rate)
################################################################
#
# Class: SeedingOptionsPanel
#
# Contains options controlling how long torrents should remain
# seeding.
#
################################################################
class SeedingOptionsPanel(ABCOptionPanel):
def __init__(self, parent, dialog):
ABCOptionPanel.__init__(self, parent, dialog)
sizer = self.sizer
# GUI dialog for Global upload setting
########################################
# Upload setting for completed files
########################################
continuesection_title = wx.StaticBox(self, -1, self.utility.lang.get('uploadoptforcompletedfile'))
continuesection = wx.StaticBoxSizer(continuesection_title, wx.VERTICAL)
uploadlist = [self.utility.lang.get('unlimitedupload'), self.utility.lang.get('continueuploadfor'), self.utility.lang.get('untilratio')]
rb1 = wx.RadioButton(self, -1, uploadlist[0], wx.Point(-1, -1), wx.Size(-1, -1), wx.RB_GROUP)
rb2 = wx.RadioButton(self, -1, uploadlist[1], wx.Point(-1, -1), wx.Size(-1, -1))
rb3 = wx.RadioButton(self, -1, uploadlist[2], wx.Point(-1, -1), wx.Size(-1, -1))
self.rb = [rb1, rb2, rb3]
mtimeval = ['30', '45', '60', '75']
htimeval = []
for i in range(24):
htimeval.append(str(i))
self.cbhtime = wx.ComboBox(self, -1, "", wx.Point(-1, -1),
wx.Size(37, -1), htimeval, wx.CB_DROPDOWN|wx.CB_READONLY)
self.cbmtime = wx.ComboBox(self, -1, "", wx.Point(-1, -1),
wx.Size(37, -1), mtimeval, wx.CB_DROPDOWN|wx.CB_READONLY)
continuesection.Add(rb1, 0, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
time_sizer = wx.BoxSizer(wx.HORIZONTAL)
time_sizer.Add(rb2, 0, wx.ALIGN_CENTER_VERTICAL)
time_sizer.Add(self.cbhtime, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
time_sizer.Add(wx.StaticText(self, -1, self.utility.lang.get('hour')), 0, wx.ALIGN_CENTER_VERTICAL)
time_sizer.Add(self.cbmtime, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
time_sizer.Add(wx.StaticText(self, -1, self.utility.lang.get('minute')), 0, wx.ALIGN_CENTER_VERTICAL)
continuesection.Add(time_sizer, -1, wx.ALIGN_CENTER_VERTICAL|wx.ALL, 5)
ratioval = ['50', '75', '100', '125', '150', '175', '200', '300', '400', '500']
self.cbratio = wx.ComboBox(self, -1, "",
wx.Point(-1, -1), wx.Size(45, -1), ratioval, wx.CB_DROPDOWN|wx.CB_READONLY)
percent_sizer = wx.BoxSizer(wx.HORIZONTAL)
percent_sizer.Add(rb3, 0, wx.ALIGN_CENTER_VERTICAL)
percent_sizer.Add(self.cbratio, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT, 5)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -