Esempio n. 1
0
def createProfileType(name, title, *, options=None, leftData=None, rightData=None,
                      overwrite={}, addOptions=[]):
    """Create a profile type and an associated default profile and add them to the delegate profile category.
    This should be called once inside the class definition of each treeview-subclass that needs its own
    type of delegate profiles.
    
    Arguments are:
    
        - name: internal name of the type,
        - title: displayed name of the type and name of the profile,
        - options: list of DelegateOptions. This defines which options can be modified by the user.
           If this is None, then the default options defined in this module will be used.
        - leftData: default DataPieces for the left column,
        - rightData: default DataPieces for the right column,
        - overwrite: dict mapping option names to values which will overwrite the values from *options*,
        - addOptions: like options, will be added to *options* (or to the default options if *options* is
          None).
    
    """
    if options is None:
        options = defaultOptions  # defined below
    
    options = collections.OrderedDict([(option.name, copy.copy(option)) for option in options])
    for optionName, value in overwrite.items():
        options[optionName].default = value
    for option in addOptions:
        options[option.name] = option
    
    leftData = [DataPiece.fromString(string) for string in leftData]
    rightData = [DataPiece.fromString(string) for string in rightData]
    
    profileType = ProfileType(name, title, options, leftData, rightData)
    # this will in particular load the profiles of this type from storage
    profiles.category('delegates').addType(profileType)
    return profileType
Esempio n. 2
0
 def __init__(self, state=None, **args):
     super().__init__(**args)
     # Read state
     profileType = PlaylistDelegate.profileType
     playerProfileCategory = profiles.category('playback')
     if state is None:
         if len(playerProfileCategory.profiles()) > 0:
             backend = playerProfileCategory.profiles()[0]
         else:
             backend = None
         delegateProfile = profileType.default()
     else:
         backend = playerProfileCategory.getFromStorage(state['backend'])
         delegateProfile = profiles.category('delegates').getFromStorage(
             state.get('delegate'),
             profileType
         )
     
     self.treeview = PlaylistTreeView(delegateProfile)
      
     layout = QtWidgets.QVBoxLayout(self)
     layout.setSpacing(0)
     layout.setContentsMargins(0, 0, 0, 0)
     
     layout.addWidget(self.treeview)
     self.errorLabel = QtWidgets.QLabel()
     self.errorLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)
     self.errorLabel.linkActivated.connect(lambda: self.backend.connectBackend())
     self.mainLayout = layout
     self.mainWidgetIndex = layout.indexOf(self.treeview)
     
     self.backend = None
     self.setBackend(backend)
Esempio n. 3
0
    def __init__(self, state=None, **args):
        super().__init__(**args)
        # Read state
        profileType = PlaylistDelegate.profileType
        playerProfileCategory = profiles.category('playback')
        if state is None:
            if len(playerProfileCategory.profiles()) > 0:
                backend = playerProfileCategory.profiles()[0]
            else:
                backend = None
            delegateProfile = profileType.default()
        else:
            backend = playerProfileCategory.getFromStorage(state['backend'])
            delegateProfile = profiles.category('delegates').getFromStorage(
                state.get('delegate'), profileType)

        self.treeview = PlaylistTreeView(delegateProfile)

        layout = QtWidgets.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self.treeview)
        self.errorLabel = QtWidgets.QLabel()
        self.errorLabel.setAlignment(Qt.AlignVCenter | Qt.AlignHCenter)
        self.errorLabel.linkActivated.connect(
            lambda: self.backend.connectBackend())
        self.mainLayout = layout
        self.mainWidgetIndex = layout.indexOf(self.treeview)

        self.backend = None
        self.setBackend(backend)
Esempio n. 4
0
 def __init__(self, profile, parent):
     super().__init__(parent)
     self.profile = profile
     
     layout = QtWidgets.QVBoxLayout(self)
     
     layout.addWidget(QtWidgets.QLabel("Decide which tags should be displayed on the left and right side:"))
     dataLayout = QtWidgets.QHBoxLayout()
     layout.addLayout(dataLayout)
     dataLayout.addWidget(DataPiecesEditor(self,True,))
     dataLayout.addWidget(DataPiecesEditor(self,False))
     
     layout.addSpacing(20)
     
     optionsBox = QtWidgets.QGroupBox(self.tr("Options"))
     layout.addWidget(optionsBox)
     grid = QtWidgets.QGridLayout(optionsBox)
     grid.setContentsMargins(0,0,0,0)
     
     # Create an editor for each option
     row = 0
     self._editors = {}
     for option in profile.type.options.values():
         grid.addWidget(QtWidgets.QLabel(option.title),row,1)
         editor = createEditor(option.type,profile.options[option.name],option.typeOptions)
         editor.valueChanged.connect(functools.partial(self._handleValueChanged,option,editor))
         self._editors[option.name] = editor
         grid.addWidget(editor,row,0,Qt.AlignRight)
         row += 1
     grid.setRowStretch(row,1)
     grid.setColumnStretch(1,1)
     
     layout.addStretch(1)
     profiles.category('delegates').profileChanged.connect(self._handleProfileChanged)
Esempio n. 5
0
 def save(self):
     """Really change the profile."""
     host = self.hostEdit.text()
     port = int(self.portEdit.text())
     password = self.passwordEdit.text()
     path = self.pathEdit.text()
     self.profile.setConnectionParameters(host, port, password)
     self.profile.setPath(path)
     profiles.category('playback').save()
     self.saveButton.setEnabled(False)
