Пример #1
0
    def __init__(self, parent=None):
        """Dialogs that allows users to load music libraries.

        A list of libraries is listed in a ListWidget on the left with the library module's InitWidget shown on the right.

        First all libraries stored in puddlestuff.libraries are loaded.
        Then puddlestuff.musiclib.extralibs is checked for an extra libraries.
        They should already be loaded.

        

        Useful methods:
            loadLib()->Loads the currently selected library.
            loadLibConfig()

        Libraries are module which should contain the following:
            name->The name of the library.
            InitWidget class->Used to allow the use to set options required for loading the library.
        """
        QDialog.__init__(self, parent)
        self.listbox = QListWidget()
        self.setWindowTitle(translate('MusicLib', 'Import Music Library'))
        winsettings('importmusiclib', self)

        self.libattrs = []
        for libname in libraries.__all__:
            try:
                lib = __import__('puddlestuff.libraries.%s' % libname,
                                 fromlist=['puddlestuff', 'libraries'])
                if not hasattr(lib, 'InitWidget'):
                    raise Exception(translate('MusicLib', 'Invalid library'))
            except Exception, detail:
                msg = translate('MusicLib', 'Error loading %1: %2\n')
                msg = msg.arg(libname).arg(unicode(detail))
                sys.stderr.write(msg.encode('utf8'))
                continue

            try:
                name = lib.name
            except AttributeError:
                name = translate('MusicLib', 'Anonymous Library')

            try:
                desc = lib.description
            except AttributeError:
                desc = translate('MusicLib', 'Description was left out.')

            try:
                author = lib.author
            except AttributeError:
                author = translate('MusicLib', 'Anonymous author.')

            self.libattrs.append({
                'name': name,
                'desc': desc,
                'author': author,
                'module': lib
            })
Пример #2
0
    def __init__(self, parent = None):
        """Dialogs that allows users to load music libraries.

        A list of libraries is listed in a ListWidget on the left with the library module's InitWidget shown on the right.

        First all libraries stored in puddlestuff.libraries are loaded.
        Then puddlestuff.musiclib.extralibs is checked for an extra libraries.
        They should already be loaded.

        

        Useful methods:
            loadLib()->Loads the currently selected library.
            loadLibConfig()

        Libraries are module which should contain the following:
            name->The name of the library.
            InitWidget class->Used to allow the use to set options required for loading the library.
        """
        QDialog.__init__(self, parent)
        self.listbox = QListWidget()
        self.setWindowTitle(translate('MusicLib', 'Import Music Library'))
        winsettings('importmusiclib', self)

        self.libattrs = []
        for libname in libraries.__all__:
            try:
                lib =  __import__('puddlestuff.libraries.%s' % libname,
                                    fromlist=['puddlestuff', 'libraries'])
                if not hasattr(lib, 'InitWidget'):
                    raise Exception(translate('MusicLib', 'Invalid library'))
            except Exception, detail:
                msg = translate('MusicLib', 'Error loading %1: %2\n')
                msg = msg.arg(libname).arg(unicode(detail))
                sys.stderr.write(msg.encode('utf8'))
                continue
            
            try: name = lib.name
            except AttributeError:
                name = translate('MusicLib', 'Anonymous Library')

            try: desc = lib.description
            except AttributeError:
                desc = translate('MusicLib', 'Description was left out.')

            try: author = lib.author
            except AttributeError:
                author = translate('MusicLib',  'Anonymous author.')

            self.libattrs.append(
                {'name': name, 'desc':desc, 'author': author, 'module': lib})
Пример #3
0
    def __init__(self, parent=None, status=None):
        super(MassTagWindow, self).__init__(parent)
        self.receives = []
        self.emits = ['setpreview', 'clearpreview', 'enable_preview_mode',
            'writepreview', 'disable_preview_mode']
        self.__flag = MassTagFlag()
        self.__flag.stop = False

        self.setWindowTitle(translate('Masstagging', 'Mass Tagging'))
        winsettings('masstaglog', self)
        self._startButton = QPushButton(translate('Masstagging', '&Search'))
        configure = QPushButton(translate('Masstagging', '&Configure Profiles'))
        write = QPushButton(translate('Masstagging', '&Write Previews'))
        clear = QPushButton(translate('Masstagging', 'Clear &Preview'))
        self._log = QTextEdit()
        self.tag_sources = status['initialized_tagsources']

        self.profileCombo = QComboBox()
        self.profile = None

        self._status = status

        self.connect(status_obj, SIGNAL('statusChanged'), self._appendLog)
        self.connect(status_obj, SIGNAL('logappend'), self._appendLog)
        self.connect(self.profileCombo, SIGNAL('currentIndexChanged(int)'),
            self.changeProfile)
        self.connect(self._startButton, SIGNAL('clicked()'), self.lookup)
        self.connect(configure, SIGNAL('clicked()'), self.configure)
        self.connect(write, SIGNAL('clicked()'), self.writePreview)
        self.connect(clear, SIGNAL('clicked()'), self.clearPreview)

        buttons = QHBoxLayout()
        buttons.addWidget(configure)
        buttons.addStretch()
        buttons.addWidget(write)
        buttons.addWidget(clear)

        combo = QHBoxLayout()
        label = QLabel(translate('Masstagging', '&Profile:'))
        label.setBuddy(self.profileCombo)
        combo.addWidget(label)
        combo.addWidget(self.profileCombo, 1)
        combo.addWidget(self._startButton)

        layout = QVBoxLayout()
        layout.addLayout(combo)
        layout.addWidget(self._log)
        layout.addLayout(buttons)
        self.setLayout(layout)
