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

stable cmdui: give Widget three mandatory parameters

* logWidget - tell Core instance to create a log widget
* statusBar - create and connect a status/progress bar
* parent - a parent widget

Nearly all Widget users will need a logWidget, but a portion of
them will not want a status bar.

Changeset 29caeb413598

Parent f50560f2ee7a

by Steve Borho

Changes to 16 files · Browse files at 29caeb413598 Showing diff from parent f50560f2ee7a Diff from another changeset...

 
89
90
91
92
 
93
94
95
 
89
90
91
 
92
93
94
95
@@ -89,7 +89,7 @@
  self.grid.addWidget(self.keep_open_chk, 10, 1)     # command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, True, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)
 
97
98
99
100
 
101
102
103
 
97
98
99
 
100
101
102
103
@@ -97,7 +97,7 @@
  box.addWidget(self.reslabel)     ## command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, False, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)
 
51
52
53
54
 
55
56
57
 
51
52
53
 
54
55
56
57
@@ -51,7 +51,7 @@
  box.addLayout(hbox)     ## command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, False, self)   self.cmd.setShowOutput(True)   box.addWidget(self.cmd, 1)  
 
128
129
130
131
 
132
133
134
 
128
129
130
 
131
132
133
134
@@ -128,7 +128,7 @@
  stretch=40)     ## command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, True, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandFinished.connect(self.cmdfinished)
 
141
142
143
144
 
145
146
147
 
151
152
153
154
155
 
156
157
158
 
283
284
285
286
 
287
288
289
 
501
502
503
504
 
505
506
507
 
642
643
644
645
 
646
647
648
649
 
650
651
652
653
654
655
 
656
657
658
659
660
 
661
662
663
664
 
665
666
667
668
669
670
671
672
673
 
 
 
 
 
 
674
675
676
 
681
682
683
684
 
685
686
687
688
 
689
690
691
 
803
804
805
806
 
807
808
809
810
811
 
812
813
814
815
816
817
818
819
820
821
822
823
824
 
840
841
842
843
 
844
845
846
 
848
849
850
 
851
852
853
 
141
142
143
 
144
145
146
147
 
151
152
153
 
 
154
155
156
157
 
282
283
284
 
285
286
287
288
 
500
501
502
 
503
504
505
506
 
641
642
643
 
644
645
646
 
 
647
648
649
650
651
652
 
653
654
655
656
657
658
659
660
661
662
 
663
664
 
 
 
 
 
 
 
 
665
666
667
668
669
670
671
672
673
 
678
679
680
 
681
682
683
684
 
685
686
687
688
 
800
801
802
 
803
804
 
805
 
 
806
807
808
809
 
810
811
812
 
 
 
813
814
815
 
831
832
833
 
834
835
836
837
 
