コード例 #1
0
ファイル: __init__.py プロジェクト: elmamyra/frescobaldi
    def openDefaultView(self, document, job, success):
        """Called when a job finishes.
        
        Open the default viewer for the created files if the user has the
        preference for this set.
        
        """
        if (
            success
            and jobattributes.get(job).mainwindow is self.mainwindow()
            and QSettings().value("lilypond_settings/open_default_view", True, bool)
        ):

            # which files were created by this job?
            import resultfiles

            extensions = set(
                os.path.splitext(filename)[1].lower() for filename in resultfiles.results(document).files_lastjob()
            )

            mgr = panelmanager.manager(self.mainwindow())
            if ".svg" in extensions or ".svgz" in extensions:
                mgr.svgview.activate()
            elif ".pdf" in extensions:
                mgr.musicview.activate()
コード例 #2
0
ファイル: documents.py プロジェクト: WedgeLeft/frescobaldi
 def update(self, newer=None):
     """Queries the resultfiles of this text document for PDF files and loads them.
     
     Returns True if new documents were loaded.
     If newer is True, only PDF files newer than the source document are returned.
     If newer is False, all PDF files are returned.
     If newer is None (default), the setting from the configuration is used.
     
     """
     if newer is None:
         newer = QSettings().value("musicview/newer_files_only", True, bool)
     
     results = resultfiles.results(self.document())
     files = results.files(".pdf", newer)
     if files:
         # reuse the older Document objects, they will probably be displaying
         # (about) the same documents, and so the viewer will remember their position.
         def docs():
             # yield existing docs and then new ones
             if self._documents:
                 for d in self._documents:
                     yield d
             while True:
                 yield Document()
         documents = []
         for filename, doc in zip(files, docs()):
             doc.setFilename(filename)
             doc.updated = newer or results.is_newer(filename)
             documents.append(doc)
         self._documents = documents
         return True
コード例 #3
0
 def update(self):
     files = resultfiles.results(self.document()).files('.mid*')
     self._files = files
     self._songs = [None] * len(files)
     if files and self.current >= len(files):
         self.current = len(files) - 1
     return bool(files)
コード例 #4
0
    def update(self, newer=None):
        """Queries the resultfiles of this text document for PDF files and loads them.

        Returns True if new documents were loaded.
        If newer is True, only PDF files newer than the source document are returned.
        If newer is False, all PDF files are returned.
        If newer is None (default), the setting from the configuration is used.

        """
        if newer is None:
            newer = QSettings().value("musicview/newer_files_only", True, bool)

        results = resultfiles.results(self.document())
        files = results.files(".pdf", newer)
        if files:
            # reuse the older Document objects, they will probably be displaying
            # (about) the same documents, and so the viewer will remember their position.
            d = {}
            if self._documents:
                for doc in self._documents:
                    if doc.filename() in files:
                        d[doc.filename()] = doc
            documents = []
            for filename in files:
                doc = d.get(filename)
                if doc:
                    doc.invalidate()
                elif popplerqt5:
                    doc = pagedview.loadPdf(filename)
                else:
                    continue
                doc.updated = newer or results.is_newer(filename)
                documents.append(doc)
            self._documents = documents
            return True
コード例 #5
0
 def exportAudio(self):
     """ Convert the current document to Audio """
     mainwin = self.mainwindow()
     doc = mainwin.currentDocument()
     midfiles = resultfiles.results(doc).files('.mid*')
     if not midfiles:
         QMessageBox.critical(
             None, _("Error"),
             _("The audio file couldn't be created. Please create midi file first"
               ))
         return False
     orgname = doc.url().toLocalFile()
     midifile = midfiles[0]
     wavfile = os.path.splitext(orgname)[0] + '.wav'
     caption = app.caption(_("dialog title", "Export Audio File"))
     filetypes = '{0} (*.wav);;{1} (*)'.format(_("WAV Files"),
                                               _("All Files"))
     wavfile = QFileDialog.getSaveFileName(mainwin, caption, wavfile,
                                           filetypes)[0]
     if not wavfile:
         return False  # cancelled
     dlg = AudioExportDialog(mainwin, caption)
     dlg.setAttribute(Qt.WA_DeleteOnClose)  # we use it only once
     dlg.midi2wav(midifile, wavfile)
     dlg.show()
