Example #1
0
    def loadLib(self):
        """Loads the currently selected library.

        Emits 'adddock' signal if successful with a LibraryTree class as its
        widget.
        """
        p = ProgressWin(self, 0,
            translate('MusicLib', 'Loading music library...'), False)
        p.show()
        t = PuddleThread(self._loadLib, self)
        t.start()
        while t.isRunning():
            QApplication.processEvents()
        library = t.retval
        p.close()
        QApplication.processEvents()
        if isinstance(library, basestring):
            error_msg = library
            msg = translate('MusicLib',
                'An error occured while loading the %1 library: <b>%2</b>')
            msg = msg.arg(self.currentlib['name']).arg(error_msg)
            
            QMessageBox.critical(self, translate('Defaults', "Error"),
                msg, QMessageBox.Ok, QMessageBox.NoButton,
                QMessageBox.NoButton)
        else:
            dialog = partial(LibraryDialog, library)
            self.emit(SIGNAL('adddock'),
                translate('MusicLib', 'Music Library'), dialog, RIGHTDOCK)
            self.close()
Example #2
0
    def __init__(self, parent = None, cenwid = None, status=None):
        QFrame.__init__(self, parent)
        self.title = translate('Settings', "Patterns")
        connect = lambda c, signal, s: self.connect(c, SIGNAL(signal), s)
        self.setFrameStyle(QFrame.Box)
        self.listbox = ListBox()
        self.listbox.setSelectionMode(self.listbox.ExtendedSelection)
        buttons = ListButtons()

        self.listbox.addItems(status['patterns'])
        hbox = QHBoxLayout()
        hbox.addWidget(self.listbox)
        self.setLayout(hbox)

        vbox = QVBoxLayout()
        sortlistbox = QPushButton(translate("Pattern Settings", '&Sort'))
        self._sortOrder = Qt.AscendingOrder
        connect(sortlistbox, 'clicked()', self._sortListBox)
        vbox.addWidget(sortlistbox)
        vbox.addLayout(buttons)
        vbox.addStretch()

        hbox.addLayout(vbox)

        connect(buttons, "add", self.addPattern)
        connect(buttons, "edit", self.editItem)
        buttons.duplicate.setVisible(False)
        self.listbox.connectToListButtons(buttons)
        self.listbox.editButton = buttons.edit
        connect(self.listbox, 'itemDoubleClicked(QListWidgetItem *)',
                    self._doubleClicked)
Example #3
0
    def loadLib(self):
        """Loads the currently selected library.

        Emits 'adddock' signal if successful with a LibraryTree class as its
        widget.
        """
        p = ProgressWin(self, 0,
                        translate('MusicLib', 'Loading music library...'),
                        False)
        p.show()
        t = PuddleThread(self._loadLib, self)
        t.start()
        while t.isRunning():
            QApplication.processEvents()
        library = t.retval
        p.close()
        QApplication.processEvents()
        if isinstance(library, basestring):
            error_msg = library
            msg = translate(
                'MusicLib',
                'An error occured while loading the %1 library: <b>%2</b>')
            msg = msg.arg(self.currentlib['name']).arg(error_msg)

            QMessageBox.critical(self, translate('Defaults',
                                                 "Error"), msg, QMessageBox.Ok,
                                 QMessageBox.NoButton, QMessageBox.NoButton)
        else:
            dialog = partial(LibraryDialog, library)
            self.emit(SIGNAL('adddock'), translate('MusicLib',
                                                   'Music Library'), dialog,
                      RIGHTDOCK)
            self.close()
Example #4
0
    def openFile(self, filename=None, dirpath=None):
        """Open the file and fills the textboxes."""
        if not dirpath:
            dirpath = self.lastDir

        if not filename:
            filedlg = QFileDialog()
            filename = unicode(
                filedlg.getOpenFileName(self, 'OpenFolder', dirpath))

        if not filename:
            return True

        try:
            f = open(filename, 'r')
        except (IOError, OSError), detail:
            errormsg = translate(
                'Text File -> Tag',
                "The file <b>%1</b> couldn't be loaded.<br /> "
                "Do you want to choose another?")

            ret = QMessageBox.question(
                self, translate('Text File -> Tag', "Error"),
                translate('Text File -> Tag', errormsg.arg(filename)),
                translate('Text File -> Tag', "&Yes"),
                translate('Text File -> Tag', "&No"))

            if ret == 0:
                return self.openFile()
            else:
                return detail
Example #5
0
    def setReleases(self, releases, files=None):
        from puddlestuff.masstag import find_best
        self.model().setupModelData(releases)
        #FIXME: The expander isn't shown if I don't do this. However
        #I can still click on it...Qt bug probably.
        QApplication.processEvents()

        if files:
            matches = find_best(releases, files, self.albumBound)
            if not matches:
                self.emit(SIGNAL('statusChanged'),
                          translate('WebDB', 'No matching albums were found.'))
            elif len(matches) > 1:
                self.emit(
                    SIGNAL('statusChanged'),
                    translate(
                        'WebDB',
                        'More than one album matches. None will be retrieved.')
                )
            else:
                self.emit(SIGNAL('statusChanged'),
                          translate('WebDB', 'Retrieving album.'))
                model = self.model()
                children = [z.itemData for z in model.rootItem.childItems]
                if children:
                    row = children.index(matches[0][0])
                    index = model.index(row, 0, QModelIndex())
                    x = lambda: self.emitExactMatches(
                        model.rootItem.childItems[row], files)
                    model.retrieve(index, x)
Example #6
0
    def openFile(self, filename=None, dirpath=None):
        """Open the file and fills the textboxes."""
        if not dirpath:
            dirpath = self.lastDir

        if not filename:
            filedlg = QFileDialog()
            filename = unicode(filedlg.getOpenFileName(self,
                'OpenFolder', dirpath))

        if not filename:
            return True

        try:
            f = open(filename, 'r')
        except (IOError, OSError), detail:
            errormsg = translate('Text File -> Tag',
                "The file <b>%1</b> couldn't be loaded.<br /> "
                "Do you want to choose another?")

            ret = QMessageBox.question(self,
                translate('Text File -> Tag', "Error"),
                translate('Text File -> Tag', errormsg.arg(filename)),
                translate('Text File -> Tag', "&Yes"),
                translate('Text File -> Tag', "&No"))

            if ret == 0:
                return self.openFile()
            else:
                return detail