Пример #4
0
    def __init__(self, tag_sources, profiles=None, parent = None):
        super(MassTagEdit, self).__init__(parent)

        self.setWindowTitle(translate('Profile Config',
            'Configure Mass Tagging Profiles'))
        winsettings('masstag_edit', self)

        self.listbox = ListBox()
        self.tag_sources = tag_sources

        okcancel = OKCancel()
        okcancel.ok.setDefault(True)

        self.buttonlist = ListButtons()

        connect = lambda control, signal, slot: self.connect(
            control, SIGNAL(signal), slot)

        connect(okcancel, "ok" , self.okClicked)
        connect(okcancel, "cancel",self.close)
        connect(self.buttonlist, "add", self.addClicked)
        connect(self.buttonlist, "edit", self.editClicked)
        connect(self.buttonlist, "moveup", self.moveUp)
        connect(self.buttonlist, "movedown", self.moveDown)
        connect(self.buttonlist, "remove", self.remove)
        connect(self.buttonlist, "duplicate", self.dupClicked)
        connect(self.listbox, "itemDoubleClicked (QListWidgetItem *)",
            self.editClicked)
        connect(self.listbox, "currentRowChanged(int)", self.enableListButtons)

        self.enableListButtons(self.listbox.currentRow())

        layout = QVBoxLayout()
        self.setLayout(layout)

        layout.addWidget(QLabel(translate('Profile Config',
            'Masstagging Profiles')))

        list_layout = QHBoxLayout()
        list_layout.addWidget(self.listbox, 1)
        list_layout.addLayout(self.buttonlist)

        layout.addLayout(list_layout)
        layout.addLayout(okcancel)
        if profiles is not None:
            self.setProfiles(profiles)
Пример #5
0
    def __init__(self, parent=None, alg = None):
        QWidget.__init__(self, parent)
        winsettings('algwin', self)
        taglabel = QLabel('&Tags')
        self.tags = QLineEdit('artist | title')
        taglabel.setBuddy(self.tags)
        self.alcombo = QComboBox()
        allabel = QLabel('&Algorithms')
        allabel.setBuddy(self.alcombo)
        self.threshold = QLineEdit('90')
        self.threshold.setValidator(QDoubleValidator(self.threshold))
        perlabel = QLabel("&Match threshold")
        perlabel.setBuddy(self.threshold)

        self.matchcase = QCheckBox('&Match Case')

        okcancel = OKCancel()
        okcancel.ok.setDefault(True)

        self.connect(okcancel, SIGNAL("ok") , self.okClicked)
        self.connect(okcancel, SIGNAL("cancel"),self.close)

        vbox = QVBoxLayout()
        [vbox.addWidget(z) for z in [taglabel,self.tags, perlabel, self.threshold,
                                    allabel, self.alcombo, self.matchcase]]
        frame = QFrame()
        frame.setFrameStyle(QFrame.Box)
        frame.setLayout(vbox)

        box = QVBoxLayout()
        box.addWidget(frame)
        box.addLayout(okcancel)
        self.setLayout(box)

        x = [funcinfo(z) for z in funcs]
        names = [z[0] for z in x]
        ds = [z[1] for z in x]

        self.alcombo.clear()
        self.alcombo.addItems(names)
        self.alcombo.setCurrentIndex(0)
        tooltip = u"<dl>%s</dl>" % u''.join([u'<dt><b>%s<b></dt> <dd>%s</dd>' % z for z in x])
        self.alcombo.setToolTip(tooltip)
        if alg:
            self.loadAlgo(alg)
