def add_progress_page(self): """ Add the progress page for the wizard. This page informs the user how the wizard is progressing with its task. """ self.progress_page = QtWidgets.QWizardPage() self.progress_page.setObjectName('progress_page') self.progress_layout = QtWidgets.QVBoxLayout(self.progress_page) self.progress_layout.setContentsMargins(48, 48, 48, 48) self.progress_layout.setObjectName('progress_layout') self.progress_label = QtWidgets.QLabel(self.progress_page) self.progress_label.setObjectName('progress_label') self.progress_label.setWordWrap(True) self.progress_layout.addWidget(self.progress_label) self.progress_bar = QtWidgets.QProgressBar(self.progress_page) self.progress_bar.setObjectName('progress_bar') self.progress_layout.addWidget(self.progress_bar) # Add a QTextEdit and a copy to file and copy to clipboard button to be # able to provide feedback to the user. Hidden by default. self.error_report_text_edit = QtWidgets.QTextEdit(self.progress_page) self.error_report_text_edit.setObjectName('error_report_text_edit') self.error_report_text_edit.setHidden(True) self.error_report_text_edit.setReadOnly(True) self.progress_layout.addWidget(self.error_report_text_edit) self.error_button_layout = QtWidgets.QHBoxLayout() self.error_button_layout.setObjectName('error_button_layout') spacer = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.error_button_layout.addItem(spacer) self.error_copy_to_button = QtWidgets.QPushButton(self.progress_page) self.error_copy_to_button.setObjectName('error_copy_to_button') self.error_copy_to_button.setHidden(True) self.error_copy_to_button.setIcon(UiIcons().copy) self.error_button_layout.addWidget(self.error_copy_to_button) self.error_save_to_button = QtWidgets.QPushButton(self.progress_page) self.error_save_to_button.setObjectName('error_save_to_button') self.error_save_to_button.setHidden(True) self.error_save_to_button.setIcon(UiIcons().save) self.error_button_layout.addWidget(self.error_save_to_button) self.progress_layout.addLayout(self.error_button_layout) self.addPage(self.progress_page)
def setup_ui(self, book_name_dialog): book_name_dialog.setObjectName('book_name_dialog') book_name_dialog.setWindowIcon(UiIcons().main_icon) book_name_dialog.resize(400, 271) self.book_name_layout = QtWidgets.QVBoxLayout(book_name_dialog) self.book_name_layout.setSpacing(8) self.book_name_layout.setContentsMargins(8, 8, 8, 8) self.book_name_layout.setObjectName('book_name_layout') self.info_label = QtWidgets.QLabel(book_name_dialog) self.info_label.setWordWrap(True) self.info_label.setObjectName('info_label') self.book_name_layout.addWidget(self.info_label) self.corresponding_layout = QtWidgets.QGridLayout() self.corresponding_layout.setColumnStretch(1, 1) self.corresponding_layout.setSpacing(8) self.corresponding_layout.setObjectName('corresponding_layout') self.current_label = QtWidgets.QLabel(book_name_dialog) self.current_label.setObjectName('current_label') self.corresponding_layout.addWidget(self.current_label, 0, 0, 1, 1) self.current_book_label = QtWidgets.QLabel(book_name_dialog) self.current_book_label.setObjectName('current_book_label') self.corresponding_layout.addWidget(self.current_book_label, 0, 1, 1, 1) self.corresponding_label = QtWidgets.QLabel(book_name_dialog) self.corresponding_label.setObjectName('corresponding_label') self.corresponding_layout.addWidget(self.corresponding_label, 1, 0, 1, 1) self.corresponding_combo_box = QtWidgets.QComboBox(book_name_dialog) self.corresponding_combo_box.setObjectName('corresponding_combo_box') self.corresponding_layout.addWidget(self.corresponding_combo_box, 1, 1, 1, 1) self.book_name_layout.addLayout(self.corresponding_layout) self.options_group_box = QtWidgets.QGroupBox(book_name_dialog) self.options_group_box.setObjectName('options_group_box') self.options_layout = QtWidgets.QVBoxLayout(self.options_group_box) self.options_layout.setSpacing(8) self.options_layout.setContentsMargins(8, 8, 8, 8) self.options_layout.setObjectName('options_layout') self.old_testament_check_box = QtWidgets.QCheckBox(self.options_group_box) self.old_testament_check_box.setObjectName('old_testament_check_box') self.old_testament_check_box.setCheckState(QtCore.Qt.Checked) self.options_layout.addWidget(self.old_testament_check_box) self.new_testament_check_box = QtWidgets.QCheckBox(self.options_group_box) self.new_testament_check_box.setObjectName('new_testament_check_box') self.new_testament_check_box.setCheckState(QtCore.Qt.Checked) self.options_layout.addWidget(self.new_testament_check_box) self.apocrypha_check_box = QtWidgets.QCheckBox(self.options_group_box) self.apocrypha_check_box.setObjectName('apocrypha_check_box') self.apocrypha_check_box.setCheckState(QtCore.Qt.Checked) self.options_layout.addWidget(self.apocrypha_check_box) self.book_name_layout.addWidget(self.options_group_box) self.button_box = create_button_box(book_name_dialog, 'button_box', ['cancel', 'ok']) self.book_name_layout.addWidget(self.button_box) self.retranslate_ui(book_name_dialog)
def set_button_state(self): """ Keep buttons inline. Turn of signals to stop dead loop but we need the button and check box set correctly. """ self.song_usage_active_button.blockSignals(True) self.song_usage_status.blockSignals(True) if self.song_usage_active: self.song_usage_active_button.setIcon(UiIcons().song_usage_active) self.song_usage_status.setChecked(True) self.song_usage_active_button.setChecked(True) self.song_usage_active_button.setToolTip( translate('SongUsagePlugin', 'Song usage tracking is active.')) else: self.song_usage_active_button.setIcon( UiIcons().song_usage_inactive) self.song_usage_status.setChecked(False) self.song_usage_active_button.setChecked(False) self.song_usage_active_button.setToolTip( translate('SongUsagePlugin', 'Song usage tracking is inactive.')) self.song_usage_active_button.blockSignals(False) self.song_usage_status.blockSignals(False)
def add_custom_context_actions(self): create_widget_action(self.list_view, separator=True) self.replace_action_context = create_widget_action( self.list_view, text=UiStrings().ReplaceBG, icon=':/slides/slide_theme.png', triggers=self.on_replace_click) self.reset_action_context = create_widget_action( self.list_view, text=UiStrings().ReplaceLiveBG, icon=UiIcons().close, visible=False, triggers=self.on_reset_click)
def __init__(self): """ PluginPresentation constructor. """ log.debug('Initialised') self.controllers = {} Plugin.__init__(self, 'presentations', __default_settings__, __default_settings__) self.weight = -8 self.icon_path = UiIcons().presentation self.icon = build_icon(self.icon_path) register_endpoint(presentations_endpoint) register_endpoint(api_presentations_endpoint)
def setup_ui(self, edit_verse_dialog): edit_verse_dialog.setObjectName('edit_verse_dialog') edit_verse_dialog.setWindowIcon(UiIcons().main_icon) edit_verse_dialog.resize(400, 400) edit_verse_dialog.setModal(True) self.dialog_layout = QtWidgets.QVBoxLayout(edit_verse_dialog) self.dialog_layout.setObjectName('dialog_layout') self.verse_text_edit = SpellTextEdit(edit_verse_dialog) self.verse_text_edit.setObjectName('verse_text_edit') self.dialog_layout.addWidget(self.verse_text_edit) self.verse_type_layout = QtWidgets.QHBoxLayout() self.verse_type_layout.setObjectName('verse_type_layout') self.forced_split_button = QtWidgets.QPushButton(edit_verse_dialog) self.forced_split_button.setIcon(UiIcons().add) self.forced_split_button.setObjectName('forced_split_button') self.verse_type_layout.addWidget(self.forced_split_button) self.overflow_split_button = QtWidgets.QPushButton(edit_verse_dialog) self.overflow_split_button.setIcon(UiIcons().add) self.overflow_split_button.setObjectName('overflow_split_button') self.verse_type_layout.addWidget(self.overflow_split_button) self.verse_type_label = QtWidgets.QLabel(edit_verse_dialog) self.verse_type_label.setObjectName('verse_type_label') self.verse_type_layout.addWidget(self.verse_type_label) self.verse_type_combo_box = QtWidgets.QComboBox(edit_verse_dialog) self.verse_type_combo_box.addItems(['', '', '', '', '', '', '']) self.verse_type_combo_box.setObjectName('verse_type_combo_box') self.verse_type_label.setBuddy(self.verse_type_combo_box) self.verse_type_layout.addWidget(self.verse_type_combo_box) self.verse_number_box = QtWidgets.QSpinBox(edit_verse_dialog) self.verse_number_box.setMinimum(1) self.verse_number_box.setObjectName('verse_number_box') self.verse_type_layout.addWidget(self.verse_number_box) self.insert_button = QtWidgets.QPushButton(edit_verse_dialog) self.insert_button.setIcon(UiIcons().add) self.insert_button.setObjectName('insert_button') self.verse_type_layout.addWidget(self.insert_button) self.verse_type_layout.addStretch() self.dialog_layout.addLayout(self.verse_type_layout) if Registry().get('settings').value('songs/enable chords'): self.transpose_layout = QtWidgets.QHBoxLayout() self.transpose_layout.setObjectName('transpose_layout') self.transpose_label = QtWidgets.QLabel(edit_verse_dialog) self.transpose_label.setObjectName('transpose_label') self.transpose_layout.addWidget(self.transpose_label) self.transpose_up_button = QtWidgets.QPushButton(edit_verse_dialog) self.transpose_up_button.setIcon(UiIcons().arrow_up) self.transpose_up_button.setObjectName('transpose_up') self.transpose_layout.addWidget(self.transpose_up_button) self.transpose_down_button = QtWidgets.QPushButton( edit_verse_dialog) self.transpose_down_button.setIcon(UiIcons().arrow_down) self.transpose_down_button.setObjectName('transpose_down') self.transpose_layout.addWidget(self.transpose_down_button) self.dialog_layout.addLayout(self.transpose_layout) self.button_box = create_button_box(edit_verse_dialog, 'button_box', ['cancel', 'ok']) self.dialog_layout.addWidget(self.button_box) self.retranslate_ui(edit_verse_dialog)
def _setup(self, show_revert): """ Set up the widget :param bool show_revert: Show or hide the revert button :rtype: None """ widget_layout = QtWidgets.QHBoxLayout() widget_layout.setContentsMargins(0, 0, 0, 0) self.line_edit = QtWidgets.QLineEdit(self) widget_layout.addWidget(self.line_edit) self.browse_button = QtWidgets.QToolButton(self) self.browse_button.setIcon(UiIcons().open) widget_layout.addWidget(self.browse_button) self.revert_button = QtWidgets.QToolButton(self) self.revert_button.setIcon(UiIcons().undo) self.revert_button.setVisible(show_revert) widget_layout.addWidget(self.revert_button) self.setLayout(widget_layout) # Signals and Slots self.browse_button.clicked.connect(self.on_browse_button_clicked) self.revert_button.clicked.connect(self.on_revert_button_clicked) self.line_edit.editingFinished.connect(self.on_line_edit_editing_finished) self.update_button_tool_tips()
def __init__(self): super(MediaPlugin, self).__init__('media', MediaMediaItem) self.weight = -6 self.icon_path = UiIcons().video self.icon = build_icon(self.icon_path) # passed with drag and drop messages self.dnd_id = 'Media' register_endpoint(media_endpoint) register_endpoint(api_media_endpoint) State().add_service(self.name, self.weight, requires='mediacontroller', is_plugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions())
def add_end_header_bar(self): self.toolbar.addSeparator() # Song Maintenance Button self.maintenance_action = self.toolbar.add_toolbar_action( 'maintenance_action', icon=UiIcons().database, triggers=self.on_song_maintenance_click) self.add_search_to_toolbar() # Signals and slots Registry().register_function('songs_load_list', self.on_song_list_load) Registry().register_function('songs_preview', self.on_preview_click) self.search_text_edit.cleared.connect(self.on_clear_text_button_click) self.search_text_edit.searchTypeChanged.connect( self.on_search_text_button_clicked)
def __init__(self, plugin=None): """ Set up the service item. :param plugin: The plugin that this service item belongs to. """ if plugin: self.name = plugin.name self._rendered_slides = None self._display_slides = None self._print_slides = None self.title = '' self.slides = [] self.processor = None self.audit = '' self.items = [] self.icon = UiIcons().default self.raw_footer = [] # Plugins can set footer_html themselves. If they don't, it will be generated from raw_footer. self.footer_html = '' self.theme = None self.service_item_type = None self.unique_identifier = 0 self.notes = '' self.from_plugin = False self.capabilities = [] self.is_valid = True self.icon = None self.main = None self.footer = None self.bg_image_bytes = None self.search_string = '' self.data_string = '' self.edit_id = None self.xml_version = None self.start_time = 0 self.end_time = 0 self.media_length = 0 self.from_service = False self.image_border = '#000000' self.background_audio = [] self.theme_overwritten = False self.temporary_edit = False self.auto_play_slides_once = False self.auto_play_slides_loop = False self.timed_slide_interval = 0 self.will_auto_start = False self.has_original_files = True self._new_item() self.metadata = []
def __init__(self): """ Create and set up the PlanningCenter plugin. """ super(PlanningCenterPlugin, self).__init__('planningcenter', settings_tab_class=PlanningCenterTab) self.planningcenter_form = None self.icon = UiIcons().planning_center self.icon_path = self.icon self.weight = -1 State().add_service('planning_center', self.weight, is_plugin=True) State().update_pre_conditions('planning_center', self.check_pre_conditions())
def add_end_header_bar(self): """ Adds buttons to the end of the header bar. """ # Replace backgrounds do not work at present so remove functionality. self.replace_action = self.toolbar.add_toolbar_action( 'replace_action', icon=UiIcons().theme, triggers=self.on_replace_click) if 'webkit' not in get_media_players()[0]: self.replace_action.setDisabled(True) if hasattr(self, 'replace_action_context'): self.replace_action_context.setDisabled(True) self.reset_action = self.toolbar.add_toolbar_action( 'reset_action', icon=UiIcons().close, visible=False, triggers=self.on_reset_click) self.media_widget = QtWidgets.QWidget(self) self.media_widget.setObjectName('media_widget') self.display_layout = QtWidgets.QFormLayout(self.media_widget) self.display_layout.setContentsMargins(self.display_layout.spacing(), self.display_layout.spacing(), self.display_layout.spacing(), self.display_layout.spacing()) self.display_layout.setObjectName('display_layout') self.display_type_label = QtWidgets.QLabel(self.media_widget) self.display_type_label.setObjectName('display_type_label') self.display_type_combo_box = create_horizontal_adjusting_combo_box( self.media_widget, 'display_type_combo_box') self.display_type_label.setBuddy(self.display_type_combo_box) self.display_layout.addRow(self.display_type_label, self.display_type_combo_box) # Add the Media widget to the page layout. self.page_layout.addWidget(self.media_widget) self.display_type_combo_box.currentIndexChanged.connect( self.override_player_changed)
def __init__(self): """ PluginPresentation constructor. """ log.debug('Initialised') self.controllers = {} Plugin.__init__(self, 'presentations', None) self.weight = -8 self.icon_path = UiIcons().presentation self.icon = build_icon(self.icon_path) register_endpoint(presentations_endpoint) register_endpoint(api_presentations_endpoint) State().add_service('presentation', self.weight, is_plugin=True) State().update_pre_conditions('presentation', self.check_pre_conditions())
def __init__(self, parent): """ ProjectorTab initialization :param parent: Parent widget """ self.icon_path = UiIcons().projector self.udp_listeners = {} # Key on port number projector_translated = translate('OpenLP.ProjectorTab', 'Projector') super(ProjectorTab, self).__init__(parent, 'Projector', projector_translated) Registry().register_function('udp_broadcast_add', self.add_udp_listener) Registry().register_function('udp_broadcast_remove', self.remove_udp_listener)
def __init__(self, parent, plugin, name, image, add_progress_page=True): """ Constructor """ # QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint remove the "?" buttons from windows, # QtCore.Qt.WindowCloseButtonHint enables the "x" button to close these windows. super(OpenLPWizard, self).__init__(parent, QtCore.Qt.WindowSystemMenuHint | QtCore.Qt.WindowTitleHint | QtCore.Qt.WindowCloseButtonHint) self.plugin = plugin self.with_progress_page = add_progress_page self.setFixedWidth(640) self.setObjectName(name) self.open_icon = UiIcons().open self.delete_icon = UiIcons().delete self.finish_button = self.button(QtWidgets.QWizard.FinishButton) self.cancel_button = self.button(QtWidgets.QWizard.CancelButton) self.setupUi(image) self.register_fields() self.custom_init() self.custom_signals() self.currentIdChanged.connect(self.on_current_id_changed) if self.with_progress_page: self.error_copy_to_button.clicked.connect(self.on_error_copy_to_button_clicked) self.error_save_to_button.clicked.connect(self.on_error_save_to_button_clicked)
def __init__(self, themes_url, sample_theme_data, ftw, *args, **kwargs): super().__init__(*args, **kwargs) title = sample_theme_data['title'] thumbnail = sample_theme_data['thumbnail'] self.file_name = sample_theme_data['file_name'] self.sha256 = sample_theme_data['sha256'] self.setIcon(UiIcons().picture) # Set a place holder icon whilst the thumbnails download self.setText(title) self.setToolTip(title) worker = DownloadWorker(themes_url, thumbnail) worker.download_failed.connect(self._on_download_failed) worker.download_succeeded.connect(self._on_thumbnail_downloaded) thread_name = 'thumbnail_download_{thumbnail}'.format(thumbnail=thumbnail) run_thread(worker, thread_name) ftw.thumbnail_download_threads.append(thread_name)
def __init__(self): """ Class __init__ method """ super(AlertsPlugin, self).__init__('alerts', __default_settings__, settings_tab_class=AlertsTab) self.weight = -3 self.icon_path = UiIcons().alert self.icon = self.icon_path AlertsManager(self) self.manager = Manager('alerts', init_schema) self.alert_form = AlertForm(self) register_endpoint(alerts_endpoint) register_endpoint(api_alerts_endpoint)
def load_full_list(self, images, initial_load=False, open_group=None): """ Replace the list of images and groups in the interface. :param list[openlp.plugins.images.lib.db.ImageFilenames] images: A List of Image Filenames objects that will be used to reload the mediamanager list. :param initial_load: When set to False, the busy cursor and progressbar will be shown while loading images. :param open_group: ImageGroups object of the group that must be expanded after reloading the list in the interface. """ if not initial_load: self.application.set_busy_cursor() self.main_window.display_progress_bar(len(images)) self.list_view.clear() # Load the list of groups and add them to the treeView. group_items = {} self.add_sub_groups(group_items, parent_group_id=0) if open_group is not None: self.expand_group(open_group.id) # Sort the images by its filename considering language specific. # characters. images.sort(key=lambda image_object: get_natural_key(image_object. file_path.name)) for image in images: log.debug('Loading image: {name}'.format(name=image.file_path)) file_name = image.file_path.name thumbnail_path = self.generate_thumbnail_path(image) if not image.file_path.exists(): icon = UiIcons().delete else: if validate_thumb(image.file_path, thumbnail_path): icon = build_icon(thumbnail_path) else: icon = create_thumb(image.file_path, thumbnail_path) item_name = QtWidgets.QTreeWidgetItem([file_name]) item_name.setText(0, file_name) item_name.setIcon(0, icon) item_name.setToolTip(0, str(image.file_path)) item_name.setData(0, QtCore.Qt.UserRole, image) if image.group_id == 0: self.list_view.addTopLevelItem(item_name) else: group_items[image.group_id].addChild(item_name) if not initial_load: self.main_window.increment_progress_bar() if not initial_load: self.main_window.finished_progress_bar() self.application.set_normal_cursor()
def __init__(self): """ Class __init__ method """ super(AlertsPlugin, self).__init__('alerts', settings_tab_class=AlertsTab) self.weight = -3 self.icon_path = UiIcons().alert self.icon = self.icon_path AlertsManager(self) self.manager = Manager('alerts', init_schema) self.alert_form = AlertForm(self) register_endpoint(alerts_endpoint) register_endpoint(api_alerts_endpoint) State().add_service(self.name, self.weight, is_plugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions())
def __init__(self, parent, settings_section): """ Constructor. """ super().__init__(parent) self.settings_section = settings_section self._current_search_type = -1 self.clear_button = QtWidgets.QToolButton(self) self.clear_button.setIcon(UiIcons().backspace) self.clear_button.setCursor(QtCore.Qt.ArrowCursor) self.clear_button.setStyleSheet('QToolButton { border: none; padding: 0px; }') self.clear_button.resize(18, 18) self.clear_button.hide() self.clear_button.clicked.connect(self._on_clear_button_clicked) self.textChanged.connect(self._on_search_edit_text_changed) self._update_style_sheet() self.setAcceptDrops(False)
def add_tools_menu_item(self, tools_menu): """ Give the alerts plugin the opportunity to add items to the **Tools** menu. :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent. """ log.info('add tools menu') self.tools_alert_item = create_action( tools_menu, 'toolsAlertItem', text=translate('AlertsPlugin', '&Alert'), icon=UiIcons().alert, statustip=translate('AlertsPlugin', 'Show an alert message.'), visible=False, can_shortcuts=True, triggers=self.on_alerts_trigger) self.main_window.tools_menu.addAction(self.tools_alert_item)
def add_tools_menu_item(self, tools_menu): """ Give the Songs plugin the opportunity to add items to the **Tools** menu. :param tools_menu: The actual **Tools** menu item, so that your actions can use it as their parent. """ log.info('add tools menu') self.tools_menu = tools_menu self.song_tools_menu = QtWidgets.QMenu(tools_menu) self.song_tools_menu.setObjectName('song_tools_menu') self.song_tools_menu.setTitle(translate('SongsPlugin', 'Songs')) self.tools_reindex_item = create_action( tools_menu, 'toolsReindexItem', text=translate('SongsPlugin', '&Re-index Songs'), icon=UiIcons().music, statustip=translate( 'SongsPlugin', 'Re-index the songs database to improve searching and ordering.' ), triggers=self.on_tools_reindex_item_triggered) self.tools_find_duplicates = create_action( tools_menu, 'toolsFindDuplicates', text=translate('SongsPlugin', 'Find &Duplicate Songs'), statustip=translate( 'SongsPlugin', 'Find and remove duplicate songs in the song database.'), triggers=self.on_tools_find_duplicates_triggered, can_shortcuts=True) self.tools_report_song_list = create_action( tools_menu, 'toolsSongListReport', text=translate('SongsPlugin', 'Song List Report'), statustip=translate( 'SongsPlugin', 'Produce a CSV file of all the songs in the database.'), triggers=self.on_tools_report_song_list_triggered) self.tools_menu.addAction(self.song_tools_menu.menuAction()) self.song_tools_menu.addAction(self.tools_reindex_item) self.song_tools_menu.addAction(self.tools_find_duplicates) self.song_tools_menu.addAction(self.tools_report_song_list) self.song_tools_menu.menuAction().setVisible(False)
def __init__(self, parent): """ Initialise the settings tab """ self.data_exists = False self.icon_path = UiIcons().settings self.autoscroll_map = [ None, { 'dist': -1, 'pos': 0 }, { 'dist': -1, 'pos': 1 }, { 'dist': -1, 'pos': 2 }, { 'dist': 0, 'pos': 0 }, { 'dist': 0, 'pos': 1 }, { 'dist': 0, 'pos': 2 }, { 'dist': 0, 'pos': 3 }, { 'dist': 1, 'pos': 0 }, { 'dist': 1, 'pos': 1 }, { 'dist': 1, 'pos': 2 }, { 'dist': 1, 'pos': 3 } ] advanced_translated = translate('OpenLP.AdvancedTab', 'Advanced') super(AdvancedTab, self).__init__(parent, 'Advanced', advanced_translated)
def setupUi(self, image): """ Set up the wizard UI. :param image: path to start up image """ self.setWindowIcon(UiIcons().main_icon) self.setModal(True) self.setOptions(QtWidgets.QWizard.IndependentPages | QtWidgets.QWizard.NoBackButtonOnStartPage | QtWidgets.QWizard.NoBackButtonOnLastPage) if is_macosx(): self.setPixmap(QtWidgets.QWizard.BackgroundPixmap, QtGui.QPixmap(':/wizards/openlp-osx-wizard.png')) else: self.setWizardStyle(QtWidgets.QWizard.ModernStyle) add_welcome_page(self, image) self.add_custom_pages() if self.with_progress_page: self.add_progress_page() self.retranslateUi()
def __init__(self): """ Create and set up the Songs plugin. """ super(SongsPlugin, self).__init__('songs', SongMediaItem, SongsTab) self.manager = Manager('songs', init_schema, upgrade_mod=upgrade) self.weight = -10 self.icon_path = UiIcons().music self.icon = build_icon(self.icon_path) self.songselect_form = None self.settings.extend_default_settings(song_footer) register_endpoint(songs_endpoint) register_endpoint(api_songs_endpoint) State().add_service(self.name, self.weight, is_plugin=True) State().update_pre_conditions(self.name, self.check_pre_conditions()) if not self.settings.value('songs/last import type'): self.settings.setValue('songs/last import type', SongFormat.OpenLyrics)
def setupUi(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.retranslateUi(song_usage_detail_dialog) self.report_path_edit.pathChanged.connect(song_usage_detail_dialog.on_report_path_edit_path_changed)
def test_class_init_defaults(self): """ Test that the plugin class is instantiated with the correct defaults """ # GIVEN: A PlanningcenterPlugin Class # WHEN: the class has been through __init__ # THEN: # planningcenter form is set to None self.assertEqual(self.plugin.planningcenter_form, None, "Init plugin set to None") # icon is set correctly self.assertEqual(self.plugin.icon, UiIcons().planning_center, "Init icon set to planning_center icon") # weight is -1 self.assertEqual(self.plugin.weight, -1, "Init weight set to -1") # the planning_center module is registered active self.assertEqual(State().is_module_active('planning_center'), True, "Init State() is active")
def setupUi(self, file_rename_dialog): """ Set up the UI """ file_rename_dialog.setObjectName('file_rename_dialog') file_rename_dialog.setWindowIcon(UiIcons().main_icon) file_rename_dialog.resize(300, 10) self.dialog_layout = QtWidgets.QGridLayout(file_rename_dialog) self.dialog_layout.setObjectName('dialog_layout') self.file_name_label = QtWidgets.QLabel(file_rename_dialog) self.file_name_label.setObjectName('file_name_label') self.dialog_layout.addWidget(self.file_name_label, 0, 0) self.file_name_edit = QtWidgets.QLineEdit(file_rename_dialog) self.file_name_edit.setValidator(QtGui.QRegExpValidator(QtCore.QRegExp(r'[^/\\?*|<>\[\]":+%]+'), self)) self.file_name_edit.setObjectName('file_name_edit') self.dialog_layout.addWidget(self.file_name_edit, 0, 1) self.button_box = create_button_box(file_rename_dialog, 'button_box', ['cancel', 'ok']) self.dialog_layout.addWidget(self.button_box, 1, 0, 1, 2) self.retranslateUi(file_rename_dialog) self.setMaximumHeight(self.sizeHint().height())
def test_successful_download(self, mocked_build_icon): """ Test that the downloaded thumbnail is set as the icon when `DownloadWorker` emits the `download_succeeded` signal """ # GIVEN: An instance of `DownloadWorker` instance = ThemeListWidgetItem('url', self.sample_theme_data, MagicMock()) # noqa Overcome GC issue worker_threads = Registry().get('application').worker_threads worker = worker_threads['thumbnail_download_BlueBurst.png']['worker'] test_path = Path('downlaoded', 'file') # WHEN: `DownloadWorker` emits the `download_succeeded` signal worker.download_succeeded.emit(test_path) # THEN: An icon should have been built from the downloaded file and used to replace the loading icon mocked_build_icon.assert_called_once_with(test_path) self.mocked_set_icon.assert_has_calls( [call(UiIcons().picture), call(mocked_build_icon())])
def set_search_types(self, items): """ A list of tuples to be used in the search type menu. The first item in the list will be preselected as the default. :param items: The list of tuples to use. The tuples should contain an integer identifier, an icon (QIcon instance or string) and a title for the item in the menu. In short, they should look like this:: (<identifier>, <icon>, <title>, <place holder text>) For instance:: (1, <QIcon instance>, "Titles", "Search Song Titles...") Or:: (2, ":/songs/authors.png", "Authors", "Search Authors...") """ menu = QtWidgets.QMenu(self) for identifier, icon, title, placeholder in items: action = create_widget_action( menu, text=title, icon=icon, data=identifier, triggers=self._on_menu_action_triggered) action.placeholder_text = placeholder if not hasattr(self, 'menu_button'): self.menu_button = QtWidgets.QToolButton(self) self.menu_button.setIcon(UiIcons().shortcuts) self.menu_button.setCursor(QtCore.Qt.ArrowCursor) self.menu_button.setPopupMode(QtWidgets.QToolButton.InstantPopup) self.menu_button.setStyleSheet( 'QToolButton { border: none; padding: 0px 10px 0px 0px; }') self.menu_button.resize(QtCore.QSize(28, 18)) self.menu_button.setMenu(menu) self.set_current_search_type(Settings().value( '{section}/last used search type'.format( section=self.settings_section))) self.menu_button.show() self._update_style_sheet()