コード例 #1
0
 def add_groups():
     for k in sorted(groups.keys()):
         m = self.addMenu(k)
         self.groupMenus.append(m)
         for name in groups[k]:
             add_session(m, name, k)
         qutil.addAccelerators(m.actions())
コード例 #2
0
ファイル: menu.py プロジェクト: 19joho66/frescobaldi
 def add_groups():
     for k in sorted(groups.keys()):
         m = self.addMenu(k)
         self.groupMenus.append(m)
         for name in groups[k]:
             add_session(m, name, k)
         qutil.addAccelerators(m.actions())
コード例 #3
0
 def populateRecentFilesMenu(self):
     self.menu_recent_files.clear()
     for url in recentfiles.urls():
         f = url.toLocalFile()
         dirname, basename = os.path.split(f)
         text = "{0}  ({1})".format(basename, util.homify(dirname))
         self.menu_recent_files.addAction(text).url = url
     qutil.addAccelerators(self.menu_recent_files.actions())
コード例 #4
0
ファイル: mainwindow.py プロジェクト: brumleygap/frescobaldi
 def populateRecentFilesMenu(self):
     self.menu_recent_files.clear()
     for url in recentfiles.urls():
         f = url.toLocalFile()
         dirname, basename = os.path.split(f)
         text = "{0}  ({1})".format(basename, util.homify(dirname))
         self.menu_recent_files.addAction(text).url = url
     qutil.addAccelerators(self.menu_recent_files.actions())
コード例 #5
0
ファイル: header.py プロジェクト: taasan/frescobaldi
 def translateUI(self):
     self.setPreviewTexts()
     for name, desc in headers():
         self.labels[name].setText(desc + ":")
     # add accelerators to names, avoiding the tab names
     tabwidget = self.window().tabs
     used = filter(None, (qutil.getAccelerator(tabwidget.widget(i).title())
                          for i in range(tabwidget.count())))
     qutil.addAccelerators([self.labels[name] for name, desc in headers()], used)
コード例 #6
0
def menu_sessions(parent):
    m = QMenu(parent)
    m.setTitle(_('menu title', '&Session'))
    m.triggered.connect(slot_session_action)
    import sessions
    for name in sessions.sessionNames():
        a = m.addAction(name.replace('&', '&&'))
        a.setObjectName(name)
    qutil.addAccelerators(m.actions())
    return m
コード例 #7
0
ファイル: menu.py プロジェクト: 19joho66/frescobaldi
    def populate(self):
        groups = {}
        tl_sessions = []

        def add_session(menu, name, group=None):
            name = name.replace('&', '&&')
            fullname = group + '/' + name if group else name
            a = menu.addAction(name)
            a.setCheckable(True)
            if fullname == sessions.currentSession():
                a.setChecked(True)
                if group:
                    menu.setTitle('* ' + menu.title())
            a.setObjectName(fullname)
            self._actionGroup.addAction(a)

        def add_sessions():
            for name in tl_sessions:
                add_session(self, name)

        def add_groups():
            for k in sorted(groups.keys()):
                m = self.addMenu(k)
                self.groupMenus.append(m)
                for name in groups[k]:
                    add_session(m, name, k)
                qutil.addAccelerators(m.actions())

        def reset_menu():
            for m in self.groupMenus:
                m.deleteLater()
            self.groupMenus = []
            ac = manager.get(self.parentWidget()).actionCollection
            ag = self._actionGroup
            for a in ag.actions():
                if a is not ac.session_none:
                    self.removeAction(a)
                    ag.removeAction(a)
            ac.session_none.setChecked(not sessions.currentSession())

        reset_menu()
        for name in sessions.sessionNames():
            if '/' in name:
                group, name = name.split('/')
                if group in groups:
                    groups[group].append(name)
                else:
                    groups[group] = [name]
            else:
                tl_sessions.append(name)
        add_groups()
        if groups:
            self.addSeparator()
        add_sessions()
        qutil.addAccelerators(self.actions())
