示例#1
0
def export_config(window) -> None:
    file_name = QFileDialog.getSaveFileName(
        window, "Export Config",
        os.path.expanduser("~/streamdeck_ui_export.json"), "JSON (*.json)")[0]
    if not file_name:
        return

    api.export_config(file_name)
示例#2
0
def export_config(window) -> None:
    deck_id = _deck_id(window.ui)
    valueLocation = api.get_last_known_export_folder(deck_id)
    file_name = QFileDialog.getSaveFileName(window, "Export Config",
                                            valueLocation, "JSON (*.json)")[0]
    if not file_name:
        return

    api.set_last_known_export_folder(deck_id, file_name)
    api.export_config(file_name)
def md_action_changed(button_index: int, action: str) -> None:
    """
    Handles changing the type of action Material Deck listens for.
    """
    global _ui  # pylint: disable=global-statement,invalid-name
    button_state = deck_api._button_state(  # pylint: disable=protected-access
        _deck_id, deck_api.get_page(_deck_id), button_index)
    page = deck_api.get_page(_deck_id)
    if action:
        deck_info: dict = button_state.setdefault('material_deck', {})
        init_data = deck_info.setdefault(
            'init_data', {
                'event': 'willAppear',
                'payload': {
                    'settings': {
                        'displayName': True,
                        'displayIcon': True,
                        'displaySceneIcon': True,
                        'displaySceneName': True,
                    },
                },
            })
        init_data['action'] = action
        command = _create_command_payload(action, 'keyDown', button_index,
                                          page)
        deck_api.set_button_command(
            _deck_id, page, button_index,
            f"{CONFIG_PATH}/pipe_writer.sh '{_bridge_file}' '{json.dumps(command)}'"
        )

        _write_message(
            json.dumps(
                _create_will_display_payload(deck_info, button_index, page)))
    elif 'material_deck' in button_state:
        previous_action = button_state['material_deck'].get('init_data',
                                                            {}).get(
                                                                'action', '')
        del button_state['material_deck']
        _reset_button(button_index, '', page)
        _write_message(
            json.dumps({
                'event': 'willDisappear',
                'action': previous_action,
                'payload': {
                    'coordinates': {
                        'column': button_index % DECK_COLUMNS,
                        'row': math.floor(button_index / DECK_COLUMNS),
                    },
                },
                'context': _to_context(button_index, page),
                'device': _deck_id,
            }))
    deck_api.export_config(DECK_CONFIG_FILE)
    deck_gui.redraw_buttons(_ui)