Esempio n. 6
0
    def __init__(self, category):
        super().__init__()
        if isinstance(category, str):
            category = profiles.category(category)
        self.category = category
        self.category.profileAdded.connect(self._makeMenu)
        self.category.profileRemoved.connect(self._makeMenu)
        self.category.profileRenamed.connect(self._makeMenu)
        self.baseProfile = None
        self.profile = None

        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        topLayout = QtWidgets.QHBoxLayout()
        style = QtWidgets.QApplication.style()
        topLayout.setContentsMargins(
            style.pixelMetric(style.PM_LayoutLeftMargin),
            style.pixelMetric(style.PM_LayoutTopMargin),
            style.pixelMetric(style.PM_LayoutRightMargin), 1)

        self.profileNameLabel = QtWidgets.QLabel()
        topLayout.addWidget(self.profileNameLabel)
        topLayout.addStretch(1)
        self.profileButton = QtWidgets.QPushButton(self.tr("Profiles..."))
        topLayout.addWidget(self.profileButton)
        self._makeMenu()
        layout.addLayout(topLayout)
        if len(category.profiles()) == 0:
            profile = category.profileClass(category.suggestProfileName())
        else:
            profile = category.profiles()[0]
        self.configWidget = profile.configurationWidget(profile, self)
        self.setProfile(profile)
        layout.addWidget(self.configWidget)
Esempio n. 7
0
    def __init__(self, category):
        super().__init__()
        if isinstance(category, str):
            category = profiles.category(category)
        self.category = category
        self.category.profileAdded.connect(self._makeMenu)
        self.category.profileRemoved.connect(self._makeMenu)
        self.category.profileRenamed.connect(self._makeMenu)
        self.baseProfile = None
        self.profile = None

        layout = QtWidgets.QVBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        topLayout = QtWidgets.QHBoxLayout()
        style = QtWidgets.QApplication.style()
        topLayout.setContentsMargins(style.pixelMetric(style.PM_LayoutLeftMargin),
                                     style.pixelMetric(style.PM_LayoutTopMargin),
                                     style.pixelMetric(style.PM_LayoutRightMargin),
                                     1)

        self.profileNameLabel = QtWidgets.QLabel()
        topLayout.addWidget(self.profileNameLabel)
        topLayout.addStretch(1)
        self.profileButton = QtWidgets.QPushButton(self.tr("Profiles..."))
        topLayout.addWidget(self.profileButton)
        self._makeMenu()
        layout.addLayout(topLayout)
        if len(category.profiles()) == 0:
            profile = category.profileClass(category.suggestProfileName())
        else:
            profile = category.profiles()[0]
        self.configWidget = profile.configurationWidget(profile, self)
        self.setProfile(profile)
        layout.addWidget(self.configWidget)
Esempio n. 8
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setWindowTitle(self.tr("Export"))
        layout = QtWidgets.QVBoxLayout(self)
        self.stackedLayout = QtWidgets.QStackedLayout(self)
        layout.addLayout(self.stackedLayout, 1)
        self.profileActionWidget = profilesgui.ProfileActionWidget(
            profiles.category('wtf'))
        self.configWidget = self.profileActionWidget.configWidget
        self.stackedLayout.addWidget(self.profileActionWidget)
        self.stackedLayout.setContentsMargins(0, 0, 0, 0)
        fileTreePage = QtWidgets.QWidget()
        fileTreeLayout = QtWidgets.QVBoxLayout(fileTreePage)
        self.statLabel = QtWidgets.QLabel()
        fileTreeLayout.addWidget(self.statLabel)
        self.fileTree = filetree.FileTreeView()
        fileTreeLayout.addWidget(self.fileTree)
        self.stackedLayout.addWidget(fileTreePage)

        buttonLayout = QtWidgets.QHBoxLayout()
        layout.addLayout(buttonLayout)
        cancelButton = QtWidgets.QPushButton(self.tr("Cancel"))
        cancelButton.clicked.connect(self.reject)
        buttonLayout.addWidget(cancelButton)
        buttonLayout.addStretch()

        self.previousButton = QtWidgets.QPushButton(self.tr("Previous"))
        self.previousButton.clicked.connect(self.previous)
        self.previousButton.setEnabled(False)
        buttonLayout.addWidget(self.previousButton)

        self.nextButton = QtWidgets.QPushButton(self.tr("Next"))
        self.nextButton.clicked.connect(self.next)
        buttonLayout.addWidget(self.nextButton)
Esempio n. 9
0
    def __init__(self,
                 category,
                 restrictToType=None,
                 default=None,
                 includeConfigure=True,
                 showTypes=False,
                 selectFirstProfile=True):
        super().__init__()
        self._profile = None
        if isinstance(category, str):
            category = profiles.category(category)
        self.category = category
        if isinstance(restrictToType, str):
            restrictToType = category.getType(restrictToType)
        self.restrictToType = restrictToType
        self.includeConfigure = includeConfigure
        self.showTypes = showTypes
        self.selectFirstProfile = selectFirstProfile
        self._fillBox()
        category.profileAdded.connect(self._handleProfileAdded)
        category.profileRenamed.connect(self._fillBox)
        category.profileRemoved.connect(self._handleProfileRemoved)
        self.currentIndexChanged.connect(self._handleIndexChanged)

        if default is not None:
            self.setCurrentProfile(default)
        else:
            self._profile = self.currentProfile()  # the first one or None