Example #7
0
    def search(self, artist, files=None):
        if files is not None and self.searchby:
            keywords = format_value(files[0], self.searchby)
        else:
            keywords = artist
        keywords = re.sub(r'\s+', self._separator, keywords)

        if self.search_source is None:
            album = self.retrieve(keywords)
            return [album] if album else []

        url = self._search_base.replace('%s', keywords)

        write_log(translate('Mp3tag', 'Retrieving search page: %s') % url)
        set_status(translate('Mp3tag', 'Retrieving search page...'))
        if self.html is None:
            page = get_encoding(urlopen(url), True, 'utf8')[1]
        else:
            page = get_encoding(self.html, True, 'utf8')[1]

        write_log(translate('Mp3tag', 'Parsing search page.'))
        set_status(translate('Mp3tag', 'Parsing search page...'))
        infos = parse_search_page(self.indexformat, page, self.search_source,
                                  url)
        return [(info, []) for info in infos]
Example #8
0
 def setReleases(self, releases, files=None):
     from puddlestuff.masstag import find_best
     self.model().setupModelData(releases)
     #FIXME: The expander isn't shown if I don't do this. However
     #I can still click on it...Qt bug probably.
     QApplication.processEvents()
     
     if files:
         matches = find_best(releases, files, self.albumBound)
         if not matches:
             self.emit(SIGNAL('statusChanged'), translate(
                 'WebDB', 'No matching albums were found.'))
         elif len(matches) > 1:
             self.emit(SIGNAL('statusChanged'), translate(
                 'WebDB', 'More than one album matches. None will be retrieved.'))
         else:
             self.emit(SIGNAL('statusChanged'), translate(
                 'WebDB', 'Retrieving album.'))
             model = self.model()
             children = [z.itemData for z in model.rootItem.childItems]
             if children:
                 row = children.index(matches[0][0])
                 index = model.index(row, 0, QModelIndex())
                 x = lambda: self.emitExactMatches(
                     model.rootItem.childItems[row], files)
                 model.retrieve(index, x)
Example #9
0
 def set_preview_status(value):
     if value:
         preview_status.setText(
             translate("Previews", '<b>Preview Mode: On</b>'))
     else:
         preview_status.setText(
             translate("Previews", 'Preview Mode: Off'))
Example #10
0
    def _dirChanged(self, dirs):
        if not dirs:
            self.setWindowTitle('puddletag')
            return
        
        if isinstance(dirs, basestring):
            dirs = [dirs]

        dirs = [encode_fn(d) for d in dirs]

        if self._lastdir:
            initial = self._lastdir[0]
        else:
            initial = None

        if initial not in dirs:
            initial = dirs[0]

        if isinstance(initial, str):
            initial = initial.decode('utf8', 'replace')
        
        if len(dirs) > 1:
            self.setWindowTitle(translate("Main Window", 'puddletag: %1 + others').arg(initial))
        else:
            self.setWindowTitle(translate("Main Window", 'puddletag: %1').arg(initial))

        self._lastdir = dirs
    def __init__(self, title='Add Action', shortcut=u'', actions=None, names=None, shortcuts=None, parent=None):
        super(Editor, self).__init__(parent)
        self.setWindowTitle(title)

        self._items = {}

        self._name = QLineEdit('Name')
        
        if shortcut and shortcut in shortcuts:
            shortcuts.remove(shortcut)

        self._shortcut = puddleobjects.ShortcutEditor(shortcuts)
        self._shortcut.setText(shortcut)
        clear = QPushButton(translate('Shortcuts', '&Clear'))
        self.connect(clear, SIGNAL('clicked()'), self._shortcut.clear)
        
        if names is None:
            names = []
        self._names = names
        
        self._actionList = ListBox()
        self.connect(self._actionList,
            SIGNAL('itemDoubleClicked (QListWidgetItem *)'), self._addAction)
        self._newActionList = ListBox()
        listbuttons = ListButtons()
        listbuttons.duplicate.hide()
        listbuttons.insertStretch(0)
        self.connect(listbuttons, SIGNAL('add'), self._addAction)

        self._newActionList.connectToListButtons(listbuttons)

        okcancel = OKCancel()
        self.connect(okcancel, SIGNAL('ok'), self.okClicked)
        self.connect(okcancel, SIGNAL('cancel'), self.close)
        self._ok = okcancel.ok
        self.connect(self._name, SIGNAL('textChanged(const QString)'), self.enableOk)
        scut_status = QLabel('')
        self.connect(self._shortcut, SIGNAL('validityChanged'),
            lambda v: scut_status.setText(u'') if v or (not self._shortcut.text()) else
                scut_status.setText(translate('Shortcuts', "Invalid shortcut sequence.")))
        okcancel.insertWidget(0, scut_status)

        hbox = QHBoxLayout()
        hbox.addLayout(
            create_buddy('Actions', self._actionList, QVBoxLayout()), 1)
        hbox.addLayout(listbuttons, 0)
        hbox.addLayout(create_buddy('Actions to run for shortcut',
            self._newActionList, QVBoxLayout()), 1)

        layout = QVBoxLayout()
        layout.addLayout(create_buddy('Shortcut &Name: ', self._name))
        scut_layout = create_buddy('&Keyboard Shortcut: ', self._shortcut)
        scut_layout.addWidget(clear)
        layout.addLayout(scut_layout)
        layout.addLayout(hbox)
        layout.addLayout(okcancel)
        self.setLayout(layout)

        if actions:
            self.setActions(actions)
Example #12
0
    def __init__(self, parent = None):
        QWidget.__init__(self, parent)

        def hbox(*widgets):
            box = QHBoxLayout()
            [box.addWidget(z) for z in widgets]
            box.addStretch()
            return box

        vbox = QVBoxLayout()

        startlabel = QLabel(translate('Autonumbering Wizard', "&Start: "))
        self._start = QSpinBox()
        startlabel.setBuddy(self._start)
        self._start.setValue(1)
        self._start.setMaximum(65536)

        vbox.addLayout(hbox(startlabel, self._start))

        label = QLabel(translate('Autonumbering Wizard', 'Max length after padding with zeroes: '))
        self._padlength = QSpinBox()
        label.setBuddy(self._padlength)
        self._padlength.setValue(1)
        self._padlength.setMaximum(65535)
        self._padlength.setMinimum(1)
        vbox.addLayout(hbox(label, self._padlength))

        self._restart_numbering = QCheckBox(translate('Autonumbering Wizard', "&Restart numbering at each directory."))

        vbox.addWidget(self._restart_numbering)
        vbox.addStretch()

        self.setLayout(vbox)
