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)
def __init__(self, load=False, parent=None, buttons=False): super(ShortcutEditor, self).__init__(parent) self._names = [] self._hotkeys = [] self._listbox = ListBox() listbuttons = ListButtons() listbuttons.insertStretch(0) self.connect(listbuttons, SIGNAL('add'), self._addShortcut) self.connect(listbuttons, SIGNAL('edit'), self._editShortcut) self.connect(listbuttons, SIGNAL('duplicate'), self._duplicate) self.connect(self._listbox, SIGNAL('itemDoubleClicked (QListWidgetItem *)'), self._editShortcut) self._listbox.connectToListButtons(listbuttons) hbox = QHBoxLayout() hbox.addLayout(create_buddy('Shortcuts', self._listbox, QVBoxLayout())) hbox.addLayout(listbuttons) okcancel = OKCancel() vbox = QVBoxLayout() vbox.addLayout(hbox) if buttons: vbox.addLayout(okcancel) self.setLayout(vbox) self.connect(okcancel, SIGNAL('ok'), self.okClicked) self.connect(okcancel, SIGNAL('cancel'), self.close) if load: self.loadSettings()
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)
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)
def __init__(self, parent=None, status=None): QWidget.__init__(self, parent) self.emits = ['filter'] self.receives = [] edit = QLineEdit() self.combo = PuddleCombo('filter_text') self.combo.setEditText(u'') self.combo.combo.setLineEdit(edit) hbox = create_buddy(translate("Defaults", "Filter: "), self.combo) go_button = QPushButton(translate('Defaults', 'Go')) hbox.addWidget(go_button) self.setLayout(hbox) emit_filter = lambda: self.emit(SIGNAL('filter'), unicode(edit.text())) self.connect(go_button, SIGNAL('clicked()'), emit_filter) self.connect(edit, SIGNAL('returnPressed()'), emit_filter) self.connect(self.combo.combo, SIGNAL('activated(int)'), lambda i: emit_filter())
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)
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())
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)