Esempio n. 10
0
 def __init__(self, parent, editor):
     super().__init__(parent)
     self.editor = editor
     layout = QtWidgets.QFormLayout(self)
     
     autoExpandBox = QtWidgets.QCheckBox()
     autoExpandBox.setChecked(editor.autoExpand)
     autoExpandBox.stateChanged.connect(self._handleAutoExpandBox)
     layout.addRow(self.tr("Auto expand"),autoExpandBox)
     
     albumGuessLayout = QtWidgets.QHBoxLayout()
     albumGuessCheckBox = QtWidgets.QCheckBox()
     albumGuessCheckBox.setChecked(self.editor.model().guessingEnabled)
     albumGuessCheckBox.setToolTip(self.tr("Auto expand dropped containers"))
     albumGuessCheckBox.toggled.connect(self._handleAlbumGuessCheckBox)
     albumGuessLayout.addWidget(albumGuessCheckBox)
     
     self.albumGuessComboBox = profilesgui.ProfileComboBox(
         profiles.category('albumguesser'),
         default=self.editor.model().guessProfile
     )
     self.albumGuessComboBox.setToolTip(self.tr("Select album guessing profile"))
     self._handleAlbumGuessCheckBox(albumGuessCheckBox.isChecked()) # initialize enabled/disabled
     self.albumGuessComboBox.profileChosen.connect(self._handleAlbumGuessComboBox)
     albumGuessLayout.addWidget(self.albumGuessComboBox,1)
     layout.addRow(self.tr("Guess albums"),albumGuessLayout)
     
     delegateType = delegate.EditorDelegate.profileType
     delegateChooser = profilesgui.ProfileComboBox('delegates', 'editor',
                                                   self.editor.itemDelegate().profile)
     delegateChooser.profileChosen.connect(self.editor.itemDelegate().setProfile)
     layout.addRow(self.tr("Item display"),delegateChooser)
Esempio n. 11
0
    def doAction(self):

        currentWidget = widgets.current('playback')
        currentBackend = None if currentWidget is None else currentWidget.backend
        backends = [b for b in profiles.category('playback').profiles()
                    if b.connectionState is player.ConnectionState.Connected]
        if self.command is PlayCommand.PlayPause:

            if any(backend.state() is player.PlayState.Play for backend in backends):
                # When a single backend is playing, stop all
                for backend in backends:
                    backend.setState(player.PlayState.Pause)
            elif currentBackend:
                # otherwise start only the current one
                currentBackend.setState(player.PlayState.Play)
        elif self.command is PlayCommand.Stop:
            for backend in backends:
                backend.setState(player.PlayState.Stop)
        elif self.command is PlayCommand.AddMark:
            if currentWidget:
                currentWidget.seekSlider.addMark()
        else:
            if currentBackend is None:
                return
            if self.command is PlayCommand.SkipForward:
                currentBackend.skipForward()
            elif self.command is PlayCommand.SkipBackward:
                currentBackend.skipBackward()
Esempio n. 12
0
 def __init__(self, parent=None):
     super().__init__(parent)
     self.setWindowTitle(self.tr("Export"))
     layout = QtWidgets.QVBoxLayout(self)
     self.stackedLayout = QtWidgets.QStackedLayout(self)
     layout.addLayout(self.stackedLayout, 1)
     self.profileActionWidget = profilesgui.ProfileActionWidget(profiles.category('wtf'))
     self.configWidget = self.profileActionWidget.configWidget
     self.stackedLayout.addWidget(self.profileActionWidget)
     self.stackedLayout.setContentsMargins(0, 0, 0, 0)
     fileTreePage = QtWidgets.QWidget()
     fileTreeLayout = QtWidgets.QVBoxLayout(fileTreePage)
     self.statLabel = QtWidgets.QLabel()
     fileTreeLayout.addWidget(self.statLabel)
     self.fileTree = filetree.FileTreeView()
     fileTreeLayout.addWidget(self.fileTree)
     self.stackedLayout.addWidget(fileTreePage)
     
     buttonLayout = QtWidgets.QHBoxLayout()
     layout.addLayout(buttonLayout)
     cancelButton = QtWidgets.QPushButton(self.tr("Cancel"))
     cancelButton.clicked.connect(self.reject)
     buttonLayout.addWidget(cancelButton)
     buttonLayout.addStretch()
     
     self.previousButton = QtWidgets.QPushButton(self.tr("Previous"))
     self.previousButton.clicked.connect(self.previous)
     self.previousButton.setEnabled(False)
     buttonLayout.addWidget(self.previousButton)
     
     self.nextButton = QtWidgets.QPushButton(self.tr("Next"))
     self.nextButton.clicked.connect(self.next)
     buttonLayout.addWidget(self.nextButton)
Esempio n. 13
0
 def initialize(self, state=None):
     super().initialize(state)
     playerProfileCategory = profiles.category('playback')
     if state:
         backend = playerProfileCategory.get(state)  # may be None
     elif len(playerProfileCategory.profiles()) > 0:
         backend = playerProfileCategory.profiles()[0]
     else:
         backend = None
     self.setBackend(backend)