839
840
841
842
843
844
845
@@ -141,7 +141,7 @@
  output = pyqtSignal(QString, QString)   progress = pyqtSignal(QString, object, QString, QString, object)   - def __init__(self, useInternal, parent): + def __init__(self, logWindow, parent):   super(Core, self).__init__(parent)     self.thread = None @@ -151,8 +151,7 @@
  self.rawoutlines = []   self.display = None   self.useproc = False - self.internallog = useInternal - if useInternal: + if logWindow:   self.outputLog = LogWidget()   self.outputLog.installEventFilter(qscilib.KeyPressInterceptor(self))   self.output.connect(self.outputLog.appendLog) @@ -283,7 +282,7 @@
  return True     def clearOutput(self): - if self.internallog: + if hasattr(self, 'outputLog'):   self.outputLog.clear()     ### Signal Handlers ### @@ -501,7 +500,7 @@
    @util.propertycache   def _cmdcore(self): - cmdcore = Core(useInternal=False, parent=self) + cmdcore = Core(False, self)   cmdcore.output.connect(self._logwidget.appendLog)   cmdcore.commandStarted.connect(self.closePrompt)   cmdcore.commandFinished.connect(self.openPrompt) @@ -642,35 +641,33 @@
  progress = pyqtSignal(QString, object, QString, QString, object)   makeLogVisible = pyqtSignal(bool)   - def __init__(self, useInternal=True, parent=None): + def __init__(self, logWindow, statusBar, parent):   super(Widget, self).__init__(parent)   - self.internallog = useInternal - self.core = Core(useInternal, self) + self.core = Core(logWindow, self)   self.core.commandStarted.connect(self.commandStarted)   self.core.commandFinished.connect(self.onCommandFinished)   self.core.commandCanceling.connect(self.commandCanceling)   self.core.output.connect(self.output)   self.core.progress.connect(self.progress) - if not useInternal: + if not logWindow:   return     vbox = QVBoxLayout()   vbox.setSpacing(4)   vbox.setContentsMargins(*(1,)*4) + self.setLayout(vbox)     # command output area   self.core.outputLog.setHidden(True) - vbox.addWidget(self.core.outputLog, 1) + self.layout().addWidget(self.core.outputLog, 1)   - ## status and progress labels - self.stbar = ThgStatusBar() - self.stbar.setSizeGripEnabled(False) - self.core.setStbar(self.stbar) - vbox.addWidget(self.stbar) - - # widget setting - self.setLayout(vbox) + if statusBar: + ## status and progress labels + self.stbar = ThgStatusBar() + self.stbar.setSizeGripEnabled(False) + self.core.setStbar(self.stbar) + self.layout().addWidget(self.stbar)     ### Public Methods ###   @@ -681,11 +678,11 @@
  self.core.cancel()     def setShowOutput(self, visible): - if self.internallog: + if hasattr(self.core, 'outputLog'):   self.core.outputLog.setShown(visible)     def outputShown(self): - if self.internallog: + if hasattr(self.core, 'outputLog'):   return self.core.outputLog.isVisible()   else:   return False @@ -803,22 +800,16 @@
  progress = pyqtSignal(QString, object, QString, QString, object)   makeLogVisible = pyqtSignal(bool)   - def __init__(self, useInternal, parent): + def __init__(self, logWindow, parent):   super(Runner, self).__init__(parent) - self.internallog = useInternal   self.title = _('TortoiseHg') - - self.core = Core(useInternal, parent) + self.core = Core(logWindow, parent)   self.core.commandStarted.connect(self.commandStarted)   self.core.commandFinished.connect(self.onCommandFinished)   self.core.commandCanceling.connect(self.commandCanceling) -   self.core.output.connect(self.output)   self.core.progress.connect(self.progress)   - if useInternal: - self.core.outputLog.setMinimumSize(460, 320) -   ### Public Methods ###     def setTitle(self, title): @@ -840,7 +831,7 @@
  return False     def setShowOutput(self, visible=True): - if not self.internallog: + if not hasattr(self.core, 'outputLog'):   return   if not hasattr(self, 'dlg'):   self.dlg = dlg = QDialog(self.parent()) @@ -848,6 +839,7 @@
  dlg.setWindowFlags(Qt.Dialog)   dlg.setLayout(QVBoxLayout())   dlg.layout().addWidget(self.core.outputLog) + self.core.outputLog.setMinimumSize(460, 320)   self.dlg.setVisible(visible)     ### Signal Handler ###
 
50
51
52
53
 
54
55
56
 
50
51
52
 
53
54
55
56
@@ -50,7 +50,7 @@
  self.destcsinfo = dest   self.layout().addWidget(destb)   - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, False, self)   self.cmd.commandFinished.connect(self.commandFinished)   self.cmd.setShowOutput(True)   self.showMessage.connect(self.cmd.stbar.showMessage)
 
118
119
120
121
 
122
123
124
 
118
119
120
 
121
122
123
124
@@ -118,7 +118,7 @@
  # perform pane   ppane = QVBoxLayout()   ppane.addSpacing(4) - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, True, self)   self.cmd.setShowOutput(True)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)
 
78
79
80
81
 
82
83
84
 
78
79
80
 
