~ubuntuone-control-tower/ubuntuone-windows-installer/trunk

« back to all changes in this revision

Viewing changes to ubuntuone_installer/gui/qt/preferences.py

  • Committer: Diego Sarmentero
  • Date: 2011-08-08 21:48:11 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: diego.sarmentero@canonical.com-20110808214811-rsvbmd615euu5mc2
Several improves in the UI for Page 18 and 19.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
 
 
3
# Authors: Roberto Alsina <roberto.alsina@canonical.com>
 
4
#          Diego Sarmentero <diego.sarmentero@canonical.com>
 
5
#
 
6
# Copyright 2011 Canonical Ltd.
 
7
#
 
8
# This program is free software: you can redistribute it and/or modify it
 
9
# under the terms of the GNU General Public License version 3, as published
 
10
# by the Free Software Foundation.
 
11
#
 
12
# This program is distributed in the hope that it will be useful, but
 
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
# PURPOSE.  See the GNU General Public License for more details.
 
16
#
 
17
# You should have received a copy of the GNU General Public License along
 
18
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 
 
20
"""Page to list folders in a Ubuntu One account."""
 
21
 
 
22
import gettext
 
23
 
 
24
from PyQt4 import QtCore, QtGui
 
25
 
 
26
from ubuntuone_installer.gui.qt.ui import preferences_ui
 
27
 
 
28
_ = gettext.gettext
 
29
 
 
30
 
 
31
class PreferencesPage(QtGui.QWizardPage):
 
32
    """Wizard page to list and manage an account's folders."""
 
33
    def __init__(self, parent=None):
 
34
        super(PreferencesPage, self).__init__(parent)
 
35
        self.ui = preferences_ui.Ui_Form()
 
36
        self.ui.setupUi(self)
 
37
        self.ui.widget.ui.apply_changes_button.hide()
 
38
        self.ui.widget.ui.restore_defaults_button.hide()
 
39
 
 
40
    def initializePage(self):
 
41
        self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, True)
 
42
        self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, True)
 
43
        # This is just to catch an exception thrown when nothing
 
44
        # is connected to the signal. It's not an exceptional
 
45
        # condition at all.
 
46
        try:
 
47
            self.wizard().customButtonClicked.disconnect()
 
48
        except TypeError:
 
49
            pass
 
50
        self.wizard()._next_id = None
 
51
        self.setButtonText(QtGui.QWizard.CustomButton1,
 
52
            _("Apply these settings >"))
 
53
        self.setButtonText(QtGui.QWizard.CustomButton2, _("Default settings"))
 
54
 
 
55
        self.wizard().setButtonLayout([
 
56
            QtGui.QWizard.BackButton,
 
57
            QtGui.QWizard.Stretch,
 
58
            QtGui.QWizard.CustomButton2,
 
59
            QtGui.QWizard.CustomButton1])
 
60
        self.wizard().button(QtGui.QWizard.CustomButton1).setDefault(True)
 
61
        self.wizard().button(QtGui.QWizard.CustomButton1).style().unpolish(
 
62
            self.wizard().button(QtGui.QWizard.CustomButton1))
 
63
        self.wizard().button(QtGui.QWizard.CustomButton1).style().polish(
 
64
            self.wizard().button(QtGui.QWizard.CustomButton1))
 
65
 
 
66
        self.wizard().customButtonClicked.connect(self._button_clicked)
 
67
 
 
68
    def _button_clicked(self, btn):
 
69
        if btn == QtGui.QWizard.CustomButton1:
 
70
            self.ui.widget.on_apply_changes_button_clicked()
 
71
            self.cleanupPage()
 
72
            self.wizard().back()
 
73
        elif btn == QtGui.QWizard.CustomButton2:
 
74
            self.ui.widget.on_restore_defaults_button_clicked()
 
75
 
 
76
    def cleanupPage(self):
 
77
        self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, False)
 
78
        self.wizard().setOption(QtGui.QWizard.HaveCustomButton2, False)
 
79
        self.wizard().setButtonLayout([
 
80
            QtGui.QWizard.BackButton,
 
81
            QtGui.QWizard.Stretch,
 
82
            QtGui.QWizard.NextButton])
 
83
        self.wizard().setButtonText(QtGui.QWizard.NextButton, _("Sync Now!"))
 
84
        self.wizard()._next_id = self.wizard().CONGRATULATIONS_PAGE