コード例 #8
0
    def populate(self):
        groups = {}
        tl_sessions = []

        def add_session(menu, name, group=None):
            name = name.replace('&', '&&')
            fullname = group + '/' + name if group else name
            a = menu.addAction(name)
            a.setCheckable(True)
            if fullname == sessions.currentSession():
                a.setChecked(True)
                if group:
                    menu.setTitle('* ' + menu.title())
            a.setObjectName(fullname)
            self._actionGroup.addAction(a)

        def add_sessions():
            for name in tl_sessions:
                add_session(self, name)

        def add_groups():
            for k in sorted(groups.keys()):
                m = self.addMenu(k)
                self.groupMenus.append(m)
                for name in groups[k]:
                    add_session(m, name, k)
                qutil.addAccelerators(m.actions())

        def reset_menu():
            for m in self.groupMenus:
                m.deleteLater()
            self.groupMenus = []
            ac = manager.get(self.parentWidget()).actionCollection
            ag = self._actionGroup
            for a in ag.actions():
                if a is not ac.session_none:
                    self.removeAction(a)
                    ag.removeAction(a)
            ac.session_none.setChecked(not sessions.currentSession())

        reset_menu()
        for name in sessions.sessionNames():
            if '/' in name:
                group, name = name.split('/')
                if group in groups:
                    groups[group].append(name)
                else:
                    groups[group] = [name]
            else:
                tl_sessions.append(name)
        add_groups()
        if groups:
            self.addSeparator()
        add_sessions()
        qutil.addAccelerators(self.actions())
コード例 #9
0
def menu_file_open_recent(parent):
    m = QMenu(parent)
    m.setTitle(_("Open &Recent"))
    m.triggered.connect(slot_file_open_recent_action)
    import recentfiles
    for url in recentfiles.urls():
        f = url.toLocalFile()
        dirname, basename = os.path.split(f)
        text = "{0}  ({1})".format(basename, util.homify(dirname))
        m.addAction(text).url = url
    qutil.addAccelerators(m.actions())
    return m
コード例 #10
0
ファイル: header.py プロジェクト: AlexSchr/frescobaldi
 def translateUI(self):
     msg = _("Click to enter a value.")
     self.htmlView.setHtml(titles_html.format(
         copyrightmsg = _("bottom of first page"),
         taglinemsg = _("bottom of last page"),
         imgurl = QUrl.fromLocalFile(__path__[0]).toString(),
         **dict((name, "<a title='{0}' href='{1}'>{2}</a>".format(msg, name, desc))
                 for name, desc in headers())))
     for name, desc in headers():
         self.labels[name].setText(desc + ":")
     # add accelerators to names, avoiding the tab names
     tabwidget = self.window().tabs
     used = filter(None, (qutil.getAccelerator(tabwidget.widget(i).title())
                          for i in range(tabwidget.count())))
     qutil.addAccelerators([self.labels[name] for name, desc in headers()], used)
コード例 #11
0
ファイル: menu.py プロジェクト: shimpe/frescobaldi
 def populate(self):
     ac = manager.get(self.parentWidget()).actionCollection
     ag = self._actionGroup
     for a in ag.actions():
         if a is not ac.session_none:
             self.removeAction(a)
             ag.removeAction(a)
     ac.session_none.setChecked(not sessions.currentSession())
     for name in sessions.sessionNames():
         a = self.addAction(name.replace('&', '&&'))
         a.setCheckable(True)
         if name == sessions.currentSession():
             a.setChecked(True)
         a.setObjectName(name)
         ag.addAction(a)
     qutil.addAccelerators(self.actions())
コード例 #12
0
ファイル: menu.py プロジェクト: brownian/frescobaldi
 def populate(self):
     ac = manager.get(self.parentWidget()).actionCollection
     ag = self._actionGroup
     for a in ag.actions():
         if a is not ac.session_none:
             self.removeAction(a)
             ag.removeAction(a)
     ac.session_none.setChecked(not sessions.currentSession())
     for name in sessions.sessionNames():
         a = self.addAction(name.replace('&', '&&'))
         a.setCheckable(True)
         if name == sessions.currentSession():
             a.setChecked(True)
         a.setObjectName(name)
         ag.addAction(a)
     qutil.addAccelerators(self.actions())
