Exemplo n.º 1
0
    def includepath(self):
        """Return the configured include path.

        A path is a list of directories.

        If there is a session specific include path, it is used.
        Otherwise the path is taken from the LilyPond preferences.

        Currently the document does not matter.

        """
        # get the global include path
        include_path = qsettings.get_string_list(
            QSettings(), "lilypond_settings/include_path")

        # get the session specific include path
        import sessions
        session_settings = sessions.currentSessionGroup()
        if session_settings and session_settings.value("set-paths", False, bool):
            sess_path = qsettings.get_string_list(session_settings, "include-path")
            if session_settings.value("repl-paths", False, bool):
                include_path = sess_path
            else:
                include_path = sess_path + include_path

        return include_path
Exemplo n.º 2
0
 def slotSaveSessionData(self):
     """Saves the filenames and positions of the open manuscripts.
     If a file doesn't have a position (because it hasn't been moved or
     shown) a default position is stored."""
     import sessions
     g = sessions.currentSessionGroup()
     if g:
         # TODO: cleanup for multi-file documents later
         files_key = "{}-documents".format(self.viewerName())
         docs = self.actionCollection.viewer_document_select.viewdocs()
         if docs:
             current = self.currentViewdoc()
             g.beginWriteArray(files_key, len(docs))
             for i, doc in enumerate(docs):
                 g.setArrayIndex(i)
                 g.setValue("filename", doc.filename())
                 g.setValue("isactive", doc is current)
                 if doc is current:
                     self.view.documentPropertyStore.set(
                         doc,
                         self.view.properties().get(self.view))
                 props = self.view.documentPropertyStore.get(doc)
                 if props:
                     props.save(g)
             g.endArray()
         else:
             g.remove(files_key)
Exemplo n.º 3
0
 def slotSaveSessionData(self):
     """Saves the filenames and positions of the open manuscripts.
     If a file doesn't have a position (because it hasn't been moved or
     shown) a default position is stored."""
     import sessions
     g = sessions.currentSessionGroup()
     if g:
         files_key = "{}-files".format(self.viewerName())
         active_file_key = "{}-active-file".format(self.viewerName())
         docs = self.actionCollection.viewer_document_select.viewdocs()
         if docs:
             current_viewdoc = self.currentViewdoc()
             current_file = current_viewdoc.filename()
             g.setValue(active_file_key, current_file)
             pos = []
             for d in docs:
                 if d.filename() == current_file:
                     # retrieve the position of the current document directly
                     # from the view because the entry in _positions may not
                     # be set in all cases
                     p = self.view.position()
                 else:
                     p = self._positions.get(d, (0, 0, 0))
                 pos.append((d.filename(), p))
             g.setValue(files_key, pos)
         else:
             g.remove(active_file_key)
             g.remove(files_key)
Exemplo n.º 4
0
 def includepath(self):
     """Return the configured include path.
     
     A path is a list of directories.
     
     If there is a session specific include path, it is used.
     Otherwise the path is taken from the LilyPond preferences.
     
     Currently the document does not matter.
     
     """
     # get the global include path
     try:
         include_path = QSettings().value("lilypond_settings/include_path", [], type(""))
     except TypeError:
         include_path = []
     
     # get the session specific include path
     import sessions
     session_settings = sessions.currentSessionGroup()
     if session_settings and session_settings.value("set-paths", False, bool):
         try:
             sess_path = session_settings.value("include-path", [], type(""))
         except TypeError:
             sess_path = []
         
         if session_settings.value("repl-paths", False, bool):
             include_path = sess_path
         else:
             include_path = sess_path + include_path
     
     return include_path
Exemplo n.º 5
0
 def slotSaveSessionData(self):
     """Saves the filenames and positions of the open manuscripts.
     If a file doesn't have a position (because it hasn't been moved or
     shown) a default position is stored."""
     import sessions
     g = sessions.currentSessionGroup()
     if g:
         files_key = "{}-files".format(self.viewerName())
         active_file_key = "{}-active-file".format(self.viewerName())
         docs = self.actionCollection.viewer_document_select.viewdocs()
         if docs:
             current_viewdoc = self.currentViewdoc()
             current_file = current_viewdoc.filename()
             g.setValue(active_file_key, current_file)
             pos = []
             for d in docs:
                 if d.filename() == current_file:
                     # retrieve the position of the current document directly
                     # from the view because the entry in _positions may not
                     # be set in all cases
                     p = self.view.position()
                 else:
                     p = self._positions.get(d, (0, 0, 0))
                 pos.append((d.filename(), p))
             g.setValue(files_key, pos)
         else:
             g.remove(active_file_key)
             g.remove(files_key)
Exemplo n.º 6
0
 def slotSaveSessionData(self):
     """Called when a session needs to save data."""
     import sessions
     d = self.stickyDocument()
     g = sessions.currentSessionGroup()
     if g:
         if d and not d.url().isEmpty():
             g.setValue("sticky_url", d.url())
         else:
             g.remove("sticky_url")
Exemplo n.º 7
0
 def slotSessionChanged(self):
     """Called when the session is changed."""
     import sessions
     g = sessions.currentSessionGroup()
     if g:
         url = g.value("sticky_url", QUrl())
         if not url.isEmpty():
             d = app.findDocument(url)
             if d:
                 self.setStickyDocument(d)
Exemplo n.º 8
0
 def slotSaveSessionData(self):
     """Called when a session needs to save data."""
     import sessions
     d = self.stickyDocument()
     g = sessions.currentSessionGroup()
     if g:
         if d and not d.url().isEmpty():
             g.setValue("sticky_url", d.url())
         else:
             g.remove("sticky_url")
Exemplo n.º 9
0
 def slotSessionChanged(self):
     """Called when the session is changed."""
     import sessions
     g = sessions.currentSessionGroup()
     if g:
         url = g.value("sticky_url", QUrl())
         if not url.isEmpty():
             d = app.findDocument(url)
             if d:
                 self.setStickyDocument(d)
Exemplo n.º 10
0
def basedir():
    """Returns a base directory for documents.

    First looks in the session settings, then the default settings.
    Returns "" if no directory was set. It is recommended to use the
    home directory in that case.

    """
    import sessions
    conf = sessions.currentSessionGroup()
    if conf:
        basedir = conf.value("basedir", "", type(""))
        if basedir:
            return basedir
    return QSettings().value("basedir", "", type(""))
Exemplo n.º 11
0
def basedir():
    """Returns a base directory for documents.

    First looks in the session settings, then the default settings.
    Returns "" if no directory was set. It is recommended to use the
    home directory in that case.

    """
    import sessions
    conf = sessions.currentSessionGroup()
    if conf:
        basedir = conf.value("basedir", "", str)
        if basedir:
            return basedir
    return QSettings().value("basedir", "", str)
Exemplo n.º 12
0
 def includepath(self):
     """Returns the configured include path. 
     If there are session specific include paths, they are used.
     Otherwise the paths are taken from the LilyPond preferences.
     Currently the document does not matter."""
     import sessions
     session_settings = sessions.currentSessionGroup()
     try:
         if session_settings and session_settings.contains("include-path"):
             include_path = session_settings.value("include-path", [], type(""))
         else:
             include_path = QSettings().value("lilypond_settings/include_path", [], type(""))
     except TypeError:
         include_path = []
     return include_path