Example #13
0
    def _dirChanged(self, dirs):
        if not dirs:
            self.setWindowTitle('puddletag')
            return

        if isinstance(dirs, basestring):
            dirs = [dirs]

        dirs = [encode_fn(d) for d in dirs]

        if self._lastdir:
            initial = self._lastdir[0]
        else:
            initial = None

        if initial not in dirs:
            initial = dirs[0]

        if isinstance(initial, str):
            initial = initial.decode('utf8', 'replace')

        if len(dirs) > 1:
            self.setWindowTitle(
                translate("Main Window",
                          'puddletag: %1 + others').arg(initial))
        else:
            self.setWindowTitle(
                translate("Main Window", 'puddletag: %1').arg(initial))

        self._lastdir = dirs
Example #14
0
    def __init__(self, parent=None, cenwid=None, status=None):
        QFrame.__init__(self, parent)
        self.title = translate('Settings', "Patterns")
        connect = lambda c, signal, s: self.connect(c, SIGNAL(signal), s)
        self.setFrameStyle(QFrame.Box)
        self.listbox = ListBox()
        self.listbox.setSelectionMode(self.listbox.ExtendedSelection)
        buttons = ListButtons()

        self.listbox.addItems(status['patterns'])
        hbox = QHBoxLayout()
        hbox.addWidget(self.listbox)
        self.setLayout(hbox)

        vbox = QVBoxLayout()
        sortlistbox = QPushButton(translate("Pattern Settings", '&Sort'))
        self._sortOrder = Qt.AscendingOrder
        connect(sortlistbox, 'clicked()', self._sortListBox)
        vbox.addWidget(sortlistbox)
        vbox.addLayout(buttons)
        vbox.addStretch()

        hbox.addLayout(vbox)

        connect(buttons, "add", self.addPattern)
        connect(buttons, "edit", self.editItem)
        buttons.duplicate.setVisible(False)
        self.listbox.connectToListButtons(buttons)
        self.listbox.editButton = buttons.edit
        connect(self.listbox, 'itemDoubleClicked(QListWidgetItem *)',
                self._doubleClicked)
Example #15
0
    def contextMenuEvent(self, event):

        connect = lambda o,s: self.connect(o, SIGNAL('triggered()'), s)
        
        menu = QMenu(self)
        refresh = QAction(translate("Dirview",
            'Refresh Directory'), self)

        index = self.indexAt(event.pos())
        connect(refresh, lambda: self.model().refresh(index))
        
        header = self.header()
        if self.header().isHidden():
            show_header = QAction(translate("Dirview",
                'Show Header'), self)
            connect(show_header, header.show)
        else:
            show_header = QAction(translate("Dirview",
                'Hide Header'), self)
            connect(show_header, header.hide)
        
        open_dir = QAction(translate(
            'Dirview', 'Open in File Manager'), self)
        connect(open_dir, lambda: self.openExtern(index))
        
        menu.addAction(refresh)
        menu.addAction(show_header)
        menu.addAction(open_dir)

        menu.exec_(event.globalPos())
        super(DirView, self).contextMenuEvent(event)
Example #16
0
    def __init__(self,parent = None, filename = None, clipboard = None):
        QDialog.__init__(self, parent)
        
        self.setWindowTitle(
            translate('Text File -> Tag', "Import tags from text file"))
        winsettings('importwin', self)

        grid = QGridLayout()

        self.label = QLabel(translate('Text File -> Tag', "Text"))
        grid.addWidget(self.label, 0, 0)

        self.label = QLabel(translate('Text File -> Tag', "Tag preview"))
        grid.addWidget(self.label, 0, 2)


        self.file = QTextEdit()
        grid.addWidget(self.file, 1, 0, 1, 2)

        self.tags = QTextEdit()
        grid.addWidget(self.tags,1, 2, 1, 2)
        self.tags.setLineWrapMode(QTextEdit.NoWrap)

        hbox = QHBoxLayout()

        self.patterncombo = QComboBox()
        self.patterncombo.setEditable(True)
        self.patterncombo.setDuplicatesEnabled(False)

        okcancel = OKCancel()
        self.ok = okcancel.ok
        self.cancel = okcancel.cancel

        self.openfile = QPushButton(
            translate('Text File -> Tag', "&Select File"))
        getclip = QPushButton(
            translate('Text File -> Tag', "&Paste Clipboard"))
        self.connect(getclip, SIGNAL('clicked()'), self.openClipBoard)

        hbox.addWidget(self.openfile)
        hbox.addWidget(getclip)
        hbox.addWidget(self.patterncombo,1)
        hbox.addLayout(okcancel)

        grid.addLayout(hbox, 3, 0, 1, 4)
        self.setLayout(grid)

        self.connect(self.openfile,SIGNAL("clicked()"),self.openFile)
        self.connect(self.cancel, SIGNAL("clicked()"),self.close)
        self.connect(self.ok, SIGNAL("clicked()"), self.emitValues)

        if clipboard:
            self.openClipBoard()
            return

        self.lastDir = HOMEDIR

        if filename is not None:
            self.openFile(filename)
Example #17
0
 def __init__(self, parent=None, status=None):
     ButtonsAndList.__init__(self, parent,
         translate('ViewAllFields', 'View All Fields'),
         translate("ViewAllFields", 'Add Field'),
         translate("ViewAllFields", 'Edit fields for "View All Fields"'),
         )
     self.addItems(load_fields())
     self.status = status
