Пример #1
0
def menu_tools(mainwindow):
    m = Menu(_('menu title', '&Tools'), mainwindow)
    
    ac = documentactions.get(mainwindow).actionCollection
    m.addAction(ac.tools_indent_auto)
    m.addAction(ac.tools_indent_indent)
    m.addAction(ac.tools_reformat)
    m.addAction(ac.tools_remove_trailing_whitespace)
    m.addSeparator()
    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_pitch(mainwindow))
    m.addMenu(menu_tools_rest(mainwindow))
    m.addMenu(menu_tools_rhythm(mainwindow))
    m.addMenu(menu_tools_lyrics(mainwindow))
    m.addMenu(menu_tools_quick_remove(mainwindow))
    m.addSeparator()
    ac = documentactions.get(mainwindow).actionCollection
    m.addAction(ac.tools_convert_ly)
    m.addAction(mainwindow.actionCollection.file_open_current_directory)
    m.addAction(mainwindow.actionCollection.file_open_command_prompt)
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    return m
Пример #2
0
def menu_file(mainwindow):
    m = Menu(_("menu title", "&File"), mainwindow)
    ac = mainwindow.actionCollection
    
    m.addAction(ac.file_new)
    m.addMenu(snippet.menu.TemplateMenu(mainwindow))
    m.addSeparator()
    m.addAction(ac.file_open)
    m.addAction(ac.file_open_recent)
    m.addAction(ac.file_insert_file)
    m.addAction(documentactions.get(mainwindow).actionCollection.file_open_file_at_cursor)
    m.addAction(ac.file_open_current_directory)
    m.addSeparator()
    m.addAction(ac.file_save)
    m.addAction(ac.file_save_as)
    m.addAction(ac.file_save_copy_as)
    m.addAction(panelmanager.manager(mainwindow).snippettool.actionCollection.file_save_as_template)
    m.addSeparator()
    m.addAction(ac.file_save_all)
    m.addSeparator()
    m.addAction(panelmanager.manager(mainwindow).musicview.actionCollection.music_print)
    m.addAction(ac.file_print_source)
    m.addMenu(menu_file_export(mainwindow))
    m.addSeparator()
    m.addAction(ac.file_close)
    m.addAction(ac.file_close_other)
    m.addAction(ac.file_close_all)
    m.addSeparator()
    m.addAction(ac.file_quit)
    return m
Пример #3
0
def menu_tools(mainwindow):
    m = Menu(_('menu title', '&Tools'), mainwindow)

    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_format(mainwindow))
    m.addMenu(menu_tools_transform(mainwindow))
    fac = fonts.fonts(mainwindow).actionCollection
    m.addAction(fac.fonts_document_fonts)
    dac = documentactions.get(mainwindow).actionCollection
    m.addAction(dac.tools_convert_ly)
    m.addSeparator()
    m.addMenu(menu_tools_directories(mainwindow))
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    extensions = app.extensions()
    # store a reference to the Tools menu
    extensions.set_tools_menu(m)
    ext_menu = extensions.menu('tools')

    if not ext_menu.isEmpty():
        m.addSeparator()
        m.addMenu(ext_menu)
    return m
Пример #4
0
def menu_tools(mainwindow):
    m = Menu(_('menu title', '&Tools'), mainwindow)

    ac = documentactions.get(mainwindow).actionCollection
    m.addAction(ac.tools_indent_auto)
    m.addAction(ac.tools_indent_indent)
    m.addAction(ac.tools_reformat)
    m.addAction(ac.tools_remove_trailing_whitespace)
    m.addSeparator()
    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_pitch(mainwindow))
    m.addMenu(menu_tools_rest(mainwindow))
    m.addMenu(menu_tools_rhythm(mainwindow))
    m.addMenu(menu_tools_lyrics(mainwindow))
    m.addMenu(menu_tools_quick_remove(mainwindow))
    m.addSeparator()
    ac = documentactions.get(mainwindow).actionCollection
    m.addAction(ac.tools_convert_ly)
    m.addAction(mainwindow.actionCollection.file_open_current_directory)
    m.addAction(mainwindow.actionCollection.file_open_command_prompt)
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    return m
Пример #5
0
def menu_tools(mainwindow):
    m = Menu(_("menu title", "&Tools"), mainwindow)

    m.addAction(scorewiz.ScoreWizard.instance(mainwindow).actionCollection.scorewiz)
    m.addSeparator()
    ac = documentactions.get(mainwindow).actionCollection
    m.addAction(ac.tools_indent_auto)
    m.addAction(ac.tools_indent_indent)
    m.addAction(ac.tools_reformat)
    m.addSeparator()
    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_pitch(mainwindow))
    m.addMenu(menu_tools_rhythm(mainwindow))
    m.addMenu(menu_tools_lyrics(mainwindow))
    m.addMenu(menu_tools_quick_remove(mainwindow))
    m.addSeparator()
    ac = documentactions.get(mainwindow).actionCollection
    m.addAction(ac.tools_convert_ly)
    m.addAction(mainwindow.actionCollection.file_open_current_directory)
    m.addAction(mainwindow.actionCollection.file_open_command_prompt)
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    return m
Пример #6
0
def menu_file(mainwindow):
    m = Menu(_("menu title", "&File"), mainwindow)
    ac = mainwindow.actionCollection
    
    m.addAction(ac.file_new)
    m.addMenu(snippet.menu.TemplateMenu(mainwindow))
    m.addAction(scorewiz.ScoreWizard.instance(mainwindow).actionCollection.newwithwiz)
    m.addSeparator()
    m.addAction(ac.file_open)
    m.addAction(ac.file_open_recent)
    m.addAction(ac.file_insert_file)
    m.addAction(documentactions.get(mainwindow).actionCollection.file_open_file_at_cursor)
    m.addSeparator()
    m.addAction(ac.file_save)
    m.addAction(ac.file_save_as)
    m.addAction(ac.file_save_copy_as)
    m.addAction(panelmanager.manager(mainwindow).snippettool.actionCollection.file_save_as_template)
    m.addAction(ac.file_save_all)
    m.addSeparator()
    m.addAction(ac.file_reload)
    m.addAction(ac.file_reload_all)
    m.addAction(ac.file_external_changes)
    m.addSeparator()
    m.addAction(panelmanager.manager(mainwindow).musicview.actionCollection.music_print)
    m.addAction(ac.file_print_source)
    m.addMenu(menu_file_export(mainwindow))
    m.addSeparator()
    m.addAction(ac.file_close)
    m.addAction(ac.file_close_other)
    m.addAction(ac.file_close_all)
    m.addSeparator()
    m.addAction(ac.file_quit)
    return m