81
82
83
84
@@ -78,7 +78,7 @@
  else:   self.svnchk = None   - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, False, self)   self.cmd.commandFinished.connect(self.commandFinished)   self.showMessage.connect(self.cmd.stbar.showMessage)   self.cmd.stbar.linkActivated.connect(self.linkActivated)
 
83
84
85
86
 
87
88
89
 
83
84
85
 
86
87
88
89
@@ -83,7 +83,7 @@
  self.keep_open_chk = QCheckBox(_('Always show output'))     # command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, False, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)
 
127
128
129
130
 
131
132
133
 
127
128
129
 
130
131
132
133
@@ -127,7 +127,7 @@
    out = qtlib.LabeledSeparator(_('Command output'))   self.layout().addWidget(out) - self.cmd = cmdui.Widget(True, self) + self.cmd = cmdui.Widget(True, False, self)   self.cmd.commandFinished.connect(self.refresh)   self.cmd.setShowOutput(True)   self.layout().addWidget(self.cmd)
 
36
37
38
39
40
41
 
42
43
44
45
46
 
62
63
64
65
66
67
68
69
 
36
37
38
 
 
 
39
40
 
41
42
43
 
59
60
61
 
 
62
63
64
@@ -36,11 +36,8 @@
  self.allchk = QCheckBox(_('Revert all files to this revision'))   self.layout().addWidget(self.allchk)   - self.cmd = cmdui.Widget() - self.cmd.setShowOutput(False) - self.cmd.stbar.setVisible(False) + self.cmd = cmdui.Runner(True, self)   self.cmd.commandFinished.connect(self.finished) - self.layout().addWidget(self.cmd, 1)     BB = QDialogButtonBox   bbox = QDialogButtonBox(BB.Ok|BB.Cancel) @@ -62,8 +59,6 @@
  else:   cmdline = ['revert', '--repository', self.repo.root, self.wfile]   cmdline += ['--rev', self.rev] - self.cmd.setShowOutput(True) - self.cmd.stbar.setVisible(True)   self.cmd.run(cmdline)     def finished(self, ret):
 
34
35
36
37
 
38
39
40
 
34
35
36
 
37
38
39
40
@@ -34,7 +34,7 @@
  self._updateform()     def _initcmd(self): - self._cmd = cmdui.Widget() + self._cmd = cmdui.Widget(True, False, self)   # TODO: forget old logs?   self._log_edit = self._cmd.core.outputLog   self._qui.details_tabs.addTab(self._log_edit, _('Log'))
 
242
243
244
245
 
246
247
248
249
250
251
 
242
243
244
 
245
246
247
 
248
249
250
@@ -242,10 +242,9 @@
  self.postpullbutton.clicked.connect(self.postpullclicked)   self.optionsbutton.pressed.connect(self.editOptions)   - cmd = cmdui.Widget(not self.embedded, self) + cmd = cmdui.Widget(not self.embedded, True, self)   cmd.commandStarted.connect(self.commandStarted)   cmd.commandFinished.connect(self.commandFinished) -   cmd.makeLogVisible.connect(self.makeLogVisible)   cmd.output.connect(self.output)   cmd.progress.connect(self.progress)
 
89
90
91
92
 
93
94
95
 
89
90
91
 
92
93
94
95
@@ -89,7 +89,7 @@
  grid.addItem(statbox, 3, 1)     ## command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, False, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)
 
91
92
93
94
 
95
96
97
 
91
92
93
 
94
95
96
97
@@ -91,7 +91,7 @@
  self.nobackup_chk.setChecked(bool(opts.get('nobackup')))     ## command widget - self.cmd = cmdui.Widget() + self.cmd = cmdui.Widget(True, True, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)
 
107
108
109
110
 
111
112
113
 
107
108
109
 
110
111
112
113
@@ -107,7 +107,7 @@
  repo.ui.configbool('tortoisehg', 'autoresolve', False))     ## command widget - self.cmd = cmdui.Widget(True, self) + self.cmd = cmdui.Widget(True, True, self)   self.cmd.commandStarted.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.commandCanceling.connect(self.command_canceling)