Example #18
0
    def __init__(self, parent=None, filename=None, clipboard=None):
        QDialog.__init__(self, parent)

        self.setWindowTitle(
            translate('Text File -> Tag', "Import tags from text file"))
        winsettings('importwin', self)

        grid = QGridLayout()

        self.label = QLabel(translate('Text File -> Tag', "Text"))
        grid.addWidget(self.label, 0, 0)

        self.label = QLabel(translate('Text File -> Tag', "Tag preview"))
        grid.addWidget(self.label, 0, 2)

        self.file = QTextEdit()
        grid.addWidget(self.file, 1, 0, 1, 2)

        self.tags = QTextEdit()
        grid.addWidget(self.tags, 1, 2, 1, 2)
        self.tags.setLineWrapMode(QTextEdit.NoWrap)

        hbox = QHBoxLayout()

        self.patterncombo = QComboBox()
        self.patterncombo.setEditable(True)
        self.patterncombo.setDuplicatesEnabled(False)

        okcancel = OKCancel()
        self.ok = okcancel.ok
        self.cancel = okcancel.cancel

        self.openfile = QPushButton(
            translate('Text File -> Tag', "&Select File"))
        getclip = QPushButton(translate('Text File -> Tag',
                                        "&Paste Clipboard"))
        self.connect(getclip, SIGNAL('clicked()'), self.openClipBoard)

        hbox.addWidget(self.openfile)
        hbox.addWidget(getclip)
        hbox.addWidget(self.patterncombo, 1)
        hbox.addLayout(okcancel)

        grid.addLayout(hbox, 3, 0, 1, 4)
        self.setLayout(grid)

        self.connect(self.openfile, SIGNAL("clicked()"), self.openFile)
        self.connect(self.cancel, SIGNAL("clicked()"), self.close)
        self.connect(self.ok, SIGNAL("clicked()"), self.emitValues)

        if clipboard:
            self.openClipBoard()
            return

        self.lastDir = HOMEDIR

        if filename is not None:
            self.openFile(filename)
Example #19
0
 def enableNumTracks(self, state):
     if state == Qt.Checked:
         self._numtracks.setVisible(False)
         self._separator.setText(translate('Autonumbering Wizard',
         "Add track &separator ['/']"))
     else:
         self._numtracks.setVisible(True)
         self._separator.setText(translate('Autonumbering Wizard',
         "Add track &separator ['/']: Number of tracks"))
Example #20
0
 def __init__(self):
     object.__init__(self)
     self.min_score = 0.80
     self.preferences = [[
         translate("AcoustID", 'Minimum Score'), SPINBOX, [0, 100, 80]
     ], [translate("AcoustID", "AcoustID Key"), TEXT, u""]]
     self.__lasttime = time.time()
     acoustid._send_request = self._send_request
     self.__user_key = ""
    def __init__(self, actions, parent=None):
    
        super(ActionEditorDialog, self).__init__(parent)
        self.actions = actions

        help = QLabel(translate("Shortcut Settings", '<b>Double click a cell in the Shortcut Column' \
            ' to <br />modify the key sequence.</b>'))
        
        self.actionTable = QTableWidget(self)
        self.actionTable.setSelectionBehavior(QTableWidget.SelectRows)
        self.actionTable.setEditTriggers(QTableWidget.DoubleClicked)
        self.actionTable.setColumnCount(2)
        self.actionTable.setHorizontalHeaderLabels(
            [translate("Shortcut Settings", "Description"),
            translate("Shortcut Settings", "Shortcut")]
            )
        self.actionTable.horizontalHeader().setStretchLastSection(True)
        self.actionTable.verticalHeader().hide()
        self.actionTable.setItemDelegate(ActionEditorDelegate(self))
        
        self.connect(self.actionTable, SIGNAL("cellChanged(int, int)"),
                     self.validateAction)
        
        row = 0
        for action in self.actions:
        
            if action.text().isEmpty():
                continue
            
            self.actionTable.insertRow(self.actionTable.rowCount())
            
            item = QTableWidgetItem()
            item.setText(action.text())
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsSelectable)
            self.actionTable.setItem(row, 0, item)
            
            item = QTableWidgetItem()
            item.setText(action.shortcut().toString())
            item.setFlags(Qt.ItemIsEnabled | Qt.ItemIsEditable | Qt.ItemIsSelectable)
            item.oldShortcutText = item.text()
            self.actionTable.setItem(row, 1, item)
            
            row += 1
        
        self.actionTable.resizeColumnsToContents()
                
        mainLayout = QVBoxLayout()
        mainLayout.addWidget(help)
        mainLayout.setMargin(8)
        mainLayout.setSpacing(8)
        mainLayout.addWidget(self.actionTable)
        self.setLayout(mainLayout)
        self._model = self.actionTable.model()
        self._model.edited = False
        self.actionTable.model().edited = False
        
        self.setWindowTitle(translate("Shortcut Settings", "Edit Shortcuts"))
Example #22
0
 def changeInfo(self, info):
     labels = [translate('Plugin Settings', 'Name'),
         translate('Plugin Settings', 'Author'),
         translate('Plugin Settings', 'Description'),
         translate('Plugin Settings', 'Version')]
     properties = [NAME, AUTHOR, DESC, VERSION]
     
     text = u'<br />'.join([u'<b>%s:</b> %s' % (disp, info[prop]) for 
         disp, prop in zip(labels, properties)])
     self.setText(text)
Example #23
0
 def lookup(self):
     button = self.sender()
     if self._startButton.text() != translate('Masstagging', '&Stop'):
         self.__flag.stop = False
         self._log.clear()
         self._startButton.setText(translate('Masstagging', '&Stop'))
         self._start()
     else:
         self._startButton.setText(translate('Masstagging', '&Search'))
         self.__flag.stop = True
Example #24
0
 def __init__(self):
     object.__init__(self)
     self.min_score = 0.80
     self.preferences = [
         [translate("AcoustID", 'Minimum Score'), SPINBOX, [0, 100, 80]],
         [translate("AcoustID", "AcoustID Key"), TEXT, u""]
         ]
     self.__lasttime = time.time()
     acoustid._send_request = self._send_request
     self.__user_key = ""
Example #25
0
 def __init__(self, parent=None, status=None):
     ButtonsAndList.__init__(
         self,
         parent,
         translate('ViewAllFields', 'View All Fields'),
         translate("ViewAllFields", 'Add Field'),
         translate("ViewAllFields", 'Edit fields for "View All Fields"'),
     )
     self.addItems(load_fields())
     self.status = status
