Ejemplo n.º 1
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 = get_application_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
            log.debug('Splashscreen closing')
            self.splash.close()
            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()
        if Settings().value('core/update check'):
            check_for_update(self.main_window)
        self.main_window.is_display_blank()
        self.main_window.app_startup()
        return self.exec()
Ejemplo n.º 2
0
def test_get_application_stylesheet_win_repair(MockSettings, mocked_is_win):
    """Test that the Windows repair stylesheet is returned when on Windows"""
    # GIVEN: We're on Windows and no dark style is set
    mocked_is_win.return_value = True
    MockSettings.return_value.value.return_value = True

    # WHEN: can_show_icon() is called
    result = get_application_stylesheet()

    # THEN: the result should be false
    MockSettings.return_value.value.assert_called_once_with(
        'advanced/alternate rows')
    assert result == WIN_REPAIR_STYLESHEET
Ejemplo n.º 3
0
def test_get_application_stylesheet_dark(mocked_qdarkstyle, MockSettings):
    """Test that the dark stylesheet is returned when available and enabled"""
    # GIVEN: We're on Windows and no dark style is set
    mocked_settings = MagicMock()
    mocked_settings.value.return_value = True
    MockSettings.return_value = mocked_settings
    mocked_qdarkstyle.load_stylesheet_pyqt5.return_value = 'dark_style'

    # WHEN: can_show_icon() is called
    result = get_application_stylesheet()

    # THEN: the result should be false
    assert result == 'dark_style'
Ejemplo n.º 4
0
def test_get_application_stylesheet_not_alternate_rows(mocked_palette,
                                                       MockSettings,
                                                       mocked_is_win):
    """Test that the alternate rows stylesheet is returned when enabled in settings"""
    # GIVEN: We're on Windows and no dark style is set
    mocked_is_win.return_value = False
    MockSettings.return_value.value.return_value = False
    mocked_palette.return_value.color.return_value.name.return_value = 'color'

    # WHEN: can_show_icon() is called
    result = get_application_stylesheet()

    # THEN: the result should be false
    MockSettings.return_value.value.assert_called_once_with(
        'advanced/alternate rows')
    assert result == 'QTableWidget, QListWidget, QTreeWidget {alternate-background-color: color;}\n', result