Ejemplo n.º 1
0
    def setupMenuBar(self, menuBar=None):
        if menuBar is None:
            try:
                menuBar = self._menuBar
            except Exception:
                return
            menuBar.resetState()
        activeWindow = self.activeWindow()
        fileMenu = menuBar.fetchMenu(Entries.File)
        # HACK: scripting window has its own New/Open;
        # figure out how to do this without explicit blacklist.
        if not isinstance(activeWindow, ScriptingWindow):
            fileMenu.fetchAction(Entries.File_New, self.newFile)
            fileMenu.fetchAction(Entries.File_Open, self.openFile)
        recentFilesMenu = fileMenu.fetchMenu(Entries.File_Open_Recent)
        self.updateRecentFiles(recentFilesMenu)
        if not platformSpecific.mergeOpenAndImport():
            fileMenu.fetchAction(Entries.File_Import, self.importFile)
        fileMenu.fetchAction(Entries.File_Save_All, self.saveAll)
        fileMenu.fetchAction(Entries.File_Exit, self.closeAll)

        editMenu = menuBar.fetchMenu(Entries.Edit)
        editMenu.fetchAction(Entries.Edit_Settings, self.settings)

        viewMenu = menuBar.fetchMenu(Entries.View)
        self.updateDrawingAttributes(viewMenu)

        scriptsMenu = menuBar.fetchMenu(Entries.Scripts)
        self.updateExtensions(scriptsMenu)

        windowMenu = menuBar.fetchMenu(Entries.Window)
        if platformSpecific.windowCommandsInMenu(
        ) and activeWindow is not None:
            windowMenu.fetchAction(Entries.Window_Minimize,
                                   activeWindow.showMinimized)
            windowMenu.fetchAction(Entries.Window_Minimize_All,
                                   self.minimizeAll)
            windowMenu.fetchAction(Entries.Window_Zoom,
                                   lambda: self.zoom(activeWindow))
        windowMenu.fetchAction(Entries.Window_Scripting, self.scripting)
        if self.outputWindow is not None:
            windowMenu.fetchAction(Entries.Window_Output, self.output)
        # TODO: add a list of open windows in window menu, check active window
        # maybe add helper function that filters topLevelWidgets into windows
        # bc we need this in a few places

        helpMenu = menuBar.fetchMenu(Entries.Help)
        helpMenu.fetchAction(
            Entries.Help_Documentation,
            lambda: QDesktopServices.openUrl(QUrl("http://trufont.github.io/")
                                             ),
        )
        helpMenu.fetchAction(
            Entries.Help_Report_An_Issue,
            lambda: QDesktopServices.openUrl(
                QUrl("https://github.com/trufont/trufont/issues/new")),
        )
        helpMenu.addSeparator()
        helpMenu.fetchAction(Entries.Help_About, self.about)
Ejemplo n.º 2
0
    def setupMenu(self, menuBar):
        app = QApplication.instance()

        fileMenu = menuBar.fetchMenu(Entries.File)
        fileMenu.fetchAction(Entries.File_New)
        fileMenu.fetchAction(Entries.File_Open)
        fileMenu.fetchMenu(Entries.File_Open_Recent)
        if not platformSpecific.mergeOpenAndImport():
            fileMenu.fetchAction(Entries.File_Import)
        fileMenu.addSeparator()
        fileMenu.fetchAction(Entries.File_Save, self.saveFile)
        fileMenu.fetchAction(Entries.File_Save_As, self.saveFileAs)
        fileMenu.fetchAction(Entries.File_Save_All)
        fileMenu.fetchAction(Entries.File_Reload, self.reloadFile)
        fileMenu.addSeparator()
        fileMenu.fetchAction(Entries.File_Export, self.exportFile)
        fileMenu.fetchAction(Entries.File_Exit)

        editMenu = menuBar.fetchMenu(Entries.Edit)
        self._undoAction = editMenu.fetchAction(Entries.Edit_Undo, self.undo)
        self._redoAction = editMenu.fetchAction(Entries.Edit_Redo, self.redo)
        editMenu.addSeparator()
        cut = editMenu.fetchAction(Entries.Edit_Cut, self.cut)
        copy = editMenu.fetchAction(Entries.Edit_Copy, self.copy)
        copyComponent = editMenu.fetchAction(
            Entries.Edit_Copy_As_Component, self.copyAsComponent)
        paste = editMenu.fetchAction(Entries.Edit_Paste, self.paste)
        self._clipboardActions = (cut, copy, copyComponent, paste)
        editMenu.addSeparator()
        editMenu.fetchAction(Entries.Edit_Settings)

        fontMenu = menuBar.fetchMenu(Entries.Font)
        fontMenu.fetchAction(Entries.Font_Font_Info, self.fontInfo)
        fontMenu.fetchAction(Entries.Font_Font_Features, self.fontFeatures)
        fontMenu.addSeparator()
        fontMenu.fetchAction(Entries.Font_Add_Glyphs, self.addGlyphs)
        fontMenu.fetchAction(Entries.Font_Sort, self.sortGlyphs)

        menuBar.fetchMenu(Entries.Scripts)

        windowMenu = menuBar.fetchMenu(Entries.Window)
        windowMenu.fetchAction(Entries.Window_Inspector)
        windowMenu.addSeparator()
        windowMenu.fetchAction(Entries.Window_Groups, self.groups)
        windowMenu.fetchAction(Entries.Window_Metrics, self.metrics)
        windowMenu.fetchAction(Entries.Window_Scripting)
        windowMenu.addSeparator()
        action = windowMenu.fetchAction(Entries.Window_Output)
        action.setEnabled(app.outputWindow is not None)

        helpMenu = menuBar.fetchMenu(Entries.Help)
        helpMenu.fetchAction(Entries.Help_Documentation)
        helpMenu.fetchAction(Entries.Help_Report_An_Issue)
        helpMenu.addSeparator()
        helpMenu.fetchAction(Entries.Help_About)

        self._updateGlyphActions()
