1
# -*- coding: utf-8 -*-
3
# Authors: Roberto Alsina <roberto.alsina@canonical.com>
4
# Diego Sarmentero <diego.sarmentero@canonical.com>
6
# Copyright 2011 Canonical Ltd.
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.
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.
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/>.
20
"""Page to list folders in a Ubuntu One account."""
24
from PyQt4 import QtCore, QtGui
26
from ubuntuone_installer.gui.qt.ui import preferences_ui
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()
37
self.ui.widget.ui.apply_changes_button.hide()
38
self.ui.widget.ui.restore_defaults_button.hide()
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
47
self.wizard().customButtonClicked.disconnect()
50
self.wizard()._next_id = None
51
self.setButtonText(QtGui.QWizard.CustomButton1,
52
_("Apply these settings >"))
53
self.setButtonText(QtGui.QWizard.CustomButton2, _("Default settings"))
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))
66
self.wizard().customButtonClicked.connect(self._button_clicked)
68
def _button_clicked(self, btn):
69
if btn == QtGui.QWizard.CustomButton1:
70
self.ui.widget.on_apply_changes_button_clicked()
73
elif btn == QtGui.QWizard.CustomButton2:
74
self.ui.widget.on_restore_defaults_button_clicked()
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