Пример #6
0
    def __init__(self, parent=None, alg = None):
        QWidget.__init__(self, parent)
        winsettings('algwin', self)
        taglabel = QLabel('&Tags')
        self.tags = QLineEdit('artist | title')
        taglabel.setBuddy(self.tags)
        self.alcombo = QComboBox()
        allabel = QLabel('&Algorithms')
        allabel.setBuddy(self.alcombo)
        self.threshold = QLineEdit('90')
        self.threshold.setValidator(QDoubleValidator(self.threshold))
        perlabel = QLabel("&Match threshold")
        perlabel.setBuddy(self.threshold)

        self.matchcase = QCheckBox('&Match Case')

        okcancel = OKCancel()
        okcancel.ok.setDefault(True)

        self.connect(okcancel, SIGNAL("ok") , self.okClicked)
        self.connect(okcancel, SIGNAL("cancel"),self.close)

        vbox = QVBoxLayout()
        [vbox.addWidget(z) for z in [taglabel,self.tags, perlabel, self.threshold,
                                    allabel, self.alcombo, self.matchcase]]
        frame = QFrame()
        frame.setFrameStyle(QFrame.Box)
        frame.setLayout(vbox)

        box = QVBoxLayout()
        box.addWidget(frame)
        box.addLayout(okcancel)
        self.setLayout(box)

        x = [funcinfo(z) for z in funcs]
        names = [z[0] for z in x]
        ds = [z[1] for z in x]

        self.alcombo.clear()
        self.alcombo.addItems(names)
        self.alcombo.setCurrentIndex(0)
        tooltip = u"<dl>%s</dl>" % u''.join([u'<dt><b>%s<b></dt> <dd>%s</dd>' % z for z in x])
        self.alcombo.setToolTip(tooltip)
        if alg:
            self.loadAlgo(alg)
Пример #7
0
    def __init__(self, parent=None):
        super(PluginConfig, self).__init__(parent)
        winsettings('pluginconfig', self)
        self._listbox = QListWidget()
        info_display = InfoWidget()

        hbox = QHBoxLayout()
        hbox.addWidget(self._listbox, 0)
        hbox.addWidget(info_display, 1)

        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(
            QLabel(
                translate(
                    "Plugin Settings",
                    '<b>Loading/unloading plugins requires a restart.</b>')))
        self.setLayout(vbox)

        plugins = []
        [plugins.extend(get_plugins(d)) for d in PLUGIN_DIRS]

        cparser = PuddleConfig()
        to_load = cparser.get('plugins', 'to_load', [])
        plugins.sort(key=lambda d: d.get(NAME, u''))
        for plugin in plugins:
            item = QListWidgetItem()
            item.setText(plugin[NAME])
            if plugin[MODULE_NAME] in to_load:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)
            item.plugin = plugin
            self._listbox.addItem(item)

        self.connect(
            self._listbox,
            SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem *)'),
            lambda item, previous: info_display.changeInfo(item.plugin))
Пример #8
0
    def __init__(self, parent = None):
        super(PluginConfig, self).__init__(parent)
        winsettings('pluginconfig', self)
        self._listbox = QListWidget()
        info_display = InfoWidget()
        
        hbox = QHBoxLayout()
        hbox.addWidget(self._listbox, 0)
        hbox.addWidget(info_display, 1)
        
        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addWidget(
            QLabel(translate("Plugin Settings",
                '<b>Loading/unloading plugins requires a restart.</b>')))
        self.setLayout(vbox)

        plugins = []
        [plugins.extend(get_plugins(d)) for d in PLUGIN_DIRS]
        
        cparser = PuddleConfig()
        to_load = cparser.get('plugins', 'to_load', [])
        plugins.sort(key=lambda d: d.get(NAME, u''))
        for plugin in plugins:
            item = QListWidgetItem()
            item.setText(plugin[NAME])
            if plugin[MODULE_NAME] in to_load:
                item.setCheckState(Qt.Checked)
            else:
                item.setCheckState(Qt.Unchecked)
            item.plugin = plugin
            self._listbox.addItem(item)
        
        self.connect(self._listbox, 
            SIGNAL('currentItemChanged(QListWidgetItem*, QListWidgetItem *)'),
            lambda item, previous: info_display.changeInfo(item.plugin))