Example #26
0
    def __init__(self, controls, parent=None):
        QWidget.__init__(self, parent)
        settings = []
        for control in controls:
            if hasattr(control, 'gensettings'):
                settings.extend(load_gen_settings(control.gensettings, True))
        self._controls = []

        def create_control(desc, val):
            if isinstance(val, bool):
                return SettingsCheckBox(val, desc)
            elif isinstance(val, basestring):
                return SettingsLineEdit(desc, val)

        vbox = QVBoxLayout()
        for desc, val in settings:
            widget = create_control(desc, val)
            vbox.addWidget(widget)
            self._controls.append(widget)

        edit_sort_options = QPushButton(
            translate("GenSettings", '&Edit sort options'))

        self._lang_combo = QComboBox()
        self._lang_combo.addItems([
            translate('GenSettings', '<Autodetect>'),
            translate('GenSettings', 'Default')
        ])
        self._lang_combo.setCurrentIndex(0)

        lang = PuddleConfig().get('main', 'lang', u'auto')
        self._lang_combo.addItems(list(get_languages([TRANSDIR])))

        if lang != u'auto':
            i = self._lang_combo.findText(lang, Qt.MatchFixedString)
            if i > 0:
                self._lang_combo.setCurrentIndex(i)

        self.connect(edit_sort_options, SIGNAL('clicked()'),
                     self.editSortOptions)

        hbox = QHBoxLayout()
        hbox.addWidget(edit_sort_options)
        hbox.addStretch()

        vbox.addLayout(hbox)
        if self._lang_combo.count() > 2:
            vbox.addLayout(
                create_buddy(
                    translate('GenSettings', 'Language (Requires a restart)'),
                    self._lang_combo))
        else:
            self._lang_combo.setCurrentIndex(0)
        vbox.addStretch()
        self.setLayout(vbox)
Example #27
0
    def _start(self):
        mtp = self.profile
        tag_groups = split_files(self._status['selectedfiles'],
            mtp.file_pattern)

        search_msg = translate('Masstagging',
            'An error occured during the search: <b>%s</b>')

        retrieve_msg = translate('Masstagging',
            'An error occured during album retrieval: <b>%s</b>')

        def search_error(error, mtp):
            thread.emit(SIGNAL('statusChanged'),
                search_msg % unicode(error))

        def retrieval_error(error, mtp):
            thread.emit(SIGNAL('statusChanged'),
                retrieve_msg % unicode(error))

        def run_masstag():
            replace_fields = []
            for files in tag_groups:
                mtp.clear()

                
                masstag(mtp, files, self.__flag, search_error,
                    retrieval_error)

                retrieved = merge_tsp_tracks(mtp.profiles)
                ret = match_files(files, retrieved,
                        mtp.track_bound, mtp.fields,
                        mtp.jfdi, mtp.leave_existing, True)[0]

                if ret:
                    thread.emit(SIGNAL('enable_preview_mode'))
                    thread.emit(SIGNAL('setpreview'), ret)

                set_status('<hr width="45%" /><br />')

        def finished(value):
            if not (value is True):
                set_status(translate('Masstagging',
                    '<b>Lookups completed.</b>'))
            self._startButton.setText(translate('Masstagging', '&Search'))
            self.__flag.stop = False

        thread = PuddleThread(run_masstag, self)
        self.connect(thread, SIGNAL('setpreview'), SIGNAL('setpreview'))
        self.connect(thread, SIGNAL('enable_preview_mode'),
            SIGNAL('enable_preview_mode'))
        self.connect(thread, SIGNAL('threadfinished'), finished)
        self.connect(thread, SIGNAL('statusChanged'), set_status)
        
        thread.start()
Example #28
0
    def __init__(self, parent=None):
        QWidget.__init__(self, parent)

        def inttocheck(value):
            if value:
                return Qt.Checked
            return Qt.Unchecked

        cparser = PuddleConfig()

        self.extpattern = QLineEdit()
        self.extpattern.setText(
            cparser.load('playlist', 'extpattern', '%artist% - %title%'))

        self.extinfo = QCheckBox(
            translate("Playlist Settings", '&Write extended info'), self)
        self.connect(self.extinfo, SIGNAL('stateChanged(int)'),
                     self.extpattern.setEnabled)
        self.extinfo.setCheckState(
            inttocheck(cparser.load('playlist', 'extinfo', 1, True)))
        self.extpattern.setEnabled(self.extinfo.checkState())

        self.reldir = QCheckBox(
            translate("Playlist Settings",
                      'Entries &relative to working directory'))
        self.reldir.setCheckState(
            inttocheck(cparser.load('playlist', 'reldir', 0, True)))

        self.windows_separator = QCheckBox(
            translate("Playlist Settings", 'Use windows path separator (\\)'))
        self.windows_separator.setCheckState(
            inttocheck(cparser.load('playlist', 'windows_separator', 0, True)))

        self.filename = QLineEdit()
        self.filename.setText(
            cparser.load('playlist', 'filepattern', 'puddletag.m3u'))
        label = QLabel(translate("Playlist Settings", '&Filename pattern.'))
        label.setBuddy(self.filename)

        hbox = QHBoxLayout()
        hbox.addSpacing(10)
        hbox.addWidget(self.extpattern)

        vbox = QVBoxLayout()
        [
            vbox.addWidget(z)
            for z in (self.extinfo, self.reldir, self.windows_separator, label,
                      self.filename)
        ]
        vbox.insertLayout(1, hbox)
        vbox.addStretch()
        vbox.insertSpacing(3, 5)
        vbox.insertSpacing(5, 5)
        self.setLayout(vbox)
Example #29
0
 def add(self):
     table = self._table
     row = table.rowCount()
     table.insertRow(row)
     for column, v in enumerate([
         translate("Mapping Settings", 'Tag'),
         translate("Mapping Settings", 'Source'),
         translate("Mapping Settings", 'Target')]):
         table.setItem(row, column, QTableWidgetItem(v))
     item = table.item(row, 0)
     table.setCurrentItem(item)
     table.editItem(item)
Example #30
0
    def __init__(self, controls, parent = None):
        QWidget.__init__(self, parent)
        settings = []
        for control in controls:
            if hasattr(control, 'gensettings'):
                settings.extend(load_gen_settings(control.gensettings, True))
        self._controls = []

        def create_control(desc, val):
            if isinstance(val, bool):
                return SettingsCheckBox(val, desc)
            elif isinstance(val, basestring):
                return SettingsLineEdit(desc, val)

        vbox = QVBoxLayout()
        for desc, val in settings:
            widget = create_control(desc, val)
            vbox.addWidget(widget)
            self._controls.append(widget)

        edit_sort_options = QPushButton(
            translate("GenSettings", '&Edit sort options'))

        self._lang_combo = QComboBox()
        self._lang_combo.addItems([translate('GenSettings', '<Autodetect>'),
            translate('GenSettings', 'Default')])
        self._lang_combo.setCurrentIndex(0)

        lang = PuddleConfig().get('main', 'lang', u'auto')
        self._lang_combo.addItems(list(get_languages([TRANSDIR])))

        if lang != u'auto':
            i = self._lang_combo.findText(lang, Qt.MatchFixedString)
            if i > 0:
                self._lang_combo.setCurrentIndex(i)
        
        self.connect(edit_sort_options, SIGNAL('clicked()'), 
            self.editSortOptions)

        hbox = QHBoxLayout()
        hbox.addWidget(edit_sort_options)
        hbox.addStretch()
        
        vbox.addLayout(hbox)
        if self._lang_combo.count() > 2:
            vbox.addLayout(create_buddy(
                translate('GenSettings', 'Language (Requires a restart)'),
                self._lang_combo))
        else:
            self._lang_combo.setCurrentIndex(0)
        vbox.addStretch()
        self.setLayout(vbox)
