⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abcoption.py

📁 ABC-win32-v3.1 一个P2P软源代码
💻 PY
📖 第 1 页 / 共 5 页
字号:
        listfont_box.Add(self.fontexample, 1, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 5)
        
        fontbutton = browsebtn = wx.Button(self, -1, self.utility.lang.get('choosefont'), style = wx.BU_EXACTFIT)
        listfont_box.Add(fontbutton, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 5)
        self.Bind(wx.EVT_BUTTON, self.onFontButton, fontbutton)
        
        sizer.Add(listfont_box, 0, wx.EXPAND|wx.ALIGN_LEFT|wx.ALL, 5)
        
        # Striped list options
        stripedlist_box = wx.BoxSizer(wx.HORIZONTAL)
        
        self.stripedlist = wx.CheckBox(self, -1, self.utility.lang.get('stripedlist'))
        stripedlist_box.Add(self.stripedlist, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 5)
        
        self.stripedlist_button = colourselect.ColourSelect(self, -1, "", size = (60, 20))
        
        stripedlist_box.Add(self.stripedlist_button, 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(stripedlist_box, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        self.savecolumnwidth = wx.CheckBox(self, -1, self.utility.lang.get('savecolumnwidth'))        
        sizer.Add(self.savecolumnwidth, 0, wx.ALL, 5)
        
        self.contextmenu = wx.Button(self, -1, self.utility.lang.get('customizecontextmenu') + "...")
        sizer.Add(self.contextmenu, 0, wx.ALL, 5)
        self.Bind(wx.EVT_BUTTON, self.onContextMenuDialog, self.contextmenu)
        
#        self.showmenuicons = wx.CheckBox(self, -1, self.utility.lang.get('showmenuicons'))
#        sizer.Add(self.showmenuicons, 0, wx.ALL, 5)
        
        self.initTasks()
        
    def onContextMenuDialog(self, event = None):
        dialog = MenuDialog(self, 'menu_listrightclick')
        dialog.ShowModal()
        dialog.Destroy()
        
    def loadValues(self, Read = None):
        if Read is None:
            Read = self.utility.config.Read
        
        self.stripedlist.SetValue(Read('stripedlist', "boolean"))
        
        self.stripedlist_button.SetValue(Read('color_stripe', "color"))
        
        self.savecolumnwidth.SetValue(Read('savecolumnwidth', "boolean"))
        
#        self.showmenuicons.SetValue(Read('showmenuicons', "boolean"))
        
        # Get font information                          
        self.fontexample.SetFont(self.utility.getFontFromInfo(Read('listfont', "bencode-fontinfo")))

               
    def apply(self):
        self.utility.config.Write('savecolumnwidth', self.savecolumnwidth.GetValue(), "boolean")
#        self.utility.config.Write('showmenuicons', self.showmenuicons.GetValue(), "boolean")
         
        overallchanged = False
        changed = self.utility.config.Write('stripedlist', self.stripedlist.GetValue(), "boolean")
        if changed:
            overallchanged = True
            
        # Set stripe color
        changed = self.utility.config.Write('color_stripe', self.stripedlist_button.GetColour(), "color")
        if changed:
            overallchanged = True
            
        if overallchanged:
            for ABCTorrentTemp in self.utility.torrents["all"]:
                ABCTorrentTemp.updateColor()
        
        # Set list font
        newfont = self.fontexample.GetFont()
        newfontinfo = self.utility.getInfoFromFont(newfont)

        fontchanged = self.utility.config.Write('listfont', newfontinfo, "bencode-fontinfo")

        if fontchanged:
            for managedlist in self.utility.lists:
                try:
                    if self.utility.lists[managedlist]:
                        managedlist.loadFont()
                except:
                    pass
                
    def onFontButton(self, event = None):
        fontdata = wx.FontData()
        fontdata.EnableEffects(False)
        fontdata.SetInitialFont(self.fontexample.GetFont())

        dlg = wx.FontDialog(self, fontdata)
        if dlg.ShowModal() == wx.ID_OK:
            data = dlg.GetFontData()
                        
            newfont = data.GetChosenFont()
            newfontinfo = self.utility.getInfoFromFont(newfont)
            
            oldfontinfo = self.utility.config.Read('listfont', "bencode-fontinfo")
                           
            changed = False
            for attr in oldfontinfo:
                if oldfontinfo[attr] != newfontinfo[attr]:
                    changed = True
                    break
            
            if changed:
                # (TODO: May need to adjust if a large font was used)
                self.fontexample.SetFont(newfont)
                self.Layout()
                self.Refresh()


################################################################
#
# Class: MiscPanel
#
# Contains settings that don't seem to fit well anywhere else
#
################################################################
class MiscPanel(ABCOptionPanel):
    def __init__(self, parent, dialog):
        ABCOptionPanel.__init__(self, parent, dialog)
        sizer = self.sizer
        
        self.trayoptions = [self.utility.lang.get('showtray_never'), 
                            self.utility.lang.get('showtray_min'), 
                            self.utility.lang.get('showtray_always')]
        self.mintray = wx.RadioBox(self, 
                                    -1, 
                                    self.utility.lang.get('showtray'), 
                                    wx.DefaultPosition, 
                                    wx.DefaultSize, 
                                    self.trayoptions, 
                                    3, 
                                    wx.RA_SPECIFY_COLS)
        sizer.Add(self.mintray, 0, wx.ALIGN_LEFT|wx.ALL, 5)
               
        self.confirmonclose = wx.CheckBox(self, -1, self.utility.lang.get('confirmonexit'))
        sizer.Add(self.confirmonclose, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        # Registry association (only makes sense under windows)
        if (sys.platform == 'win32'):
            self.associate = wx.CheckBox(self, -1, self.utility.lang.get('associate'))
            sizer.Add(self.associate, 0, wx.ALIGN_LEFT|wx.ALL, 5)

		#rename torrent with dest
        self.rtwd = wx.CheckBox(self, -1, self.utility.lang.get('rtwd'))
        self.rtwd.SetValue(self.utility.config.Read('defrentorwithdest', "boolean"))
        sizer.Add(self.rtwd, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        
        # Languages option
        if self.utility.languages == {}:
            self.getLanguages()
        self.language_names = []
        self.language_filenames = []
        for item in self.utility.languages:
            self.language_names.append(item)
            self.language_filenames.append(self.utility.languages[item])
       
        self.language_choice = wx.ComboBox(self, -1, "", wx.Point(-1, -1), wx.Size(-1, -1), self.language_names, wx.CB_DROPDOWN|wx.CB_READONLY)
        
        lang_box = wx.BoxSizer(wx.HORIZONTAL)
        lang_box.Add(wx.StaticText(self, -1, self.utility.lang.get('choose_language')), 0, wx.ALIGN_CENTER_VERTICAL)
        lang_box.Add(self.language_choice, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
        lang_box.Add(wx.StaticText(self, -1, self.utility.lang.get('restartabc')), 0, wx.ALIGN_CENTER_VERTICAL)
        sizer.Add(lang_box, 0, wx.ALL, 5)
        
        self.initTasks()
        
    def loadValues(self, Read = None):
        if Read is None:
            Read = self.utility.config.Read
        
        mintray = Read('mintray', "int")
        if mintray >= len(self.trayoptions):
            mintray = len(self.trayoptions) - 1
        self.mintray.SetSelection(mintray)
        
        self.confirmonclose.SetValue(Read('confirmonclose', "boolean"))
        
        self.rtwd.SetValue(Read('defrentorwithdest', "boolean"))
        if (sys.platform == 'win32'):
            self.associate.SetValue(Read('associate', "boolean"))        
        
        index = self.language_filenames.index(Read('language_file'))
        if not self.language_names:
            # Should never get here -- this means there are no valid language files found!
            sys.stderr.write("\nNO LANGUAGE FILES FOUND!  Please add a valid language file\n")
            defaultlang = ""
        elif (index > -1):
            defaultlang = self.language_names[index]
        self.language_choice.SetStringSelection(defaultlang)
              
    def apply(self):       
        self.utility.config.Write('mintray', self.mintray.GetSelection())
        self.utility.frame.tbicon.updateIcon()

        langname_index = self.language_names.index(self.language_choice.GetValue())
        self.utility.config.Write('language_file', self.language_filenames[langname_index])
        
        self.utility.config.Write('confirmonclose', self.confirmonclose.GetValue(), "boolean")
        
        self.utility.config.Write('defrentorwithdest', self.rtwd.GetValue(), "boolean")          
        
        self.utility.config.Write('associate', self.associate.GetValue(), "boolean")
        self.utility.regchecker.updateRegistry(self.associate.GetValue())         

    def getLanguages(self):
        langpath = os.path.join(self.utility.getPath(), "lang")
        
        dirlist = os.listdir(langpath)
        dirlist2 = []
        for filename in dirlist:
            if (filename[-5:] == '.lang'):
                dirlist2.append(filename)
        dirlist2.sort()
        
        # Remove user.lang from the list
        try:
            dirlist2.remove("user.lang")
        except:
            pass
        
        self.utility.languages = {}
        
        for filename in dirlist2:
            filepath = os.path.join(langpath, filename)

            config = ConfigReader(filepath, "ABC/language")
            if config.Exists('languagename'):
                self.utility.languages[config.Read('languagename')] = filename


################################################################
#
# Class: DiskPanel
#
# Contains settings related to saving files
#
################################################################
class DiskPanel(ABCOptionPanel):
    def __init__(self, parent, dialog):
        ABCOptionPanel.__init__(self, parent, dialog)
        sizer = self.sizer
                      
        self.torrentbackup = wx.CheckBox(self, -1, self.utility.lang.get('removebackuptorrent'))
        sizer.Add(self.torrentbackup, 0, wx.ALIGN_LEFT|wx.ALL, 5)
           
        self.defaultdir = wx.CheckBox(self, -1, self.utility.lang.get('setdefaultfolder'))

        self.dir = wx.TextCtrl(self, -1, "")
        browsebtn = wx.Button(self, -1, "...", style = wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onBrowseDir, browsebtn)

        dirbox = wx.BoxSizer(wx.HORIZONTAL)
        dirbox.Add(self.defaultdir, 0, wx.ALIGN_CENTER_VERTICAL)
        dirbox.Add(self.dir, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
        dirbox.Add(browsebtn, 0, wx.ALIGN_CENTER_VERTICAL)

        sizer.Add(dirbox, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        self.movecompleted = wx.CheckBox(self, -1, self.utility.lang.get('movecompleted'))

        self.movedir = wx.TextCtrl(self, -1, "")
        movebrowsebtn = wx.Button(self, -1, "...", style = wx.BU_EXACTFIT)
        self.Bind(wx.EVT_BUTTON, self.onBrowseMoveDir, movebrowsebtn)

        movedirbox = wx.BoxSizer(wx.HORIZONTAL)
        movedirbox.Add(self.movecompleted, 0, wx.ALIGN_CENTER_VERTICAL)
        movedirbox.Add(self.movedir, 0, wx.ALIGN_CENTER_VERTICAL|wx.LEFT|wx.RIGHT, 5)
        movedirbox.Add(movebrowsebtn, 0, wx.ALIGN_CENTER_VERTICAL)

        sizer.Add(movedirbox, 0, wx.ALIGN_LEFT|wx.ALL, 5)
       
#        self.forcenewdir = wx.CheckBox(self, -1, self.utility.lang.get('forcenewdir'))
#        self.forcenewdir.SetToolTipString(self.utility.lang.get('forcenewdir_hint'))
#        
#        sizer.Add(self.forcenewdir, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        diskfullbox = wx.BoxSizer(wx.HORIZONTAL)
        self.diskfullcheckbox = wx.CheckBox(self, -1, self.utility.lang.get('diskfullthreshold'))
        self.diskfullthreshold = self.utility.makeNumCtrl(self, 1, integerWidth = 4)
        diskfullbox.Add(self.diskfullcheckbox, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 5)
        diskfullbox.Add(self.diskfullthreshold, 0, wx.ALIGN_CENTER_VERTICAL|wx.RIGHT, 5)
        diskfullbox.Add(wx.StaticText(self, -1, self.utility.lang.get('MB')), 0, wx.ALIGN_CENTER_VERTICAL)
        
        sizer.Add(diskfullbox, 0, wx.ALIGN_LEFT|wx.ALL, 5)

        self.initTasks()

    def loadValues(self, Read = None):
        if Read is None:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -