Пример #1
0
 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")
Пример #2
0
 def setUp(self):
     """
     Create the UI
     """
     Registry.create()
     self.app = QtGui.QApplication.instance()
     ScreenList.create(self.app.desktop())
     self.image_manager = ImageManager()
Пример #3
0
 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
Пример #4
0
 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')
Пример #5
0
 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_()
Пример #6
0
 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()
Пример #7
0
 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()
Пример #8
0
 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')
Пример #9
0
    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)
Пример #10
0
 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()
Пример #11
0
    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)
Пример #12
0
 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()
Пример #13
0
 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()
Пример #14
0
 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
Пример #15
0
 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
Пример #16
0
    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()
Пример #17
0
    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_()