Esempio n. 14
0
    def __init__(self, state=None, **args):
        super().__init__(**args)
        layout = QtWidgets.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        if state is None:
            state = {}
        expand = 'expand' not in state or state['expand']  # by default expand
        guessingEnabled = 'guessingEnabled' not in state or state[
            'guessingEnabled']
        guessProfile = profiles.category('albumguesser').getFromStorage(
            state.get('guessProfile'))
        delegateProfile = profiles.category('delegates').getFromStorage(
            state.get('delegate'),
            profiles.category('delegates').getType('editor'))

        buttonLayout = QtWidgets.QHBoxLayout()
        # buttonLayout is filled below, when the editor exists
        layout.addLayout(buttonLayout)

        self.splitter = QtWidgets.QSplitter(Qt.Vertical)
        layout.addWidget(self.splitter)

        self.editor = EditorTreeView(delegateProfile)
        self.editor.autoExpand = expand
        self.editor.model().guessingEnabled = guessingEnabled
        self.editor.model().guessProfile = guessProfile

        self.externalTagsWidget = ExternalTagsWidget(self.editor)

        self.splitter.addWidget(self.externalTagsWidget)
        self.splitter.addWidget(self.editor)
        self.splitter.setStretchFactor(0, 0)
        self.splitter.setStretchFactor(1, 1)

        # Fill buttonLayout
        self.toolbar = QtWidgets.QToolBar(self)
        self.toolbar.addAction(self.editor.treeActions['clearTree'])

        self.toolbar.addAction(self.editor.treeActions['commit'])
        buttonLayout.addWidget(self.toolbar)
        buttonLayout.addStretch()
Esempio n. 15
0
    def __init__(self, profile, parent):
        super().__init__(parent)
        self.profile = profile

        layout = QtWidgets.QVBoxLayout(self)

        layout.addWidget(
            QtWidgets.QLabel(
                "Decide which tags should be displayed on the left and right side:"
            ))
        dataLayout = QtWidgets.QHBoxLayout()
        layout.addLayout(dataLayout)
        dataLayout.addWidget(DataPiecesEditor(
            self,
            True,
        ))
        dataLayout.addWidget(DataPiecesEditor(self, False))

        layout.addSpacing(20)

        optionsBox = QtWidgets.QGroupBox(self.tr("Options"))
        layout.addWidget(optionsBox)
        grid = QtWidgets.QGridLayout(optionsBox)
        grid.setContentsMargins(0, 0, 0, 0)

        # Create an editor for each option
        row = 0
        self._editors = {}
        for option in profile.type.options.values():
            grid.addWidget(QtWidgets.QLabel(option.title), row, 1)
            editor = createEditor(option.type, profile.options[option.name],
                                  option.typeOptions)
            editor.valueChanged.connect(
                functools.partial(self._handleValueChanged, option, editor))
            self._editors[option.name] = editor
            grid.addWidget(editor, row, 0, Qt.AlignRight)
            row += 1
        grid.setRowStretch(row, 1)
        grid.setColumnStretch(1, 1)

        layout.addStretch(1)
        profiles.category('delegates').profileChanged.connect(
            self._handleProfileChanged)
Esempio n. 16
0
def createProfileType(name,
                      title,
                      *,
                      options=None,
                      leftData=None,
                      rightData=None,
                      overwrite={},
                      addOptions=[]):
    """Create a profile type and an associated default profile and add them to the delegate profile category.
    This should be called once inside the class definition of each treeview-subclass that needs its own
    type of delegate profiles.
    
    Arguments are:
    
        - name: internal name of the type,
        - title: displayed name of the type and name of the profile,
        - options: list of DelegateOptions. This defines which options can be modified by the user.
           If this is None, then the default options defined in this module will be used.
        - leftData: default DataPieces for the left column,
        - rightData: default DataPieces for the right column,
        - overwrite: dict mapping option names to values which will overwrite the values from *options*,
        - addOptions: like options, will be added to *options* (or to the default options if *options* is
          None).
    
    """
    if options is None:
        options = defaultOptions  # defined below

    options = collections.OrderedDict([(option.name, copy.copy(option))
                                       for option in options])
    for optionName, value in overwrite.items():
        options[optionName].default = value
    for option in addOptions:
        options[option.name] = option

    leftData = [DataPiece.fromString(string) for string in leftData]
    rightData = [DataPiece.fromString(string) for string in rightData]

    profileType = ProfileType(name, title, options, leftData, rightData)
    # this will in particular load the profiles of this type from storage
    profiles.category('delegates').addType(profileType)
    return profileType
Esempio n. 17
0
 def __init__(self, state=None, **args):
     super().__init__(**args)
     layout = QtWidgets.QVBoxLayout(self)
     layout.setSpacing(0)
     layout.setContentsMargins(0,0,0,0)
     
     if state is None:
         state = {}
     expand = 'expand' not in state or state['expand'] # by default expand
     guessingEnabled = 'guessingEnabled' not in state or state['guessingEnabled']
     guessProfile = profiles.category('albumguesser').getFromStorage(state.get('guessProfile'))
     delegateProfile = profiles.category('delegates').getFromStorage(
         state.get('delegate'),
         profiles.category('delegates').getType('editor')
     )
     
     buttonLayout = QtWidgets.QHBoxLayout()
     # buttonLayout is filled below, when the editor exists 
     layout.addLayout(buttonLayout)
     
     self.splitter = QtWidgets.QSplitter(Qt.Vertical)
     layout.addWidget(self.splitter)
     
     self.editor = EditorTreeView(delegateProfile)
     self.editor.autoExpand = expand
     self.editor.model().guessingEnabled = guessingEnabled
     self.editor.model().guessProfile = guessProfile
     
     self.externalTagsWidget = ExternalTagsWidget(self.editor)
     
     self.splitter.addWidget(self.externalTagsWidget)
     self.splitter.addWidget(self.editor)
     self.splitter.setStretchFactor(0,0)
     self.splitter.setStretchFactor(1,1)
     
     # Fill buttonLayout
     self.toolbar = QtWidgets.QToolBar(self)
     self.toolbar.addAction(self.editor.treeActions['clearTree'])
     
     self.toolbar.addAction(self.editor.treeActions['commit'])
     buttonLayout.addWidget(self.toolbar)
     buttonLayout.addStretch()