Example #31
0
 def add(self):
     table = self._table
     row = table.rowCount()
     table.insertRow(row)
     for column, v in enumerate([
             translate("Mapping Settings", 'Tag'),
             translate("Mapping Settings", 'Source'),
             translate("Mapping Settings", 'Target')
     ]):
         table.setItem(row, column, QTableWidgetItem(v))
     item = table.item(row, 0)
     table.setCurrentItem(item)
     table.editItem(item)
Example #32
0
    def showDirectorySplittingOptions(self, state):
        is_checked = state==Qt.Checked
        for widget in self.custom_numbering_widgets:
            widget.setVisible(is_checked)

        if is_checked:
            self._numtracks.setVisible(False)
            self._separator.setText(translate('Autonumbering Wizard',
            "Add track &separator ['/']"))
        else:
            self._numtracks.setVisible(True)
            self._separator.setText(translate('Autonumbering Wizard',
            "Add track &separator ['/']: Number of tracks"))
Example #33
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)
Example #34
0
    def changeInfo(self, info):
        labels = [
            translate('Plugin Settings', 'Name'),
            translate('Plugin Settings', 'Author'),
            translate('Plugin Settings', 'Description'),
            translate('Plugin Settings', 'Version')
        ]
        properties = [NAME, AUTHOR, DESC, VERSION]

        text = u'<br />'.join([
            u'<b>%s:</b> %s' % (disp, info[prop])
            for disp, prop in zip(labels, properties)
        ])
        self.setText(text)
Example #35
0
    def showDirectorySplittingOptions(self, state):
        is_checked = state == Qt.Checked
        for widget in self.custom_numbering_widgets:
            widget.setVisible(is_checked)

        if is_checked:
            self._numtracks.setVisible(False)
            self._separator.setText(
                translate('Autonumbering Wizard',
                          "Add track &separator ['/']"))
        else:
            self._numtracks.setVisible(True)
            self._separator.setText(
                translate('Autonumbering Wizard',
                          "Add track &separator ['/']: Number of tracks"))
Example #36
0
 def loadPlayList(self):
     filedlg = QFileDialog()
     dirname = self._lastdir[0] if self._lastdir else QDir.homePath()
     filename = unicode(filedlg.getOpenFileName(self,
         translate("Playlist", translate("Playlist", 'Select m3u file...')), ))
     if not filename:
         return
     try:
         files = m3u.readm3u(filename)
         self.emit(SIGNAL('loadFiles'), files, None, None, None, filename)
     except (OSError, IOError), e:
         QMessageBox.information(self._table,
             translate("Defaults", 'Error'),
             translate("Playlist", 'An error occured while reading <b>%1</b> (%2)').arg(filename).arg(e.strerror),
             QMessageBox.Ok, QMessageBox.NoButton)
Example #37
0
    def __init__(self, field=None, parent=None, field_list=None, edit=True):

        QDialog.__init__(self, parent)
        self.setWindowTitle(translate('Edit Field', 'Edit Field'))
        winsettings('edit_field', self)

        self.vbox = QVBoxLayout()

        label = QLabel(translate('Edit Field', "&Field"))
        self.tagcombo = QComboBox()
        self.tagcombo.setEditable(True)
        label.setBuddy(self.tagcombo)
        completer = self.tagcombo.completer()
        completer.setCaseSensitivity(Qt.CaseSensitive)
        completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.tagcombo.setCompleter(completer)
        self.tagcombo.addItems(field_list if field_list else gettaglist())

        #Get the previous field
        self.__oldField = field
        label1 = QLabel(translate('Edit Field', "&Value"))
        self.value = TextEdit()
        self.value.setTabChangesFocus(True)
        label1.setBuddy(self.value)

        okcancel = OKCancel()
        okcancel.ok.setText(translate('Edit Field', 'A&dd'))

        if field is not None:
            x = self.tagcombo.findText(field[0])

            if x > -1:
                self.tagcombo.setCurrentIndex(x)
            else:
                self.tagcombo.setEditText(field[0])
            self.value.setPlainText(field[1])
            if edit:
                okcancel.ok.setText(translate('Edit Field', 'E&dit'))

        map(self.vbox.addWidget, [label, self.tagcombo, label1, self.value])

        self.vbox.addLayout(okcancel)
        self.setLayout(self.vbox)

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

        self.value.setFocus() if self.__oldField else self.tagcombo.setFocus()
Example #38
0
    def __init__(self, field=None, parent=None, field_list=None, edit=True):

        QDialog.__init__(self, parent)
        self.setWindowTitle(translate('Edit Field', 'Edit Field'))
        winsettings('edit_field', self)
        
        self.vbox = QVBoxLayout()

        label = QLabel(translate('Edit Field', "&Field"))
        self.tagcombo = QComboBox()
        self.tagcombo.setEditable(True)
        label.setBuddy(self.tagcombo)
        completer = self.tagcombo.completer()
        completer.setCaseSensitivity(Qt.CaseSensitive)
        completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion)
        self.tagcombo.setCompleter(completer)
        self.tagcombo.addItems(field_list if field_list else gettaglist())

        #Get the previous field
        self.__oldField = field
        label1 = QLabel(translate('Edit Field', "&Value"))
        self.value = TextEdit()
        self.value.setTabChangesFocus(True)
        label1.setBuddy(self.value)
        
        okcancel = OKCancel()
        okcancel.ok.setText(translate('Edit Field', 'A&dd'))

        if field is not None:
            x = self.tagcombo.findText(field[0])

            if x > -1:
                self.tagcombo.setCurrentIndex(x)
            else:
                self.tagcombo.setEditText(field[0])
            self.value.setPlainText(field[1])
            if edit:
                okcancel.ok.setText(translate('Edit Field', 'E&dit'))

        map(self.vbox.addWidget, [label, self.tagcombo, label1, self.value])

        self.vbox.addLayout(okcancel)
        self.setLayout(self.vbox)

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

        self.value.setFocus() if self.__oldField else self.tagcombo.setFocus()
