コード例 #1
0
ファイル: documentinfo.py プロジェクト: zmole945/frescobaldi
    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
コード例 #2
0
ファイル: popplerwidget.py プロジェクト: taasan/frescobaldi
 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)
コード例 #3
0
ファイル: popplerwidget.py プロジェクト: AlexSchr/frescobaldi
 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)
コード例 #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
コード例 #5
0
ファイル: popplerwidget.py プロジェクト: zsalch/frescobaldi
 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)
コード例 #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")
コード例 #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)
コード例 #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")
コード例 #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)
コード例 #10
0
ファイル: app.py プロジェクト: EdwardBetts/frescobaldi
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(""))
コード例 #11
0
ファイル: app.py プロジェクト: zsalch/frescobaldi
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)
コード例 #12
0
ファイル: documentinfo.py プロジェクト: cognot/frescobaldi
 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