Esempio n. 18
0
 def __init__(self, parent, playback):
     super().__init__(parent)
     layout = QtWidgets.QVBoxLayout(self)
     hLayout = QtWidgets.QHBoxLayout()
     layout.addLayout(hLayout)
     hLayout.addWidget(QtWidgets.QLabel(self.tr("Backend:")))
     backendChooser = profilesgui.ProfileComboBox(profiles.category('playback'),
                                                  default=playback.backend)
     backendChooser.profileChosen.connect(playback.setBackend)
     hLayout.addWidget(backendChooser)
     hLayout.addStretch()
     layout.addStretch()
Esempio n. 19
0
 def __init__(self, parent, playlist):
     super().__init__(parent)
     layout = QtWidgets.QFormLayout(self)
     backendChooser = profilesgui.ProfileComboBox(profiles.category('playback'),
                                                  default=playlist.backend)
     backendChooser.profileChosen.connect(playlist.setBackend)
     layout.addRow(self.tr("Backend:"), backendChooser)
     profileChooser = profilesgui.ProfileComboBox(
         'delegates', 'playlist',
         default=playlist.treeview.itemDelegate().profile
     )
     profileChooser.profileChosen.connect(playlist.treeview.itemDelegate().setProfile)
     layout.addRow(self.tr("Item view:"), profileChooser)
Esempio n. 20
0
def enable():
    playerProfileCategory = profiles.category('playback')
    profileType = profiles.ProfileType(name='localplay',
                                       title=translate('LocalPlayBackend',
                                                       'Local Playback'),
                                       profileClass=LocalPlayerBackend)
    playerProfileCategory.addType(profileType)
    # addType loads stored profiles of this type from storage
    # If no profile was loaded, create a default one.
    if len(playerProfileCategory.profiles(profileType)) == 0:
        name = translate('LocalPlayBackend', 'Local playback')
        if playerProfileCategory.get(name) is None:
            playerProfileCategory.addProfile(name, profileType)
Esempio n. 21
0
def enable():
    playerProfileCategory = profiles.category('playback')
    profileType = profiles.ProfileType(
        name='localplay',
        title=translate('LocalPlayBackend', 'Local Playback'),
        profileClass=LocalPlayerBackend
    )
    playerProfileCategory.addType(profileType)
    # addType loads stored profiles of this type from storage
    # If no profile was loaded, create a default one.
    if len(playerProfileCategory.profiles(profileType)) == 0:
        name = translate('LocalPlayBackend', 'Local playback')
        if playerProfileCategory.get(name) is None:
            playerProfileCategory.addProfile(name, profileType)
Esempio n. 22
0
 def __init__(self, parent, playlist):
     super().__init__(parent)
     layout = QtWidgets.QFormLayout(self)
     backendChooser = profilesgui.ProfileComboBox(
         profiles.category('playback'), default=playlist.backend)
     backendChooser.profileChosen.connect(playlist.setBackend)
     layout.addRow(self.tr("Backend:"), backendChooser)
     profileChooser = profilesgui.ProfileComboBox(
         'delegates',
         'playlist',
         default=playlist.treeview.itemDelegate().profile)
     profileChooser.profileChosen.connect(
         playlist.treeview.itemDelegate().setProfile)
     layout.addRow(self.tr("Item view:"), profileChooser)
Esempio n. 23
0
    def __init__(self, category, restrictToType=None, default=None,
                 includeConfigure=True, showTypes=False, selectFirstProfile=True):
        super().__init__()
        self._profile = None
        if isinstance(category, str):
            category = profiles.category(category)
        self.category = category
        if isinstance(restrictToType, str):
            restrictToType = category.getType(restrictToType)
        self.restrictToType = restrictToType
        self.includeConfigure = includeConfigure
        self.showTypes = showTypes
        self.selectFirstProfile = selectFirstProfile
        self._fillBox()
        category.profileAdded.connect(self._handleProfileAdded)
        category.profileRenamed.connect(self._fillBox)
        category.profileRemoved.connect(self._handleProfileRemoved)
        self.currentIndexChanged.connect(self._handleIndexChanged)

        if default is not None:
            self.setCurrentProfile(default)
        else:
            self._profile = self.currentProfile()  # the first one or None
