def setupUi(self):
        self.setWindowTitle(constants.ADDON_NAME)
        self.resize(700, 500)

        vlayout = aqt.qt.QVBoxLayout(self)

        vlayout.addWidget(gui_utils.get_header_label(self.get_header_text()))

        vlayout.addWidget(
            aqt.qt.QLabel(
                'You can visualize and remove Audio / Translation / Transliteration rules from here.'
            ))

        self.layout_rules(vlayout)

        vlayout.addWidget(
            gui_utils.get_medium_label(f'Apply Changes While Typing'))
        self.checkbox = aqt.qt.QCheckBox(
            "Language Tools will automatically apply field translations / transliterations / audio when typing into the From field"
        )
        self.checkbox.setChecked(
            self.languagetools.get_apply_updates_automatically())
        self.checkbox.setContentsMargins(10, 0, 10, 0)
        vlayout.addWidget(self.checkbox)

        vlayout.addStretch()

        # buttom buttons
        buttonBox = aqt.qt.QDialogButtonBox()
        self.applyButton = buttonBox.addButton(
            "Save Settings", aqt.qt.QDialogButtonBox.AcceptRole)
        self.applyButton.setEnabled(False)
        self.cancelButton = buttonBox.addButton(
            "Cancel", aqt.qt.QDialogButtonBox.RejectRole)
        self.cancelButton.setStyleSheet(
            self.languagetools.anki_utils.get_red_stylesheet())
        vlayout.addWidget(buttonBox)

        # wire events
        self.checkbox.stateChanged.connect(self.apply_updates_state_changed)
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
Exemplo n.º 2
0
    def setupUi(self):
        self.setWindowTitle(constants.ADDON_NAME)
        self.resize(700, 200)

        vlayout = aqt.qt.QVBoxLayout(self)

        vlayout.addWidget(gui_utils.get_header_label('Add Audio'))

        description_label = aqt.qt.QLabel(
            f'After adding audio to notes, the setting will be memorized.')
        vlayout.addWidget(description_label)

        # from/ to field
        gridlayout = aqt.qt.QGridLayout()

        # from
        gridlayout.addWidget(gui_utils.get_medium_label('From Field:'), 0, 0,
                             1, 1)
        self.from_field_combobox = aqt.qt.QComboBox()
        self.from_field_combobox.addItems(self.from_field_name_list)
        gridlayout.addWidget(self.from_field_combobox, 0, 1, 1, 1)
        # to
        gridlayout.addWidget(gui_utils.get_medium_label('To Field:'), 0, 3, 1,
                             1)
        self.to_field_combobox = aqt.qt.QComboBox()
        self.to_field_combobox.addItems(self.to_field_name_list)
        gridlayout.addWidget(self.to_field_combobox, 0, 4, 1, 1)

        # voice
        gridlayout.addWidget(gui_utils.get_medium_label('Voice:'), 1, 0, 1, 2)
        self.voice_label = aqt.qt.QLabel()
        self.voice_label.setText('undefined')
        self.voice = aqt.qt.QComboBox()
        gridlayout.addWidget(self.voice_label, 1, 1, 1, 4)

        vlayout.addLayout(gridlayout)

        self.progress_bar = aqt.qt.QProgressBar()
        vlayout.addWidget(self.progress_bar)

        vlayout.addStretch()

        buttonBox = aqt.qt.QDialogButtonBox()
        self.applyButton = buttonBox.addButton(
            "Apply To Notes", aqt.qt.QDialogButtonBox.AcceptRole)
        self.applyButton.setEnabled(False)
        self.cancelButton = buttonBox.addButton(
            "Cancel", aqt.qt.QDialogButtonBox.RejectRole)
        self.cancelButton.setStyleSheet(
            self.languagetools.anki_utils.get_red_stylesheet())

        vlayout.addWidget(buttonBox)

        # wire events
        self.pick_default_fields()
        self.from_field_combobox.currentIndexChanged.connect(
            self.from_field_index_changed)
        self.to_field_combobox.currentIndexChanged.connect(
            self.to_field_index_changed)

        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
    def layout_rules(self, vlayout):

        font_bold = aqt.qt.QFont()
        font_bold.setBold(True)

        # do we have translation rules for this deck_note_type
        translation_settings = self.languagetools.get_batch_translation_settings(
            self.deck_note_type)
        if len(translation_settings) > 0:
            vlayout.addWidget(gui_utils.get_medium_label(f'Translation Rules'))
            gridlayout = aqt.qt.QGridLayout()
            i = 0
            for to_field, setting in translation_settings.items():
                from_field = setting['from_field']
                from_dntf = self.languagetools.deck_utils.build_dntf_from_dnt(
                    self.deck_note_type, from_field)
                to_dntf = self.languagetools.deck_utils.build_dntf_from_dnt(
                    self.deck_note_type, to_field)
                from_language_name = self.languagetools.get_language_name(
                    self.languagetools.get_language(from_dntf))
                to_language_name = self.languagetools.get_language_name(
                    self.languagetools.get_language(to_dntf))

                from_field_label = aqt.qt.QLabel(f'{from_field}')
                from_field_label.setFont(font_bold)

                to_field_label = aqt.qt.QLabel(f'{to_field}')
                to_field_label.setFont(font_bold)

                x_offset = 0
                if self.add_rule_enable_checkbox():
                    self.target_field_enabled_map[to_field] = True
                    checkbox = aqt.qt.QCheckBox()
                    checkbox.setChecked(True)
                    self.target_field_checkbox_map[to_field] = checkbox
                    gridlayout.addWidget(checkbox, i, 0, 1, 1)
                    x_offset = 1

                gridlayout.addWidget(aqt.qt.QLabel(f'From:'), i, x_offset + 0,
                                     1, 1)
                gridlayout.addWidget(from_field_label, i, x_offset + 1, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'({from_language_name})'),
                                     i, x_offset + 2, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'To:'), i, x_offset + 3, 1,
                                     1)
                gridlayout.addWidget(to_field_label, i, x_offset + 4, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'({to_language_name})'), i,
                                     x_offset + 5, 1, 1)

                if self.add_delete_button():
                    delete_button = aqt.qt.QPushButton()
                    delete_button.setText('Remove')

                    def get_remove_lambda(to_dntf, button):
                        def remove():
                            button.setEnabled(False)
                            button.setText('Removed')
                            self.remove_translation(to_dntf)

                        return remove

                    delete_button.pressed.connect(
                        get_remove_lambda(to_dntf, delete_button))
                    gridlayout.addWidget(delete_button, i, 6, 1, 1)
                i += 1

            x_offset = 0
            if self.add_rule_enable_checkbox():
                gridlayout.setColumnStretch(0, 10)  # enable checkbox
                x_offset = 1
            gridlayout.setColumnStretch(x_offset + 0, 10)  # from:
            gridlayout.setColumnStretch(x_offset + 1, 20)  # from field label
            gridlayout.setColumnStretch(x_offset + 2, 30)  # from language name
            gridlayout.setColumnStretch(x_offset + 3, 10)  # to:
            gridlayout.setColumnStretch(x_offset + 4, 20)  # to field label
            gridlayout.setColumnStretch(x_offset + 5, 30)  # to language name
            if self.add_delete_button():
                gridlayout.setColumnStretch(6, 10)  # remove button
            gridlayout.setContentsMargins(10, 0, 10, 0)
            vlayout.addLayout(gridlayout)

        # do we have transliteration rules for this deck_note_type
        transliteration_settings = self.languagetools.get_batch_transliteration_settings(
            self.deck_note_type)
        if len(transliteration_settings) > 0:
            vlayout.addWidget(
                gui_utils.get_medium_label(f'Transliteration Rules'))
            gridlayout = aqt.qt.QGridLayout()
            i = 0
            for to_field, setting in transliteration_settings.items():
                from_field = setting['from_field']
                from_dntf = self.languagetools.deck_utils.build_dntf_from_dnt(
                    self.deck_note_type, from_field)
                to_dntf = self.languagetools.deck_utils.build_dntf_from_dnt(
                    self.deck_note_type, to_field)
                from_language_name = self.languagetools.get_language_name(
                    self.languagetools.get_language(from_dntf))
                transliteration_name = setting['transliteration_option'][
                    'transliteration_name']

                from_field_label = aqt.qt.QLabel(f'{from_field}')
                from_field_label.setFont(font_bold)

                to_field_label = aqt.qt.QLabel(f'{to_field}')
                to_field_label.setFont(font_bold)

                x_offset = 0
                if self.add_rule_enable_checkbox():
                    self.target_field_enabled_map[to_field] = True
                    checkbox = aqt.qt.QCheckBox()
                    checkbox.setChecked(True)
                    self.target_field_checkbox_map[to_field] = checkbox
                    gridlayout.addWidget(checkbox, i, 0, 1, 1)
                    x_offset = 1

                gridlayout.addWidget(aqt.qt.QLabel(f'From:'), i, x_offset + 0,
                                     1, 1)
                gridlayout.addWidget(from_field_label, i, x_offset + 1, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'({from_language_name})'),
                                     i, x_offset + 2, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'To:'), i, x_offset + 3, 1,
                                     1)
                gridlayout.addWidget(to_field_label, i, x_offset + 4, 1, 1)
                gridlayout.addWidget(
                    aqt.qt.QLabel(f'({transliteration_name})'), i,
                    x_offset + 5, 1, 1)

                if self.add_delete_button():
                    delete_button = aqt.qt.QPushButton()
                    delete_button.setText('Remove')

                    def get_remove_lambda(to_dntf, button):
                        def remove():
                            button.setEnabled(False)
                            button.setText('Removed')
                            self.remove_transliteration(to_dntf)

                        return remove

                    delete_button.pressed.connect(
                        get_remove_lambda(to_dntf, delete_button))
                    gridlayout.addWidget(delete_button, i, 6, 1, 1)
                i += 1

            x_offset = 0
            if self.add_rule_enable_checkbox():
                gridlayout.setColumnStretch(0, 10)  # enable checkbox
                x_offset = 1
            gridlayout.setColumnStretch(x_offset + 0, 10)  # from:
            gridlayout.setColumnStretch(x_offset + 1, 20)  # from field label
            gridlayout.setColumnStretch(x_offset + 2, 30)  # from language name
            gridlayout.setColumnStretch(x_offset + 3, 10)  # to:
            gridlayout.setColumnStretch(x_offset + 4, 20)  # to field label
            gridlayout.setColumnStretch(x_offset + 5, 30)  # to language name
            if self.add_delete_button():
                gridlayout.setColumnStretch(6, 10)  # remove button
            gridlayout.setContentsMargins(10, 0, 10, 0)
            vlayout.addLayout(gridlayout)

        # do we have any audio rules for this deck_note_type
        audio_settings = self.languagetools.get_batch_audio_settings(
            self.deck_note_type)
        if len(audio_settings) > 0:
            vlayout.addWidget(gui_utils.get_medium_label(f'Audio Rules'))
            gridlayout = aqt.qt.QGridLayout()
            i = 0
            for to_field, from_field in audio_settings.items():
                from_dntf = self.languagetools.deck_utils.build_dntf_from_dnt(
                    self.deck_note_type, from_field)
                to_dntf = self.languagetools.deck_utils.build_dntf_from_dnt(
                    self.deck_note_type, to_field)
                from_language_code = self.languagetools.get_language(from_dntf)
                from_language_name = self.languagetools.get_language_name(
                    from_language_code)
                # get the assigned voice for this langugae
                voice_selection_settings = self.languagetools.get_voice_selection_settings(
                )
                voice_description = 'No Voice Selected'
                if from_language_code in voice_selection_settings:
                    voice_description = voice_selection_settings[
                        from_language_code]['voice_description']

                from_field_label = aqt.qt.QLabel(f'{from_field}')
                from_field_label.setFont(font_bold)

                to_field_label = aqt.qt.QLabel(f'{to_field}')
                to_field_label.setFont(font_bold)

                x_offset = 0
                if self.add_rule_enable_checkbox():
                    self.target_field_enabled_map[to_field] = True
                    checkbox = aqt.qt.QCheckBox()
                    checkbox.setChecked(True)
                    self.target_field_checkbox_map[to_field] = checkbox
                    gridlayout.addWidget(checkbox, i, 0, 1, 1)
                    x_offset = 1

                gridlayout.addWidget(aqt.qt.QLabel(f'From:'), i, x_offset + 0,
                                     1, 1)
                gridlayout.addWidget(from_field_label, i, x_offset + 1, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'({from_language_name})'),
                                     i, x_offset + 2, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'To:'), i, x_offset + 3, 1,
                                     1)
                gridlayout.addWidget(to_field_label, i, x_offset + 4, 1, 1)
                gridlayout.addWidget(aqt.qt.QLabel(f'({voice_description})'),
                                     i, x_offset + 5, 1, 1)

                if self.add_delete_button():
                    delete_button = aqt.qt.QPushButton()
                    delete_button.setText('Remove')

                    def get_remove_lambda(to_dntf, button):
                        def remove():
                            button.setEnabled(False)
                            button.setText('Removed')
                            self.remove_audio(to_dntf)

                        return remove

                    delete_button.pressed.connect(
                        get_remove_lambda(to_dntf, delete_button))
                    gridlayout.addWidget(delete_button, i, 6, 1, 1)
                i += 1

            x_offset = 0
            if self.add_rule_enable_checkbox():
                gridlayout.setColumnStretch(0, 10)  # enable checkbox
                x_offset = 1
            gridlayout.setColumnStretch(x_offset + 0, 10)  # from:
            gridlayout.setColumnStretch(x_offset + 1, 20)  # from field label
            gridlayout.setColumnStretch(x_offset + 2, 30)  # from language name
            gridlayout.setColumnStretch(x_offset + 3, 10)  # to:
            gridlayout.setColumnStretch(x_offset + 4, 20)  # to field label
            gridlayout.setColumnStretch(x_offset + 5, 30)  # to language name
            if self.add_delete_button():
                gridlayout.setColumnStretch(6, 10)  # remove button
            gridlayout.setContentsMargins(10, 0, 10, 0)
            vlayout.addLayout(gridlayout)
Exemplo n.º 4
0
    def setupUi(self):
        self.setWindowTitle(constants.ADDON_NAME)
        self.resize(700, 500)

        vlayout = aqt.qt.QVBoxLayout(self)

        vlayout.addWidget(
            gui_utils.get_header_label('Text Processing Settings'))

        # setup test input box
        # ====================

        vlayout.addWidget(gui_utils.get_medium_label('Preview Settings'))

        # first line
        hlayout = aqt.qt.QHBoxLayout()
        hlayout.addWidget(aqt.qt.QLabel('Transformation Type:'))
        self.sample_transformation_type_combo_box = aqt.qt.QComboBox()
        transformation_type_names = [
            x.name for x in constants.TransformationType
        ]
        self.sample_transformation_type_combo_box.addItems(
            transformation_type_names)
        hlayout.addWidget(self.sample_transformation_type_combo_box)

        label = aqt.qt.QLabel('Enter sample text:')
        hlayout.addWidget(label)
        self.sample_text_input = aqt.qt.QLineEdit()
        hlayout.addWidget(self.sample_text_input)
        hlayout.addStretch()
        vlayout.addLayout(hlayout)

        # second line
        hlayout = aqt.qt.QHBoxLayout()
        hlayout.addWidget(aqt.qt.QLabel('Transformed Text:'))
        self.sample_text_transformed_label = aqt.qt.QLabel(BLANK_TEXT)
        hlayout.addWidget(self.sample_text_transformed_label)
        hlayout.addStretch()
        vlayout.addLayout(hlayout)

        vlayout.addWidget(gui_utils.get_medium_label('Text Replacement'))

        # setup preview table
        # ===================

        self.table_view = aqt.qt.QTableView()
        self.table_view.setModel(self.textReplacementTableModel)
        self.table_view.setSelectionMode(
            aqt.qt.QTableView.SelectionMode.SingleSelection)
        # self.table_view.setSelectionBehavior(aqt.qt.QTableView.SelectionBehavior.SelectRows)
        header = self.table_view.horizontalHeader()
        header.setSectionResizeMode(0, aqt.qt.QHeaderView.Stretch)
        header.setSectionResizeMode(1, aqt.qt.QHeaderView.Stretch)
        vlayout.addWidget(self.table_view)

        # setup buttons below table
        hlayout = aqt.qt.QHBoxLayout()
        self.add_replace_simple_button = aqt.qt.QPushButton(
            'Add Simple Text Replacement Rule')
        hlayout.addWidget(self.add_replace_simple_button)
        self.add_replace_regex_button = aqt.qt.QPushButton(
            'Add Regex Text Replacement Rule')
        hlayout.addWidget(self.add_replace_regex_button)
        self.remove_replace_button = aqt.qt.QPushButton('Remove Selected Rule')
        hlayout.addWidget(self.remove_replace_button)
        vlayout.addLayout(hlayout)

        # setup bottom buttons
        # ====================

        buttonBox = aqt.qt.QDialogButtonBox()
        self.applyButton = buttonBox.addButton(
            "OK", aqt.qt.QDialogButtonBox.AcceptRole)
        self.applyButton.setStyleSheet(
            self.languagetools.anki_utils.get_green_stylesheet())
        self.cancelButton = buttonBox.addButton(
            "Cancel", aqt.qt.QDialogButtonBox.RejectRole)
        self.cancelButton.setStyleSheet(
            self.languagetools.anki_utils.get_red_stylesheet())

        vlayout.addWidget(buttonBox)

        # wire events
        # ===========
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        self.add_replace_simple_button.pressed.connect(
            lambda: self.textReplacementTableModel.add_replacement(
                constants.ReplaceType.simple))
        self.add_replace_regex_button.pressed.connect(
            lambda: self.textReplacementTableModel.add_replacement(
                constants.ReplaceType.regex))
        self.remove_replace_button.pressed.connect(
            self.delete_text_replacement)
        self.typing_timer = self.languagetools.anki_utils.wire_typing_timer(
            self.sample_text_input, self.sample_text_changed)
        self.sample_transformation_type_combo_box.currentIndexChanged.connect(
            self.sample_transformation_type_changed)
