Beispiel #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)
Beispiel #2
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)
Beispiel #3
0
    def setupMenuBar(self, menuBar=None):
        if menuBar is None:
            try:
                menuBar = self._menuBar
            except:
                return
            menuBar.resetState()
        activeWindow = self.activeWindow()
        # XXX: on local menu bar, entries shouldnt be activated if they werent
        # fetched by local
        # in that case, maybe return a parentless action, that isnt added to
        # the menu
        fileMenu = menuBar.fetchMenu(Entries.File)
        fileMenu.fetchAction(Entries.File_New, self.newFile)
        fileMenu.fetchAction(Entries.File_Open, self.openFile)
        # TODO: maybe move save in there and add save all and close
        recentFilesMenu = fileMenu.fetchMenu(Entries.File_Open_Recent)
        self.updateRecentFiles(recentFilesMenu)
        fileMenu.fetchAction(Entries.File_Exit, self.exit)

        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)
Beispiel #4
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
Beispiel #5
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
    # TODO
    # 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.addSeparator()
    editMenu.fetchAction(Entries.Edit_Find)
    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