def load(): global _recentfiles if _recentfiles is not None: return _recentfiles = [] urls = qsettings.get_url_list(QSettings(), "recent_files") for url in urls: if os.access(url.toLocalFile(), os.R_OK): _recentfiles.append(url) del _recentfiles[MAXLEN:] app.aboutToQuit.connect(save)
def loadSession(name): """Loads the given session (without closing other docs first). Return the document that should become the active one. If None is returned, the session did not open any documents! """ session = sessionGroup(name) urls = qsettings.get_url_list(session, "urls") active = session.value("active", -1, int) result = None docs = [] for url in urls: try: doc = app.openUrl(url) except IOError: pass else: docs.append(doc) setCurrentSession(name) if docs: if active not in range(len(docs)): active = 0 return docs[active]