Merge lp:~ralsina/ubuntuone-windows-installer/ui_files_2 into lp:ubuntuone-windows-installer

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 23
Merged at revision: 3
Proposed branch: lp:~ralsina/ubuntuone-windows-installer/ui_files_2
Merge into: lp:ubuntuone-windows-installer
Diff against target: 176 lines (+84/-44)
4 files modified
data/qt/license.ui (+6/-41)
ubuntuone_installer/gui/qt/__init__.py (+0/-2)
ubuntuone_installer/gui/qt/gui.py (+59/-1)
ubuntuone_installer/gui/qt/ui/__init__.py (+19/-0)
To merge this branch: bzr merge lp:~ralsina/ubuntuone-windows-installer/ui_files_2
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
dobey (community) Approve
Review via email: mp+65388@code.launchpad.net

Commit message

Implements the first page of the wizard (license information), including a "print" button.

Description of the change

Implements the first page of the wizard (license information), including a "print" button.

To test:

On linux, run

PYTHONPATH=. python bin/ubuntuone-installer-qt

Clicking print should give you a standard printing dialog, which you should be able to use to print to a PDF file (or to a real printer)

If you "finish" or "cancel" the wizard, the app is stuck (that's a bug for another branch)

To post a comment you must log in.
23. By Roberto Alsina

Open links on external browser

Revision history for this message
dobey (dobey) :
review: Approve
Revision history for this message
Alejandro J. Cura (alecu) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'data/qt/license.ui'
2--- data/qt/license.ui 2011-06-21 16:06:01 +0000
3+++ data/qt/license.ui 2011-06-21 18:47:23 +0000
4@@ -29,49 +29,14 @@
5 <p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-family:'MS Shell Dlg 2'; font-size:8pt;"></p>
6 &lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt;&quot;&gt;As free software, this programme is distributed without warranty. See the GNU General Public License for more details at &lt;/span&gt;&lt;a href=&quot;http://www.gnu.org/licenses&quot;&gt;&lt;span style=&quot; font-family:'MS Shell Dlg 2'; font-size:8pt; text-decoration: underline; color:#0000ff;&quot;&gt;http://www.gnu.org/licenses&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
7 </property>
8+ <property name="openExternalLinks">
9+ <bool>true</bool>
10+ </property>
11+ <property name="openLinks">
12+ <bool>true</bool>
13+ </property>
14 </widget>
15 </item>
16- <item>
17- <layout class="QHBoxLayout" name="horizontalLayout">
18- <item>
19- <widget class="QPushButton" name="agree">
20- <property name="text">
21- <string>Disagree &amp;&amp; Cancel</string>
22- </property>
23- </widget>
24- </item>
25- <item>
26- <widget class="QPushButton" name="printButton">
27- <property name="text">
28- <string>Print</string>
29- </property>
30- </widget>
31- </item>
32- <item>
33- <spacer name="horizontalSpacer">
34- <property name="orientation">
35- <enum>Qt::Horizontal</enum>
36- </property>
37- <property name="sizeHint" stdset="0">
38- <size>
39- <width>40</width>
40- <height>20</height>
41- </size>
42- </property>
43- </spacer>
44- </item>
45- <item>
46- <widget class="QPushButton" name="disagree">
47- <property name="text">
48- <string>Agree &amp;&amp; Install</string>
49- </property>
50- <property name="default">
51- <bool>true</bool>
52- </property>
53- </widget>
54- </item>
55- </layout>
56- </item>
57 </layout>
58 </widget>
59 <resources/>
60
61=== modified file 'ubuntuone_installer/gui/qt/__init__.py'
62--- ubuntuone_installer/gui/qt/__init__.py 2011-06-21 16:36:01 +0000
63+++ ubuntuone_installer/gui/qt/__init__.py 2011-06-21 18:47:23 +0000
64@@ -18,5 +18,3 @@
65
66 """The Qt graphical interface for the Ubuntu One Installer."""
67
68-from PyQt4 import QtGui, QtCore
69-
70
71=== modified file 'ubuntuone_installer/gui/qt/gui.py'
72--- ubuntuone_installer/gui/qt/gui.py 2011-06-21 16:36:01 +0000
73+++ ubuntuone_installer/gui/qt/gui.py 2011-06-21 18:47:23 +0000
74@@ -23,11 +23,59 @@
75 from PyQt4 import QtGui
76
77 from ubuntuone_installer.logger import setup_logging
78-
79+from ubuntuone_installer.gui.qt.ui import license_ui
80+
81+import gettext
82+
83+_ = gettext.gettext
84
85 logger = setup_logging('qt.gui')
86
87
88+class LicensePage(QtGui.QWizardPage):
89+ """Wizard Page that displays the license info and links to the GPL"""
90+
91+ # Invalid constant names and Qt-inherited methods
92+ # pylint: disable=C0103
93+
94+ LICENSE_PAGE = 0
95+
96+ def __init__(self, parent=None):
97+ QtGui.QWizardPage.__init__(self, parent)
98+ self.ui = license_ui.Ui_Form()
99+ self.ui.setupUi(self)
100+
101+ def initializePage(self):
102+ """Setup UI details"""
103+
104+ # We need custom buttons
105+ self.wizard().setButtonText(QtGui.QWizard.CustomButton1, _("&Print"))
106+ self.wizard().setOption(QtGui.QWizard.HaveCustomButton1, True)
107+
108+ # Set the right texts and connections for buttons
109+ self.setButtonText(QtGui.QWizard.NextButton, _("Agree && Install"))
110+ self.setButtonText(QtGui.QWizard.CancelButton,
111+ _("Disagree && Cancel"))
112+ self.setButtonText(QtGui.QWizard.CustomButton1, _("&Print"))
113+ self.wizard().customButtonClicked.connect(self.printDocument)
114+
115+ def printDocument(self, button_id):
116+ """Print the document displayed in textBrowser"""
117+
118+ if button_id == QtGui.QWizard.CustomButton1:
119+ document = self.ui.textBrowser.document()
120+ printer = QtGui.QPrinter(QtGui.QPrinter.HighResolution)
121+
122+ dialog = QtGui.QPrintDialog(printer, self)
123+
124+ dialog.setWindowTitle(_("Send to printer"))
125+ if dialog.exec_() != QtGui.QDialog.Accepted:
126+ return
127+ printer.setFullPage(True)
128+ printer.setPageSize(QtGui.QPrinter.A4)
129+ document.print_(printer)
130+
131+
132 class MainWindow(QtGui.QWizard):
133 """The Main Window of the Installer wizard."""
134
135@@ -36,6 +84,16 @@
136 QtGui.QWizard.__init__(self)
137 self.close_callback = close_callback
138
139+ self.setOption(self.NoBackButtonOnStartPage, True)
140+
141+ # PyQt doesn't support the (int, page) version of addPage
142+ # Add the pages in the right order
143+
144+ # pylint: disable=C0103
145+ self.LICENSE_PAGE = self.addPage(LicensePage())
146+ # Dummy page to have a "Next"
147+ self.addPage(QtGui.QWizardPage())
148+
149 # Invalid name "closeEvent"
150 # pylint: disable=C0103
151
152
153=== added directory 'ubuntuone_installer/gui/qt/ui'
154=== added file 'ubuntuone_installer/gui/qt/ui/__init__.py'
155--- ubuntuone_installer/gui/qt/ui/__init__.py 1970-01-01 00:00:00 +0000
156+++ ubuntuone_installer/gui/qt/ui/__init__.py 2011-06-21 18:47:23 +0000
157@@ -0,0 +1,19 @@
158+# -*- coding: utf-8 -*-
159+
160+# Authors: Alejandro J. Cura <alecu@canonical.com>
161+#
162+# Copyright 2011 Canonical Ltd.
163+#
164+# This program is free software: you can redistribute it and/or modify it
165+# under the terms of the GNU General Public License version 3, as published
166+# by the Free Software Foundation.
167+#
168+# This program is distributed in the hope that it will be useful, but
169+# WITHOUT ANY WARRANTY; without even the implied warranties of
170+# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
171+# PURPOSE. See the GNU General Public License for more details.
172+#
173+# You should have received a copy of the GNU General Public License along
174+# with this program. If not, see <http://www.gnu.org/licenses/>.
175+
176+"""The Qt graphical interface for the Ubuntu One Installer."""

Subscribers

People subscribed via source and target branches