def setup(): """Create the global menu bar, and switch to no-session.""" global _menubar _menubar = menubar() import sessions sessions.setCurrentSession(None)
def newSession(self): from . import dialog name = dialog.SessionEditor(self.mainwindow()).edit() if name: sessions.setCurrentSession(name) self.saveCurrentSession()
def restoreSession(key): """Restore a session specified by key, previously saved by the session manager.""" settings = sessionSettings(key) ## restore current named session name session_name = settings.value('session_name', "", str) if session_name: import sessions sessions.setCurrentSession(session_name) ## restore documents numdocuments = settings.value('numdocuments', 0, int) doc = None for index in range(numdocuments): settings.beginGroup("document{0}".format(index)) url = settings.value("url", QUrl(), QUrl) if url.isEmpty(): import document doc = document.EditorDocument() else: try: doc = app.openUrl(url) except IOError: pass settings.endGroup() # open at least one if doc is None: doc = app.openUrl(QUrl()) ## restore windows numwindows = settings.value('numwindows', 0, int) if numwindows > 0: for index in range(numwindows): settings.beginGroup("mainwindow{0}".format(index)) win = mainwindow.MainWindow() win.readSessionSettings(settings) win.show() app.qApp.processEvents() # init (re)size dock tools u = settings.value("active_document", QUrl(), QUrl) # we don't use app.findDocument because it does not allow empty url for d in app.documents: if u == d.url(): win.setCurrentDocument(d) break else: win.setCurrentDocument(app.documents[0]) settings.endGroup() else: win = mainwindow.MainWindow() win.show() app.qApp.processEvents() # init (re)size dock tools
def restoreSession(key): """Restore a session specified by key, previously saved by the session manager.""" settings = sessionSettings(key) ## restore current named session name session_name = settings.value('session_name', "", str) if session_name: import sessions sessions.setCurrentSession(session_name) ## restore documents numdocuments = settings.value('numdocuments', 0, int) doc = None for index in range(numdocuments): settings.beginGroup("document{0}".format(index)) url = settings.value("url", QUrl(), QUrl) if url.isEmpty(): import document doc = document.EditorDocument() else: try: doc = app.openUrl(url) except IOError: pass settings.endGroup() # open at least one if doc is None: doc = app.openUrl(QUrl()) ## restore windows numwindows = settings.value('numwindows', 0, int) if numwindows > 0: for index in range(numwindows): settings.beginGroup("mainwindow{0}".format(index)) win = mainwindow.MainWindow() win.readSessionSettings(settings) win.show() u = settings.value("active_document", QUrl(), QUrl) # we don't use app.findDocument because it does not allow empty url for d in app.documents: if u == d.url(): win.setCurrentDocument(d) break else: win.setCurrentDocument(app.documents[0]) settings.endGroup() else: win = mainwindow.MainWindow() win.show()
def noSession(self): if sessions.currentSession(): self.saveCurrentSessionIfDesired() sessions.setCurrentSession(None)
def setup(): """Create the global menu bar, and switch to no-session.""" menubar(app.qApp._menubar) import sessions sessions.setCurrentSession(None)