Esempio n. 24
0
    def __init__(self, parent, editor):
        super().__init__(parent)
        self.editor = editor
        layout = QtWidgets.QFormLayout(self)

        autoExpandBox = QtWidgets.QCheckBox()
        autoExpandBox.setChecked(editor.autoExpand)
        autoExpandBox.stateChanged.connect(self._handleAutoExpandBox)
        layout.addRow(self.tr("Auto expand"), autoExpandBox)

        albumGuessLayout = QtWidgets.QHBoxLayout()
        albumGuessCheckBox = QtWidgets.QCheckBox()
        albumGuessCheckBox.setChecked(self.editor.model().guessingEnabled)
        albumGuessCheckBox.setToolTip(
            self.tr("Auto expand dropped containers"))
        albumGuessCheckBox.toggled.connect(self._handleAlbumGuessCheckBox)
        albumGuessLayout.addWidget(albumGuessCheckBox)

        self.albumGuessComboBox = profilesgui.ProfileComboBox(
            profiles.category('albumguesser'),
            default=self.editor.model().guessProfile)
        self.albumGuessComboBox.setToolTip(
            self.tr("Select album guessing profile"))
        self._handleAlbumGuessCheckBox(
            albumGuessCheckBox.isChecked())  # initialize enabled/disabled
        self.albumGuessComboBox.profileChosen.connect(
            self._handleAlbumGuessComboBox)
        albumGuessLayout.addWidget(self.albumGuessComboBox, 1)
        layout.addRow(self.tr("Guess albums"), albumGuessLayout)

        delegateType = delegate.EditorDelegate.profileType
        delegateChooser = profilesgui.ProfileComboBox(
            'delegates', 'editor',
            self.editor.itemDelegate().profile)
        delegateChooser.profileChosen.connect(
            self.editor.itemDelegate().setProfile)
        layout.addRow(self.tr("Item display"), delegateChooser)
Esempio n. 25
0
    def __init__(self, file, dbTags, fsTags):
        super().__init__(application.mainWindow)
        self.file = file
        self.dbTags = dbTags
        self.fsTags = fsTags
        self.setModal(True)

        self.setWindowTitle(self.tr('Detected Modified Tags on Disk'))
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(
            QtWidgets.QLabel(
                self.
                tr('Maestro has detected that the tags of <center><i>{}</i>'
                   '</center> do not match Maestro\'s database. Please choose which version to keep:'
                   ).format(self.file.url.path)))
        viewLayout = QtWidgets.QHBoxLayout()
        leftLayout = QtWidgets.QVBoxLayout()
        rightLayout = QtWidgets.QVBoxLayout()
        midLayout = QtWidgets.QVBoxLayout()
        leftLayout.addWidget(
            QtWidgets.QLabel(self.tr('<b>In Maestro\'s database:</b>')))
        rightLayout.addWidget(QtWidgets.QLabel(self.tr('<b>In the file:</b>')))

        delegateProfile = profiles.category('delegates').getFromStorage(
            None,
            profiles.category('delegates').getType('editor'))
        delegateProfile.options['showPaths'] = False
        dbElem = levels.real.collect(file.id)

        dbModel = LevelTreeModel(levels.real, [dbElem])
        dbTree = treeview.TreeView(levels.real, affectGlobalSelection=False)
        dbTree.setRootIsDecorated(False)
        dbTree.setModel(dbModel)
        dbTree.setItemDelegate(
            editordelegate.EditorDelegate(dbTree, delegateProfile))
        fsLevel = levels.Level('tmp', levels.real, [dbElem])
        fsElem = fsLevel[file.id]
        fsElemTags = fsElem.tags
        nonPrivateTags = [tag for tag in fsElemTags if not tag.private]
        for tag in nonPrivateTags:
            del fsElemTags[tag]
        for tag, values in fsTags.items():
            fsElemTags[tag] = values
        fsModel = LevelTreeModel(fsLevel, [fsLevel[file.id]])
        fsTree = treeview.TreeView(fsLevel, affectGlobalSelection=False)
        fsTree.setRootIsDecorated(False)
        fsTree.setModel(fsModel)
        fsTree.setItemDelegate(
            editordelegate.EditorDelegate(fsTree, delegateProfile))
        leftLayout.addWidget(dbTree)
        rightLayout.addWidget(fsTree)

        dbButton = QtWidgets.QPushButton(utils.images.icon('go-next'), '')
        dbButton.setToolTip(self.tr('Write database tags to file'))
        fsButton = QtWidgets.QPushButton(utils.images.icon('go-previous'), '')
        fsButton.setToolTip(self.tr('Store tags from file into database'))

        dbButton.clicked.connect(self.useDBTags)
        fsButton.clicked.connect(self.useFSTags)

        midLayout.setAlignment(Qt.AlignVCenter)
        midLayout.addWidget(dbButton)
        midLayout.addWidget(fsButton)
        viewLayout.addLayout(leftLayout)
        viewLayout.addLayout(midLayout)
        viewLayout.addLayout(rightLayout)
        layout.addLayout(viewLayout)
        bbx = QtWidgets.QDialogButtonBox()
        bbx.addButton(self.tr('Cancel (ignore for now)'), bbx.RejectRole)
        bbx.rejected.connect(self.reject)
        layout.addWidget(bbx)
        self.setLayout(layout)
Esempio n. 26
0
 def readTags(self):
     mpdProfile = profiles.category('playback').get(self.url.netloc)
     self.tags, self.length = mpdProfile.getInfo(self.url.path[1:])
Esempio n. 27
0
def disable():
    profiles.category('playback').removeType('mpd')
    urls.fileBackends.remove(MPDFile)
Esempio n. 28
0
def enable():
    profiles.category('playback').addType(profiles.ProfileType(
        name='mpd', title=translate('MPDPlayerBackend', 'MPD'),
        profileClass=MPDPlayerBackend,
    ))
    urls.fileBackends.append(MPDFile)
Esempio n. 29
0
 def __init__(self, profile, left):
     super().__init__()
     self.profile = profile
     self.left = left
     profiles.category('delegates').profileChanged.connect(
         self._handleProfileChanged)
