コード例 #1
0
    def __init__(self, parent=None):
        filename = os.path.join(PuddleConfig().savedir, 'mappings')
        self._edited = deepcopy(audioinfo.mapping)
        self._mappings = audioinfo.mapping

        QWidget.__init__(self, parent)
        tooltip = translate(
            "Mapping Settings",
            '''<ul><li>Tag is the format that the mapping applies to.
            One of <b>ID3, APEv2, MP4, or VorbisComment</b>.
            </li><li>Fields will be mapped from Source to Target,
            meaning that if Source is found in a tag, it'll be
            editable in puddletag using Target.</li>
            <li>Eg. For <b>Tag=VorbisComment, Source=organization,
            and Target=publisher</b> means that writing to the publisher
            field for VorbisComments in puddletag will in actuality
            write to the organization field.</li><li>Mappings for
            tag sources are also supported, just use the name of the
            tag source as Tag, eg. <b>Tag=MusicBrainz,
            Source=artist,Target=performer</b>.</li></ul>''')

        self._table = QTableWidget()
        self._table.setToolTip(tooltip)
        self._table.setColumnCount(3)
        self._table.setHorizontalHeaderLabels([
            translate("Mapping Settings", 'Tag'),
            translate("Mapping Settings", 'Original Field'),
            translate("Mapping Settings", 'Target')
        ])
        header = self._table.horizontalHeader()
        header.setVisible(True)
        self._table.verticalHeader().setVisible(False)
        header.setStretchLastSection(True)
        buttons = ListButtons()
        buttons.connectToWidget(self)
        buttons.moveup.setVisible(False)
        buttons.movedown.setVisible(False)
        self.connect(buttons, SIGNAL('duplicate'), self.duplicate)

        hbox = QHBoxLayout()
        hbox.addWidget(self._table, 1)
        hbox.addLayout(buttons, 0)

        self._setMappings(self._mappings)
        label = QLabel(
            translate("Mapping Settings",
                      '<b>A restart is required to apply these settings.</b>'))
        vbox = QVBoxLayout()
        vbox.addLayout(hbox, 1)
        vbox.addWidget(label)
        self.setLayout(vbox)
コード例 #2
0
    def __init__(self, parent = None):
        filename = os.path.join(PuddleConfig().savedir, 'mappings')
        self._edited = deepcopy(audioinfo.mapping)
        self._mappings = audioinfo.mapping

        QWidget.__init__(self, parent)
        tooltip = translate("Mapping Settings",
            '''<ul><li>Tag is the format that the mapping applies to.
            One of <b>ID3, APEv2, MP4, or VorbisComment</b>.
            </li><li>Fields will be mapped from Source to Target,
            meaning that if Source is found in a tag, it'll be
            editable in puddletag using Target.</li>
            <li>Eg. For <b>Tag=VorbisComment, Source=organization,
            and Target=publisher</b> means that writing to the publisher
            field for VorbisComments in puddletag will in actuality
            write to the organization field.</li><li>Mappings for
            tag sources are also supported, just use the name of the
            tag source as Tag, eg. <b>Tag=MusicBrainz,
            Source=artist,Target=performer</b>.</li></ul>''')
        
        self._table = QTableWidget()
        self._table.setToolTip(tooltip)
        self._table.setColumnCount(3)
        self._table.setHorizontalHeaderLabels([
            translate("Mapping Settings", 'Tag'),
            translate("Mapping Settings", 'Original Field'),
            translate("Mapping Settings", 'Target')])
        header = self._table.horizontalHeader()
        header.setVisible(True)
        self._table.verticalHeader().setVisible(False)
        header.setStretchLastSection(True)
        buttons = ListButtons()
        buttons.connectToWidget(self)
        buttons.moveup.setVisible(False)
        buttons.movedown.setVisible(False)
        self.connect(buttons, SIGNAL('duplicate'), self.duplicate)

        hbox = QHBoxLayout()
        hbox.addWidget(self._table, 1)
        hbox.addLayout(buttons, 0)

        self._setMappings(self._mappings)
        label = QLabel(translate("Mapping Settings",
            '<b>A restart is required to apply these settings.</b>'))
        vbox = QVBoxLayout()
        vbox.addLayout(hbox, 1)
        vbox.addWidget(label)
        self.setLayout(vbox)
コード例 #3
0
ファイル: algwin.py プロジェクト: korala1968/tago
    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)
コード例 #4
0
ファイル: tagpanel.py プロジェクト: korala1968/tago
class SettingsWin(QWidget):
    
    def __init__(self, parent = None, status=None):
        QDialog.__init__(self, parent)
        self.title = translate('Settings', 'Tag Panel')
        self._table = PuddleTable([TITLE, FIELD, ROW],
            [TITLE, FIELD, u'0'], self)
        self._buttons = ListButtons()
        self._buttons.connectToWidget(self._table, add=self.add,
            edit=self.edit, moveup=self._table.moveUp,
            movedown=self._table.moveDown, duplicate=self.duplicate)

        hbox = QHBoxLayout()
        hbox.addWidget(self._table, 1)
        hbox.addLayout(self._buttons, 0)
        self.setLayout(hbox)

        self.connect(self._table, SIGNAL('cellChanged(int,int)'),
            self._checkItem)
        self.connect(self._table, SIGNAL('itemSelectionChanged()'),
            self._enableButtons)
        self.fill()

    def add(self, texts = None):
        table = self._table
        if not texts:
            text = table.text
            rows = []
            for row in table.rows:
                try: rows.append(int(text(row, 2)))
                except (TypeError, ValueError): pass
            row = unicode(max(rows) + 1) if rows else u'1'
            table.add([TITLE, FIELD.lower(), row])
        else:
            table.add(texts)
        item = table.item(table.rowCount() - 1, 0)
        table.setCurrentItem(item)
        table.editItem(item)

    def fill(self):
        d = loadsettings()
        self._old = d
        for row in d:
            for z in d[row]:
                self._table.add(z + (unicode(row),))

    def applySettings(self, control = None):
        texts = self._table.texts
        d = {}
        for row in self._table.rows:
            l = texts(row)
            try:
                l[2] = int(l[2])
            except ValueError:
                raise SettingsError(translate('Tag Panel Settings',
                'All row numbers must be integers.'))
            try:
                d[l[2]].append(l[:-1])
            except KeyError:
                d[l[2]] = [l[:-1]]
        d = dict([(i, d[v]) for i, v in enumerate(sorted(d))]) #consecutive rows
        if self._old == d:
            return
        savesettings(d)
        control.setCombos(d)

    def edit(self):
        self._table.editItem(self._table.currentItem())

    def _checkItem(self, row, column):
        table = self._table
        if column == 2:
            try:
               int(table.text(row, column))
               table.item(row, column).setBackground(TABLEWIDGETBG)
            except ValueError:
                i = table.item(row, column)
                i.setBackground(RED)

    def _enableButtons(self):
        table = self._table
        if table.rowCount() <= 0:
            self._buttons.edit.setEnabled(False)
            self._buttons.duplicate.setEnabled(False)
            self._buttons.remove.setEnabled(False)
        elif self._table.selectedRows():
            self._buttons.edit.setEnabled(True)
            self._buttons.duplicate.setEnabled(True)
            self._buttons.remove.setEnabled(True)

    def duplicate(self):
        table = self._table
        row = table.currentRow()
        if row < 0: return
        self.add(table.texts(row))
コード例 #5
0
ファイル: algwin.py プロジェクト: RaphaelRochet/puddletag
    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)