Пример #7
0
def menu_help(mainwindow):
    m = Menu(_('menu title', '&Help'), mainwindow)
    ac = mainwindow.actionCollection
    m.addAction(ac.help_manual)
    m.addAction(ac.help_whatsthis)
    m.addSeparator()
    m.addAction(panelmanager.manager(mainwindow).docbrowser.actionCollection.help_lilypond_doc)
    m.addAction(panelmanager.manager(mainwindow).docbrowser.actionCollection.help_lilypond_context)
    m.addSeparator()
    m.addAction(ac.help_bugreport)
    m.addSeparator()
    m.addAction(ac.help_about)
    return m
Пример #8
0
def menu_help(mainwindow):
    m = Menu(_('menu title', '&Help'), mainwindow)
    ac = mainwindow.actionCollection
    m.addAction(ac.help_manual)
    m.addAction(ac.help_whatsthis)
    m.addSeparator()
    m.addAction(panelmanager.manager(mainwindow).docbrowser.actionCollection.help_lilypond_doc)
    m.addAction(panelmanager.manager(mainwindow).docbrowser.actionCollection.help_lilypond_context)
    m.addSeparator()
    m.addAction(ac.help_bugreport)
    m.addSeparator()
    m.addAction(ac.help_about)
    return m
Пример #9
0
def contextmenu(view):
    cursor = view.textCursor()
    menu = view.createStandardContextMenu()
    mainwindow = view.window()

    # create the actions in the actions list
    actions = []

    actions.extend(open_files(cursor, menu, mainwindow))

    actions.extend(jump_to_definition(cursor, menu, mainwindow))

    if cursor.hasSelection():
        import panelmanager
        actions.append(mainwindow.actionCollection.edit_copy_colored_html)
        actions.append(
            panelmanager.manager(
                mainwindow).snippettool.actionCollection.copy_to_snippet)
        import documentactions
        ac = documentactions.get(mainwindow).actionCollection
        actions.append(ac.edit_cut_assign)
        actions.append(ac.edit_move_to_include_file)

    # now add the actions to the standard menu
    if actions:
        first_action = menu.actions()[0] if menu.actions() else None
        if first_action:
            first_action = menu.insertSeparator(first_action)
            menu.insertActions(first_action, actions)
        else:
            menu.addActions(actions)
    return menu
Пример #10
0
 def createToolBars(self):
     ac = self.actionCollection
     self.toolbar_main = t = self.addToolBar('')
     t.setObjectName('toolbar_main')
     t.addAction(ac.file_new)
     t.addAction(ac.file_open)
     t.addAction(ac.file_save)
     t.addAction(ac.file_save_as)
     t.addAction(ac.file_close)
     t.addSeparator()
     t.addAction(browseriface.get(self).actionCollection.go_back)
     t.addAction(browseriface.get(self).actionCollection.go_forward)
     t.addSeparator()
     t.addAction(ac.edit_undo)
     t.addAction(ac.edit_redo)
     t.addSeparator()
     t.addAction(scorewiz.ScoreWizard.instance(self).actionCollection.scorewiz)
     t.addAction(engrave.engraver(self).actionCollection.engrave_runner)
     
     self.toolbar_music = t = self.addToolBar('')
     t.setObjectName('toolbar_music')
     ma = panelmanager.manager(self).musicview.actionCollection
     t.addAction(ma.music_document_select)
     t.addAction(ma.music_print)
     t.addSeparator()
     t.addAction(ma.music_zoom_in)
     t.addAction(ma.music_zoom_combo)
     t.addAction(ma.music_zoom_out)
     t.addSeparator()
     t.addAction(ma.music_prev_page)
     t.addAction(ma.music_pager)
     t.addAction(ma.music_next_page)
Пример #11
0
 def makeCommandLine(self):
     """Reads the widgets and builds a command line."""
     f = formats[self.outputCombo.currentIndex()]
     self.resolutionCombo.setEnabled('resolution' in f.widgets)
     self.antialiasSpin.setEnabled('antialias' in f.widgets)
     cmd = ["$lilypond"]
     
     if self.modeCombo.currentIndex() == 0:   # preview mode
         cmd.append('-dpoint-and-click')
     elif self.modeCombo.currentIndex() == 1: # publish mode
         cmd.append('-dno-point-and-click')
     else:                                    # debug mode
         args = panelmanager.manager(self.parent()).layoutcontrol.widget().preview_options()
         cmd.extend(args)
     
     if self.deleteCheck.isChecked():
         cmd.append('-ddelete-intermediate-files')
     else:
         cmd.append('-dno-delete-intermediate-files')
     d = {
         'version': self.lilyChooser.lilyPondInfo().version,
         'resolution': self.resolutionCombo.currentText(),
         'antialias': self.antialiasSpin.value(),
     }
     cmd.append("$include")
     cmd.extend(f.options(d))
     cmd.append("$filename")
     self.commandLine.setText(' '.join(cmd))
Пример #12
0
    def makeCommandLine(self):
        """Reads the widgets and builds a command line."""
        f = formats[self.outputCombo.currentIndex()]
        self.resolutionCombo.setEnabled('resolution' in f.widgets)
        self.antialiasSpin.setEnabled('antialias' in f.widgets)
        cmd = ["$lilypond"]

        if self.modeCombo.currentIndex() == 0:  # preview mode
            cmd.append('-dpoint-and-click')
        elif self.modeCombo.currentIndex() == 1:  # publish mode
            cmd.append('-dno-point-and-click')
        else:  # debug mode
            args = panelmanager.manager(
                self.parent()).layoutcontrol.widget().preview_options()
            cmd.extend(args)

        if self.deleteCheck.isChecked():
            cmd.append('-ddelete-intermediate-files')
        else:
            cmd.append('-dno-delete-intermediate-files')

        if self.embedSourceCodeCheck.isChecked():
            cmd.append('-dembed-source-code')

        d = {
            'version': self.lilyChooser.lilyPondInfo().version,
            'resolution': self.resolutionCombo.currentText(),
            'antialias': self.antialiasSpin.value(),
        }
        cmd.append("$include")
        cmd.extend(f.options(d))
        cmd.append("$filename")
        self.commandLine.setText(' '.join(cmd))
