def setUp(self): """ Create the UI """ Registry.create() self.setup_application() ScreenList.create(self.app.desktop()) Registry().register("application", MagicMock()) # Mock classes and methods used by mainwindow. with patch("openlp.core.ui.mainwindow.SettingsForm") as mocked_settings_form, patch( "openlp.core.ui.mainwindow.ImageManager" ) as mocked_image_manager, patch("openlp.core.ui.mainwindow.LiveController") as mocked_live_controller, patch( "openlp.core.ui.mainwindow.PreviewController" ) as mocked_preview_controller, patch( "openlp.core.ui.mainwindow.OpenLPDockWidget" ) as mocked_dock_widget, patch( "openlp.core.ui.mainwindow.QtGui.QToolBox" ) as mocked_q_tool_box_class, patch( "openlp.core.ui.mainwindow.QtGui.QMainWindow.addDockWidget" ) as mocked_add_dock_method, patch( "openlp.core.ui.mainwindow.ThemeManager" ) as mocked_theme_manager, patch( "openlp.core.ui.mainwindow.ProjectorManager" ) as mocked_projector_manager, patch( "openlp.core.ui.mainwindow.Renderer" ) as mocked_renderer: self.main_window = MainWindow() self.service_manager = Registry().get("service_manager")
def __init__(self, parent): """ Initialise the general settings tab """ self.screens = ScreenList() self.icon_path = ':/icon/openlp-logo-16x16.png' general_translated = translate('OpenLP.GeneralTab', 'General') super(GeneralTab, self).__init__(parent, 'Core', general_translated)
def setUp(self): """ Create the UI """ Registry.create() self.app = QtGui.QApplication.instance() ScreenList.create(self.app.desktop()) self.image_manager = ImageManager()
def load_presentation(self): """ Called when a presentation is added to the SlideController. It generates images from the PDF. :return: True is loading succeeded, otherwise False. """ log.debug('load_presentation pdf') # Check if the images has already been created, and if yes load them if os.path.isfile( os.path.join(self.get_temp_folder(), 'mainslide001.png')): created_files = sorted(os.listdir(self.get_temp_folder())) for fn in created_files: if os.path.isfile(os.path.join(self.get_temp_folder(), fn)): self.image_files.append( os.path.join(self.get_temp_folder(), fn)) self.num_pages = len(self.image_files) return True size = ScreenList().current['size'] # Generate images from PDF that will fit the frame. runlog = '' try: if not os.path.isdir(self.get_temp_folder()): os.makedirs(self.get_temp_folder()) if self.controller.mudrawbin: runlog = check_output([ self.controller.mudrawbin, '-w', str(size.width()), '-h', str(size.height()), '-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path ], startupinfo=self.startupinfo) elif self.controller.gsbin: resolution = self.gs_get_resolution(size) runlog = check_output([ self.controller.gsbin, '-dSAFER', '-dNOPAUSE', '-dBATCH', '-sDEVICE=png16m', '-r' + str(resolution), '-dTextAlphaBits=4', '-dGraphicsAlphaBits=4', '-sOutputFile=' + os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path ], startupinfo=self.startupinfo) created_files = sorted(os.listdir(self.get_temp_folder())) for fn in created_files: if os.path.isfile(os.path.join(self.get_temp_folder(), fn)): self.image_files.append( os.path.join(self.get_temp_folder(), fn)) except Exception as e: log.debug(e) log.debug(runlog) return False self.num_pages = len(self.image_files) # Create thumbnails self.create_thumbnails() return True
def setUp(self): """ Create the UI """ Registry.create() self.setup_application() ScreenList.create(self.app.desktop()) self.image_manager = ImageManager() self.lock = Lock() self.sleep_time = 0.1
def __init__(self, parent): """ Initialise the general settings tab """ self.logo_file = ':/graphics/openlp-splash-screen.png' self.logo_background_color = '#ffffff' self.screens = ScreenList() self.icon_path = ':/icon/openlp-logo-16x16.png' general_translated = translate('OpenLP.GeneralTab', 'General') super(GeneralTab, self).__init__(parent, 'Core', general_translated)
def load_presentation(self): """ Called when a presentation is added to the SlideController. It generates images from the PDF. :return: True is loading succeeded, otherwise False. """ log.debug('load_presentation pdf') # Check if the images has already been created, and if yes load them if os.path.isfile(os.path.join(self.get_temp_folder(), 'mainslide001.png')): created_files = sorted(os.listdir(self.get_temp_folder())) for fn in created_files: if os.path.isfile(os.path.join(self.get_temp_folder(), fn)): self.image_files.append(os.path.join(self.get_temp_folder(), fn)) self.num_pages = len(self.image_files) return True size = ScreenList().current['size'] # Generate images from PDF that will fit the frame. runlog = '' try: if not os.path.isdir(self.get_temp_folder()): os.makedirs(self.get_temp_folder()) if self.controller.mudrawbin: log.debug('loading presentation using mudraw') # TODO: Find out where the string conversion actually happens runlog = check_output([self.controller.mudrawbin, '-w', str(size.width()), '-h', str(size.height()), '-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path], startupinfo=self.startupinfo) elif self.controller.mutoolbin: log.debug('loading presentation using mutool') # TODO: Find out where the string convertsion actually happens runlog = check_output([self.controller.mutoolbin, 'draw', '-w', str(size.width()), '-h', str(size.height()), '-o', os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path], startupinfo=self.startupinfo) elif self.controller.gsbin: log.debug('loading presentation using gs') resolution = self.gs_get_resolution(size) # TODO: Find out where the string conversion actually happens runlog = check_output([self.controller.gsbin, '-dSAFER', '-dNOPAUSE', '-dBATCH', '-sDEVICE=png16m', '-r' + str(resolution), '-dTextAlphaBits=4', '-dGraphicsAlphaBits=4', '-sOutputFile=' + os.path.join(self.get_temp_folder(), 'mainslide%03d.png'), self.file_path], startupinfo=self.startupinfo) created_files = sorted(os.listdir(self.get_temp_folder())) for fn in created_files: if os.path.isfile(os.path.join(self.get_temp_folder(), fn)): self.image_files.append(os.path.join(self.get_temp_folder(), fn)) except Exception as e: log.debug(e) log.debug(runlog) return False self.num_pages = len(self.image_files) # Create thumbnails self.create_thumbnails() return True
def setUp(self): """ Create the UI """ Registry.create() self.app = QtGui.QApplication([]) ScreenList.create(self.app.desktop()) Registry().register('application', MagicMock()) with patch('openlp.core.lib.PluginManager'): self.main_window = MainWindow() self.service_manager = Registry().get('service_manager')
def unblank_screen(self): """ Unblanks (restores) the presentation. """ log.debug('unblank_screen') try: self.presentation.SlideShowWindow.Activate() self.presentation.SlideShowWindow.View.State = 1 # Unblanking is broken in PowerPoint 2010 (14.0), need to redisplay if 15.0 > float(self.presentation.Application.Version) >= 14.0: self.presentation.SlideShowWindow.View.GotoSlide( self.index_map[self.blank_slide], False) if self.blank_click: self.presentation.SlideShowWindow.View.GotoClick( self.blank_click) except (AttributeError, pywintypes.com_error) as e: log.exception('Caught exception while in unblank_screen') log.exception(e) trace_error_handler(log) self.show_error_msg() # Stop powerpoint from flashing in the taskbar if self.presentation_hwnd: win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0) # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup if len(ScreenList().screen_list) > 1: Registry().get('main_window').activateWindow()
def load_presentation(self): """ Called when a presentation is added to the SlideController. Opens the PowerPoint file using the process created earlier. """ log.debug('load_presentation') try: if not self.controller.process: self.controller.start_process() self.controller.process.Presentations.Open( os.path.normpath(self.file_path), False, False, False) self.presentation = self.controller.process.Presentations( self.controller.process.Presentations.Count) self.create_thumbnails() self.create_titles_and_notes() # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup if len(ScreenList().screen_list) > 1: Registry().get('main_window').activateWindow() return True except (AttributeError, pywintypes.com_error) as e: log.exception( 'Exception caught while loading Powerpoint presentation') log.exception(e) trace_error_handler(log) return False
def load_presentation(self): """ Called when a presentation is added to the SlideController. It builds the environment, starts communcations with the background OpenOffice task started earlier. If OpenOffice is not present is is started. Once the environment is available the presentation is loaded and started. """ log.debug('Load Presentation OpenOffice') if is_win(): desktop = self.controller.get_com_desktop() if desktop is None: self.controller.start_process() desktop = self.controller.get_com_desktop() url = 'file:///' + self.file_path.replace('\\', '/').replace( ':', '|').replace(' ', '%20') else: desktop = self.controller.get_uno_desktop() url = uno.systemPathToFileUrl(self.file_path) if desktop is None: return False self.desktop = desktop properties = [] properties.append(self.create_property('Hidden', True)) properties = tuple(properties) try: self.document = desktop.loadComponentFromURL( url, '_blank', 0, properties) except: log.warning('Failed to load presentation %s' % url) return False self.presentation = self.document.getPresentation() self.presentation.Display = ScreenList().current['number'] + 1 self.control = None self.create_thumbnails() self.create_titles_and_notes() return True
def __init__(self, parent): """ Initialise the general settings tab """ self.screens = ScreenList() self.iconPath = u':/icon/openlp-logo-16x16.png' generalTranslated = translate('OpenLP.GeneralTab', 'General') SettingsTab.__init__(self, parent, u'General', generalTranslated)
def load_presentation(self): """ Called when a presentation is added to the SlideController. It builds the environment, starts communication with the background PptView task started earlier. """ log.debug('LoadPresentation') size = ScreenList().current['size'] rect = RECT(size.x(), size.y(), size.right(), size.bottom()) filepath = str(self.filepath.replace('/', '\\')) if not os.path.isdir(self.get_temp_folder()): os.makedirs(self.get_temp_folder()) self.ppt_id = self.controller.process.OpenPPT(filepath, None, rect, str(self.get_temp_folder()) + '\\slide') if self.ppt_id >= 0: self.create_thumbnails() self.stop_presentation() return True else: return False
def run(self, args): """ Run the OpenLP application. """ self.is_event_loop_active = False # On Windows, the args passed into the constructor are ignored. Not # very handy, so set the ones we want to use. On Linux and FreeBSD, in # order to set the WM_CLASS property for X11, we pass "OpenLP" in as a # command line argument. This interferes with files being passed in as # command line arguments, so we remove it from the list. if 'OpenLP' in args: args.remove('OpenLP') self.args.extend(args) # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings has_run_wizard = Settings().value(u'general/has run wizard') if not has_run_wizard: if FirstTimeForm(screens).exec_() == QtGui.QDialog.Accepted: Settings().setValue(u'general/has run wizard', True) # Correct stylesheet bugs application_stylesheet = u'' if not Settings().value(u'advanced/alternate rows'): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_rows_repair_stylesheet = \ u'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += alternate_rows_repair_stylesheet if os.name == u'nt': application_stylesheet += nt_repair_stylesheet if application_stylesheet: self.setStyleSheet(application_stylesheet) show_splash = Settings().value(u'general/show splash') if show_splash: self.splash = SplashScreen() self.splash.show() # make sure Qt really display the splash screen self.processEvents() # start the main app window self.main_window = MainWindow() self.main_window.show() if show_splash: # now kill the splashscreen self.splash.finish(self.main_window) log.debug(u'Splashscreen closed') # make sure Qt really display the splash screen self.processEvents() self.main_window.repaint() self.processEvents() if not has_run_wizard: self.main_window.first_time() update_check = Settings().value(u'general/update check') if update_check: VersionThread(self.main_window).start() Receiver.send_message(u'live_display_blank_check') self.main_window.app_startup() return self.exec_()
def setUp(self): """ Set up the components need for all tests """ # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) Registry.create()
def update_display(self): """ Screen has changed size so rebuild the cache to new size. """ log.debug('update_display') current_screen = ScreenList().current self.width = current_screen['size'].width() self.height = current_screen['size'].height() # Mark the images as dirty for a rebuild by setting the image and byte stream to None. for image in list(self._cache.values()): self._reset_image(image)
def start_presentation(self): """ Starts a presentation from the beginning. """ log.debug('start_presentation') #SlideShowWindow measures its size/position by points, not pixels try: dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88) except win32ui.error: try: dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88) except win32ui.error: dpi = 96 size = ScreenList().current['size'] ppt_window = self.presentation.SlideShowSettings.Run() if not ppt_window: return ppt_window.Top = size.y() * 72 / dpi ppt_window.Height = size.height() * 72 / dpi ppt_window.Left = size.x() * 72 / dpi ppt_window.Width = size.width() * 72 / dpi
def setUp(self): """ Create the UI """ Registry.create() self.setup_application() ScreenList.create(self.app.desktop()) Registry().register('application', MagicMock()) # Mock classes and methods used by mainwindow. with patch('openlp.core.ui.mainwindow.SettingsForm') as mocked_settings_form, \ patch('openlp.core.ui.mainwindow.ImageManager') as mocked_image_manager, \ patch('openlp.core.ui.mainwindow.LiveController') as mocked_live_controller, \ patch('openlp.core.ui.mainwindow.PreviewController') as mocked_preview_controller, \ patch('openlp.core.ui.mainwindow.OpenLPDockWidget') as mocked_dock_widget, \ patch('openlp.core.ui.mainwindow.QtWidgets.QToolBox') as mocked_q_tool_box_class, \ patch('openlp.core.ui.mainwindow.QtWidgets.QMainWindow.addDockWidget') as mocked_add_dock_method, \ patch('openlp.core.ui.mainwindow.ThemeManager') as mocked_theme_manager, \ patch('openlp.core.ui.mainwindow.ProjectorManager') as mocked_projector_manager, \ patch('openlp.core.ui.mainwindow.Renderer') as mocked_renderer: self.main_window = MainWindow() self.service_manager = Registry().get('service_manager')
def set_default_header_footer(self): """ Set the header and footer size into the current primary screen. 10 px on each side is removed to allow for a border. """ current_screen = ScreenList().current self.font_main_y = 0 self.font_main_width = current_screen['size'].width() - 20 self.font_main_height = current_screen['size'].height() * 9 / 10 self.font_footer_width = current_screen['size'].width() - 20 self.font_footer_y = current_screen['size'].height() * 9 / 10 self.font_footer_height = current_screen['size'].height() / 10
def __init__(self): """ Constructor for the image manager. """ super(ImageManager, self).__init__() Registry().register('image_manager', self) current_screen = ScreenList().current self.width = current_screen['size'].width() self.height = current_screen['size'].height() self._cache = {} self.image_thread = ImageThread(self) self._conversion_queue = PriorityQueue() self.stop_manager = False Registry().register_function('images_regenerate', self.process_updates)
def load_presentation(self): """ Called when a presentation is added to the SlideController. It builds the environment, starts communication with the background PptView task started earlier. """ log.debug('LoadPresentation') temp_folder = self.get_temp_folder() size = ScreenList().current['size'] rect = RECT(size.x(), size.y(), size.right(), size.bottom()) self.file_path = os.path.normpath(self.file_path) preview_path = os.path.join(temp_folder, 'slide') # Ensure that the paths are null terminated byte_file_path = self.file_path.encode('utf-16-le') + b'\0' preview_path = preview_path.encode('utf-16-le') + b'\0' if not os.path.isdir(temp_folder): os.makedirs(temp_folder) self.ppt_id = self.controller.process.OpenPPT(byte_file_path, None, rect, preview_path) if self.ppt_id >= 0: self.create_thumbnails() self.stop_presentation() return True else: return False
def start_presentation(self): """ Starts a presentation from the beginning. """ log.debug('start_presentation') # SlideShowWindow measures its size/position by points, not pixels # https://technet.microsoft.com/en-us/library/dn528846.aspx try: dpi = win32ui.GetActiveWindow().GetDC().GetDeviceCaps(88) except win32ui.error: try: dpi = win32ui.GetForegroundWindow().GetDC().GetDeviceCaps(88) except win32ui.error: dpi = 96 size = ScreenList().current['size'] ppt_window = None try: ppt_window = self.presentation.SlideShowSettings.Run() except (AttributeError, pywintypes.com_error) as e: log.exception('Caught exception while in start_presentation') log.exception(e) trace_error_handler(log) self.show_error_msg() if ppt_window and not Settings().value('presentations/powerpoint control window'): try: ppt_window.Top = size.y() * 72 / dpi ppt_window.Height = size.height() * 72 / dpi ppt_window.Left = size.x() * 72 / dpi ppt_window.Width = size.width() * 72 / dpi except AttributeError as e: log.exception('AttributeError while in start_presentation') log.exception(e) # Find the presentation window and save the handle for later self.presentation_hwnd = None if ppt_window: log.debug('main display size: y=%d, height=%d, x=%d, width=%d' % (size.y(), size.height(), size.x(), size.width())) win32gui.EnumWindows(self._window_enum_callback, size) # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup if len(ScreenList().screen_list) > 1: Registry().get('main_window').activateWindow()
def setUp(self): """ Set up the components need for all tests. """ # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.application = QtGui.QApplication.instance() Registry.create() self.application.setOrganizationName('OpenLP-tests') self.application.setOrganizationDomain('openlp.org') self.screens = ScreenList.create(self.desktop)
def setUp(self): """ Some pre-test setup required. """ self.dummy1 = MagicMock() self.dummy2 = MagicMock() self.dummy3 = MagicMock() self.desktop = MagicMock() self.setup_application() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) Registry.create() self.form = settingsform.SettingsForm()
def setUp(self): """ Set up the components need for all tests. """ self.setup_application() self.build_settings() # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = SCREEN['primary'] self.desktop.screenCount.return_value = SCREEN['number'] self.desktop.screenGeometry.return_value = SCREEN['size'] self.screens = ScreenList.create(self.desktop) Settings().extend_default_settings(__default_settings__) self.temp_folder = mkdtemp() self.thumbnail_folder = mkdtemp() self.mock_plugin = MagicMock() self.mock_plugin.settings_section = self.temp_folder
def setUp(self): """ Set up the components need for all tests. """ # Mocked out desktop object self.desktop = MagicMock() self.desktop.primaryScreen.return_value = 0 self.desktop.screenCount.return_value = 2 self.desktop.screenGeometry.side_effect = lambda x: {0: QtCore.QRect(0, 0, 1024, 768), 1: QtCore.QRect(0, 0, 1024, 768)}[x] self.screens = ScreenList.create(self.desktop) Registry.create() self.registry = Registry() self.setup_application() Registry().register('application', self.app) self.mocked_audio_player = patch('openlp.core.ui.maindisplay.AudioPlayer') self.mocked_audio_player.start()
def __init__(self, parent=None, name=None, icon=None): """ Initialise the DockWidget """ log.debug('Initialise the %s widget' % name) super(OpenLPDockWidget, self).__init__(parent) if name: self.setObjectName(name) if icon: self.setWindowIcon(build_icon(icon)) # Sort out the minimum width. screens = ScreenList() main_window_docbars = screens.current['size'].width() // 5 if main_window_docbars > 300: self.setMinimumWidth(300) else: self.setMinimumWidth(main_window_docbars)
def close_presentation(self): """ Close presentation and clean up objects. This is triggered by a new object being added to SlideController or OpenLP being shut down. """ log.debug('ClosePresentation') if self.presentation: try: self.presentation.Close() except (AttributeError, pywintypes.com_error) as e: log.exception('Caught exception while closing powerpoint presentation') log.exception(e) trace_error_handler(log) self.presentation = None self.controller.remove_doc(self) # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup if len(ScreenList().screen_list) > 1: Registry().get('main_window').activateWindow()
def __init__(self): """ Initialise the renderer. """ super(Renderer, self).__init__(None) # Need live behaviour if this is also working as a pseudo MainDisplay. self.screens = ScreenList() self.theme_level = ThemeLevel.Global self.global_theme_name = '' self.service_theme_name = '' self.item_theme_name = '' self.force_page = False self._theme_dimensions = {} self._calculate_default() self.web = QtWebKitWidgets.QWebView() self.web.setVisible(False) self.web_frame = self.web.page().mainFrame() Registry().register_function('theme_update_global', self.set_global_theme)
def __init__(self, parent): """ Constructor """ super(MainDisplay, self).__init__(parent) self.screens = ScreenList() self.rebuild_css = False self.hide_mode = None self.override = {} self.retranslateUi() self.media_object = None if self.is_live and PHONON_AVAILABLE: self.audio_player = AudioPlayer(self) else: self.audio_player = None self.first_time = True self.web_loaded = True self.setStyleSheet(OPAQUE_STYLESHEET) window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint if Settings().value('advanced/x11 bypass wm'): window_flags |= QtCore.Qt.X11BypassWindowManagerHint # TODO: The following combination of window_flags works correctly # on Mac OS X. For next OpenLP version we should test it on other # platforms. For OpenLP 2.0 keep it only for OS X to not cause any # regressions on other platforms. if is_macosx(): window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window # For primary screen ensure it stays above the OS X dock # and menu bar if self.screens.current['primary']: self.setWindowState(QtCore.Qt.WindowFullScreen) else: window_flags |= QtCore.Qt.WindowStaysOnTopHint self.setWindowFlags(window_flags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.set_transparency(False) if self.is_live: Registry().register_function('live_display_hide', self.hide_display) Registry().register_function('live_display_show', self.show_display) Registry().register_function('update_display_css', self.css_changed)
def start_presentation(self): """ Start the presentation from the beginning. """ log.debug('start presentation OpenOffice') if self.control is None or not self.control.isRunning(): window = self.document.getCurrentController().getFrame().getContainerWindow() window.setVisible(True) self.presentation.start() self.control = self.presentation.getController() # start() returns before the Component is ready. Try for 15 seconds. sleep_count = 1 while not self.control and sleep_count < 150: time.sleep(0.1) sleep_count += 1 self.control = self.presentation.getController() window.setVisible(False) else: self.control.activate() self.goto_slide(1) # Make sure impress doesn't steal focus, unless we're on a single screen setup if len(ScreenList().screen_list) > 1: Registry().get('main_window').activateWindow()
def next_step(self): """ Triggers the next effect of slide on the running presentation. """ log.debug('next_step') try: self.presentation.SlideShowWindow.Activate() self.presentation.SlideShowWindow.View.Next() except (AttributeError, pywintypes.com_error) as e: log.exception('Caught exception while in next_step') log.exception(e) trace_error_handler(log) self.show_error_msg() return if self.get_slide_number() > self.get_slide_count(): log.debug('past end, stepping back to previous') self.previous_step() # Stop powerpoint from flashing in the taskbar if self.presentation_hwnd: win32gui.FlashWindowEx(self.presentation_hwnd, win32con.FLASHW_STOP, 0, 0) # Make sure powerpoint doesn't steal focus, unless we're on a single screen setup if len(ScreenList().screen_list) > 1: Registry().get('main_window').activateWindow()
def run(self, args): """ Run the OpenLP application. :param args: Some Args """ self.is_event_loop_active = False # On Windows, the args passed into the constructor are ignored. Not very handy, so set the ones we want to use. # On Linux and FreeBSD, in order to set the WM_CLASS property for X11, we pass "OpenLP" in as a command line # argument. This interferes with files being passed in as command line arguments, so we remove it from the list. if 'OpenLP' in args: args.remove('OpenLP') self.args.extend(args) # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings has_run_wizard = Settings().value('core/has run wizard') if not has_run_wizard: ftw = FirstTimeForm() ftw.initialize(screens) if ftw.exec() == QtWidgets.QDialog.Accepted: Settings().setValue('core/has run wizard', True) elif ftw.was_cancelled: QtCore.QCoreApplication.exit() sys.exit() # Correct stylesheet bugs application_stylesheet = '' if not Settings().value('advanced/alternate rows'): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_rows_repair_stylesheet = \ 'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += alternate_rows_repair_stylesheet if is_win(): application_stylesheet += WIN_REPAIR_STYLESHEET if application_stylesheet: self.setStyleSheet(application_stylesheet) can_show_splash = Settings().value('core/show splash') if can_show_splash: self.splash = SplashScreen() self.splash.show() # make sure Qt really display the splash screen self.processEvents() # Check if OpenLP has been upgrade and if a backup of data should be created self.backup_on_upgrade(has_run_wizard, can_show_splash) # start the main app window self.main_window = MainWindow() Registry().execute('bootstrap_initialise') Registry().execute('bootstrap_post_set_up') Registry().initialise = False self.main_window.show() if can_show_splash: # now kill the splashscreen self.splash.finish(self.main_window) log.debug('Splashscreen closed') # make sure Qt really display the splash screen self.processEvents() self.main_window.repaint() self.processEvents() if not has_run_wizard: self.main_window.first_time() update_check = Settings().value('core/update check') if update_check: version = VersionThread(self.main_window) version.start() self.main_window.is_display_blank() self.main_window.app_startup() return self.exec()
class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. """ def __init__(self, parent): """ Initialise the general settings tab """ self.screens = ScreenList() self.iconPath = u':/icon/openlp-logo-16x16.png' generalTranslated = translate('OpenLP.GeneralTab', 'General') SettingsTab.__init__(self, parent, u'General', generalTranslated) def setupUi(self): """ Create the user interface for the general settings tab """ self.setObjectName(u'GeneralTab') SettingsTab.setupUi(self) self.tabLayout.setStretch(1, 1) # Monitors self.monitorGroupBox = QtGui.QGroupBox(self.leftColumn) self.monitorGroupBox.setObjectName(u'monitorGroupBox') self.monitorLayout = QtGui.QGridLayout(self.monitorGroupBox) self.monitorLayout.setObjectName(u'monitorLayout') self.monitorRadioButton = QtGui.QRadioButton(self.monitorGroupBox) self.monitorRadioButton.setObjectName(u'monitorRadioButton') self.monitorLayout.addWidget(self.monitorRadioButton, 0, 0, 1, 5) self.monitorComboBox = QtGui.QComboBox(self.monitorGroupBox) self.monitorComboBox.setObjectName(u'monitorComboBox') self.monitorLayout.addWidget(self.monitorComboBox, 1, 1, 1, 4) # Display Position self.overrideRadioButton = QtGui.QRadioButton(self.monitorGroupBox) self.overrideRadioButton.setObjectName(u'overrideRadioButton') self.monitorLayout.addWidget(self.overrideRadioButton, 2, 0, 1, 5) # Custom position self.customXLabel = QtGui.QLabel(self.monitorGroupBox) self.customXLabel.setObjectName(u'customXLabel') self.monitorLayout.addWidget(self.customXLabel, 3, 1) self.customXValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customXValueEdit.setObjectName(u'customXValueEdit') self.customXValueEdit.setRange(-9999, 9999) self.monitorLayout.addWidget(self.customXValueEdit, 4, 1) self.customYLabel = QtGui.QLabel(self.monitorGroupBox) self.customYLabel.setObjectName(u'customYLabel') self.monitorLayout.addWidget(self.customYLabel, 3, 2) self.customYValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customYValueEdit.setObjectName(u'customYValueEdit') self.customYValueEdit.setRange(-9999, 9999) self.monitorLayout.addWidget(self.customYValueEdit, 4, 2) self.customWidthLabel = QtGui.QLabel(self.monitorGroupBox) self.customWidthLabel.setObjectName(u'customWidthLabel') self.monitorLayout.addWidget(self.customWidthLabel, 3, 3) self.customWidthValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customWidthValueEdit.setObjectName(u'customWidthValueEdit') self.customWidthValueEdit.setMaximum(9999) self.monitorLayout.addWidget(self.customWidthValueEdit, 4, 3) self.customHeightLabel = QtGui.QLabel(self.monitorGroupBox) self.customHeightLabel.setObjectName(u'customHeightLabel') self.monitorLayout.addWidget(self.customHeightLabel, 3, 4) self.customHeightValueEdit = QtGui.QSpinBox(self.monitorGroupBox) self.customHeightValueEdit.setObjectName(u'customHeightValueEdit') self.customHeightValueEdit.setMaximum(9999) self.monitorLayout.addWidget(self.customHeightValueEdit, 4, 4) self.displayOnMonitorCheck = QtGui.QCheckBox(self.monitorGroupBox) self.displayOnMonitorCheck.setObjectName(u'monitorComboBox') self.monitorLayout.addWidget(self.displayOnMonitorCheck, 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.monitorLayout.setColumnStretch(0, 1) self.monitorLayout.setColumnStretch(1, 3) self.monitorLayout.setColumnStretch(2, 3) self.monitorLayout.setColumnStretch(3, 3) self.monitorLayout.setColumnStretch(4, 3) self.leftLayout.addWidget(self.monitorGroupBox) # CCLI Details self.ccliGroupBox = QtGui.QGroupBox(self.leftColumn) self.ccliGroupBox.setObjectName(u'ccliGroupBox') self.ccliLayout = QtGui.QFormLayout(self.ccliGroupBox) self.ccliLayout.setObjectName(u'ccliLayout') self.numberLabel = QtGui.QLabel(self.ccliGroupBox) self.numberLabel.setObjectName(u'numberLabel') self.numberEdit = QtGui.QLineEdit(self.ccliGroupBox) self.numberEdit.setValidator(QtGui.QIntValidator()) self.numberEdit.setObjectName(u'numberEdit') self.ccliLayout.addRow(self.numberLabel, self.numberEdit) self.usernameLabel = QtGui.QLabel(self.ccliGroupBox) self.usernameLabel.setObjectName(u'usernameLabel') self.usernameEdit = QtGui.QLineEdit(self.ccliGroupBox) self.usernameEdit.setObjectName(u'usernameEdit') self.ccliLayout.addRow(self.usernameLabel, self.usernameEdit) self.passwordLabel = QtGui.QLabel(self.ccliGroupBox) self.passwordLabel.setObjectName(u'passwordLabel') self.passwordEdit = QtGui.QLineEdit(self.ccliGroupBox) self.passwordEdit.setEchoMode(QtGui.QLineEdit.Password) self.passwordEdit.setObjectName(u'passwordEdit') self.ccliLayout.addRow(self.passwordLabel, self.passwordEdit) self.leftLayout.addWidget(self.ccliGroupBox) # Background audio self.audioGroupBox = QtGui.QGroupBox(self.leftColumn) self.audioGroupBox.setObjectName(u'audioGroupBox') self.audioLayout = QtGui.QVBoxLayout(self.audioGroupBox) self.audioLayout.setObjectName(u'audioLayout') self.startPausedCheckBox = QtGui.QCheckBox(self.audioGroupBox) self.startPausedCheckBox.setObjectName(u'startPausedCheckBox') self.audioLayout.addWidget(self.startPausedCheckBox) self.repeatListCheckBox = QtGui.QCheckBox(self.audioGroupBox) self.repeatListCheckBox.setObjectName(u'repeatListCheckBox') self.audioLayout.addWidget(self.repeatListCheckBox) self.leftLayout.addWidget(self.audioGroupBox) self.leftLayout.addStretch() # Application Startup self.startupGroupBox = QtGui.QGroupBox(self.rightColumn) self.startupGroupBox.setObjectName(u'startupGroupBox') self.startupLayout = QtGui.QVBoxLayout(self.startupGroupBox) self.startupLayout.setObjectName(u'startupLayout') self.warningCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.warningCheckBox.setObjectName(u'warningCheckBox') self.startupLayout.addWidget(self.warningCheckBox) self.autoOpenCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.autoOpenCheckBox.setObjectName(u'autoOpenCheckBox') self.startupLayout.addWidget(self.autoOpenCheckBox) self.showSplashCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.showSplashCheckBox.setObjectName(u'showSplashCheckBox') self.startupLayout.addWidget(self.showSplashCheckBox) self.checkForUpdatesCheckBox = QtGui.QCheckBox(self.startupGroupBox) self.checkForUpdatesCheckBox.setObjectName(u'checkForUpdatesCheckBox') self.startupLayout.addWidget(self.checkForUpdatesCheckBox) self.rightLayout.addWidget(self.startupGroupBox) # Application Settings self.settingsGroupBox = QtGui.QGroupBox(self.rightColumn) self.settingsGroupBox.setObjectName(u'settingsGroupBox') self.settingsLayout = QtGui.QFormLayout(self.settingsGroupBox) self.settingsLayout.setObjectName(u'settingsLayout') self.saveCheckServiceCheckBox = QtGui.QCheckBox(self.settingsGroupBox) self.saveCheckServiceCheckBox.setObjectName(u'saveCheckServiceCheckBox') self.settingsLayout.addRow(self.saveCheckServiceCheckBox) self.autoUnblankCheckBox = QtGui.QCheckBox(self.settingsGroupBox) self.autoUnblankCheckBox.setObjectName(u'autoUnblankCheckBox') self.settingsLayout.addRow(self.autoUnblankCheckBox) self.autoPreviewCheckBox = QtGui.QCheckBox(self.settingsGroupBox) self.autoPreviewCheckBox.setObjectName(u'autoPreviewCheckBox') self.settingsLayout.addRow(self.autoPreviewCheckBox) # Moved here from image tab self.timeoutLabel = QtGui.QLabel(self.settingsGroupBox) self.timeoutLabel.setObjectName(u'timeoutLabel') self.timeoutSpinBox = QtGui.QSpinBox(self.settingsGroupBox) self.timeoutSpinBox.setObjectName(u'timeoutSpinBox') self.timeoutSpinBox.setRange(1, 180) self.settingsLayout.addRow(self.timeoutLabel, self.timeoutSpinBox) self.rightLayout.addWidget(self.settingsGroupBox) self.rightLayout.addStretch() # Signals and slots QtCore.QObject.connect(self.overrideRadioButton, QtCore.SIGNAL(u'toggled(bool)'), self.onOverrideRadioButtonPressed) QtCore.QObject.connect(self.customHeightValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) QtCore.QObject.connect(self.customWidthValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) QtCore.QObject.connect(self.customYValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) QtCore.QObject.connect(self.customXValueEdit, QtCore.SIGNAL(u'valueChanged(int)'), self.onDisplayChanged) QtCore.QObject.connect(self.monitorComboBox, QtCore.SIGNAL(u'currentIndexChanged(int)'), self.onDisplayChanged) # Reload the tab, as the screen resolution/count may have changed. QtCore.QObject.connect(Receiver.get_receiver(), QtCore.SIGNAL(u'config_screen_changed'), self.load) # Remove for now self.usernameLabel.setVisible(False) self.usernameEdit.setVisible(False) self.passwordLabel.setVisible(False) self.passwordEdit.setVisible(False) def retranslateUi(self): """ Translate the general settings tab to the currently selected language """ self.tabTitleVisible = translate('OpenLP.GeneralTab', 'General') self.monitorGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Monitors')) self.monitorRadioButton.setText(translate('OpenLP.GeneralTab', 'Select monitor for output display:')) self.displayOnMonitorCheck.setText(translate('OpenLP.GeneralTab', 'Display if a single screen')) self.startupGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Application Startup')) self.warningCheckBox.setText(translate('OpenLP.GeneralTab', 'Show blank screen warning')) self.autoOpenCheckBox.setText(translate('OpenLP.GeneralTab', 'Automatically open the last service')) self.showSplashCheckBox.setText(translate('OpenLP.GeneralTab', 'Show the splash screen')) self.checkForUpdatesCheckBox.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) self.settingsGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Application Settings')) self.saveCheckServiceCheckBox.setText(translate('OpenLP.GeneralTab', 'Prompt to save before starting a new service')) self.autoUnblankCheckBox.setText(translate('OpenLP.GeneralTab', 'Unblank display when adding new live item')) self.autoPreviewCheckBox.setText(translate('OpenLP.GeneralTab', 'Automatically preview next item in service')) self.timeoutLabel.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:')) self.timeoutSpinBox.setSuffix(translate('OpenLP.GeneralTab', ' sec')) self.ccliGroupBox.setTitle(translate('OpenLP.GeneralTab', 'CCLI Details')) self.numberLabel.setText(UiStrings().CCLINumberLabel) self.usernameLabel.setText(translate('OpenLP.GeneralTab', 'SongSelect username:'******'OpenLP.GeneralTab', 'SongSelect password:'******'OpenLP.GeneralTab', 'Override display position:')) self.customXLabel.setText(translate('OpenLP.GeneralTab', 'X')) self.customYLabel.setText(translate('OpenLP.GeneralTab', 'Y')) self.customHeightLabel.setText(translate('OpenLP.GeneralTab', 'Height')) self.customWidthLabel.setText(translate('OpenLP.GeneralTab', 'Width')) self.audioGroupBox.setTitle(translate('OpenLP.GeneralTab', 'Background Audio')) self.startPausedCheckBox.setText(translate('OpenLP.GeneralTab', 'Start background audio paused')) self.repeatListCheckBox.setText(translate('OpenLP.GeneralTab', 'Repeat track list')) def load(self): """ Load the settings to populate the form """ settings = Settings() settings.beginGroup(self.settingsSection) self.monitorComboBox.clear() self.monitorComboBox.addItems(self.screens.get_screen_list()) monitorNumber = settings.value(u'monitor') self.monitorComboBox.setCurrentIndex(monitorNumber) self.numberEdit.setText(settings.value(u'ccli number')) self.usernameEdit.setText(settings.value(u'songselect username')) self.passwordEdit.setText(settings.value(u'songselect password')) self.saveCheckServiceCheckBox.setChecked(settings.value(u'save prompt')) self.autoUnblankCheckBox.setChecked(settings.value(u'auto unblank')) self.displayOnMonitorCheck.setChecked(self.screens.display) self.warningCheckBox.setChecked(settings.value(u'blank warning')) self.autoOpenCheckBox.setChecked(settings.value(u'auto open')) self.showSplashCheckBox.setChecked(settings.value(u'show splash')) self.checkForUpdatesCheckBox.setChecked(settings.value(u'update check')) self.autoPreviewCheckBox.setChecked(settings.value(u'auto preview')) self.timeoutSpinBox.setValue(settings.value(u'loop delay')) self.monitorRadioButton.setChecked(not settings.value(u'override position',)) self.overrideRadioButton.setChecked(settings.value(u'override position')) self.customXValueEdit.setValue(settings.value(u'x position')) self.customYValueEdit.setValue(settings.value(u'y position')) self.customHeightValueEdit.setValue(settings.value(u'height')) self.customWidthValueEdit.setValue(settings.value(u'width')) self.startPausedCheckBox.setChecked(settings.value(u'audio start paused')) self.repeatListCheckBox.setChecked(settings.value(u'audio repeat list')) settings.endGroup() self.monitorComboBox.setDisabled(self.overrideRadioButton.isChecked()) self.customXValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customYValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customHeightValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.customWidthValueEdit.setEnabled(self.overrideRadioButton.isChecked()) self.display_changed = False settings.beginGroup(self.settingsSection) def save(self): """ Save the settings from the form """ settings = Settings() settings.beginGroup(self.settingsSection) settings.setValue(u'monitor', self.monitorComboBox.currentIndex()) settings.setValue(u'display on monitor', self.displayOnMonitorCheck.isChecked()) settings.setValue(u'blank warning', self.warningCheckBox.isChecked()) settings.setValue(u'auto open', self.autoOpenCheckBox.isChecked()) settings.setValue(u'show splash', self.showSplashCheckBox.isChecked()) settings.setValue(u'update check', self.checkForUpdatesCheckBox.isChecked()) settings.setValue(u'save prompt', self.saveCheckServiceCheckBox.isChecked()) settings.setValue(u'auto unblank', self.autoUnblankCheckBox.isChecked()) settings.setValue(u'auto preview', self.autoPreviewCheckBox.isChecked()) settings.setValue(u'loop delay', self.timeoutSpinBox.value()) settings.setValue(u'ccli number', self.numberEdit.displayText()) settings.setValue(u'songselect username', self.usernameEdit.displayText()) settings.setValue(u'songselect password', self.passwordEdit.displayText()) settings.setValue(u'x position', self.customXValueEdit.value()) settings.setValue(u'y position', self.customYValueEdit.value()) settings.setValue(u'height', self.customHeightValueEdit.value()) settings.setValue(u'width', self.customWidthValueEdit.value()) settings.setValue(u'override position', self.overrideRadioButton.isChecked()) settings.setValue(u'audio start paused', self.startPausedCheckBox.isChecked()) settings.setValue(u'audio repeat list', self.repeatListCheckBox.isChecked()) settings.endGroup() # On save update the screens as well self.postSetUp(True) def postSetUp(self, postUpdate=False): """ Apply settings after settings tab has loaded and most of the system so must be delayed """ Receiver.send_message(u'slidecontroller_live_spin_delay', self.timeoutSpinBox.value()) # Do not continue on start up. if not postUpdate: return self.screens.set_current_display(self.monitorComboBox.currentIndex()) self.screens.display = self.displayOnMonitorCheck.isChecked() self.screens.override[u'size'] = QtCore.QRect( self.customXValueEdit.value(), self.customYValueEdit.value(), self.customWidthValueEdit.value(), self.customHeightValueEdit.value()) if self.overrideRadioButton.isChecked(): self.screens.set_override_display() else: self.screens.reset_current_display() if self.display_changed: Receiver.send_message(u'config_screen_changed') self.display_changed = False def onOverrideRadioButtonPressed(self, checked): """ Toggle screen state depending on check box state. ``checked`` The state of the check box (boolean). """ self.monitorComboBox.setDisabled(checked) self.customXValueEdit.setEnabled(checked) self.customYValueEdit.setEnabled(checked) self.customHeightValueEdit.setEnabled(checked) self.customWidthValueEdit.setEnabled(checked) self.display_changed = True def onDisplayChanged(self): """ Called when the width, height, x position or y position has changed. """ self.display_changed = True
def __init__(self, parent): """ Constructor """ super(MainDisplay, self).__init__(parent) self.screens = ScreenList() self.rebuild_css = False self.hide_mode = None self.override = {} self.retranslateUi() self.media_object = None if self.is_live: self.audio_player = AudioPlayer(self) else: self.audio_player = None self.first_time = True self.web_loaded = True self.setStyleSheet(OPAQUE_STYLESHEET) window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Tool | QtCore.Qt.WindowStaysOnTopHint if Settings().value('advanced/x11 bypass wm'): window_flags |= QtCore.Qt.X11BypassWindowManagerHint # TODO: The following combination of window_flags works correctly # on Mac OS X. For next OpenLP version we should test it on other # platforms. For OpenLP 2.0 keep it only for OS X to not cause any # regressions on other platforms. if is_macosx(): window_flags = QtCore.Qt.FramelessWindowHint | QtCore.Qt.Window self.setWindowFlags(window_flags) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.set_transparency(False) if is_macosx(): if self.is_live: # Get a pointer to the underlying NSView try: nsview_pointer = self.winId().ascapsule() except: nsview_pointer = voidptr(self.winId()).ascapsule() # Set PyCapsule name so pyobjc will accept it pythonapi.PyCapsule_SetName.restype = c_void_p pythonapi.PyCapsule_SetName.argtypes = [py_object, c_char_p] pythonapi.PyCapsule_SetName(nsview_pointer, c_char_p(b"objc.__object__")) # Covert the NSView pointer into a pyobjc NSView object self.pyobjc_nsview = objc_object(cobject=nsview_pointer) # Set the window level so that the MainDisplay is above the menu bar and dock self.pyobjc_nsview.window().setLevel_(NSMainMenuWindowLevel + 2) # Set the collection behavior so the window is visible when Mission Control is activated self.pyobjc_nsview.window().setCollectionBehavior_( NSWindowCollectionBehaviorManaged) if self.screens.current['primary']: # Connect focusWindowChanged signal so we can change the window level when the display is not in # focus on the primary screen self.application.focusWindowChanged.connect( self.change_window_level) if self.is_live: Registry().register_function('live_display_hide', self.hide_display) Registry().register_function('live_display_show', self.show_display) Registry().register_function('update_display_css', self.css_changed) self.close_display = False
class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. """ def __init__(self, parent): """ Initialise the general settings tab """ self.screens = ScreenList() self.icon_path = ':/icon/openlp-logo-16x16.png' general_translated = translate('OpenLP.GeneralTab', 'General') super(GeneralTab, self).__init__(parent, 'Core', general_translated) def setupUi(self): """ Create the user interface for the general settings tab """ self.setObjectName('GeneralTab') super(GeneralTab, self).setupUi() self.tab_layout.setStretch(1, 1) # Monitors self.monitor_group_box = QtGui.QGroupBox(self.left_column) self.monitor_group_box.setObjectName('monitor_group_box') self.monitor_layout = QtGui.QGridLayout(self.monitor_group_box) self.monitor_layout.setObjectName('monitor_layout') self.monitor_radio_button = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.QGroupBox(self.left_column) self.ccli_group_box.setObjectName('ccli_group_box') self.ccli_layout = QtGui.QFormLayout(self.ccli_group_box) self.ccli_layout.setObjectName('ccli_layout') self.number_label = QtGui.QLabel(self.ccli_group_box) self.number_label.setObjectName('number_label') self.number_edit = QtGui.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 = QtGui.QLabel(self.ccli_group_box) self.username_label.setObjectName('username_label') self.username_edit = QtGui.QLineEdit(self.ccli_group_box) self.username_edit.setObjectName('username_edit') self.ccli_layout.addRow(self.username_label, self.username_edit) self.password_label = QtGui.QLabel(self.ccli_group_box) self.password_label.setObjectName('password_label') self.password_edit = QtGui.QLineEdit(self.ccli_group_box) self.password_edit.setEchoMode(QtGui.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 = QtGui.QGroupBox(self.left_column) self.audio_group_box.setObjectName('audio_group_box') self.audio_layout = QtGui.QVBoxLayout(self.audio_group_box) self.audio_layout.setObjectName('audio_layout') self.start_paused_check_box = QtGui.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 = QtGui.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 = QtGui.QGroupBox(self.right_column) self.startup_group_box.setObjectName('startup_group_box') self.startup_layout = QtGui.QVBoxLayout(self.startup_group_box) self.startup_layout.setObjectName('startup_layout') self.warning_check_box = QtGui.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 = QtGui.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 = QtGui.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 = QtGui.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) # Application Settings self.settings_group_box = QtGui.QGroupBox(self.right_column) self.settings_group_box.setObjectName('settings_group_box') self.settings_layout = QtGui.QFormLayout(self.settings_group_box) self.settings_layout.setObjectName('settings_layout') self.save_check_service_check_box = QtGui.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 = QtGui.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.auto_preview_check_box = QtGui.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 = QtGui.QLabel(self.settings_group_box) self.timeout_label.setObjectName('timeout_label') self.timeout_spin_box = QtGui.QSpinBox(self.settings_group_box) self.timeout_spin_box.setObjectName('timeout_spin_box') self.timeout_spin_box.setRange(1, 180) self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box) self.right_layout.addWidget(self.settings_group_box) self.right_layout.addStretch() # Signals and slots self.override_radio_button.toggled.connect(self.on_override_radio_button_pressed) self.custom_height_value_edit.valueChanged.connect(self.on_display_changed) self.custom_width_value_edit.valueChanged.connect(self.on_display_changed) self.custom_Y_value_edit.valueChanged.connect(self.on_display_changed) self.custom_X_value_edit.valueChanged.connect(self.on_display_changed) self.monitor_combo_box.currentIndexChanged.connect(self.on_display_changed) # Reload the tab, as the screen resolution/count may have changed. Registry().register_function('config_screen_changed', self.load) # Remove for now self.username_label.setVisible(False) self.username_edit.setVisible(False) self.password_label.setVisible(False) self.password_edit.setVisible(False) def retranslateUi(self): """ Translate the general settings tab to the currently selected language """ self.tab_title_visible = translate('OpenLP.GeneralTab', 'General') self.monitor_group_box.setTitle(translate('OpenLP.GeneralTab', 'Monitors')) self.monitor_radio_button.setText(translate('OpenLP.GeneralTab', 'Select monitor for output display:')) self.display_on_monitor_check.setText(translate('OpenLP.GeneralTab', 'Display if a single screen')) self.startup_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Startup')) self.warning_check_box.setText(translate('OpenLP.GeneralTab', 'Show blank screen warning')) self.auto_open_check_box.setText(translate('OpenLP.GeneralTab', 'Automatically open the last service')) self.show_splash_check_box.setText(translate('OpenLP.GeneralTab', 'Show the splash screen')) self.check_for_updates_check_box.setText(translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) self.settings_group_box.setTitle(translate('OpenLP.GeneralTab', 'Application Settings')) self.save_check_service_check_box.setText(translate('OpenLP.GeneralTab', 'Prompt to save before starting a new service')) self.auto_unblank_check_box.setText(translate('OpenLP.GeneralTab', 'Unblank display when adding new live item')) self.auto_preview_check_box.setText(translate('OpenLP.GeneralTab', 'Automatically preview next item in service')) self.timeout_label.setText(translate('OpenLP.GeneralTab', 'Timed slide interval:')) self.timeout_spin_box.setSuffix(translate('OpenLP.GeneralTab', ' sec')) self.ccli_group_box.setTitle(translate('OpenLP.GeneralTab', 'CCLI Details')) self.number_label.setText(UiStrings().CCLINumberLabel) self.username_label.setText(translate('OpenLP.GeneralTab', 'SongSelect username:'******'OpenLP.GeneralTab', 'SongSelect password:'******'OpenLP.GeneralTab', 'Override display position:')) self.custom_x_label.setText(translate('OpenLP.GeneralTab', 'X')) self.custom_y_label.setText(translate('OpenLP.GeneralTab', 'Y')) self.custom_height_label.setText(translate('OpenLP.GeneralTab', 'Height')) self.custom_width_label.setText(translate('OpenLP.GeneralTab', 'Width')) self.audio_group_box.setTitle(translate('OpenLP.GeneralTab', 'Background Audio')) self.start_paused_check_box.setText(translate('OpenLP.GeneralTab', 'Start background audio paused')) self.repeat_list_check_box.setText(translate('OpenLP.GeneralTab', 'Repeat track list')) def load(self): """ Load the settings to populate the form """ settings = Settings() settings.beginGroup(self.settings_section) self.monitor_combo_box.clear() self.monitor_combo_box.addItems(self.screens.get_screen_list()) monitorNumber = settings.value('monitor') self.monitor_combo_box.setCurrentIndex(monitorNumber) self.number_edit.setText(settings.value('ccli number')) self.username_edit.setText(settings.value('songselect username')) self.password_edit.setText(settings.value('songselect password')) self.save_check_service_check_box.setChecked(settings.value('save prompt')) self.auto_unblank_check_box.setChecked(settings.value('auto unblank')) self.display_on_monitor_check.setChecked(self.screens.display) self.warning_check_box.setChecked(settings.value('blank warning')) self.auto_open_check_box.setChecked(settings.value('auto open')) self.show_splash_check_box.setChecked(settings.value('show splash')) self.check_for_updates_check_box.setChecked(settings.value('update check')) self.auto_preview_check_box.setChecked(settings.value('auto preview')) self.timeout_spin_box.setValue(settings.value('loop delay')) self.monitor_radio_button.setChecked(not settings.value('override position',)) self.override_radio_button.setChecked(settings.value('override position')) self.custom_X_value_edit.setValue(settings.value('x position')) self.custom_Y_value_edit.setValue(settings.value('y position')) self.custom_height_value_edit.setValue(settings.value('height')) self.custom_width_value_edit.setValue(settings.value('width')) self.start_paused_check_box.setChecked(settings.value('audio start paused')) self.repeat_list_check_box.setChecked(settings.value('audio repeat list')) settings.endGroup() self.monitor_combo_box.setDisabled(self.override_radio_button.isChecked()) self.custom_X_value_edit.setEnabled(self.override_radio_button.isChecked()) self.custom_Y_value_edit.setEnabled(self.override_radio_button.isChecked()) self.custom_height_value_edit.setEnabled(self.override_radio_button.isChecked()) self.custom_width_value_edit.setEnabled(self.override_radio_button.isChecked()) self.display_changed = False def save(self): """ Save the settings from the form """ settings = Settings() settings.beginGroup(self.settings_section) settings.setValue('monitor', self.monitor_combo_box.currentIndex()) settings.setValue('display on monitor', self.display_on_monitor_check.isChecked()) settings.setValue('blank warning', self.warning_check_box.isChecked()) settings.setValue('auto open', self.auto_open_check_box.isChecked()) settings.setValue('show splash', self.show_splash_check_box.isChecked()) settings.setValue('update check', self.check_for_updates_check_box.isChecked()) settings.setValue('save prompt', self.save_check_service_check_box.isChecked()) settings.setValue('auto unblank', self.auto_unblank_check_box.isChecked()) settings.setValue('auto preview', self.auto_preview_check_box.isChecked()) settings.setValue('loop delay', self.timeout_spin_box.value()) settings.setValue('ccli number', self.number_edit.displayText()) settings.setValue('songselect username', self.username_edit.displayText()) settings.setValue('songselect password', self.password_edit.displayText()) settings.setValue('x position', self.custom_X_value_edit.value()) settings.setValue('y position', self.custom_Y_value_edit.value()) settings.setValue('height', self.custom_height_value_edit.value()) settings.setValue('width', self.custom_width_value_edit.value()) settings.setValue('override position', self.override_radio_button.isChecked()) settings.setValue('audio start paused', self.start_paused_check_box.isChecked()) settings.setValue('audio repeat list', self.repeat_list_check_box.isChecked()) settings.endGroup() # On save update the screens as well self.post_set_up(True) def post_set_up(self, postUpdate=False): """ Apply settings after settings tab has loaded and most of the system so must be delayed """ self.settings_form.register_post_process('slidecontroller_live_spin_delay') # Do not continue on start up. if not postUpdate: return self.screens.set_current_display(self.monitor_combo_box.currentIndex()) self.screens.display = self.display_on_monitor_check.isChecked() self.screens.override['size'] = QtCore.QRect( self.custom_X_value_edit.value(), self.custom_Y_value_edit.value(), self.custom_width_value_edit.value(), self.custom_height_value_edit.value()) if self.override_radio_button.isChecked(): self.screens.set_override_display() else: self.screens.reset_current_display() if self.display_changed: self.settings_form.register_post_process('config_screen_changed') self.display_changed = False def on_override_radio_button_pressed(self, checked): """ Toggle screen state depending on check box state. ``checked`` The state of the check box (boolean). """ self.monitor_combo_box.setDisabled(checked) self.custom_X_value_edit.setEnabled(checked) self.custom_Y_value_edit.setEnabled(checked) self.custom_height_value_edit.setEnabled(checked) self.custom_width_value_edit.setEnabled(checked) self.display_changed = True def on_display_changed(self): """ Called when the width, height, x position or y position has changed. """ self.display_changed = True
def run(self, args): """ Run the OpenLP application. :param args: Some Args """ self.is_event_loop_active = False # On Windows, the args passed into the constructor are ignored. Not very handy, so set the ones we want to use. # On Linux and FreeBSD, in order to set the WM_CLASS property for X11, we pass "OpenLP" in as a command line # argument. This interferes with files being passed in as command line arguments, so we remove it from the list. if 'OpenLP' in args: args.remove('OpenLP') self.args.extend(args) # Decide how many screens we have and their size screens = ScreenList.create(self.desktop()) # First time checks in settings has_run_wizard = Settings().value('core/has run wizard') if not has_run_wizard: ftw = FirstTimeForm() ftw.initialize(screens) if ftw.exec_() == QtGui.QDialog.Accepted: Settings().setValue('core/has run wizard', True) elif ftw.was_cancelled: QtCore.QCoreApplication.exit() sys.exit() # Correct stylesheet bugs application_stylesheet = '' if not Settings().value('advanced/alternate rows'): base_color = self.palette().color(QtGui.QPalette.Active, QtGui.QPalette.Base) alternate_rows_repair_stylesheet = \ 'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: ' + base_color.name() + ';}\n' application_stylesheet += alternate_rows_repair_stylesheet if is_win(): application_stylesheet += WIN_REPAIR_STYLESHEET if application_stylesheet: self.setStyleSheet(application_stylesheet) show_splash = Settings().value('core/show splash') if show_splash: self.splash = SplashScreen() self.splash.show() # make sure Qt really display the splash screen self.processEvents() # Check if OpenLP has been upgrade and if a backup of data should be created self.backup_on_upgrade(has_run_wizard) # start the main app window self.main_window = MainWindow() Registry().execute('bootstrap_initialise') Registry().execute('bootstrap_post_set_up') Registry().initialise = False self.main_window.show() if show_splash: # now kill the splashscreen self.splash.finish(self.main_window) log.debug('Splashscreen closed') # make sure Qt really display the splash screen self.processEvents() self.main_window.repaint() self.processEvents() if not has_run_wizard: self.main_window.first_time() update_check = Settings().value('core/update check') #if update_check: # version = VersionThread(self.main_window) # version.start() self.main_window.is_display_blank() self.main_window.app_startup() return self.exec_()
class GeneralTab(SettingsTab): """ GeneralTab is the general settings tab in the settings dialog. """ def __init__(self, parent): """ Initialise the general settings tab """ self.screens = ScreenList() self.icon_path = ':/icon/openlp-logo-16x16.png' general_translated = translate('OpenLP.GeneralTab', 'General') super(GeneralTab, self).__init__(parent, 'Core', general_translated) def setupUi(self): """ Create the user interface for the general settings tab """ self.setObjectName('GeneralTab') super(GeneralTab, self).setupUi() self.tab_layout.setStretch(1, 1) # Monitors self.monitor_group_box = QtWidgets.QGroupBox(self.left_column) self.monitor_group_box.setObjectName('monitor_group_box') self.monitor_layout = QtWidgets.QGridLayout(self.monitor_group_box) self.monitor_layout.setObjectName('monitor_layout') self.monitor_radio_button = QtWidgets.QRadioButton( self.monitor_group_box) self.monitor_radio_button.setObjectName('monitor_radio_button') self.monitor_layout.addWidget(self.monitor_radio_button, 0, 0, 1, 5) self.monitor_combo_box = QtWidgets.QComboBox(self.monitor_group_box) self.monitor_combo_box.setObjectName('monitor_combo_box') self.monitor_layout.addWidget(self.monitor_combo_box, 1, 1, 1, 4) # Display Position self.override_radio_button = QtWidgets.QRadioButton( self.monitor_group_box) self.override_radio_button.setObjectName('override_radio_button') self.monitor_layout.addWidget(self.override_radio_button, 2, 0, 1, 5) # Custom position self.custom_x_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_x_label.setObjectName('custom_x_label') self.monitor_layout.addWidget(self.custom_x_label, 3, 1) self.custom_X_value_edit = QtWidgets.QSpinBox(self.monitor_group_box) self.custom_X_value_edit.setObjectName('custom_X_value_edit') self.custom_X_value_edit.setRange(-9999, 9999) self.monitor_layout.addWidget(self.custom_X_value_edit, 4, 1) self.custom_y_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_y_label.setObjectName('custom_y_label') self.monitor_layout.addWidget(self.custom_y_label, 3, 2) self.custom_Y_value_edit = QtWidgets.QSpinBox(self.monitor_group_box) self.custom_Y_value_edit.setObjectName('custom_Y_value_edit') self.custom_Y_value_edit.setRange(-9999, 9999) self.monitor_layout.addWidget(self.custom_Y_value_edit, 4, 2) self.custom_width_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_width_label.setObjectName('custom_width_label') self.monitor_layout.addWidget(self.custom_width_label, 3, 3) self.custom_width_value_edit = QtWidgets.QSpinBox( self.monitor_group_box) self.custom_width_value_edit.setObjectName('custom_width_value_edit') self.custom_width_value_edit.setRange(1, 9999) self.monitor_layout.addWidget(self.custom_width_value_edit, 4, 3) self.custom_height_label = QtWidgets.QLabel(self.monitor_group_box) self.custom_height_label.setObjectName('custom_height_label') self.monitor_layout.addWidget(self.custom_height_label, 3, 4) self.custom_height_value_edit = QtWidgets.QSpinBox( self.monitor_group_box) self.custom_height_value_edit.setObjectName('custom_height_value_edit') self.custom_height_value_edit.setRange(1, 9999) self.monitor_layout.addWidget(self.custom_height_value_edit, 4, 4) self.display_on_monitor_check = QtWidgets.QCheckBox( self.monitor_group_box) self.display_on_monitor_check.setObjectName('monitor_combo_box') self.monitor_layout.addWidget(self.display_on_monitor_check, 5, 0, 1, 5) # Set up the stretchiness of each column, so that the first column # less stretchy (and therefore smaller) than the others self.monitor_layout.setColumnStretch(0, 1) self.monitor_layout.setColumnStretch(1, 3) self.monitor_layout.setColumnStretch(2, 3) self.monitor_layout.setColumnStretch(3, 3) self.monitor_layout.setColumnStretch(4, 3) self.left_layout.addWidget(self.monitor_group_box) # CCLI Details self.ccli_group_box = QtWidgets.QGroupBox(self.left_column) self.ccli_group_box.setObjectName('ccli_group_box') self.ccli_layout = QtWidgets.QFormLayout(self.ccli_group_box) self.ccli_layout.setObjectName('ccli_layout') self.number_label = QtWidgets.QLabel(self.ccli_group_box) self.number_label.setObjectName('number_label') self.number_edit = QtWidgets.QLineEdit(self.ccli_group_box) self.number_edit.setValidator(QtGui.QIntValidator()) self.number_edit.setObjectName('number_edit') self.ccli_layout.addRow(self.number_label, self.number_edit) self.username_label = QtWidgets.QLabel(self.ccli_group_box) self.username_label.setObjectName('username_label') self.username_edit = QtWidgets.QLineEdit(self.ccli_group_box) self.username_edit.setObjectName('username_edit') self.ccli_layout.addRow(self.username_label, self.username_edit) self.password_label = QtWidgets.QLabel(self.ccli_group_box) self.password_label.setObjectName('password_label') self.password_edit = QtWidgets.QLineEdit(self.ccli_group_box) self.password_edit.setEchoMode(QtWidgets.QLineEdit.Password) self.password_edit.setObjectName('password_edit') self.ccli_layout.addRow(self.password_label, self.password_edit) self.left_layout.addWidget(self.ccli_group_box) # Background audio self.audio_group_box = QtWidgets.QGroupBox(self.left_column) self.audio_group_box.setObjectName('audio_group_box') self.audio_layout = QtWidgets.QVBoxLayout(self.audio_group_box) self.audio_layout.setObjectName('audio_layout') self.start_paused_check_box = QtWidgets.QCheckBox(self.audio_group_box) self.start_paused_check_box.setObjectName('start_paused_check_box') self.audio_layout.addWidget(self.start_paused_check_box) self.repeat_list_check_box = QtWidgets.QCheckBox(self.audio_group_box) self.repeat_list_check_box.setObjectName('repeat_list_check_box') self.audio_layout.addWidget(self.repeat_list_check_box) self.left_layout.addWidget(self.audio_group_box) self.left_layout.addStretch() # Application Startup self.startup_group_box = QtWidgets.QGroupBox(self.right_column) self.startup_group_box.setObjectName('startup_group_box') self.startup_layout = QtWidgets.QVBoxLayout(self.startup_group_box) self.startup_layout.setObjectName('startup_layout') self.warning_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.warning_check_box.setObjectName('warning_check_box') self.startup_layout.addWidget(self.warning_check_box) self.auto_open_check_box = QtWidgets.QCheckBox(self.startup_group_box) self.auto_open_check_box.setObjectName('auto_open_check_box') self.startup_layout.addWidget(self.auto_open_check_box) self.show_splash_check_box = QtWidgets.QCheckBox( self.startup_group_box) self.show_splash_check_box.setObjectName('show_splash_check_box') self.startup_layout.addWidget(self.show_splash_check_box) self.check_for_updates_check_box = QtWidgets.QCheckBox( self.startup_group_box) self.check_for_updates_check_box.setObjectName( 'check_for_updates_check_box') self.startup_layout.addWidget(self.check_for_updates_check_box) self.right_layout.addWidget(self.startup_group_box) # 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.auto_preview_check_box = QtWidgets.QCheckBox( self.settings_group_box) self.auto_preview_check_box.setObjectName('auto_preview_check_box') self.settings_layout.addRow(self.auto_preview_check_box) # Moved here from image tab self.timeout_label = QtWidgets.QLabel(self.settings_group_box) self.timeout_label.setObjectName('timeout_label') self.timeout_spin_box = QtWidgets.QSpinBox(self.settings_group_box) self.timeout_spin_box.setObjectName('timeout_spin_box') self.timeout_spin_box.setRange(1, 180) self.settings_layout.addRow(self.timeout_label, self.timeout_spin_box) self.right_layout.addWidget(self.settings_group_box) self.right_layout.addStretch() # Signals and slots self.override_radio_button.toggled.connect( self.on_override_radio_button_pressed) self.custom_height_value_edit.valueChanged.connect( self.on_display_changed) self.custom_width_value_edit.valueChanged.connect( self.on_display_changed) self.custom_Y_value_edit.valueChanged.connect(self.on_display_changed) self.custom_X_value_edit.valueChanged.connect(self.on_display_changed) self.monitor_combo_box.currentIndexChanged.connect( self.on_display_changed) # Reload the tab, as the screen resolution/count may have changed. Registry().register_function('config_screen_changed', self.load) # Remove for now self.username_label.setVisible(False) self.username_edit.setVisible(False) self.password_label.setVisible(False) self.password_edit.setVisible(False) def retranslateUi(self): """ Translate the general settings tab to the currently selected language """ self.tab_title_visible = translate('OpenLP.GeneralTab', 'General') self.monitor_group_box.setTitle( translate('OpenLP.GeneralTab', 'Monitors')) self.monitor_radio_button.setText( translate('OpenLP.GeneralTab', 'Select monitor for output display:')) self.display_on_monitor_check.setText( translate('OpenLP.GeneralTab', 'Display if a single screen')) self.startup_group_box.setTitle( translate('OpenLP.GeneralTab', 'Application Startup')) self.warning_check_box.setText( translate('OpenLP.GeneralTab', 'Show blank screen warning')) self.auto_open_check_box.setText( translate('OpenLP.GeneralTab', 'Automatically open the last service')) self.show_splash_check_box.setText( translate('OpenLP.GeneralTab', 'Show the splash screen')) self.check_for_updates_check_box.setText( translate('OpenLP.GeneralTab', 'Check for updates to OpenLP')) self.settings_group_box.setTitle( translate('OpenLP.GeneralTab', 'Application Settings')) self.save_check_service_check_box.setText( translate('OpenLP.GeneralTab', 'Prompt to save before starting a new service')) self.auto_unblank_check_box.setText( translate('OpenLP.GeneralTab', 'Unblank display when adding new live item')) self.auto_preview_check_box.setText( translate('OpenLP.GeneralTab', 'Automatically preview next item in service')) self.timeout_label.setText( translate('OpenLP.GeneralTab', 'Timed slide interval:')) self.timeout_spin_box.setSuffix(translate('OpenLP.GeneralTab', ' sec')) self.ccli_group_box.setTitle( translate('OpenLP.GeneralTab', 'CCLI Details')) self.number_label.setText(UiStrings().CCLINumberLabel) self.username_label.setText( translate('OpenLP.GeneralTab', 'SongSelect username:'******'OpenLP.GeneralTab', 'SongSelect password:'******'OpenLP.GeneralTab', 'Override display position:')) self.custom_x_label.setText(translate('OpenLP.GeneralTab', 'X')) self.custom_y_label.setText(translate('OpenLP.GeneralTab', 'Y')) self.custom_height_label.setText( translate('OpenLP.GeneralTab', 'Height')) self.custom_width_label.setText(translate('OpenLP.GeneralTab', 'Width')) self.audio_group_box.setTitle( translate('OpenLP.GeneralTab', 'Background Audio')) self.start_paused_check_box.setText( translate('OpenLP.GeneralTab', 'Start background audio paused')) self.repeat_list_check_box.setText( translate('OpenLP.GeneralTab', 'Repeat track list')) def load(self): """ Load the settings to populate the form """ settings = Settings() settings.beginGroup(self.settings_section) self.monitor_combo_box.clear() self.monitor_combo_box.addItems(self.screens.get_screen_list()) monitor_number = settings.value('monitor') self.monitor_combo_box.setCurrentIndex(monitor_number) self.number_edit.setText(settings.value('ccli number')) self.username_edit.setText(settings.value('songselect username')) self.password_edit.setText(settings.value('songselect password')) self.save_check_service_check_box.setChecked( settings.value('save prompt')) self.auto_unblank_check_box.setChecked(settings.value('auto unblank')) self.display_on_monitor_check.setChecked(self.screens.display) self.warning_check_box.setChecked(settings.value('blank warning')) self.auto_open_check_box.setChecked(settings.value('auto open')) self.show_splash_check_box.setChecked(settings.value('show splash')) self.check_for_updates_check_box.setChecked( settings.value('update check')) self.auto_preview_check_box.setChecked(settings.value('auto preview')) self.timeout_spin_box.setValue(settings.value('loop delay')) self.monitor_radio_button.setChecked( not settings.value('override position', )) self.override_radio_button.setChecked( settings.value('override position')) self.custom_X_value_edit.setValue(settings.value('x position')) self.custom_Y_value_edit.setValue(settings.value('y position')) self.custom_height_value_edit.setValue(settings.value('height')) self.custom_width_value_edit.setValue(settings.value('width')) self.start_paused_check_box.setChecked( settings.value('audio start paused')) self.repeat_list_check_box.setChecked( settings.value('audio repeat list')) settings.endGroup() self.monitor_combo_box.setDisabled( self.override_radio_button.isChecked()) self.custom_X_value_edit.setEnabled( self.override_radio_button.isChecked()) self.custom_Y_value_edit.setEnabled( self.override_radio_button.isChecked()) self.custom_height_value_edit.setEnabled( self.override_radio_button.isChecked()) self.custom_width_value_edit.setEnabled( self.override_radio_button.isChecked()) self.display_changed = False def save(self): """ Save the settings from the form """ settings = Settings() settings.beginGroup(self.settings_section) settings.setValue('monitor', self.monitor_combo_box.currentIndex()) settings.setValue('display on monitor', self.display_on_monitor_check.isChecked()) settings.setValue('blank warning', self.warning_check_box.isChecked()) settings.setValue('auto open', self.auto_open_check_box.isChecked()) settings.setValue('show splash', self.show_splash_check_box.isChecked()) settings.setValue('update check', self.check_for_updates_check_box.isChecked()) settings.setValue('save prompt', self.save_check_service_check_box.isChecked()) settings.setValue('auto unblank', self.auto_unblank_check_box.isChecked()) settings.setValue('auto preview', self.auto_preview_check_box.isChecked()) settings.setValue('loop delay', self.timeout_spin_box.value()) settings.setValue('ccli number', self.number_edit.displayText()) settings.setValue('songselect username', self.username_edit.displayText()) settings.setValue('songselect password', self.password_edit.displayText()) settings.setValue('x position', self.custom_X_value_edit.value()) settings.setValue('y position', self.custom_Y_value_edit.value()) settings.setValue('height', self.custom_height_value_edit.value()) settings.setValue('width', self.custom_width_value_edit.value()) settings.setValue('override position', self.override_radio_button.isChecked()) settings.setValue('audio start paused', self.start_paused_check_box.isChecked()) settings.setValue('audio repeat list', self.repeat_list_check_box.isChecked()) settings.endGroup() # On save update the screens as well self.post_set_up(True) def post_set_up(self, postUpdate=False): """ Apply settings after settings tab has loaded and most of the system so must be delayed """ self.settings_form.register_post_process( 'slidecontroller_live_spin_delay') # Do not continue on start up. if not postUpdate: return self.screens.set_current_display(self.monitor_combo_box.currentIndex()) self.screens.display = self.display_on_monitor_check.isChecked() self.screens.override['size'] = QtCore.QRect( self.custom_X_value_edit.value(), self.custom_Y_value_edit.value(), self.custom_width_value_edit.value(), self.custom_height_value_edit.value()) self.screens.override['number'] = self.screens.which_screen( self.screens.override['size']) self.screens.override['primary'] = (self.screens.desktop.primaryScreen( ) == self.screens.override['number']) if self.override_radio_button.isChecked(): self.screens.set_override_display() else: self.screens.reset_current_display() if self.display_changed: self.settings_form.register_post_process('config_screen_changed') self.display_changed = False def on_override_radio_button_pressed(self, checked): """ Toggle screen state depending on check box state. :param checked: The state of the check box (boolean). """ self.monitor_combo_box.setDisabled(checked) self.custom_X_value_edit.setEnabled(checked) self.custom_Y_value_edit.setEnabled(checked) self.custom_height_value_edit.setEnabled(checked) self.custom_width_value_edit.setEnabled(checked) self.display_changed = True def on_display_changed(self): """ Called when the width, height, x position or y position has changed. """ self.display_changed = True