Пример #1
0
def setup():
    """Create the global menu bar, and switch to no-session."""
    global _menubar
    _menubar = menubar()
    import sessions

    sessions.setCurrentSession(None)
Пример #2
0
    def newSession(self):
        from . import dialog

        name = dialog.SessionEditor(self.mainwindow()).edit()
        if name:
            sessions.setCurrentSession(name)
            self.saveCurrentSession()
Пример #3
0
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
Пример #4
0
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()
Пример #5
0
 def noSession(self):
     if sessions.currentSession():
         self.saveCurrentSessionIfDesired()
         sessions.setCurrentSession(None)
Пример #6
0
def setup():
    """Create the global menu bar, and switch to no-session."""
    global _menubar
    _menubar = menubar()
    import sessions
    sessions.setCurrentSession(None)
Пример #7
0
 def noSession(self):
     if sessions.currentSession():
         self.saveCurrentSessionIfDesired()
         sessions.setCurrentSession(None)
Пример #8
0
 def newSession(self):
     from . import dialog
     name = dialog.SessionEditor(self.mainwindow()).edit()
     if name:
         sessions.setCurrentSession(name)
         self.saveCurrentSession()
Пример #9
0
def setup():
    """Create the global menu bar, and switch to no-session."""
    menubar(app.qApp._menubar)
    import sessions
    sessions.setCurrentSession(None)