Пример #13
0
    def engrave(self, mode='preview', document=None, may_save=True):
        """Starts an engraving job.

        The mode can be 'preview', 'publish', or 'layout-control'. The last
        one uses the settings in the Layout Control Options panel. The
        default mode is 'preview'.

        If document is not specified, it is either the sticky or current
        document.

        If may_save is False, the document will not be saved before running
        LilyPond, even if the preference setting "save document before LilyPond
        is run" is enabled.

        """
        if mode == 'preview':
            args = ['-dpoint-and-click']
        elif mode == 'publish':
            args = None  # command.defaultJob() will handle publish mode
        elif mode == 'layout-control':
            args = panelmanager.manager(
                self.mainwindow()).layoutcontrol.widget().preview_options()
        doc = document or self.document()
        if may_save:
            self.saveDocumentIfDesired()
        from . import command
        self.runJob(command.defaultJob(doc, args), doc)
Пример #14
0
def menu_edit(mainwindow):
    m = Menu(_("menu title", "&Edit"), mainwindow)
    ac = mainwindow.actionCollection

    m.addAction(ac.edit_undo)
    m.addAction(ac.edit_redo)
    m.addSeparator()
    m.addAction(documentactions.get(mainwindow).actionCollection.edit_cut_assign)
    m.addAction(ac.edit_cut)
    m.addAction(ac.edit_copy)
    m.addAction(panelmanager.manager(mainwindow).snippettool.actionCollection.copy_to_snippet)
    m.addAction(ac.edit_copy_colored_html)
    m.addAction(ac.edit_paste)
    m.addSeparator()
    m.addAction(ac.edit_select_all)
    m.addAction(ac.edit_select_current_toplevel)
    m.addAction(ac.edit_select_none)
    m.addSeparator()
    m.addAction(ac.edit_find)
    m.addAction(ac.edit_find_next)
    m.addAction(ac.edit_find_previous)
    m.addAction(ac.edit_replace)
    m.addSeparator()
    m.addAction(ac.edit_preferences)
    return m    
Пример #15
0
def contextmenu(view):
    cursor = view.textCursor()
    menu = view.createStandardContextMenu()
    mainwindow = view.window()

    # create the actions in the actions list
    actions = []

    actions.extend(open_files(cursor, menu, mainwindow))

    actions.extend(jump_to_definition(cursor, menu, mainwindow))


    if cursor.hasSelection():
        import panelmanager
        actions.append(mainwindow.actionCollection.edit_copy_colored_html)
        actions.append(panelmanager.manager(mainwindow).snippettool.actionCollection.copy_to_snippet)
        import documentactions
        ac = documentactions.get(mainwindow).actionCollection
        actions.append(ac.edit_cut_assign)
        actions.append(ac.edit_move_to_include_file)

    # now add the actions to the standard menu
    if actions:
        first_action = menu.actions()[0] if menu.actions() else None
        if first_action:
            first_action = menu.insertSeparator(first_action)
            menu.insertActions(first_action, actions)
        else:
            menu.addActions(actions)
    menu.addSeparator()
    extensions = app.extensions().menu('editor')
    if not extensions.isEmpty():
        menu.addMenu(extensions)
    return menu
Пример #16
0
def menu_view(mainwindow):
    m = Menu(_("menu title", "&View"), mainwindow)
    ac = mainwindow.actionCollection
    
    m.addAction(ac.view_next_document)
    m.addAction(ac.view_previous_document)
    m.addSeparator()
    m.addAction(ac.view_wrap_lines)
    m.addAction(documentactions.get(mainwindow).actionCollection.view_highlighting)
    m.addAction(sidebar.SideBarManager.instance(mainwindow).actionCollection.view_linenumbers)
    m.addMenu(menu_view_folding(mainwindow))
    m.addSeparator()
    m.addAction(documentactions.get(mainwindow).actionCollection.view_goto_file_or_definition)
    ac = browseriface.get(mainwindow).actionCollection
    m.addAction(ac.go_back)
    m.addAction(ac.go_forward)
    m.addSeparator()
    ac = matcher.Matcher.instance(mainwindow).actionCollection
    m.addAction(ac.view_matching_pair)
    m.addAction(ac.view_matching_pair_select)
    m.addSeparator()
    ac = bookmarkmanager.BookmarkManager.instance(mainwindow).actionCollection
    m.addAction(ac.view_bookmark)
    m.addAction(ac.view_next_mark)
    m.addAction(ac.view_previous_mark)
    m.addAction(ac.view_clear_error_marks)
    m.addAction(ac.view_clear_all_marks)
    m.addSeparator()
    ac = panelmanager.manager(mainwindow).logtool.actionCollection
    m.addAction(ac.log_next_error)
    m.addAction(ac.log_previous_error)
    return m
Пример #17
0
def contextmenu(view):
    cursor = view.textCursor()
    menu = view.createStandardContextMenu()
    mainwindow = view.window()

    # create the actions in the actions list
    actions = []
    
    actions.extend(open_files(cursor, menu, mainwindow))
    
    actions.extend(jump_to_definition(cursor, menu, mainwindow))
    
    
    if cursor.hasSelection():
        import panelmanager
        actions.append(panelmanager.manager(mainwindow).snippettool.actionCollection.copy_to_snippet)
        actions.append(mainwindow.actionCollection.edit_copy_colored_html)
    
    # now add the actions to the standard menu
    if actions:
        first_action = menu.actions()[0] if menu.actions() else None
        if first_action:
            first_action = menu.insertSeparator(first_action)
            menu.insertActions(first_action, actions)
        else:
            menu.addActions(actions)
    return menu
Пример #18
0
    def createToolBars(self):
        ac = self.actionCollection
        self.toolbar_main = t = self.addToolBar('')
        t.setObjectName('toolbar_main')
        t.addAction(ac.file_new)
        t.addAction(ac.file_open)
        t.addAction(ac.file_save)
        t.addAction(ac.file_save_as)
        t.addAction(ac.file_close)
        t.addSeparator()
        t.addAction(browseriface.get(self).actionCollection.go_back)
        t.addAction(browseriface.get(self).actionCollection.go_forward)
        t.addSeparator()
        t.addAction(ac.edit_undo)
        t.addAction(ac.edit_redo)
        t.addSeparator()
        t.addAction(
            scorewiz.ScoreWizard.instance(self).actionCollection.scorewiz)
        t.addAction(engrave.engraver(self).actionCollection.engrave_runner)

        self.toolbar_music = t = self.addToolBar('')
        t.setObjectName('toolbar_music')
        ma = panelmanager.manager(self).musicview.actionCollection
        t.addAction(ma.music_document_select)
        t.addAction(ma.music_print)
        t.addSeparator()
        t.addAction(ma.music_zoom_in)
        t.addAction(ma.music_zoom_combo)
        t.addAction(ma.music_zoom_out)
        t.addSeparator()
        t.addAction(ma.music_prev_page)
        t.addAction(ma.music_pager)
        t.addAction(ma.music_next_page)
