class LogView(QtGui.QWidget): """A simple dialog to display command logs.""" def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self._layout = QtGui.QVBoxLayout(self) self._layout.setMargin(0) self.output_text = MonoTextView(self) self._layout.addWidget(self.output_text) if output: self.set_output(output) def clear(self): self.output_text.clear() def set_output(self, output): self.output_text.setText(output) def log(self, status, output): if not output: return cursor = self.output_text.textCursor() cursor.movePosition(cursor.End) text = self.output_text cursor.insertText(time.asctime() + '\n') for line in unicode(core.decode(output)).splitlines(): cursor.insertText(line + '\n') cursor.insertText('\n') cursor.movePosition(cursor.End) text.setTextCursor(cursor)
class LogWidget(QtGui.QWidget): """A simple dialog to display command logs.""" def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self._layout = QtGui.QVBoxLayout(self) self._layout.setMargin(0) self.output_text = MonoTextView(self) self._layout.addWidget(self.output_text) if output: self.set_output(output) def clear(self): self.output_text.clear() def set_output(self, output): self.output_text.setText(output) def log(self, status, output): if not output: return cursor = self.output_text.textCursor() cursor.movePosition(cursor.End) text = self.output_text cursor.insertText(time.asctime() + '\n') for line in unicode(core.decode(output)).splitlines(): cursor.insertText(line + '\n') cursor.insertText('\n') cursor.movePosition(cursor.End) text.setTextCursor(cursor)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('About git-cola')) self.setWindowModality(Qt.WindowModal) self.label = QtGui.QLabel() self.pixmap = QtGui.QPixmap(icons.name_from_basename('logo-top.png')) #self.label.setStyleSheet('QWidget {background: #000; }') self.label.setPixmap(self.pixmap) self.label.setAlignment(Qt.AlignRight | Qt.AlignTop) palette = self.label.palette() palette.setColor(QtGui.QPalette.Window, Qt.black) self.label.setAutoFillBackground(True) self.label.setPalette(palette) self.text = MonoTextView(self) self.text.setReadOnly(True) self.text.setPlainText(COPYRIGHT) self.close_button = qtutils.close_button() self.close_button.setDefault(True) self.button_layout = qtutils.hbox(defs.spacing, defs.margin, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.label, self.text, self.button_layout) self.setLayout(self.main_layout) self.resize(666, 420) qtutils.connect_button(self.close_button, self.accept)
def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self.output_text = MonoTextView(self) if output: self.set_output(output) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.output_text) self.setLayout(self.main_layout)
def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self._layout = QtGui.QVBoxLayout(self) self._layout.setMargin(0) self.output_text = MonoTextView(self) self._layout.addWidget(self.output_text) if output: self.set_output(output)
class LogWidget(QtGui.QWidget): """A simple dialog to display command logs.""" def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self.output_text = MonoTextView(self) if output: self.set_output(output) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.output_text) self.setLayout(self.main_layout) self.connect(self, SIGNAL('log'), self.log) def clear(self): self.output_text.clear() def set_output(self, output): self.output_text.setText(output) def log_status(self, status, out, err=None): msg = [] if out: msg.append(out) if err: msg.append(err) if status: msg.append(N_('exit code %s') % status) self.log('\n'.join(msg)) def log(self, msg): if not msg: return cursor = self.output_text.textCursor() cursor.movePosition(cursor.End) text = self.output_text cursor.insertText(time.asctime() + '\n') for line in msg.splitlines(): cursor.insertText(line + '\n') cursor.insertText('\n') cursor.movePosition(cursor.End) text.setTextCursor(cursor) def safe_log(self, msg): """A version of the log() method that can be called from other threads.""" self.emit(SIGNAL('log'), msg)
class LogWidget(QtGui.QWidget): """A simple dialog to display command logs.""" def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self._layout = QtGui.QVBoxLayout(self) self._layout.setMargin(0) self.output_text = MonoTextView(self) self._layout.addWidget(self.output_text) if output: self.set_output(output) def clear(self): self.output_text.clear() def set_output(self, output): self.output_text.setText(output) def log_status(self, status, out, err=None): msg = out if err: msg += "\n" + err if status != 0: msg += "\n" msg += N_("exit code %s") % status self.log(msg) def log(self, msg): if not msg: return cursor = self.output_text.textCursor() cursor.movePosition(cursor.End) text = self.output_text cursor.insertText(time.asctime() + "\n") for line in msg.splitlines(): cursor.insertText(line + "\n") cursor.insertText("\n") cursor.movePosition(cursor.End) text.setTextCursor(cursor)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('About git-cola')) self.setWindowModality(Qt.WindowModal) self.label = QtGui.QLabel() self.pixmap = QtGui.QPixmap('icons:logo-top.png') #self.label.setStyleSheet('QWidget {background: #000; }') self.label.setPixmap(self.pixmap) self.label.setAlignment(Qt.AlignRight | Qt.AlignTop) palette = self.label.palette() palette.setColor(QtGui.QPalette.Window, Qt.black) self.label.setAutoFillBackground(True) self.label.setPalette(palette) self.text = MonoTextView(self) self.text.setReadOnly(True) self.text.setPlainText(COPYRIGHT) self.close_button = QtGui.QPushButton() self.close_button.setText(N_('Close')) self.close_button.setDefault(True) self.button_layout = QtGui.QHBoxLayout() self.button_layout.addStretch() self.button_layout.addWidget(self.close_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(0) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.text) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) self.resize(666, 420) qtutils.connect_button(self.close_button, self.accept)
class LogWidget(QtGui.QWidget): """A simple dialog to display command logs.""" def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self._layout = QtGui.QVBoxLayout(self) self._layout.setMargin(defs.no_margin) self.output_text = MonoTextView(self) self._layout.addWidget(self.output_text) if output: self.set_output(output) def clear(self): self.output_text.clear() def set_output(self, output): self.output_text.setText(output) def log_status(self, status, out, err=None): msg = [] if out: msg.append(out) if err: msg.append(err) if status: msg.append(N_('exit code %s') % status) self.log('\n'.join(msg)) def log(self, msg): if not msg: return cursor = self.output_text.textCursor() cursor.movePosition(cursor.End) text = self.output_text cursor.insertText(time.asctime() + '\n') for line in msg.splitlines(): cursor.insertText(line + '\n') cursor.insertText('\n') cursor.movePosition(cursor.End) text.setTextCursor(cursor)
class LogWidget(QtGui.QWidget): """A simple dialog to display command logs.""" def __init__(self, parent=None, output=None): QtGui.QWidget.__init__(self, parent) self._layout = QtGui.QVBoxLayout(self) self._layout.setMargin(0) self.output_text = MonoTextView(self) self._layout.addWidget(self.output_text) if output: self.set_output(output) def clear(self): self.output_text.clear() def set_output(self, output): self.output_text.setText(output) def log_status(self, status, out, err=None): msg = [] if out: msg.append(out) if err: msg.append(err) if status: msg.append(N_('exit code %s') % status) self.log('\n'.join(msg)) def log(self, msg): if not msg: return cursor = self.output_text.textCursor() cursor.movePosition(cursor.End) text = self.output_text cursor.insertText(time.asctime() + '\n') for line in msg.splitlines(): cursor.insertText(line + '\n') cursor.insertText('\n') cursor.movePosition(cursor.End) text.setTextCursor(cursor)
class AboutView(QtGui.QDialog): """Provides the git-cola 'About' dialog. """ def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('About git-cola')) self.setWindowModality(Qt.WindowModal) self.label = QtGui.QLabel() self.pixmap = QtGui.QPixmap('icons:logo-top.png') #self.label.setStyleSheet('QWidget {background: #000; }') self.label.setPixmap(self.pixmap) self.label.setAlignment(Qt.AlignRight | Qt.AlignTop) palette = self.label.palette() palette.setColor(QtGui.QPalette.Window, Qt.black) self.label.setAutoFillBackground(True) self.label.setPalette(palette) self.text = MonoTextView(self) self.text.setReadOnly(True) self.text.setPlainText(COPYRIGHT) self.close_button = QtGui.QPushButton() self.close_button.setText(N_('Close')) self.close_button.setDefault(True) self.button_layout = QtGui.QHBoxLayout() self.button_layout.addStretch() self.button_layout.addWidget(self.close_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.no_margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.text) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) self.resize(666, 420) qtutils.connect_button(self.close_button, self.accept) def set_version(self, version): """Sets the version field in the 'about' dialog""" self.text.setPlainText(self.text.toPlainText().replace('$VERSION', version))
class AboutView(QtGui.QDialog): """Provides the git-cola 'About' dialog. """ def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('About git-cola')) self.setWindowModality(Qt.WindowModal) self.label = QtGui.QLabel() self.pixmap = QtGui.QPixmap('icons:logo-top.png') #self.label.setStyleSheet('QWidget {background: #000; }') self.label.setPixmap(self.pixmap) self.label.setAlignment(Qt.AlignRight | Qt.AlignTop) palette = self.label.palette() palette.setColor(QtGui.QPalette.Window, Qt.black) self.label.setAutoFillBackground(True) self.label.setPalette(palette) self.text = MonoTextView(self) self.text.setReadOnly(True) self.text.setPlainText(COPYRIGHT) self.close_button = QtGui.QPushButton() self.close_button.setText(N_('Close')) self.close_button.setDefault(True) self.button_layout = qtutils.hbox(defs.spacing, defs.margin, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.label, self.text, self.button_layout) self.setLayout(self.main_layout) self.resize(666, 420) qtutils.connect_button(self.close_button, self.accept) def set_version(self, version): """Sets the version field in the 'about' dialog""" self.text.setPlainText(self.text.toPlainText().replace( '$VERSION', version))
def __init__(self, parent, whitespace=True): MonoTextView.__init__(self, parent) # Diff/patch syntax highlighter self.highlighter = DiffSyntaxHighlighter(self.document(), whitespace=whitespace)