Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 1.9, 1.9.1, and 1.9.2

qtlib: use wildcard import for QtCore and QtGui

Changeset 63e1abb497d5

Parent 3b8fd17d8d36

by Yuya Nishihara

Changes to one file · Browse files at 63e1abb497d5 Showing diff from parent 3b8fd17d8d36 Diff from another changeset...

 
10
11
12
13
 
 
14
15
16
 
87
88
89
90
 
91
92
93
94
95
 
96
97
98
 
148
149
150
151
 
152
153
154
 
167
168
169
170
171
 
 
172
173
 
174
175
176
 
189
190
191
192
 
193
194
 
195
196
197
 
205
206
207
208
 
209
210
211
 
212
213
214
 
215
216
217
218
219
 
 
 
220
221
 
222
223
224
 
225
226
227
 
235
236
237
238
 
239
240
241
 
252
253
254
255
 
256
257
258
259
 
260
261
 
262
263
264
265
 
266
267
 
268
269
270
 
294
295
296
297
 
298
299
 
300
301
302
 
303
304
305
306
307
308
309
 
310
311
 
312
313
314
 
315
316
 
317
318
319
 
330
331
332
333
 
334
335
336
 
337
338
 
339
340
 
341
342
 
343
344
345
 
 
346
347
348
 
372
373
374
375
 
376
377
 
378
379
380
 
384
385
386
387
 
388
389
390
 
391
392
 
393
394
395
396
 
397
398
399
400
401
402
 
 
 
 
403
404
405
 
450
451
452
453
454
455
 
 
 
456
457
458
459
460
461
462
463
464
465
 
 
 
 
 
 
466
467
468
469
470
 
 
471
472
473
 
477
478
479
480
 
481
482
483
 
10
11
12
 
13
14
15
16
17
 
88
89
90
 
91
92
93
94
95
 
96
97
98
99
 
149
150
151
 
152
153
154
155
 
168
169
170
 
 
171
172
173
 
174
175
176
177
 
190
191
192
 
193
194
 
195
196
197
198
 
206
207
208
 
209
210
211
 
212
213
214
 
215
216
217
 
 
 
218
219
220
221
 
222
223
224
 
225
226
227
228
 
236
237
238
 
239
240
241
242
 
253
254
255
 
256
257
258
259
 
260
261
 
262
263
264
265
 
266
267
 
268
269
270
271
 
295
296
297
 
298
299
 
300
301
302
 
303
304
305
306
307
308
309
 
310
311
 
312
313
314
 
315
316
 
317
318
319
320
 
331
332
333
 
334
335
336
 
337
338
 
339
340
 
341
342
 
343
344
 
 
345
346
347
348
349
 
373
374
375
 
376
377
 
378
379
380
381
 
385
386
387
 
388
389
390
 
391
392
 
393
394
395
396
 
397
398
399
 
 
 
 
400
401
402
403
404
405
406
 
451
452
453
 
 
 
454
455
456
457
458
459
460
 
 
 
 
 
 
461
462
463
464
465
466
467
468
469
 
 
470
471
472
473
474
 
478
479
480
 
481
482
483
484
@@ -10,7 +10,8 @@
 import shutil  import tempfile   -from PyQt4 import QtCore, QtGui +from PyQt4.QtCore import * +from PyQt4.QtGui import *  from PyQt4 import Qsci  from mercurial import extensions, util   @@ -87,12 +88,12 @@
  for e in es.split():   if e in _effects:   effects.append(_effects[e]) - elif e in QtGui.QColor.colorNames(): + elif e in QColor.colorNames():   # Accept any valid QColor   effects.append('color: ' + e)   elif e.endswith('_background'):   e = e[:-11] - if e in QtGui.QColor.colorNames(): + if e in QColor.colorNames():   effects.append('bgcolor: ' + e)   return ';'.join(effects)   @@ -148,7 +149,7 @@
  style[name] = value   style = ';'.join(['%s: %s' % t for t in style.items()])   msg = hglib.tounicode(msg) - msg = QtCore.Qt.escape(msg) + msg = Qt.escape(msg)   msg = msg.replace('\n', '<br />')   return '<span style="%s">%s</span>' % (style, msg)   @@ -167,10 +168,10 @@
  for pfx in (':/icons', paths.get_icon_path()):   for ext in ('svg', 'png', 'ico'):   path = '%s/%s.%s' % (pfx, name, ext) - if QtCore.QFile.exists(path): - return QtGui.QIcon(path) + if QFile.exists(path): + return QIcon(path)   - return QtGui.QIcon(':/icons/fallback.svg') + return QIcon(':/icons/fallback.svg')     try:   return _iconcache[name] @@ -189,9 +190,9 @@
  _pixmapcache[key] = pixmap   return pixmap   -def CommonMsgBox(icon, title, main, text='', buttons=QtGui.QMessageBox.Close, +def CommonMsgBox(icon, title, main, text='', buttons=QMessageBox.Close,   labels=[], parent=None): - msg = QtGui.QMessageBox(parent) + msg = QMessageBox(parent)   msg.setIcon(icon)   msg.setWindowTitle(title)   msg.setStandardButtons(buttons) @@ -205,23 +206,23 @@
  return msg.exec_()    def InfoMsgBox(*args, **kargs): - return CommonMsgBox(QtGui.QMessageBox.Information, *args, **kargs) + return CommonMsgBox(QMessageBox.Information, *args, **kargs)    def WarningMsgBox(*args, **kargs): - return CommonMsgBox(QtGui.QMessageBox.Warning, *args, **kargs) + return CommonMsgBox(QMessageBox.Warning, *args, **kargs)    def ErrorMsgBox(*args, **kargs): - return CommonMsgBox(QtGui.QMessageBox.Critical, *args, **kargs) + return CommonMsgBox(QMessageBox.Critical, *args, **kargs)    def QuestionMsgBox(*args, **kargs): - btn = QtGui.QMessageBox.Yes | QtGui.QMessageBox.No - res = CommonMsgBox(QtGui.QMessageBox.Question, buttons=btn, *args, **kargs) - return res == QtGui.QMessageBox.Yes + btn = QMessageBox.Yes | QMessageBox.No + res = CommonMsgBox(QMessageBox.Question, buttons=btn, *args, **kargs) + return res == QMessageBox.Yes   -class CustomPrompt(QtGui.QMessageBox): +class CustomPrompt(QMessageBox):   def __init__(self, title, message, parent, choices, default=None,   esc=None, files=None): - QtGui.QMessageBox.__init__(self, parent) + QMessageBox.__init__(self, parent)     self.setWindowTitle(hglib.toutf(title))   self.setText(hglib.toutf(message)) @@ -235,7 +236,7 @@
  self.setDetailedText(hglib.toutf(msg))   self.hotkeys = {}   for i, s in enumerate(choices): - btn = self.addButton(s, QtGui.QMessageBox.AcceptRole) + btn = self.addButton(s, QMessageBox.AcceptRole)   try:   char = s[s.index('&')+1].lower()   self.hotkeys[char] = btn @@ -252,19 +253,19 @@
  def keyPressEvent(self, event):   for k, btn in self.hotkeys.iteritems():   if event.text() == k: - btn.emit(QtCore.SIGNAL('clicked()')) + btn.emit(SIGNAL('clicked()'))   super(CustomPrompt, self).keyPressEvent(event)    def setup_font_substitutions(): - QtGui.QFont.insertSubstitutions('monospace', ['monaco', 'courier new']) + QFont.insertSubstitutions('monospace', ['monaco', 'courier new'])   -class PMButton(QtGui.QPushButton): +class PMButton(QPushButton):   """Toggle button with plus/minus icon images"""     def __init__(self, expanded=True, parent=None): - QtGui.QPushButton.__init__(self, parent) + QPushButton.__init__(self, parent)   - size = QtCore.QSize(11, 11) + size = QSize(11, 11)   self.setIconSize(size)   self.setMaximumSize(size)   self.setFlat(True) @@ -294,26 +295,26 @@
  def is_collapsed(self):   return not self.is_expanded()   -class ClickableLabel(QtGui.QLabel): +class ClickableLabel(QLabel):   - clicked = QtCore.pyqtSignal() + clicked = pyqtSignal()     def __init__(self, label, parent=None): - QtGui.QLabel.__init__(self, parent) + QLabel.__init__(self, parent)     self.setText(label)     def mouseReleaseEvent(self, event):   self.clicked.emit()   -class ExpanderLabel(QtGui.QWidget): +class ExpanderLabel(QWidget):   - expanded = QtCore.pyqtSignal(bool) + expanded = pyqtSignal(bool)     def __init__(self, label, expanded=True, stretch=True, parent=None): - QtGui.QWidget.__init__(self, parent) + QWidget.__init__(self, parent)   - box = QtGui.QHBoxLayout() + box = QHBoxLayout()   box.setSpacing(4)   box.setContentsMargins(*(0,)*4)   self.button = PMButton(expanded, self) @@ -330,19 +331,19 @@
  def pm_clicked(self):   self.expanded.emit(self.button.is_expanded())   -class StatusLabel(QtGui.QWidget): +class StatusLabel(QWidget):     def __init__(self, parent=None): - QtGui.QWidget.__init__(self, parent) + QWidget.__init__(self, parent)   - box = QtGui.QHBoxLayout() + box = QHBoxLayout()   box.setContentsMargins(*(0,)*4) - self.status_icon = QtGui.QLabel() + self.status_icon = QLabel()   self.status_icon.setMaximumSize(16, 16) - self.status_icon.setAlignment(QtCore.Qt.AlignCenter) + self.status_icon.setAlignment(Qt.AlignCenter)   box.addWidget(self.status_icon) - self.status_text = QtGui.QLabel() - self.status_text.setAlignment(QtCore.Qt.AlignVCenter | QtCore.Qt.AlignLeft) + self.status_text = QLabel() + self.status_text.setAlignment(Qt.AlignVCenter | Qt.AlignLeft)   box.addWidget(self.status_text)   box.addStretch(0)   @@ -372,9 +373,9 @@
  pixmap = icon and getpixmap('success') or getpixmap('error')   elif isinstance(icon, basestring):   pixmap = getpixmap(icon) - elif isinstance(icon, QtGui.QIcon): + elif isinstance(icon, QIcon):   pixmap = icon.pixmap(16, 16) - elif isinstance(icon, QtGui.QPixmap): + elif isinstance(icon, QPixmap):   pixmap = icon   else:   raise TypeError, '%s: bool, str, QIcon or QPixmap' % type(icon) @@ -384,22 +385,22 @@
  def clear_icon(self):   self.status_icon.setHidden(True)   -class LabeledSeparator(QtGui.QWidget): +class LabeledSeparator(QWidget):     def __init__(self, label=None, parent=None): - QtGui.QWidget.__init__(self, parent) + QWidget.__init__(self, parent)   - box = QtGui.QHBoxLayout() + box = QHBoxLayout()   box.setContentsMargins(*(0,)*4)     if label: - label = QtGui.QLabel(label) + label = QLabel(label)   box.addWidget(label)   - sep = QtGui.QFrame() - sep.setFrameShadow(QtGui.QFrame.Sunken) - sep.setFrameShape(QtGui.QFrame.HLine) - box.addWidget(sep, 1, QtCore.Qt.AlignVCenter) + sep = QFrame() + sep.setFrameShadow(QFrame.Sunken) + sep.setFrameShape(QFrame.HLine) + box.addWidget(sep, 1, Qt.AlignVCenter)     self.setLayout(box)   @@ -450,24 +451,24 @@
   def fileEditor(filename):   'Open a simple modal file editing dialog' - dialog = QtGui.QDialog() - dialog.setWindowFlags(dialog.windowFlags() & ~QtCore.Qt.WindowContextHelpButtonHint) - vbox = QtGui.QVBoxLayout() + dialog = QDialog() + dialog.setWindowFlags(dialog.windowFlags() & ~Qt.WindowContextHelpButtonHint) + vbox = QVBoxLayout()   dialog.setLayout(vbox)   editor = qsci()   editor.setBraceMatching(qsci.SloppyBraceMatch)   vbox.addWidget(editor) - BB = QtGui.QDialogButtonBox - bb = QtGui.QDialogButtonBox(BB.Save|BB.Cancel) - dialog.connect(bb, QtCore.SIGNAL('accepted()'), - dialog, QtCore.SLOT('accept()')) - dialog.connect(bb, QtCore.SIGNAL('rejected()'), - dialog, QtCore.SLOT('reject()')) + BB = QDialogButtonBox + bb = QDialogButtonBox(BB.Save|BB.Cancel) + dialog.connect(bb, SIGNAL('accepted()'), + dialog, SLOT('accept()')) + dialog.connect(bb, SIGNAL('rejected()'), + dialog, SLOT('reject()'))   vbox.addWidget(bb)   lexer = Qsci.QsciLexerProperties()   editor.setLexer(lexer) - s = QtCore.QSettings() - ret = QtGui.QDialog.Rejected + s = QSettings() + ret = QDialog.Rejected   try:   contents = open(filename, 'rb').read()   dialog.setWindowTitle(filename) @@ -477,7 +478,7 @@
  editor.setModified(False)   dialog.restoreGeometry(s.value(geomname).toByteArray())   ret = dialog.exec_() - if ret == QtGui.QDialog.Accepted: + if ret == QDialog.Accepted:   f = util.atomictempfile(filename, 'wb', createmode=None)   f.write(hglib.fromunicode(editor.text()))   f.rename()