Пример #19
0
def menu_tools(mainwindow):
    m = Menu(_('menu title', '&Tools'), mainwindow)

    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_format(mainwindow))
    m.addMenu(menu_tools_transform(mainwindow))
    dac = documentactions.get(mainwindow).actionCollection
    m.addAction(dac.tools_convert_ly)
    m.addSeparator()
    m.addMenu(menu_tools_directories(mainwindow))
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    return m
Пример #20
0
    def engrave(self, mode='preview', document=None, may_save=True):
        """Starts an engraving job.

        The mode can be 'preview', 'publish', or 'layout-control'. The last
        one uses the settings in the Layout Control Options panel. The
        default mode is 'preview'.

        If document is not specified, it is either the sticky or current
        document.

        If may_save is False, the document will not be saved before running
        LilyPond, even if the preference setting "save document before LilyPond
        is run" is enabled.

        """
        job_class = (job.lilypond.PreviewJob
                     if mode == 'preview' else job.lilypond.PublishJob
                     if mode == 'publish' else job.lilypond.LayoutControlJob)
        # TODO: Try to move this argument creation into
        # LayoutControlJob's constructor. However, somehow this has to
        # obtain access to the mainwindow.
        args = (panelmanager.manager(
            self.mainwindow()).layoutcontrol.widget().preview_options()
                if mode == 'layout-control' else None)
        doc = document or self.document()
        if may_save:
            self.saveDocumentIfDesired()
        self.runJob(job_class(doc, args), doc)
Пример #21
0
def menu_tools(mainwindow):
    m = Menu(_('menu title', '&Tools'), mainwindow)

    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_format(mainwindow))
    m.addMenu(menu_tools_transform(mainwindow))
    dac = documentactions.get(mainwindow).actionCollection
    m.addAction(dac.tools_convert_ly)
    m.addSeparator()
    m.addMenu(menu_tools_directories(mainwindow))
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    return m
Пример #22
0
    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()
Пример #23
0
    def engrave(self, mode='preview', document=None, may_save=True):
        """Starts an engraving job.

        The mode can be 'preview', 'publish', or 'layout-control'. The last
        one uses the settings in the Layout Control Options panel. The
        default mode is 'preview'.

        If document is not specified, it is either the sticky or current
        document.

        If may_save is False, the document will not be saved before running
        LilyPond, even if the preference setting "save document before LilyPond
        is run" is enabled.

        """
        job_class = (
            job.lilypond.PreviewJob if mode == 'preview'
            else job.lilypond.PublishJob if mode == 'publish'
            else job.lilypond.LayoutControlJob
        )
        # TODO: Try to move this argument creation into
        # LayoutControlJob's constructor. However, somehow this has to
        # obtain access to the mainwindow.
        args = (
            panelmanager.manager(
                self.mainwindow()).layoutcontrol.widget().preview_options()
            if mode == 'layout-control' else None)
        doc = document or self.document()
        if may_save:
            self.saveDocumentIfDesired()
        self.runJob(job_class(doc, args), doc)
Пример #24
0
def menu_music(mainwindow):
    m = Menu(_("menu title", "&Music"), mainwindow)
    ac = panelmanager.manager(mainwindow).musicview.actionCollection
    
    m.addAction(ac.music_reload)
    m.addSeparator()
    m.addAction(ac.music_zoom_in)
    m.addAction(ac.music_zoom_out)
    m.addAction(ac.music_zoom_original)
    m.addSeparator()
    m.addAction(ac.music_fit_width)
    m.addAction(ac.music_fit_height)
    m.addAction(ac.music_fit_both)
    m.addSeparator()
    m.addAction(ac.music_single_pages)
    m.addAction(ac.music_two_pages_first_right)
    m.addAction(ac.music_two_pages_first_left)
    m.addSeparator()
    m.addAction(ac.music_copy_image)
    m.addSeparator()
    m.addAction(ac.music_jump_to_cursor)
    m.addAction(ac.music_sync_cursor)
    m.addSeparator()
    m.addAction(ac.music_maximize)
    return m
Пример #25
0
def menu_music(mainwindow):
    m = Menu(_("menu title", "&Music"), mainwindow)
    ac = panelmanager.manager(mainwindow).musicview.actionCollection

    m.addAction(ac.music_reload)
    m.addSeparator()
    m.addAction(ac.music_zoom_in)
    m.addAction(ac.music_zoom_out)
    m.addAction(ac.music_zoom_original)
    m.addSeparator()
    m.addAction(ac.music_fit_width)
    m.addAction(ac.music_fit_height)
    m.addAction(ac.music_fit_both)
    m.addSeparator()
    m.addAction(ac.music_single_pages)
    m.addAction(ac.music_two_pages_first_right)
    m.addAction(ac.music_two_pages_first_left)
    m.addSeparator()
    m.addAction(ac.music_copy_image)
    m.addAction(ac.music_copy_text)
    m.addSeparator()
    m.addAction(ac.music_jump_to_cursor)
    m.addAction(ac.music_sync_cursor)
    m.addSeparator()
    m.addAction(ac.music_maximize)
    return m
Пример #26
0
 def engrave(self, mode='preview', document=None, may_save=True):
     """Starts an engraving job.
     
     The mode can be 'preview', 'publish', or 'layout-control'. The last 
     one uses the settings in the Layout Control Options panel. The 
     default mode is 'preview'.
     
     If document is not specified, it is either the sticky or current
     document.
     
     If may_save is False, the document will not be saved before running
     LilyPond, even if the preference setting "save document before LilyPond
     is run" is enabled.
     
     """
     if mode == 'preview':
         args = ['-dpoint-and-click']
     elif mode == 'publish':
         args = None     # command.defaultJob() will handle publish mode
     elif mode == 'layout-control':
         args = panelmanager.manager(
                 self.mainwindow()).layoutcontrol.widget().preview_options()
     doc = document or self.document()
     if may_save:
         self.saveDocumentIfDesired()
     from . import command
     self.runJob(command.defaultJob(doc, args), doc)