Esempio n. 30
0
    def __init__(self, file, dbTags, fsTags):
        super().__init__(application.mainWindow)
        self.file = file
        self.dbTags = dbTags
        self.fsTags = fsTags
        self.setModal(True)

        self.setWindowTitle(self.tr('Detected Modified Tags on Disk'))
        layout = QtWidgets.QVBoxLayout()
        layout.addWidget(QtWidgets.QLabel(self.tr(
            'Maestro has detected that the tags of <center><i>{}</i>'
            '</center> do not match Maestro\'s database. Please choose which version to keep:')
            .format(self.file.url.path)
        ))
        viewLayout = QtWidgets.QHBoxLayout()
        leftLayout = QtWidgets.QVBoxLayout()
        rightLayout = QtWidgets.QVBoxLayout()
        midLayout = QtWidgets.QVBoxLayout()
        leftLayout.addWidget(QtWidgets.QLabel(self.tr('<b>In Maestro\'s database:</b>')))
        rightLayout.addWidget(QtWidgets.QLabel(self.tr('<b>In the file:</b>')))
        
        delegateProfile = profiles.category('delegates').getFromStorage(
            None, profiles.category('delegates').getType('editor')
        )
        delegateProfile.options['showPaths'] = False
        dbElem = levels.real.collect(file.id)
        
        dbModel = LevelTreeModel(levels.real, [dbElem])
        dbTree = treeview.TreeView(levels.real, affectGlobalSelection=False)
        dbTree.setRootIsDecorated(False)
        dbTree.setModel(dbModel)
        dbTree.setItemDelegate(editordelegate.EditorDelegate(dbTree, delegateProfile))
        fsLevel = levels.Level('tmp', levels.real, [dbElem])
        fsElem = fsLevel[file.id]
        fsElemTags = fsElem.tags
        nonPrivateTags = [tag for tag in fsElemTags if not tag.private]
        for tag in nonPrivateTags:
            del fsElemTags[tag]
        for tag, values in fsTags.items():
            fsElemTags[tag] = values
        fsModel = LevelTreeModel(fsLevel, [fsLevel[file.id]])
        fsTree = treeview.TreeView(fsLevel, affectGlobalSelection=False)
        fsTree.setRootIsDecorated(False)
        fsTree.setModel(fsModel)
        fsTree.setItemDelegate(editordelegate.EditorDelegate(fsTree, delegateProfile))
        leftLayout.addWidget(dbTree)
        rightLayout.addWidget(fsTree)

        dbButton = QtWidgets.QPushButton(utils.images.icon('go-next'), '')
        dbButton.setToolTip(self.tr('Write database tags to file'))
        fsButton = QtWidgets.QPushButton(utils.images.icon('go-previous'), '')
        fsButton.setToolTip(self.tr('Store tags from file into database'))

        dbButton.clicked.connect(self.useDBTags)
        fsButton.clicked.connect(self.useFSTags)

        midLayout.setAlignment(Qt.AlignVCenter)
        midLayout.addWidget(dbButton)
        midLayout.addWidget(fsButton)
        viewLayout.addLayout(leftLayout)
        viewLayout.addLayout(midLayout)
        viewLayout.addLayout(rightLayout)
        layout.addLayout(viewLayout)
        bbx = QtWidgets.QDialogButtonBox()
        bbx.addButton(self.tr('Cancel (ignore for now)'), bbx.RejectRole)
        bbx.rejected.connect(self.reject)
        layout.addWidget(bbx)
        self.setLayout(layout)
Esempio n. 31
0
    def __init__(self, state=None, **args):
        """Initialize a new Browser with the given parent."""
        super().__init__(**args)
        self.views = [] # List of treeviews
        self.domain = domains.domains[0]
        
        # These three criteria determine the set of elements displayed in the browser. They are combined
        # using AND.
        self.filterCriterion = None  # Used by the 'filter'-line edit in the option dialog 
        self.flagCriterion = None    # Used by the flags filter in the option dialog
        self.searchCriterion = None  # Used by the search box

        # Layout
        layout = QtWidgets.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0,0,0,0)
        
        controlLineLayout = QtWidgets.QHBoxLayout()
        self.searchBox = searchgui.SearchBox()
        self.searchBox.criterionChanged.connect(self.search)
        controlLineLayout.addWidget(self.searchBox)
        
        # This option button is only used when dock widget title bars are hidden (otherwise the dock widget
        # title bar contains an analogous button).
        self.optionButton = dockwidget.DockWidgetTitleButton('options')
        self.optionButton.clicked.connect(functools.partial(self.toggleOptionDialog, self.optionButton))
        controlLineLayout.addWidget(self.optionButton)
        self.optionButton.setVisible(mainwindow.mainWindow.hideTitleBarsAction.isChecked())
        
        self.filterButton = FilterButton()
        controlLineLayout.addWidget(self.filterButton)
        self.filterButton.clicked.connect(self._handleFilterButton)
        
        layout.addLayout(controlLineLayout)
               
        self.splitter = QtWidgets.QSplitter(Qt.Vertical, self)
        layout.addWidget(self.splitter)
        
        # Restore state
        layersForViews = [self.defaultLayers()]
        self.delegateProfile = delegate.BrowserDelegate.profileType.default()
        self.sortTags = {}
        if state is not None and isinstance(state, dict):
            if 'domain' in state:
                self.domain = domains.domainById(state['domain'])
            if 'instant' in state:
                self.searchBox.instant = bool(state['instant'])
            if 'showHiddenValues' in state:
                self.showHiddenValues = state['showHiddenValues']
            if 'views' in state:
                layersForViews = []
                for layersConfig in state['views']:
                    layers = []
                    layersForViews.append(layers)
                    for layerConfig in layersConfig: 
                        try:
                            className, layerState = layerConfig
                            if className in model.layerClasses:
                                theClass = model.layerClasses[className][1]
                                layer = theClass(state=layerState)
                                layers.append(layer)
                        except Exception:
                            logging.exception(__name__, "Could not parse a layer of the browser.")
            if 'flags' in state:
                flagList = [flags.get(name) for name in state['flags'] if flags.exists(name)]
                if len(flagList) > 0:
                    self.flagCriterion = search.criteria.FlagCriterion(flagList)
            if 'filter' in state:
                try:
                    self.filterCriterion = search.criteria.parse(state['filter'])
                except search.criteria.ParseException:
                    logging.exception(__name__, "Could not parse the browser's filter criterion.")
            if 'delegate' in state:
                from maestro import profiles
                self.delegateProfile = profiles.category('delegates').getFromStorage(
                    state['delegate'],
                    profiles.category('delegates').getType('browser')
                )
            
        application.dispatcher.connect(self._handleChangeEvent)
        levels.real.connect(self._handleChangeEvent)

        self.createViews(layersForViews)
        self.filterButton.setEnabled(self.getFilter() is not None)
        
        global defaultBrowser
        defaultBrowser = self
