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)
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)
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()
def __init__(self, title, controls, parent = None): """title => Dialog's title. controls is a list of 3-element-lists. The three 3-element lists consist of: description => Descriptive label for the control. control_type => One of TEXT, COMBO, CHECKBOX corresponding to a QLineEdit, QComboBox and QCheckBox being created respectively. default => Default arguments. Can be any string for TEXT, Must be a list of strings for COMBO as these will form the items selectable by the combo box. Can be either True or False for CheckBox. A dialog will be created with vertical layout. Like so: <label> <control> <label> <control> When the user has finished editing an 'editingFinished' signal will be emitted containing a list with the new value. The list will consist of the value for each control in the order given. For TEXT it'll a string. COMBO an integer corresponding to the selected index. True or False for CHECK. """ QDialog.__init__(self, parent) vbox = QVBoxLayout() self._controls = [] winsettings(title, self) self.setWindowTitle(translate("WebDB", 'Configure: %s') % title) for desc, ctype, default in controls: if ctype == TEXT: control = QLineEdit(default) vbox.addLayout(create_buddy(desc, control)) elif ctype == COMBO: control = QComboBox() control.addItems(default[0]) control.setCurrentIndex(default[1]) label = QLabel(desc) label.setBuddy(control) vbox.addWidget(label) vbox.addWidget(control) elif ctype == CHECKBOX: control = QCheckBox(desc) if default: control.setCheckState(Qt.Checked) else: control.setCheckState(Qt.Unchecked) vbox.addWidget(control) elif ctype == SPINBOX: control = QSpinBox() control.setMinimum(default[0]) control.setMaximum(default[1]) control.setValue(default[2]) vbox.addLayout(create_buddy(desc, control)) self._controls.append(control) okcancel = OKCancel() self.connect(okcancel, SIGNAL('ok'), self.okClicked) self.connect(okcancel, SIGNAL('cancel'), self.close) vbox.addLayout(okcancel) vbox.addStretch() self.setLayout(vbox)
def __init__(self, parent=None, row=None, files=None, preview_mode=False, artwork=True, status=None): if status is None: status = {'cover_pattern': 'folder'} self.status = status QDialog.__init__(self, parent) winsettings('extendedtags', self) self.get_fieldlist = [] self.previewMode = preview_mode add = QColor.fromRgb(255, 255, 0) edit = QColor.fromRgb(0, 255, 0) remove = QColor.fromRgb(255, 0, 0) self._colors = {ADD: QBrush(add), EDIT: QBrush(edit), REMOVE: QBrush(remove)} self.table = QTableWidget(0, 2, self) self.table.setVerticalHeader(VerticalHeader()) self.table.verticalHeader().setVisible(False) self.table.setSortingEnabled(True) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setHorizontalHeaderLabels([ translate('Extended Tags', 'Field'), translate('Extended Tags', 'Value')]) header = self.table.horizontalHeader() header.setVisible(True) header.setSortIndicatorShown (True) header.setStretchLastSection (True) header.setSortIndicator (0, Qt.AscendingOrder) self.piclabel = PicWidget(buttons = True) self.connect(self.piclabel, SIGNAL('imageChanged'), self._imageChanged) if not isinstance(self.piclabel.removepic, QAction): self.connect(self.piclabel.removepic, SIGNAL('clicked()'), self.removePic) else: self.connect(self.piclabel.removepic, SIGNAL('triggered()'), self.removePic) if row >= 0 and files: buttons = MoveButtons(files, row) self.connect(buttons, SIGNAL('indexChanged'), self._prevnext) buttons.setVisible(True) else: buttons = MoveButtons([], row) buttons.setVisible(False) self._files = files self.okcancel = OKCancel() self.okcancel.insertWidget(0, buttons) self._reset = QToolButton() self._reset.setToolTip(translate('Extended Tags', 'Resets the selected fields to their original value.')) self._reset.setIcon(get_icon('edit-undo', ':/undo.png')) self.connect(self._reset, SIGNAL('clicked()'), self.resetFields) self.listbuttons = ListButtons() self.listbuttons.layout().addWidget(self._reset) self.listbuttons.moveup.hide() self.listbuttons.movedown.hide() listframe = QFrame() listframe.setFrameStyle(QFrame.Box) hbox = QHBoxLayout() hbox.addWidget(self.table, 1) hbox.addLayout(self.listbuttons, 0) listframe.setLayout(hbox) layout = QVBoxLayout() if artwork: imageframe = QFrame() imageframe.setFrameStyle(QFrame.Box) vbox = QVBoxLayout() vbox.setMargin(0) vbox.addWidget(self.piclabel) vbox.addStretch() vbox.addStrut(0) imageframe.setLayout(vbox) hbox = QHBoxLayout() hbox.addWidget(listframe, 1) hbox.addSpacing(4) hbox.addWidget(imageframe) hbox.addStrut(1) layout.addLayout(hbox) else: layout.addWidget(listframe) layout.addLayout(self.okcancel) self.setLayout(layout) self.connect(self.okcancel, SIGNAL("cancel"), self.closeMe) self.connect(self.table, SIGNAL("itemDoubleClicked(QTableWidgetItem *)"), self.editField) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self._checkListBox) self.connect(self.okcancel, SIGNAL("ok"), self.okClicked) clicked = SIGNAL('clicked()') self.connect(self.listbuttons, SIGNAL('edit'), self.editField) self.connect(self.listbuttons.add, clicked, self.addField) self.connect(self.listbuttons.remove, clicked, self.removeField) self.connect(self.listbuttons, SIGNAL('duplicate'), self.duplicate) self.setMinimumSize(450, 350) self.canceled = False self.filechanged = False if row >= 0 and files: self._prevnext(row) else: self.loadFiles(files)
def __init__(self, parent=None, minval=0, numtracks = 0, enablenumtracks = False): QDialog.__init__(self,parent) self.setWindowTitle( translate('Autonumbering Wizard', "Autonumbering Wizard")) winsettings('autonumbering', self) def hbox(*widgets): box = QHBoxLayout() [box.addWidget(z) for z in widgets] box.addStretch() return box vbox = QVBoxLayout() self._start = QSpinBox() self._start.setValue(minval) self._start.setMaximum(65536) startlabel = QLabel(translate('Autonumbering Wizard', "&Start: ")) startlabel.setBuddy(self._start) vbox.addLayout(hbox(startlabel, self._start)) self._padlength = QSpinBox() self._padlength.setValue(1) self._padlength.setMaximum(65535) self._padlength.setMinimum(1) label = QLabel(translate('Autonumbering Wizard', 'Max length after padding with zeroes: ')) label.setBuddy(self._padlength) vbox.addLayout(hbox(label, self._padlength)) self._separator = QCheckBox(translate('Autonumbering Wizard', "Add track &separator ['/']: Number of tracks")) self._numtracks = QSpinBox() self._numtracks.setEnabled(False) self._numtracks.setMaximum(65535) if numtracks: self._numtracks.setValue(numtracks) self._restart_numbering = QCheckBox(translate('Autonumbering Wizard', "&Restart numbering at each directory.")) self.connect(self._restart_numbering, SIGNAL("stateChanged(int)"), self.enableNumTracks) vbox.addLayout(hbox(self._separator, self._numtracks)) vbox.addWidget(self._restart_numbering) okcancel = OKCancel() vbox.addLayout(okcancel) self.setLayout(vbox) self.connect(okcancel,SIGNAL('ok'), self.emitValuesAndSave) self.connect(okcancel,SIGNAL('cancel'),self.close) self.connect(self._separator, SIGNAL("stateChanged(int)"), lambda v: self._numtracks.setEnabled(v == Qt.Checked)) self._separator.setChecked(enablenumtracks) self._loadSettings()
def __init__(self, title, controls, parent=None): """title => Dialog's title. controls is a list of 3-element-lists. The three 3-element lists consist of: description => Descriptive label for the control. control_type => One of TEXT, COMBO, CHECKBOX corresponding to a QLineEdit, QComboBox and QCheckBox being created respectively. default => Default arguments. Can be any string for TEXT, Must be a list of strings for COMBO as these will form the items selectable by the combo box. Can be either True or False for CheckBox. A dialog will be created with vertical layout. Like so: <label> <control> <label> <control> When the user has finished editing an 'editingFinished' signal will be emitted containing a list with the new value. The list will consist of the value for each control in the order given. For TEXT it'll a string. COMBO an integer corresponding to the selected index. True or False for CHECK. """ QDialog.__init__(self, parent) vbox = QVBoxLayout() self._controls = [] winsettings(title, self) self.setWindowTitle(translate("WebDB", 'Configure: %s') % title) for desc, ctype, default in controls: if ctype == TEXT: control = QLineEdit(default) vbox.addLayout(create_buddy(desc, control)) elif ctype == COMBO: control = QComboBox() control.addItems(default[0]) control.setCurrentIndex(default[1]) label = QLabel(desc) label.setBuddy(control) vbox.addWidget(label) vbox.addWidget(control) elif ctype == CHECKBOX: control = QCheckBox(desc) if default: control.setCheckState(Qt.Checked) else: control.setCheckState(Qt.Unchecked) vbox.addWidget(control) elif ctype == SPINBOX: control = QSpinBox() control.setMinimum(default[0]) control.setMaximum(default[1]) control.setValue(default[2]) vbox.addLayout(create_buddy(desc, control)) self._controls.append(control) okcancel = OKCancel() self.connect(okcancel, SIGNAL('ok'), self.okClicked) self.connect(okcancel, SIGNAL('cancel'), self.close) vbox.addLayout(okcancel) vbox.addStretch() self.setLayout(vbox)
def __init__(self, parent=None, minval=0, numtracks = 0, enablenumtracks = False): QDialog.__init__(self,parent) self.setWindowTitle( translate('Autonumbering Wizard', "Autonumbering Wizard")) winsettings('autonumbering', self) def hbox(*widgets): box = QHBoxLayout() [box.addWidget(z) for z in widgets] box.addStretch() return box vbox = QVBoxLayout() self._start = QSpinBox() self._start.setValue(minval) self._start.setMaximum(65536) startlabel = QLabel(translate('Autonumbering Wizard', "&Start: ")) startlabel.setBuddy(self._start) vbox.addLayout(hbox(startlabel, self._start)) self._padlength = QSpinBox() self._padlength.setValue(1) self._padlength.setMaximum(65535) self._padlength.setMinimum(1) label = QLabel(translate('Autonumbering Wizard', 'Max length after padding with zeroes: ')) label.setBuddy(self._padlength) vbox.addLayout(hbox(label, self._padlength)) self._separator = QCheckBox(translate('Autonumbering Wizard', "Add track &separator ['/']: Number of tracks")) self._numtracks = QSpinBox() self._numtracks.setEnabled(False) self._numtracks.setMaximum(65535) if numtracks: self._numtracks.setValue(numtracks) self._restart_numbering = QCheckBox(translate('Autonumbering Wizard', "&Restart numbering at each directory group.")) self.connect(self._restart_numbering, SIGNAL("stateChanged(int)"), self.showDirectorySplittingOptions) vbox.addLayout(hbox(self._separator, self._numtracks)) vbox.addWidget(self._restart_numbering) self.custom_numbering_widgets = [] label = QLabel(translate('Autonumbering Wizard', "Group tracks using pattern:: ")) self.grouping = QLineEdit() label.setBuddy(self.grouping) vbox.addLayout(hbox(label, self.grouping)) self.custom_numbering_widgets.extend([label, self.grouping]) label = QLabel(translate('Autonumbering Wizard', "Output field: ")) self.output_field = QComboBox() label.setBuddy(self.output_field) self.output_field.setEditable(True) completer = self.output_field.completer() completer.setCaseSensitivity(Qt.CaseSensitive) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.output_field.setCompleter(completer) self.output_field.addItems(gettaglist()) vbox.addLayout(hbox(label, self.output_field)) self.custom_numbering_widgets.extend([label, self.output_field]) self.count_by_group = QCheckBox(translate(u'Autonumbering Wizard', u'Increase counter only on group change')) vbox.addWidget(self.count_by_group) self.custom_numbering_widgets.append(self.count_by_group) okcancel = OKCancel() vbox.addLayout(okcancel) self.setLayout(vbox) self.connect(okcancel,SIGNAL('ok'), self.emitValuesAndSave) self.connect(okcancel,SIGNAL('cancel'),self.close) self.connect(self._separator, SIGNAL("stateChanged(int)"), lambda v: self._numtracks.setEnabled(v == Qt.Checked)) # self.connect(self._restart_numbering, SIGNAL("stateChanged(int)"), # self.showDirectorySplittingOptions) self._separator.setChecked(enablenumtracks) self._loadSettings()
def __init__(self, parent=None, row=None, files=None, preview_mode=False, artwork=True, status=None): if status is None: status = {'cover_pattern': 'folder'} self.status = status QDialog.__init__(self, parent) winsettings('extendedtags', self) self.get_fieldlist = [] self.previewMode = preview_mode add = QColor.fromRgb(255, 255, 0) edit = QColor.fromRgb(0, 255, 0) remove = QColor.fromRgb(255, 0, 0) self._colors = { ADD: QBrush(add), EDIT: QBrush(edit), REMOVE: QBrush(remove) } self.table = QTableWidget(0, 2, self) self.table.setVerticalHeader(VerticalHeader()) self.table.verticalHeader().setVisible(False) self.table.setSortingEnabled(True) self.table.setSelectionBehavior(QAbstractItemView.SelectRows) self.table.setHorizontalHeaderLabels([ translate('Extended Tags', 'Field'), translate('Extended Tags', 'Value') ]) header = self.table.horizontalHeader() header.setVisible(True) header.setSortIndicatorShown(True) header.setStretchLastSection(True) header.setSortIndicator(0, Qt.AscendingOrder) self.piclabel = PicWidget(buttons=True) self.connect(self.piclabel, SIGNAL('imageChanged'), self._imageChanged) if not isinstance(self.piclabel.removepic, QAction): self.connect(self.piclabel.removepic, SIGNAL('clicked()'), self.removePic) else: self.connect(self.piclabel.removepic, SIGNAL('triggered()'), self.removePic) if row >= 0 and files: buttons = MoveButtons(files, row) self.connect(buttons, SIGNAL('indexChanged'), self._prevnext) buttons.setVisible(True) else: buttons = MoveButtons([], row) buttons.setVisible(False) self._files = files self.okcancel = OKCancel() self.okcancel.insertWidget(0, buttons) self._reset = QToolButton() self._reset.setToolTip( translate('Extended Tags', 'Resets the selected fields to their original value.')) self._reset.setIcon(get_icon('edit-undo', ':/undo.png')) self.connect(self._reset, SIGNAL('clicked()'), self.resetFields) self.listbuttons = ListButtons() self.listbuttons.layout().addWidget(self._reset) self.listbuttons.moveup.hide() self.listbuttons.movedown.hide() listframe = QFrame() listframe.setFrameStyle(QFrame.Box) hbox = QHBoxLayout() hbox.addWidget(self.table, 1) hbox.addLayout(self.listbuttons, 0) listframe.setLayout(hbox) layout = QVBoxLayout() if artwork: imageframe = QFrame() imageframe.setFrameStyle(QFrame.Box) vbox = QVBoxLayout() vbox.setMargin(0) vbox.addWidget(self.piclabel) vbox.addStretch() vbox.addStrut(0) imageframe.setLayout(vbox) hbox = QHBoxLayout() hbox.addWidget(listframe, 1) hbox.addSpacing(4) hbox.addWidget(imageframe) hbox.addStrut(1) layout.addLayout(hbox) else: layout.addWidget(listframe) layout.addLayout(self.okcancel) self.setLayout(layout) self.connect(self.okcancel, SIGNAL("cancel"), self.closeMe) self.connect(self.table, SIGNAL("itemDoubleClicked(QTableWidgetItem *)"), self.editField) self.connect(self.table, SIGNAL("itemSelectionChanged()"), self._checkListBox) self.connect(self.okcancel, SIGNAL("ok"), self.okClicked) clicked = SIGNAL('clicked()') self.connect(self.listbuttons, SIGNAL('edit'), self.editField) self.connect(self.listbuttons.add, clicked, self.addField) self.connect(self.listbuttons.remove, clicked, self.removeField) self.connect(self.listbuttons, SIGNAL('duplicate'), self.duplicate) self.setMinimumSize(450, 350) self.canceled = False self.filechanged = False if row >= 0 and files: self._prevnext(row) else: self.loadFiles(files)
def __init__(self, parent=None, minval=0, numtracks=0, enablenumtracks=False): QDialog.__init__(self, parent) self.setWindowTitle( translate('Autonumbering Wizard', "Autonumbering Wizard")) winsettings('autonumbering', self) def hbox(*widgets): box = QHBoxLayout() [box.addWidget(z) for z in widgets] box.addStretch() return box vbox = QVBoxLayout() self._start = QSpinBox() self._start.setValue(minval) self._start.setMaximum(65536) startlabel = QLabel(translate('Autonumbering Wizard', "&Start: ")) startlabel.setBuddy(self._start) vbox.addLayout(hbox(startlabel, self._start)) self._padlength = QSpinBox() self._padlength.setValue(1) self._padlength.setMaximum(65535) self._padlength.setMinimum(1) label = QLabel( translate('Autonumbering Wizard', 'Max length after padding with zeroes: ')) label.setBuddy(self._padlength) vbox.addLayout(hbox(label, self._padlength)) self._separator = QCheckBox( translate('Autonumbering Wizard', "Add track &separator ['/']: Number of tracks")) self._numtracks = QSpinBox() self._numtracks.setEnabled(False) self._numtracks.setMaximum(65535) if numtracks: self._numtracks.setValue(numtracks) self._restart_numbering = QCheckBox( translate('Autonumbering Wizard', "&Restart numbering at each directory group.")) self.connect(self._restart_numbering, SIGNAL("stateChanged(int)"), self.showDirectorySplittingOptions) vbox.addLayout(hbox(self._separator, self._numtracks)) vbox.addWidget(self._restart_numbering) self.custom_numbering_widgets = [] label = QLabel( translate('Autonumbering Wizard', "Group tracks using pattern:: ")) self.grouping = QLineEdit() label.setBuddy(self.grouping) vbox.addLayout(hbox(label, self.grouping)) self.custom_numbering_widgets.extend([label, self.grouping]) label = QLabel(translate('Autonumbering Wizard', "Output field: ")) self.output_field = QComboBox() label.setBuddy(self.output_field) self.output_field.setEditable(True) completer = self.output_field.completer() completer.setCaseSensitivity(Qt.CaseSensitive) completer.setCompletionMode(QCompleter.UnfilteredPopupCompletion) self.output_field.setCompleter(completer) self.output_field.addItems(gettaglist()) vbox.addLayout(hbox(label, self.output_field)) self.custom_numbering_widgets.extend([label, self.output_field]) self.count_by_group = QCheckBox( translate(u'Autonumbering Wizard', u'Increase counter only on group change')) vbox.addWidget(self.count_by_group) self.custom_numbering_widgets.append(self.count_by_group) okcancel = OKCancel() vbox.addLayout(okcancel) self.setLayout(vbox) self.connect(okcancel, SIGNAL('ok'), self.emitValuesAndSave) self.connect(okcancel, SIGNAL('cancel'), self.close) self.connect(self._separator, SIGNAL("stateChanged(int)"), lambda v: self._numtracks.setEnabled(v == Qt.Checked)) # self.connect(self._restart_numbering, SIGNAL("stateChanged(int)"), # self.showDirectorySplittingOptions) self._separator.setChecked(enablenumtracks) self._loadSettings()