Пример #27
0
def menu_view(mainwindow):
    m = Menu(_("menu title", "&View"), mainwindow)
    ac = mainwindow.actionCollection

    m.addAction(ac.view_next_document)
    m.addAction(ac.view_previous_document)
    m.addSeparator()
    m.addAction(ac.view_wrap_lines)
    m.addAction(documentactions.get(mainwindow).actionCollection.view_highlighting)
    m.addAction(sidebar.SideBarManager.instance(mainwindow).actionCollection.view_linenumbers)
    m.addMenu(menu_view_folding(mainwindow))
    m.addSeparator()
    m.addAction(documentactions.get(mainwindow).actionCollection.view_goto_file_or_definition)
    m.addAction(ac.view_goto_line)
    ac = browseriface.get(mainwindow).actionCollection
    m.addAction(ac.go_back)
    m.addAction(ac.go_forward)
    m.addSeparator()
    ac = matcher.Matcher.instance(mainwindow).actionCollection
    m.addAction(ac.view_matching_pair)
    m.addAction(ac.view_matching_pair_select)
    m.addSeparator()
    ac = bookmarkmanager.BookmarkManager.instance(mainwindow).actionCollection
    m.addAction(ac.view_bookmark)
    m.addAction(ac.view_next_mark)
    m.addAction(ac.view_previous_mark)
    m.addAction(ac.view_clear_error_marks)
    m.addAction(ac.view_clear_all_marks)
    m.addSeparator()
    ac = panelmanager.manager(mainwindow).logtool.actionCollection
    m.addAction(ac.log_next_error)
    m.addAction(ac.log_previous_error)
    return m
Пример #28
0
def menu_edit(mainwindow):
    m = Menu(_("menu title", "&Edit"), mainwindow)
    ac = mainwindow.actionCollection

    m.addAction(ac.edit_undo)
    m.addAction(ac.edit_redo)
    m.addSeparator()
    m.addAction(documentactions.get(mainwindow).actionCollection.edit_cut_assign)
    m.addAction(documentactions.get(mainwindow).actionCollection.edit_move_to_include_file)
    m.addAction(ac.edit_cut)
    m.addAction(ac.edit_copy)
    m.addAction(panelmanager.manager(mainwindow).snippettool.actionCollection.copy_to_snippet)
    m.addAction(ac.edit_copy_colored_html)
    m.addAction(ac.edit_paste)
    m.addSeparator()
    m.addAction(ac.edit_select_all)
    m.addAction(ac.edit_select_current_toplevel)
    m.addAction(ac.edit_select_none)
    m.addSeparator()
    m.addAction(ac.edit_find)
    m.addAction(ac.edit_find_next)
    m.addAction(ac.edit_find_previous)
    m.addAction(ac.edit_replace)
    m.addSeparator()
    m.addAction(ac.edit_preferences)
    return m
Пример #29
0
def menu_file_print(mainwindow):
    m = Menu(_("submenu title", "&Print"), mainwindow)
    ac = mainwindow.actionCollection
    m.addAction(
        panelmanager.manager(
            mainwindow).musicview.actionCollection.music_print)
    m.addAction(ac.file_print_source)
    return m
Пример #30
0
 def openDefaultView(self, document, job, success):
     if (success and jobattributes.get(job).mainwindow is self.mainwindow()
             and QSettings().value("lilypond_settings/open_default_view", True, bool)):
         target = QSettings().value(
             "lilypond_settings/default_output_target", "pdf", type(""))
         mgr = panelmanager.manager(self.mainwindow())
         if target == "svg":
             mgr.svgview.activate()
         elif target == "pdf":
             mgr.musicview.activate()
Пример #31
0
def menu_file(mainwindow):
    m = Menu(_("menu title", "&File"), mainwindow)
    ac = mainwindow.actionCollection

    m.addAction(ac.file_new)
    m.addAction(
        scorewiz.ScoreWizard.instance(mainwindow).actionCollection.scorewiz)
    m.addMenu(snippet.menu.TemplateMenu(mainwindow))
    m.addSeparator()
    m.addAction(ac.file_open)
    m.addAction(ac.file_open_recent)
    m.addAction(ac.file_insert_file)
    m.addSeparator()
    m.addAction(ac.file_save)
    m.addAction(ac.file_save_as)
    m.addAction(ac.file_save_copy_as)
    m.addAction(ac.file_rename)
    m.addAction(
        panelmanager.manager(
            mainwindow).snippettool.actionCollection.file_save_as_template)
    m.addAction(ac.file_save_all)
    m.addSeparator()
    m.addAction(ac.file_reload)
    m.addAction(ac.file_reload_all)
    m.addAction(ac.file_external_changes)
    m.addSeparator()
    m.addMenu(menu_file_import(mainwindow))
    m.addMenu(menu_file_export(mainwindow))
    m.addSeparator()
    m.addAction(
        panelmanager.manager(
            mainwindow).musicview.actionCollection.music_print)
    m.addAction(ac.file_print_source)
    m.addSeparator()
    m.addAction(ac.file_close)
    m.addAction(ac.file_close_other)
    m.addAction(ac.file_close_all)
    m.addSeparator()
    m.addAction(ac.file_quit)
    if app.is_git_controlled():
        m.addAction(ac.file_restart)
    return m
Пример #32
0
def menu_file_save(mainwindow):
    m = Menu(_("submenu title", "Save"), mainwindow)
    ac = mainwindow.actionCollection
    m.addAction(ac.file_save_as)
    m.addAction(ac.file_save_copy_as)
    m.addAction(ac.file_rename)
    m.addAction(
        panelmanager.manager(
            mainwindow).snippettool.actionCollection.file_save_as_template)
    m.addAction(ac.file_save_all)
    return m
Пример #33
0
def menu_view_music(mainwindow):
    m = Menu(_("submenu title", "Music &View"), mainwindow)
    ac = panelmanager.manager(mainwindow).musicview.actionCollection
    
    m.addAction(ac.music_zoom_in)
    m.addAction(ac.music_zoom_out)
    m.addSeparator()
    m.addAction(ac.music_fit_width)
    m.addAction(ac.music_fit_height)
    m.addAction(ac.music_fit_both)
    m.addSeparator()
    m.addAction(ac.music_jump_to_cursor)
    return m
