Beispiel #1
0
 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()
Beispiel #2
0
 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()
Beispiel #3
0
 def slotSessionChanged(self, name):
     """Called whenever the current session is changed
     (also on application startup or after a session is created).
     If the session already exists load manuscripts from the
     session object and load them in the viewer."""
     if name:
         import sessions
         session = sessions.sessionGroup(name)
         if session.contains("urls"): # the session is not new
             files_key = "{}-files".format(self.viewerName())
             active_file_key = "{}-active-file".format(self.viewerName())
             ds = self.actionCollection.viewer_document_select
             ds.removeAllViewdocs(update = False)
             self.clear()
             viewdocs = []
             for v in session.value(files_key, ""):
                 filename = v[0]
                 position = v[1]
                 doc = documents.Document(filename)
                 viewdocs.append(doc)
                 self._positions[doc] = position
                 if not os.path.isfile(filename):
                     doc.ispresent = False
             # Temporary hack to suppress the resize event that
             # clears the position of the current document
             self.view._centerPos = None
             ds.loadViewdocs(viewdocs,
                 active_viewdoc = session.value(active_file_key, ""),
                 sort = False) # may be replaced by a Preference
Beispiel #4
0
 def slotSessionChanged(self, name):
     """Called whenever the current session is changed
     (also on application startup or after a session is created).
     If the session already exists load manuscripts from the
     session object and load them in the viewer."""
     if name:
         import sessions
         import qsettings
         g = sessions.sessionGroup(name)
         if g.contains("urls"):  # the session is not new
             ds = self.actionCollection.viewer_document_select
             ds.removeAllViewdocs(update=False)
             self.clear()
             viewdocs = []
             files_key = "{}-documents".format(self.viewerName())
             active_file = ""
             for i in range(g.beginReadArray(files_key)):
                 g.setArrayIndex(i)
                 filename = g.value("filename", "", str)
                 if filename:
                     doc = pagedview.loadPdf(filename)
                     viewdocs.append(doc)
                     # can it load?
                     doc.ispresent = os.path.isfile(filename)
                     if g.value("isactive", False, bool):
                         active_file = filename
                     props = self.view.properties().load(g)
                     self.view.documentPropertyStore.set(doc, props)
             ds.loadViewdocs(viewdocs,
                             active_viewdoc=active_file,
                             sort=False)  # may be replaced by a Preference
Beispiel #5
0
 def slotSessionChanged(self, name):
     """Called whenever the current session is changed
     (also on application startup or after a session is created).
     If the session already exists load manuscripts from the
     session object and load them in the viewer."""
     if name:
         import sessions
         session = sessions.sessionGroup(name)
         if session.contains("urls"): # the session is not new
             files_key = "{}-files".format(self.viewerName())
             active_file_key = "{}-active-file".format(self.viewerName())
             ds = self.actionCollection.viewer_document_select
             ds.removeAllViewdocs(update = False)
             self.clear()
             viewdocs = []
             for v in session.value(files_key, ""):
                 filename = v[0]
                 position = v[1]
                 doc = documents.Document(filename)
                 viewdocs.append(doc)
                 self._positions[doc] = position
                 if not os.path.isfile(filename):
                     doc.ispresent = False
             # Temporary hack to suppress the resize event that
             # clears the position of the current document
             self.view._centerPos = None
             ds.loadViewdocs(viewdocs,
                 active_viewdoc = session.value(active_file_key, ""),
                 sort = False) # may be replaced by a Preference
Beispiel #6
0
 def save(self, name):
     settings = sessions.sessionGroup(name)
     settings.setValue("autosave", self.autosave.isChecked())
     settings.setValue("basedir", self.basedir.path())
Beispiel #7
0
 def load(self, name):
     settings = sessions.sessionGroup(name)
     self.autosave.setChecked(settings.value("autosave", True, bool))
     self.basedir.setPath(settings.value("basedir", "", type("")))
Beispiel #8
0
 def save(self, name):
     settings = sessions.sessionGroup(name)
     settings.setValue("autosave", self.autosave.isChecked())
     settings.setValue("basedir", self.basedir.path())
Beispiel #9
0
 def load(self, name):
     settings = sessions.sessionGroup(name)
     self.autosave.setChecked(settings.value("autosave", True, bool))
     self.basedir.setPath(settings.value("basedir", "", type("")))
Beispiel #10
0
 def load(self, name):
     settings = sessions.sessionGroup(name)
     self.autosave.setChecked(settings.value("autosave", True) not in (False, 'false'))
     self.basedir.setPath(settings.value("basedir", ""))