How to use the picard.config.Option function in picard

To help you get started, we’ve selected a few picard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github metabrainz / picard / test / test_config.py View on Github external
def test_var_opt_set_none(self):
        Option("setting", "var_option", set(["a", "b"]))

        # set option to None
        self.config.setting["var_option"] = None
        self.assertEqual(self.config.setting["var_option"], set(["a", "b"]))
github metabrainz / picard / test / test_config.py View on Github external
def test_var_opt_no_config(self):
        Option("setting", "var_option", set(["a", "b"]))

        # test default, nothing in config yet
        self.assertEqual(self.config.setting["var_option"], set(["a", "b"]))
        self.assertIs(type(self.config.setting["var_option"]), set)
github metabrainz / picard / picard / ui / mainwindow.py View on Github external
ui_init = ExtensionPoint(label='ui_init')


def register_ui_init(function):
    ui_init.register(function.__module__, function)


class MainWindow(QtWidgets.QMainWindow, PreserveGeometry):

    defaultsize = QtCore.QSize(780, 560)
    autorestore = False
    selection_updated = QtCore.pyqtSignal(object)

    options = [
        config.Option("persist", "window_state", QtCore.QByteArray()),
        config.Option("persist", "bottom_splitter_state", QtCore.QByteArray()),
        config.BoolOption("persist", "window_maximized", False),
        config.BoolOption("persist", "view_cover_art", True),
        config.BoolOption("persist", "view_toolbar", True),
        config.BoolOption("persist", "view_file_browser", False),
        config.TextOption("persist", "current_directory", ""),
        config.FloatOption("persist", "mediaplayer_playback_rate", 1.0),
        config.IntOption("persist", "mediaplayer_volume", 50),
    ]

    def __init__(self, parent=None):
        super().__init__(parent)
        self.selected_objects = []
        self.ignore_selection_changes = False
        self.toolbar = None
        self.player = None
        self.status_indicators = []
github metabrainz / picard / picard / ui / itemviews.py View on Github external
_file_actions.register(action.__module__, action)


def get_match_color(similarity, basecolor):
    c1 = (basecolor.red(), basecolor.green(), basecolor.blue())
    c2 = (223, 125, 125)
    return QtGui.QColor(
        c2[0] + (c1[0] - c2[0]) * similarity,
        c2[1] + (c1[1] - c2[1]) * similarity,
        c2[2] + (c1[2] - c2[2]) * similarity)


