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

cmdui: use stylesheet instead of <pre> tags

Changeset d3960278281b

Parent 081068bed495

by Steve Borho

Changes to 2 files · Browse files at d3960278281b Showing diff from parent 081068bed495 Diff from another changeset...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
 
119
120
121
 
 
122
123
124
125
126
127
 
 
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
 
117
 
118
119
120
121
122
123
124
 
125
126
127
128
129
130
131
 
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
 # cmdui.py - A widget to execute Mercurial command for TortoiseHg  #  # Copyright 2010 Yuki KODAMA <endflow.net@gmail.com>  #  # This software may be used and distributed according to the terms of the  # GNU General Public License version 2, incorporated herein by reference.    from PyQt4.QtCore import Qt, QString  from PyQt4.QtGui import QDialog, QDialogButtonBox, QLabel, QProgressBar  from PyQt4.QtGui import QTextEdit, QHBoxLayout, QGridLayout, QMessageBox    from tortoisehg.util import hglib  from tortoisehg.hgqt.i18n import _, localgettext  from tortoisehg.hgqt import qtlib, thread    local = localgettext()    class Dialog(QDialog):   def __init__(self, cmdline, parent=None):   super(Dialog, self).__init__(parent, Qt.WindowTitleHint or \   Qt.WindowSystemMenuHint)     # main layout grid   grid = QGridLayout()   grid.setSpacing(6)   grid.setContentsMargins(*(7,)*4)     ## hbox for status and progress labels   hbox = QHBoxLayout()   grid.addLayout(hbox, 0, 0)     self.status_label = QLabel('')   hbox.addWidget(self.status_label, 1)     self.prog_label = QLabel('')   hbox.addWidget(self.prog_label, 0, Qt.AlignRight)     self.pbar = QProgressBar()   self.pbar.setTextVisible(False)   self.pbar.setMinimum(0)   grid.addWidget(self.pbar, 1, 0)     # command output area   self.log_text = QTextEdit()   self.log_text.setReadOnly(True) + self.log_text.document().setDefaultStyleSheet(qtlib.thgstylesheet)   grid.addWidget(self.log_text, 2, 0, 5, 0)   grid.setRowStretch(2, 1)     # bottom buttons   buttons = QDialogButtonBox()   self.cancel_btn = buttons.addButton(QDialogButtonBox.Cancel)   self.cancel_btn.clicked.connect(self.cancel_clicked)   self.close_btn = buttons.addButton(QDialogButtonBox.Close)   self.close_btn.setHidden(True)   self.close_btn.clicked.connect(self.reject)   grid.addWidget(buttons, 7, 0)     self.setLayout(grid)   self.setWindowTitle(_('TortoiseHg Command Dialog'))   self.resize(540, 420)     # setup and start command thread   self.cmd = thread.CmdThread(cmdline)   self.cmd.outputReceived.connect(self.output_received)   self.cmd.errorReceived.connect(self.error_received)   self.cmd.progressReceived.connect(self.progress_received)   self.cmd.started.connect(self.command_started)   self.cmd.commandFinished.connect(self.command_finished)   self.cmd.start()     def reject(self):   if self.cmd.isRunning():   ret = QMessageBox.question(self, _('Confirm Exit'), _('Mercurial'   ' command is still running.\nAre you sure you want'   ' to terminate?'), QMessageBox.Yes | QMessageBox.No,   QMessageBox.No)   if ret == QMessageBox.Yes:   self.cancel_clicked()     # don't close dialog   return     # close dialog   QDialog.reject(self)     def cancel_clicked(self):   # trigger KeyboardInterrupt   self.cmd.abort()     # until thread is terminated   self.cancel_btn.setDisabled(True)   self.pbar.setMaximum(0)     def command_started(self):   # use indeterminate mode   self.pbar.setMaximum(0)   self.status_label.setText(_('Running...'))     def command_finished(self, wrapper):   ret = wrapper.data   if ret is None or self.pbar.maximum() == 0:   self.clear_progress()   if ret is None:   if self.cmd.abortbyuser:   status = _('Terminated by user')   else:   status = _('Terminated')   else:   status = _('Finished')   self.status_label.setText(status)   self.cancel_btn.setHidden(True)   self.close_btn.setShown(True)   self.close_btn.setFocus()     def append_output(self, msg, style=''): - msg = hglib.tounicode(msg)   msg = msg.replace('\n', '<br />') - self.log_text.insertHtml('<pre style="%s">%s</pre>' % (style, msg)) + self.log_text.insertHtml('<font style="%s">%s</pre>' % (style, msg))     def output_received(self, wrapper):   msg, label = wrapper.data + msg = hglib.tounicode(msg) + msg = Qt.escape(msg)   style = qtlib.geteffect(label) - style += ';font-size: 9pt'   self.append_output(msg, style)     def error_received(self, wrapper):   msg, label = wrapper.data + msg = hglib.tounicode(msg) + msg = Qt.escape(msg)   style = qtlib.geteffect(label) - style += ';font-size: 9pt'   self.append_output(msg, style)     def clear_progress(self):   self.pbar.reset()   self.pbar.setMaximum(100)   self.status_label.setText('')   self.prog_label.setText('')   self.inprogress = False     def progress_received(self, wrapper):   if self.cmd.isFinished():   self.clear_progress()   return     counting = False   topic, item, pos, total, unit = wrapper.data   if pos is None:   self.clear_progress()   return   if total is None:   count = '%d' % pos   counting = True   else:   self.pbar.setMaximum(total)   self.pbar.setValue(pos)   count = '%d / %d' % (pos, total)   if unit:   count += ' ' + unit   self.prog_label.setText(hglib.tounicode(count))   if item:   status = '%s: %s' % (topic, item)   else:   status = local._('Status: %s') % topic   self.status_label.setText(hglib.tounicode(status))   self.inprogress = True     if not self.inprogress or counting:   # use indeterminate mode   self.pbar.setMinimum(0)
 
21
22
23
24
 
25
26
27
 
21
22
23
 
24
25
26
27
@@ -21,7 +21,7 @@
  'underline': 'text-decoration: underline',  }   -thgstylesheet = '* { white-space: pre; font-family: monospace; }' +thgstylesheet = '* { white-space: pre; font-family: monospace; font-size: 9pt; }'    def configstyles(ui):   # extensions may provide more labels and default effects