Example #1
0
class PlayerTab(SettingsTab):
    """
    MediaTab is the Media settings tab in the settings dialog.
    """
    def __init__(self, parent):
        """
        Constructor
        """
        self.media_players = Registry().get('media_controller').media_players
        self.saved_used_players = None
        self.icon_path = UiIcons().player
        player_translated = translate('OpenLP.PlayerTab', 'Players')
        super(PlayerTab, self).__init__(parent, 'Players', player_translated)

    def setupUi(self):
        """
        Set up the UI
        """
        self.setObjectName('MediaTab')
        super(PlayerTab, self).setupUi()
        self.background_color_group_box = QtWidgets.QGroupBox(self.left_column)
        self.background_color_group_box.setObjectName(
            'background_color_group_box')
        self.form_layout = QtWidgets.QFormLayout(
            self.background_color_group_box)
        self.form_layout.setObjectName('form_layout')
        self.color_layout = QtWidgets.QHBoxLayout()
        self.background_color_label = QtWidgets.QLabel(
            self.background_color_group_box)
        self.background_color_label.setObjectName('background_color_label')
        self.color_layout.addWidget(self.background_color_label)
        self.background_color_button = ColorButton(
            self.background_color_group_box)
        self.background_color_button.setObjectName('background_color_button')
        self.color_layout.addWidget(self.background_color_button)
        self.form_layout.addRow(self.color_layout)
        self.information_label = QtWidgets.QLabel(
            self.background_color_group_box)
        self.information_label.setObjectName('information_label')
        self.information_label.setWordWrap(True)
        self.form_layout.addRow(self.information_label)
        self.left_layout.addWidget(self.background_color_group_box)
        self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                        QtWidgets.QSizePolicy.Preferred)
        self.media_player_group_box = QtWidgets.QGroupBox(self.left_column)
        self.media_player_group_box.setObjectName('media_player_group_box')
        self.media_player_layout = QtWidgets.QVBoxLayout(
            self.media_player_group_box)
        self.media_player_layout.setObjectName('media_player_layout')
        self.player_check_boxes = {}
        self.left_layout.addWidget(self.media_player_group_box)
        self.player_order_group_box = QtWidgets.QGroupBox(self.left_column)
        self.player_order_group_box.setObjectName('player_order_group_box')
        self.player_order_layout = QtWidgets.QHBoxLayout(
            self.player_order_group_box)
        self.player_order_layout.setObjectName('player_order_layout')
        self.player_order_list_widget = QtWidgets.QListWidget(
            self.player_order_group_box)
        size_policy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum,
                                            QtWidgets.QSizePolicy.Expanding)
        size_policy.setHorizontalStretch(0)
        size_policy.setVerticalStretch(0)
        size_policy.setHeightForWidth(
            self.player_order_list_widget.sizePolicy().hasHeightForWidth())
        self.player_order_list_widget.setSizePolicy(size_policy)
        self.player_order_list_widget.setVerticalScrollBarPolicy(
            QtCore.Qt.ScrollBarAsNeeded)
        self.player_order_list_widget.setHorizontalScrollBarPolicy(
            QtCore.Qt.ScrollBarAlwaysOff)
        self.player_order_list_widget.setEditTriggers(
            QtWidgets.QAbstractItemView.NoEditTriggers)
        self.player_order_list_widget.setObjectName('player_order_list_widget')
        self.player_order_layout.addWidget(self.player_order_list_widget)
        self.ordering_button_layout = QtWidgets.QVBoxLayout()
        self.ordering_button_layout.setObjectName('ordering_button_layout')
        self.ordering_button_layout.addStretch(1)
        self.ordering_up_button = create_button(
            self,
            'ordering_up_button',
            role='up',
            click=self.on_up_button_clicked)
        self.ordering_down_button = create_button(
            self,
            'ordering_down_button',
            role='down',
            click=self.on_down_button_clicked)
        self.ordering_button_layout.addWidget(self.ordering_up_button)
        self.ordering_button_layout.addWidget(self.ordering_down_button)
        self.ordering_button_layout.addStretch(1)
        self.player_order_layout.addLayout(self.ordering_button_layout)
        self.left_layout.addWidget(self.player_order_group_box)
        self.left_layout.addStretch()
        self.right_layout.addStretch()
        # Signals and slots
        self.background_color_button.colorChanged.connect(
            self.on_background_color_changed)

    def retranslateUi(self):
        """
        Translate the UI on the fly
        """
        self.media_player_group_box.setTitle(
            translate('OpenLP.PlayerTab', 'Available Media Players'))
        self.player_order_group_box.setTitle(
            translate('OpenLP.PlayerTab', 'Player Search Order'))
        self.background_color_group_box.setTitle(UiStrings().BackgroundColor)
        self.background_color_label.setText(UiStrings().BackgroundColorColon)
        self.information_label.setText(
            translate(
                'OpenLP.PlayerTab',
                'Visible background for videos with aspect ratio different to screen.'
            ))
        self.retranslate_players()

    def on_background_color_changed(self, color):
        """
        Set the background color

        :param color: The color to be set.
        """
        self.background_color = color

    def on_player_check_box_changed(self, check_state):
        """
        Add or remove players depending on their status

        :param check_state: The requested status.
        """
        player = self.sender().player_name
        if check_state == QtCore.Qt.Checked:
            if player not in self.used_players:
                self.used_players.append(player)
        else:
            if player in self.used_players:
                self.used_players.remove(player)
        self.update_player_list()

    def update_player_list(self):
        """
        Update the list of media players
        """
        self.player_order_list_widget.clear()
        for player in self.used_players:
            if player in list(self.player_check_boxes.keys()):
                if len(self.used_players) == 1:
                    # At least one media player has to stay active
                    self.player_check_boxes['%s' % player].setEnabled(False)
                else:
                    self.player_check_boxes['%s' % player].setEnabled(True)
                self.player_order_list_widget.addItem(
                    self.media_players[str(player)].original_name)

    def on_up_button_clicked(self):
        """
        Move a media player up in the order
        """
        row = self.player_order_list_widget.currentRow()
        if row <= 0:
            return
        item = self.player_order_list_widget.takeItem(row)
        self.player_order_list_widget.insertItem(row - 1, item)
        self.player_order_list_widget.setCurrentRow(row - 1)
        self.used_players.insert(row - 1, self.used_players.pop(row))

    def on_down_button_clicked(self):
        """
        Move a media player down in the order
        """
        row = self.player_order_list_widget.currentRow()
        if row == -1 or row > self.player_order_list_widget.count() - 1:
            return
        item = self.player_order_list_widget.takeItem(row)
        self.player_order_list_widget.insertItem(row + 1, item)
        self.player_order_list_widget.setCurrentRow(row + 1)
        self.used_players.insert(row + 1, self.used_players.pop(row))

    def load(self):
        """
        Load the settings
        """
        if self.saved_used_players:
            self.used_players = self.saved_used_players
        self.used_players = get_media_players()[0]
        self.saved_used_players = self.used_players
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.update_player_list()
        self.background_color = settings.value('background color')
        self.initial_color = self.background_color
        settings.endGroup()
        self.background_color_button.color = self.background_color

    def save(self):
        """
        Save the settings
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        settings.setValue('background color', self.background_color)
        settings.endGroup()
        old_players, override_player = get_media_players()
        if self.used_players != old_players:
            # clean old Media stuff
            set_media_players(self.used_players, override_player)
            self.settings_form.register_post_process('mediaitem_suffix_reset')
            self.settings_form.register_post_process('mediaitem_media_rebuild')
            self.settings_form.register_post_process('config_screen_changed')

    def post_set_up(self, post_update=False):
        """
        Late setup for players as the MediaController has to be initialised first.

        :param post_update: Indicates if called before or after updates.
        """
        for key, player in self.media_players.items():
            player = self.media_players[key]
            checkbox = MediaQCheckBox(self.media_player_group_box)
            checkbox.setEnabled(player.available)
            checkbox.setObjectName(player.name + '_check_box')
            checkbox.setToolTip(player.get_info())
            checkbox.set_player_name(player.name)
            self.player_check_boxes[player.name] = checkbox
            checkbox.stateChanged.connect(self.on_player_check_box_changed)
            self.media_player_layout.addWidget(checkbox)
            if player.available and player.name in self.used_players:
                checkbox.setChecked(True)
            else:
                checkbox.setChecked(False)
        self.update_player_list()
        self.retranslate_players()

    def retranslate_players(self):
        """
        Translations for players is dependent on  their setup as well
         """
        for key in self.media_players and self.player_check_boxes:
            player = self.media_players[key]
            checkbox = self.player_check_boxes[player.name]
            checkbox.set_player_name(player.name)
            if player.available:
                checkbox.setText(player.display_name)
            else:
                checkbox_text = translate(
                    'OpenLP.PlayerTab',
                    '%s (unavailable)') % player.display_name
                if player.name == 'vlc':
                    checkbox_text += ' ' + translate(
                        'OpenLP.PlayerTab',
                        'NOTE: To use VLC you must install the %s version',
                        'Will insert "32bit" or "64bit"'
                    ) % platform.architecture()[0]
                checkbox.setText(checkbox_text)
Example #2
0
class BackgroundPage(GridLayoutPage):
    """
    A background selection widget
    """
    Color = 'color'
    Gradient = 'gradient'
    Image = 'image'
    Video = 'video'

    def setup_ui(self):
        """
        Set up the ui
        """
        # background type
        self.background_label = FormLabel(self)
        self.background_label.setObjectName('background_label')
        self.layout.addWidget(self.background_label, 0, 0)
        self.background_combo_box = QtWidgets.QComboBox(self)
        self.background_combo_box.addItems(['', '', '', '', '', ''])
        self.background_combo_box.setObjectName('background_combo_box')
        self.layout.addWidget(self.background_combo_box, 0, 1, 1, 3)
        # color
        self.color_label = FormLabel(self)
        self.color_label.setObjectName('color_label')
        self.layout.addWidget(self.color_label, 1, 0)
        self.color_button = ColorButton(self)
        self.color_button.setObjectName('color_button')
        self.layout.addWidget(self.color_button, 1, 1)
        self.color_widgets = [self.color_label, self.color_button]
        # gradient
        self.gradient_type_label = FormLabel(self)
        self.gradient_type_label.setObjectName('gradient_type_label')
        self.layout.addWidget(self.gradient_type_label, 2, 0)
        self.gradient_combo_box = QtWidgets.QComboBox(self)
        self.gradient_combo_box.setObjectName('gradient_combo_box')
        self.gradient_combo_box.addItems(['', '', '', '', ''])
        self.layout.addWidget(self.gradient_combo_box, 2, 1, 1, 3)
        self.gradient_start_label = FormLabel(self)
        self.gradient_start_label.setObjectName('gradient_start_label')
        self.layout.addWidget(self.gradient_start_label, 3, 0)
        self.gradient_start_button = ColorButton(self)
        self.gradient_start_button.setObjectName('gradient_start_button')
        self.layout.addWidget(self.gradient_start_button, 3, 1)
        self.gradient_end_label = FormLabel(self)
        self.gradient_end_label.setObjectName('gradient_end_label')
        self.layout.addWidget(self.gradient_end_label, 3, 2)
        self.gradient_end_button = ColorButton(self)
        self.gradient_end_button.setObjectName('gradient_end_button')
        self.layout.addWidget(self.gradient_end_button, 3, 3)
        self.gradient_widgets = [
            self.gradient_type_label, self.gradient_combo_box,
            self.gradient_start_label, self.gradient_start_button,
            self.gradient_end_label, self.gradient_end_button
        ]
        # image
        self.image_label = FormLabel(self)
        self.image_label.setObjectName('image_label')
        self.layout.addWidget(self.image_label, 4, 0)
        self.image_path_edit = PathEdit(self,
                                        dialog_caption=translate(
                                            'OpenLP.ThemeWizard',
                                            'Select Image'),
                                        show_revert=False)
        self.layout.addWidget(self.image_path_edit, 4, 1, 1, 3)
        self.image_color_label = FormLabel(self)
        self.image_color_label.setObjectName('image_color_label')
        self.layout.addWidget(self.image_color_label, 5, 0)
        self.image_color_button = ColorButton(self)
        self.image_color_button.color = '#000000'
        self.image_color_button.setObjectName('image_color_button')
        self.layout.addWidget(self.image_color_button, 5, 1)
        self.image_widgets = [
            self.image_label, self.image_path_edit, self.image_color_label,
            self.image_color_button
        ]
        # video
        self.video_label = FormLabel(self)
        self.video_label.setObjectName('video_label')
        self.layout.addWidget(self.video_label, 6, 0)
        self.video_path_edit = PathEdit(self,
                                        dialog_caption=translate(
                                            'OpenLP.ThemeWizard',
                                            'Select Video'),
                                        show_revert=False)
        self.layout.addWidget(self.video_path_edit, 6, 1, 1, 3)
        self.video_color_label = FormLabel(self)
        self.video_color_label.setObjectName('video_color_label')
        self.layout.addWidget(self.video_color_label, 7, 0)
        self.video_color_button = ColorButton(self)
        self.video_color_button.color = '#000000'
        self.video_color_button.setObjectName('video_color_button')
        self.layout.addWidget(self.video_color_button, 7, 1)
        self.video_widgets = [
            self.video_label, self.video_path_edit, self.video_color_label,
            self.video_color_button
        ]
        # Force everything up
        self.layout_spacer = QtWidgets.QSpacerItem(1, 1)
        self.layout.addItem(self.layout_spacer, 8, 0, 1, 4)
        # Connect slots
        self.background_combo_box.currentIndexChanged.connect(
            self._on_background_type_index_changed)
        # Force the first set of widgets to show
        self._on_background_type_index_changed(0)

    def retranslate_ui(self):
        """
        Translate the text elements of the widget
        """
        self.background_label.setText(
            translate('OpenLP.ThemeWizard', 'Background type:'))
        self.background_combo_box.setItemText(
            BackgroundType.Solid, translate('OpenLP.ThemeWizard',
                                            'Solid color'))
        self.background_combo_box.setItemText(
            BackgroundType.Gradient, translate('OpenLP.ThemeWizard',
                                               'Gradient'))
        self.background_combo_box.setItemText(BackgroundType.Image,
                                              UiStrings().Image)
        self.background_combo_box.setItemText(BackgroundType.Video,
                                              UiStrings().Video)
        self.background_combo_box.setItemText(
            BackgroundType.Transparent,
            translate('OpenLP.ThemeWizard', 'Transparent'))
        self.background_combo_box.setItemText(
            BackgroundType.Stream,
            translate('OpenLP.ThemeWizard', 'Live Stream'))
        self.color_label.setText(translate('OpenLP.ThemeWizard', 'Color:'))
        self.gradient_start_label.setText(
            translate('OpenLP.ThemeWizard', 'Starting color:'))
        self.gradient_end_label.setText(
            translate('OpenLP.ThemeWizard', 'Ending color:'))
        self.gradient_type_label.setText(
            translate('OpenLP.ThemeWizard', 'Gradient:'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.Horizontal,
            translate('OpenLP.ThemeWizard', 'Horizontal'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.Vertical,
            translate('OpenLP.ThemeWizard', 'Vertical'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.Circular,
            translate('OpenLP.ThemeWizard', 'Circular'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.LeftTop,
            translate('OpenLP.ThemeWizard', 'Top Left - Bottom Right'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.LeftBottom,
            translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right'))
        self.image_color_label.setText(
            translate('OpenLP.ThemeWizard', 'Background color:'))
        self.image_label.setText('{text}:'.format(text=UiStrings().Image))
        self.video_color_label.setText(
            translate('OpenLP.ThemeWizard', 'Background color:'))
        self.video_label.setText('{text}:'.format(text=UiStrings().Video))
        self.image_path_edit.filters = \
            '{name};;{text} (*)'.format(name=get_images_filter(), text=UiStrings().AllFiles)
        visible_formats = '(*.{name})'.format(name='; *.'.join(VIDEO_EXT))
        actual_formats = '(*.{name})'.format(name=' *.'.join(VIDEO_EXT))
        video_filter = '{trans} {visible} {actual}'.format(
            trans=translate('OpenLP', 'Video Files'),
            visible=visible_formats,
            actual=actual_formats)
        self.video_path_edit.filters = '{video};;{ui} (*)'.format(
            video=video_filter, ui=UiStrings().AllFiles)

    def _on_background_type_index_changed(self, index):
        """
        Hide and show widgets based on index
        """
        widget_sets = [
            self.color_widgets, self.gradient_widgets, self.image_widgets, [],
            self.video_widgets
        ]
        for widgets in widget_sets:
            for widget in widgets:
                widget.hide()
        if index < len(widget_sets):
            for widget in widget_sets[index]:
                widget.show()

    @property
    def background_type(self):
        return BackgroundType.to_string(
            self.background_combo_box.currentIndex())

    @background_type.setter
    def background_type(self, value):
        if isinstance(value, str):
            self.background_combo_box.setCurrentIndex(
                BackgroundType.from_string(value))
        elif isinstance(value, int):
            self.background_combo_box.setCurrentIndex(value)
        else:
            raise TypeError(
                'background_type must either be a string or an int')

    @property
    def color(self):
        return self.color_button.color

    @color.setter
    def color(self, value):
        self.color_button.color = value

    @property
    def gradient_type(self):
        return BackgroundGradientType.to_string(
            self.gradient_combo_box.currentIndex())

    @gradient_type.setter
    def gradient_type(self, value):
        if isinstance(value, str):
            self.gradient_combo_box.setCurrentIndex(
                BackgroundGradientType.from_string(value))
        elif isinstance(value, int):
            self.gradient_combo_box.setCurrentIndex(value)
        else:
            raise TypeError('gradient_type must either be a string or an int')

    @property
    def gradient_start(self):
        return self.gradient_start_button.color

    @gradient_start.setter
    def gradient_start(self, value):
        self.gradient_start_button.color = value

    @property
    def gradient_end(self):
        return self.gradient_end_button.color

    @gradient_end.setter
    def gradient_end(self, value):
        self.gradient_end_button.color = value

    @property
    def image_color(self):
        return self.image_color_button.color

    @image_color.setter
    def image_color(self, value):
        self.image_color_button.color = value

    @property
    def image_path(self):
        return self.image_path_edit.path

    @image_path.setter
    def image_path(self, value):
        self.image_path_edit.path = value

    @property
    def video_color(self):
        return self.video_color_button.color

    @video_color.setter
    def video_color(self, value):
        self.video_color_button.color = value

    @property
    def video_path(self):
        return self.video_path_edit.path

    @video_path.setter
    def video_path(self, value):
        self.video_path_edit.path = value
Example #3
0
class GeneralTab(SettingsTab):
    """
    GeneralTab is the general settings tab in the settings dialog.
    """
    def __init__(self, parent):
        """
        Initialise the general settings tab
        """
        self.logo_file = ':/graphics/openlp-splash-screen.png'
        self.logo_background_color = '#ffffff'
        self.screens = ScreenList()
        self.icon_path = ':/icon/openlp-logo.svg'
        general_translated = translate('OpenLP.GeneralTab', 'General')
        super(GeneralTab, self).__init__(parent, 'Core', general_translated)

    def setupUi(self):
        """
        Create the user interface for the general settings tab
        """
        self.setObjectName('GeneralTab')
        super(GeneralTab, self).setupUi()
        self.tab_layout.setStretch(1, 1)
        # Monitors
        self.monitor_group_box = QtWidgets.QGroupBox(self.left_column)
        self.monitor_group_box.setObjectName('monitor_group_box')
        self.monitor_layout = QtWidgets.QGridLayout(self.monitor_group_box)
        self.monitor_layout.setObjectName('monitor_layout')
        self.monitor_radio_button = QtWidgets.QRadioButton(
            self.monitor_group_box)
        self.monitor_radio_button.setObjectName('monitor_radio_button')
        self.monitor_layout.addWidget(self.monitor_radio_button, 0, 0, 1, 5)
        self.monitor_combo_box = QtWidgets.QComboBox(self.monitor_group_box)
        self.monitor_combo_box.setObjectName('monitor_combo_box')
        self.monitor_layout.addWidget(self.monitor_combo_box, 1, 1, 1, 4)
        # Display Position
        self.override_radio_button = QtWidgets.QRadioButton(
            self.monitor_group_box)
        self.override_radio_button.setObjectName('override_radio_button')
        self.monitor_layout.addWidget(self.override_radio_button, 2, 0, 1, 5)
        # Custom position
        self.custom_x_label = QtWidgets.QLabel(self.monitor_group_box)
        self.custom_x_label.setObjectName('custom_x_label')
        self.monitor_layout.addWidget(self.custom_x_label, 3, 1)
        self.custom_X_value_edit = QtWidgets.QSpinBox(self.monitor_group_box)
        self.custom_X_value_edit.setObjectName('custom_X_value_edit')
        self.custom_X_value_edit.setRange(-9999, 9999)
        self.monitor_layout.addWidget(self.custom_X_value_edit, 4, 1)
        self.custom_y_label = QtWidgets.QLabel(self.monitor_group_box)
        self.custom_y_label.setObjectName('custom_y_label')
        self.monitor_layout.addWidget(self.custom_y_label, 3, 2)
        self.custom_Y_value_edit = QtWidgets.QSpinBox(self.monitor_group_box)
        self.custom_Y_value_edit.setObjectName('custom_Y_value_edit')
        self.custom_Y_value_edit.setRange(-9999, 9999)
        self.monitor_layout.addWidget(self.custom_Y_value_edit, 4, 2)
        self.custom_width_label = QtWidgets.QLabel(self.monitor_group_box)
        self.custom_width_label.setObjectName('custom_width_label')
        self.monitor_layout.addWidget(self.custom_width_label, 3, 3)
        self.custom_width_value_edit = QtWidgets.QSpinBox(
            self.monitor_group_box)
        self.custom_width_value_edit.setObjectName('custom_width_value_edit')
        self.custom_width_value_edit.setRange(1, 9999)
        self.monitor_layout.addWidget(self.custom_width_value_edit, 4, 3)
        self.custom_height_label = QtWidgets.QLabel(self.monitor_group_box)
        self.custom_height_label.setObjectName('custom_height_label')
        self.monitor_layout.addWidget(self.custom_height_label, 3, 4)
        self.custom_height_value_edit = QtWidgets.QSpinBox(
            self.monitor_group_box)
        self.custom_height_value_edit.setObjectName('custom_height_value_edit')
        self.custom_height_value_edit.setRange(1, 9999)
        self.monitor_layout.addWidget(self.custom_height_value_edit, 4, 4)
        self.display_on_monitor_check = QtWidgets.QCheckBox(
            self.monitor_group_box)
        self.display_on_monitor_check.setObjectName('monitor_combo_box')
        self.monitor_layout.addWidget(self.display_on_monitor_check, 5, 0, 1,
                                      5)
        # Set up the stretchiness of each column, so that the first column
        # less stretchy (and therefore smaller) than the others
        self.monitor_layout.setColumnStretch(0, 1)
        self.monitor_layout.setColumnStretch(1, 3)
        self.monitor_layout.setColumnStretch(2, 3)
        self.monitor_layout.setColumnStretch(3, 3)
        self.monitor_layout.setColumnStretch(4, 3)
        self.left_layout.addWidget(self.monitor_group_box)
        # CCLI Details
        self.ccli_group_box = QtWidgets.QGroupBox(self.left_column)
        self.ccli_group_box.setObjectName('ccli_group_box')
        self.ccli_layout = QtWidgets.QFormLayout(self.ccli_group_box)
        self.ccli_layout.setObjectName('ccli_layout')
        self.number_label = QtWidgets.QLabel(self.ccli_group_box)
        self.number_label.setObjectName('number_label')
        self.number_edit = QtWidgets.QLineEdit(self.ccli_group_box)
        self.number_edit.setValidator(QtGui.QIntValidator())
        self.number_edit.setObjectName('number_edit')
        self.ccli_layout.addRow(self.number_label, self.number_edit)
        self.username_label = QtWidgets.QLabel(self.ccli_group_box)
        self.username_label.setObjectName('username_label')
        self.username_edit = QtWidgets.QLineEdit(self.ccli_group_box)
        self.username_edit.setObjectName('username_edit')
        self.ccli_layout.addRow(self.username_label, self.username_edit)
        self.password_label = QtWidgets.QLabel(self.ccli_group_box)
        self.password_label.setObjectName('password_label')
        self.password_edit = QtWidgets.QLineEdit(self.ccli_group_box)
        self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password)
        self.password_edit.setObjectName('password_edit')
        self.ccli_layout.addRow(self.password_label, self.password_edit)
        self.left_layout.addWidget(self.ccli_group_box)
        # Background audio
        self.audio_group_box = QtWidgets.QGroupBox(self.left_column)
        self.audio_group_box.setObjectName('audio_group_box')
        self.audio_layout = QtWidgets.QVBoxLayout(self.audio_group_box)
        self.audio_layout.setObjectName('audio_layout')
        self.start_paused_check_box = QtWidgets.QCheckBox(self.audio_group_box)
        self.start_paused_check_box.setObjectName('start_paused_check_box')
        self.audio_layout.addWidget(self.start_paused_check_box)
        self.repeat_list_check_box = QtWidgets.QCheckBox(self.audio_group_box)
        self.repeat_list_check_box.setObjectName('repeat_list_check_box')
        self.audio_layout.addWidget(self.repeat_list_check_box)
        self.left_layout.addWidget(self.audio_group_box)
        self.left_layout.addStretch()
        # Application Startup
        self.startup_group_box = QtWidgets.QGroupBox(self.right_column)
        self.startup_group_box.setObjectName('startup_group_box')
        self.startup_layout = QtWidgets.QVBoxLayout(self.startup_group_box)
        self.startup_layout.setObjectName('startup_layout')
        self.warning_check_box = QtWidgets.QCheckBox(self.startup_group_box)
        self.warning_check_box.setObjectName('warning_check_box')
        self.startup_layout.addWidget(self.warning_check_box)
        self.auto_open_check_box = QtWidgets.QCheckBox(self.startup_group_box)
        self.auto_open_check_box.setObjectName('auto_open_check_box')
        self.startup_layout.addWidget(self.auto_open_check_box)
        self.show_splash_check_box = QtWidgets.QCheckBox(
            self.startup_group_box)
        self.show_splash_check_box.setObjectName('show_splash_check_box')
        self.startup_layout.addWidget(self.show_splash_check_box)
        self.check_for_updates_check_box = QtWidgets.QCheckBox(
            self.startup_group_box)
        self.check_for_updates_check_box.setObjectName(
            'check_for_updates_check_box')
        self.startup_layout.addWidget(self.check_for_updates_check_box)
        self.right_layout.addWidget(self.startup_group_box)
        # Logo
        self.logo_group_box = QtWidgets.QGroupBox(self.right_column)
        self.logo_group_box.setObjectName('logo_group_box')
        self.logo_layout = QtWidgets.QFormLayout(self.logo_group_box)
        self.logo_layout.setObjectName('logo_layout')
        self.logo_file_label = QtWidgets.QLabel(self.logo_group_box)
        self.logo_file_label.setObjectName('logo_file_label')
        self.logo_file_path_edit = PathEdit(
            self.logo_group_box,
            default_path=Path(':/graphics/openlp-splash-screen.png'))
        self.logo_layout.addRow(self.logo_file_label, self.logo_file_path_edit)
        self.logo_color_label = QtWidgets.QLabel(self.logo_group_box)
        self.logo_color_label.setObjectName('logo_color_label')
        self.logo_color_button = ColorButton(self.logo_group_box)
        self.logo_color_button.setObjectName('logo_color_button')
        self.logo_layout.addRow(self.logo_color_label, self.logo_color_button)
        self.logo_hide_on_startup_check_box = QtWidgets.QCheckBox(
            self.logo_group_box)
        self.logo_hide_on_startup_check_box.setObjectName(
            'logo_hide_on_startup_check_box')
        self.logo_layout.addRow(self.logo_hide_on_startup_check_box)
        self.right_layout.addWidget(self.logo_group_box)
        self.logo_color_button.colorChanged.connect(
            self.on_logo_background_color_changed)
        # Application Settings
        self.settings_group_box = QtWidgets.QGroupBox(self.right_column)
        self.settings_group_box.setObjectName('settings_group_box')
        self.settings_layout = QtWidgets.QFormLayout(self.settings_group_box)
        self.settings_layout.setObjectName('settings_layout')
        self.save_check_service_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.save_check_service_check_box.setObjectName(
            'save_check_service_check_box')
        self.settings_layout.addRow(self.save_check_service_check_box)
        self.auto_unblank_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.auto_unblank_check_box.setObjectName('auto_unblank_check_box')
        self.settings_layout.addRow(self.auto_unblank_check_box)
        self.click_live_slide_to_unblank_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.click_live_slide_to_unblank_check_box.setObjectName(
            'click_live_slide_to_unblank')
        self.settings_layout.addRow(self.click_live_slide_to_unblank_check_box)
        self.auto_preview_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.auto_preview_check_box.setObjectName('auto_preview_check_box')
        self.settings_layout.addRow(self.auto_preview_check_box)
        # Moved here from image tab
        self.timeout_label = QtWidgets.QLabel(self.settings_group_box)
        self.timeout_label.setObjectName('timeout_label')
        self.timeout_spin_box = QtWidgets.QSpinBox(self.settings_group_box)
        self.timeout_spin_box.setObjectName('timeout_spin_box')
        self.timeout_spin_box.setRange(1, 180)
        self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box)
        self.right_layout.addWidget(self.settings_group_box)
        self.right_layout.addStretch()
        # Signals and slots
        self.override_radio_button.toggled.connect(
            self.on_override_radio_button_pressed)
        self.custom_height_value_edit.valueChanged.connect(
            self.on_display_changed)
        self.custom_width_value_edit.valueChanged.connect(
            self.on_display_changed)
        self.custom_Y_value_edit.valueChanged.connect(self.on_display_changed)
        self.custom_X_value_edit.valueChanged.connect(self.on_display_changed)
        self.monitor_combo_box.currentIndexChanged.connect(
            self.on_display_changed)
        # Reload the tab, as the screen resolution/count may have changed.
        Registry().register_function('config_screen_changed', self.load)
        # Remove for now
        self.username_label.setVisible(False)
        self.username_edit.setVisible(False)
        self.password_label.setVisible(False)
        self.password_edit.setVisible(False)

    def retranslateUi(self):
        """
        Translate the general settings tab to the currently selected language
        """
        self.tab_title_visible = translate('OpenLP.GeneralTab', 'General')
        self.monitor_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'Monitors'))
        self.monitor_radio_button.setText(
            translate('OpenLP.GeneralTab',
                      'Select monitor for output display:'))
        self.display_on_monitor_check.setText(
            translate('OpenLP.GeneralTab', 'Display if a single screen'))
        self.startup_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'Application Startup'))
        self.warning_check_box.setText(
            translate('OpenLP.GeneralTab', 'Show blank screen warning'))
        self.auto_open_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Automatically open the previous service file'))
        self.show_splash_check_box.setText(
            translate('OpenLP.GeneralTab', 'Show the splash screen'))
        self.logo_group_box.setTitle(translate('OpenLP.GeneralTab', 'Logo'))
        self.logo_color_label.setText(UiStrings().BackgroundColorColon)
        self.logo_file_label.setText(
            translate('OpenLP.GeneralTab', 'Logo file:'))
        self.logo_hide_on_startup_check_box.setText(
            translate('OpenLP.GeneralTab', 'Don\'t show logo on startup'))
        self.check_for_updates_check_box.setText(
            translate('OpenLP.GeneralTab', 'Check for updates to OpenLP'))
        self.settings_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'Application Settings'))
        self.save_check_service_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Prompt to save before starting a new service'))
        self.click_live_slide_to_unblank_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Unblank display when changing slide in Live'))
        self.auto_unblank_check_box.setText(
            translate('OpenLP.GeneralTab', 'Unblank display when sending '
                      'items to Live'))
        self.auto_preview_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Automatically preview the next item in service'))
        self.timeout_label.setText(
            translate('OpenLP.GeneralTab', 'Timed slide interval:'))
        self.timeout_spin_box.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
        self.ccli_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'CCLI Details'))
        self.number_label.setText(UiStrings().CCLINumberLabel)
        self.username_label.setText(
            translate('OpenLP.GeneralTab', 'SongSelect username:'******'OpenLP.GeneralTab', 'SongSelect password:'******'OpenLP.GeneralTab', 'Override display position:'))
        self.custom_x_label.setText(translate('OpenLP.GeneralTab', 'X'))
        self.custom_y_label.setText(translate('OpenLP.GeneralTab', 'Y'))
        self.custom_height_label.setText(
            translate('OpenLP.GeneralTab', 'Height'))
        self.custom_width_label.setText(translate('OpenLP.GeneralTab',
                                                  'Width'))
        self.audio_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'Background Audio'))
        self.start_paused_check_box.setText(
            translate('OpenLP.GeneralTab', 'Start background audio paused'))
        self.repeat_list_check_box.setText(
            translate('OpenLP.GeneralTab', 'Repeat track list'))
        self.logo_file_path_edit.dialog_caption = translate(
            'OpenLP.AdvancedTab', 'Select Logo File')
        self.logo_file_path_edit.filters = '{text};;{names} (*)'.format(
            text=get_images_filter(), names=UiStrings().AllFiles)

    def load(self):
        """
        Load the settings to populate the form
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.monitor_combo_box.clear()
        self.monitor_combo_box.addItems(self.screens.get_screen_list())
        monitor_number = settings.value('monitor')
        self.monitor_combo_box.setCurrentIndex(monitor_number)
        self.number_edit.setText(settings.value('ccli number'))
        self.username_edit.setText(settings.value('songselect username'))
        self.password_edit.setText(settings.value('songselect password'))
        self.save_check_service_check_box.setChecked(
            settings.value('save prompt'))
        self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
        self.click_live_slide_to_unblank_check_box.setChecked(
            settings.value('click live slide to unblank'))
        self.display_on_monitor_check.setChecked(self.screens.display)
        self.warning_check_box.setChecked(settings.value('blank warning'))
        self.auto_open_check_box.setChecked(settings.value('auto open'))
        self.show_splash_check_box.setChecked(settings.value('show splash'))
        self.logo_background_color = settings.value('logo background color')
        self.logo_file_path_edit.path = settings.value('logo file')
        self.logo_hide_on_startup_check_box.setChecked(
            settings.value('logo hide on startup'))
        self.logo_color_button.color = self.logo_background_color
        self.check_for_updates_check_box.setChecked(
            settings.value('update check'))
        self.auto_preview_check_box.setChecked(settings.value('auto preview'))
        self.timeout_spin_box.setValue(settings.value('loop delay'))
        self.monitor_radio_button.setChecked(
            not settings.value('override position', ))
        self.override_radio_button.setChecked(
            settings.value('override position'))
        self.custom_X_value_edit.setValue(settings.value('x position'))
        self.custom_Y_value_edit.setValue(settings.value('y position'))
        self.custom_height_value_edit.setValue(settings.value('height'))
        self.custom_width_value_edit.setValue(settings.value('width'))
        self.start_paused_check_box.setChecked(
            settings.value('audio start paused'))
        self.repeat_list_check_box.setChecked(
            settings.value('audio repeat list'))
        settings.endGroup()
        self.monitor_combo_box.setDisabled(
            self.override_radio_button.isChecked())
        self.custom_X_value_edit.setEnabled(
            self.override_radio_button.isChecked())
        self.custom_Y_value_edit.setEnabled(
            self.override_radio_button.isChecked())
        self.custom_height_value_edit.setEnabled(
            self.override_radio_button.isChecked())
        self.custom_width_value_edit.setEnabled(
            self.override_radio_button.isChecked())
        self.display_changed = False

    def save(self):
        """
        Save the settings from the form
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        settings.setValue('monitor', self.monitor_combo_box.currentIndex())
        settings.setValue('display on monitor',
                          self.display_on_monitor_check.isChecked())
        settings.setValue('blank warning', self.warning_check_box.isChecked())
        settings.setValue('auto open', self.auto_open_check_box.isChecked())
        settings.setValue('show splash',
                          self.show_splash_check_box.isChecked())
        settings.setValue('logo background color', self.logo_background_color)
        settings.setValue('logo file', self.logo_file_path_edit.path)
        settings.setValue('logo hide on startup',
                          self.logo_hide_on_startup_check_box.isChecked())
        settings.setValue('update check',
                          self.check_for_updates_check_box.isChecked())
        settings.setValue('save prompt',
                          self.save_check_service_check_box.isChecked())
        settings.setValue('auto unblank',
                          self.auto_unblank_check_box.isChecked())
        settings.setValue(
            'click live slide to unblank',
            self.click_live_slide_to_unblank_check_box.isChecked())
        settings.setValue('auto preview',
                          self.auto_preview_check_box.isChecked())
        settings.setValue('loop delay', self.timeout_spin_box.value())
        settings.setValue('ccli number', self.number_edit.displayText())
        settings.setValue('songselect username',
                          self.username_edit.displayText())
        settings.setValue('songselect password',
                          self.password_edit.displayText())
        settings.setValue('x position', self.custom_X_value_edit.value())
        settings.setValue('y position', self.custom_Y_value_edit.value())
        settings.setValue('height', self.custom_height_value_edit.value())
        settings.setValue('width', self.custom_width_value_edit.value())
        settings.setValue('override position',
                          self.override_radio_button.isChecked())
        settings.setValue('audio start paused',
                          self.start_paused_check_box.isChecked())
        settings.setValue('audio repeat list',
                          self.repeat_list_check_box.isChecked())
        settings.endGroup()
        # On save update the screens as well
        self.post_set_up(True)

    def post_set_up(self, postUpdate=False):
        """
        Apply settings after settings tab has loaded and most of the system so must be delayed
        """
        self.settings_form.register_post_process(
            'slidecontroller_live_spin_delay')
        # Do not continue on start up.
        if not postUpdate:
            return
        self.screens.set_current_display(self.monitor_combo_box.currentIndex())
        self.screens.display = self.display_on_monitor_check.isChecked()
        self.screens.override['size'] = QtCore.QRect(
            self.custom_X_value_edit.value(), self.custom_Y_value_edit.value(),
            self.custom_width_value_edit.value(),
            self.custom_height_value_edit.value())
        self.screens.override['number'] = self.screens.which_screen(
            self.screens.override['size'])
        self.screens.override['primary'] = (self.screens.desktop.primaryScreen(
        ) == self.screens.override['number'])
        if self.override_radio_button.isChecked():
            self.screens.set_override_display()
        else:
            self.screens.reset_current_display()
        if self.display_changed:
            self.settings_form.register_post_process('config_screen_changed')
        self.display_changed = False

    def on_override_radio_button_pressed(self, checked):
        """
        Toggle screen state depending on check box state.

        :param checked: The state of the check box (boolean).
        """
        self.monitor_combo_box.setDisabled(checked)
        self.custom_X_value_edit.setEnabled(checked)
        self.custom_Y_value_edit.setEnabled(checked)
        self.custom_height_value_edit.setEnabled(checked)
        self.custom_width_value_edit.setEnabled(checked)
        self.display_changed = True

    def on_display_changed(self):
        """
        Called when the width, height, x position or y position has changed.
        """
        self.display_changed = True

    def on_logo_background_color_changed(self, color):
        """
        Select the background color for logo.
        """
        self.logo_background_color = color
Example #4
0
class ImageTab(SettingsTab):
    """
    ImageTab is the images settings tab in the settings dialog.
    """
    def setupUi(self):
        self.setObjectName('ImagesTab')
        super(ImageTab, self).setupUi()
        self.background_color_group_box = QtWidgets.QGroupBox(self.left_column)
        self.background_color_group_box.setObjectName(
            'background_color_group_box')
        self.form_layout = QtWidgets.QFormLayout(
            self.background_color_group_box)
        self.form_layout.setObjectName('form_layout')
        self.color_layout = QtWidgets.QHBoxLayout()
        self.background_color_label = QtWidgets.QLabel(
            self.background_color_group_box)
        self.background_color_label.setObjectName('background_color_label')
        self.color_layout.addWidget(self.background_color_label)
        self.background_color_button = ColorButton(
            self.background_color_group_box)
        self.background_color_button.setObjectName('background_color_button')
        self.color_layout.addWidget(self.background_color_button)
        self.form_layout.addRow(self.color_layout)
        self.information_label = QtWidgets.QLabel(
            self.background_color_group_box)
        self.information_label.setObjectName('information_label')
        self.information_label.setWordWrap(True)
        self.form_layout.addRow(self.information_label)
        self.left_layout.addWidget(self.background_color_group_box)
        self.left_layout.addStretch()
        self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding,
                                        QtWidgets.QSizePolicy.Preferred)
        self.right_layout.addStretch()
        # Signals and slots
        self.background_color_button.colorChanged.connect(
            self.on_background_color_changed)

    def retranslateUi(self):
        self.background_color_group_box.setTitle(UiStrings().BackgroundColor)
        self.background_color_label.setText(UiStrings().BackgroundColorColon)
        self.information_label.setText(
            translate(
                'ImagesPlugin.ImageTab',
                'Visible background for images with aspect ratio different to screen.'
            ))

    def on_background_color_changed(self, color):
        self.background_color = color

    def load(self):
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.background_color = settings.value('background color')
        self.initial_color = self.background_color
        settings.endGroup()
        self.background_color_button.color = self.background_color

    def save(self):
        settings = Settings()
        settings.beginGroup(self.settings_section)
        settings.setValue('background color', self.background_color)
        settings.endGroup()
        if self.initial_color != self.background_color:
            self.settings_form.register_post_process('images_config_updated')
Example #5
0
class FontSelectPage(GridLayoutPage):
    """
    A font selection widget
    """
    Outline = 'outline'
    Shadow = 'shadow'
    LineSpacing = 'line_spacing'

    font_name_changed = QtCore.pyqtSignal(str)
    font_size_changed = QtCore.pyqtSignal(int)
    font_color_changed = QtCore.pyqtSignal(str)
    is_bold_changed = QtCore.pyqtSignal(bool)
    is_italic_changed = QtCore.pyqtSignal(bool)
    line_spacing_changed = QtCore.pyqtSignal(int)
    is_outline_enabled_changed = QtCore.pyqtSignal(bool)
    outline_color_changed = QtCore.pyqtSignal(str)
    outline_size_changed = QtCore.pyqtSignal(int)
    is_shadow_enabled_changed = QtCore.pyqtSignal(bool)
    shadow_color_changed = QtCore.pyqtSignal(str)
    shadow_size_changed = QtCore.pyqtSignal(int)

    def __init__(self, parent=None):
        super().__init__(parent)
        self.feature_widgets = {
            FontSelectPage.Outline: [self.outline_groupbox],
            FontSelectPage.Shadow: [self.shadow_groupbox],
            FontSelectPage.LineSpacing:
            [self.line_spacing_label, self.line_spacing_spinbox]
        }

    def setup_ui(self):
        # Font name
        self.font_name_label = FormLabel(self)
        self.font_name_label.setObjectName('font_name_label')
        self.layout.addWidget(self.font_name_label, 0, 0)
        self.font_name_combobox = QtWidgets.QFontComboBox(self)
        self.font_name_combobox.setObjectName('font_name_combobox')
        self.layout.addWidget(self.font_name_combobox, 0, 1, 1, 3)
        # Font color
        self.font_color_label = FormLabel(self)
        self.font_color_label.setObjectName('font_color_label')
        self.layout.addWidget(self.font_color_label, 1, 0)
        self.font_color_button = ColorButton(self)
        self.font_color_button.setObjectName('font_color_button')
        self.layout.addWidget(self.font_color_button, 1, 1)
        # Font style
        self.font_style_label = FormLabel(self)
        self.font_style_label.setObjectName('font_style_label')
        self.layout.addWidget(self.font_style_label, 1, 2)
        self.style_layout = QtWidgets.QHBoxLayout()
        self.style_bold_button = QtWidgets.QToolButton(self)
        self.style_bold_button.setCheckable(True)
        self.style_bold_button.setIcon(UiIcons().bold)
        self.style_bold_button.setShortcut(
            QtGui.QKeySequence(QtGui.QKeySequence.Bold))
        self.style_bold_button.setObjectName('style_bold_button')
        self.style_layout.addWidget(self.style_bold_button)
        self.style_italic_button = QtWidgets.QToolButton(self)
        self.style_italic_button.setCheckable(True)
        self.style_italic_button.setIcon(UiIcons().italic)
        self.style_italic_button.setShortcut(
            QtGui.QKeySequence(QtGui.QKeySequence.Italic))
        self.style_italic_button.setObjectName('style_italic_button')
        self.style_layout.addWidget(self.style_italic_button)
        self.style_layout.addStretch(1)
        self.layout.addLayout(self.style_layout, 1, 3)
        # Font size
        self.font_size_label = FormLabel(self)
        self.font_size_label.setObjectName('font_size_label')
        self.layout.addWidget(self.font_size_label, 2, 0)
        self.font_size_spinbox = QtWidgets.QSpinBox(self)
        self.font_size_spinbox.setMaximum(999)
        self.font_size_spinbox.setValue(16)
        self.font_size_spinbox.setObjectName('font_size_spinbox')
        self.layout.addWidget(self.font_size_spinbox, 2, 1)
        # Line spacing
        self.line_spacing_label = FormLabel(self)
        self.line_spacing_label.setObjectName('line_spacing_label')
        self.layout.addWidget(self.line_spacing_label, 2, 2)
        self.line_spacing_spinbox = QtWidgets.QSpinBox(self)
        self.line_spacing_spinbox.setMinimum(-250)
        self.line_spacing_spinbox.setMaximum(250)
        self.line_spacing_spinbox.setObjectName('line_spacing_spinbox')
        self.layout.addWidget(self.line_spacing_spinbox, 2, 3)
        # Outline
        self.outline_groupbox = QtWidgets.QGroupBox(self)
        self.outline_groupbox.setCheckable(True)
        self.outline_groupbox.setChecked(False)
        self.outline_groupbox.setObjectName('outline_groupbox')
        self.outline_layout = QtWidgets.QGridLayout(self.outline_groupbox)
        self.layout.addWidget(self.outline_groupbox, 3, 0, 1, 2)
        # Outline colour
        self.outline_color_label = FormLabel(self.outline_groupbox)
        self.outline_color_label.setObjectName('outline_color_label')
        self.outline_layout.addWidget(self.outline_color_label, 0, 0)
        self.outline_color_button = ColorButton(self.outline_groupbox)
        self.outline_color_button.setObjectName('outline_color_button')
        self.outline_layout.addWidget(self.outline_color_button, 0, 1)
        # Outline size
        self.outline_size_label = FormLabel(self.outline_groupbox)
        self.outline_size_label.setObjectName('outline_size_label')
        self.outline_layout.addWidget(self.outline_size_label, 1, 0)
        self.outline_size_spinbox = QtWidgets.QSpinBox(self.outline_groupbox)
        self.outline_size_spinbox.setMaximum(9999)
        self.outline_size_spinbox.setObjectName('outline_size_spinbox')
        self.outline_layout.addWidget(self.outline_size_spinbox, 1, 1)
        # Shadow
        self.shadow_groupbox = QtWidgets.QGroupBox(self)
        self.shadow_groupbox.setCheckable(True)
        self.shadow_groupbox.setChecked(False)
        self.shadow_groupbox.setObjectName('shadow_groupbox')
        self.shadow_layout = QtWidgets.QGridLayout(self.shadow_groupbox)
        self.layout.addWidget(self.shadow_groupbox, 3, 2, 1, 2)
        # Shadow color
        self.shadow_color_label = FormLabel(self.shadow_groupbox)
        self.shadow_color_label.setObjectName('shadow_color_label')
        self.shadow_layout.addWidget(self.shadow_color_label, 0, 0)
        self.shadow_color_button = ColorButton(self.shadow_groupbox)
        self.shadow_color_button.setObjectName('shadow_color_button')
        self.shadow_layout.addWidget(self.shadow_color_button, 0, 1)
        # Shadow size
        self.shadow_size_label = FormLabel(self.shadow_groupbox)
        self.shadow_size_label.setObjectName('shadow_size_label')
        self.shadow_layout.addWidget(self.shadow_size_label, 1, 0)
        self.shadow_size_spinbox = QtWidgets.QSpinBox(self.shadow_groupbox)
        self.shadow_size_spinbox.setMaximum(9999)
        self.shadow_size_spinbox.setObjectName('shadow_size_spinbox')
        self.shadow_layout.addWidget(self.shadow_size_spinbox, 1, 1)
        # Connect all the signals
        self.font_name_combobox.activated.connect(self._on_font_name_changed)
        self.font_color_button.colorChanged.connect(
            self._on_font_color_changed)
        self.style_bold_button.toggled.connect(self._on_style_bold_toggled)
        self.style_italic_button.toggled.connect(self._on_style_italic_toggled)
        self.font_size_spinbox.valueChanged.connect(self._on_font_size_changed)
        self.line_spacing_spinbox.valueChanged.connect(
            self._on_line_spacing_changed)
        self.outline_groupbox.toggled.connect(self._on_outline_toggled)
        self.outline_color_button.colorChanged.connect(
            self._on_outline_color_changed)
        self.outline_size_spinbox.valueChanged.connect(
            self._on_outline_size_changed)
        self.shadow_groupbox.toggled.connect(self._on_shadow_toggled)
        self.shadow_color_button.colorChanged.connect(
            self._on_shadow_color_changed)
        self.shadow_size_spinbox.valueChanged.connect(
            self._on_shadow_size_changed)

    def retranslate_ui(self):
        self.font_name_label.setText(
            translate('OpenLP.FontSelectWidget', 'Font:'))
        self.font_color_label.setText(
            translate('OpenLP.FontSelectWidget', 'Color:'))
        self.font_style_label.setText(
            translate('OpenLP.FontSelectWidget', 'Style:'))
        self.style_bold_button.setToolTip('{name} ({shortcut})'.format(
            name=translate('OpenLP.FontSelectWidget', 'Bold'),
            shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Bold).toString()))
        self.style_italic_button.setToolTip('{name} ({shortcut})'.format(
            name=translate('OpenLP.FontSelectWidget', 'Italic'),
            shortcut=QtGui.QKeySequence(QtGui.QKeySequence.Italic).toString()))
        self.font_size_label.setText(
            translate('OpenLP.FontSelectWidget', 'Size:'))
        self.font_size_spinbox.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.line_spacing_label.setText(
            translate('OpenLP.FontSelectWidget', 'Line Spacing:'))
        self.outline_groupbox.setTitle(
            translate('OpenLP.FontSelectWidget', 'Outline'))
        self.outline_color_label.setText(
            translate('OpenLP.FontSelectWidget', 'Color:'))
        self.outline_size_label.setText(
            translate('OpenLP.FontSelectWidget', 'Size:'))
        self.shadow_groupbox.setTitle(
            translate('OpenLP.FontSelectWidget', 'Shadow'))
        self.shadow_color_label.setText(
            translate('OpenLP.FontSelectWidget', 'Color:'))
        self.shadow_size_label.setText(
            translate('OpenLP.FontSelectWidget', 'Size:'))

    def _on_font_name_changed(self, name):
        if isinstance(name, str):
            self.font_name_changed.emit(name)

    def _on_font_color_changed(self, color):
        self.font_color_changed.emit(color)

    def _on_style_bold_toggled(self, is_bold):
        self.is_bold_changed.emit(is_bold)

    def _on_style_italic_toggled(self, is_italic):
        self.is_italic_changed.emit(is_italic)

    def _on_font_size_changed(self, size):
        self.font_size_changed.emit(size)

    def _on_line_spacing_changed(self, spacing):
        self.line_spacing_changed.emit(spacing)

    def _on_outline_toggled(self, is_enabled):
        self.is_outline_enabled_changed.emit(is_enabled)

    def _on_outline_color_changed(self, color):
        self.outline_color_changed.emit(color)

    def _on_outline_size_changed(self, size):
        self.outline_size_changed.emit(size)

    def _on_shadow_toggled(self, is_enabled):
        self.is_shadow_enabled_changed.emit(is_enabled)

    def _on_shadow_color_changed(self, color):
        self.shadow_color_changed.emit(color)

    def _on_shadow_size_changed(self, size):
        self.shadow_size_changed.emit(size)

    def enable_features(self, *features):
        """
        Enable a feature
        """
        for feature_name in features:
            if feature_name not in self.feature_widgets.keys():
                raise KeyError('No such feature: {feature_name}'.format(
                    feature_name=feature_name))
            for widget in self.feature_widgets[feature_name]:
                widget.show()

    def disable_features(self, *features):
        """
        Disable a feature
        """
        for feature_name in features:
            if feature_name not in self.feature_widgets.keys():
                raise KeyError('No such feature: {feature_name}'.format(
                    feature_name=feature_name))
            for widget in self.feature_widgets[feature_name]:
                widget.hide()

    @property
    def font_name(self):
        return self.font_name_combobox.currentFont().family()

    @font_name.setter
    def font_name(self, font):
        self.font_name_combobox.setCurrentFont(QtGui.QFont(font))

    @property
    def font_color(self):
        return self.font_color_button.color

    @font_color.setter
    def font_color(self, color):
        self.font_color_button.color = color

    @property
    def is_bold(self):
        return self.style_bold_button.isChecked()

    @is_bold.setter
    def is_bold(self, is_bold):
        self.style_bold_button.setChecked(is_bold)

    @property
    def is_italic(self):
        return self.style_italic_button.isChecked()

    @is_italic.setter
    def is_italic(self, is_italic):
        self.style_italic_button.setChecked(is_italic)

    @property
    def font_size(self):
        return self.font_size_spinbox.value()

    @font_size.setter
    def font_size(self, size):
        self.font_size_spinbox.setValue(size)

    @property
    def line_spacing(self):
        return self.line_spacing_spinbox.value()

    @line_spacing.setter
    def line_spacing(self, line_spacing):
        self.line_spacing_spinbox.setValue(line_spacing)

    @property
    def is_outline_enabled(self):
        return self.outline_groupbox.isChecked()

    @is_outline_enabled.setter
    def is_outline_enabled(self, is_enabled):
        self.outline_groupbox.setChecked(is_enabled)

    @property
    def outline_color(self):
        return self.outline_color_button.color

    @outline_color.setter
    def outline_color(self, color):
        self.outline_color_button.color = color

    @property
    def outline_size(self):
        return self.outline_size_spinbox.value()

    @outline_size.setter
    def outline_size(self, size):
        self.outline_size_spinbox.setValue(size)

    @property
    def is_shadow_enabled(self):
        return self.shadow_groupbox.isChecked()

    @is_shadow_enabled.setter
    def is_shadow_enabled(self, is_enabled):
        self.shadow_groupbox.setChecked(is_enabled)

    @property
    def shadow_color(self):
        return self.shadow_color_button.color

    @shadow_color.setter
    def shadow_color(self, color):
        self.shadow_color_button.color = color

    @property
    def shadow_size(self):
        return self.shadow_size_spinbox.value()

    @shadow_size.setter
    def shadow_size(self, size):
        self.shadow_size_spinbox.setValue(size)
Example #6
0
class AlertsTab(SettingsTab):
    """
    AlertsTab is the alerts settings tab in the settings dialog.
    """
    def setupUi(self):
        self.setObjectName('AlertsTab')
        super(AlertsTab, self).setupUi()
        self.font_group_box = QtWidgets.QGroupBox(self.left_column)
        self.font_group_box.setObjectName('font_group_box')
        self.font_layout = QtWidgets.QFormLayout(self.font_group_box)
        self.font_layout.setObjectName('font_layout')
        self.font_label = QtWidgets.QLabel(self.font_group_box)
        self.font_label.setObjectName('font_label')
        self.font_combo_box = QtWidgets.QFontComboBox(self.font_group_box)
        self.font_combo_box.setObjectName('font_combo_box')
        self.font_layout.addRow(self.font_label, self.font_combo_box)
        self.font_color_label = QtWidgets.QLabel(self.font_group_box)
        self.font_color_label.setObjectName('font_color_label')
        self.color_layout = QtWidgets.QHBoxLayout()
        self.color_layout.setObjectName('color_layout')
        self.font_color_button = ColorButton(self.font_group_box)
        self.font_color_button.setObjectName('font_color_button')
        self.color_layout.addWidget(self.font_color_button)
        self.color_layout.addSpacing(20)
        self.background_color_label = QtWidgets.QLabel(self.font_group_box)
        self.background_color_label.setObjectName('background_color_label')
        self.color_layout.addWidget(self.background_color_label)
        self.background_color_button = ColorButton(self.font_group_box)
        self.background_color_button.setObjectName('background_color_button')
        self.color_layout.addWidget(self.background_color_button)
        self.font_layout.addRow(self.font_color_label, self.color_layout)
        self.font_size_label = QtWidgets.QLabel(self.font_group_box)
        self.font_size_label.setObjectName('font_size_label')
        self.font_size_spin_box = QtWidgets.QSpinBox(self.font_group_box)
        self.font_size_spin_box.setObjectName('font_size_spin_box')
        self.font_layout.addRow(self.font_size_label, self.font_size_spin_box)
        self.timeout_label = QtWidgets.QLabel(self.font_group_box)
        self.timeout_label.setObjectName('timeout_label')
        self.timeout_spin_box = QtWidgets.QSpinBox(self.font_group_box)
        self.timeout_spin_box.setMaximum(180)
        self.timeout_spin_box.setObjectName('timeout_spin_box')
        self.font_layout.addRow(self.timeout_label, self.timeout_spin_box)
        self.vertical_label, self.vertical_combo_box = create_valign_selection_widgets(
            self.font_group_box)
        self.vertical_label.setObjectName('vertical_label')
        self.vertical_combo_box.setObjectName('vertical_combo_box')
        self.font_layout.addRow(self.vertical_label, self.vertical_combo_box)
        self.left_layout.addWidget(self.font_group_box)
        self.left_layout.addStretch()
        self.preview_group_box = QtWidgets.QGroupBox(self.right_column)
        self.preview_group_box.setObjectName('preview_group_box')
        self.preview_layout = QtWidgets.QVBoxLayout(self.preview_group_box)
        self.preview_layout.setObjectName('preview_layout')
        self.font_preview = QtWidgets.QLineEdit(self.preview_group_box)
        self.font_preview.setObjectName('font_preview')
        self.preview_layout.addWidget(self.font_preview)
        self.right_layout.addWidget(self.preview_group_box)
        self.right_layout.addStretch()
        # Signals and slots
        self.background_color_button.colorChanged.connect(
            self.on_background_color_changed)
        self.font_color_button.colorChanged.connect(self.on_font_color_changed)
        self.font_combo_box.activated.connect(self.on_font_combo_box_clicked)
        self.timeout_spin_box.valueChanged.connect(
            self.on_timeout_spin_box_changed)
        self.font_size_spin_box.valueChanged.connect(
            self.on_font_size_spin_box_changed)

    def retranslateUi(self):
        self.font_group_box.setTitle(
            translate('AlertsPlugin.AlertsTab', 'Font'))
        self.font_label.setText(
            translate('AlertsPlugin.AlertsTab', 'Font name:'))
        self.font_color_label.setText(
            translate('AlertsPlugin.AlertsTab', 'Font color:'))
        self.background_color_label.setText(UiStrings().BackgroundColorColon)
        self.font_size_label.setText(
            translate('AlertsPlugin.AlertsTab', 'Font size:'))
        self.font_size_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.timeout_label.setText(
            translate('AlertsPlugin.AlertsTab', 'Alert timeout:'))
        self.timeout_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().Seconds))
        self.preview_group_box.setTitle(UiStrings().Preview)
        self.font_preview.setText(UiStrings().OpenLP)

    def on_background_color_changed(self, color):
        """
        The background color has been changed.
        """
        self.background_color = color
        self.update_display()

    def on_font_combo_box_clicked(self):
        """
        The Font Combo was changed.
        """
        self.update_display()

    def on_font_color_changed(self, color):
        """
        The Font Color button has clicked.
        """
        self.font_color = color
        self.update_display()

    def on_timeout_spin_box_changed(self):
        """
        The Time out spin box has changed.

        """
        self.timeout = self.timeout_spin_box.value()
        self.changed = True

    def on_font_size_spin_box_changed(self):
        """
        The font size spin box has changed.
        """
        self.font_size = self.font_size_spin_box.value()
        self.update_display()

    def load(self):
        """
        Load the settings into the UI.
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.timeout = settings.value('timeout')
        self.font_color = settings.value('font color')
        self.font_size = settings.value('font size')
        self.background_color = settings.value('background color')
        self.font_face = settings.value('font face')
        self.location = settings.value('location')
        settings.endGroup()
        self.font_size_spin_box.setValue(self.font_size)
        self.timeout_spin_box.setValue(self.timeout)
        self.font_color_button.color = self.font_color
        self.background_color_button.color = self.background_color
        self.vertical_combo_box.setCurrentIndex(self.location)
        font = QtGui.QFont()
        font.setFamily(self.font_face)
        self.font_combo_box.setCurrentFont(font)
        self.update_display()
        self.changed = False

    def save(self):
        """
        Save the changes on exit of the Settings dialog.
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        # Check value has changed as no event handles this field
        if settings.value(
                'location') != self.vertical_combo_box.currentIndex():
            self.changed = True
        settings.setValue('background color', self.background_color)
        settings.setValue('font color', self.font_color)
        settings.setValue('font size', self.font_size)
        self.font_face = self.font_combo_box.currentFont().family()
        settings.setValue('font face', self.font_face)
        settings.setValue('timeout', self.timeout)
        self.location = self.vertical_combo_box.currentIndex()
        settings.setValue('location', self.location)
        settings.endGroup()
        if self.changed:
            self.settings_form.register_post_process('update_display_css')
        self.changed = False

    def update_display(self):
        """
        Update the preview display after changes have been made,
        """
        font = QtGui.QFont()
        font.setFamily(self.font_combo_box.currentFont().family())
        font.setBold(True)
        font.setPointSize(self.font_size)
        self.font_preview.setFont(font)
        self.font_preview.setStyleSheet(
            'background-color: {back}; color: {front}'.format(
                back=self.background_color, front=self.font_color))
        self.changed = True
Example #7
0
class Ui_ThemeWizard(object):
    """
    The Create/Edit theme wizard
    """
    def setupUi(self, theme_wizard):
        """
        Set up the UI
        """
        theme_wizard.setObjectName('OpenLP.ThemeWizard')
        theme_wizard.setWindowIcon(UiIcons().main_icon)
        theme_wizard.setModal(True)
        theme_wizard.setOptions(QtWidgets.QWizard.IndependentPages
                                | QtWidgets.QWizard.NoBackButtonOnStartPage
                                | QtWidgets.QWizard.HaveCustomButton1)
        theme_wizard.setFixedWidth(640)
        if is_macosx():
            theme_wizard.setPixmap(
                QtWidgets.QWizard.BackgroundPixmap,
                QtGui.QPixmap(':/wizards/openlp-osx-wizard.png'))
        else:
            theme_wizard.setWizardStyle(QtWidgets.QWizard.ModernStyle)
        self.spacer = QtWidgets.QSpacerItem(10, 0, QtWidgets.QSizePolicy.Fixed,
                                            QtWidgets.QSizePolicy.Minimum)
        # Welcome Page
        add_welcome_page(theme_wizard, ':/wizards/wizard_createtheme.bmp')
        # Background Page
        self.background_page = QtWidgets.QWizardPage()
        self.background_page.setObjectName('background_page')
        self.background_layout = QtWidgets.QVBoxLayout(self.background_page)
        self.background_layout.setObjectName('background_layout')
        self.background_type_layout = QtWidgets.QFormLayout()
        self.background_type_layout.setObjectName('background_type_layout')
        self.background_label = QtWidgets.QLabel(self.background_page)
        self.background_label.setObjectName('background_label')
        self.background_combo_box = QtWidgets.QComboBox(self.background_page)
        self.background_combo_box.addItems(['', '', '', '', ''])
        self.background_combo_box.setObjectName('background_combo_box')
        self.background_type_layout.addRow(self.background_label,
                                           self.background_combo_box)
        self.background_type_layout.setItem(1, QtWidgets.QFormLayout.LabelRole,
                                            self.spacer)
        self.background_layout.addLayout(self.background_type_layout)
        self.background_stack = QtWidgets.QStackedLayout()
        self.background_stack.setObjectName('background_stack')
        self.color_widget = QtWidgets.QWidget(self.background_page)
        self.color_widget.setObjectName('color_widget')
        self.color_layout = QtWidgets.QFormLayout(self.color_widget)
        self.color_layout.setContentsMargins(0, 0, 0, 0)
        self.color_layout.setObjectName('color_layout')
        self.color_label = QtWidgets.QLabel(self.color_widget)
        self.color_label.setObjectName('color_label')
        self.color_button = ColorButton(self.color_widget)
        self.color_button.setObjectName('color_button')
        self.color_layout.addRow(self.color_label, self.color_button)
        self.color_layout.setItem(1, QtWidgets.QFormLayout.LabelRole,
                                  self.spacer)
        self.background_stack.addWidget(self.color_widget)
        self.gradient_widget = QtWidgets.QWidget(self.background_page)
        self.gradient_widget.setObjectName('Gradient_widget')
        self.gradient_layout = QtWidgets.QFormLayout(self.gradient_widget)
        self.gradient_layout.setContentsMargins(0, 0, 0, 0)
        self.gradient_layout.setObjectName('gradient_layout')
        self.gradient_start_label = QtWidgets.QLabel(self.gradient_widget)
        self.gradient_start_label.setObjectName('gradient_start_label')
        self.gradient_start_button = ColorButton(self.gradient_widget)
        self.gradient_start_button.setObjectName('gradient_start_button')
        self.gradient_layout.addRow(self.gradient_start_label,
                                    self.gradient_start_button)
        self.gradient_end_label = QtWidgets.QLabel(self.gradient_widget)
        self.gradient_end_label.setObjectName('gradient_end_label')
        self.gradient_end_button = ColorButton(self.gradient_widget)
        self.gradient_end_button.setObjectName('gradient_end_button')
        self.gradient_layout.addRow(self.gradient_end_label,
                                    self.gradient_end_button)
        self.gradient_type_label = QtWidgets.QLabel(self.gradient_widget)
        self.gradient_type_label.setObjectName('Gradient_type_label')
        self.gradient_combo_box = QtWidgets.QComboBox(self.gradient_widget)
        self.gradient_combo_box.setObjectName('gradient_combo_box')
        self.gradient_combo_box.addItems(['', '', '', '', ''])
        self.gradient_layout.addRow(self.gradient_type_label,
                                    self.gradient_combo_box)
        self.gradient_layout.setItem(3, QtWidgets.QFormLayout.LabelRole,
                                     self.spacer)
        self.background_stack.addWidget(self.gradient_widget)
        self.image_widget = QtWidgets.QWidget(self.background_page)
        self.image_widget.setObjectName('image_widget')
        self.image_layout = QtWidgets.QFormLayout(self.image_widget)
        self.image_layout.setContentsMargins(0, 0, 0, 0)
        self.image_layout.setObjectName('image_layout')
        self.image_color_label = QtWidgets.QLabel(self.color_widget)
        self.image_color_label.setObjectName('image_color_label')
        self.image_color_button = ColorButton(self.color_widget)
        self.image_color_button.setObjectName('image_color_button')
        self.image_layout.addRow(self.image_color_label,
                                 self.image_color_button)
        self.image_label = QtWidgets.QLabel(self.image_widget)
        self.image_label.setObjectName('image_label')
        self.image_path_edit = PathEdit(self.image_widget,
                                        dialog_caption=translate(
                                            'OpenLP.ThemeWizard',
                                            'Select Image'),
                                        show_revert=False)
        self.image_layout.addRow(self.image_label, self.image_path_edit)
        self.image_layout.setItem(2, QtWidgets.QFormLayout.LabelRole,
                                  self.spacer)
        self.background_stack.addWidget(self.image_widget)
        self.transparent_widget = QtWidgets.QWidget(self.background_page)
        self.transparent_widget.setObjectName('TransparentWidget')
        self.transparent_layout = QtWidgets.QFormLayout(
            self.transparent_widget)
        self.transparent_layout.setContentsMargins(0, 0, 0, 0)
        self.transparent_layout.setObjectName('Transparent_layout')
        self.background_stack.addWidget(self.transparent_widget)
        self.background_layout.addLayout(self.background_stack)
        self.video_widget = QtWidgets.QWidget(self.background_page)
        self.video_widget.setObjectName('video_widget')
        self.video_layout = QtWidgets.QFormLayout(self.video_widget)
        self.video_layout.setContentsMargins(0, 0, 0, 0)
        self.video_layout.setObjectName('video_layout')
        self.video_color_label = QtWidgets.QLabel(self.color_widget)
        self.video_color_label.setObjectName('video_color_label')
        self.video_color_button = ColorButton(self.color_widget)
        self.video_color_button.setObjectName('video_color_button')
        self.video_layout.addRow(self.video_color_label,
                                 self.video_color_button)
        self.video_label = QtWidgets.QLabel(self.video_widget)
        self.video_label.setObjectName('video_label')
        self.video_path_edit = PathEdit(self.video_widget,
                                        dialog_caption=translate(
                                            'OpenLP.ThemeWizard',
                                            'Select Video'),
                                        show_revert=False)
        self.video_layout.addRow(self.video_label, self.video_path_edit)
        self.video_layout.setItem(2, QtWidgets.QFormLayout.LabelRole,
                                  self.spacer)
        self.background_stack.addWidget(self.video_widget)
        theme_wizard.addPage(self.background_page)
        # Main Area Page
        self.main_area_page = QtWidgets.QWizardPage()
        self.main_area_page.setObjectName('main_area_page')
        self.main_area_layout = QtWidgets.QFormLayout(self.main_area_page)
        self.main_area_layout.setObjectName('main_area_layout')
        self.main_font_label = QtWidgets.QLabel(self.main_area_page)
        self.main_font_label.setObjectName('main_font_label')
        self.main_font_combo_box = QtWidgets.QFontComboBox(self.main_area_page)
        self.main_font_combo_box.setObjectName('main_font_combo_box')
        self.main_area_layout.addRow(self.main_font_label,
                                     self.main_font_combo_box)
        self.main_color_label = QtWidgets.QLabel(self.main_area_page)
        self.main_color_label.setObjectName('main_color_label')
        self.main_properties_layout = QtWidgets.QHBoxLayout()
        self.main_properties_layout.setObjectName('main_properties_layout')
        self.main_color_button = ColorButton(self.main_area_page)
        self.main_color_button.setObjectName('main_color_button')
        self.main_properties_layout.addWidget(self.main_color_button)
        self.main_properties_layout.addSpacing(20)
        self.main_bold_check_box = QtWidgets.QCheckBox(self.main_area_page)
        self.main_bold_check_box.setObjectName('main_bold_check_box')
        self.main_properties_layout.addWidget(self.main_bold_check_box)
        self.main_properties_layout.addSpacing(20)
        self.main_italics_check_box = QtWidgets.QCheckBox(self.main_area_page)
        self.main_italics_check_box.setObjectName('MainItalicsCheckBox')
        self.main_properties_layout.addWidget(self.main_italics_check_box)
        self.main_area_layout.addRow(self.main_color_label,
                                     self.main_properties_layout)
        self.main_size_label = QtWidgets.QLabel(self.main_area_page)
        self.main_size_label.setObjectName('main_size_label')
        self.main_size_layout = QtWidgets.QHBoxLayout()
        self.main_size_layout.setObjectName('main_size_layout')
        self.main_size_spin_box = QtWidgets.QSpinBox(self.main_area_page)
        self.main_size_spin_box.setMaximum(999)
        self.main_size_spin_box.setValue(16)
        self.main_size_spin_box.setObjectName('main_size_spin_box')
        self.main_size_layout.addWidget(self.main_size_spin_box)
        self.main_line_count_label = QtWidgets.QLabel(self.main_area_page)
        self.main_line_count_label.setObjectName('main_line_count_label')
        self.main_size_layout.addWidget(self.main_line_count_label)
        self.main_area_layout.addRow(self.main_size_label,
                                     self.main_size_layout)
        self.line_spacing_label = QtWidgets.QLabel(self.main_area_page)
        self.line_spacing_label.setObjectName('line_spacing_label')
        self.line_spacing_spin_box = QtWidgets.QSpinBox(self.main_area_page)
        self.line_spacing_spin_box.setMinimum(-250)
        self.line_spacing_spin_box.setMaximum(250)
        self.line_spacing_spin_box.setObjectName('line_spacing_spin_box')
        self.main_area_layout.addRow(self.line_spacing_label,
                                     self.line_spacing_spin_box)
        self.outline_check_box = QtWidgets.QCheckBox(self.main_area_page)
        self.outline_check_box.setObjectName('outline_check_box')
        self.outline_layout = QtWidgets.QHBoxLayout()
        self.outline_layout.setObjectName('outline_layout')
        self.outline_color_button = ColorButton(self.main_area_page)
        self.outline_color_button.setEnabled(False)
        self.outline_color_button.setObjectName('Outline_color_button')
        self.outline_layout.addWidget(self.outline_color_button)
        self.outline_layout.addSpacing(20)
        self.outline_size_label = QtWidgets.QLabel(self.main_area_page)
        self.outline_size_label.setObjectName('outline_size_label')
        self.outline_layout.addWidget(self.outline_size_label)
        self.outline_size_spin_box = QtWidgets.QSpinBox(self.main_area_page)
        self.outline_size_spin_box.setEnabled(False)
        self.outline_size_spin_box.setObjectName('outline_size_spin_box')
        self.outline_layout.addWidget(self.outline_size_spin_box)
        self.main_area_layout.addRow(self.outline_check_box,
                                     self.outline_layout)
        self.shadow_check_box = QtWidgets.QCheckBox(self.main_area_page)
        self.shadow_check_box.setObjectName('shadow_check_box')
        self.shadow_layout = QtWidgets.QHBoxLayout()
        self.shadow_layout.setObjectName('shadow_layout')
        self.shadow_color_button = ColorButton(self.main_area_page)
        self.shadow_color_button.setEnabled(False)
        self.shadow_color_button.setObjectName('shadow_color_button')
        self.shadow_layout.addWidget(self.shadow_color_button)
        self.shadow_layout.addSpacing(20)
        self.shadow_size_label = QtWidgets.QLabel(self.main_area_page)
        self.shadow_size_label.setObjectName('shadow_size_label')
        self.shadow_layout.addWidget(self.shadow_size_label)
        self.shadow_size_spin_box = QtWidgets.QSpinBox(self.main_area_page)
        self.shadow_size_spin_box.setEnabled(False)
        self.shadow_size_spin_box.setObjectName('shadow_size_spin_box')
        self.shadow_layout.addWidget(self.shadow_size_spin_box)
        self.main_area_layout.addRow(self.shadow_check_box, self.shadow_layout)
        theme_wizard.addPage(self.main_area_page)
        # Footer Area Page
        self.footer_area_page = QtWidgets.QWizardPage()
        self.footer_area_page.setObjectName('footer_area_page')
        self.footer_area_layout = QtWidgets.QFormLayout(self.footer_area_page)
        self.footer_area_layout.setObjectName('footer_area_layout')
        self.footer_font_label = QtWidgets.QLabel(self.footer_area_page)
        self.footer_font_label.setObjectName('FooterFontLabel')
        self.footer_font_combo_box = QtWidgets.QFontComboBox(
            self.footer_area_page)
        self.footer_font_combo_box.setObjectName('footer_font_combo_box')
        self.footer_area_layout.addRow(self.footer_font_label,
                                       self.footer_font_combo_box)
        self.footer_color_label = QtWidgets.QLabel(self.footer_area_page)
        self.footer_color_label.setObjectName('footer_color_label')
        self.footer_color_button = ColorButton(self.footer_area_page)
        self.footer_color_button.setObjectName('footer_color_button')
        self.footer_area_layout.addRow(self.footer_color_label,
                                       self.footer_color_button)
        self.footer_size_label = QtWidgets.QLabel(self.footer_area_page)
        self.footer_size_label.setObjectName('footer_size_label')
        self.footer_size_spin_box = QtWidgets.QSpinBox(self.footer_area_page)
        self.footer_size_spin_box.setMaximum(999)
        self.footer_size_spin_box.setValue(10)
        self.footer_size_spin_box.setObjectName('FooterSizeSpinBox')
        self.footer_area_layout.addRow(self.footer_size_label,
                                       self.footer_size_spin_box)
        self.footer_area_layout.setItem(3, QtWidgets.QFormLayout.LabelRole,
                                        self.spacer)
        theme_wizard.addPage(self.footer_area_page)
        # Alignment Page
        self.alignment_page = QtWidgets.QWizardPage()
        self.alignment_page.setObjectName('alignment_page')
        self.alignment_layout = QtWidgets.QFormLayout(self.alignment_page)
        self.alignment_layout.setObjectName('alignment_layout')
        self.horizontal_label = QtWidgets.QLabel(self.alignment_page)
        self.horizontal_label.setObjectName('horizontal_label')
        self.horizontal_combo_box = QtWidgets.QComboBox(self.alignment_page)
        self.horizontal_combo_box.addItems(['', '', '', ''])
        self.horizontal_combo_box.setObjectName('horizontal_combo_box')
        self.alignment_layout.addRow(self.horizontal_label,
                                     self.horizontal_combo_box)
        self.vertical_label, self.vertical_combo_box = create_valign_selection_widgets(
            self.alignment_page)
        self.vertical_label.setObjectName('vertical_label')
        self.vertical_combo_box.setObjectName('vertical_combo_box')
        self.alignment_layout.addRow(self.vertical_label,
                                     self.vertical_combo_box)
        self.transitions_label = QtWidgets.QLabel(self.alignment_page)
        self.transitions_label.setObjectName('transitions_label')
        self.transitions_check_box = QtWidgets.QCheckBox(self.alignment_page)
        self.transitions_check_box.setObjectName('transitions_check_box')
        self.alignment_layout.addRow(self.transitions_label,
                                     self.transitions_check_box)
        self.alignment_layout.setItem(3, QtWidgets.QFormLayout.LabelRole,
                                      self.spacer)
        theme_wizard.addPage(self.alignment_page)
        # Area Position Page
        self.area_position_page = QtWidgets.QWizardPage()
        self.area_position_page.setObjectName('area_position_page')
        self.area_position_layout = QtWidgets.QHBoxLayout(
            self.area_position_page)
        self.area_position_layout.setObjectName('area_position_layout')
        self.main_position_group_box = QtWidgets.QGroupBox(
            self.area_position_page)
        self.main_position_group_box.setObjectName('main_position_group_box')
        self.main_position_layout = QtWidgets.QFormLayout(
            self.main_position_group_box)
        self.main_position_layout.setObjectName('main_position_layout')
        self.main_position_check_box = QtWidgets.QCheckBox(
            self.main_position_group_box)
        self.main_position_check_box.setObjectName('main_position_check_box')
        self.main_position_layout.addRow(self.main_position_check_box)
        self.main_x_label = QtWidgets.QLabel(self.main_position_group_box)
        self.main_x_label.setObjectName('main_x_label')
        self.main_x_spin_box = QtWidgets.QSpinBox(self.main_position_group_box)
        self.main_x_spin_box.setMaximum(9999)
        self.main_x_spin_box.setObjectName('main_x_spin_box')
        self.main_position_layout.addRow(self.main_x_label,
                                         self.main_x_spin_box)
        self.main_y_label = QtWidgets.QLabel(self.main_position_group_box)
        self.main_y_label.setObjectName('main_y_label')
        self.main_y_spin_box = QtWidgets.QSpinBox(self.main_position_group_box)
        self.main_y_spin_box.setMaximum(9999)
        self.main_y_spin_box.setObjectName('main_y_spin_box')
        self.main_position_layout.addRow(self.main_y_label,
                                         self.main_y_spin_box)
        self.main_width_label = QtWidgets.QLabel(self.main_position_group_box)
        self.main_width_label.setObjectName('main_width_label')
        self.main_width_spin_box = QtWidgets.QSpinBox(
            self.main_position_group_box)
        self.main_width_spin_box.setMaximum(9999)
        self.main_width_spin_box.setObjectName('main_width_spin_box')
        self.main_position_layout.addRow(self.main_width_label,
                                         self.main_width_spin_box)
        self.main_height_label = QtWidgets.QLabel(self.main_position_group_box)
        self.main_height_label.setObjectName('main_height_label')
        self.main_height_spin_box = QtWidgets.QSpinBox(
            self.main_position_group_box)
        self.main_height_spin_box.setMaximum(9999)
        self.main_height_spin_box.setObjectName('main_height_spin_box')
        self.main_position_layout.addRow(self.main_height_label,
                                         self.main_height_spin_box)
        self.area_position_layout.addWidget(self.main_position_group_box)
        self.footer_position_group_box = QtWidgets.QGroupBox(
            self.area_position_page)
        self.footer_position_group_box.setObjectName(
            'footer_position_group_box')
        self.footer_position_layout = QtWidgets.QFormLayout(
            self.footer_position_group_box)
        self.footer_position_layout.setObjectName('footer_position_layout')
        self.footer_position_check_box = QtWidgets.QCheckBox(
            self.footer_position_group_box)
        self.footer_position_check_box.setObjectName(
            'footer_position_check_box')
        self.footer_position_layout.addRow(self.footer_position_check_box)
        self.footer_x_label = QtWidgets.QLabel(self.footer_position_group_box)
        self.footer_x_label.setObjectName('footer_x_label')
        self.footer_x_spin_box = QtWidgets.QSpinBox(
            self.footer_position_group_box)
        self.footer_x_spin_box.setMaximum(9999)
        self.footer_x_spin_box.setObjectName('footer_x_spin_box')
        self.footer_position_layout.addRow(self.footer_x_label,
                                           self.footer_x_spin_box)
        self.footer_y_label = QtWidgets.QLabel(self.footer_position_group_box)
        self.footer_y_label.setObjectName('footer_y_label')
        self.footer_y_spin_box = QtWidgets.QSpinBox(
            self.footer_position_group_box)
        self.footer_y_spin_box.setMaximum(9999)
        self.footer_y_spin_box.setObjectName('footer_y_spin_box')
        self.footer_position_layout.addRow(self.footer_y_label,
                                           self.footer_y_spin_box)
        self.footer_width_label = QtWidgets.QLabel(
            self.footer_position_group_box)
        self.footer_width_label.setObjectName('footer_width_label')
        self.footer_width_spin_box = QtWidgets.QSpinBox(
            self.footer_position_group_box)
        self.footer_width_spin_box.setMaximum(9999)
        self.footer_width_spin_box.setObjectName('footer_width_spin_box')
        self.footer_position_layout.addRow(self.footer_width_label,
                                           self.footer_width_spin_box)
        self.footer_height_label = QtWidgets.QLabel(
            self.footer_position_group_box)
        self.footer_height_label.setObjectName('footer_height_label')
        self.footer_height_spin_box = QtWidgets.QSpinBox(
            self.footer_position_group_box)
        self.footer_height_spin_box.setMaximum(9999)
        self.footer_height_spin_box.setObjectName('footer_height_spin_box')
        self.footer_position_layout.addRow(self.footer_height_label,
                                           self.footer_height_spin_box)
        self.area_position_layout.addWidget(self.footer_position_group_box)
        theme_wizard.addPage(self.area_position_page)
        # Preview Page
        self.preview_page = QtWidgets.QWizardPage()
        self.preview_page.setObjectName('preview_page')
        self.preview_layout = QtWidgets.QVBoxLayout(self.preview_page)
        self.preview_layout.setObjectName('preview_layout')
        self.theme_name_layout = QtWidgets.QFormLayout()
        self.theme_name_layout.setObjectName('theme_name_layout')
        self.theme_name_label = QtWidgets.QLabel(self.preview_page)
        self.theme_name_label.setObjectName('theme_name_label')
        self.theme_name_edit = QtWidgets.QLineEdit(self.preview_page)
        self.theme_name_edit.setValidator(
            QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":<>+%]+'),
                                   self))
        self.theme_name_edit.setObjectName('ThemeNameEdit')
        self.theme_name_layout.addRow(self.theme_name_label,
                                      self.theme_name_edit)
        self.preview_layout.addLayout(self.theme_name_layout)
        self.preview_area = QtWidgets.QWidget(self.preview_page)
        self.preview_area.setObjectName('PreviewArea')
        self.preview_area_layout = QtWidgets.QGridLayout(self.preview_area)
        self.preview_area_layout.setContentsMargins(0, 0, 0, 0)
        self.preview_area_layout.setColumnStretch(0, 1)
        self.preview_area_layout.setRowStretch(0, 1)
        self.preview_area_layout.setObjectName('preview_area_layout')
        self.preview_box_label = QtWidgets.QLabel(self.preview_area)
        self.preview_box_label.setFrameShape(QtWidgets.QFrame.Box)
        self.preview_box_label.setScaledContents(True)
        self.preview_box_label.setObjectName('preview_box_label')
        self.preview_area_layout.addWidget(self.preview_box_label)
        self.preview_layout.addWidget(self.preview_area)
        theme_wizard.addPage(self.preview_page)
        self.retranslateUi(theme_wizard)
        self.background_combo_box.currentIndexChanged.connect(
            self.background_stack.setCurrentIndex)
        self.outline_check_box.toggled.connect(
            self.outline_color_button.setEnabled)
        self.outline_check_box.toggled.connect(
            self.outline_size_spin_box.setEnabled)
        self.shadow_check_box.toggled.connect(
            self.shadow_color_button.setEnabled)
        self.shadow_check_box.toggled.connect(
            self.shadow_size_spin_box.setEnabled)
        self.main_position_check_box.toggled.connect(
            self.main_x_spin_box.setDisabled)
        self.main_position_check_box.toggled.connect(
            self.main_y_spin_box.setDisabled)
        self.main_position_check_box.toggled.connect(
            self.main_width_spin_box.setDisabled)
        self.main_position_check_box.toggled.connect(
            self.main_height_spin_box.setDisabled)
        self.footer_position_check_box.toggled.connect(
            self.footer_x_spin_box.setDisabled)
        self.footer_position_check_box.toggled.connect(
            self.footer_y_spin_box.setDisabled)
        self.footer_position_check_box.toggled.connect(
            self.footer_width_spin_box.setDisabled)
        self.footer_position_check_box.toggled.connect(
            self.footer_height_spin_box.setDisabled)

    def retranslateUi(self, theme_wizard):
        """
        Translate the UI on the fly
        """
        theme_wizard.setWindowTitle(
            translate('OpenLP.ThemeWizard', 'Theme Wizard'))
        text = translate('OpenLP.ThemeWizard', 'Welcome to the Theme Wizard')
        self.title_label.setText(
            '<span style="font-size:14pt; font-weight:600;">{text}</span>'.
            format(text=text))
        self.information_label.setText(
            translate(
                'OpenLP.ThemeWizard',
                'This wizard will help you to create and edit your themes. Click the next '
                'button below to start the process by setting up your background.'
            ))
        self.background_page.setTitle(
            translate('OpenLP.ThemeWizard', 'Set Up Background'))
        self.background_page.setSubTitle(
            translate(
                'OpenLP.ThemeWizard', 'Set up your theme\'s background '
                'according to the parameters below.'))
        self.background_label.setText(
            translate('OpenLP.ThemeWizard', 'Background type:'))
        self.background_combo_box.setItemText(
            BackgroundType.Solid, translate('OpenLP.ThemeWizard',
                                            'Solid color'))
        self.background_combo_box.setItemText(
            BackgroundType.Gradient, translate('OpenLP.ThemeWizard',
                                               'Gradient'))
        self.background_combo_box.setItemText(BackgroundType.Image,
                                              UiStrings().Image)
        self.background_combo_box.setItemText(BackgroundType.Video,
                                              UiStrings().Video)
        self.background_combo_box.setItemText(
            BackgroundType.Transparent,
            translate('OpenLP.ThemeWizard', 'Transparent'))
        self.color_label.setText(translate('OpenLP.ThemeWizard', 'color:'))
        self.gradient_start_label.setText(
            translate('OpenLP.ThemeWizard', 'Starting color:'))
        self.gradient_end_label.setText(
            translate('OpenLP.ThemeWizard', 'Ending color:'))
        self.gradient_type_label.setText(
            translate('OpenLP.ThemeWizard', 'Gradient:'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.Horizontal,
            translate('OpenLP.ThemeWizard', 'Horizontal'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.Vertical,
            translate('OpenLP.ThemeWizard', 'Vertical'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.Circular,
            translate('OpenLP.ThemeWizard', 'Circular'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.LeftTop,
            translate('OpenLP.ThemeWizard', 'Top Left - Bottom Right'))
        self.gradient_combo_box.setItemText(
            BackgroundGradientType.LeftBottom,
            translate('OpenLP.ThemeWizard', 'Bottom Left - Top Right'))
        self.image_color_label.setText(
            translate('OpenLP.ThemeWizard', 'Background color:'))
        self.image_label.setText('{text}:'.format(text=UiStrings().Image))
        self.video_color_label.setText(
            translate('OpenLP.ThemeWizard', 'Background color:'))
        self.video_label.setText('{text}:'.format(text=UiStrings().Video))
        self.main_area_page.setTitle(
            translate('OpenLP.ThemeWizard', 'Main Area Font Details'))
        self.main_area_page.setSubTitle(
            translate(
                'OpenLP.ThemeWizard', 'Define the font and display '
                'characteristics for the Display text'))
        self.main_font_label.setText(translate('OpenLP.ThemeWizard', 'Font:'))
        self.main_color_label.setText(translate('OpenLP.ThemeWizard',
                                                'color:'))
        self.main_size_label.setText(translate('OpenLP.ThemeWizard', 'Size:'))
        self.main_size_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.line_spacing_label.setText(
            translate('OpenLP.ThemeWizard', 'Line Spacing:'))
        self.line_spacing_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.outline_check_box.setText(
            translate('OpenLP.ThemeWizard', '&Outline:'))
        self.outline_size_label.setText(
            translate('OpenLP.ThemeWizard', 'Size:'))
        self.outline_size_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.shadow_check_box.setText(
            translate('OpenLP.ThemeWizard', '&Shadow:'))
        self.shadow_size_label.setText(translate('OpenLP.ThemeWizard',
                                                 'Size:'))
        self.shadow_size_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.main_bold_check_box.setText(
            translate('OpenLP.ThemeWizard', 'Bold'))
        self.main_italics_check_box.setText(
            translate('OpenLP.ThemeWizard', 'Italic'))
        self.footer_area_page.setTitle(
            translate('OpenLP.ThemeWizard', 'Footer Area Font Details'))
        self.footer_area_page.setSubTitle(
            translate(
                'OpenLP.ThemeWizard', 'Define the font and display '
                'characteristics for the Footer text'))
        self.footer_font_label.setText(translate('OpenLP.ThemeWizard',
                                                 'Font:'))
        self.footer_color_label.setText(
            translate('OpenLP.ThemeWizard', 'color:'))
        self.footer_size_label.setText(translate('OpenLP.ThemeWizard',
                                                 'Size:'))
        self.footer_size_spin_box.setSuffix(
            ' {unit}'.format(unit=UiStrings().FontSizePtUnit))
        self.alignment_page.setTitle(
            translate('OpenLP.ThemeWizard', 'Text Formatting Details'))
        self.alignment_page.setSubTitle(
            translate(
                'OpenLP.ThemeWizard', 'Allows additional display '
                'formatting information to be defined'))
        self.horizontal_label.setText(
            translate('OpenLP.ThemeWizard', 'Horizontal Align:'))
        self.horizontal_combo_box.setItemText(
            HorizontalType.Left, translate('OpenLP.ThemeWizard', 'Left'))
        self.horizontal_combo_box.setItemText(
            HorizontalType.Right, translate('OpenLP.ThemeWizard', 'Right'))
        self.horizontal_combo_box.setItemText(
            HorizontalType.Center, translate('OpenLP.ThemeWizard', 'Center'))
        self.horizontal_combo_box.setItemText(
            HorizontalType.Justify, translate('OpenLP.ThemeWizard', 'Justify'))
        self.transitions_label.setText(
            translate('OpenLP.ThemeWizard', 'Transitions:'))
        self.area_position_page.setTitle(
            translate('OpenLP.ThemeWizard', 'Output Area Locations'))
        self.area_position_page.setSubTitle(
            translate(
                'OpenLP.ThemeWizard', 'Allows you to change and move the'
                ' Main and Footer areas.'))
        self.main_position_group_box.setTitle(
            translate('OpenLP.ThemeWizard', '&Main Area'))
        self.main_position_check_box.setText(
            translate('OpenLP.ThemeWizard', '&Use default location'))
        self.main_x_label.setText(
            translate('OpenLP.ThemeWizard', 'X position:'))
        self.main_x_spin_box.setSuffix(translate('OpenLP.ThemeWizard', 'px'))
        self.main_y_spin_box.setSuffix(translate('OpenLP.ThemeWizard', 'px'))
        self.main_y_label.setText(
            translate('OpenLP.ThemeWizard', 'Y position:'))
        self.main_width_spin_box.setSuffix(
            translate('OpenLP.ThemeWizard', 'px'))
        self.main_width_label.setText(translate('OpenLP.ThemeWizard',
                                                'Width:'))
        self.main_height_spin_box.setSuffix(
            translate('OpenLP.ThemeWizard', 'px'))
        self.main_height_label.setText(
            translate('OpenLP.ThemeWizard', 'Height:'))
        self.footer_position_group_box.setTitle(
            translate('OpenLP.ThemeWizard', '&Footer Area'))
        self.footer_x_label.setText(
            translate('OpenLP.ThemeWizard', 'X position:'))
        self.footer_x_spin_box.setSuffix(translate('OpenLP.ThemeWizard', 'px'))
        self.footer_y_label.setText(
            translate('OpenLP.ThemeWizard', 'Y position:'))
        self.footer_y_spin_box.setSuffix(translate('OpenLP.ThemeWizard', 'px'))
        self.footer_width_label.setText(
            translate('OpenLP.ThemeWizard', 'Width:'))
        self.footer_width_spin_box.setSuffix(
            translate('OpenLP.ThemeWizard', 'px'))
        self.footer_height_label.setText(
            translate('OpenLP.ThemeWizard', 'Height:'))
        self.footer_height_spin_box.setSuffix(
            translate('OpenLP.ThemeWizard', 'px'))
        self.footer_position_check_box.setText(
            translate('OpenLP.ThemeWizard', 'Use default location'))
        theme_wizard.setOption(QtWidgets.QWizard.HaveCustomButton1, False)
        theme_wizard.setButtonText(
            QtWidgets.QWizard.CustomButton1,
            translate('OpenLP.ThemeWizard', 'Layout Preview'))
        self.preview_page.setTitle(
            translate('OpenLP.ThemeWizard', 'Preview and Save'))
        self.preview_page.setSubTitle(
            translate('OpenLP.ThemeWizard', 'Preview the theme and save it.'))
        self.theme_name_label.setText(
            translate('OpenLP.ThemeWizard', 'Theme name:'))
        # Align all QFormLayouts towards each other.
        label_width = max(self.background_label.minimumSizeHint().width(),
                          self.horizontal_label.minimumSizeHint().width())
        self.spacer.changeSize(label_width, 0, QtWidgets.QSizePolicy.Fixed,
                               QtWidgets.QSizePolicy.Fixed)
Example #8
0
class GeneralTab(SettingsTab):
    """
    GeneralTab is the general settings tab in the settings dialog.
    """
    def __init__(self, parent):
        """
        Initialise the general settings tab
        """
        self.logo_background_color = '#ffffff'
        self.screens = ScreenList()
        self.icon_path = ':/icon/openlp-logo.svg'
        general_translated = translate('OpenLP.GeneralTab', 'General')
        super(GeneralTab, self).__init__(parent, 'Core', general_translated)

    def setup_ui(self):
        """
        Create the user interface for the general settings tab
        """
        self.setObjectName('GeneralTab')
        super(GeneralTab, self).setup_ui()
        self.tab_layout.setStretch(1, 1)
        # CCLI Details
        self.ccli_group_box = QtWidgets.QGroupBox(self.left_column)
        self.ccli_group_box.setObjectName('ccli_group_box')
        self.ccli_layout = QtWidgets.QFormLayout(self.ccli_group_box)
        self.ccli_layout.setObjectName('ccli_layout')
        self.number_label = QtWidgets.QLabel(self.ccli_group_box)
        self.number_label.setObjectName('number_label')
        self.number_edit = QtWidgets.QLineEdit(self.ccli_group_box)
        self.number_edit.setValidator(QtGui.QIntValidator())
        self.number_edit.setObjectName('number_edit')
        self.ccli_layout.addRow(self.number_label, self.number_edit)
        self.username_label = QtWidgets.QLabel(self.ccli_group_box)
        self.username_label.setObjectName('username_label')
        self.username_edit = QtWidgets.QLineEdit(self.ccli_group_box)
        self.username_edit.setObjectName('username_edit')
        self.ccli_layout.addRow(self.username_label, self.username_edit)
        self.password_label = QtWidgets.QLabel(self.ccli_group_box)
        self.password_label.setObjectName('password_label')
        self.password_edit = QtWidgets.QLineEdit(self.ccli_group_box)
        self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password)
        self.password_edit.setObjectName('password_edit')
        self.ccli_layout.addRow(self.password_label, self.password_edit)
        self.left_layout.addWidget(self.ccli_group_box)
        self.left_layout.addStretch()
        # Application Startup
        self.startup_group_box = QtWidgets.QGroupBox(self.right_column)
        self.startup_group_box.setObjectName('startup_group_box')
        self.startup_layout = QtWidgets.QVBoxLayout(self.startup_group_box)
        self.startup_layout.setObjectName('startup_layout')
        self.warning_check_box = QtWidgets.QCheckBox(self.startup_group_box)
        self.warning_check_box.setObjectName('warning_check_box')
        self.startup_layout.addWidget(self.warning_check_box)
        self.auto_open_check_box = QtWidgets.QCheckBox(self.startup_group_box)
        self.auto_open_check_box.setObjectName('auto_open_check_box')
        self.startup_layout.addWidget(self.auto_open_check_box)
        self.show_splash_check_box = QtWidgets.QCheckBox(
            self.startup_group_box)
        self.show_splash_check_box.setObjectName('show_splash_check_box')
        self.startup_layout.addWidget(self.show_splash_check_box)
        self.check_for_updates_check_box = QtWidgets.QCheckBox(
            self.startup_group_box)
        self.check_for_updates_check_box.setObjectName(
            'check_for_updates_check_box')
        self.startup_layout.addWidget(self.check_for_updates_check_box)
        self.right_layout.addWidget(self.startup_group_box)
        # Logo
        self.logo_group_box = QtWidgets.QGroupBox(self.right_column)
        self.logo_group_box.setObjectName('logo_group_box')
        self.logo_layout = QtWidgets.QFormLayout(self.logo_group_box)
        self.logo_layout.setObjectName('logo_layout')
        self.logo_file_label = QtWidgets.QLabel(self.logo_group_box)
        self.logo_file_label.setObjectName('logo_file_label')
        self.logo_file_path_edit = PathEdit(
            self.logo_group_box,
            default_path=Path(':/graphics/openlp-splash-screen.png'))
        self.logo_layout.addRow(self.logo_file_label, self.logo_file_path_edit)
        self.logo_color_label = QtWidgets.QLabel(self.logo_group_box)
        self.logo_color_label.setObjectName('logo_color_label')
        self.logo_color_button = ColorButton(self.logo_group_box)
        self.logo_color_button.setObjectName('logo_color_button')
        self.logo_layout.addRow(self.logo_color_label, self.logo_color_button)
        self.logo_hide_on_startup_check_box = QtWidgets.QCheckBox(
            self.logo_group_box)
        self.logo_hide_on_startup_check_box.setObjectName(
            'logo_hide_on_startup_check_box')
        self.logo_layout.addRow(self.logo_hide_on_startup_check_box)
        self.right_layout.addWidget(self.logo_group_box)
        self.logo_color_button.colorChanged.connect(
            self.on_logo_background_color_changed)
        # Application Settings
        self.settings_group_box = QtWidgets.QGroupBox(self.right_column)
        self.settings_group_box.setObjectName('settings_group_box')
        self.settings_layout = QtWidgets.QFormLayout(self.settings_group_box)
        self.settings_layout.setObjectName('settings_layout')
        self.save_check_service_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.save_check_service_check_box.setObjectName(
            'save_check_service_check_box')
        self.settings_layout.addRow(self.save_check_service_check_box)
        self.auto_unblank_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.auto_unblank_check_box.setObjectName('auto_unblank_check_box')
        self.settings_layout.addRow(self.auto_unblank_check_box)
        self.click_live_slide_to_unblank_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.click_live_slide_to_unblank_check_box.setObjectName(
            'click_live_slide_to_unblank')
        self.settings_layout.addRow(self.click_live_slide_to_unblank_check_box)
        self.auto_preview_check_box = QtWidgets.QCheckBox(
            self.settings_group_box)
        self.auto_preview_check_box.setObjectName('auto_preview_check_box')
        self.settings_layout.addRow(self.auto_preview_check_box)
        # Moved here from image tab
        self.timeout_label = QtWidgets.QLabel(self.settings_group_box)
        self.timeout_label.setObjectName('timeout_label')
        self.timeout_spin_box = QtWidgets.QSpinBox(self.settings_group_box)
        self.timeout_spin_box.setObjectName('timeout_spin_box')
        self.timeout_spin_box.setRange(1, 180)
        self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box)
        self.right_layout.addWidget(self.settings_group_box)
        self.right_layout.addStretch()
        # Remove for now
        self.username_label.setVisible(False)
        self.username_edit.setVisible(False)
        self.password_label.setVisible(False)
        self.password_edit.setVisible(False)

    def retranslate_ui(self):
        """
        Translate the general settings tab to the currently selected language
        """
        self.tab_title_visible = translate('OpenLP.GeneralTab', 'General')
        self.startup_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'Application Startup'))
        self.warning_check_box.setText(
            translate('OpenLP.GeneralTab', 'Show blank screen warning'))
        self.auto_open_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Automatically open the previous service file'))
        self.show_splash_check_box.setText(
            translate('OpenLP.GeneralTab', 'Show the splash screen'))
        self.logo_group_box.setTitle(translate('OpenLP.GeneralTab', 'Logo'))
        self.logo_color_label.setText(UiStrings().BackgroundColorColon)
        self.logo_file_label.setText(
            translate('OpenLP.GeneralTab', 'Logo file:'))
        self.logo_hide_on_startup_check_box.setText(
            translate('OpenLP.GeneralTab', 'Don\'t show logo on startup'))
        self.check_for_updates_check_box.setText(
            translate('OpenLP.GeneralTab', 'Check for updates to OpenLP'))
        self.settings_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'Application Settings'))
        self.save_check_service_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Prompt to save before starting a new service'))
        self.click_live_slide_to_unblank_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Unblank display when changing slide in Live'))
        self.auto_unblank_check_box.setText(
            translate('OpenLP.GeneralTab', 'Unblank display when sending '
                      'items to Live'))
        self.auto_preview_check_box.setText(
            translate('OpenLP.GeneralTab',
                      'Automatically preview the next item in service'))
        self.timeout_label.setText(
            translate('OpenLP.GeneralTab', 'Timed slide interval:'))
        self.timeout_spin_box.setSuffix(translate('OpenLP.GeneralTab', ' sec'))
        self.ccli_group_box.setTitle(
            translate('OpenLP.GeneralTab', 'CCLI Details'))
        self.number_label.setText(UiStrings().CCLINumberLabel)
        self.username_label.setText(
            translate('OpenLP.GeneralTab', 'SongSelect username:'******'OpenLP.GeneralTab', 'SongSelect password:'******'OpenLP.AdvancedTab', 'Select Logo File')
        self.logo_file_path_edit.dialog_caption = translate(
            'OpenLP.AdvancedTab', 'Select Logo File')
        self.logo_file_path_edit.filters = '{text};;{names} (*)'.format(
            text=get_images_filter(), names=UiStrings().AllFiles)

    def load(self):
        """
        Load the settings to populate the form
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        self.number_edit.setText(settings.value('ccli number'))
        self.username_edit.setText(settings.value('songselect username'))
        self.password_edit.setText(settings.value('songselect password'))
        self.save_check_service_check_box.setChecked(
            settings.value('save prompt'))
        self.auto_unblank_check_box.setChecked(settings.value('auto unblank'))
        self.click_live_slide_to_unblank_check_box.setChecked(
            settings.value('click live slide to unblank'))
        self.warning_check_box.setChecked(settings.value('blank warning'))
        self.auto_open_check_box.setChecked(settings.value('auto open'))
        self.show_splash_check_box.setChecked(settings.value('show splash'))
        self.logo_background_color = settings.value('logo background color')
        self.logo_file_path_edit.path = settings.value('logo file')
        self.logo_hide_on_startup_check_box.setChecked(
            settings.value('logo hide on startup'))
        self.logo_color_button.color = self.logo_background_color
        self.check_for_updates_check_box.setChecked(
            settings.value('update check'))
        self.auto_preview_check_box.setChecked(settings.value('auto preview'))
        self.timeout_spin_box.setValue(settings.value('loop delay'))
        settings.endGroup()

    def save(self):
        """
        Save the settings from the form
        """
        settings = Settings()
        settings.beginGroup(self.settings_section)
        settings.setValue('blank warning', self.warning_check_box.isChecked())
        settings.setValue('auto open', self.auto_open_check_box.isChecked())
        settings.setValue('show splash',
                          self.show_splash_check_box.isChecked())
        settings.setValue('logo background color', self.logo_background_color)
        settings.setValue('logo file', self.logo_file_path_edit.path)
        settings.setValue('logo hide on startup',
                          self.logo_hide_on_startup_check_box.isChecked())
        settings.setValue('update check',
                          self.check_for_updates_check_box.isChecked())
        settings.setValue('save prompt',
                          self.save_check_service_check_box.isChecked())
        settings.setValue('auto unblank',
                          self.auto_unblank_check_box.isChecked())
        settings.setValue(
            'click live slide to unblank',
            self.click_live_slide_to_unblank_check_box.isChecked())
        settings.setValue('auto preview',
                          self.auto_preview_check_box.isChecked())
        settings.setValue('loop delay', self.timeout_spin_box.value())
        settings.setValue('ccli number', self.number_edit.displayText())
        settings.setValue('songselect username',
                          self.username_edit.displayText())
        settings.setValue('songselect password',
                          self.password_edit.displayText())
        settings.endGroup()
        self.post_set_up()

    def post_set_up(self):
        """
        Apply settings after the tab has loaded
        """
        self.settings_form.register_post_process(
            'slidecontroller_live_spin_delay')

    def on_logo_background_color_changed(self, color):
        """
        Select the background color for logo.
        """
        self.logo_background_color = color