class MainPanel(QtWidgets.QSplitter):

    options = [
        config.Option("persist", "splitter_state", QtCore.QByteArray()),
    ]

    columns = [
        (N_('Title'), 'title'),
        (N_('Length'), '~length'),
        (N_('Artist'), 'artist'),
        (N_('Album Artist'), 'albumartist'),
        (N_('Composer'), 'composer'),
        (N_('Album'), 'album'),
        (N_('Disc Subtitle'), 'discsubtitle'),
        (N_('Track No.'), 'tracknumber'),
        (N_('Disc No.'), 'discnumber'),
        (N_('Catalog No.'), 'catalognumber'),
        (N_('Barcode'), 'barcode'),
        (N_('Media'), 'media'),
        (N_('Genre'), 'genre'),
github metabrainz / picard / picard / ui / options / interface_colors.py View on Github external
if widget is not None:
                widget.setParent(None)
            else:
                delete_items_of_layout(item.layout())


class InterfaceColorsOptionsPage(OptionsPage):

    NAME = "interface_colors"
    TITLE = N_("Colors")
    PARENT = "interface"
    SORT_ORDER = 30
    ACTIVE = True

    options = [
        config.Option("setting", "interface_colors", interface_colors.get_colors()),
    ]

    def __init__(self, parent=None):
        super().__init__(parent)
        self.ui = Ui_InterfaceColorsOptionsPage()
        self.ui.setupUi(self)
        self.new_colors = {}
        self.colors_list = QtWidgets.QVBoxLayout()
        self.ui.colors.setLayout(self.colors_list)

    def update_color_selectors(self):
        if self.colors_list:
            delete_items_of_layout(self.colors_list)

        def color_changed(color_key, color_value):
            interface_colors.set_color(color_key, color_value)
github metabrainz / picard / picard / ui / searchdialog.py View on Github external
if self.file_:
                album = self.file_.parent.album
                self.tagger.move_file_to_nat(track["musicbrainz_recordingid"])
                if album._files == 0:
                    self.tagger.remove_album(album)
            else:
                self.tagger.load_nat(track["musicbrainz_recordingid"], node)


class AlbumSearchDialog(SearchDialog):

    dialog_window_size = "albumsearchdialog_window_size"
    dialog_header_state = "albumsearchdialog_header_state"

    options = [
        config.Option("persist", dialog_window_size, QtCore.QSize(720, 360)),
        config.Option("persist", dialog_header_state, QtCore.QByteArray())
    ]

    def __init__(self, parent):
        super(AlbumSearchDialog, self).__init__(
            parent,
            accept_button_title=_("Load into Picard"))
        self.cluster = None
        self.setWindowTitle(_("Album Search Results"))
        self.table_headers = [
                _("Name"),
                _("Artist"),
                _("Format"),
                _("Tracks"),
                _("Date"),
                _("Country"),
github metabrainz / picard / picard / ui / searchdialog.py View on Github external
album = self.file_.parent.album
                self.tagger.move_file_to_nat(track["musicbrainz_recordingid"])
                if album._files == 0:
                    self.tagger.remove_album(album)
            else:
                self.tagger.load_nat(track["musicbrainz_recordingid"], node)


class AlbumSearchDialog(SearchDialog):

    dialog_window_size = "albumsearchdialog_window_size"
    dialog_header_state = "albumsearchdialog_header_state"

    options = [
        config.Option("persist", dialog_window_size, QtCore.QSize(720, 360)),
        config.Option("persist", dialog_header_state, QtCore.QByteArray())
    ]

    def __init__(self, parent):
        super(AlbumSearchDialog, self).__init__(
            parent,
            accept_button_title=_("Load into Picard"))
        self.cluster = None
        self.setWindowTitle(_("Album Search Results"))
        self.table_headers = [
                _("Name"),
                _("Artist"),
                _("Format"),
                _("Tracks"),
                _("Date"),
                _("Country"),
                _("Labels"),
github metabrainz / picard / picard / ui / searchdialog.py View on Github external
release["musicbrainz_releasegroupid"]).loaded_albums.add(
                release["musicbrainz_albumid"])
        album = self.tagger.load_album(release["musicbrainz_albumid"])
        if self.cluster:
            files = self.tagger.get_files_from_objects([self.cluster])
            self.tagger.move_files_to_album(files, release["musicbrainz_albumid"],
                                            album)


class ArtistSearchDialog(SearchDialog):

    dialog_window_size = "artistsearchdialog_window_size"
    dialog_header_state = "artistsearchdialog_header_state"

    options = [
        config.Option("persist", dialog_window_size, QtCore.QSize(720, 360)),
        config.Option("persist", dialog_header_state, QtCore.QByteArray())
    ]

    def __init__(self, parent):
        super(ArtistSearchDialog, self).__init__(
            parent,
            accept_button_title=_("Show in browser"))
        self.setWindowTitle(_("Artist Search Dialog"))
        self.table_headers = [
                _("Name"),
                _("Type"),
                _("Gender"),
                _("Area"),
                _("Begin"),
                _("Begin Area"),
                _("End"),
github metabrainz / picard / picard / ui / itemviews.py View on Github external
cluster_item.update()
            cluster_item.setHidden(True)
        else:
            cluster_item.add_files(cluster.files)

    def moveCursor(self, action, modifiers):
        if action in (QtWidgets.QAbstractItemView.MoveUp, QtWidgets.QAbstractItemView.MoveDown):
            item = self.currentItem()
            if item and not item.isSelected():
                self.setCurrentItem(item)
        return QtWidgets.QTreeWidget.moveCursor(self, action, modifiers)


class FileTreeView(BaseTreeView):

    header_state = config.Option("persist", "file_view_header_state", QtCore.QByteArray())

    def __init__(self, window, parent=None):
        super().__init__(window, parent)
        self.setAccessibleName(_("file view"))
        self.setAccessibleDescription(_("Contains unmatched files and clusters"))
        self.unmatched_files = ClusterItem(self.tagger.unclustered_files, False, self)
        self.unmatched_files.update()
        self.unmatched_files.setExpanded(True)
        self.clusters = ClusterItem(self.tagger.clusters, False, self)
        self.set_clusters_text()
        self.clusters.setExpanded(True)
        self.tagger.cluster_added.connect(self.add_file_cluster)
        self.tagger.cluster_removed.connect(self.remove_file_cluster)

    def add_file_cluster(self, cluster, parent_item=None):
        self.add_cluster(cluster, parent_item)
github metabrainz / picard / picard / ui / cdlookup.py View on Github external
from picard.util import (
    compare_barcodes,
    restore_method,
)

from picard.ui import PicardDialog
from picard.ui.ui_cdlookup import Ui_Dialog


class CDLookupDialog(PicardDialog):

    autorestore = False
    dialog_header_state = "cdlookupdialog_header_state"

    options = [
        config.Option("persist", dialog_header_state, QtCore.QByteArray())
    ]

    def __init__(self, releases, disc, parent=None):
        super().__init__(parent)
        self.releases = releases
        self.disc = disc
        self.ui = Ui_Dialog()
        self.ui.setupUi(self)
        release_list = self.ui.release_list
        release_list.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection)
        release_list.setSortingEnabled(True)
        release_list.setAlternatingRowColors(True)
        release_list.setHeaderLabels([_("Album"), _("Artist"), _("Date"), _("Country"),
                                      _("Labels"), _("Catalog #s"), _("Barcode")])
        self.ui.submit_button.setIcon(QtGui.QIcon(":/images/cdrom.png"))
        if self.releases: