1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304 | --- /home/neo/ubiquity/pyqt4topyqt5/kde_ui.py 2016-08-17 15:53:22.337206951 +0100
+++ /home/neo/ubiquity/pyqt4topyqt5/kde_ui_PyQt5.py 2016-08-17 15:56:52.421016567 +0100
@@ -39,7 +39,7 @@
# kde gui specifics
import sip
sip.setapi("QVariant", 1)
-from PyQt4 import QtCore, QtGui, uic
+from PyQt5 import QtCore, QtGui, QtWidgets, uic
from ubiquity import filteredcommand, i18n, misc
from ubiquity.components import partman_commit, install, plugininstall
@@ -63,9 +63,9 @@
UIDIR = os.path.join(PATH, 'qt')
-class UbiquityUI(QtGui.QMainWindow):
+class UbiquityUI(QtWidgets.QMainWindow):
def __init__(self, parent=None):
- QtGui.QMainWindow.__init__(self, parent)
+ QtWidgets.QMainWindow.__init__(self, parent)
# app.ui MainWindow now hardcoded to 1000px wide for main
# content this will look bad on high res displays and should be
# defined by dpi not pixels
@@ -173,7 +173,7 @@
# Pretty much all of the above but for Qt5
os.environ["QT_QPA_PLATFORMTHEME"] = "kde"
- self.app = QtGui.QApplication([])
+ self.app = QtWidgets.QApplication([])
# The "hicolor" icon theme gets picked when Ubiquity is running as a
# DM. This causes some icons to be missing. Hardcode the theme name to
# prevent that.
@@ -200,17 +200,17 @@
self.icon_widget.load(logoDirectory + distro + ".svgz")
else:
self.icon_widget.load(logoDirectory + "branding.svgz")
- branding_layout = QtGui.QHBoxLayout()
- branding_layout.addItem(QtGui.QSpacerItem(1, 1,
- QtGui.QSizePolicy.Expanding,
- QtGui.QSizePolicy.Minimum))
+ branding_layout = QtWidgets.QHBoxLayout()
+ branding_layout.addItem(QtWidgets.QSpacerItem(1, 1,
+ QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Minimum))
branding_layout.addWidget(self.icon_widget)
- branding_layout.addItem(QtGui.QSpacerItem(1, 1,
- QtGui.QSizePolicy.Expanding,
- QtGui.QSizePolicy.Minimum))
- branding_spacer = QtGui.QSpacerItem(1, 1,
- QtGui.QSizePolicy.Minimum,
- QtGui.QSizePolicy.Expanding)
+ branding_layout.addItem(QtWidgets.QSpacerItem(1, 1,
+ QtWidgets.QSizePolicy.Expanding,
+ QtWidgets.QSizePolicy.Minimum))
+ branding_spacer = QtWidgets.QSpacerItem(1, 1,
+ QtWidgets.QSizePolicy.Minimum,
+ QtWidgets.QSizePolicy.Expanding)
self.ui.sidebar_widget.layout().addItem(branding_spacer)
self.ui.sidebar_widget.layout().addItem(branding_layout)
@@ -228,7 +228,7 @@
self.ui.setWizard(self)
- self.stackLayout = QtGui.QStackedLayout(self.ui.content_widget)
+ self.stackLayout = QtWidgets.QStackedLayout(self.ui.content_widget)
self.pages = []
self.pagesindex = 0
@@ -360,7 +360,7 @@
def _apply_stylesheet(self):
qss = qssutils.load("style.qss",
- ltr=QtGui.QApplication.isLeftToRight())
+ ltr=QtWidgets.QApplication.isLeftToRight())
self.app.setStyleSheet(qss)
def excepthook(self, exctype, excvalue, exctb):
@@ -384,28 +384,25 @@
if os.path.exists('/usr/share/apport/apport-qt'):
self.previous_excepthook(exctype, excvalue, exctb)
else:
- dialog = QtGui.QDialog(self.ui)
+ dialog = QtWidgets.QDialog(self.ui)
uic.loadUi("%s/crashdialog.ui" % UIDIR, dialog)
dialog.crash_detail.setText(tbtext)
dialog.exec_()
sys.exit(1)
def network_change(self, online=False):
- from PyQt4.QtCore import QTimer, SIGNAL
+ from PyQt5.QtCore import QTimer
if not online:
self.set_online_state(False)
return
QTimer.singleShot(300, self.check_returncode)
self.timer = QTimer(self.ui)
- self.timer.connect(
- self.timer, SIGNAL("timeout()"), self.check_returncode)
+ self.timer.timeout.connect(self.check_returncode)
self.timer.start(300)
def check_returncode(self, *args):
- from PyQt4.QtCore import SIGNAL
if not BaseFrontend.check_returncode(self, args):
- self.timer.disconnect(
- self.timer, SIGNAL("timeout()"), self.check_returncode)
+ self.timer.timeout.disconnect(self.check_returncode)
def set_online_state(self, state):
for p in self.pages:
@@ -429,7 +426,7 @@
if os.getuid() != 0:
title = ('This installer must be run with administrative '
'privileges, and cannot continue without them.')
- QtGui.QMessageBox.critical(self.ui, "Must be root", title)
+ QtWidgets.QMessageBox.critical(self.ui, "Must be root", title)
sys.exit(1)
self.disable_volume_manager()
@@ -542,18 +539,18 @@
'ubiquity/finished_restart_only')
quitText = quitText.replace(
'${RELEASE}', misc.get_release().name)
- messageBox = QtGui.QMessageBox(
- QtGui.QMessageBox.Question, titleText,
- quitText, QtGui.QMessageBox.NoButton, self.ui)
+ messageBox = QtWidgets.QMessageBox(
+ QtWidgets.QMessageBox.Question, titleText,
+ quitText, QtWidgets.QMessageBox.NoButton, self.ui)
messageBox.addButton(
- rebootButtonText, QtGui.QMessageBox.AcceptRole)
+ rebootButtonText, QtWidgets.QMessageBox.AcceptRole)
if self.show_shutdown_button:
messageBox.addButton(shutdownButtonText,
- QtGui.QMessageBox.AcceptRole)
+ QtWidgets.QMessageBox.AcceptRole)
if ('UBIQUITY_ONLY' not in os.environ and
'UBIQUITY_GREETER' not in os.environ):
messageBox.addButton(
- quitButtonText, QtGui.QMessageBox.RejectRole)
+ quitButtonText, QtWidgets.QMessageBox.RejectRole)
messageBox.setWindowFlags(messageBox.windowFlags() |
QtCore.Qt.WindowStaysOnTopHint)
quitAnswer = messageBox.exec_()
@@ -591,8 +588,8 @@
# the slideshow does not start (but it starts if one runs
# UBIQUITY_TEST_SLIDESHOW=1 ubiquity !). Creating it from the code
# works. I have no idea why.
- from PyQt4.QtWebKit import QWebView
- from PyQt4.QtWebKit import QWebPage
+ from PyQt5.QtWebKitWidgets import QWebView
+ from PyQt5.QtWebKitWidgets import QWebPage
webView = QWebView()
webView.setMinimumSize(700, 420)
@@ -620,7 +617,7 @@
self.locale)
slideshow_main = os.path.join(slideshow_dir, 'slides', 'index.html')
if not os.path.exists(slideshow_main) or self.hide_slideshow:
- placeHolder = QtGui.QWidget()
+ placeHolder = QtWidgets.QWidget()
self.stackLayout.addWidget(placeHolder)
self.stackLayout.setCurrentWidget(placeHolder)
return
@@ -772,7 +769,7 @@
if lang is None:
lang = self.locale
# FIXME needs translations for Next, Back and Cancel
- if not isinstance(widget, QtGui.QWidget):
+ if not isinstance(widget, QtWidgets.QWidget):
return
name = str(widget.objectName())
@@ -785,7 +782,7 @@
if text is None:
return
- if isinstance(widget, (QtGui.QLabel, Breadcrumb)):
+ if isinstance(widget, (QtWidgets.QLabel, Breadcrumb)):
if name == 'select_language_label' and self.oem_user_config:
text = self.get_string(
'select_language_oem_user_label', lang, prefix)
@@ -804,10 +801,10 @@
else:
widget.setText(text)
- elif isinstance(widget, QtGui.QAbstractButton):
+ elif isinstance(widget, QtWidgets.QAbstractButton):
widget.setText(text.replace('_', '&', 1))
- elif (isinstance(widget, QtGui.QWidget) and
+ elif (isinstance(widget, QtWidgets.QWidget) and
str(name) == "UbiquityUIBase"):
if self.custom_title:
text = self.custom_title
@@ -862,16 +859,16 @@
# FIXME QMessageBox seems to have lost the ability to set custom
# labels so for now we have to get by with these not-entirely
# meaningful stock labels
- answer = QtGui.QMessageBox.warning(
+ answer = QtWidgets.QMessageBox.warning(
self.ui, '%s crashed' % self.dbfilter_status[0], text,
- QtGui.QMessageBox.Retry,
- QtGui.QMessageBox.Ignore,
- QtGui.QMessageBox.Close)
+ QtWidgets.QMessageBox.Retry,
+ QtWidgets.QMessageBox.Ignore,
+ QtWidgets.QMessageBox.Close)
self.dbfilter_status = None
syslog.syslog('dbfilter_handle_status: answer %d' % answer)
- if answer == QtGui.QMessageBox.Ignore:
+ if answer == QtWidgets.QMessageBox.Ignore:
return True
- elif answer == QtGui.QMessageBox.Close:
+ elif answer == QtWidgets.QMessageBox.Close:
self.quit()
else:
step = self.step_name(self.get_current_page())
@@ -892,7 +889,7 @@
return 0
def update_back_button(self):
- if QtGui.QApplication.isRightToLeft():
+ if QtWidgets.QApplication.isRightToLeft():
icon = "go-next"
else:
icon = "go-previous"
@@ -907,7 +904,7 @@
icon = "dialog-ok-apply"
else:
text = self.get_string('next')
- if QtGui.QApplication.isRightToLeft():
+ if QtWidgets.QApplication.isRightToLeft():
icon = "go-previous"
else:
icon = "go-next"
@@ -1049,18 +1046,18 @@
abortTitle = self.get_string("warning_dialog")
yes = self.get_string('yes', prefix='ubiquity/imported')
no = self.get_string('no', prefix='ubiquity/imported')
- messageBox = QtGui.QMessageBox()
+ messageBox = QtWidgets.QMessageBox()
messageBox.setWindowTitle(abortTitle)
messageBox.setText(warning_dialog_label)
messageBox.setStandardButtons(
- QtGui.QMessageBox.Yes | QtGui.QMessageBox.No)
- messageBox.setDefaultButton(QtGui.QMessageBox.Yes)
- messageBox.button(QtGui.QMessageBox.Yes).setText(
+ QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
+ messageBox.setDefaultButton(QtWidgets.QMessageBox.Yes)
+ messageBox.button(QtWidgets.QMessageBox.Yes).setText(
yes.replace('_', '&', 1))
- messageBox.button(QtGui.QMessageBox.No).setText(
+ messageBox.button(QtWidgets.QMessageBox.No).setText(
no.replace('_', '&', 1))
response = messageBox.exec_()
- if response == QtGui.QMessageBox.Yes:
+ if response == QtWidgets.QMessageBox.Yes:
self.current_page = None
self.quit()
return True
@@ -1278,7 +1275,7 @@
# result.
# TODO: We may want to call return_to_partitioning after the crash
# dialog instead.
- dialog = QtGui.QDialog(self.ui)
+ dialog = QtWidgets.QDialog(self.ui)
uic.loadUi("%s/crashdialog.ui" % UIDIR, dialog)
dialog.exec_()
sys.exit(1)
@@ -1375,7 +1372,7 @@
saved_busy_cursor = self.busy_cursor
self.set_busy_cursor(False)
# TODO: cancel button as well if capb backup
- QtGui.QMessageBox.warning(self.ui, title, msg, QtGui.QMessageBox.Ok)
+ QtWidgets.QMessageBox.warning(self.ui, title, msg, QtWidgets.QMessageBox.Ok)
self.set_busy_cursor(saved_busy_cursor)
if fatal:
self.return_to_partitioning()
@@ -1388,8 +1385,8 @@
saved_busy_cursor = self.busy_cursor
self.set_busy_cursor(False)
buttons = {}
- messageBox = QtGui.QMessageBox(QtGui.QMessageBox.Question, title, msg,
- QtGui.QMessageBox.NoButton, self.ui)
+ messageBox = QtWidgets.QMessageBox(QtWidgets.QMessageBox.Question, title, msg,
+ QtWidgets.QMessageBox.NoButton, self.ui)
for option in options:
if use_templates:
text = self.get_string(option)
@@ -1402,10 +1399,10 @@
# KDE convention is to have it first.
if option == options[-1]:
button = messageBox.addButton(
- text, QtGui.QMessageBox.AcceptRole)
+ text, QtWidgets.QMessageBox.AcceptRole)
else:
button = messageBox.addButton(
- text, QtGui.QMessageBox.RejectRole)
+ text, QtWidgets.QMessageBox.RejectRole)
buttons[button] = option
response = messageBox.exec_()
|