コード例 #13
0
 def translateUI(self):
     msg = _("Click to enter a value.")
     self.htmlView.setHtml(
         titles_html.format(
             copyrightmsg=_("bottom of first page"),
             taglinemsg=_("bottom of last page"),
             imgurl=QUrl.fromLocalFile(__path__[0]).toString(),
             **dict((name, "<a title='{0}' href='{1}'>{2}</a>".format(
                 msg, name, desc)) for name, desc in headers())))
     for name, desc in headers():
         self.labels[name].setText(desc + ":")
     # add accelerators to names, avoiding the tab names
     tabwidget = self.window().tabs
     used = filter(None, (qutil.getAccelerator(tabwidget.widget(i).title())
                          for i in range(tabwidget.count())))
     qutil.addAccelerators([self.labels[name] for name, desc in headers()],
                           used)
コード例 #14
0
ファイル: __init__.py プロジェクト: WedgeLeft/frescobaldi
 def __init__(self, mainwindow):
     self.actionCollection = ac = Actions()
     actioncollectionmanager.manager(mainwindow).addActionCollection(ac)
     m = self.language_menu = QMenu()
     g = self.language_group = QActionGroup(None)
     for name in sorted(ly.pitch.pitchInfo.keys()):
         a = m.addAction(name.title())
         a.setObjectName(name)
         a.setCheckable(True)
         g.addAction(a)
     qutil.addAccelerators(m.actions())
     ac.pitch_language.setMenu(m)
     m.aboutToShow.connect(self.setLanguageMenu)
     g.triggered.connect(self.changeLanguage)
     ac.pitch_rel2abs.triggered.connect(self.rel2abs)
     ac.pitch_abs2rel.triggered.connect(self.abs2rel)
     ac.pitch_transpose.triggered.connect(self.transpose)
コード例 #15
0
 def populate(self):
     """Populates the menu with snippet actions."""
     from . import model, snippets, actions
     last = self.insertBeforeAction()
     shortcuts = self.tool().snippetActions
     groups = {}
     for name in sorted(model.model().names()):
         variables = snippets.get(name).variables
         group = self.snippetGroup(variables)
         if group:
             action = actions.action(name, self.mainwindow(), shortcuts)
             self.visitAction(action, variables)
             groups.setdefault(group, []).append(action)
     for group in sorted(groups):
         for action in groups[group]:
             self.insertAction(last, action)
         self.insertSeparator(last)
     qutil.addAccelerators(self.actions())
コード例 #16
0
 def __init__(self, mainwindow):
     self.actionCollection = ac = Actions()
     actioncollectionmanager.manager(mainwindow).addActionCollection(ac)
     m = self.language_menu = QMenu()
     g = self.language_group = QActionGroup(None)
     for name in sorted(ly.pitch.pitchInfo.keys()):
         a = m.addAction(name.title())
         a.setObjectName(name)
         a.setCheckable(True)
         g.addAction(a)
     qutil.addAccelerators(m.actions())
     ac.pitch_language.setMenu(m)
     m.aboutToShow.connect(self.setLanguageMenu)
     g.triggered.connect(self.changeLanguage)
     ac.pitch_rel2abs.triggered.connect(self.rel2abs)
     ac.pitch_abs2rel.triggered.connect(self.abs2rel)
     ac.pitch_transpose.triggered.connect(self.transpose)
     ac.pitch_modal_transpose.triggered.connect(self.modalTranspose)