Exemplo n.º 5
0
    def setupUi(self):
        self.setWindowTitle(constants.ADDON_NAME)
        self.resize(500, 350)

        vlayout = aqt.qt.QVBoxLayout(self)
        vlayout.addWidget(gui_utils.get_header_label('Breakdown'))
        vlayout.addWidget(
            gui_utils.get_medium_label(
                f'{self.text} ({self.languagetools.get_language_name(self.from_language)})'
            ))

        gridlayout = aqt.qt.QGridLayout()

        # show tokenization options
        # show translation options, with checkbox
        # show transliteration options, with checkbox

        # create all widgets
        # ==================

        font1 = aqt.qt.QFont()
        font1.setBold(True)

        self.target_language_dropdown = aqt.qt.QComboBox()

        self.tokenization_dropdown = aqt.qt.QComboBox()
        self.translation_checkbox = aqt.qt.QCheckBox()
        self.translation_checkbox.setText('Enable')
        self.translation_dropdown = aqt.qt.QComboBox()
        self.transliteration_checkbox = aqt.qt.QCheckBox()
        self.transliteration_checkbox.setText('Enable')
        self.transliteration_dropdown = aqt.qt.QComboBox()
        self.target_field_dropdown = aqt.qt.QComboBox()
        self.target_field_dropdown.setDisabled(True)

        self.breakdown_result = aqt.qt.QLabel()
        self.breakdown_result.setTextInteractionFlags(
            aqt.qt.Qt.TextSelectableByMouse)
        self.breakdown_result.setText(
            '<i>Press Load Breakdown to see result</i>')

        target_language_label = aqt.qt.QLabel()
        target_language_label.setText('Target Language:')
        target_language_label.setFont(font1)

        segmentation_label = aqt.qt.QLabel()
        segmentation_label.setText('Segmentation:')
        segmentation_label.setFont(font1)

        translation_label = aqt.qt.QLabel()
        translation_label.setText('Translation:')
        translation_label.setFont(font1)

        transliteration_label = aqt.qt.QLabel()
        transliteration_label.setText('Transliteration:')
        transliteration_label.setFont(font1)

        self.load_button = aqt.qt.QPushButton()
        self.load_button.setText('Load Breakdown')
        self.load_button.setDisabled(False)
        self.load_button.setStyleSheet(
            self.languagetools.anki_utils.get_green_stylesheet())
        self.load_button.setFont(gui_utils.get_large_button_font())

        self.copy_to_field_button = aqt.qt.QPushButton()
        self.copy_to_field_button.setText('Copy to Field')
        self.copy_to_field_button.setDisabled(True)

        vlayout.addWidget(gui_utils.get_medium_label('Options'))

        # place widgets on grid
        # =====================

        regular_width = 2
        row = 0
        gridlayout.addWidget(segmentation_label, row, 0, 1, 1)
        gridlayout.addWidget(self.tokenization_dropdown, row, 1, 1,
                             regular_width)
        row = 1
        gridlayout.addWidget(target_language_label, row, 0, 1, 1)
        gridlayout.addWidget(self.target_language_dropdown, row, 1, 1,
                             regular_width)
        row = 2
        gridlayout.addWidget(translation_label, row, 0, 1, 1)
        gridlayout.addWidget(self.translation_checkbox, row, 1, 1, 1)
        gridlayout.addWidget(self.translation_dropdown, row, 2, 1, 1)
        row = 3
        gridlayout.addWidget(transliteration_label, row, 0, 1, 1)
        gridlayout.addWidget(self.transliteration_checkbox, row, 1, 1, 1)
        gridlayout.addWidget(self.transliteration_dropdown, row, 2, 1, 1)

        gridlayout.setContentsMargins(10, 10, 10, 10)
        vlayout.addLayout(gridlayout)

        # add result label
        # ================
        vlayout.addWidget(gui_utils.get_medium_label('Breakdown Result'))
        self.breakdown_result.setContentsMargins(10, 10, 10, 10)
        vlayout.addWidget(self.breakdown_result)

        # load button
        # ===========
        vlayout.addWidget(self.load_button)

        hlayout = aqt.qt.QHBoxLayout(self)
        hlayout.addWidget(self.copy_to_field_button)
        hlayout.addWidget(self.target_field_dropdown)
        vlayout.addLayout(hlayout)

        self.populate_target_languages()
        self.populate_controls()

        self.load_button.pressed.connect(self.load_breakdown)
        self.copy_to_field_button.pressed.connect(self.copy_to_field)
    def setupUi(self):
        self.setWindowTitle(constants.ADDON_NAME)
        self.resize(500, 350)

        vlayout = aqt.qt.QVBoxLayout(self)
        vlayout.addWidget(gui_utils.get_header_label('Choose Translation'))

        # add the source text / languages
        translation_info_gridlayout = aqt.qt.QGridLayout()
        vlayout.addLayout(translation_info_gridlayout)

        translation_info_gridlayout.addWidget(
            gui_utils.get_medium_label('Source Text'), 0, 0, 1, 1)

        self.original_text_label = aqt.qt.QLabel(self.original_text)
        translation_info_gridlayout.addWidget(self.original_text_label, 1, 0,
                                              1, 1)

        self.from_language_label = aqt.qt.QLabel(
            self.languagetools.get_language_name(self.from_language))
        translation_info_gridlayout.addWidget(
            gui_utils.get_medium_label('From'), 0, 1, 1, 1)
        translation_info_gridlayout.addWidget(self.from_language_label, 1, 1,
                                              1, 1)

        self.to_language_label = aqt.qt.QLabel(
            self.languagetools.get_language_name(self.to_language))
        translation_info_gridlayout.addWidget(gui_utils.get_medium_label('To'),
                                              0, 2, 1, 1)
        translation_info_gridlayout.addWidget(self.to_language_label, 1, 2, 1,
                                              1)

        translation_info_gridlayout.setColumnStretch(0, 60)
        translation_info_gridlayout.setColumnStretch(1, 20)
        translation_info_gridlayout.setColumnStretch(2, 20)

        vlayout.addLayout(translation_info_gridlayout)

        # add grid with translations
        vlayout.addWidget(gui_utils.get_medium_label('Translations Available'))
        translation_gridlayout = aqt.qt.QGridLayout()

        i = 0
        for key, value in self.all_translations.items():
            service_radio_button = aqt.qt.QRadioButton()
            service_radio_button.setObjectName(f'radio_button_{i}')
            service_radio_button.service = key
            service_radio_button.toggled.connect(self.on_translation_selected)
            service_label = aqt.qt.QLabel()
            service_label.setText(f'<b>{key}</b>')
            service_label.setObjectName(f'service_label_{i}')
            translation_label = aqt.qt.QLabel()
            translation_label.setText(f'{value}')
            translation_label.setObjectName(f'translation_label_{i}')
            translation_gridlayout.addWidget(service_radio_button, i, 0, 1, 1)
            translation_gridlayout.addWidget(service_label, i, 1, 1, 1)
            translation_gridlayout.addWidget(translation_label, i, 2, 1, 1)
            i += 1
        translation_gridlayout.setColumnStretch(0, 5)
        translation_gridlayout.setColumnStretch(1, 15)
        translation_gridlayout.setColumnStretch(2, 80)
        vlayout.addLayout(translation_gridlayout)

        vlayout.addStretch()

        # buttom buttons
        buttonBox = aqt.qt.QDialogButtonBox()
        self.apply_button = buttonBox.addButton(
            "OK", aqt.qt.QDialogButtonBox.AcceptRole)
        self.apply_button.setObjectName('apply')
        self.apply_button.setEnabled(False)
        self.cancel_button = buttonBox.addButton(
            "Cancel", aqt.qt.QDialogButtonBox.RejectRole)
        self.cancel_button.setObjectName('cancel')
        self.cancel_button.setStyleSheet(
            self.languagetools.anki_utils.get_red_stylesheet())
        buttonBox.accepted.connect(self.accept)
        buttonBox.rejected.connect(self.reject)
        vlayout.addWidget(buttonBox)