Kiln » TortoiseHg » TortoiseHg
Clone URL:  
Pushed to one repository · View In Graph Contained in 2.1, 2.1.1, and 2.1.2

repowidget: show status of sync operation at InfoBar area

Now InfoBar area has a priority. Error messages are not hidden by status
messages, which priority is lower than error.

Changeset 2ecbd136e053

Parent 105f1d354e0b

by Yuya Nishihara

Changes to 2 files · Browse files at 2ecbd136e053 Showing diff from parent 105f1d354e0b Diff from another changeset...

 
783
784
785
 
 
 
 
 
 
 
 
786
787
788
 
783
784
785
786
787
788
789
790
791
792
793
794
795
796
@@ -783,6 +783,14 @@
  def addRightWidget(self, w):   self.layout().insertWidget(self.layout().count() - 1, w)   +class StatusInfoBar(InfoBar): + """Show status message""" + def __init__(self, message, parent=None): + super(StatusInfoBar, self).__init__(parent) + self._msglabel = QLabel(message, self, + textInteractionFlags=Qt.TextSelectableByMouse) + self.addWidget(self._msglabel) +  class CommandErrorInfoBar(InfoBar):   """Show command execution failure (with link to open log window)"""   infobartype = InfoBar.ERROR
 
245
246
247
248
249
 
 
 
 
 
 
 
 
250
251
252
253
254
255
256
 
 
257
258
 
 
 
259
 
 
 
260
261
262
263
264
265
 
 
 
 
 
 
 
266
267
268
 
306
307
308
 
309
310
311
 
674
675
676
 
677
678
679
 
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
 
324
325
326
327
328
329
330
 
693
694
695
696
697
698
699
@@ -245,24 +245,42 @@
  QDesktopServices.openUrl(QUrl(link))     def setInfoBar(self, cls, *args, **kwargs): - """Show the given infobar at top of RepoWidget""" - self.clearInfoBar() + """Show the given infobar at top of RepoWidget + + If the priority of the current infobar is higher than new one, + the request is silently ignored. + """ + cleared = self.clearInfoBar(priority=cls.infobartype) + if not cleared: + return   w = cls(*args, **kwargs)   w.linkActivated.connect(self._openLink)   self._infobarlayout.insertWidget(0, w)   return w   - def clearInfoBar(self): - """Close current infobar if available""" + def clearInfoBar(self, priority=None): + """Close current infobar if available; return True if got empty"""   it = self._infobarlayout.itemAt(0) - if it: + if not it: + return True + if priority is None or it.widget().infobartype <= priority:   it.widget().close() + return True + else: + return False     @pyqtSlot(unicode, unicode)   def _showOutputOnInfoBar(self, msg, label):   if label == 'ui.error':   self.setInfoBar(qtlib.CommandErrorInfoBar, unicode(msg).strip())   + @pyqtSlot(unicode) + def _showMessageOnInfoBar(self, msg): + if msg: + self.setInfoBar(qtlib.StatusInfoBar, msg) + else: + self.clearInfoBar(priority=qtlib.StatusInfoBar.infobartype) +   def createCommitWidget(self):   pats, opts = {}, {}   cw = CommitWidget(self.repo, pats, opts, True, self) @@ -306,6 +324,7 @@
  sw.makeLogVisible.connect(self.makeLogVisible)   sw.outgoingNodes.connect(self.setOutgoingNodes)   sw.showMessage.connect(self.showMessage) + sw.showMessage.connect(self._showMessageOnInfoBar)   sw.incomingBundle.connect(self.setBundle)   sw.pullCompleted.connect(self.onPullCompleted)   sw.showBusyIcon.connect(self.onShowBusyIcon) @@ -674,6 +693,7 @@
  def onRevisionSelected(self, rev):   'View selection changed, could be a reload'   self.showMessage('') + self.clearInfoBar(qtlib.InfoBar.INFO)   if self.repomodel.graph is None:   return   try: