def saveCurrentSessionIfDesired(self): """Saves the current session if it is configured to save itself on exit.""" cur = sessions.currentSession() if cur: s = sessions.sessionGroup(cur) if s.value("autosave", True) not in (False, "false"): self.saveCurrentSession()
def startSession(self, name): """Switches to the given session.""" if name == sessions.currentSession(): return if self.mainwindow().queryClose(): active = sessions.loadSession(name) or document.Document() self.mainwindow().setCurrentDocument(active)
def saveCurrentSessionIfDesired(self): """Saves the current session if it is configured to save itself on exit.""" cur = sessions.currentSession() if cur: s = sessions.sessionGroup(cur) if s.value("autosave", True, bool): self.saveCurrentSession()
def populate(self): ac = manager.get(self.parentWidget()).actionCollection ag = self._actionGroup for a in ag.actions(): if a is not ac.session_none: self.removeAction(a) ag.removeAction(a) ac.session_none.setChecked(not sessions.currentSession()) for name in sessions.sessionNames(): a = self.addAction(name.replace('&', '&&')) a.setCheckable(True) if name == sessions.currentSession(): a.setChecked(True) a.setObjectName(name) ag.addAction(a) qutil.addAccelerators(self.actions())
def saveCurrentSession(self): """Saves the current session.""" cur = sessions.currentSession() if cur: documents = self.mainwindow().documents() active = self.mainwindow().currentDocument() sessions.saveSession(cur, documents, active) self.saveSessionData(cur)
def startSession(self, name): """Switches to the given session.""" if name == sessions.currentSession(): return if self.mainwindow().queryClose(): active = sessions.loadSession(name) if active: self.mainwindow().setCurrentDocument(active) else: self.mainwindow().cleanStart()
def add_session(menu, name, group=None): name = name.replace('&', '&&') fullname = group + '/' + name if group else name a = menu.addAction(name) a.setCheckable(True) if fullname == sessions.currentSession(): a.setChecked(True) if group: menu.setTitle('* ' + menu.title()) a.setObjectName(fullname) self._actionGroup.addAction(a)
def reset_menu(): for m in self.groupMenus: m.deleteLater() self.groupMenus = [] ac = manager.get(self.parentWidget()).actionCollection ag = self._actionGroup for a in ag.actions(): if a is not ac.session_none: self.removeAction(a) ag.removeAction(a) ac.session_none.setChecked(not sessions.currentSession())
def saveSession(key): """Save the current session under key.""" settings = sessionSettings(key) ## save current named session name import sessions settings.setValue('session_name', sessions.currentSession() or "") ## save the list of open documents settings.setValue('numdocuments', len(app.documents)) for index, d in enumerate(app.documents): settings.beginGroup("document{0}".format(index)) settings.setValue("url", d.url()) settings.endGroup() ## save windows settings.setValue('numwindows', len(app.windows)) for index, win in enumerate(app.windows): settings.beginGroup("mainwindow{0}".format(index)) win.writeSessionSettings(settings) settings.setValue("active_document", win.currentDocument().url()) settings.endGroup() settings.sync()
def __init__(self, panel): """Creates the Poppler View for the panel.""" super(AbstractPopplerWidget, self).__init__(panel) self.actionCollection = panel.actionCollection self.createProtectedFields() self.createLayout() self._toolbar = self.createToolbar() self._main_layout.addWidget(self._toolbar) self.createHighlighters() self.createView() self.createContextMenu() self.connectSlots() # load current session when the widget is created import sessions cs = sessions.currentSession() if cs: self.slotSessionChanged(cs) self.readSettings() userguide.openWhatsThis(self) app.translateUI(self)
def load(self): names = sessions.sessionNames() current = sessions.currentSession() self.setValue(names) if current in names: self.setCurrentRow(names.index(current))
def saveSession(self): if not sessions.currentSession(): return self.newSession() self.saveCurrentSession()
def noSession(self): if sessions.currentSession(): self.saveCurrentSessionIfDesired() sessions.setCurrentSession(None)