コード例 #17
0
ファイル: menu.py プロジェクト: EdwardBetts/frescobaldi
 def populate(self):
     """Populates the menu with snippet actions."""
     self.clearMenu() # on some systems aboutToHide does not fire...
     from . import model, snippets, actions
     last = self.insertBeforeAction()
     shortcuts = self.tool().snippetActions
     groups = {}
     for name in sorted(model.model().names()):
         variables = snippets.get(name).variables
         group = self.snippetGroup(variables)
         if group:
             action = actions.action(name, self.mainwindow(), shortcuts)
             self.visitAction(action, variables)
             groups.setdefault(group, []).append(action)
     for group in sorted(groups, key=lambda g: '' if g is True else g):
         for action in groups[group]:
             self.insertAction(last, action)
         self.insertSeparator(last)
     qutil.addAccelerators(self.actions())
コード例 #18
0
def menu_file_new_from_template(parent):
    m = QMenu(parent)
    m.setTitle(_("New from &Template"))
    m.triggered.connect(slot_file_new_from_template_action)
    from snippet import model, actions, snippets
    groups = {}
    for name in sorted(model.model().names()):
        variables = snippets.get(name).variables
        group = variables.get('template')
        if group:
            action = actions.action(name, m)
            if action:
                groups.setdefault(group, []).append(action)
    for group in sorted(groups):
        for action in groups[group]:
            m.addAction(action)
        m.addSeparator()
    qutil.addAccelerators(m.actions())
    return m
コード例 #19
0
ファイル: menu.py プロジェクト: ryanakca/frescobaldi
 def populate(self):
     """Populates the menu with snippet actions."""
     self.clearMenu()  # on some systems aboutToHide does not fire...
     from . import model, snippets, actions
     last = self.insertBeforeAction()
     shortcuts = self.tool().snippetActions
     groups = {}
     for name in sorted(model.model().names()):
         variables = snippets.get(name).variables
         group = self.snippetGroup(variables)
         if group:
             action = actions.action(name, self.mainwindow(), shortcuts)
             self.visitAction(action, variables)
             groups.setdefault(group, []).append(action)
     for group in sorted(groups):
         for action in groups[group]:
             self.insertAction(last, action)
         self.insertSeparator(last)
     qutil.addAccelerators(self.actions())
コード例 #20
0
 def repopulate(self):
     """Clears the menu and populates it with snippet actions."""
     # PyQt5's aboutToHide is buggy on macOS and prevents actions
     # from being triggered; instead of clearing the menu in aboutToHide
     # we do it just before repopulating it
     self.clearMenu()
     from . import model, snippets, actions
     last = self.insertBeforeAction()
     shortcuts = self.tool().snippetActions
     groups = {}
     for name in sorted(model.model().names()):
         variables = snippets.get(name).variables
         group = self.snippetGroup(variables)
         if group:
             action = actions.action(name, self.mainwindow(), shortcuts)
             self.visitAction(action, variables)
             groups.setdefault(group, []).append(action)
     for group in sorted(groups, key=lambda g: '' if g is True else g):
         for action in groups[group]:
             self.insertAction(last, action)
         self.insertSeparator(last)
     qutil.addAccelerators(self.actions())
コード例 #21
0
ファイル: menu.py プロジェクト: 19joho66/frescobaldi
 def repopulate(self):
     """Clears the menu and populates it with snippet actions."""
     # PyQt5's aboutToHide is buggy on macOS and prevents actions
     # from being triggered; instead of clearing the menu in aboutToHide
     # we do it just before repopulating it
     self.clearMenu()
     from . import model, snippets, actions
     last = self.insertBeforeAction()
     shortcuts = self.tool().snippetActions
     groups = {}
     for name in sorted(model.model().names()):
         variables = snippets.get(name).variables
         group = self.snippetGroup(variables)
         if group:
             action = actions.action(name, self.mainwindow(), shortcuts)
             self.visitAction(action, variables)
             groups.setdefault(group, []).append(action)
     for group in sorted(groups, key=lambda g: '' if g is True else g):
         for action in groups[group]:
             self.insertAction(last, action)
         self.insertSeparator(last)
     qutil.addAccelerators(self.actions())
コード例 #22
0
 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())
コード例 #23
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())