Пример #34
0
def menu_edit_cut(mainwindow):
    m = Menu(_("menu title", "Cut/Copy (advanced)"), mainwindow)
    ac = mainwindow.actionCollection
    m.addAction(
        documentactions.get(mainwindow).actionCollection.edit_cut_assign)
    m.addAction(
        documentactions.get(
            mainwindow).actionCollection.edit_move_to_include_file)
    m.addAction(
        panelmanager.manager(
            mainwindow).snippettool.actionCollection.copy_to_snippet)
    m.addAction(ac.edit_copy_colored_html)
    return m
Пример #35
0
def menu_tools(mainwindow):
    m = Menu(_('menu title', '&Tools'), mainwindow)

    ac = autocomplete.CompleterManager.instance(mainwindow).actionCollection
    m.addAction(ac.autocomplete)
    m.addAction(ac.popup_completions)
    m.addSeparator()
    m.addMenu(menu_tools_format(mainwindow))
    m.addMenu(menu_tools_transform(mainwindow))
    dac = documentactions.get(mainwindow).actionCollection
    m.addAction(dac.tools_convert_ly)
    m.addSeparator()
    m.addMenu(menu_tools_directories(mainwindow))
    m.addSeparator()
    panelmanager.manager(mainwindow).addActionsToMenu(m)
    extensions = app.extensions()
    # store a reference to the Tools menu
    extensions.set_tools_menu(m)
    ext_menu = extensions.menu('tools')

    if not ext_menu.isEmpty():
        m.addSeparator()
        m.addMenu(ext_menu)
    return m
Пример #36
0
def handle_exception(name, view):
    """Called when a snippet raises a Python exception.
    
    Shows the error message and offers the option to edit the offending snippet.
    
    """
    import sys, traceback
    exc_type, exc_value, exc_traceback = sys.exc_info()
    tb = traceback.extract_tb(exc_traceback)
    while tb and tb[0][0] != "<snippet>":
        del tb[0]
    msg = ''.join(
        traceback.format_list(tb) +
        traceback.format_exception_only(exc_type, exc_value))
    dlg = QMessageBox(QMessageBox.Critical, _("Snippet error"), msg,
                      QMessageBox.Ok | QMessageBox.Cancel)
    dlg.button(QMessageBox.Ok).setText(_("Edit Snippet"))
    dlg.setDefaultButton(QMessageBox.Cancel)
    dlg.setEscapeButton(QMessageBox.Cancel)
    if dlg.exec_() != QMessageBox.Ok:
        return

    # determine line number
    if exc_type is SyntaxError:
        lineno = exc_value.lineno
    elif tb:
        lineno = tb[0][1]
    else:
        lineno = None

    import panelmanager
    from . import edit
    widget = panelmanager.manager(view.window()).snippettool.widget()
    textedit = edit.Edit(widget, name).text
    if lineno is not None:
        # convert to line number in full snippet text
        for block in cursortools.all_blocks(textedit.document()):
            if block.text().startswith('-*- '):
                lineno += 1
            else:
                break
        block = textedit.document().findBlockByNumber(lineno - 1)
        if block.isValid():
            textedit.setTextCursor(QTextCursor(block))
Пример #37
0
def handle_exception(name, view):
    """Called when a snippet raises a Python exception.
    
    Shows the error message and offers the option to edit the offending snippet.
    
    """
    import sys, traceback
    exc_type, exc_value, exc_traceback = sys.exc_info()
    tb = traceback.extract_tb(exc_traceback)
    while tb and tb[0][0] != "<snippet>":
        del tb[0]
    msg = ''.join(traceback.format_list(tb) +
                    traceback.format_exception_only(exc_type, exc_value))
    dlg = QMessageBox(QMessageBox.Critical, _("Snippet error"), msg,
        QMessageBox.Ok | QMessageBox.Cancel)
    dlg.button(QMessageBox.Ok).setText(_("Edit Snippet"))
    dlg.setDefaultButton(QMessageBox.Cancel)
    dlg.setEscapeButton(QMessageBox.Cancel)
    if dlg.exec_() != QMessageBox.Ok:
        return
    
    # determine line number
    if exc_type is SyntaxError:
        lineno = exc_value.lineno
    elif tb:
        lineno = tb[0][1]
    else:
        lineno = None
    
    import panelmanager
    from . import edit
    widget = panelmanager.manager(view.window()).snippettool.widget()
    textedit = edit.Edit(widget, name).text
    if lineno is not None:
        # convert to line number in full snippet text
        for block in cursortools.all_blocks(textedit.document()):
            if block.text().startswith('-*- '):
                lineno += 1
            else:
                break
        block = textedit.document().findBlockByNumber(lineno-1)
        if block.isValid():
            textedit.setTextCursor(QTextCursor(block))
Пример #38
0
    def __init__(self, tool):
        super(Widget, self).__init__(tool)
        self.mainwindow = tool.mainwindow()
        self.define = None

        import panelmanager
        self.svgview = panelmanager.manager(
            tool.mainwindow()).svgview.widget().view

        layout = QVBoxLayout(spacing=1)
        self.setLayout(layout)

        self.elemLabel = QLabel()

        self.XOffsetBox = QDoubleSpinBox()
        self.XOffsetBox.setRange(-99, 99)
        self.XOffsetBox.setSingleStep(0.1)
        self.XOffsetLabel = l = QLabel()
        l.setBuddy(self.XOffsetBox)

        self.YOffsetBox = QDoubleSpinBox()
        self.YOffsetBox.setRange(-99, 99)
        self.YOffsetBox.setSingleStep(0.1)
        self.YOffsetLabel = l = QLabel()
        l.setBuddy(self.YOffsetBox)

        self.insertButton = QPushButton("insert offset in source", self)
        self.insertButton.clicked.connect(self.callInsert)

        layout.addWidget(self.elemLabel)
        layout.addWidget(self.XOffsetLabel)
        layout.addWidget(self.XOffsetBox)
        layout.addWidget(self.YOffsetLabel)
        layout.addWidget(self.YOffsetBox)
        layout.addWidget(self.insertButton)

        layout.addStretch(1)

        app.translateUI(self)
        self.loadSettings()

        self.connectSlots()
