Update the About dialog:

bzr-revno: 2894
This commit is contained in:
Raoul Snyman 2019-08-27 21:18:22 -07:00
commit 96544355b1
3 changed files with 675 additions and 635 deletions

File diff suppressed because it is too large Load Diff

View File

@ -50,19 +50,20 @@ class AboutForm(QtWidgets.QDialog, UiAboutDialog):
Set up the dialog. This method is mocked out in tests. Set up the dialog. This method is mocked out in tests.
""" """
self.setup_ui(self) self.setup_ui(self)
self.button_box.buttons()[0].setFocus()
application_version = get_version() application_version = get_version()
about_text = self.about_text_edit.toPlainText() about_text = self.about_text_edit.toHtml()
about_text = about_text.replace('<version>', application_version['version']) about_text = about_text.replace('{version}', application_version['version'])
if application_version['build']: if application_version['build']:
build_text = translate('OpenLP.AboutForm', ' build {version}').format(version=application_version['build']) build_text = translate('OpenLP.AboutForm', ' build {version}').format(version=application_version['build'])
else: else:
build_text = '' build_text = ''
about_text = about_text.replace('<revision>', build_text) about_text = about_text.replace('{revision}', build_text)
self.about_text_edit.setPlainText(about_text) self.about_text_edit.setHtml(about_text)
self.volunteer_button.clicked.connect(self.on_volunteer_button_clicked) self.contribute_button.clicked.connect(self.on_contribute_button_clicked)
def on_volunteer_button_clicked(self): def on_contribute_button_clicked(self):
""" """
Launch a web browser and go to the contribute page on the site. Launch a web browser and go to the contribute page on the site.
""" """
webbrowser.open_new('http://openlp.org/en/contribute') webbrowser.open_new('http://openlp.org/contribute')

View File

@ -30,10 +30,10 @@ from openlp.core.ui.aboutform import AboutForm
from tests.helpers.testmixin import TestMixin from tests.helpers.testmixin import TestMixin
class TestFirstTimeForm(TestCase, TestMixin): class TestAboutForm(TestCase, TestMixin):
@patch('openlp.core.ui.aboutform.webbrowser') @patch('openlp.core.ui.aboutform.webbrowser')
def test_on_volunteer_button_clicked(self, mocked_webbrowser): def test_on_contribute_button_clicked(self, mocked_webbrowser):
""" """
Test that clicking on the "Volunteer" button opens a web page. Test that clicking on the "Volunteer" button opens a web page.
""" """
@ -41,10 +41,10 @@ class TestFirstTimeForm(TestCase, TestMixin):
about_form = AboutForm(None) about_form = AboutForm(None)
# WHEN: The "Volunteer" button is "clicked" # WHEN: The "Volunteer" button is "clicked"
about_form.on_volunteer_button_clicked() about_form.on_contribute_button_clicked()
# THEN: A web browser is opened # THEN: A web browser is opened
mocked_webbrowser.open_new.assert_called_with('http://openlp.org/en/contribute') mocked_webbrowser.open_new.assert_called_with('http://openlp.org/contribute')
@patch('openlp.core.ui.aboutform.get_version') @patch('openlp.core.ui.aboutform.get_version')
def test_about_form_build_number(self, mocked_get_version): def test_about_form_build_number(self, mocked_get_version):
@ -66,11 +66,11 @@ class TestFirstTimeForm(TestCase, TestMixin):
Test that the copyright date is included correctly Test that the copyright date is included correctly
""" """
# GIVEN: A correct application date # GIVEN: A correct application date
date_string = "2004-%s" % datetime.date.today().year date_string = '2004-{year}'.format(year=datetime.date.today().year)
# WHEN: The about form is created # WHEN: The about form is created
about_form = AboutForm(None) about_form = AboutForm(None)
license_text = about_form.license_text_edit.toPlainText() about_text = about_form.about_text_edit.toPlainText()
# THEN: The date should be in the text twice. # THEN: The date should be in the text twice.
assert license_text.count(date_string, 0) == 2, "The text string should be added twice to the license string" assert about_text.count(date_string, 0) == 1, "The text string should be added twice to the license string"