def test_set_transition_type_str(self): """ Test the transition_type setter with a str """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.transition_type = TransitionType.to_string(TransitionType.Convex) # THEN: The combobox should be correct assert page.transition_effect_combo_box.currentIndex() == 2
def test_on_transition_reverse_setter(self): """ Test the is_transition_reverse_enabled setter """ # GIVEN: And instance of AlignmentTransitionsPage and transition_reverse checked page = AlignmentTransitionsPage() # WHEN: The property is set page.is_transition_reverse_enabled = True # THEN: The checkbox should be correct assert page.transition_reverse_check_box.isChecked() is True
def test_set_transition_direction_int(self): """ Test the transition_direction setter with an int """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.transition_direction = TransitionDirection.Horizontal # THEN: The combobox should be correct assert page.transition_direction_combo_box.currentIndex() == 0
def test_set_horizontal_align_int(self): """ Test the horizontal_align setter with an int """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.horizontal_align = HorizontalType.Center # THEN: The combobox should be correct assert page.horizontal_combo_box.currentIndex() == 2
def test_set_vertical_align_str(self): """ Test the vertical_align setter with a str """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.vertical_align = VerticalType.to_string(VerticalType.Top) # THEN: The combobox should be correct assert page.vertical_combo_box.currentIndex() == 0
def test_set_vertical_align_int(self): """ Test the vertical_align setter with an int """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.vertical_align = VerticalType.Bottom # THEN: The combobox should be correct assert page.vertical_combo_box.currentIndex() == 2
def test_set_transition_speed_str(self): """ Test the transition_speed setter with a str """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.transition_speed = TransitionSpeed.to_string(TransitionSpeed.Slow) # THEN: The combobox should be correct assert page.transition_speed_combo_box.currentIndex() == 2
def test_set_transition_speed_exception(self): """ Test the transition_speed setter with something other than a str or int """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set # THEN: An exception is raised with pytest.raises( TypeError, match='transition_speed must either be a string or an int'): page.transition_speed = []
def test_set_horizontal_align_str(self): """ Test the horizontal_align setter with a str """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.horizontal_align = HorizontalType.to_string( HorizontalType.Justify) # THEN: The combobox should be correct assert page.horizontal_combo_box.currentIndex() == 3
def test_set_transition_direction_str(self): """ Test the transition_direction setter with a str """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() # WHEN: The property is set page.transition_direction = TransitionDirection.to_string( TransitionDirection.Vertical) # THEN: The combobox should be correct assert page.transition_direction_combo_box.currentIndex() == 1
def test_set_is_transition_enabled(self): """ Test the is_transition_enabled setter """ # GIVEN: A AlignmentTransitionsPage instance page = AlignmentTransitionsPage() page._on_transition_enabled_changed = MagicMock() # WHEN: The property is set page.is_transition_enabled = True # THEN: The result should be correct assert page.transitions_enabled_check_box.isChecked() is True page._on_transition_enabled_changed.assert_called_once_with(True)
def test_on_transition_enabled_changed(self): """ Test the _on_transition_enabled_changed() slot """ # GIVEN: And instance of AlignmentTransitionsPage and some mock widgets page = AlignmentTransitionsPage() # WHEN: _on_transition_enabled_changed page._on_transition_enabled_changed(True) # THEN: The correct widgets should be visible assert page.transition_effect_label.isEnabled() assert page.transition_effect_combo_box.isEnabled() assert page.transition_speed_label.isEnabled() assert page.transition_speed_combo_box.isEnabled() assert page.transition_direction_combo_box.isEnabled() assert page.transition_reverse_check_box.isEnabled()
def test_init_(self): """ Test the initialisation of AlignmentTransitionsPage """ # GIVEN: The AlignmentTransitionsPage class # WHEN: Initialising AlignmentTransitionsPage # THEN: We should have an instance of the widget with no errors AlignmentTransitionsPage()
def test_get_is_transition_enabled(self): """ Test the is_transition_enabled getter """ # GIVEN: A AlignmentTransitionsPage instance with the transitions enabled page = AlignmentTransitionsPage() page.transitions_enabled_check_box.setChecked(False) # WHEN: The property is accessed result = page.is_transition_enabled # THEN: The result should be correct assert result is False
def test_get_horizontal_align(self): """ Test the horizontal_align getter """ # GIVEN: A AlignmentTransitionsPage instance with the combobox set to index 1 page = AlignmentTransitionsPage() page.horizontal_combo_box.setCurrentIndex(1) # WHEN: The property is accessed result = page.horizontal_align # THEN: The result should be correct assert result == HorizontalType.Right
def test_on_transition_reverse_getter(self): """ Test the is_transition_reverse_enabled getter """ # GIVEN: And instance of AlignmentTransitionsPage and transition_reverse checked page = AlignmentTransitionsPage() page.transition_reverse_check_box.setChecked(True) # WHEN: The property is accessed result = page.is_transition_reverse_enabled # THEN: The result should be correct assert result is True
def test_get_transition_type(self): """ Test the transition_type getter """ # GIVEN: A AlignmentTransitionsPage instance with the combobox set to index 1 page = AlignmentTransitionsPage() page.transition_effect_combo_box.setCurrentIndex(1) # WHEN: The property is accessed result = page.transition_type # THEN: The result should be correct assert result == TransitionType.Slide
def test_get_transition_direction(self): """ Test the transition_direction getter """ # GIVEN: A AlignmentTransitionsPage instance with the combobox set to index 0 page = AlignmentTransitionsPage() page.transition_direction_combo_box.setCurrentIndex(0) # WHEN: The property is accessed result = page.transition_direction # THEN: The result should be correct assert result == TransitionDirection.Horizontal
def test_get_transition_speed(self): """ Test the transition_speed getter """ # GIVEN: A AlignmentTransitionsPage instance with the combobox set to index 0 page = AlignmentTransitionsPage() page.transition_speed_combo_box.setCurrentIndex(0) # WHEN: The property is accessed result = page.transition_speed # THEN: The result should be correct assert result == TransitionSpeed.Normal
class Ui_ThemeWizard(object): """ The Create/Edit theme wizard """ def setup_ui(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(): # pragma: no cover 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 = BackgroundPage() self.background_page.setObjectName('background_page') theme_wizard.addPage(self.background_page) # Main Area Page self.main_area_page = FontSelectPage() self.main_area_page.setObjectName('main_area_page') theme_wizard.addPage(self.main_area_page) # Footer Area Page self.footer_area_page = FontSelectPage() self.footer_area_page.setObjectName('footer_area_page') self.footer_area_page.disable_features(FontSelectPage.Outline, FontSelectPage.Shadow, FontSelectPage.LineSpacing) theme_wizard.addPage(self.footer_area_page) # Alignment Page self.alignment_page = AlignmentTransitionsPage() self.alignment_page.setObjectName('alignment_page') theme_wizard.addPage(self.alignment_page) # Area Position Page self.area_position_page = AreaPositionPage() self.area_position_page.setObjectName('area_position_page') 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 = AspectRatioLayout( self.preview_area, 0.75) # Dummy ratio, will be update self.preview_area_layout.margin = 8 self.preview_area_layout.setSpacing(0) self.preview_area_layout.setObjectName('preview_web_layout') self.preview_box = ThemePreviewRenderer(self) self.preview_box.setObjectName('preview_box') self.preview_area_layout.addWidget(self.preview_box) self.preview_layout.addWidget(self.preview_area) theme_wizard.addPage(self.preview_page) self.retranslate_ui(theme_wizard) def retranslate_ui(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.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.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.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.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.')) 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:'))
def setup_ui(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(): # pragma: no cover 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 = BackgroundPage() self.background_page.setObjectName('background_page') theme_wizard.addPage(self.background_page) # Main Area Page self.main_area_page = FontSelectPage() self.main_area_page.setObjectName('main_area_page') theme_wizard.addPage(self.main_area_page) # Footer Area Page self.footer_area_page = FontSelectPage() self.footer_area_page.setObjectName('footer_area_page') self.footer_area_page.disable_features(FontSelectPage.Outline, FontSelectPage.Shadow, FontSelectPage.LineSpacing) theme_wizard.addPage(self.footer_area_page) # Alignment Page self.alignment_page = AlignmentTransitionsPage() self.alignment_page.setObjectName('alignment_page') theme_wizard.addPage(self.alignment_page) # Area Position Page self.area_position_page = AreaPositionPage() self.area_position_page.setObjectName('area_position_page') 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 = AspectRatioLayout( self.preview_area, 0.75) # Dummy ratio, will be update self.preview_area_layout.margin = 8 self.preview_area_layout.setSpacing(0) self.preview_area_layout.setObjectName('preview_web_layout') self.preview_box = ThemePreviewRenderer(self) self.preview_box.setObjectName('preview_box') self.preview_area_layout.addWidget(self.preview_box) self.preview_layout.addWidget(self.preview_area) theme_wizard.addPage(self.preview_page) self.retranslate_ui(theme_wizard)