Exemple #1
0
    def __init__(self, options, parent=None):
        """options is a list of strings. Each a comma-delimited field list.

        Eg. ['artist, title', 'album, genre']
        """

        QDialog.__init__(self, parent)
        connect = lambda c, signal, s: self.connect(c, SIGNAL(signal), s)
        self.listbox = ListBox()
        self.listbox.setSelectionMode(self.listbox.ExtendedSelection)

        buttons = ListButtons()

        self.listbox.addItems(options)
        hbox = QHBoxLayout()
        hbox.addWidget(self.listbox, 1)

        hbox.addLayout(buttons)

        okcancel = OKCancel()
        vbox = QVBoxLayout()
        vbox.addLayout(hbox)
        vbox.addLayout(okcancel)
        self.setLayout(vbox)

        connect(buttons, "add", self.addPattern)
        connect(buttons, "edit", self.editItem)
        buttons.duplicate.setVisible(False)
        self.connect(okcancel, SIGNAL('ok'), self.applySettings)
        self.connect(okcancel, SIGNAL('cancel'), self.applySettings)
        self.listbox.connectToListButtons(buttons)
        self.listbox.editButton = buttons.edit
        connect(self.listbox, 'itemDoubleClicked(QListWidgetItem *)',
                self._doubleClicked)
Exemple #2
0
    def __init__(self, parent=None, status=None):
        QWidget.__init__(self, parent)
        if status is None:
            self._status = {}
            genres = load_genres()
        else:
            self._status = status
            genres = status['genres']

        self.listbox = ListBox()
        self._itemflags = Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled
        [self.listbox.addItem(self._createItem(z)) for z in genres]

        buttons = ListButtons()
        self.listbox.connectToListButtons(buttons)
        self.listbox.setAutoScroll(False)

        self.connect(buttons, SIGNAL('add'), self.add)
        self.connect(buttons, SIGNAL('edit'), self.edit)

        hbox = QHBoxLayout()
        hbox.addWidget(self.listbox, 1)
        hbox.addLayout(buttons, 0)
        self.setLayout(hbox)
Exemple #3
0
    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)