=== modified file 'ubuntuone/controlpanel/gui/__init__.py' --- ubuntuone/controlpanel/gui/__init__.py 2012-03-19 20:55:52 +0000 +++ ubuntuone/controlpanel/gui/__init__.py 2012-03-20 15:18:18 +0000 @@ -179,6 +179,17 @@ INSTALL_PLUGIN = _('Install the %(plugin_name)s for the sync service: ' '%(service_name)s') INSTALLING = _('Installation of %(package_name)s in progress') +LICENSE_AGREE = _('Agree and continue') +LICENSE_AGREEMENT = _('License Agreement') +LICENSE_BASIC = _('Ubuntu One Basic is free, while additional service add-ons ' + 'may be paid for services.') +LICENSE_DISAGREE = _('Disagree and uninstall') +LICENSE_GPL3 = _('This program is free software: you can redistribute it ' + 'and/or modify it under the terms of the GNU General Public License ' + 'version 3, as published by the Free Software Foundation.') +LICENSE_LINK = _('As free software, this programme is distributed without ' + 'warranty. See the GNU General Public License for more details at ' + '{license_link}') LOADING = _('Loading...') LOADING_OVERLAY = _('Getting information, please wait...') LOCAL_FOLDERS_CALCULATING = _('Calculating...') === modified file 'ubuntuone/controlpanel/gui/qt/tests/test_wizard.py' --- ubuntuone/controlpanel/gui/qt/tests/test_wizard.py 2012-03-19 20:51:26 +0000 +++ ubuntuone/controlpanel/gui/qt/tests/test_wizard.py 2012-03-20 15:18:18 +0000 @@ -95,6 +95,19 @@ self.assertFalse(self.ui.isFinalPage()) +class LicensePageTestCase(UbuntuOnePageTestCase): + """Test the LicensePage wizard page.""" + + class_ui = gui.LicensePage + panel_class = gui.QtGui.QTextBrowser + + def test_content(self): + """The page content is correct.""" + expected = gui.QtGui.QTextBrowser() + expected.setHtml(gui.LICENSE_CONTENT) + self.assertEqual(self.ui.panel.toHtml(), expected.toHtml()) + + class SignInPageTestCase(UbuntuOnePageTestCase): """Test the SignInPage wizard page.""" @@ -140,9 +153,11 @@ class_ui = gui.UbuntuOneWizard confirm_response = gui.QtGui.QDialog.Accepted + show_license = False @defer.inlineCallbacks def setUp(self): + self.patch(self.class_ui, 'show_license', self.show_license) yield super(UbuntuOneWizardTestCase, self).setUp() self.patch(self.ui.confirm_dialog, 'exec_', lambda: self.confirm_response) @@ -171,7 +186,11 @@ def test_first_page(self): """The first page is the correct one.""" - expected = self.ui.pages[self.ui.signin_page] + if self.show_license: + expected = self.ui.pages[self.ui.license_page] + else: + expected = self.ui.pages[self.ui.signin_page] + self.assertEqual(self.ui.startId(), expected) def test_done_accepted(self): @@ -183,6 +202,12 @@ self.assertEqual(self._called, ((gui.QtGui.QDialog.Accepted,), {})) +class LicensedUbuntuOneWizardTestCase(UbuntuOneWizardTestCase): + """Test the LicensedUbuntuOneWizard.""" + + show_license = True + + class UbuntuOneWizardSignInTestCase(UbuntuOneWizardTestCase): """Test the SignInPage wizard page.""" @@ -312,6 +337,18 @@ # does not apply to this page +class UbuntuOneWizardLicensePage(UbuntuOneWizardSignInTestCase): + """Test the LicensePage wizard page.""" + + buttons = { + 'NextButton': (gui.LICENSE_AGREE, 'currentIdChanged', (1,)), + 'CancelButton': (gui.LICENSE_DISAGREE, 'rejected', ()), + } + page_name = 'license' + show_license = True + stage_name = 'install' + + class UbuntuOneWizardLoginTestCase(UbuntuOneWizardTestCase): """Test the login through the wizard.""" === modified file 'ubuntuone/controlpanel/gui/qt/wizard.py' --- ubuntuone/controlpanel/gui/qt/wizard.py 2012-03-19 17:16:43 +0000 +++ ubuntuone/controlpanel/gui/qt/wizard.py 2012-03-20 15:18:18 +0000 @@ -36,6 +36,12 @@ CLOUD_TO_COMPUTER_TITLE, COMPUTER_TO_CLOUD_SUBTITLE, COMPUTER_TO_CLOUD_TITLE, + LICENSE_AGREE, + LICENSE_AGREEMENT, + LICENSE_BASIC, + LICENSE_DISAGREE, + LICENSE_GPL3, + LICENSE_LINK, UBUNTUONE_LINK, ) from ubuntuone.controlpanel.gui.qt.folders import ( @@ -51,6 +57,21 @@ logger = setup_logging('qt.wizard') +GPL_URL = u'http://www.gnu.org/licenses' +GPL_LINK = LINK_STYLE.format(link_url=GPL_URL, link_text=GPL_URL) +LICENSE_CONTENT = u""" + +