Ejemplo n.º 3
0
    def setupMenuBar(self, menuBar=None):
        if menuBar is None:
            try:
                menuBar = self._menuBar
            except:
                return
            menuBar.resetState()
        activeWindow = self.activeWindow()
        fileMenu = menuBar.fetchMenu(Entries.File)
        # HACK: scripting window has its own New/Open;
        # figure out how to do this without explicit blacklist.
        if not isinstance(activeWindow, ScriptingWindow):
            fileMenu.fetchAction(Entries.File_New, self.newFile)
            fileMenu.fetchAction(Entries.File_Open, self.openFile)
        recentFilesMenu = fileMenu.fetchMenu(Entries.File_Open_Recent)
        self.updateRecentFiles(recentFilesMenu)
        if not platformSpecific.mergeOpenAndImport():
            fileMenu.fetchAction(Entries.File_Import, self.importFile)
        fileMenu.fetchAction(Entries.File_Save_All, self.saveAll)
        fileMenu.fetchAction(Entries.File_Exit, self.closeAll)

        editMenu = menuBar.fetchMenu(Entries.Edit)
        editMenu.fetchAction(Entries.Edit_Settings, self.settings)

        scriptsMenu = menuBar.fetchMenu(Entries.Scripts)
        self.updateExtensions(scriptsMenu)

        windowMenu = menuBar.fetchMenu(Entries.Window)
        if platformSpecific.windowCommandsInMenu(
                ) and activeWindow is not None:
            windowMenu.fetchAction(
                Entries.Window_Minimize, activeWindow.showMinimized)
            windowMenu.fetchAction(
                Entries.Window_Minimize_All, self.minimizeAll)
            windowMenu.fetchAction(
                Entries.Window_Zoom, lambda: self.zoom(activeWindow))
        windowMenu.fetchAction(Entries.Window_Inspector, self.inspector)
        windowMenu.fetchAction(Entries.Window_Scripting, self.scripting)
        if self.outputWindow is not None:
            windowMenu.fetchAction(
                Entries.Window_Output, self.output)
        # TODO: add a list of open windows in window menu, check active window
        # maybe add helper function that filters topLevelWidgets into windows
        # bc we need this in a few places

        helpMenu = menuBar.fetchMenu(Entries.Help)
        helpMenu.fetchAction(
            Entries.Help_Documentation,
            lambda: QDesktopServices.openUrl(
                QUrl("http://trufont.github.io/")))
        helpMenu.fetchAction(
            Entries.Help_Report_An_Issue,
            lambda: QDesktopServices.openUrl(
                QUrl("https://github.com/trufont/trufont/issues/new")))
        helpMenu.addSeparator()
        helpMenu.fetchAction(Entries.Help_About, self.about)