Example #39
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)
Example #40
0
 def renameDirs(self, dirs):
     self._table.saveSelection()
     showmessage = True
     dirs = sorted(dirs, dircmp, itemgetter(0))
     for index, (olddir, newdir) in enumerate(dirs):
         try:
             if os.path.exists(newdir) and (olddir != newdir):
                 raise IOError(EEXIST, os.strerror(EEXIST), newdir)
             os.rename(olddir, newdir)
             self._table.changeFolder(olddir, newdir)
             if self._lastdir and olddir in self._lastdir:
                 self._lastdir[self._lastdir.index(olddir)] = newdir
         except (IOError, OSError), detail:
             msg = (
                 translate("Dir Renaming", "I couldn't rename: <i>%1</i> to <b>%2</b> (%3)")
                 .arg(olddir)
                 .arg(newdir)
                 .arg(detail.strerror)
             )
             if index == len(dirs) - 1:
                 dirlen = 1
             else:
                 dirlen = len(dirs)
             if showmessage:
                 ret = errormsg(self, msg, dirlen)
                 if ret is True:
                     showmessage = False
                 elif ret is False:
                     break
Example #41
0
def create_action(win, name, control, command, icon = None, enabled=ALWAYS,
    tooltip=None, shortcut=None, status=None, togglecheck=None,
    checkstate=None, icon_name=None):
    if icon:
        action = QAction(get_icon(icon_name, icon), name, win)
    else:
        action = QAction(name, win)
    action.setEnabled(False)

    if shortcut:
        try:
            action.setShortcut(shortcut)
        except TypeError:
            action.setShortcuts(shortcut)

    if tooltip:
        action.setToolTip(translate('Menus', tooltip))
    
    if togglecheck is not None:
        action.setCheckable(True)
        checked = int(checkstate)
        action.setChecked(bool(checked))

    action.togglecheck = togglecheck
    action.enabled = enabled
    action.command = command
    action.control = control
    action.status = status

    return action
Example #42
0
def remove_tag(tag, parent):
    if status['previewmode']:
        QMessageBox.information(
            parent, 'puddletag',
            translate("Previews",
                      'Disable Preview Mode first to enable tag deletion.'))
        return
    files = status['selectedfiles']
    rows = status['selectedrows']

    def func():
        for row, f in zip(rows, files):
            try:
                _remove_tag(f, tag)
                yield None
            except (IOError, OSError), e:
                filename = f[audioinfo.PATH]
                m = translate(
                    "Defaults",
                    'An error occured while writing to <b>%1</b>. (%2)')
                m = m.arg(filename).arg(e.strerror)
                if row == rows[-1]:
                    yield m, 1
                else:
                    yield m, len(rows)
        status['model'].undolevel += 1
Example #43
0
    def __init__(self,
                 data=None,
                 album_pattern=None,
                 track_pattern='%track% - %title%',
                 tagsource=None,
                 parent=None):
        QtCore.QAbstractItemModel.__init__(self, parent)

        self.mapping = {}
        rootData = map(QtCore.QVariant,
                       [translate("WebDB", 'Retrieved Albums')])
        self.rootItem = RootItem(rootData)

        self._albumPattern = ''
        if album_pattern is None:
            self.albumPattern = default_albumpattern
        else:
            self.albumPattern = album_pattern
        self._sortOrder = ['album', 'artist']
        self._trackPattern = ''
        self.trackPattern = track_pattern
        self.tagsource = tagsource
        icon = QWidget().style().standardIcon
        self.expandedIcon = icon(QStyle.SP_DirOpenIcon)
        self.collapsedIcon = icon(QStyle.SP_DirClosedIcon)

        if data:
            self.setupModelData(data)
Example #44
0
    def closeEvent(self, e):
        preview_msg = translate(
            'Previews', 'Some files have uncommited previews. '
            'These changes will be lost once you exit puddletag. <br />'
            'Do you want to exit without writing those changes?<br />')
        if tagmodel.has_previews(parent=self, msg=preview_msg):
            e.ignore()
            return False
        controls = PuddleDock._controls
        for control in PuddleDock._controls.values():
            if hasattr(control, 'saveSettings'):
                try:
                    control.saveSettings(self)
                except TypeError:
                    control.saveSettings()

        cparser = PuddleConfig()
        settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat)
        if self._lastdir:
            cparser.set('main', 'lastfolder', unicode(self._lastdir[0],
                                                      'utf8'))
        cparser.set("main", "maximized", self.isMaximized())
        settings.setValue('main/state', QVariant(self.saveState()))

        headstate = self._table.horizontalHeader().saveState()
        settings.setValue('table/header', QVariant(headstate))
        genres.save_genres(status['genres'])
        e.accept()
Example #45
0
    def closeEvent(self, e):
        preview_msg = translate('Previews',
            'Some files have uncommited previews. '
            'These changes will be lost once you exit puddletag. <br />'
            'Do you want to exit without writing those changes?<br />')
        if tagmodel.has_previews(parent=self, msg=preview_msg):
            e.ignore()
            return False
        controls = PuddleDock._controls
        for control in PuddleDock._controls.values():
            if hasattr(control, 'saveSettings'):
                try:
                    control.saveSettings(self)
                except TypeError:
                    control.saveSettings()

        cparser = PuddleConfig()
        settings = QSettings(constants.QT_CONFIG, QSettings.IniFormat)
        if self._lastdir:
            cparser.set('main', 'lastfolder', unicode(self._lastdir[0], 'utf8'))
        cparser.set("main", "maximized", self.isMaximized())
        settings.setValue('main/state', QVariant(self.saveState()))

        headstate = self._table.horizontalHeader().saveState()
        settings.setValue('table/header', QVariant(headstate))
        genres.save_genres(status['genres'])
        e.accept()
