A few fixes for the alpha.

This commit is contained in:
Tomas Groth 2020-01-06 21:15:11 +00:00 committed by Raoul Snyman
parent 0d2e9b9aa6
commit a0616ddf0f
10 changed files with 50 additions and 26 deletions

View File

@ -106,10 +106,6 @@ class OpenLP(QtCore.QObject, LogMixin):
else:
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()
@ -122,6 +118,10 @@ class OpenLP(QtCore.QObject, LogMixin):
loader()
self.main_window = MainWindow()
self.main_window.installEventFilter(self.main_window)
# Correct stylesheet bugs
application_stylesheet = get_application_stylesheet()
if application_stylesheet:
self.main_window.setStyleSheet(application_stylesheet)
Registry().execute('bootstrap_initialise')
State().flush_preconditions()
Registry().execute('bootstrap_post_set_up')

View File

@ -173,6 +173,14 @@ class DisplayWindow(QtWidgets.QWidget, RegistryProperties):
if len(ScreenList()) > 1 or Settings().value('core/display on monitor'):
self.show()
def deregister_display(self):
"""
De-register this displays callbacks in the registry to be able to remove it
"""
if self.is_display:
Registry().remove_function('live_display_hide', self.hide_display)
Registry().remove_function('live_display_show', self.show_display)
@property
def is_initialised(self):
return self._is_initialised

View File

@ -100,7 +100,7 @@ class Ui_ExceptionDialog(object):
'<strong>Oops, OpenLP hit a problem and couldn\'t recover!<br><br>'
'You can help </strong> the OpenLP developers to <strong>fix this</strong>'
' by<br> sending them a <strong>bug report to {email}</strong>{newlines}'
).format(email='<a href = "mailto:bugs@openlp.org" > bugs@openlp.org</a>',
).format(email='<a href = "mailto:bugs3@openlp.org" > bugs3@openlp.org</a>',
newlines='<br><br>'))
self.message_label.setText(
translate('OpenLP.ExceptionDialog', '{first_part}'

View File

@ -139,7 +139,7 @@ class ExceptionForm(QtWidgets.QDialog, Ui_ExceptionDialog, RegistryProperties):
libs=content['libs']))
if self.file_attachment:
mail_urlquery.addQueryItem('attach', self.file_attachment)
mail_to_url = QtCore.QUrl('mailto:bugs@openlp.org')
mail_to_url = QtCore.QUrl('mailto:bugs3@openlp.org')
mail_to_url.setQuery(mail_urlquery)
QtGui.QDesktopServices.openUrl(mail_to_url)

View File

