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

filelistview: disable innapplicable menu options for various contexts

We have to disable the actions themselves since they have keyboard shortcuts.

Changeset bbbf7eeb50a6

Parent e360b4613734

by Steve Borho

Changes to one file · Browse files at bbbf7eeb50a6 Showing diff from parent e360b4613734 Diff from another changeset...

 
53
54
55
 
56
57
 
 
 
 
 
 
 
 
 
 
58
59
60
 
104
105
106
107
 
 
108
109
110
 
115
116
117
118
 
 
119
120
121
 
151
152
153
 
 
154
155
156
 
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
 
115
116
117
 
118
119
120
121
122
 
127
128
129
 
130
131
132
133
134
 
164
165
166
167
168
169
170
171
@@ -53,8 +53,19 @@
  def setModel(self, model):   QTableView.setModel(self, model)   model.layoutChanged.connect(self.layoutChanged) + model.contextChanged.connect(self.contextChanged)   self.selectionModel().currentRowChanged.connect(self.fileSelected)   self.horizontalHeader().setResizeMode(1, QHeaderView.Stretch) + if model._ctx is not None: + self.contextChanged(model._ctx) + + def contextChanged(self, ctx): + real = type(ctx.rev()) is int + wd = ctx.rev() is None + for act in ['ldiff', 'edit']: + self._actions[act].setEnabled(real) + for act in ['diff', 'revert']: + self._actions[act].setEnabled(real or wd)     def currentFile(self):   index = self.currentIndex() @@ -104,7 +115,8 @@
  return   model = self.model()   pats = [filename] - opts = {'change':str(model._ctx.rev())} + rev = model._ctx.rev() + opts = {'change':model._ctx.rev()}   dlg = visdiff.visualdiff(model.repo.ui, model.repo, pats, opts)   if dlg:   dlg.exec_() @@ -115,7 +127,8 @@
  return   model = self.model()   pats = [filename] - opts = {'rev':[str(model._ctx.rev())]} + assert type(model._ctx.rev()) is int + opts = {'rev':['rev(%d)' % (model._ctx.rev())]}   dlg = visdiff.visualdiff(model.repo.ui, model.repo, pats, opts)   if dlg:   dlg.exec_() @@ -151,6 +164,8 @@
  model = self.model()   repo = model.repo   rev = model._ctx.rev() + if rev is None: + rev = model._ctx.p1().rev()   dlg = revert.RevertDialog(repo, filename, rev, self)   dlg.exec_()