Пример #9
0
    def __init__(self, parent=None):
        QDialog.__init__(self,parent)
        winsettings('setdialog', self)
        vbox = QVBoxLayout()
        self._previndex = 0
        self.setscombo = QComboBox()
        setlabel = QLabel('&Sets')
        setlabel.setBuddy(self.setscombo)
        vbox.addWidget(setlabel)

        comboadd = QToolButton()
        comboadd.setIcon(QIcon(':/filenew.png'))
        comboadd.setToolTip('Add set')
        self.connect(comboadd, SIGNAL('clicked()'), self.addSet)

        hbox = QHBoxLayout()
        hbox.addWidget(self.setscombo)
        hbox.addWidget(comboadd)

        vbox.addLayout(hbox)

        conditions = QLabel('&Conditions')
        vbox.addWidget(conditions)

        self.listbox = ListBox()
        conditions.setBuddy(self.listbox)
        listbuttons = ListButtons()

        listhbox = QHBoxLayout()
        listhbox.addWidget(self.listbox)
        listhbox.addLayout(listbuttons)
        vbox.addLayout(listhbox)

        label = QLabel('Retrieve values via: ')
        self.maintag = QComboBox()
        self.maintag.addItems(['artist', 'title', 'genre', 'album', 'year'])
        maintaghbox = QHBoxLayout()
        maintaghbox.addWidget(label)
        maintaghbox.addWidget(self.maintag)
        maintaghbox.addStretch()
        vbox.addLayout(maintaghbox)

        dispformat = QLabel('Display Format')
        vbox.addWidget(dispformat)
        self.texts = [QLineEdit(), QLineEdit()]
        t = ['Original', 'Duplicates']
        for i, text in enumerate(self.texts):
            label = QLabel(t[i])
            label.setBuddy(text)
            dispbox = QHBoxLayout()
            dispbox.addWidget(label)
            dispbox.addWidget(text)
            vbox.addLayout(dispbox)

        okcancel = OKCancel()
        vbox.addLayout(okcancel)
        self.connect(okcancel, SIGNAL('ok'), self.okClicked)
        self.connect(okcancel, SIGNAL('cancel'), self.cancelClicked)
        self.setLayout(vbox)

        self.fill(loadsets())
        listbuttons.connectToWidget(self)
Пример #10
0
    def __init__(self, tag_sources, profile=None, parent=None):
        super(TSProfileEdit, self).__init__(parent)
        self.setWindowTitle(translate('Profile Editor',
            'Edit Tag Source Config'))
        winsettings('ts_profile_edit', self)
        self.tag_sources = tag_sources

        layout = QVBoxLayout(self)
        self.setLayout(layout)

        self.fields = QLineEdit(self)
        layout.addLayout(
            create_buddy(translate('Defaults', 'Fields: '), self.fields))
        self.fields.setToolTip(translate('Profile Editor',
            '<p>Enter a comma-seperated list of fields to retrieve. '
            'Leave empty to retrieve all available fields/values. '

            '<br /><br />Eg. <b>artist, album, title</b> will '
            'only retrieve the artist, album and title fields of '
            'from the Tag Source. '

            '<br /><br />Start the list with '
            'the tilde (~) character to write all retrieved fields '
            ', but the ones listed. Eg the field list '
            '<b>~composer,__image</b> will write all fields but the '
            'composer and __image (aka cover art) fields.</p>'

            '<p>If a field has been retrieved in a previous '
            'Tag Source the values will be combined if they differ. '
            'Eg. If genre=<b>Rock</b> for the first tag source polled '
            'and genre=<b>Alternative</b> for the tag source '
            'polled second then the resulting field will have '
            'multiple-values ie. genre=<b>Rock\\\\Rap</b>'))

        self.replace_fields = QLineEdit(self)
        layout.addLayout(create_buddy(translate('Profile Editor',
            'Fields to replace: '), self.replace_fields))
        self.replace_fields.setToolTip(translate('Profile Editor',
            'Enter a comma-separated lists of fields that\'ll replace any '
            'retrieved from previously polled tag sources. '
            
            '<br />Start the list with the tilde (~) character to replace all '
            'but the fields you list. <br />'
            '<b>NB: Fields listed here must also be listed in the '
            'list of fields to retrieve.</b>'
            
            '<br /><br />Eg. Assume you have two Tag Sources. '
            'The first retrieves <b>artist=Freshlyground, '
            'album=Nomvula, genre=Afro Pop</b>. The second source gets '
            '<b>artist=Freshly Ground, album=Nomvula, '
            'genre=Pop</b>. '
            'For the second Tag Source, setting just <b>artist</b> as the '
            'list of fields to replace will overwrite the artist '
            'field retrieved from the first tag source. '
            'The resulting retrieved fields/values as shown in puddletag will '
            'then be <b>artist=Freshly Ground, album=Nomvula, '
            'genre=Afro Pop\\\\Pop</b>.'))

        self.source = QComboBox()
        self.source.addItems([source.name for source in tag_sources])
        layout.addLayout(create_buddy(
            translate('Profile Editor', '&Source'), self.source))

        self.no_match = QComboBox()
        self.no_match.addItems(NO_MATCH_OPTIONS)
        layout.addLayout(create_buddy(translate('Profile Editor',
            '&If no results found: '), self.no_match))
        self.no_match.setToolTip(translate('Profile Editor',
            '<p><b>Continue</b>: The lookup for the current album will continue '
            'by checking the other tag sources if no matching results '
            'were found for this tag source.</p>'

            '<p><b>Stop:</b> The lookup for the current album will '
            'stop and any previously retrieved results will be used.</p>'))

        okcancel = OKCancel()
        self.connect(okcancel, SIGNAL('ok'), self._okClicked)
        self.connect(okcancel, SIGNAL('cancel'), self.close)
        layout.addLayout(okcancel)

        layout.addStretch()
        self.setMaximumHeight(layout.sizeHint().height())

        if profile:
            self.setProfile(profile)