@ -101,8 +101,9 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
Create and set up the first time wizard.
"""
super(FirstTimeForm, self).__init__(parent)
self.web_access = True
self.has_web_access = True
self.web = ''
self.is_index_downloaded = False
self.setup_ui(self)
self.customButtonClicked.connect(self._on_custom_button_clicked)
self.themes_list_widget.itemSelectionChanged.connect(self.on_themes_list_widget_selection_changed)
@ -132,7 +133,7 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
"""
self.application.process_events()
if self.currentId() == FirstTimePage.Download:
if not self.web_access:
if not self.has_web_access:
return FirstTimePage.NoInternet
else:
return FirstTimePage.Songs
@ -164,11 +165,14 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
"""
Download the configuration file and kick off the theme screenshot download threads
"""
# Check if the index file has already been downloaded
if self.is_index_downloaded:
return
# check to see if we have web access
self.web_access = False
self.has_web_access = False
self.config = ''
web_config = None
user_agent = 'OpenLP/' + Registry().get('application').applicationVersion()
user_agent = 'OpenLP/' + QtWidgets.QApplication.applicationVersion()
self.application.process_events()
try:
web_config = get_web_page('{host}{name}'.format(host=self.web, name='download_3.0.json'),
@ -179,10 +183,11 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
'to connect to retrieve initial configuration information'),
QtWidgets.QMessageBox.Ok)
if web_config and self._parse_config(web_config):
self.web_access = True
self.has_web_access = True
self.application.process_events()
self.downloading = translate('OpenLP.FirstTimeWizard', 'Downloading {name}...')
self.application.set_normal_cursor()
self.is_index_downloaded = True
def _parse_config(self, web_config):
try:
@ -419,7 +424,7 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
'download, so further downloads will be skipped. Try to re-run the '
'First Time Wizard later.'))
self.max_progress = 0
self.web_access = None
self.has_web_access = None
if self.max_progress:
# Add on 2 for plugins status setting plus a "finished" point.
self.max_progress += 2
@ -465,7 +470,7 @@ class FirstTimeForm(QtWidgets.QWizard, UiFirstTimeWizard, RegistryProperties):
Run the tasks in the wizard.
"""
if self.web_access:
if self.has_web_access:
if not self._download_selected():
critical_error_message_box(translate('OpenLP.FirstTimeWizard', 'Download Error'),
translate('OpenLP.FirstTimeWizard', 'There was a connection problem while '

View File

@ -28,7 +28,9 @@ from PyQt5 import QtGui, QtWidgets
from openlp.core.common import Singleton
from openlp.core.common.applocation import AppLocation
from openlp.core.common.settings import Settings
from openlp.core.lib import build_icon
from openlp.core.ui.style import HAS_DARK_STYLE
log = logging.getLogger(__name__)
@ -164,6 +166,7 @@ class UiIcons(metaclass=Singleton):
"""
Load the list of icons to be processed
"""
is_dark = (HAS_DARK_STYLE and Settings().value('advanced/use_dark_style'))
for key in icon_list:
try:
icon = icon_list[key]['icon']
@ -171,7 +174,10 @@ class UiIcons(metaclass=Singleton):
attr = icon_list[key]['attr']
setattr(self, key, qta.icon(icon, color=attr))
except KeyError:
setattr(self, key, qta.icon(icon))
if is_dark:
setattr(self, key, qta.icon(icon, color='white'))
else:
setattr(self, key, qta.icon(icon))
except Exception:
import sys
log.error('Unexpected error: %s' % sys.exc_info())

View File

@ -169,11 +169,16 @@ class SlideController(QtWidgets.QWidget, LogMixin, RegistryProperties):
return
if self.displays:
# Delete any existing displays
del self.displays[:]
for display in self.displays:
display.deregister_display()
display.setParent(None)
del display
self.displays = []
for screen in self.screens:
if screen.is_display:
display = DisplayWindow(self, screen)
self.displays.append(display)
self._reset_blank(False)
if self.display:
self.__add_actions_to_widget(self.display)

View File

@ -126,7 +126,7 @@
<item>
<widget class="QLabel" name="messageLabel">
<property name="text">
<string>Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs@openlp.org, along with a detailed description of what you were doing when the problem occurred.</string>
<string>Oops! OpenLP hit a problem, and couldn't recover. The text in the box below contains information that might be helpful to the OpenLP developers, so please e-mail it to bugs3@openlp.org, along with a detailed description of what you were doing when the problem occurred.</string>
</property>
<property name="wordWrap">
<bool>true</bool>

View File

@ -220,16 +220,16 @@ def test_set_normal_cursor(mocked_restoreOverrideCursor, mocked_processEvents, q
@patch('openlp.core.app.get_version')
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
def test_backup_on_upgrade_first_install(mocked_question, mocked_get_version, qapp):
def test_backup_on_upgrade_first_install(mocked_question, mocked_get_version, qapp, settings):
"""
Test that we don't try to backup on a new install
"""
# GIVEN: Mocked data version and OpenLP version which are the same
old_install = False
MOCKED_VERSION = {
'full': '2.4.0-bzr000',
'full': '2.4.0',
'version': '2.4.0',
'build': 'bzr000'
'build': None
}
Settings().setValue('core/application version', '2.4.0')
mocked_get_version.return_value = MOCKED_VERSION
@ -245,18 +245,18 @@ def test_backup_on_upgrade_first_install(mocked_question, mocked_get_version, qa
@patch('openlp.core.app.get_version')
@patch('openlp.core.app.QtWidgets.QMessageBox.question')
def test_backup_on_upgrade(mocked_question, mocked_get_version, qapp):
def test_backup_on_upgrade(mocked_question, mocked_get_version, qapp, settings):
"""
Test that we try to backup on a new install
"""
# GIVEN: Mocked data version and OpenLP version which are different
old_install = True
MOCKED_VERSION = {
'full': '2.4.0-bzr000',
'version': '2.4.0',
'build': 'bzr000'
'full': '2.9.0.dev2963+97ba02d1f',
'version': '2.9.0',
'build': '97ba02d1f'
}
Settings().setValue('core/application version', '2.0.5')
Settings().setValue('core/application version', '2.4.6')
qapp.splash = MagicMock()
qapp.splash.isVisible.return_value = True
mocked_get_version.return_value = MOCKED_VERSION
@ -266,7 +266,7 @@ def test_backup_on_upgrade(mocked_question, mocked_get_version, qapp):
qapp.backup_on_upgrade(old_install, True)
# THEN: It should ask if we want to create a backup
assert Settings().value('core/application version') == '2.4.0', 'Version should be upgraded!'
assert Settings().value('core/application version') == '2.9.0', 'Version should be upgraded!'
assert mocked_question.call_count == 1, 'A question should have been asked!'
qapp.splash.hide.assert_called_once_with()
qapp.splash.show.assert_called_once_with()

View File

@ -121,7 +121,7 @@ class TestFirstTimeForm(TestCase, TestMixin):
# THEN: The screens should be set up, and the default values initialised
assert expected_screens == frw.screens, 'The screens should be correct'
assert frw.web_access is True, 'The default value of self.web_access should be True'
assert frw.has_web_access is True, 'The default value of self.web_access should be True'
assert [] == frw.thumbnail_download_threads, 'The list of threads should be empty'
assert frw.has_run_wizard is False, 'has_run_wizard should be False'