コード例 #6
0
ファイル: documents.py プロジェクト: stweil/frescobaldi
    def update(self, newer=None):
        """Queries the resultfiles of this text document for PDF files and loads them.
        
        Returns True if new documents were loaded.
        If newer is True, only PDF files newer than the source document are returned.
        If newer is False, all PDF files are returned.
        If newer is None (default), the setting from the configuration is used.
        
        """
        if newer is None:
            newer = QSettings().value("musicview/newer_files_only", True, bool)

        results = resultfiles.results(self.document())
        files = results.files(".pdf", newer)
        if files:
            # reuse the older Document objects, they will probably be displaying
            # (about) the same documents, and so the viewer will remember their position.
            def docs():
                # yield existing docs and then new ones
                if self._documents:
                    for d in self._documents:
                        yield d
                while True:
                    yield Document()

            documents = []
            for filename, doc in zip(files, docs()):
                doc.setFilename(filename)
                doc.updated = newer or results.is_newer(filename)
                documents.append(doc)
            self._documents = documents
            return True
コード例 #7
0
ファイル: midifiles.py プロジェクト: brownian/frescobaldi
 def update(self):
     files = resultfiles.results(self.document()).files('.mid*')
     self._files = files
     self._songs = [None] * len(files)
     if files and self.current >= len(files):
         self.current = len(files) - 1
     return bool(files)
コード例 #8
0
ファイル: mainwindow.py プロジェクト: brumleygap/frescobaldi
 def currentDirectory(self):
     """Returns the current directory of the current document.
     
     If the document has no filename yet, returns the configured default
     directory, or the user's home directory.
     Is that is not set as well, returns the current directory
     of the application.
     
     """
     import resultfiles
     return (resultfiles.results(self.currentDocument()).currentDirectory()
             or app.basedir() or QDir.homePath() or os.getcwdu())
コード例 #9
0
 def currentDirectory(self):
     """Returns the current directory of the current document.
     
     If the document has no filename yet, returns the configured default
     directory, or the user's home directory.
     Is that is not set as well, returns the current directory
     of the application.
     
     """
     import resultfiles
     return (resultfiles.results(self.currentDocument()).currentDirectory()
             or app.basedir() or QDir.homePath() or os.getcwdu())
コード例 #10
0
ファイル: autocompile.py プロジェクト: cognot/frescobaldi
 def initialize(self):
     document = self.document()
     if document.isModified():
         self._dirty = True
     else:
         # look for existing result files in the default output format
         s = QSettings()
         s.beginGroup("lilypond_settings")
         if s.value("default_output_target", "pdf", type("")) == "svg":
             ext = '.svg*'
         else:
             ext = '.pdf'
         self._dirty = not resultfiles.results(document).files(ext)
     self._hash = None if self._dirty else documentinfo.docinfo(document).token_hash()
コード例 #11
0
 def initialize(self):
     document = self.document()
     if document.isModified():
         self._dirty = True
     else:
         # look for existing result files in the default output format
         s = QSettings()
         s.beginGroup("lilypond_settings")
         if s.value("default_output_target", "pdf", type("")) == "svg":
             ext = '.svg*'
         else:
             ext = '.pdf'
         self._dirty = not resultfiles.results(document).files(ext)
     self._hash = None if self._dirty else documentinfo.docinfo(
         document).token_hash()
コード例 #12
0
ファイル: autocompile.py プロジェクト: ryanakca/frescobaldi
 def __init__(self, document):
     document.contentsChanged.connect(self.slotDocumentContentsChanged)
     document.saved.connect(self.slotDocumentSaved)
     if document.isModified():
         self._dirty = True
     else:
         # look for existing result files in the default output format
         s = QSettings()
         s.beginGroup("lilypond_settings")
         if s.value("default_output_target", "pdf", type("")) == "svg":
             ext = '.svg*'
         else:
             ext = '.pdf'
         self._dirty = not resultfiles.results(document).files(ext)
     self._hash = None if self._dirty else documentinfo.docinfo(document).token_hash()
     jobmanager.manager(document).started.connect(self.slotJobStarted)
