Esempio 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
Esempio n. 2
0
 def loadSettings(self):
     s = settings()
     self.saveDocument.setChecked(s.value("save_on_run", False, bool))
     self.deleteFiles.setChecked(s.value("delete_intermediate_files", True, bool))
     self.noTranslation.setChecked(s.value("no_translation", False, bool))
     include_path = qsettings.get_string_list(s, "include_path")
     self.include.setValue(include_path)
Esempio n. 3
0
 def load_settings(self):
     """Load application-wide settings relating to extensions."""
     s = QSettings()
     s.beginGroup('extension-settings')
     self._active = s.value('active', True, bool)
     self._inactive_extensions = qsettings.get_string_list(s, 'installed/inactive')
     self._root_directory = s.value('root-directory', '', str)
Esempio n. 4
0
 def loadSettings(self):
     s = settings()
     self.saveDocument.setChecked(s.value("save_on_run", False, bool))
     self.deleteFiles.setChecked(
         s.value("delete_intermediate_files", True, bool))
     self.noTranslation.setChecked(s.value("no_translation", False, bool))
     include_path = qsettings.get_string_list(s, "include_path")
     self.include.setValue(include_path)
Esempio n. 5
0
 def load(self, name):
     settings = sessions.sessionGroup(name)
     self.autosave.setChecked(settings.value("autosave", True, bool))
     self.basedir.setPath(settings.value("basedir", "", type("")))
     self.include.setValue(qsettings.get_string_list(settings, "include-path"))
     self.inclPaths.setChecked(settings.value("set-paths", False, bool))
     self.replPaths.setChecked(settings.value("repl-paths", False, bool))
     if not self.replPaths.isChecked():
         self.addDisabledGenPaths()
         self.revt.setEnabled(False)
Esempio n. 6
0
 def load(self, name):
     settings = sessions.sessionGroup(name)
     self.autosave.setChecked(settings.value("autosave", True, bool))
     self.basedir.setPath(settings.value("basedir", "", str))
     self.include.setValue(qsettings.get_string_list(settings, "include-path"))
     self.inclPaths.setChecked(settings.value("set-paths", False, bool))
     self.replPaths.setChecked(settings.value("repl-paths", False, bool))
     if not self.replPaths.isChecked():
         self.addDisabledGenPaths()
         self.revt.setEnabled(False)
Esempio n. 7
0
 def settings_changed(self):
     """Determine if any changes in global extension settings
     requires a restart."""
     s = QSettings()
     s.beginGroup('extension-settings')
     active = s.value('active', True, bool)
     inactive = qsettings.get_string_list(s, 'installed/inactive')
     root = s.value('root-directory', '', str)
     inactive_changed = False
     if len(inactive) != len(self._inactive_extensions):
         inactive_changed = True
     else:
         for ext in inactive:
             if not ext in self._inactive_extensions:
                 inactive_changed = True
                 break
     self.reset_inactive(inactive)
     if (active != self.active() or root != self.root_directory()
             or inactive_changed):
         from widgets.restartmessage import suggest_restart
         suggest_restart(_('Extensions have changed'))
Esempio n. 8
0
 def load(self):
     strings = qsettings.get_string_list(QSettings(), self.key)
     self.setStringList(sorted(strings))
     self._changed = False
Esempio n. 9
0
 def fetchGenPaths(self):
     """Fetch paths from general preferences."""
     return qsettings.get_string_list(QSettings(),
         "lilypond_settings/include_path")
Esempio n. 10
0
 def loadSettings(self):
     s = QSettings()
     s.beginGroup("hyphenation")
     paths = qsettings.get_string_list(s, "paths")
     self.listedit.setValue(paths)
Esempio n. 11
0
 def fetchGenPaths(self):
     """Fetch paths from general preferences."""
     return qsettings.get_string_list(QSettings(),
                                      "lilypond_settings/include_path")
Esempio n. 12
0
 def load(self):
     strings = qsettings.get_string_list(QSettings(), self.key)
     self.setStringList(sorted(strings))
     self._changed = False
Esempio n. 13
0
 def loadSettings(self):
     paths = qsettings.get_string_list(QSettings(), "documentation/paths")
     self.paths.setValue(paths)
Esempio n. 14
0
 def loadSettings(self):
     paths = qsettings.get_string_list(QSettings(), "documentation/paths")
     self.paths.setValue(paths)
