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

qtlib: define new class TaskWidget

Provides a default implementation of a function canswitch. If canswitch
returns True, the task widget "agrees" to switch away from it when a new
revision / patch is selected.

repowidget.RepoWidget.onRevisionClicked calls canswitch(). If it returns
False, no task tab switch occurs.

All task widgets are now also derived from qtlib.TaskWidget, so they get the
default canswitch() implementation, which always returns True.

manifestdialog.ManifestWidget overrides canswitch to return False. So the
decision if switching is allowed is moved into the implementation of that
widget.

qtlib.DemandWidget also got a canswitch function which returns True if
the widget wasn't yet created. If it's already created, it calls canswitch()
on the widget.

For the future, this design allows to deny a task tab switch dynamically,
that is, depending on some state of the task widget (not yet used).

Changeset 23808f9cf85e

Parent 708d95144c97

by Adrian Buehlmann

Changes to 9 files · Browse files at 23808f9cf85e Showing diff from parent 708d95144c97 Diff from another changeset...

 
154
155
156
157
 
158
159
160
 
154
155
156
 
157
158
159
160
@@ -154,7 +154,7 @@
  else:   super(MessageEntry, self).keyPressEvent(event)   -class CommitWidget(QWidget): +class CommitWidget(QWidget, qtlib.TaskWidget):   'A widget that encompasses a StatusWidget and commit extras'   commitButtonEnable = pyqtSignal(bool)   linkActivated = pyqtSignal(QString)
 
20
21
22
23
 
24
25
26
 
20
21
22
 
23
24
25
26
@@ -20,7 +20,7 @@
 # This widget can be embedded in any application that would like to  # provide search features   -class SearchWidget(QWidget): +class SearchWidget(QWidget, qtlib.TaskWidget):   '''Working copy and repository search widget'''   showMessage = pyqtSignal(QString)   progress = pyqtSignal(QString, object, QString, QString, object)
 
90
91
92
93
 
94
95
96
 
111
112
113
 
 
 
114
115
116
 
90
91
92
 
93
94
95
96
 
111
112
113
114
115
116
117
118
119
@@ -90,7 +90,7 @@
  _openineditor(self._repo, path, rev, line,   pattern=self._fileview.searchbar.pattern(), parent=self)   -class ManifestWidget(QWidget): +class ManifestWidget(QWidget, qtlib.TaskWidget):   """Display file tree and contents at the specified revision"""     revChanged = pyqtSignal(object) @@ -111,6 +111,9 @@
  filecontextmenu = None   subrepocontextmenu = None   + def canswitch(self): + return False +   def __init__(self, repo, rev=None, parent=None):   super(ManifestWidget, self).__init__(parent)   self._repo = repo
 
533
534
535
536
 
537
538
539
 
533
534
535
 
536
537
538
539
@@ -533,7 +533,7 @@
  return super(MQPatchesWidget, self).keyPressEvent(event)     -class MQWidget(QWidget): +class MQWidget(QWidget, qtlib.TaskWidget):   showMessage = pyqtSignal(unicode)   output = pyqtSignal(QString, QString)   progress = pyqtSignal(QString, object, QString, QString, object)
 
22
23
24
25
 
26
27
28
 
22
23
24
 
25
26
27
28
@@ -22,7 +22,7 @@
 PATCHCACHEPATH = 'thgpbcache'  nullvariant = QVariant()   -class PatchBranchWidget(QWidget): +class PatchBranchWidget(QWidget, qtlib.TaskWidget):   '''   A widget that show the patch graph and provide actions   for the pbranch extension
 
891
892
893
 
 
 
 
 
894
895
896
 
924
925
926
 
 
 
 
 
 
927
928
929
 
891
892
893
894
895
896
897
898
899
900
901
 
929
930
931
932
933
934
935
936
937
938
939
940
@@ -891,6 +891,11 @@
  def set_enable(self, *args, **kargs):   self.set_prop('setEnabled', *args, **kargs)   +class TaskWidget(object): + def canswitch(self): + """Return True if the widget allows to switch away from it""" + return True +  class DemandWidget(QWidget):   'Create a widget the first time it is shown'   @@ -924,6 +929,12 @@
  self.layout().addWidget(self._widget)   return self._widget   + def canswitch(self): + """Return True if the widget allows to switch away from it""" + if self._widget is None: + return True + return self._widget.canswitch() +   def __getattr__(self, name):   return getattr(self._widget, name)  
 
685
686
687
688
689
690
 
 
 
691
692
693
 
685
686
687
 
 
 
688
689
690
691
692
693
@@ -685,9 +685,9 @@
  def onRevisionClicked(self, rev):   'User clicked on a repoview row'   tw = self.taskTabsWidget - manifestidx = self.namedTabs['manifest'] - if tw.currentIndex() == manifestidx: - return # don't switch tabs if we are in manifest mode + cw = tw.currentWidget() + if not cw.canswitch(): + return   ctx = self.repo.changectx(rev)   if rev is None:   # Clicking on working copy switches to commit tab
 
23
24
25
26
 
27
28
29
 
23
24
25
 
26
27
28
29
@@ -23,7 +23,7 @@
 from PyQt4.QtCore import *  from PyQt4.QtGui import *   -class RevDetailsWidget(QWidget): +class RevDetailsWidget(QWidget, qtlib.TaskWidget):     showMessage = pyqtSignal(QString)   linkActivated = pyqtSignal(unicode)
 
50
51
52
53
 
54
55
56
 
50
51
52
 
53
54
55
56
@@ -50,7 +50,7 @@
  scheme = 'local'   return user, host, port, folder, passwd, scheme   -class SyncWidget(QWidget): +class SyncWidget(QWidget, qtlib.TaskWidget):   outgoingNodes = pyqtSignal(object)   incomingBundle = pyqtSignal(QString)   showMessage = pyqtSignal(unicode)