示例#1
0
    def settingsDialog(self):
        """
        Return a new instance of the settings dialog for this library.

        :rtype: studiolibrary.SettingsDialog
        """
        def validator():
            name = settingsDialog.name()
            path = settingsDialog.path()
            valid = [self.name()]

            studiolibrary.validateName(name, valid=valid)
            studiolibrary.validatePath(path)

        title = "Settings"
        header = "Local Library Settings"
        text = "All changes will be saved to your local settings."

        parent = self.libraryWidget()
        settingsDialog = studiolibrary.SettingsDialog(parent)

        settingsDialog.close()
        settingsDialog.setTitle(title)
        settingsDialog.setHeader(header)
        settingsDialog.setText(text)
        settingsDialog.setName(self.name())
        settingsDialog.setPath(self.path())
        settingsDialog.setValidator(validator)
        settingsDialog.setAccentColor(self.accentColor())
        settingsDialog.setBackgroundColor(self.backgroundColor())

        settingsDialog.accentColorChanged.connect(self.setAccentColor)
        settingsDialog.backgroundColorChanged.connect(self.setBackgroundColor)

        return settingsDialog
示例#2
0
文件: library.py 项目: jonntd/mira
 def settingsDialog(self):
     """
     :rtype: studiolibrary.SettingsDialog
     """
     if not self._settingsDialog:
         self._settingsDialog = studiolibrary.SettingsDialog(None, library=self)
     return self._settingsDialog
示例#3
0
文件: library.py 项目: jonntd/mira
    def showNewLibraryDialog():
        """
        :rtype: None
        """
        library = Library("None")

        settingsDialog = studiolibrary.SettingsDialog(None, library=library)
        settingsDialog.setTitle("New Library!")
        settingsDialog.setHeader("Create a new library")
        settingsDialog.setText(
            "Create a new library with a different folder location and switch between them. "
            "For example; This could be useful when working on different film productions, "
            "or for having a shared library and a local library."
        )

        result = settingsDialog.exec_()

        if result == QtWidgets.QDialog.Accepted:
            name = settingsDialog.name()
            path = settingsDialog.location()

            library.validateName(name)
            library.validatePath(path)

            library = Library.instance(name)

            library.setPath(path)
            library.setAccentColor(settingsDialog.color())
            library.setBackgroundColor(settingsDialog.backgroundColor())

            library.show()

            return library
        else:
            logger.info("New library dialog was canceled!")
示例#4
0
    def showNewLibraryDialog():
        """
        :rtype: None
        """
        library = Library()
        settings = studiolibrary.MetaFile("")
        library.setSettings(settings)

        settingsDialog = studiolibrary.SettingsDialog(None, library=library)
        settingsDialog.setTitle("New Library!")
        settingsDialog.setHeader("Create a new library")
        settingsDialog.setText(
            "Create a new library with a different folder location and switch between them. "
            "For example; This could be useful when working on different film productions, "
            "or for having a shared library and a local library.")

        result = settingsDialog.exec_()

        if result == QtGui.QDialog.Accepted:
            name = settingsDialog.name()
            path = settingsDialog.location()

            library.validateName(name)
            library.validatePath(path)

            library = Library.fromName(name)
            library.setPath(path)
            library.settings().data().update(settings.data())
            library.show()
            Library.onAdded.emit(library)

            return library
        else:
            logger.info("New library dialog was canceled!")
示例#5
0
def showNewLibraryDialog(
    name="",
    path="",
    title="New Library!",
    header="Create a new library",
    text="""Create a new library with a different folder location and switch between them.
For example; This could be useful when working on different film productions,
or for having a shared library and a local library.""",
    validNames=None,
    showOnAccepted=True,
    errorOnRejected=True
):
    """
    Show the settings dialog for creating a new library.

    :type name: str
    :type path: str
    :type title: str
    :type header: str
    :type text: str
    :type validNames: list[str]
    :type showOnAccepted: bool
    :type errorOnRejected: bool

    :rtype: studiolibrary.Library
    """
    library = None

    def validator():
        name = settingsDialog.name()
        path = settingsDialog.path()

        studiolibrary.validateName(name, validNames)
        studiolibrary.validatePath(path)

    settingsDialog = studiolibrary.SettingsDialog()
    settingsDialog.setValidator(validator)
    settingsDialog.setName(name)
    settingsDialog.setPath(path)
    settingsDialog.setText(text)
    settingsDialog.setTitle(title)
    settingsDialog.setHeader(header)

    result = settingsDialog.exec_()

    if result == QtWidgets.QDialog.Accepted:
        name = settingsDialog.name()
        path = settingsDialog.path()

        library = studiolibrary.Library.instance(name)
        library.setPath(path)
        library.setAccentColor(settingsDialog.accentColor())
        library.setBackgroundColor(settingsDialog.backgroundColor())
        library.saveSettings()

        if showOnAccepted:
            library.show()

    else:
        logger.info("New library dialog was canceled!")
        if errorOnRejected:
            raise Exception("Dialog was rejected.")

    return library