Ejemplo n.º 4
0
    def setupMenu(self, menuBar):
        app = QApplication.instance()

        fileMenu = menuBar.fetchMenu(Entries.File)
        fileMenu.fetchAction(Entries.File_New)
        fileMenu.fetchAction(Entries.File_Open)
        fileMenu.fetchMenu(Entries.File_Open_Recent)
        if not platformSpecific.mergeOpenAndImport():
            fileMenu.fetchAction(Entries.File_Import)
        fileMenu.addSeparator()
        fileMenu.fetchAction(Entries.File_Save, self.saveFile)
        fileMenu.fetchAction(Entries.File_Save_As, self.saveFileAs)
        fileMenu.fetchAction(Entries.File_Save_All)
        fileMenu.fetchAction(Entries.File_Reload, self.reloadFile)
        fileMenu.addSeparator()
        fileMenu.fetchAction(Entries.File_Export, self.exportFile)
        fileMenu.fetchAction(Entries.File_Exit)

        editMenu = menuBar.fetchMenu(Entries.Edit)
        self._undoAction = editMenu.fetchAction(Entries.Edit_Undo, self.undo)
        self._redoAction = editMenu.fetchAction(Entries.Edit_Redo, self.redo)
        editMenu.addSeparator()
        cut = editMenu.fetchAction(Entries.Edit_Cut, self.cut)
        copy = editMenu.fetchAction(Entries.Edit_Copy, self.copy)
        copyComponent = editMenu.fetchAction(
            Entries.Edit_Copy_As_Component, self.copyAsComponent
        )
        paste = editMenu.fetchAction(Entries.Edit_Paste, self.paste)
        self._clipboardActions = (cut, copy, copyComponent, paste)
        editMenu.fetchAction(Entries.Edit_Select_All, self.selectAll)
        # editMenu.fetchAction(Entries.Edit_Deselect, self.deselect)
        editMenu.fetchAction(Entries.Edit_Find, self.findGlyph)
        editMenu.addSeparator()
        editMenu.fetchAction(Entries.Edit_Settings)

        viewMenu = menuBar.fetchMenu(Entries.View)
        viewMenu.fetchAction(Entries.View_Zoom_In, lambda: self.zoom(1))
        viewMenu.fetchAction(Entries.View_Zoom_Out, lambda: self.zoom(-1))
        viewMenu.fetchAction(Entries.View_Reset_Zoom, self.resetZoom)
        viewMenu.addSeparator()
        viewMenu.fetchAction(Entries.View_Next_Tab, lambda: self.tabOffset(1))
        viewMenu.fetchAction(Entries.View_Previous_Tab, lambda: self.tabOffset(-1))
        viewMenu.fetchAction(Entries.View_Next_Glyph, lambda: self.glyphOffset(1))
        viewMenu.fetchAction(Entries.View_Previous_Glyph, lambda: self.glyphOffset(-1))
        viewMenu.fetchAction(Entries.View_Layer_Up, lambda: self.layerOffset(-1))
        viewMenu.fetchAction(Entries.View_Layer_Down, lambda: self.layerOffset(1))
        viewMenu.addSeparator()
        viewMenu.fetchAction(Entries.View_Show_Points)
        viewMenu.fetchAction(Entries.View_Show_Metrics)
        viewMenu.fetchAction(Entries.View_Show_Images)
        viewMenu.fetchAction(Entries.View_Show_Guidelines)

        fontMenu = menuBar.fetchMenu(Entries.Font)
        fontMenu.fetchAction(Entries.Font_Font_Info, self.fontInfo)
        fontMenu.fetchAction(Entries.Font_Font_Features, self.fontFeatures)
        fontMenu.addSeparator()
        fontMenu.fetchAction(Entries.Font_Add_Glyphs, self.addGlyphs)
        fontMenu.fetchAction(Entries.Font_Sort, self.sortGlyphs)

        # glyphMenu = menuBar.fetchMenu(self.tr("&Glyph"))
        # self._layerAction = glyphMenu.fetchAction(
        #     self.tr("&Layer Actions…"), self.layerActions, "L")

        menuBar.fetchMenu(Entries.Scripts)

        windowMenu = menuBar.fetchMenu(Entries.Window)
        windowMenu.fetchAction(Entries.Window_Groups, self.groups)
        windowMenu.fetchAction(Entries.Window_Kerning, self.kerning)
        windowMenu.fetchAction(Entries.Window_Metrics, self.metrics)
        windowMenu.fetchAction(Entries.Window_Scripting)
        windowMenu.fetchAction(Entries.Window_Properties, self.properties)
        windowMenu.addSeparator()
        action = windowMenu.fetchAction(Entries.Window_Output)
        action.setEnabled(app.outputWindow is not None)

        helpMenu = menuBar.fetchMenu(Entries.Help)
        helpMenu.fetchAction(Entries.Help_Documentation)
        helpMenu.fetchAction(Entries.Help_Report_An_Issue)
        helpMenu.addSeparator()
        helpMenu.fetchAction(Entries.Help_About)

        self._updateGlyphActions()
