def retranslate_ui(self, first_time_wizard): """ Translate the UI on the fly :param first_time_wizard: The wizard form """ first_time_wizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard')) first_time_wizard.title_label.setText('<span style="font-size:14pt; font-weight:600;">%s</span>' % translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard')) first_time_wizard.information_label.setText( translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' 'Click the %s button below to start.') % clean_button_text(first_time_wizard.buttonText(QtGui.QWizard.NextButton))) self.download_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading Resource Index')) self.download_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while the resource index is ' 'downloaded.')) self.download_label.setText(translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP downloads the ' 'resource index file...')) self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Activate required Plugins')) self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select the Plugins you wish to use. ')) self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides')) self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bible')) self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images')) self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations')) self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media (Audio and Video)')) self.remote_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow remote access')) self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Monitor Song Usage')) self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Allow Alerts')) self.no_internet_page.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection')) self.no_internet_page.setSubTitle( translate('OpenLP.FirstTimeWizard', 'Unable to detect an Internet connection.')) self.no_internet_text = translate('OpenLP.FirstTimeWizard', 'No Internet connection was found. The First Time Wizard needs an Internet ' 'connection in order to be able to download sample songs, Bibles and themes.' ' Click the Finish button now to start OpenLP with initial settings and ' 'no sample data.\n\nTo re-run the First Time Wizard and import this sample ' 'data at a later time, check your Internet connection and re-run this ' 'wizard by selecting "Tools/Re-run First Time Wizard" from OpenLP.') self.cancel_wizard_text = translate('OpenLP.FirstTimeWizard', '\n\nTo cancel the First Time Wizard completely (and not start OpenLP), ' 'click the %s button now.') % \ clean_button_text(first_time_wizard.buttonText(QtGui.QWizard.CancelButton)) self.songs_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) self.songs_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) self.bibles_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) self.bibles_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download free Bibles.')) self.themes_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Themes')) self.themes_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download sample themes.')) self.defaults_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Default Settings')) self.defaults_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Set up default settings to be used by OpenLP.')) self.display_label.setText(translate('OpenLP.FirstTimeWizard', 'Default output display:')) self.theme_label.setText(translate('OpenLP.FirstTimeWizard', 'Select default theme:')) self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring')) self.progress_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded ' 'and OpenLP is configured.')) self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...')) first_time_wizard.setButtonText(QtGui.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Finish')) first_time_wizard.setButtonText(QtGui.QWizard.CustomButton2, translate('OpenLP.FirstTimeWizard', 'Cancel'))
def _post_wizard(self): """ Clean up the UI after the process has finished. """ if self.max_progress: self.progress_bar.setValue(self.progress_bar.maximum()) if self.has_run_wizard: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the %s button to return to OpenLP.') % clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) else: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the %s button to start OpenLP.') % clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) else: if self.has_run_wizard: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Click the %s button to return to OpenLP.') % clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) else: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Click the %s button to start OpenLP.') % clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton))) self.finish_button.setVisible(True) self.finish_button.setEnabled(True) self.cancel_button.setVisible(False) self.next_button.setVisible(False) self.application.process_events()
def _post_wizard(self): """ Clean up the UI after the process has finished. """ if self.max_progress: self.progress_bar.setValue(self.progress_bar.maximum()) if self.has_run_wizard: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the %s button to return to OpenLP.') % clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) else: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Download complete. Click the %s button to start OpenLP.') % clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) else: if self.has_run_wizard: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Click the %s button to return to OpenLP.') % clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) else: self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Click the %s button to start OpenLP.') % clean_button_text(self.buttonText(QtGui.QWizard.FinishButton))) self.finish_button.setVisible(True) self.finish_button.setEnabled(True) self.cancel_button.setVisible(False) self.next_button.setVisible(False) self.application.process_events()
def test_clean_button_text(self): """ Test the clean_button_text() function. """ # GIVEN: Button text input_text = '&Next >' expected_text = 'Next' # WHEN: The button caption is sent through the clean_button_text function actual_text = clean_button_text(input_text) # THEN: The text should have been cleaned self.assertEqual(expected_text, actual_text, 'The text should be clean')
def test_clean_button_text(self): """ Test the clean_button_text() function. """ # GIVEN: Button text input_text = '&Next >' expected_text = 'Next' # WHEN: The button caption is sent through the clean_button_text function actual_text = clean_button_text(input_text) # THEN: The text should have been cleaned assert expected_text == actual_text, 'The text should be clean'
def retranslate_ui(self, first_time_wizard): """ Translate the UI on the fly :param first_time_wizard: The wizard form """ first_time_wizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard')) text = translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard') first_time_wizard.title_label.setText('<span style="font-size:14pt; font-weight:600;">{text}' '</span>'.format(text=text)) button = clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.NextButton)) first_time_wizard.information_label.setText( translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' 'Click the {button} button below to start.').format(button=button)) self.download_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading Resource Index')) self.download_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while the resource index is ' 'downloaded.')) self.download_label.setText(translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP downloads the ' 'resource index file...')) self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Select parts of the program you wish to use')) self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'You can also change these settings after the Wizard.')) self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides – Easier to manage than songs and they have their own' ' list of slides')) self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bibles – Import and show Bibles')) self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images – Show images or replace background with them')) self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations – Show .ppt, .odp and .pdf files')) self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media – Playback of Audio and Video files')) self.remote_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Remote – Control OpenLP via browser or smart' 'phone app')) self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Song Usage Monitor')) self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Alerts – Display informative messages while showing other slides')) self.projectors_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Projectors – Control PJLink compatible projects on your network' ' from OpenLP')) self.no_internet_page.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection')) self.no_internet_page.setSubTitle( translate('OpenLP.FirstTimeWizard', 'Unable to detect an Internet connection.')) button = clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.FinishButton)) self.no_internet_text = translate('OpenLP.FirstTimeWizard', 'No Internet connection was found. The First Time Wizard needs an Internet ' 'connection in order to be able to download sample songs, Bibles and themes.' ' Click the {button} button now to start OpenLP with initial settings and ' 'no sample data.\n\nTo re-run the First Time Wizard and import this sample ' 'data at a later time, check your Internet connection and re-run this ' 'wizard by selecting "Tools/Re-run First Time Wizard" from OpenLP.' ).format(button=button) button = clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton)) self.cancel_wizard_text = translate('OpenLP.FirstTimeWizard', '\n\nTo cancel the First Time Wizard completely (and not start OpenLP), ' 'click the {button} button now.').format(button=button) self.songs_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) self.songs_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) self.bibles_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) self.bibles_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download free Bibles.')) self.themes_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Themes')) self.themes_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download sample themes.')) self.defaults_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Default Settings')) self.defaults_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Set up default settings to be used by OpenLP.')) self.display_label.setText(translate('OpenLP.FirstTimeWizard', 'Default output display:')) self.theme_label.setText(translate('OpenLP.FirstTimeWizard', 'Select default theme:')) self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring')) self.progress_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded ' 'and OpenLP is configured.')) self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...')) first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton1, clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.FinishButton))) first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton2, clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton)))
def retranslate_ui(self, first_time_wizard): """ Translate the UI on the fly :param first_time_wizard: The wizard form """ first_time_wizard.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard')) text = translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard') first_time_wizard.title_label.setText('<span style="font-size:14pt; font-weight:600;">{text}' '</span>'.format(text=text)) button = clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.NextButton)) first_time_wizard.information_label.setText( translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' 'Click the {button} button below to start.').format(button=button)) self.download_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading Resource Index')) self.download_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while the resource index is ' 'downloaded.')) self.download_label.setText(translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP downloads the ' 'resource index file...')) self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Select parts of the program you wish to use')) self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'You can also change these settings after the Wizard.')) self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) self.custom_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Custom Slides – Easier to manage than songs and they have their own' ' list of slides')) self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bibles – Import and show Bibles')) self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images – Show images or replace background with them')) self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations – Show .ppt, .odp and .pdf files')) self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media – Playback of Audio and Video files')) self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Song Usage Monitor')) self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Alerts – Display informative messages while showing other slides')) self.no_internet_page.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection')) self.no_internet_page.setSubTitle( translate('OpenLP.FirstTimeWizard', 'Unable to detect an Internet connection.')) button = clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.FinishButton)) self.no_internet_text = translate('OpenLP.FirstTimeWizard', 'No Internet connection was found. The First Time Wizard needs an Internet ' 'connection in order to be able to download sample songs, Bibles and themes.' ' Click the {button} button now to start OpenLP with initial settings and ' 'no sample data.\n\nTo re-run the First Time Wizard and import this sample ' 'data at a later time, check your Internet connection and re-run this ' 'wizard by selecting "Tools/Re-run First Time Wizard" from OpenLP.' ).format(button=button) button = clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton)) self.cancel_wizard_text = translate('OpenLP.FirstTimeWizard', '\n\nTo cancel the First Time Wizard completely (and not start OpenLP), ' 'click the {button} button now.').format(button=button) self.songs_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) self.songs_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) self.bibles_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) self.bibles_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download free Bibles.')) self.themes_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Themes')) self.themes_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download sample themes.')) self.defaults_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Default Settings')) self.defaults_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Set up default settings to be used by OpenLP.')) self.display_label.setText(translate('OpenLP.FirstTimeWizard', 'Default output display:')) self.theme_label.setText(translate('OpenLP.FirstTimeWizard', 'Select default theme:')) self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring')) self.progress_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded ' 'and OpenLP is configured.')) self.progress_label.setText(translate('OpenLP.FirstTimeWizard', 'Starting configuration process...')) first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton1, clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.FinishButton))) first_time_wizard.setButtonText(QtWidgets.QWizard.CustomButton2, clean_button_text(first_time_wizard.buttonText(QtWidgets.QWizard.CancelButton)))
def retranslate_ui(self): """ Translate the UI on the fly :param first_time_wizard: The wizard form """ self.finish_button_text = clean_button_text(self.buttonText(QtWidgets.QWizard.FinishButton)) back_button_text = clean_button_text(self.buttonText(QtWidgets.QWizard.BackButton)) next_button_text = clean_button_text(self.buttonText(QtWidgets.QWizard.NextButton)) self.setWindowTitle(translate('OpenLP.FirstTimeWizard', 'First Time Wizard')) text = translate('OpenLP.FirstTimeWizard', 'Welcome to the First Time Wizard') self.title_label.setText('<span style="font-size:14pt; font-weight:600;">{text}</span>'.format(text=text)) self.information_label.setText( translate('OpenLP.FirstTimeWizard', 'This wizard will help you to configure OpenLP for initial use. ' 'Click the \'{next_button}\' button below to start.' ).format(next_button=next_button_text)) self.setButtonText( QtWidgets.QWizard.CustomButton1, translate('OpenLP.FirstTimeWizard', 'Internet Settings')) self.download_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading Resource Index')) self.download_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Please wait while the resource index is downloaded.')) self.download_label.setText(translate('OpenLP.FirstTimeWizard', 'Please wait while OpenLP downloads the resource index file...')) self.plugin_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Select parts of the program you wish to use')) self.plugin_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'You can also change these settings after the Wizard.')) self.screen_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Displays')) self.screen_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Choose the main display screen for OpenLP.')) self.songs_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Songs')) self.custom_check_box.setText( translate('OpenLP.FirstTimeWizard', 'Custom Slides – Easier to manage than songs and they have their own list of slides')) self.bible_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Bibles – Import and show Bibles')) self.image_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Images – Show images or replace background with them')) self.presentation_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Presentations – Show .ppt, .odp and .pdf files')) self.media_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Media – Playback of Audio and Video files')) self.song_usage_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Song Usage Monitor')) self.alert_check_box.setText(translate('OpenLP.FirstTimeWizard', 'Alerts – Display informative messages while showing other slides')) self.resource_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Resource Data')) self.resource_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Can OpenLP download some resource data?')) self.resource_label.setText( translate('OpenLP.FirstTimeWizard', 'OpenLP has collected some resources that we have permission to distribute.\n\n' 'If you would like to download some of these resources click the \'{next_button}\' button, ' 'otherwise click the \'{finish_button}\' button.' ).format(next_button=next_button_text, finish_button=self.finish_button_text)) self.no_internet_page.setTitle(translate('OpenLP.FirstTimeWizard', 'No Internet Connection')) self.no_internet_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Cannot connect to the internet.')) self.no_internet_label.setText( translate('OpenLP.FirstTimeWizard', 'OpenLP could not connect to the internet to get information about the sample data available.\n\n' 'Please check your internet connection. If your church uses a proxy server click the ' '\'Internet Settings\' button below and enter the server details there.\n\nClick the ' '\'{back_button}\' button to try again.\n\nIf you click the \'{finish_button}\' ' 'button you can download the data at a later time by selecting \'Re-run First Time Wizard\' ' 'from the \'Tools\' menu in OpenLP.' ).format(back_button=back_button_text, finish_button=self.finish_button_text)) self.songs_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Songs')) self.songs_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download public domain songs.')) self.bibles_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Bibles')) self.bibles_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download free Bibles.')) # Themes Page self.themes_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Sample Themes')) self.themes_page.setSubTitle(translate('OpenLP.FirstTimeWizard', 'Select and download sample themes.')) self.theme_label.setText(translate('OpenLP.FirstTimeWizard', 'Default theme:')) self.themes_select_all_button.setToolTip(translate('OpenLP.FirstTimeWizard', 'Select all')) self.themes_deselect_all_button.setToolTip(translate('OpenLP.FirstTimeWizard', 'Deselect all')) self.progress_page.setTitle(translate('OpenLP.FirstTimeWizard', 'Downloading and Configuring')) self.progress_page.setSubTitle( translate('OpenLP.FirstTimeWizard', 'Please wait while resources are downloaded and OpenLP is configured.'))