def main_setup_menus():  # noqa
    global alreadyrun
    if alreadyrun:
        return
    alreadyrun = True

    view = get_menu(mw, "&View")

    action = QAction(mw)
    action.setText("Card Stats")
    action.setCheckable(True)
    action.setChecked(sidebar_visibility)
    action.setShortcut(QKeySequence("Shift+C"))
    view.addAction(action)
    action.toggled.connect(card_stats)
Example #2
0
def add_menu_item(path, text, func, keys=None, checkable=False, checked=False):
    action = QAction(text, mw)

    if keys:
        action.setShortcut(QKeySequence(keys))

    if checkable:
        action.setCheckable(checkable)
        action.toggled.connect(func)
        if not hasattr(mw, 'action_groups'):
            mw.action_groups = {}
        if path not in mw.action_groups:
            mw.action_groups[path] = QActionGroup(None)
        mw.action_groups[path].addAction(action)
        action.setChecked(checked)
    else:
        action.triggered.connect(func)

    add_menu(path)
    mw.custom_menus[path].addAction(action)