Example #46
0
    def savePlayList(self):
        tags = status['selectedfiles']
        if not tags:
            tags = status['alltags']
        settings = PuddleConfig()
        try:
            dirname = self._lastdir[0]
        except IndexError:
            dirname = constants.HOMEDIR
        filepattern = settings.get('playlist', 'filepattern', 'puddletag.m3u')
        default = encode_fn(findfunc.tagtofilename(filepattern, tags[0]))
        f = unicode(
            QFileDialog.getSaveFileName(
                self, translate("Playlist", 'Save Playlist...'),
                os.path.join(dirname, default)))
        if f:
            if settings.get('playlist', 'extinfo', 1, True):
                pattern = settings.get('playlist', 'extpattern',
                                       '%artist% - %title%')
            else:
                pattern = None

            reldir = settings.get('playlist', 'reldir', 0, True)
            windows_separator = settings.get('playlist', 'windows_separator',
                                             0, False)
            m3u.exportm3u(tags, f, pattern, reldir, windows_separator)
Example #47
0
    def createStatusBar(self):
        statusbar = self.statusBar()
        statuslabel = QLabel()
        statuslabel.setFrameStyle(QFrame.NoFrame)
        statusbar.addPermanentWidget(statuslabel, 1)
        self._totalstats = QLabel('00 (00:00:00 | 00 MB)')
        self._selectedstats = QLabel('00 (00:00:00 | 00 MB)')
        preview_status = PreviewLabel(
            translate("Previews", 'Preview Mode: Off'))
        statusbar.addPermanentWidget(preview_status, 0)
        statusbar.addPermanentWidget(self._selectedstats, 0)
        statusbar.addPermanentWidget(self._totalstats, 0)

        def set_preview_status(value):
            if value:
                preview_status.setText(
                    translate("Previews", '<b>Preview Mode: On</b>'))
            else:
                preview_status.setText(
                    translate("Previews", 'Preview Mode: Off'))

        def change_preview(value):
            if value:
                self.emit(SIGNAL('enable_preview_mode'))
            else:
                self.emit(SIGNAL('disable_preview_mode'))

        self.connect(preview_status, SIGNAL('valueChanged'), change_preview)
        self.connect(self._table.model(), SIGNAL('previewModeChanged'),
                     set_preview_status)
        statusbar.setMaximumHeight(statusbar.height())
        self.connect(statusbar, SIGNAL("messageChanged (const QString&)"),
                     statuslabel.setText)
Example #48
0
 def retrieval_func():
     try:
         return self.tagsource.retrieve(item.itemData)
     except RetrievalError, e:
         self.emit(SIGNAL("statusChanged"), 
             translate("WebDB", 'An error occured: %1').arg(unicode(e)))
         return None
Example #49
0
 def renameDirs(self, dirs):
     self._table.saveSelection()
     showmessage = True
     dirs = sorted(dirs, dircmp, itemgetter(0))
     for index, (olddir, newdir) in enumerate(dirs):
         try:
             if os.path.exists(newdir) and (olddir != newdir):
                 raise IOError(EEXIST, os.strerror(EEXIST), newdir)
             os.rename(olddir, newdir)
             self._table.changeFolder(olddir, newdir)
             if self._lastdir and olddir in self._lastdir:
                 self._lastdir[self._lastdir.index(olddir)] = newdir
         except (IOError, OSError), detail:
             msg = translate(
                 "Dir Renaming",
                 "I couldn't rename: <i>%1</i> to <b>%2</b> (%3)").arg(
                     olddir).arg(newdir).arg(detail.strerror)
             if index == len(dirs) - 1:
                 dirlen = 1
             else:
                 dirlen = len(dirs)
             if showmessage:
                 ret = errormsg(self, msg, dirlen)
                 if ret is True:
                     showmessage = False
                 elif ret is False:
                     break
Example #50
0
 def createStatusBar(self):
     statusbar = self.statusBar()
     statuslabel = QLabel()
     statuslabel.setFrameStyle(QFrame.NoFrame)
     statusbar.addPermanentWidget(statuslabel, 1)
     self._totalstats = QLabel('00 (00:00:00 | 00 MB)')
     self._selectedstats = QLabel('00 (00:00:00 | 00 MB)')
     preview_status = PreviewLabel(translate("Previews", 'Preview Mode: Off'))
     statusbar.addPermanentWidget(preview_status, 0)
     statusbar.addPermanentWidget(self._selectedstats, 0)
     statusbar.addPermanentWidget(self._totalstats, 0)
     
     def set_preview_status(value):
         if value:
             preview_status.setText(translate("Previews", '<b>Preview Mode: On</b>'))
         else:
             preview_status.setText(translate("Previews", 'Preview Mode: Off'))
     
     def change_preview(value):
         if value:
             self.emit(SIGNAL('enable_preview_mode'))
         else:
             self.emit(SIGNAL('disable_preview_mode'))
     
     self.connect(preview_status, SIGNAL('valueChanged'),
         change_preview)
     self.connect(self._table.model(), SIGNAL('previewModeChanged'),
         set_preview_status)
     statusbar.setMaximumHeight(statusbar.height())
     self.connect(statusbar,SIGNAL("messageChanged (const QString&)"),
         statuslabel.setText)
Example #51
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)
Example #52
0
    def writeTags(self, tagiter, rows=None, previews=None):
        ret = self._write(tagiter, rows, previews)
        if ret is None:
            return

        func, fin, rows = ret
        s = progress(func, translate("Defaults", 'Writing '), len(rows), fin)
        s(self)
Example #53
0
 def writeTags(self, tagiter, rows=None, previews=None):
     ret = self._write(tagiter, rows, previews)
     if ret is None:
         return
     
     func, fin, rows = ret
     s = progress(func, translate("Defaults", 'Writing '), len(rows), fin)
     s(self)
Example #54
0
 def retrieval_func():
     try:
         return self.tagsource.retrieve(item.itemData)
     except RetrievalError, e:
         self.emit(
             SIGNAL("statusChanged"),
             translate("WebDB", 'An error occured: %1').arg(unicode(e)))
         return None
Example #55
0
 def _getDir(self):
     dirname = self._lastdir[0] if self._lastdir else QDir.homePath()
     filedlg = QFileDialog()
     filedlg.setFileMode(filedlg.DirectoryOnly)
     filedlg.setResolveSymlinks(False)
     filename = unicode(filedlg.getExistingDirectory(self,
         translate("Main Window", 'Import directory...'), dirname ,QFileDialog.ShowDirsOnly))
     return filename
Example #56
0
def tooltip(tag, mapping=None):
    """Used to display tags in in a human parseable format."""
    if not tag:
        return translate("WebDB", "<b>Error in pattern</b>")
    mapping = {} if mapping is None else mapping
    tag = dict((mapping.get(k, k), v) for k, v in tag.iteritems()
               if not k.startswith('#'))

    return pprint_tag(tag)