Пример #11
0
    def __init__(self, tag_sources, profile=None, parent=None):
        super(MTProfileEdit, self).__init__(parent)

        self.setWindowTitle(translate('Profile Editor', 'Edit Masstagging Profile'))
        winsettings('masstag_profile', self)
        self._configs = []
        self.tag_sources = tag_sources
        self._tsps = []

        self._name = QLineEdit(translate('Profile Editor',
            'Masstagging Profile'))

        self._desc = QLineEdit()

        self.listbox = ListBox()

        self.okcancel = OKCancel()
        self.okcancel.ok.setDefault(True)

        self.buttonlist = ListButtons()

        self.pattern = QLineEdit('%artist% - %album%/%track% - %title%')
        self.pattern.setToolTip(translate('Profile Editor',
            "<p>If no tag information is found in a file, "
            "the tags retrieved using this pattern will be used instead.</p>"))

        self.albumBound = QSpinBox()
        self.albumBound.setRange(0,100)
        self.albumBound.setValue(70)
        self.albumBound.setToolTip(translate('Profile Editor',
            "<p>The artist and album fields will be used in "
            "determining whether an album matches the retrieved one. "
            "Each field will be compared using a fuzzy matching algorithm. "
            "If the resulting average match percentage is greater "
            "or equal than what you specify here it'll be "
            "considered to match.</p>"))

        self.matchFields = QLineEdit('artist, title')
        self.matchFields.setToolTip(translate('Profile Editor',
            '<p>The fields listed here will be used in '
            'determining whether a file matches a retrieved track. '
            'Each field will be compared using a fuzzy matching '
            'algorithm. If the resulting average match '
            'percentage is greater than the "Minimum Percentage" '
            'it\'ll be considered to match.</p>'))

        self.trackBound = QSpinBox()
        self.trackBound.setRange(0,100)
        self.trackBound.setValue(80)

        self.jfdi = QCheckBox(translate('Profile Editor',
            'Brute force unmatched files.'))
        self.jfdi.setToolTip(translate('Profile Editor',
            "<p>Check to enable brute forcing matches. "
            " If a proper match isn't found for a file, "
            'the files will get sorted by filename, '
            'the retrieved tag sources by filename and '
            'corresponding (unmatched) tracks will matched.</p>'))

        self.existing = QCheckBox(translate('Profile Editor',
            'Update empty fields only.'))

        self.grid = QGridLayout()
        self.setLayout(self.grid)

        self.grid.addLayout(create_buddy(
            translate('Profile Editor', '&Name:'), self._name), 0, 0, 1, 2)
        self.grid.addLayout(create_buddy(
            translate('Profile Editor', '&Description'), self._desc), 1, 0, 1, 2)
        self.grid.addWidget(self.listbox, 2, 0)
        self.grid.setRowStretch(2, 1)
        self.grid.addLayout(self.buttonlist, 2, 1)
        self.grid.addLayout(create_buddy(translate('Profile Editor',
                'Pattern to match filenames against.'),
            self.pattern, QVBoxLayout()), 3, 0, 1, 2)
        self.grid.addLayout(create_buddy(translate('Profile Editor',
                'Minimum percentage required for album matches.'),
            self.albumBound), 4, 0, 1, 2)
        self.grid.addLayout(create_buddy(translate('Profile Editor',
                'Match tracks using fields: '),
            self.matchFields, QVBoxLayout()), 5, 0, 1, 2)
        self.grid.addLayout(create_buddy(translate('Profile Editor',
                'Minimum percentage required for track match.'),
            self.trackBound), 6, 0, 1, 2)
        self.grid.addWidget(self.jfdi, 7, 0, 1, 2)
        self.grid.addWidget(self.existing, 8, 0, 1, 2)
        self.grid.addLayout(self.okcancel, 9, 0, 1, 2)

        connect = lambda control, signal, slot: self.connect(
            control, SIGNAL(signal), slot)

        connect(self.okcancel, "ok" , self.okClicked)
        connect(self.okcancel, "cancel",self.close)
        connect(self.buttonlist, "add", self.addClicked)
        connect(self.buttonlist, "edit", self.editClicked)
        connect(self.buttonlist, "moveup", self.moveUp)
        connect(self.buttonlist, "movedown", self.moveDown)
        connect(self.buttonlist, "remove", self.remove)
        connect(self.buttonlist, "duplicate", self.dupClicked)
        connect(self.listbox, "itemDoubleClicked (QListWidgetItem *)",
            self.editClicked)
        connect(self.listbox, "currentRowChanged(int)", self.enableListButtons)

        if profile is not None:
            self.setProfile(profile)
        self.enableListButtons(self.listbox.currentRow())