コード例 #13
0
    def openDefaultView(self, document, j, success):
        """Called when a job finishes.

        Open the default viewer for the created files if the user has the
        preference for this set.

        """
        if (success and job.attributes.get(j).mainwindow is self.mainwindow()
                and QSettings().value("lilypond_settings/open_default_view", True, bool)):

            # which files were created by this job?
            import resultfiles
            extensions = set(os.path.splitext(filename)[1].lower()
                for filename in resultfiles.results(document).files_lastjob())

            mgr = panelmanager.manager(self.mainwindow())
            if '.svg' in extensions or '.svgz' in extensions:
                mgr.svgview.activate()
            elif '.pdf' in extensions:
                mgr.musicview.activate()
コード例 #14
0
ファイル: __init__.py プロジェクト: brownian/frescobaldi
 def exportAudio(self):
     """ Convert the current document to Audio """
     mainwin = self.mainwindow()
     doc = mainwin.currentDocument()
     midfiles = resultfiles.results(doc).files('.mid*')
     if not midfiles:
         QMessageBox.critical(None, _("Error"),
                 _("The audio file couldn't be created. Please create midi file first"))
         return False
     orgname = doc.url().toLocalFile()
     midifile = midfiles[0]
     wavfile = os.path.splitext(orgname)[0] + '.wav'
     caption = app.caption(_("dialog title", "Export Audio File"))
     filetypes = '{0} (*.wav);;{1} (*)'.format(_("WAV Files"), _("All Files"))
     wavfile = QFileDialog.getSaveFileName(mainwin, caption, wavfile, filetypes)[0]
     if not wavfile:
         return False # cancelled
     dlg = AudioExportDialog(mainwin, caption)
     dlg.setAttribute(Qt.WA_DeleteOnClose) # we use it only once
     dlg.midi2wav(midifile, wavfile)
     dlg.show()
コード例 #15
0
ファイル: documents.py プロジェクト: m0003r/frescobaldi
 def update(self):
     """Queries the resultfiles of this text document for PDF files and loads them.
     
     Returns True if new documents were loaded.
     
     """
     files = resultfiles.results(self.document()).files(".pdf")
     if files:
         # reuse the older Document objects, they will probably be displaying
         # (about) the same documents, and so the viewer will remember their position.
         def docs():
             # yield existing docs and then new ones
             for d in self._documents:
                 yield d
             while True:
                 yield Document()
         documents = []
         for filename, doc in zip(files, docs()):
             doc.setFilename(filename)
             documents.append(doc)
         self._documents = documents
         return True
コード例 #16
0
ファイル: result_menu.py プロジェクト: mbsrz1972/frescobaldi
 def populate(self):
     self.clear()
     doc = self.parentWidget().currentDocument()
     if doc:
         import resultfiles
         files = resultfiles.results(doc).files()
         first = True
         for group in util.group_files(files,
                 ('pdf', 'mid midi', 'svg svgz', 'png', '!ly ily lyi')):
             if group:
                 if not first:
                     self.addSeparator()
                 first = False
                 for f in group:
                     name = os.path.split(f)[1]
                     a = self.addAction(name)
                     a.setIcon(icons.file_type(f))
                     a.filename = f
         if not self.actions():
             a = self.addAction(_("No files available"))
             a.setEnabled(False)
         else:
             util.addAccelerators(self.actions())
コード例 #17
0
ファイル: result_menu.py プロジェクト: shimpe/frescobaldi
 def populate(self):
     self.clear()
     doc = self.parentWidget().currentDocument()
     if doc:
         import resultfiles
         files = resultfiles.results(doc).files()
         first = True
         for group in util.group_files(
                 files,
             ('pdf', 'mid midi', 'svg svgz', 'png', '!ly ily lyi')):
             if group:
                 if not first:
                     self.addSeparator()
                 first = False
                 for f in group:
                     name = os.path.split(f)[1]
                     a = self.addAction(name)
                     a.setIcon(icons.file_type(f))
                     a.filename = f
         if not self.actions():
             a = self.addAction(_("No files available"))
             a.setEnabled(False)
         else:
             qutil.addAccelerators(self.actions())
コード例 #18
0
ファイル: svgfiles.py プロジェクト: arnaldorusso/frescobaldi
 def update(self):
     files = resultfiles.results(self.document()).files('.svg*')
     self._files = files
     if files and self.current >= len(files):
         self.current = len(files) - 1
     return bool(files)
コード例 #19
0
ファイル: svgfiles.py プロジェクト: ryanakca/frescobaldi
 def update(self):
     files = resultfiles.results(self.document()).files('.svg*')
     self._files = files
     if files and self.current >= len(files):
         self.current = len(files) - 1
     return bool(files)