{license_agreement}

+

{license_gpl3}

+

{license_basic}

+

{license_link}

+ +""".format(license_agreement=LICENSE_AGREEMENT, + license_gpl3=LICENSE_GPL3, license_basic=LICENSE_BASIC, + license_link=LICENSE_LINK.format(license_link=GPL_LINK), +) + + class AreYouSure(QtGui.QDialog): """A 'Are you sure?' dialog.""" @@ -100,6 +121,16 @@ self.setFinalPage(self.is_final) +class LicensePage(UbuntuOnePage): + """The page to show the license.""" + + panel_class = QtGui.QTextBrowser + + def __init__(self, *args, **kwargs): + super(LicensePage, self).__init__(*args, **kwargs) + self.panel.setHtml(LICENSE_CONTENT) + + class SignInPage(UbuntuOnePage): """The page to signin to Ubuntu One.""" @@ -152,6 +183,12 @@ self.side_widget.stage = self.side_widget.signin_stage self.setSideWidget(self.side_widget) + # license + self.license_page = LicensePage() + self.next_button_text = self.button(self.NextButton).text() + if self.show_license: + self.addPage(self.license_page) + # sign in self.signin_page = SignInPage() self.addPage(self.signin_page) @@ -193,15 +230,28 @@ button_layout = button_to = button = stage = None - if page is self.signin_page: - self.setButtonText(self.CancelButton, CLOSE_AND_SETUP_LATER) - + if page is self.license_page: + button_layout = [self.Stretch, self.CancelButton, self.NextButton] + button = self.button(self.NextButton) + button_to = self.button(self.CancelButton) + stage = self.side_widget.install_stage + + self.setButtonText(self.NextButton, LICENSE_AGREE) + self.setButtonText(self.CancelButton, LICENSE_DISAGREE) + + elif page is self.signin_page: button_layout = [self.Stretch, self.CancelButton] button = self.signin_page.panel.ui.register_button button_to = self.button(self.CancelButton) stage = self.side_widget.signin_stage self._next_id = self.pages[self.cloud_folders_page] + + self.setButtonText(self.CancelButton, CLOSE_AND_SETUP_LATER) + self.setTabOrder(self.signin_page.panel.ui.login_button, button) + elif page is self.cloud_folders_page: + self.setButtonText(self.NextButton, self.next_button_text) + button_layout = [self.Stretch, self.NextButton] button = self.cloud_folders_page.panel.ui.check_settings_button button_to = self.button(self.NextButton) @@ -289,5 +339,13 @@ if response == QtGui.QDialog.Accepted: logger.warning('UbuntuOneWizard: user canceled setup.') self.rejected.emit() + elif (self.show_license and + self.currentId() == self.pages[self.license_page]): + response = self.confirm_dialog.exec_() + if response == QtGui.QDialog.Accepted: + logger.warning('UbuntuOneWizard: user wants to uninstall.') + # TODO: needs implementation in this project + ##qt.utils.uninstall_application() + self.rejected.emit() else: super(UbuntuOneWizard, self).done(result)