Пример #12
0
    def __init__(self, controls, parent=None, status=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle("puddletag settings")
        winsettings('settingswin', self)

        built_in = [
            (translate("Settings",
                       'General'), GeneralSettings(controls), controls),
            (translate("Settings",
                       'Confirmations'), confirmations.Settings(), None),
            (translate("Settings", 'Mappings'), TagMappings(), None),
            (translate("Settings", 'Playlist'), Playlist(), None),
            (translate("Settings", 'Colours'), ColorEdit(), status['table']),
            (translate("Settings",
                       'Genres'), genres.Genres(status=status), None),
            (translate("Settings",
                       'Tags'), Tags(status=status), status['table']),
            (translate("Settings", 'Plugins'), PluginConfig(), None),
            (translate("Settings", 'Shortcuts'),
             ActionEditorDialog(status['actions']), None),
        ]

        d = dict(enumerate(built_in))

        i = len(d)
        for control in controls:
            if hasattr(control, SETTINGSWIN):
                c = getattr(control, SETTINGSWIN)(status=status)
                d[i] = [c.title, c, control]
                i += 1
        for c in config_widgets:
            d[i] = [c.title, c(status=status), None]
            i += 1

        self._widgets = d

        self.listbox = SettingsList()
        self.model = ListModel(d)
        self.listbox.setModel(self.model)

        self.stack = QStackedWidget()
        self.stack.setFrameStyle(QFrame.StyledPanel)

        self.grid = QGridLayout()
        self.grid.addWidget(self.listbox)
        self.grid.addWidget(self.stack, 0, 1)
        self.grid.setColumnStretch(1, 2)
        self.setLayout(self.grid)

        self.connect(self.listbox, SIGNAL("selectionChanged"), self.showOption)

        selection = QItemSelection()
        self.selectionModel = QItemSelectionModel(self.model)
        index = self.model.index(0, 0)
        selection.select(index, index)
        self.listbox.setSelectionModel(self.selectionModel)
        self.selectionModel.select(selection, QItemSelectionModel.Select)

        self.okbuttons = OKCancel()
        self.okbuttons.ok.setDefault(True)
        self.grid.addLayout(self.okbuttons, 1, 0, 1, 2)

        self.connect(self.okbuttons, SIGNAL("ok"), self.saveSettings)
        self.connect(self, SIGNAL("accepted"), self.saveSettings)
        self.connect(self.okbuttons, SIGNAL("cancel"), self.close)
Пример #13
0
    def restoreSettings(self):
        scts = action_shortcuts.create_action_shortcuts(
            mainwin.funcs.applyaction, self)

        self.addShortcuts('&Actions', scts)

        connect_actions(scts, PuddleDock._controls)

        cparser = PuddleConfig()
        settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat)
        
        gensettings = {}
        controls = PuddleDock._controls.values()
        for control in controls:
            if hasattr(control, 'loadSettings'):
                control.loadSettings()
            if hasattr(control, 'gensettings'):
                t = load_gen_settings(control.gensettings)
                gensettings[control] = dict(t)

        for control, val in gensettings.items():
            control.applyGenSettings(val, 0)
        
        self._lastdir = [encode_fn(cparser.get(
            'main', 'lastfolder', constants.HOMEDIR))]

        mapping = {
            u'VorbisComment':
                {u'date': u'year',
                u'tracknumber': u'track',
                u'musicbrainz_albumid': u'mbrainz_album_id',
                u'musicbrainz_artistid': u'mbrainz_artist_id',
                u'musicbrainz_trackid': u'mbrainz_track_id'},
            u'MP4':
                {u'MusicBrainz Track Id': u'mbrainz_track_id',
                u'MusicBrainz Artist Id': u'mbrainz_artist_id',
                u'MusicBrainz Album Id': u'mbrainz_album_id'},
            u'ID3':
                {u'ufid:http://musicbrainz.org': u'mbrainz_track_id',
                u'MusicBrainz Album Id': u'mbrainz_album_id',
                u'MusicBrainz Artist Id': u'mbrainz_artist_id'},
            u'APEv2':
                {u'musicbrainz_albumid': u'mbrainz_album_id',
                u'musicbrainz_artistid': u'mbrainz_artist_id',
                u'musicbrainz_trackid': u'mbrainz_track_id'}}

        filepath = os.path.join(cparser.savedir, 'mappings')
        audioinfo.setmapping(audioinfo.loadmapping(filepath, mapping))
        status['genres'] = genres.load_genres()

        connect_controls(controls + [mainwin.previews.obj])

        cover_pattern = cparser.get('tags', 'cover_pattern', 'folder')
        status['cover_pattern'] = cover_pattern

        winsettings('mainwin', self)
        if cparser.get("main", "maximized", True):
            self.showMaximized()
        
        QApplication.processEvents()

        if constants.FS_ENC == "ascii":
            QMessageBox.warning(self, "puddletag", translate("Errors",
                "Your filesystem encoding was detected as <b>ASCII</b>. <br />"
                "You won't be able to rename files using accented, <br />"
                " cyrillic or any characters outside the ASCII alphabet."))
        
        for control, val in gensettings.items():
            control.applyGenSettings(val, 1)

        h = self._table.horizontalHeader()
        h.restoreState(settings.value('table/header').toByteArray())
        self.restoreState(settings.value('main/state').toByteArray())
        
        confirmations.load()
        shortcutsettings.ActionEditorDialog._loadSettings(status['actions'])
        update_settings()

        QApplication.processEvents()