Пример #39
0
    def __init__(self, tool):
        super(Widget, self).__init__(tool)
        self.mainwindow = tool.mainwindow()
        self.define = None

        import panelmanager

        self.svgview = panelmanager.manager(tool.mainwindow()).svgview.widget().view

        layout = QVBoxLayout(spacing=1)
        self.setLayout(layout)

        self.elemLabel = QLabel()

        self.XOffsetBox = QDoubleSpinBox()
        self.XOffsetBox.setRange(-99, 99)
        self.XOffsetBox.setSingleStep(0.1)
        self.XOffsetLabel = l = QLabel()
        l.setBuddy(self.XOffsetBox)

        self.YOffsetBox = QDoubleSpinBox()
        self.YOffsetBox.setRange(-99, 99)
        self.YOffsetBox.setSingleStep(0.1)
        self.YOffsetLabel = l = QLabel()
        l.setBuddy(self.YOffsetBox)

        self.insertButton = QPushButton("insert offset in source", self)
        self.insertButton.clicked.connect(self.callInsert)

        layout.addWidget(self.elemLabel)
        layout.addWidget(self.XOffsetBox)
        layout.addWidget(self.XOffsetLabel)
        layout.addWidget(self.YOffsetBox)
        layout.addWidget(self.YOffsetLabel)
        layout.addWidget(self.insertButton)

        layout.addStretch(1)

        app.translateUI(self)
        self.loadSettings()

        self.connectSlots()
Пример #40
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()
Пример #41
0
def menu_view(mainwindow):
    m = Menu(_("menu title", "&View"), mainwindow)
    ac = mainwindow.actionCollection
    
    m.addAction(ac.view_next_document)
    m.addAction(ac.view_previous_document)
    m.addSeparator()
    m.addAction(documentactions.get(mainwindow).actionCollection.view_highlighting)
    m.addAction(sidebar.SideBarManager.instance(mainwindow).actionCollection.view_linenumbers)
    m.addMenu(menu_view_folding(mainwindow))
    m.addSeparator()
    ac = bookmarkmanager.BookmarkManager.instance(mainwindow).actionCollection
    m.addAction(ac.view_bookmark)
    m.addAction(ac.view_next_mark)
    m.addAction(ac.view_previous_mark)
    m.addAction(ac.view_clear_error_marks)
    m.addAction(ac.view_clear_all_marks)
    m.addSeparator()
    ac = panelmanager.manager(mainwindow).logtool.actionCollection
    m.addAction(ac.log_next_error)
    m.addAction(ac.log_previous_error)
    return m
Пример #42
0
    def __init__(self, mainwindow):
        super(Dialog, self).__init__(mainwindow)
        self._document = None

        layout = QGridLayout()
        self.setLayout(layout)

        self.versionLabel = QLabel()
        self.lilyChooser = lilychooser.LilyChooser()

        self.outputLabel = QLabel()
        self.outputCombo = QComboBox()

        self.resolutionLabel = QLabel()
        self.resolutionCombo = QComboBox(editable=True)

        self.antialiasLabel = QLabel()
        self.antialiasSpin = QSpinBox(minimum=1, maximum=128, value=1)

        self.modeLabel = QLabel()
        self.modeCombo = QComboBox()

        self.deleteCheck = QCheckBox()
        self.embedSourceCodeCheck = QCheckBox()
        self.englishCheck = QCheckBox()

        self.commandLineLabel = QLabel()
        self.commandLine = QTextEdit(acceptRichText=False)

        self.buttons = QDialogButtonBox(QDialogButtonBox.Ok
                                        | QDialogButtonBox.Cancel)
        self.buttons.button(QDialogButtonBox.Ok).setIcon(
            icons.get("lilypond-run"))
        userguide.addButton(self.buttons, "engrave_custom")

        self.resolutionCombo.addItems(['100', '200', '300', '600', '1200'])
        self.resolutionCombo.setCurrentIndex(2)

        self.modeCombo.addItems(['preview', 'publish', 'debug'])
        layout.addWidget(self.versionLabel, 0, 0)
        layout.addWidget(self.lilyChooser, 0, 1, 1, 3)
        layout.addWidget(self.outputLabel, 1, 0)
        layout.addWidget(self.outputCombo, 1, 1, 1, 3)
        layout.addWidget(self.resolutionLabel, 2, 0)
        layout.addWidget(self.resolutionCombo, 2, 1)
        layout.addWidget(self.antialiasLabel, 2, 2, Qt.AlignRight)
        layout.addWidget(self.antialiasSpin, 2, 3)
        layout.addWidget(self.modeLabel, 3, 0)
        layout.addWidget(self.modeCombo, 3, 1, 1, 3)
        layout.addWidget(self.deleteCheck, 4, 0, 1, 4)
        layout.addWidget(self.embedSourceCodeCheck, 5, 0, 1, 4)
        layout.addWidget(self.englishCheck, 6, 0, 1, 4)
        layout.addWidget(self.commandLineLabel, 7, 0, 1, 4)
        layout.addWidget(self.commandLine, 8, 0, 1, 4)
        layout.addWidget(widgets.Separator(), 9, 0, 1, 4)
        layout.addWidget(self.buttons, 10, 0, 1, 4)

        app.translateUI(self)
        qutil.saveDialogSize(self, "engrave/custom/dialog/size",
                             QSize(480, 260))
        self.buttons.accepted.connect(self.accept)
        self.buttons.rejected.connect(self.reject)

        model = listmodel.ListModel(formats,
                                    display=lambda f: f.title(),
                                    icon=lambda f: icons.file_type(f.type))
        self.outputCombo.setModel(model)

        s = QSettings()
        s.beginGroup("lilypond_settings")
        self.englishCheck.setChecked(s.value("no_translation", False, bool))
        self.deleteCheck.setChecked(
            s.value("delete_intermediate_files", True, bool))

        if s.value("default_output_target", "pdf", str) == "svg":
            self.outputCombo.setCurrentIndex(3)

        app.jobFinished.connect(self.slotJobFinished)
        self.outputCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.modeCombo.currentIndexChanged.connect(self.makeCommandLine)
        self.deleteCheck.toggled.connect(self.makeCommandLine)
        self.embedSourceCodeCheck.toggled.connect(self.makeCommandLine)
        self.resolutionCombo.editTextChanged.connect(self.makeCommandLine)
        self.antialiasSpin.valueChanged.connect(self.makeCommandLine)
        self.makeCommandLine()
        panelmanager.manager(
            mainwindow).layoutcontrol.widget().optionsChanged.connect(
                self.makeCommandLine)
Пример #43
0
 def tool(self):
     """Returns the snippets tool."""
     return panelmanager.manager(self.mainwindow()).snippettool
