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

quickop: switch to integrated cmdui.Widget

I did not hook up a 'show details' button, since these are supposed
to be "quick" operations. It should popup if there are any errors.

Changeset d823b18bfc1f

Parent fed37ba95b82

by Steve Borho

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

 
72
73
74
 
 
 
 
 
 
 
 
 
75
76
77
 
88
89
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
92
93
 
100
101
102
103
104
105
106
 
 
 
 
 
 
107
108
109
110
111
112
113
114
115
116
 
117
118
119
 
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
 
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
123
124
125
 
 
 
 
126
127
128
129
130
131
132
133
134
 
 
 
 
 
 
 
135
136
137
138
@@ -72,6 +72,15 @@
  bb.button(BB.Ok).setDefault(True)   bb.button(BB.Ok).setText(LABELS[command][1])   layout.addWidget(bb) + self.bb = bb + + cmd = cmdui.Widget() + cmd.commandStarted.connect(self.commandStarted) + cmd.commandFinished.connect(self.commandFinished) + cmd.commandCanceling.connect(self.commandCanceled) + layout.addWidget(cmd) + cmd.setHidden(True) + self.cmd = cmd     s = QtCore.QSettings()   stwidget.restoreState(s.value('quickop/state').toByteArray()) @@ -88,6 +97,20 @@
  return   return super(QtGui.QDialog, self).keyPressEvent(event)   + def commandStarted(self): + self.cmd.setShown(True) + self.bb.button(QtGui.QDialogButtonBox.Ok).setEnabled(False) + + def commandFinished(self, wrapper): + self.bb.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) + if wrapper.data is not 0: + self.cmd.show_output(True) + else: + self.reject() + + def commandCanceled(self): + self.bb.button(QtGui.QDialogButtonBox.Ok).setEnabled(True) +   def accept(self):   cmdline = [self.command]   if hasattr(self, 'chk') and self.chk.isChecked(): @@ -100,20 +123,16 @@
  _('No operation to perform'),   parent=self)   return - cmd = cmdui.Dialog(cmdline, parent=self) - cmd.setWindowTitle('hg ' + self.command) - cmd.show_output(False) - if cmd.exec_(): + self.cmd.run(cmdline) + + def reject(self): + if self.cmd.core.is_running(): + self.cmd.core.cancel() + else:   s = QtCore.QSettings()   s.setValue('quickop/state', self.stwidget.saveState())   s.setValue('quickop/geom', self.saveGeometry()) - QtGui.QDialog.accept(self) - - def reject(self): - s = QtCore.QSettings() - s.setValue('quickop/state', self.stwidget.saveState()) - s.setValue('quickop/geom', self.saveGeometry()) - QtGui.QDialog.reject(self) + QtGui.QDialog.reject(self)    def run(ui, *pats, **opts):   pats = hglib.canonpaths(pats)