Пример #14
0
    def __init__(self, parent=None):
        QDialog.__init__(self,parent)
        winsettings('setdialog', self)
        vbox = QVBoxLayout()
        self._previndex = 0
        self.setscombo = QComboBox()
        setlabel = QLabel('&Sets')
        setlabel.setBuddy(self.setscombo)
        vbox.addWidget(setlabel)

        comboadd = QToolButton()
        comboadd.setIcon(QIcon(':/filenew.png'))
        comboadd.setToolTip('Add set')
        self.connect(comboadd, SIGNAL('clicked()'), self.addSet)

        hbox = QHBoxLayout()
        hbox.addWidget(self.setscombo)
        hbox.addWidget(comboadd)
        
        vbox.addLayout(hbox)
        
        conditions = QLabel('&Conditions')
        vbox.addWidget(conditions)
        
        self.listbox = ListBox()
        conditions.setBuddy(self.listbox)
        listbuttons = ListButtons()
        
        listhbox = QHBoxLayout()
        listhbox.addWidget(self.listbox)
        listhbox.addLayout(listbuttons)
        vbox.addLayout(listhbox)

        label = QLabel('Retrieve values via: ')
        self.maintag = QComboBox()
        self.maintag.addItems(['artist', 'title', 'genre', 'album', 'year'])
        maintaghbox = QHBoxLayout()
        maintaghbox.addWidget(label)
        maintaghbox.addWidget(self.maintag)
        maintaghbox.addStretch()
        vbox.addLayout(maintaghbox)
        
        dispformat = QLabel('Display Format')
        vbox.addWidget(dispformat)
        self.texts = [QLineEdit(), QLineEdit()]
        t = ['Original', 'Duplicates']
        for i, text in enumerate(self.texts):
            label = QLabel(t[i])
            label.setBuddy(text)
            dispbox = QHBoxLayout()
            dispbox.addWidget(label)
            dispbox.addWidget(text)
            vbox.addLayout(dispbox)

        okcancel = OKCancel()
        vbox.addLayout(okcancel)
        self.connect(okcancel, SIGNAL('ok'), self.okClicked)
        self.connect(okcancel, SIGNAL('cancel'), self.cancelClicked)
        self.setLayout(vbox)

        self.fill(loadsets())
        listbuttons.connectToWidget(self)