Esempio n. 15
0
def urls():
    """Returns a list of QUrls where documentation can be found.

    Remote urls (from the users settings) are not checked but simply returned.
    For user-set local directories, if the directory itself does not contain
    LilyPond documentation, all directories one level deep are searched.

    This makes it possible to set one directory for local documentation and
    put there multiple sets of documentation in subdirectories (e.g. with the
    version number in the path name).

    The paths in the settings are read, and also the usual system directories
    are scanned.

    """
    user_paths = qsettings.get_string_list(QSettings(), "documentation/paths")
    system_prefixes = [p for p in (
        '/usr',
        '/usr/local',
        '/usr/share/doc',
        '/usr/doc',
    ) if os.path.isdir(p)]
    # split in local and non-local ones (local are preferred)
    user_prefixes = []
    local = []
    remote = []
    for p in user_paths:
        user_prefixes.append(p) if os.path.isdir(p) else remote.append(p)
    remote.sort(key=util.naturalsort)

    # now find all instances of LilyPond documentation in the local paths
    def paths(path):
        """Yields possible places where LilyPond documentation could live."""
        yield path
        path = os.path.join(path, 'share', 'doc', 'lilypond', 'html')
        yield path
        yield os.path.join(path, 'offline-root')

    def find(path):
        """Finds LilyPond documentation."""
        for p in paths(path):
            if os.path.isdir(os.path.join(p, 'Documentation')):
                return p

    # search in the user-set directories, if no docs, scan one level deeper
    for p in user_prefixes:
        n = find(p)
        if n:
            local.append(n)
        elif p not in system_prefixes:
            for name, dirs, files in os.walk(p):
                for d in sorted(dirs, key=util.naturalsort):
                    n = find(os.path.join(p, d))
                    if n:
                        local.append(n)
                break
    # now add the system directories if documentation is found there
    for p in system_prefixes:
        if p not in user_prefixes:
            n = find(p)
            if n:
                local.append(n)
    urls = []
    urls.extend(map(QUrl.fromLocalFile, local))
    urls.extend(map(QUrl, remote))
    if not urls:
        urls.append(QUrl("http://lilypond.org/doc/stable"))
    return urls
Esempio n. 16
0
def urls():
    """Returns a list of QUrls where documentation can be found.

    Remote urls (from the users settings) are not checked but simply returned.
    For user-set local directories, if the directory itself does not contain
    LilyPond documentation, all directories one level deep are searched.

    This makes it possible to set one directory for local documentation and
    put there multiple sets of documentation in subdirectories (e.g. with the
    version number in the path name).

    The paths in the settings are read, and also the usual system directories
    are scanned.

    """
    user_paths = qsettings.get_string_list(QSettings(), "documentation/paths")
    system_prefixes = [
        p for p in (
            '/usr',
            '/usr/local',
            '/usr/share/doc',
            '/usr/doc',
        ) if os.path.isdir(p)
    ]
    # split in local and non-local ones (local are preferred)
    user_prefixes = []
    local = []
    remote = []
    for p in user_paths:
        user_prefixes.append(p) if os.path.isdir(p) else remote.append(p)
    remote.sort(key=util.naturalsort)

    # now find all instances of LilyPond documentation in the local paths
    def paths(path):
        """Yields possible places where LilyPond documentation could live."""
        yield path
        path = os.path.join(path, 'share', 'doc', 'lilypond', 'html')
        yield path
        yield os.path.join(path, 'offline-root')

    def find(path):
        """Finds LilyPond documentation."""
        for p in paths(path):
            if os.path.isdir(os.path.join(p, 'Documentation')):
                return p

    # search in the user-set directories, if no docs, scan one level deeper
    for p in user_prefixes:
        n = find(p)
        if n:
            local.append(n)
        elif p not in system_prefixes:
            for name, dirs, files in os.walk(p):
                for d in sorted(dirs, key=util.naturalsort):
                    n = find(os.path.join(p, d))
                    if n:
                        local.append(n)
                break
    # now add the system directories if documentation is found there
    for p in system_prefixes:
        if p not in user_prefixes:
            n = find(p)
            if n:
                local.append(n)
    urls = []
    urls.extend(map(QUrl.fromLocalFile, local))
    urls.extend(map(QUrl, remote))
    if not urls:
        urls.append(QUrl("http://lilypond.org/doc/stable"))
    return urls
Esempio n. 17
0
 def loadSettings(self):
     s = QSettings()
     s.beginGroup("hyphenation")
     paths = qsettings.get_string_list(s, "paths")
     self.listedit.setValue(paths)