def setup_ui(self, song_usage_detail_dialog): """ Set up the UI :param song_usage_detail_dialog: """ song_usage_detail_dialog.setObjectName('song_usage_detail_dialog') song_usage_detail_dialog.setWindowIcon(UiIcons().main_icon) song_usage_detail_dialog.resize(609, 413) self.vertical_layout = QtWidgets.QVBoxLayout(song_usage_detail_dialog) self.vertical_layout.setSpacing(8) self.vertical_layout.setContentsMargins(8, 8, 8, 8) self.vertical_layout.setObjectName('vertical_layout') self.date_range_group_box = QtWidgets.QGroupBox( song_usage_detail_dialog) self.date_range_group_box.setObjectName('date_range_group_box') self.date_horizontal_layout = QtWidgets.QHBoxLayout( self.date_range_group_box) self.date_horizontal_layout.setSpacing(8) self.date_horizontal_layout.setContentsMargins(8, 8, 8, 8) self.date_horizontal_layout.setObjectName('date_horizontal_layout') self.from_date_calendar = QtWidgets.QCalendarWidget( self.date_range_group_box) self.from_date_calendar.setObjectName('from_date_calendar') self.date_horizontal_layout.addWidget(self.from_date_calendar) self.to_label = QtWidgets.QLabel(self.date_range_group_box) self.to_label.setScaledContents(False) self.to_label.setAlignment(QtCore.Qt.AlignCenter) self.to_label.setObjectName('to_label') self.date_horizontal_layout.addWidget(self.to_label) self.to_date_calendar = QtWidgets.QCalendarWidget( self.date_range_group_box) self.to_date_calendar.setObjectName('to_date_calendar') self.date_horizontal_layout.addWidget(self.to_date_calendar) self.vertical_layout.addWidget(self.date_range_group_box) self.file_group_box = QtWidgets.QGroupBox(self.date_range_group_box) self.file_group_box.setObjectName('file_group_box') self.file_horizontal_layout = QtWidgets.QHBoxLayout( self.file_group_box) self.file_horizontal_layout.setSpacing(8) self.file_horizontal_layout.setContentsMargins(8, 8, 8, 8) self.file_horizontal_layout.setObjectName('file_horizontal_layout') self.report_path_edit = PathEdit(self.file_group_box, path_type=PathEditType.Directories, show_revert=False) self.file_horizontal_layout.addWidget(self.report_path_edit) self.vertical_layout.addWidget(self.file_group_box) self.button_box = create_button_box(song_usage_detail_dialog, 'button_box', ['cancel', 'ok']) self.vertical_layout.addWidget(self.button_box) self.retranslate_ui(song_usage_detail_dialog) self.report_path_edit.pathChanged.connect( song_usage_detail_dialog.on_report_path_edit_path_changed)
def setup_ui(self): """ Configure the UI elements for the tab. """ self.setObjectName('AdvancedTab') super(AdvancedTab, self).setup_ui() self.ui_group_box = QtWidgets.QGroupBox(self.left_column) self.ui_group_box.setObjectName('ui_group_box') self.ui_layout = QtWidgets.QFormLayout(self.ui_group_box) self.ui_layout.setObjectName('ui_layout') self.recent_label = QtWidgets.QLabel(self.ui_group_box) self.recent_label.setObjectName('recent_label') self.recent_spin_box = QtWidgets.QSpinBox(self.ui_group_box) self.recent_spin_box.setObjectName('recent_spin_box') self.recent_spin_box.setMinimum(0) self.ui_layout.addRow(self.recent_label, self.recent_spin_box) self.media_plugin_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.media_plugin_check_box.setObjectName('media_plugin_check_box') self.ui_layout.addRow(self.media_plugin_check_box) self.hide_mouse_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.hide_mouse_check_box.setObjectName('hide_mouse_check_box') self.ui_layout.addRow(self.hide_mouse_check_box) self.double_click_live_check_box = QtWidgets.QCheckBox( self.ui_group_box) self.double_click_live_check_box.setObjectName( 'double_click_live_check_box') self.ui_layout.addRow(self.double_click_live_check_box) self.single_click_preview_check_box = QtWidgets.QCheckBox( self.ui_group_box) self.single_click_preview_check_box.setObjectName( 'single_click_preview_check_box') self.ui_layout.addRow(self.single_click_preview_check_box) self.single_click_service_preview_check_box = QtWidgets.QCheckBox( self.ui_group_box) self.single_click_service_preview_check_box.setObjectName( 'single_click_service_preview_check_box') self.ui_layout.addRow(self.single_click_service_preview_check_box) self.expand_service_item_check_box = QtWidgets.QCheckBox( self.ui_group_box) self.expand_service_item_check_box.setObjectName( 'expand_service_item_check_box') self.ui_layout.addRow(self.expand_service_item_check_box) self.slide_max_height_label = QtWidgets.QLabel(self.ui_group_box) self.slide_max_height_label.setObjectName('slide_max_height_label') self.slide_max_height_combo_box = QtWidgets.QComboBox( self.ui_group_box) self.slide_max_height_combo_box.addItem('', userData=0) self.slide_max_height_combo_box.addItem('', userData=-4) # Generate numeric values for combo box dynamically for px in range(60, 801, 5): self.slide_max_height_combo_box.addItem(str(px) + 'px', userData=px) self.slide_max_height_combo_box.setObjectName( 'slide_max_height_combo_box') self.ui_layout.addRow(self.slide_max_height_label, self.slide_max_height_combo_box) self.autoscroll_label = QtWidgets.QLabel(self.ui_group_box) self.autoscroll_label.setObjectName('autoscroll_label') self.autoscroll_combo_box = QtWidgets.QComboBox(self.ui_group_box) self.autoscroll_combo_box.addItems( ['', '', '', '', '', '', '', '', '', '', '', '']) self.autoscroll_combo_box.setObjectName('autoscroll_combo_box') self.ui_layout.addRow(self.autoscroll_label) self.ui_layout.addRow(self.autoscroll_combo_box) self.search_as_type_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.search_as_type_check_box.setObjectName('SearchAsType_check_box') self.ui_layout.addRow(self.search_as_type_check_box) self.enable_auto_close_check_box = QtWidgets.QCheckBox( self.ui_group_box) self.enable_auto_close_check_box.setObjectName( 'enable_auto_close_check_box') self.ui_layout.addRow(self.enable_auto_close_check_box) self.experimental_check_box = QtWidgets.QCheckBox(self.ui_group_box) self.experimental_check_box.setObjectName('experimental_check_box') self.ui_layout.addRow(self.experimental_check_box) self.left_layout.addWidget(self.ui_group_box) if HAS_DARK_STYLE: self.use_dark_style_checkbox = QtWidgets.QCheckBox( self.ui_group_box) self.use_dark_style_checkbox.setObjectName( 'use_dark_style_checkbox') self.ui_layout.addRow(self.use_dark_style_checkbox) # Service Item Slide Limits self.slide_group_box = QtWidgets.QGroupBox(self.left_column) self.slide_group_box.setObjectName('slide_group_box') self.slide_layout = QtWidgets.QVBoxLayout(self.slide_group_box) self.slide_layout.setObjectName('slide_layout') self.slide_label = QtWidgets.QLabel(self.slide_group_box) self.slide_label.setWordWrap(True) self.slide_layout.addWidget(self.slide_label) self.end_slide_radio_button = QtWidgets.QRadioButton( self.slide_group_box) self.end_slide_radio_button.setObjectName('end_slide_radio_button') self.slide_layout.addWidget(self.end_slide_radio_button) self.wrap_slide_radio_button = QtWidgets.QRadioButton( self.slide_group_box) self.wrap_slide_radio_button.setObjectName('wrap_slide_radio_button') self.slide_layout.addWidget(self.wrap_slide_radio_button) self.next_item_radio_button = QtWidgets.QRadioButton( self.slide_group_box) self.next_item_radio_button.setObjectName('next_item_radio_button') self.slide_layout.addWidget(self.next_item_radio_button) self.left_layout.addWidget(self.slide_group_box) # Data Directory self.data_directory_group_box = QtWidgets.QGroupBox(self.left_column) self.data_directory_group_box.setObjectName('data_directory_group_box') self.data_directory_layout = QtWidgets.QFormLayout( self.data_directory_group_box) self.data_directory_layout.setObjectName('data_directory_layout') self.data_directory_new_label = QtWidgets.QLabel( self.data_directory_group_box) self.data_directory_new_label.setObjectName( 'data_directory_current_label') self.data_directory_path_edit = PathEdit( self.data_directory_group_box, path_type=PathEditType.Directories, default_path=AppLocation.get_directory(AppLocation.DataDir)) self.data_directory_layout.addRow(self.data_directory_new_label, self.data_directory_path_edit) self.new_data_directory_has_files_label = QtWidgets.QLabel( self.data_directory_group_box) self.new_data_directory_has_files_label.setObjectName( 'new_data_directory_has_files_label') self.new_data_directory_has_files_label.setWordWrap(True) self.data_directory_cancel_button = QtWidgets.QToolButton( self.data_directory_group_box) self.data_directory_cancel_button.setObjectName( 'data_directory_cancel_button') self.data_directory_cancel_button.setIcon(UiIcons().delete) self.data_directory_copy_check_layout = QtWidgets.QHBoxLayout() self.data_directory_copy_check_layout.setObjectName( 'data_directory_copy_check_layout') self.data_directory_copy_check_box = QtWidgets.QCheckBox( self.data_directory_group_box) self.data_directory_copy_check_box.setObjectName( 'data_directory_copy_check_box') self.data_directory_copy_check_layout.addWidget( self.data_directory_copy_check_box) self.data_directory_copy_check_layout.addStretch() self.data_directory_copy_check_layout.addWidget( self.data_directory_cancel_button) self.data_directory_layout.addRow( self.data_directory_copy_check_layout) self.data_directory_layout.addRow( self.new_data_directory_has_files_label) self.left_layout.addWidget(self.data_directory_group_box) # Display Workarounds self.display_workaround_group_box = QtWidgets.QGroupBox( self.right_column) self.display_workaround_group_box.setObjectName( 'display_workaround_group_box') self.display_workaround_layout = QtWidgets.QVBoxLayout( self.display_workaround_group_box) self.display_workaround_layout.setObjectName( 'display_workaround_layout') self.ignore_aspect_ratio_check_box = QtWidgets.QCheckBox( self.display_workaround_group_box) self.ignore_aspect_ratio_check_box.setObjectName( 'ignore_aspect_ratio_check_box') self.display_workaround_layout.addWidget( self.ignore_aspect_ratio_check_box) self.x11_bypass_check_box = QtWidgets.QCheckBox( self.display_workaround_group_box) self.x11_bypass_check_box.setObjectName('x11_bypass_check_box') self.display_workaround_layout.addWidget(self.x11_bypass_check_box) self.alternate_rows_check_box = QtWidgets.QCheckBox( self.display_workaround_group_box) self.alternate_rows_check_box.setObjectName('alternate_rows_check_box') self.display_workaround_layout.addWidget(self.alternate_rows_check_box) self.right_layout.addWidget(self.display_workaround_group_box) # Default service name self.service_name_group_box = QtWidgets.QGroupBox(self.right_column) self.service_name_group_box.setObjectName('service_name_group_box') self.service_name_layout = QtWidgets.QFormLayout( self.service_name_group_box) self.service_name_check_box = QtWidgets.QCheckBox( self.service_name_group_box) self.service_name_check_box.setObjectName('service_name_check_box') self.service_name_layout.setObjectName('service_name_layout') self.service_name_layout.addRow(self.service_name_check_box) self.service_name_time_label = QtWidgets.QLabel( self.service_name_group_box) self.service_name_time_label.setObjectName('service_name_time_label') self.service_name_day = QtWidgets.QComboBox( self.service_name_group_box) self.service_name_day.addItems(['', '', '', '', '', '', '', '']) self.service_name_day.setObjectName('service_name_day') self.service_name_time = QtWidgets.QTimeEdit( self.service_name_group_box) self.service_name_time.setObjectName('service_name_time') self.service_name_time_layout = QtWidgets.QHBoxLayout() self.service_name_time_layout.setObjectName('service_name_time_layout') self.service_name_time_layout.addWidget(self.service_name_day) self.service_name_time_layout.addWidget(self.service_name_time) self.service_name_layout.addRow(self.service_name_time_label, self.service_name_time_layout) self.service_name_label = QtWidgets.QLabel(self.service_name_group_box) self.service_name_label.setObjectName('service_name_label') self.service_name_edit = QtWidgets.QLineEdit( self.service_name_group_box) self.service_name_edit.setObjectName('service_name_edit') self.service_name_edit.setValidator( QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+]+'), self)) self.service_name_revert_button = QtWidgets.QToolButton( self.service_name_group_box) self.service_name_revert_button.setObjectName( 'service_name_revert_button') self.service_name_revert_button.setIcon(UiIcons().undo) self.service_name_button_layout = QtWidgets.QHBoxLayout() self.service_name_button_layout.setObjectName( 'service_name_button_layout') self.service_name_button_layout.addWidget(self.service_name_edit) self.service_name_button_layout.addWidget( self.service_name_revert_button) self.service_name_layout.addRow(self.service_name_label, self.service_name_button_layout) self.service_name_example_label = QtWidgets.QLabel( self.service_name_group_box) self.service_name_example_label.setObjectName( 'service_name_example_label') self.service_name_example = QtWidgets.QLabel( self.service_name_group_box) self.service_name_example.setObjectName('service_name_example') self.service_name_layout.addRow(self.service_name_example_label, self.service_name_example) self.right_layout.addWidget(self.service_name_group_box) # Proxies self.proxy_widget = ProxyWidget(self.right_column) self.right_layout.addWidget(self.proxy_widget) # After the last item on each side, add some spacing self.left_layout.addStretch() self.right_layout.addStretch() # Set up all the connections and things self.should_update_service_name_example = False self.service_name_check_box.toggled.connect( self.service_name_check_box_toggled) self.service_name_day.currentIndexChanged.connect( self.on_service_name_day_changed) self.service_name_time.timeChanged.connect( self.update_service_name_example) self.service_name_edit.textChanged.connect( self.update_service_name_example) self.service_name_revert_button.clicked.connect( self.on_service_name_revert_button_clicked) self.alternate_rows_check_box.toggled.connect( self.on_alternate_rows_check_box_toggled) self.data_directory_path_edit.pathChanged.connect( self.on_data_directory_path_edit_path_changed) self.data_directory_cancel_button.clicked.connect( self.on_data_directory_cancel_button_clicked) self.data_directory_copy_check_box.toggled.connect( self.on_data_directory_copy_check_box_toggled) self.end_slide_radio_button.clicked.connect( self.on_end_slide_button_clicked) self.wrap_slide_radio_button.clicked.connect( self.on_wrap_slide_button_clicked) self.next_item_radio_button.clicked.connect( self.on_next_item_button_clicked) self.search_as_type_check_box.stateChanged.connect( self.on_search_as_type_check_box_changed)
def add_custom_pages(self): """ Add song wizard specific pages. """ # The page with all available songs. self.available_songs_page = QtWidgets.QWizardPage() self.available_songs_page.setObjectName('available_songs_page') self.available_songs_layout = QtWidgets.QHBoxLayout( self.available_songs_page) self.available_songs_layout.setObjectName('available_songs_layout') self.vertical_layout = QtWidgets.QVBoxLayout() self.vertical_layout.setObjectName('vertical_layout') self.available_list_widget = QtWidgets.QListWidget( self.available_songs_page) self.available_list_widget.setObjectName('available_list_widget') self.vertical_layout.addWidget(self.available_list_widget) self.horizontal_layout = QtWidgets.QHBoxLayout() self.horizontal_layout.setObjectName('horizontal_layout') self.search_label = QtWidgets.QLabel(self.available_songs_page) self.search_label.setObjectName('search_label') self.horizontal_layout.addWidget(self.search_label) self.search_line_edit = QtWidgets.QLineEdit(self.available_songs_page) self.search_line_edit.setObjectName('search_line_edit') self.horizontal_layout.addWidget(self.search_line_edit) spacer_item = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontal_layout.addItem(spacer_item) self.uncheck_button = QtWidgets.QPushButton(self.available_songs_page) self.uncheck_button.setObjectName('uncheck_button') self.horizontal_layout.addWidget(self.uncheck_button) self.check_button = QtWidgets.QPushButton(self.available_songs_page) self.check_button.setObjectName('selectButton') self.horizontal_layout.addWidget(self.check_button) self.vertical_layout.addLayout(self.horizontal_layout) self.available_songs_layout.addLayout(self.vertical_layout) self.addPage(self.available_songs_page) # The page with the selected songs. self.export_song_page = QtWidgets.QWizardPage() self.export_song_page.setObjectName('available_songs_page') self.export_song_layout = QtWidgets.QHBoxLayout(self.export_song_page) self.export_song_layout.setObjectName('export_song_layout') self.grid_layout = QtWidgets.QGridLayout() self.grid_layout.setObjectName('range_layout') self.selected_list_widget = QtWidgets.QListWidget( self.export_song_page) self.selected_list_widget.setObjectName('selected_list_widget') self.grid_layout.addWidget(self.selected_list_widget, 1, 0, 1, 2) self.output_directory_path_edit = PathEdit( self.export_song_page, PathEditType.Directories, dialog_caption=translate('SongsPlugin.ExportWizardForm', 'Select Destination Folder'), show_revert=False) self.output_directory_path_edit.path = Settings().value( 'songs/last directory export') self.directory_label = QtWidgets.QLabel(self.export_song_page) self.directory_label.setObjectName('directory_label') self.grid_layout.addWidget(self.directory_label, 0, 0) self.grid_layout.addWidget(self.output_directory_path_edit, 0, 1) self.export_song_layout.addLayout(self.grid_layout) self.addPage(self.export_song_page)
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 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)
class PresentationTab(SettingsTab): """ PresentationsTab is the Presentations settings tab in the settings dialog. """ def __init__(self, parent, title, visible_title, controllers, icon_path): """ Constructor """ self.controllers = controllers super(PresentationTab, self).__init__(parent, title, visible_title, icon_path) self.activated = False def setup_ui(self): """ Create the controls for the settings tab """ self.setObjectName('PresentationTab') super(PresentationTab, self).setup_ui() self.controllers_group_box = QtWidgets.QGroupBox(self.left_column) self.controllers_group_box.setObjectName('controllers_group_box') self.controllers_layout = QtWidgets.QVBoxLayout( self.controllers_group_box) self.controllers_layout.setObjectName('ccontrollers_layout') self.presenter_check_boxes = {} for key in self.controllers: controller = self.controllers[key] checkbox = QtWidgets.QCheckBox(self.controllers_group_box) checkbox.setObjectName(controller.name + 'CheckBox') self.presenter_check_boxes[controller.name] = checkbox self.controllers_layout.addWidget(checkbox) self.left_layout.addWidget(self.controllers_group_box) # Advanced self.advanced_group_box = QtWidgets.QGroupBox(self.left_column) self.advanced_group_box.setObjectName('advanced_group_box') self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box) self.advanced_layout.setObjectName('advanced_layout') self.override_app_check_box = QtWidgets.QCheckBox( self.advanced_group_box) self.override_app_check_box.setObjectName('override_app_check_box') self.advanced_layout.addWidget(self.override_app_check_box) self.left_layout.addWidget(self.advanced_group_box) # PowerPoint self.powerpoint_group_box = QtWidgets.QGroupBox(self.left_column) self.powerpoint_group_box.setObjectName('powerpoint_group_box') self.powerpoint_layout = QtWidgets.QVBoxLayout( self.powerpoint_group_box) self.powerpoint_layout.setObjectName('powerpoint_layout') self.ppt_slide_click_check_box = QtWidgets.QCheckBox( self.powerpoint_group_box) self.ppt_slide_click_check_box.setObjectName( 'ppt_slide_click_check_box') self.powerpoint_layout.addWidget(self.ppt_slide_click_check_box) self.ppt_window_check_box = QtWidgets.QCheckBox( self.powerpoint_group_box) self.ppt_window_check_box.setObjectName('ppt_window_check_box') self.powerpoint_layout.addWidget(self.ppt_window_check_box) self.left_layout.addWidget(self.powerpoint_group_box) # Pdf options self.pdf_group_box = QtWidgets.QGroupBox(self.left_column) self.pdf_group_box.setObjectName('pdf_group_box') self.pdf_layout = QtWidgets.QFormLayout(self.pdf_group_box) self.pdf_layout.setObjectName('pdf_layout') self.pdf_program_check_box = QtWidgets.QCheckBox(self.pdf_group_box) self.pdf_program_check_box.setObjectName('pdf_program_check_box') self.pdf_layout.addRow(self.pdf_program_check_box) self.program_path_edit = PathEdit(self.pdf_group_box) self.pdf_layout.addRow(self.program_path_edit) self.left_layout.addWidget(self.pdf_group_box) self.left_layout.addStretch() self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.right_layout.addStretch() # Signals and slots self.program_path_edit.pathChanged.connect( self.on_program_path_edit_path_changed) self.pdf_program_check_box.clicked.connect( self.program_path_edit.setEnabled) def retranslate_ui(self): """ Make any translation changes """ self.controllers_group_box.setTitle( translate('PresentationPlugin.PresentationTab', 'Available Controllers')) for key in self.controllers: controller = self.controllers[key] checkbox = self.presenter_check_boxes[controller.name] self.set_controller_text(checkbox, controller) self.advanced_group_box.setTitle(UiStrings().Advanced) self.pdf_group_box.setTitle( translate('PresentationPlugin.PresentationTab', 'PDF options')) self.powerpoint_group_box.setTitle( translate('PresentationPlugin.PresentationTab', 'PowerPoint options')) self.override_app_check_box.setText( translate('PresentationPlugin.PresentationTab', 'Allow presentation application to be overridden')) self.ppt_slide_click_check_box.setText( translate( 'PresentationPlugin.PresentationTab', 'Clicking on the current slide advances to the next effect')) self.ppt_window_check_box.setText( translate( 'PresentationPlugin.PresentationTab', 'Let PowerPoint control the size and monitor of the presentations\n' '(This may fix PowerPoint scaling issues in Windows 8 and 10)') ) self.pdf_program_check_box.setText( translate('PresentationPlugin.PresentationTab', 'Use given full path for mudraw or ghostscript binary:')) self.program_path_edit.dialog_caption = translate( 'PresentationPlugin.PresentationTab', 'Select mudraw or ghostscript binary') def set_controller_text(self, checkbox, controller): if checkbox.isEnabled(): checkbox.setText(controller.display_name) else: checkbox.setText( translate('PresentationPlugin.PresentationTab', '{name} (unavailable)').format( name=controller.display_name)) def load(self): """ Load the settings. """ powerpoint_available = False for key in self.controllers: controller = self.controllers[key] checkbox = self.presenter_check_boxes[controller.name] checkbox.setChecked( self.settings.value(self.settings_section + '/' + controller.name)) if controller.name == 'Powerpoint' and controller.is_available(): powerpoint_available = True self.override_app_check_box.setChecked( self.settings.value(self.settings_section + '/override app')) # Load PowerPoint settings self.ppt_slide_click_check_box.setChecked( self.settings.value(self.settings_section + '/powerpoint slide click advance')) self.ppt_slide_click_check_box.setEnabled(powerpoint_available) self.ppt_window_check_box.setChecked( self.settings.value(self.settings_section + '/powerpoint control window')) self.ppt_window_check_box.setEnabled(powerpoint_available) # load pdf-program settings enable_pdf_program = self.settings.value(self.settings_section + '/enable_pdf_program') self.pdf_program_check_box.setChecked(enable_pdf_program) self.program_path_edit.setEnabled(enable_pdf_program) self.program_path_edit.path = self.settings.value( self.settings_section + '/pdf_program') def save(self): """ Save the settings. If the tab hasn't been made visible to the user then there is nothing to do, so exit. This removes the need to start presentation applications unnecessarily. """ if not self.activated: return changed = False for key in self.controllers: controller = self.controllers[key] if controller.is_available(): checkbox = self.presenter_check_boxes[controller.name] setting_key = self.settings_section + '/' + controller.name if self.settings.value(setting_key) != checkbox.checkState(): changed = True self.settings.setValue(setting_key, checkbox.checkState()) if checkbox.isChecked(): controller.start_process() else: controller.kill() setting_key = self.settings_section + '/override app' if self.settings.value( setting_key) != self.override_app_check_box.checkState(): self.settings.setValue(setting_key, self.override_app_check_box.checkState()) changed = True # Save powerpoint settings setting_key = self.settings_section + '/powerpoint slide click advance' if self.settings.value( setting_key) != self.ppt_slide_click_check_box.checkState(): self.settings.setValue(setting_key, self.ppt_slide_click_check_box.checkState()) changed = True setting_key = self.settings_section + '/powerpoint control window' if self.settings.value( setting_key) != self.ppt_window_check_box.checkState(): self.settings.setValue(setting_key, self.ppt_window_check_box.checkState()) changed = True # Save pdf-settings pdf_program_path = self.program_path_edit.path enable_pdf_program = self.pdf_program_check_box.checkState() # If the given program is blank disable using the program if pdf_program_path is None: enable_pdf_program = 0 if pdf_program_path != self.settings.value(self.settings_section + '/pdf_program'): self.settings.setValue(self.settings_section + '/pdf_program', pdf_program_path) changed = True if enable_pdf_program != self.settings.value(self.settings_section + '/enable_pdf_program'): self.settings.setValue( self.settings_section + '/enable_pdf_program', enable_pdf_program) changed = True if changed: self.settings_form.register_post_process('mediaitem_suffix_reset') self.settings_form.register_post_process( 'mediaitem_presentation_rebuild') self.settings_form.register_post_process('mediaitem_suffixes') def tab_visible(self): """ Tab has just been made visible to the user """ self.activated = True for key in self.controllers: controller = self.controllers[key] checkbox = self.presenter_check_boxes[controller.name] checkbox.setEnabled(controller.is_available()) self.set_controller_text(checkbox, controller) def on_program_path_edit_path_changed(self, new_path): """ Handle the `pathEditChanged` signal from program_path_edit :param pathlib.Path new_path: File path to the new program :rtype: None """ if new_path: if not PdfController.process_check_binary(new_path): critical_error_message_box( UiStrings().Error, translate( 'PresentationPlugin.PresentationTab', 'The program is not ghostscript or mudraw which is required.' ))
def setup_ui(self): """ Create the controls for the settings tab """ self.setObjectName('PresentationTab') super(PresentationTab, self).setup_ui() self.controllers_group_box = QtWidgets.QGroupBox(self.left_column) self.controllers_group_box.setObjectName('controllers_group_box') self.controllers_layout = QtWidgets.QVBoxLayout( self.controllers_group_box) self.controllers_layout.setObjectName('ccontrollers_layout') self.presenter_check_boxes = {} for key in self.controllers: controller = self.controllers[key] checkbox = QtWidgets.QCheckBox(self.controllers_group_box) checkbox.setObjectName(controller.name + 'CheckBox') self.presenter_check_boxes[controller.name] = checkbox self.controllers_layout.addWidget(checkbox) self.left_layout.addWidget(self.controllers_group_box) # Advanced self.advanced_group_box = QtWidgets.QGroupBox(self.left_column) self.advanced_group_box.setObjectName('advanced_group_box') self.advanced_layout = QtWidgets.QVBoxLayout(self.advanced_group_box) self.advanced_layout.setObjectName('advanced_layout') self.override_app_check_box = QtWidgets.QCheckBox( self.advanced_group_box) self.override_app_check_box.setObjectName('override_app_check_box') self.advanced_layout.addWidget(self.override_app_check_box) self.left_layout.addWidget(self.advanced_group_box) # PowerPoint self.powerpoint_group_box = QtWidgets.QGroupBox(self.left_column) self.powerpoint_group_box.setObjectName('powerpoint_group_box') self.powerpoint_layout = QtWidgets.QVBoxLayout( self.powerpoint_group_box) self.powerpoint_layout.setObjectName('powerpoint_layout') self.ppt_slide_click_check_box = QtWidgets.QCheckBox( self.powerpoint_group_box) self.ppt_slide_click_check_box.setObjectName( 'ppt_slide_click_check_box') self.powerpoint_layout.addWidget(self.ppt_slide_click_check_box) self.ppt_window_check_box = QtWidgets.QCheckBox( self.powerpoint_group_box) self.ppt_window_check_box.setObjectName('ppt_window_check_box') self.powerpoint_layout.addWidget(self.ppt_window_check_box) self.left_layout.addWidget(self.powerpoint_group_box) # Pdf options self.pdf_group_box = QtWidgets.QGroupBox(self.left_column) self.pdf_group_box.setObjectName('pdf_group_box') self.pdf_layout = QtWidgets.QFormLayout(self.pdf_group_box) self.pdf_layout.setObjectName('pdf_layout') self.pdf_program_check_box = QtWidgets.QCheckBox(self.pdf_group_box) self.pdf_program_check_box.setObjectName('pdf_program_check_box') self.pdf_layout.addRow(self.pdf_program_check_box) self.program_path_edit = PathEdit(self.pdf_group_box) self.pdf_layout.addRow(self.program_path_edit) self.left_layout.addWidget(self.pdf_group_box) self.left_layout.addStretch() self.right_column.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) self.right_layout.addStretch() # Signals and slots self.program_path_edit.pathChanged.connect( self.on_program_path_edit_path_changed) self.pdf_program_check_box.clicked.connect( self.program_path_edit.setEnabled)
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 add_file_select_item(self): """ Add a file selection page. """ this_format = self.current_format format_name, prefix, can_disable, description_text, select_mode, filters = \ SongFormat.get(this_format, 'name', 'prefix', 'canDisable', 'descriptionText', 'selectMode', 'filter') page = QtWidgets.QWidget() page.setObjectName(prefix + 'Page') if can_disable: import_widget = self.disablable_widget(page, prefix) else: import_widget = page import_layout = QtWidgets.QVBoxLayout(import_widget) import_layout.setContentsMargins(0, 0, 0, 0) import_layout.setObjectName(prefix + 'ImportLayout') if description_text is not None: description_layout = QtWidgets.QHBoxLayout() description_layout.setObjectName(prefix + 'DescriptionLayout') description_spacer = QtWidgets.QSpacerItem(0, 0, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed) description_layout.addSpacerItem(description_spacer) description_label = QtWidgets.QLabel(import_widget) description_label.setWordWrap(True) description_label.setOpenExternalLinks(True) description_label.setObjectName(prefix + '_description_label') description_layout.addWidget(description_label) import_layout.addLayout(description_layout) self.format_widgets[this_format]['description_label'] = description_label self.format_widgets[this_format]['descriptionSpacer'] = description_spacer if select_mode == SongFormatSelect.SingleFile or select_mode == SongFormatSelect.SingleFolder: file_path_layout = QtWidgets.QHBoxLayout() file_path_layout.setObjectName(prefix + '_file_path_layout') file_path_label = QtWidgets.QLabel(import_widget) file_path_layout.addWidget(file_path_label) if select_mode == SongFormatSelect.SingleFile: path_type = PathEditType.Files dialog_caption = WizardStrings.OpenTypeFile.format(file_type=format_name) else: path_type = PathEditType.Directories dialog_caption = WizardStrings.OpenTypeFolder.format(folder_name=format_name) path_edit = PathEdit( parent=import_widget, path_type=path_type, dialog_caption=dialog_caption, show_revert=False) if path_edit.filters: path_edit.filters = filters + ';;' + path_edit.filters else: path_edit.filters = filters path_edit.path = self.settings.value(self.plugin.settings_section + '/last directory import') file_path_layout.addWidget(path_edit) import_layout.addLayout(file_path_layout) import_layout.addSpacerItem(self.stack_spacer) self.format_widgets[this_format]['filepathLabel'] = file_path_label self.format_widgets[this_format]['path_edit'] = path_edit elif select_mode == SongFormatSelect.MultipleFiles: file_list_widget = QtWidgets.QListWidget(import_widget) file_list_widget.setSelectionMode(QtWidgets.QAbstractItemView.ExtendedSelection) file_list_widget.setObjectName(prefix + 'FileListWidget') import_layout.addWidget(file_list_widget) button_layout = QtWidgets.QHBoxLayout() button_layout.setObjectName(prefix + '_button_layout') add_button = QtWidgets.QPushButton(import_widget) add_button.setIcon(self.open_icon) add_button.setObjectName(prefix + 'AddButton') button_layout.addWidget(add_button) button_layout.addStretch() remove_button = QtWidgets.QPushButton(import_widget) remove_button.setIcon(self.delete_icon) remove_button.setObjectName(prefix + 'RemoveButton') button_layout.addWidget(remove_button) import_layout.addLayout(button_layout) self.format_widgets[this_format]['file_list_widget'] = file_list_widget self.format_widgets[this_format]['button_layout'] = button_layout self.format_widgets[this_format]['addButton'] = add_button self.format_widgets[this_format]['removeButton'] = remove_button self.format_stack.addWidget(page) self.format_widgets[this_format]['page'] = page self.format_widgets[this_format]['importLayout'] = import_layout self.format_combo_box.addItem('')
def setUp(self): with patch('openlp.core.widgets.edits.PathEdit._setup'): self.widget = PathEdit()
class TestPathEdit(TestCase): """ Test the :class:`~openlp.core.widgets.edits.PathEdit` class """ def setUp(self): with patch('openlp.core.widgets.edits.PathEdit._setup'): self.widget = PathEdit() def test_path_getter(self): """ Test the `path` property getter. """ # GIVEN: An instance of PathEdit with the `_path` instance variable set self.widget._path = Path('getter', 'test', 'pat.h') # WHEN: Reading the `path` property # THEN: The value that we set should be returned assert self.widget.path == Path('getter', 'test', 'pat.h') def test_path_setter(self): """ Test the `path` property setter. """ # GIVEN: An instance of the PathEdit object and a mocked `line_edit` self.widget.line_edit = MagicMock() # WHEN: Writing to the `path` property self.widget.path = Path('setter', 'test', 'pat.h') # THEN: The `_path` instance variable should be set with the test data. The `line_edit` text and tooltip # should have also been set. assert self.widget._path == Path('setter', 'test', 'pat.h') self.widget.line_edit.setToolTip.assert_called_once_with( os.path.join('setter', 'test', 'pat.h')) self.widget.line_edit.setText.assert_called_once_with( os.path.join('setter', 'test', 'pat.h')) def test_path_type_getter(self): """ Test the `path_type` property getter. """ # GIVEN: An instance of PathEdit # WHEN: Reading the `path` property # THEN: The default value should be returned assert self.widget.path_type == PathEditType.Files def test_path_type_setter(self): """ Test the `path_type` property setter. """ # GIVEN: An instance of the PathEdit object and a mocked `update_button_tool_tips` method. with patch.object( self.widget, 'update_button_tool_tips') as mocked_update_button_tool_tips: # WHEN: Writing to a different value than default to the `path_type` property self.widget.path_type = PathEditType.Directories # THEN: The `_path_type` instance variable should be set with the test data and not the default. The # update_button_tool_tips should have been called. assert self.widget._path_type == PathEditType.Directories mocked_update_button_tool_tips.assert_called_once_with() def test_update_button_tool_tips_directories(self): """ Test the `update_button_tool_tips` method. """ # GIVEN: An instance of PathEdit with the `path_type` set to `Directories` self.widget.browse_button = MagicMock() self.widget.revert_button = MagicMock() self.widget._path_type = PathEditType.Directories # WHEN: Calling update_button_tool_tips self.widget.update_button_tool_tips() self.widget.browse_button.setToolTip.assert_called_once_with( 'Browse for directory.') self.widget.revert_button.setToolTip.assert_called_once_with( 'Revert to default directory.') def test_update_button_tool_tips_files(self): """ Test the `update_button_tool_tips` method. """ # GIVEN: An instance of PathEdit with the `path_type` set to `Files` self.widget.browse_button = MagicMock() self.widget.revert_button = MagicMock() self.widget._path_type = PathEditType.Files # WHEN: Calling update_button_tool_tips self.widget.update_button_tool_tips() self.widget.browse_button.setToolTip.assert_called_once_with( 'Browse for file.') self.widget.revert_button.setToolTip.assert_called_once_with( 'Revert to default file.') @patch('openlp.core.widgets.edits.FileDialog.getExistingDirectory', return_value=None) @patch('openlp.core.widgets.edits.FileDialog.getOpenFileName') def test_on_browse_button_clicked_directory(self, mocked_get_open_file_name, mocked_get_existing_directory): """ Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Directories. """ # GIVEN: An instance of PathEdit with the `path_type` set to `Directories` and a mocked # QFileDialog.getExistingDirectory self.widget._path_type = PathEditType.Directories self.widget._path = Path('test', 'path') # WHEN: Calling on_browse_button_clicked self.widget.on_browse_button_clicked() # THEN: The FileDialog.getExistingDirectory should have been called with the default caption mocked_get_existing_directory.assert_called_once_with( self.widget, 'Select Directory', Path('test', 'path'), FileDialog.ShowDirsOnly) assert mocked_get_open_file_name.called is False def test_on_browse_button_clicked_directory_custom_caption(self): """ Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Directories, and `dialog_caption` is set. """ # GIVEN: An instance of PathEdit with the `path_type` set to `Directories` and a mocked # QFileDialog.getExistingDirectory with `default_caption` set. with patch('openlp.core.widgets.edits.FileDialog.getExistingDirectory', return_value=None) as \ mocked_get_existing_directory, \ patch('openlp.core.widgets.edits.FileDialog.getOpenFileName') as mocked_get_open_file_name: self.widget._path_type = PathEditType.Directories self.widget._path = Path('test', 'path') self.widget.dialog_caption = 'Directory Caption' # WHEN: Calling on_browse_button_clicked self.widget.on_browse_button_clicked() # THEN: The FileDialog.getExistingDirectory should have been called with the custom caption mocked_get_existing_directory.assert_called_once_with( self.widget, 'Directory Caption', Path('test', 'path'), FileDialog.ShowDirsOnly) assert mocked_get_open_file_name.called is False def test_on_browse_button_clicked_file(self): """ Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Files. """ # GIVEN: An instance of PathEdit with the `path_type` set to `Files` and a mocked QFileDialog.getOpenFileName with patch('openlp.core.widgets.edits.FileDialog.getExistingDirectory') as mocked_get_existing_directory, \ patch('openlp.core.widgets.edits.FileDialog.getOpenFileName', return_value=(None, '')) as \ mocked_get_open_file_name: self.widget._path_type = PathEditType.Files self.widget._path = Path('test', 'pat.h') # WHEN: Calling on_browse_button_clicked self.widget.on_browse_button_clicked() # THEN: The FileDialog.getOpenFileName should have been called with the default caption mocked_get_open_file_name.assert_called_once_with( self.widget, 'Select File', Path('test', 'pat.h'), self.widget.filters) assert mocked_get_existing_directory.called is False def test_on_browse_button_clicked_file_custom_caption(self): """ Test the `browse_button` `clicked` handler on_browse_button_clicked when the `path_type` is set to Files and `dialog_caption` is set. """ # GIVEN: An instance of PathEdit with the `path_type` set to `Files` and a mocked QFileDialog.getOpenFileName # with `default_caption` set. with patch('openlp.core.widgets.edits.FileDialog.getExistingDirectory') as mocked_get_existing_directory, \ patch('openlp.core.widgets.edits.FileDialog.getOpenFileName', return_value=(None, '')) as \ mocked_get_open_file_name: self.widget._path_type = PathEditType.Files self.widget._path = Path('test', 'pat.h') self.widget.dialog_caption = 'File Caption' # WHEN: Calling on_browse_button_clicked self.widget.on_browse_button_clicked() # THEN: The FileDialog.getOpenFileName should have been called with the custom caption mocked_get_open_file_name.assert_called_once_with( self.widget, 'File Caption', Path('test', 'pat.h'), self.widget.filters) assert mocked_get_existing_directory.called is False def test_on_browse_button_clicked_user_cancels(self): """ Test the `browse_button` `clicked` handler on_browse_button_clicked when the user cancels the FileDialog (an empty str is returned) """ # GIVEN: An instance of PathEdit with a mocked QFileDialog.getOpenFileName which returns an empty str for the # file path. with patch('openlp.core.widgets.edits.FileDialog.getOpenFileName', return_value=(None, '')) as \ mocked_get_open_file_name: # WHEN: Calling on_browse_button_clicked self.widget.on_browse_button_clicked() # THEN: normpath should not have been called assert mocked_get_open_file_name.called is True def test_on_browse_button_clicked_user_accepts(self): """ Test the `browse_button` `clicked` handler on_browse_button_clicked when the user accepts the FileDialog (a path is returned) """ # GIVEN: An instance of PathEdit with a mocked QFileDialog.getOpenFileName which returns a str for the file # path. with patch('openlp.core.widgets.edits.FileDialog.getOpenFileName', return_value=(Path('test', 'pat.h'), '')) as mocked_get_open_file_name, \ patch.object(self.widget, 'on_new_path'): # WHEN: Calling on_browse_button_clicked self.widget.on_browse_button_clicked() # THEN: normpath and `on_new_path` should have been called assert mocked_get_open_file_name.called is True assert self.widget.on_new_path.called is True def test_on_revert_button_clicked(self): """ Test that the default path is set as the path when the `revert_button.clicked` handler is called. """ # GIVEN: An instance of PathEdit with a mocked `on_new_path`, and the `default_path` set. with patch.object(self.widget, 'on_new_path') as mocked_on_new_path: self.widget.default_path = Path('default', 'pat.h') # WHEN: Calling `on_revert_button_clicked` self.widget.on_revert_button_clicked() # THEN: on_new_path should have been called with the default path mocked_on_new_path.assert_called_once_with(Path( 'default', 'pat.h')) def test_on_line_edit_editing_finished(self): """ Test that the new path is set as the path when the `line_edit.editingFinished` handler is called. """ # GIVEN: An instance of PathEdit with a mocked `line_edit` and `on_new_path`. with patch.object(self.widget, 'on_new_path') as mocked_on_new_path: self.widget.line_edit = MagicMock( **{'text.return_value': 'test/pat.h'}) # WHEN: Calling `on_line_edit_editing_finished` self.widget.on_line_edit_editing_finished() # THEN: on_new_path should have been called with the path enetered in `line_edit` mocked_on_new_path.assert_called_once_with(Path('test', 'pat.h')) def test_on_new_path_no_change(self): """ Test `on_new_path` when called with a path that is the same as the existing path. """ # GIVEN: An instance of PathEdit with a test path and mocked `pathChanged` signal with patch('openlp.core.widgets.edits.PathEdit.path', new_callable=PropertyMock): self.widget._path = Path('/old', 'test', 'pat.h') self.widget.pathChanged = MagicMock() # WHEN: Calling `on_new_path` with the same path as the existing path self.widget.on_new_path(Path('/old', 'test', 'pat.h')) # THEN: The `pathChanged` signal should not be emitted assert self.widget.pathChanged.emit.called is False def test_on_new_path_change(self): """ Test `on_new_path` when called with a path that is the different to the existing path. """ # GIVEN: An instance of PathEdit with a test path and mocked `pathChanged` signal with patch('openlp.core.widgets.edits.PathEdit.path', new_callable=PropertyMock): self.widget._path = Path('/old', 'test', 'pat.h') self.widget.pathChanged = MagicMock() # WHEN: Calling `on_new_path` with the a new path self.widget.on_new_path(Path('/new', 'test', 'pat.h')) # THEN: The `pathChanged` signal should be emitted self.widget.pathChanged.emit.assert_called_once_with( Path('/new', 'test', 'pat.h'))
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)