Ejemplo n.º 5
0
 def openFile(self, path=None):
     self._openFile(path, importFile=platformSpecific.mergeOpenAndImport())
Ejemplo n.º 6
0
 def openFile(self, path=None):
     self._openFile(path, importFile=platformSpecific.mergeOpenAndImport())
Ejemplo n.º 7
0
def globalMenuBar():
    menuBar = MenuBar()
    fileMenu = menuBar.fetchMenu(Entries.File)
    fileMenu.fetchAction(Entries.File_New)
    fileMenu.fetchAction(Entries.File_Open)
    fileMenu.fetchMenu(Entries.File_Open_Recent)
    # no-op, caller will maintain this
    if not platformSpecific.mergeOpenAndImport():
        fileMenu.fetchAction(Entries.File_Import)
    fileMenu.addSeparator()
    fileMenu.fetchAction(Entries.File_Save)
    fileMenu.fetchAction(Entries.File_Save_As)
    fileMenu.fetchAction(Entries.File_Save_All)
    fileMenu.fetchAction(Entries.File_Close)
    fileMenu.fetchAction(Entries.File_Reload)
    fileMenu.addSeparator()
    fileMenu.fetchAction(Entries.File_Export)
    fileMenu.fetchAction(Entries.File_Exit)

    editMenu = menuBar.fetchMenu(Entries.Edit)
    editMenu.fetchAction(Entries.Edit_Undo)
    editMenu.fetchAction(Entries.Edit_Redo)
    editMenu.addSeparator()
    editMenu.fetchAction(Entries.Edit_Cut)
    editMenu.fetchAction(Entries.Edit_Copy)
    editMenu.fetchAction(Entries.Edit_Copy_As_Component)
    editMenu.fetchAction(Entries.Edit_Paste)
    editMenu.fetchAction(Entries.Edit_Clear)
    editMenu.fetchAction(Entries.Edit_Select_All)
    # editMenu.fetchAction(Entries.Edit_Deselect)
    editMenu.fetchAction(Entries.Edit_Find)
    editMenu.addSeparator()
    editMenu.fetchAction(Entries.Edit_Settings)
    menuBar.addMenu(editMenu)

    viewMenu = menuBar.fetchMenu(Entries.View)
    viewMenu.fetchAction(Entries.View_Zoom_In)
    viewMenu.fetchAction(Entries.View_Zoom_Out)
    viewMenu.fetchAction(Entries.View_Reset_Zoom)
    viewMenu.addSeparator()
    viewMenu.fetchAction(Entries.View_Next_Tab)
    viewMenu.fetchAction(Entries.View_Previous_Tab)
    viewMenu.fetchAction(Entries.View_Next_Glyph)
    viewMenu.fetchAction(Entries.View_Previous_Glyph)
    viewMenu.fetchAction(Entries.View_Layer_Up)
    viewMenu.fetchAction(Entries.View_Layer_Down)
    viewMenu.addSeparator()
    viewMenu.fetchAction(Entries.View_Show_Points)
    viewMenu.fetchAction(Entries.View_Show_Metrics)
    viewMenu.fetchAction(Entries.View_Show_Images)
    viewMenu.fetchAction(Entries.View_Show_Guidelines)

    fontMenu = menuBar.fetchMenu(Entries.Font)
    fontMenu.fetchAction(Entries.Font_Font_Info)
    fontMenu.fetchAction(Entries.Font_Font_Features)
    fontMenu.addSeparator()
    fontMenu.fetchAction(Entries.Font_Add_Glyphs)
    fontMenu.fetchAction(Entries.Font_Sort)

    menuBar.fetchMenu(Entries.Scripts)
    # no-op, caller will maintain this

    windowMenu = menuBar.fetchMenu(Entries.Window)
    if platformSpecific.windowCommandsInMenu():
        windowMenu.fetchAction(Entries.Window_Minimize)
        windowMenu.fetchAction(Entries.Window_Minimize_All)
        windowMenu.fetchAction(Entries.Window_Zoom)
        windowMenu.addSeparator()
    windowMenu.fetchAction(Entries.Window_Groups)
    windowMenu.fetchAction(Entries.Window_Kerning)
    windowMenu.fetchAction(Entries.Window_Metrics)
    windowMenu.fetchAction(Entries.Window_Scripting)
    windowMenu.fetchAction(Entries.Window_Properties)
    windowMenu.addSeparator()
    windowMenu.fetchAction(Entries.Window_Output)

    helpMenu = menuBar.fetchMenu(Entries.Help)
    helpMenu.fetchAction(Entries.Help_Documentation)
    helpMenu.fetchAction(Entries.Help_Report_An_Issue)
    helpMenu.addSeparator()
    helpMenu.fetchAction(Entries.Help_About)

    return menuBar