Пример #15
0
    def restoreSettings(self):
        scts = action_shortcuts.create_action_shortcuts(
            mainwin.funcs.applyaction, self)

        self.addShortcuts('&Actions', scts)

        connect_actions(scts, PuddleDock._controls)

        cparser = PuddleConfig()
        settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat)

        gensettings = {}
        controls = PuddleDock._controls.values()
        for control in controls:
            if hasattr(control, 'loadSettings'):
                control.loadSettings()
            if hasattr(control, 'gensettings'):
                t = load_gen_settings(control.gensettings)
                gensettings[control] = dict(t)

        for control, val in gensettings.items():
            control.applyGenSettings(val, 0)

        self._lastdir = [
            encode_fn(cparser.get('main', 'lastfolder', constants.HOMEDIR))
        ]

        mapping = {
            u'VorbisComment': {
                u'date': u'year',
                u'tracknumber': u'track',
                u'musicbrainz_albumid': u'mbrainz_album_id',
                u'musicbrainz_artistid': u'mbrainz_artist_id',
                u'musicbrainz_trackid': u'mbrainz_track_id'
            },
            u'MP4': {
                u'MusicBrainz Track Id': u'mbrainz_track_id',
                u'MusicBrainz Artist Id': u'mbrainz_artist_id',
                u'MusicBrainz Album Id': u'mbrainz_album_id'
            },
            u'ID3': {
                u'ufid:http://musicbrainz.org': u'mbrainz_track_id',
                u'MusicBrainz Album Id': u'mbrainz_album_id',
                u'MusicBrainz Artist Id': u'mbrainz_artist_id'
            },
            u'APEv2': {
                u'musicbrainz_albumid': u'mbrainz_album_id',
                u'musicbrainz_artistid': u'mbrainz_artist_id',
                u'musicbrainz_trackid': u'mbrainz_track_id'
            }
        }

        filepath = os.path.join(cparser.savedir, 'mappings')
        audioinfo.setmapping(audioinfo.loadmapping(filepath, mapping))
        status['genres'] = genres.load_genres()

        connect_controls(controls + [mainwin.previews.obj])

        cover_pattern = cparser.get('tags', 'cover_pattern', 'folder')
        status['cover_pattern'] = cover_pattern

        winsettings('mainwin', self)
        if cparser.get("main", "maximized", True):
            self.showMaximized()

        QApplication.processEvents()

        if constants.FS_ENC == "ascii":
            QMessageBox.warning(
                self, "puddletag",
                translate(
                    "Errors",
                    "Your filesystem encoding was detected as <b>ASCII</b>. <br />"
                    "You won't be able to rename files using accented, <br />"
                    " cyrillic or any characters outside the ASCII alphabet."))

        for control, val in gensettings.items():
            control.applyGenSettings(val, 1)

        h = self._table.horizontalHeader()
        h.restoreState(settings.value('table/header').toByteArray())
        self.restoreState(settings.value('main/state').toByteArray())

        confirmations.load()
        shortcutsettings.ActionEditorDialog._loadSettings(status['actions'])
        update_settings()

        QApplication.processEvents()
Пример #16
0
    def __init__(self, controls, parent=None, status=None):
        QDialog.__init__(self, parent)
        self.setWindowTitle("puddletag settings")
        winsettings('settingswin', self)

        built_in = [
            (translate("Settings", 'General'),
                GeneralSettings(controls), controls),
            (translate("Settings", 'Confirmations'),
                confirmations.Settings(), None),
            (translate("Settings", 'Mappings'), TagMappings(), None),
            (translate("Settings", 'Playlist'), Playlist(), None),
            (translate("Settings", 'Colours'), ColorEdit(), status['table']),
            (translate("Settings", 'Genres'),
                genres.Genres(status=status), None),
            (translate("Settings", 'Tags'), Tags(status=status),
                status['table']),
            (translate("Settings", 'Plugins'), PluginConfig(), None),
            (translate("Settings", 'Shortcuts'),
                ActionEditorDialog(status['actions']), None),]

        d = dict(enumerate(built_in))
            
        i = len(d)
        for control in controls:
            if hasattr(control, SETTINGSWIN):
                c = getattr(control, SETTINGSWIN)(status=status)
                d[i] = [c.title, c, control]
                i += 1
        for c in config_widgets:
            d[i] = [c.title, c(status=status), None]
            i += 1

        self._widgets = d

        self.listbox = SettingsList()
        self.model = ListModel(d)
        self.listbox.setModel(self.model)

        self.stack = QStackedWidget()
        self.stack.setFrameStyle(QFrame.StyledPanel)

        self.grid = QGridLayout()
        self.grid.addWidget(self.listbox)
        self.grid.addWidget(self.stack, 0, 1)
        self.grid.setColumnStretch(1, 2)
        self.setLayout(self.grid)

        self.connect(self.listbox, SIGNAL("selectionChanged"), self.showOption)

        selection = QItemSelection()
        self.selectionModel= QItemSelectionModel(self.model)
        index = self.model.index(0,0)
        selection.select(index, index)
        self.listbox.setSelectionModel(self.selectionModel)
        self.selectionModel.select(selection, QItemSelectionModel.Select)

        self.okbuttons = OKCancel()
        self.okbuttons.ok.setDefault(True)
        self.grid.addLayout(self.okbuttons, 1,0,1,2)

        self.connect(self.okbuttons,SIGNAL("ok"), self.saveSettings)
        self.connect(self, SIGNAL("accepted"),self.saveSettings)
        self.connect(self.okbuttons,SIGNAL("cancel"), self.close)