Пример #44
0
 def tool(self):
     """Returns the snippets tool."""
     return panelmanager.manager(self.mainwindow()).snippettool
Пример #45
0
 def __init__(self, mainwindow):
     super(Dialog, self).__init__(mainwindow)
     self._document = None
     
     layout = QGridLayout()
     self.setLayout(layout)
     
     self.versionLabel = QLabel()
     self.lilyChooser = lilychooser.LilyChooser()
     
     self.outputLabel = QLabel()
     self.outputCombo = QComboBox()
     
     self.resolutionLabel = QLabel()
     self.resolutionCombo = QComboBox(editable=True)
     
     self.antialiasLabel = QLabel()
     self.antialiasSpin = QSpinBox(minimum=1, maximum=128, value=1)
     
     self.modeLabel = QLabel()
     self.modeCombo = QComboBox()
     
     self.englishCheck = QCheckBox()
     self.deleteCheck = QCheckBox()
     
     self.commandLineLabel = QLabel()
     self.commandLine = QTextEdit(acceptRichText=False)
     
     self.buttons = QDialogButtonBox(
         QDialogButtonBox.Ok | QDialogButtonBox.Cancel)
     self.buttons.button(QDialogButtonBox.Ok).setIcon(icons.get("lilypond-run"))
     userguide.addButton(self.buttons, "engrave_custom")
     
     self.resolutionCombo.addItems(['100', '200', '300', '600', '1200'])
     self.resolutionCombo.setCurrentIndex(2)
     
     self.modeCombo.addItems(['preview', 'publish', 'debug'])
     layout.addWidget(self.versionLabel, 0, 0)
     layout.addWidget(self.lilyChooser, 0, 1, 1, 3)
     layout.addWidget(self.outputLabel, 1, 0)
     layout.addWidget(self.outputCombo, 1, 1, 1, 3)
     layout.addWidget(self.resolutionLabel, 2, 0)
     layout.addWidget(self.resolutionCombo, 2, 1)
     layout.addWidget(self.antialiasLabel, 2, 2, Qt.AlignRight)
     layout.addWidget(self.antialiasSpin, 2, 3)
     layout.addWidget(self.modeLabel, 3, 0)
     layout.addWidget(self.modeCombo, 3, 1, 1, 3)
     layout.addWidget(self.englishCheck, 4, 0, 1, 4)
     layout.addWidget(self.deleteCheck, 5, 0, 1, 4)
     layout.addWidget(self.commandLineLabel, 6, 0, 1, 4)
     layout.addWidget(self.commandLine, 7, 0, 1, 4)
     layout.addWidget(widgets.Separator(), 8, 0, 1, 4)
     layout.addWidget(self.buttons, 9, 0, 1, 4)
     
     app.translateUI(self)
     qutil.saveDialogSize(self, "engrave/custom/dialog/size", QSize(480, 260))
     self.buttons.accepted.connect(self.accept)
     self.buttons.rejected.connect(self.reject)
     
     model = listmodel.ListModel(formats, display=lambda f: f.title(),
         icon=lambda f: icons.file_type(f.type))
     self.outputCombo.setModel(model)
     
     s = QSettings()
     s.beginGroup("lilypond_settings")
     self.englishCheck.setChecked(
         s.value("no_translation", False, bool))
     self.deleteCheck.setChecked(
         s.value("delete_intermediate_files", True, bool))
     
     if s.value("default_output_target", "pdf", type("")) == "svg":
         self.outputCombo.setCurrentIndex(3)
     
     app.jobFinished.connect(self.slotJobFinished)
     self.outputCombo.currentIndexChanged.connect(self.makeCommandLine)
     self.modeCombo.currentIndexChanged.connect(self.makeCommandLine)
     self.deleteCheck.toggled.connect(self.makeCommandLine)
     self.resolutionCombo.editTextChanged.connect(self.makeCommandLine)
     self.antialiasSpin.valueChanged.connect(self.makeCommandLine)
     self.makeCommandLine()
     panelmanager.manager(mainwindow).layoutcontrol.widget().optionsChanged.connect(self.makeCommandLine)
Пример #46
0
    def getJob(self, document):
        """Returns and configures a Job to start."""
        f = formats[self.outputCombo.currentIndex()]
        d_options = {}
        args = []

        # Configure job type, choose class
        if self.modeCombo.currentIndex() == 0:  # preview mode
            job_class = job.lilypond.PreviewJob
        elif self.modeCombo.currentIndex() == 1:  # publish mode
            job_class = job.lilypond.PublishJob
        elif self.modeCombo.currentIndex() == 2:  # incipit mode
            job_class = job.lilypond.LilyPondJob
            d_options['preview'] = True
            d_options['print_pages'] = False
        else:  # debug mode
            job_class = job.lilypond.LayoutControlJob
            args = panelmanager.manager(
                self.parent()).layoutcontrol.widget().preview_options()

        # Instantiate Job
        j = job_class(document, args)
        j.lilypond_info = self.lilyChooser.lilyPondInfo()

        # Configure extended command line options
        d_options[
            'delete-intermediate-files'] = True if self.deleteCheck.isChecked(
            ) else False

        if self.embedSourceCodeCheck.isChecked():
            d_options['embed-source-code'] = True

        # Assign extended command line options
        for k in d_options:
            j.set_d_option(k, d_options[k])

        # Determine options for the output target/backend
        d = {
            'version':
            j.lilypond_info.version,
            'resolution':
            self.resolutionCombo.currentText(),
            'antialias':
            self.antialiasSpin.value(),
            'xml_export_init':
            os.path.join(ly.xml.__path__[0], 'xml-export-init.ly'),
        }
        j.set_backend_args(f.options(d))

        # Parse additional/custom tokens from the text edit
        for t in self.commandLine.toPlainText().split():
            if t.startswith('-d'):
                k, v = job.lilypond.parse_d_option(t)
                j.set_d_option(k, v)
            else:
                j.add_argument(t)

        # Set environment variables for the job
        if self.englishCheck.isChecked():
            j.environment['LANG'] = 'C'
            j.environment['LC_ALL'] = 'C'
        else:
            j.environment.pop('LANG', None)
            j.environment.pop('LC_ALL', None)
        j.set_title("{0} {1} [{2}]".format(
            os.path.basename(j.lilypond_info.command),
            j.lilypond_info.versionString(), document.documentName()))
        return j