Ejemplo n.º 8
0
def globalMenuBar():
    menuBar = MenuBar()
    fileMenu = menuBar.fetchMenu(Entries.File)
    fileMenu.fetchAction(Entries.File_New)
    fileMenu.fetchAction(Entries.File_Open)
    fileMenu.fetchMenu(Entries.File_Open_Recent)
    # no-op, caller will maintain this
    if not platformSpecific.mergeOpenAndImport():
        fileMenu.fetchAction(Entries.File_Import)
    fileMenu.addSeparator()
    fileMenu.fetchAction(Entries.File_Save)
    fileMenu.fetchAction(Entries.File_Save_As)
    fileMenu.fetchAction(Entries.File_Save_All)
    fileMenu.fetchAction(Entries.File_Close)
    fileMenu.fetchAction(Entries.File_Reload)
    fileMenu.addSeparator()
    fileMenu.fetchAction(Entries.File_Export)
    fileMenu.fetchAction(Entries.File_Exit)

    editMenu = menuBar.fetchMenu(Entries.Edit)
    editMenu.fetchAction(Entries.Edit_Undo)
    editMenu.fetchAction(Entries.Edit_Redo)
    editMenu.addSeparator()
    editMenu.fetchAction(Entries.Edit_Cut)
    editMenu.fetchAction(Entries.Edit_Copy)
    editMenu.fetchAction(Entries.Edit_Copy_As_Component)
    editMenu.fetchAction(Entries.Edit_Paste)
    editMenu.fetchAction(Entries.Edit_Clear)
    editMenu.fetchAction(Entries.Edit_Select_All)
    editMenu.fetchAction(Entries.Edit_Find)
    editMenu.addSeparator()
    editMenu.fetchAction(Entries.Edit_Settings)
    menuBar.addMenu(editMenu)

    viewMenu = menuBar.fetchMenu(Entries.View)
    viewMenu.fetchAction(Entries.View_Zoom_In)
    viewMenu.fetchAction(Entries.View_Zoom_Out)
    viewMenu.fetchAction(Entries.View_Reset_Zoom)
    viewMenu.addSeparator()
    viewMenu.fetchAction(Entries.View_Next_Glyph)
    viewMenu.fetchAction(Entries.View_Previous_Glyph)

    fontMenu = menuBar.fetchMenu(Entries.Font)
    fontMenu.fetchAction(Entries.Font_Font_Info)
    fontMenu.fetchAction(Entries.Font_Font_Features)
    fontMenu.addSeparator()
    fontMenu.fetchAction(Entries.Font_Add_Glyphs)
    fontMenu.fetchAction(Entries.Font_Sort)

    menuBar.fetchMenu(Entries.Scripts)
    # no-op, caller will maintain this

    windowMenu = menuBar.fetchMenu(Entries.Window)
    if platformSpecific.windowCommandsInMenu():
        windowMenu.fetchAction(Entries.Window_Minimize)
        windowMenu.fetchAction(Entries.Window_Minimize_All)
        windowMenu.fetchAction(Entries.Window_Zoom)
        windowMenu.addSeparator()
    windowMenu.fetchAction(Entries.Window_Inspector)
    windowMenu.addSeparator()
    windowMenu.fetchAction(Entries.Window_Groups)
    windowMenu.fetchAction(Entries.Window_Kerning)
    windowMenu.fetchAction(Entries.Window_Metrics)
    windowMenu.fetchAction(Entries.Window_Scripting)
    windowMenu.addSeparator()
    windowMenu.fetchAction(Entries.Window_Output)

    helpMenu = menuBar.fetchMenu(Entries.Help)
    helpMenu.fetchAction(Entries.Help_Documentation)
    helpMenu.fetchAction(Entries.Help_Report_An_Issue)
    helpMenu.addSeparator()
    helpMenu.fetchAction(Entries.Help_About)

    return menuBar