Esempio n. 32
0
def disable():
    profiles.category('playback').removeType('localplay')
Esempio n. 33
0
 def __init__(self,profile,left):
     super().__init__()
     self.profile = profile
     self.left = left
     profiles.category('delegates').profileChanged.connect(self._handleProfileChanged)
Esempio n. 34
0
    def __init__(self, state=None, **args):
        """Initialize a new Browser with the given parent."""
        super().__init__(**args)
        self.views = []  # List of treeviews
        self.domain = domains.domains[0]

        # These three criteria determine the set of elements displayed in the browser. They are combined
        # using AND.
        self.filterCriterion = None  # Used by the 'filter'-line edit in the option dialog
        self.flagCriterion = None  # Used by the flags filter in the option dialog
        self.searchCriterion = None  # Used by the search box

        # Layout
        layout = QtWidgets.QVBoxLayout(self)
        layout.setSpacing(0)
        layout.setContentsMargins(0, 0, 0, 0)

        controlLineLayout = QtWidgets.QHBoxLayout()
        self.searchBox = searchgui.SearchBox()
        self.searchBox.criterionChanged.connect(self.search)
        controlLineLayout.addWidget(self.searchBox)

        # This option button is only used when dock widget title bars are hidden (otherwise the dock widget
        # title bar contains an analogous button).
        self.optionButton = dockwidget.DockWidgetTitleButton('options')
        self.optionButton.clicked.connect(
            functools.partial(self.toggleOptionDialog, self.optionButton))
        controlLineLayout.addWidget(self.optionButton)
        self.optionButton.setVisible(
            mainwindow.mainWindow.hideTitleBarsAction.isChecked())

        self.filterButton = FilterButton()
        controlLineLayout.addWidget(self.filterButton)
        self.filterButton.clicked.connect(self._handleFilterButton)

        layout.addLayout(controlLineLayout)

        self.splitter = QtWidgets.QSplitter(Qt.Vertical, self)
        layout.addWidget(self.splitter)

        # Restore state
        layersForViews = [self.defaultLayers()]
        self.delegateProfile = delegate.BrowserDelegate.profileType.default()
        self.sortTags = {}
        if state is not None and isinstance(state, dict):
            if 'domain' in state:
                self.domain = domains.domainById(state['domain'])
            if 'instant' in state:
                self.searchBox.instant = bool(state['instant'])
            if 'showHiddenValues' in state:
                self.showHiddenValues = state['showHiddenValues']
            if 'views' in state:
                layersForViews = []
                for layersConfig in state['views']:
                    layers = []
                    layersForViews.append(layers)
                    for layerConfig in layersConfig:
                        try:
                            className, layerState = layerConfig
                            if className in model.layerClasses:
                                theClass = model.layerClasses[className][1]
                                layer = theClass(state=layerState)
                                layers.append(layer)
                        except Exception:
                            logging.exception(
                                __name__,
                                "Could not parse a layer of the browser.")
            if 'flags' in state:
                flagList = [
                    flags.get(name) for name in state['flags']
                    if flags.exists(name)
                ]
                if len(flagList) > 0:
                    self.flagCriterion = search.criteria.FlagCriterion(
                        flagList)
            if 'filter' in state:
                try:
                    self.filterCriterion = search.criteria.parse(
                        state['filter'])
                except search.criteria.ParseException:
                    logging.exception(
                        __name__,
                        "Could not parse the browser's filter criterion.")
            if 'delegate' in state:
                from maestro import profiles
                self.delegateProfile = profiles.category(
                    'delegates').getFromStorage(
                        state['delegate'],
                        profiles.category('delegates').getType('browser'))

        application.dispatcher.connect(self._handleChangeEvent)
        levels.real.connect(self._handleChangeEvent)

        self.createViews(layersForViews)
        self.filterButton.setEnabled(self.getFilter() is not None)

        global defaultBrowser
        defaultBrowser = self
Esempio n. 35
0
def disable():
    profiles.category('playback').removeType('localplay')