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): QtGui.QWidget.__init__(self, parent) self.tree = BookmarksTreeWidget(parent=self) self.open_button = qtutils.create_action_button( tooltip=N_('Open'), icon=qtutils.open_icon()) self.open_button.setEnabled(False) self.edit_button = qtutils.create_action_button( tooltip=N_('Bookmarks...'), icon=qtutils.add_icon()) qtutils.connect_button(self.open_button, self.tree.open_repo) qtutils.connect_button(self.edit_button, self.manage_bookmarks) self.connect(self.tree, SIGNAL('itemSelectionChanged()'), self._tree_selection_changed) self.button_layout = QtGui.QHBoxLayout() self.button_layout.setMargin(defs.no_margin) self.button_layout.setSpacing(defs.spacing) self.button_layout.addWidget(self.open_button) self.button_layout.addWidget(self.edit_button) self.layout = QtGui.QVBoxLayout() self.layout.setMargin(defs.no_margin) self.layout.setSpacing(defs.spacing) self.layout.addWidget(self.tree) self.setLayout(self.layout) self.corner_widget = QtGui.QWidget(self) self.corner_widget.setLayout(self.button_layout) titlebar = parent.titleBarWidget() titlebar.add_corner_widget(self.corner_widget) self.setFocusProxy(self.tree)
def __init__(self, lineedit, title, button_text, parent, icon=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(title) self.setMinimumWidth(333) self.label = QtGui.QLabel() self.label.setText(title) self.lineedit = lineedit() self.setFocusProxy(self.lineedit) if icon is None: icon = icons.ok() self.ok_button = qtutils.create_button(text=button_text, icon=icon) self.close_button = qtutils.close_button() self.button_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ok_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.label, self.lineedit, self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.ok_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.connect(self.lineedit, SIGNAL('textChanged(QString)'), self.text_changed) self.connect(self.lineedit, SIGNAL('return()'), self.accept) self.setWindowModality(Qt.WindowModal) self.ok_button.setEnabled(False)
def __init__(self, parent, title): QtGui.QWidget.__init__(self, parent) self.label = label = QtGui.QLabel() font = label.font() font.setCapitalization(QtGui.QFont.SmallCaps) label.setFont(font) label.setText(title) self.close_button = QtGui.QPushButton() self.close_button.setFlat(True) self.close_button.setFixedSize(QtCore.QSize(16, 16)) self.close_button.setIcon(qtutils.titlebar_close_icon()) self.toggle_button = QtGui.QPushButton() self.toggle_button.setFlat(True) self.toggle_button.setFixedSize(QtCore.QSize(16, 16)) self.toggle_button.setIcon(qtutils.titlebar_normal_icon()) self.corner_layout = QtGui.QHBoxLayout() self.corner_layout.setMargin(0) self.corner_layout.setSpacing(defs.spacing) layout = QtGui.QHBoxLayout() layout.setMargin(2) layout.setSpacing(defs.spacing) layout.addWidget(label) layout.addStretch() layout.addLayout(self.corner_layout) layout.addWidget(self.toggle_button) layout.addWidget(self.close_button) self.setLayout(layout) qtutils.connect_button(self.toggle_button, self.toggle_floating) qtutils.connect_button(self.close_button, self.toggle_visibility)
def __init__(self, parent, title, stretch=True): QtGui.QWidget.__init__(self, parent) self.label = label = QtGui.QLabel() font = label.font() font.setCapitalization(QtGui.QFont.SmallCaps) label.setFont(font) label.setText(title) self.setCursor(QtCore.Qt.OpenHandCursor) self.close_button = create_action_button(N_("Close"), qtutils.titlebar_close_icon()) self.toggle_button = create_action_button(N_("Detach"), qtutils.titlebar_normal_icon()) self.corner_layout = QtGui.QHBoxLayout() self.corner_layout.setMargin(defs.no_margin) self.corner_layout.setSpacing(defs.spacing) self.main_layout = QtGui.QHBoxLayout() self.main_layout.setMargin(defs.small_margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(label) self.main_layout.addSpacing(defs.spacing) if stretch: self.main_layout.addStretch() self.main_layout.addLayout(self.corner_layout) self.main_layout.addSpacing(defs.spacing) self.main_layout.addWidget(self.toggle_button) self.main_layout.addWidget(self.close_button) self.setLayout(self.main_layout) qtutils.connect_button(self.toggle_button, self.toggle_floating) qtutils.connect_button(self.close_button, self.toggle_visibility)
def __init__(self, titlebar, parent=None): QtGui.QWidget.__init__(self, parent) tooltip = N_('Toggle the paths filter') self.filter_button = qtutils.create_action_button( tooltip=tooltip, icon=qtutils.filter_icon()) self.filter_widget = StatusFilterWidget(self) self.filter_widget.hide() self.tree = StatusTreeWidget(self) self.main_layout = QtGui.QVBoxLayout(self) self.main_layout.setMargin(defs.no_margin) self.main_layout.setSpacing(defs.no_spacing) self.main_layout.addWidget(self.filter_widget) self.main_layout.addWidget(self.tree) self.setLayout(self.main_layout) self.toggle_action = qtutils.add_action(self, tooltip, self.toggle_filter, 'Shift+Ctrl+F') titlebar.add_corner_widget(self.filter_button) qtutils.connect_button(self.filter_button, self.toggle_filter)
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.model = settings.Settings() self.resize(494, 238) self.setWindowTitle(N_('Bookmarks')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.layt = QtGui.QVBoxLayout(self) self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.bookmarks = QtGui.QListWidget(self) self.bookmarks.setAlternatingRowColors(True) self.bookmarks.setSelectionMode(QtGui.QAbstractItemView .ExtendedSelection) self.layt.addWidget(self.bookmarks) self.button_layout = QtGui.QHBoxLayout() self.open_button = QtGui.QPushButton(self) self.open_button.setText(N_('Open')) self.open_button.setIcon(qtutils.open_icon()) self.open_button.setEnabled(False) self.button_layout.addWidget(self.open_button) self.add_button = QtGui.QPushButton(self) self.add_button.setText(N_('Add')) self.add_button.setIcon(qtutils.icon('add.svg')) self.button_layout.addWidget(self.add_button) self.delete_button = QtGui.QPushButton(self) self.delete_button.setText(N_('Delete')) self.delete_button.setIcon(qtutils.discard_icon()) self.delete_button.setEnabled(False) self.button_layout.addWidget(self.delete_button) self.button_layout.addStretch() self.save_button = QtGui.QPushButton(self) self.save_button.setText(N_('Save')) self.save_button.setIcon(qtutils.save_icon()) self.save_button.setEnabled(False) self.button_layout.addWidget(self.save_button) self.close_button = QtGui.QPushButton(self) self.close_button.setText(N_('Close')) self.button_layout.addWidget(self.close_button) self.layt.addLayout(self.button_layout) self.connect(self.bookmarks, SIGNAL('itemSelectionChanged()'), self.item_selection_changed) qtutils.connect_button(self.open_button, self.open_repo) qtutils.connect_button(self.add_button, self.add) qtutils.connect_button(self.delete_button, self.delete) qtutils.connect_button(self.save_button, self.save) qtutils.connect_button(self.close_button, self.accept) self.update_bookmarks()
def __init__(self, lineedit, title, button_text, parent): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(title) self.setMinimumWidth(333) self.label = QtGui.QLabel() self.label.setText(title) self.lineedit = lineedit() self.setFocusProxy(self.lineedit) self.ok_button = QtGui.QPushButton() self.ok_button.setText(button_text) self.ok_button.setIcon(qtutils.apply_icon()) self.close_button = QtGui.QPushButton() self.close_button.setText(N_('Close')) self.button_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ok_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.label, self.lineedit, self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.ok_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.connect(self.lineedit, SIGNAL('textChanged(const QString&)'), self.text_changed) self.connect(self.lineedit, SIGNAL('returnPressed()'), self.accept) self.setWindowModality(Qt.WindowModal) self.ok_button.setEnabled(False)
def __init__(self, model, select_file=False, parent=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(Qt.WindowModal) # updated for use by commands self.model = model # widgets self.tree = GitTreeWidget(parent=self) self.close = QtGui.QPushButton(N_('Close')) self.save = QtGui.QPushButton(select_file and N_('Select') or N_('Save')) self.save.setDefault(True) self.save.setEnabled(False) # layouts self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.close, self.save) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.tree, self.btnlayt) self.setLayout(self.layt) # connections if select_file: self.connect(self.tree, SIGNAL('path_chosen'), self.path_chosen) else: self.connect(self.tree, SIGNAL('path_chosen'), self.save_path) self.connect(self.tree, SIGNAL('selectionChanged()'), self.selection_changed) qtutils.connect_button(self.close, self.reject) qtutils.connect_button(self.save, self.save_blob)
def __init__(self, parent): standard.Dialog.__init__(self, parent=parent) self.settings = Settings() self.settings.load() self.resize(494, 238) self.setWindowTitle(N_('Bookmarks')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.layt = QtGui.QVBoxLayout(self) self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.bookmarks = QtGui.QListWidget(self) self.bookmarks.setAlternatingRowColors(True) self.bookmarks.setSelectionMode(QtGui.QAbstractItemView .ExtendedSelection) self.layt.addWidget(self.bookmarks) self.button_layout = QtGui.QHBoxLayout() self.open_button = qtutils.create_button(text=N_('Open'), icon=qtutils.open_icon()) self.open_button.setEnabled(False) self.button_layout.addWidget(self.open_button) self.add_button = qtutils.create_button(text=N_('Add'), icon=qtutils.add_icon()) self.button_layout.addWidget(self.add_button) self.delete_button = QtGui.QPushButton(self) self.delete_button.setText(N_('Delete')) self.delete_button.setIcon(qtutils.discard_icon()) self.delete_button.setEnabled(False) self.button_layout.addWidget(self.delete_button) self.button_layout.addStretch() self.save_button = QtGui.QPushButton(self) self.save_button.setText(N_('Save')) self.save_button.setIcon(qtutils.save_icon()) self.save_button.setEnabled(False) self.button_layout.addWidget(self.save_button) self.close_button = QtGui.QPushButton(self) self.close_button.setText(N_('Close')) self.button_layout.addWidget(self.close_button) self.layt.addLayout(self.button_layout) self.connect(self.bookmarks, SIGNAL('itemSelectionChanged()'), self.item_selection_changed) qtutils.connect_button(self.open_button, self.open_repo) qtutils.connect_button(self.add_button, self.add) qtutils.connect_button(self.delete_button, self.delete) qtutils.connect_button(self.save_button, self.save) qtutils.connect_button(self.close_button, self.accept) self.update_bookmarks()
def __init__(self, model, parent=None, title=None, multiselect=True, syntax=True): QtGui.QDialog.__init__(self, parent) self.model = model if title: self.setWindowTitle(title) self.commit_list = QtGui.QListWidget() if multiselect: mode = QtGui.QAbstractItemView.ExtendedSelection else: mode = QtGui.QAbstractItemView.SingleSelection self.commit_list.setSelectionMode(mode) self.commit_list.setAlternatingRowColors(True) self.commit_text = DiffTextEdit(self, whitespace=False) self.label = QtGui.QLabel() self.label.setText(N_('Revision Expression:')) self.revision = QtGui.QLineEdit() self.revision.setReadOnly(True) self.select_button = QtGui.QPushButton(N_('Select')) self.select_button.setIcon(qtutils.apply_icon()) self.select_button.setEnabled(False) self.select_button.setDefault(True) self.close_button = QtGui.QPushButton(N_('Close')) # Make the list widget slighty larger self.splitter = qtutils.splitter(Qt.Vertical, self.commit_list, self.commit_text) self.splitter.setSizes([100, 150]) self.input_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.label, self.revision, self.select_button, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.margin, self.splitter, self.input_layout) self.setLayout(self.main_layout) self.connect(self.commit_list, SIGNAL('itemSelectionChanged()'), self.commit_sha1_selected) self.connect(self.commit_list, SIGNAL('itemDoubleClicked(QListWidgetItem*)'), self.commit_sha1_double_clicked) qtutils.connect_button(self.select_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.resize(700, 420)
def __init__(self, parent, a=None, b=None, expr=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.a = a self.b = b self.expr = expr self.setWindowTitle('Select File(s)') self.setWindowModality(QtCore.Qt.WindowModal) self._tree = standard.TreeWidget(self) self._tree.setRootIsDecorated(False) self._tree.setSelectionMode(self._tree.ExtendedSelection) self._tree.setHeaderHidden(True) self._diff_btn = QtGui.QPushButton('Compare') self._diff_btn.setIcon(qtutils.ok_icon()) self._diff_btn.setEnabled(False) self._close_btn = QtGui.QPushButton('Close') self._close_btn.setIcon(qtutils.close_icon()) self._button_layt = QtGui.QHBoxLayout() self._button_layt.setMargin(0) self._button_layt.addStretch() self._button_layt.addWidget(self._diff_btn) self._button_layt.addWidget(self._close_btn) self._layt = QtGui.QVBoxLayout() self._layt.setMargin(defs.margin) self._layt.setSpacing(defs.spacing) self._layt.addWidget(self._tree) self._layt.addLayout(self._button_layt) self.setLayout(self._layt) self.connect(self._tree, SIGNAL('itemSelectionChanged()'), self._tree_selection_changed) self.connect(self._tree, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self._tree_double_clicked) qtutils.connect_button(self._diff_btn, self.diff) qtutils.connect_button(self._close_btn, self.close) qtutils.add_close_action(self) if self.expr: self.diff_arg = tuple(utils.shell_split(self.expr)) elif self.b is None: self.diff_arg = (self.a,) else: self.diff_arg = (self.a, self.b) self.resize(720, 420)
def __init__(self, model, parent=None): standard.Dialog.__init__(self, parent=parent) self.setWindowTitle(self.tr('Preferences')) self.resize(600, 360) self._tabbar = QtGui.QTabBar() self._tabbar.setDrawBase(False) self._tabbar.addTab('All Repositories') self._tabbar.addTab('Current Repository') self._tabbar.addTab('Settings') self._user_form = RepoFormWidget(model, self, source='user') self._repo_form = RepoFormWidget(model, self, source='all') self._options_form = SettingsFormWidget(model, self) relay_signal(self, self._user_form, SIGNAL(model.message_set_config)) relay_signal(self, self._repo_form, SIGNAL(model.message_set_config)) relay_signal(self, self._options_form, SIGNAL(model.message_set_config)) self._stackedwidget = QtGui.QStackedWidget() self._stackedwidget.addWidget(self._user_form) self._stackedwidget.addWidget(self._repo_form) self._stackedwidget.addWidget(self._options_form) self.close_button = QtGui.QPushButton(self) self.close_button.setText(qtutils.tr('Close')) self.close_button.setIcon(qtutils.close_icon()) self._button_layt = QtGui.QHBoxLayout() self._button_layt.setMargin(0) self._button_layt.setSpacing(defs.spacing) self._button_layt.addStretch() self._button_layt.addWidget(self.close_button) self._layt = QtGui.QVBoxLayout() self._layt.setMargin(defs.margin) self._layt.setSpacing(defs.spacing) self._layt.addWidget(self._tabbar) self._layt.addWidget(self._stackedwidget) self._layt.addLayout(self._button_layt) self.setLayout(self._layt) self.connect(self._tabbar, SIGNAL('currentChanged(int)'), self._stackedwidget.setCurrentIndex) self.connect(self._stackedwidget, SIGNAL('currentChanged(int)'), self.update_widget) qtutils.connect_button(self.close_button, self.accept) qtutils.add_close_action(self) self.update_widget(0)
def __init__(self, title, parent=None): standard.Dialog.__init__(self, parent) self.resize(720, 420) self.setWindowTitle(title) self.setWindowModality(Qt.ApplicationModal) # Construct the process self.proc = QtCore.QProcess(self) self.exitstatus = 0 self.out = '' self.err = '' self._layout = QtGui.QVBoxLayout(self) self._layout.setContentsMargins(3, 3, 3, 3) # Create the text browser self.output_text = QtGui.QTextBrowser(self) self.output_text.setAcceptDrops(False) self.output_text.setTabChangesFocus(True) self.output_text.setUndoRedoEnabled(False) self.output_text.setReadOnly(True) self.output_text.setAcceptRichText(False) self._layout.addWidget(self.output_text) # Create abort / close buttons self.button_abort = QtGui.QPushButton(self) self.button_abort.setText(N_('Abort')) self.button_close = QtGui.QPushButton(self) self.button_close.setText(N_('Close')) # Put them in a horizontal layout at the bottom. self.button_box = QtGui.QDialogButtonBox(self) self.button_box.addButton(self.button_abort, QtGui.QDialogButtonBox.RejectRole) self.button_box.addButton(self.button_close, QtGui.QDialogButtonBox.AcceptRole) self._layout.addWidget(self.button_box) # Connect the signals to the process self.connect(self.proc, SIGNAL('readyReadStandardOutput()'), self.readOutput) self.connect(self.proc, SIGNAL('readyReadStandardError()'), self.readErrors) self.connect(self.proc, SIGNAL('finished(int)'), self.finishProc) self.connect(self.proc, SIGNAL('stateChanged(QProcess::ProcessState)'), self.stateChanged) # Start with abort disabled - will be enabled when the process is run. self.button_abort.setEnabled(False) qtutils.connect_button(self.button_abort, self.abortProc) qtutils.connect_button(self.button_close, self.close)
def __init__(self, parent): super(AddRemoteWidget, self).__init__(parent) self.setWindowModality(Qt.WindowModal) self.add_btn = QtGui.QPushButton(self.tr('Add Remote')) self.add_btn.setIcon(qtutils.apply_icon()) self.cancel_btn = QtGui.QPushButton(self.tr('Cancel')) diff_font = prefs.diff_font() metrics = QtGui.QFontMetrics(diff_font) def lineedit(hint): widget = text.HintedLineEdit(hint) widget.setFont(diff_font) widget.enable_hint(True) widget.setMinimumWidth(metrics.width('_' * 32)) return widget self.name = lineedit('Name for the new remote') self.url = lineedit('git://git.example.com/repo.git') self._form = QtGui.QFormLayout() self._form.setMargin(defs.margin) self._form.setSpacing(defs.spacing) self._form.addRow(self.tr('Name'), self.name) self._form.addRow(self.tr('URL'), self.url) self._btn_layout = QtGui.QHBoxLayout() self._btn_layout.setMargin(0) self._btn_layout.setSpacing(defs.button_spacing) self._btn_layout.addStretch() self._btn_layout.addWidget(self.add_btn) self._btn_layout.addWidget(self.cancel_btn) self._layout = QtGui.QVBoxLayout() self._layout.setMargin(defs.margin) self._layout.setSpacing(defs.margin) self._layout.addLayout(self._form) self._layout.addLayout(self._btn_layout) self.setLayout(self._layout) self.connect(self.name, SIGNAL('textChanged(QString)'), self.validate) self.connect(self.url, SIGNAL('textChanged(QString)'), self.validate) self.add_btn.setEnabled(False) qtutils.connect_button(self.add_btn, self.accept) qtutils.connect_button(self.cancel_btn, self.reject)
def __init__(self, title, parent=None): standard.Dialog.__init__(self, parent) self.setWindowTitle(title) if parent is not None: self.setWindowModality(Qt.ApplicationModal) # Construct the process self.proc = QtCore.QProcess(self) self.exitstatus = 0 self.out = '' self.err = '' self._layout = QtGui.QVBoxLayout(self) self._layout.setContentsMargins(3, 3, 3, 3) # Create the text browser self.output_text = QtGui.QTextBrowser(self) self.output_text.setAcceptDrops(False) self.output_text.setTabChangesFocus(True) self.output_text.setUndoRedoEnabled(False) self.output_text.setReadOnly(True) self.output_text.setAcceptRichText(False) self._layout.addWidget(self.output_text) # Create abort / close buttons self.button_abort = QtGui.QPushButton(self) self.button_abort.setText(N_('Abort')) self.button_close = QtGui.QPushButton(self) self.button_close.setText(N_('Close')) # Put them in a horizontal layout at the bottom. self.button_box = QtGui.QDialogButtonBox(self) self.button_box.addButton(self.button_abort, QtGui.QDialogButtonBox.RejectRole) self.button_box.addButton(self.button_close, QtGui.QDialogButtonBox.AcceptRole) self._layout.addWidget(self.button_box) # Connect the signals to the process self.connect(self.proc, SIGNAL('readyReadStandardOutput()'), self.read_stdout) self.connect(self.proc, SIGNAL('readyReadStandardError()'), self.read_stderr) self.connect(self.proc, SIGNAL('finished(int)'), self.finishProc) self.connect(self.proc, SIGNAL('stateChanged(QProcess::ProcessState)'), self.stateChanged) # Start with abort disabled - will be enabled when the process is run. self.button_abort.setEnabled(False) qtutils.connect_button(self.button_abort, self.abortProc) qtutils.connect_button(self.button_close, self.close) self.resize(720, 420)
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowModality(Qt.WindowModal) self.add_btn = QtGui.QPushButton(N_('Add Remote')) self.add_btn.setIcon(qtutils.apply_icon()) self.cancel_btn = QtGui.QPushButton(N_('Cancel')) def lineedit(hint): widget = text.HintedLineEdit(hint) widget.enable_hint(True) metrics = QtGui.QFontMetrics(widget.font()) widget.setMinimumWidth(metrics.width('_' * 32)) return widget self.setWindowTitle(N_('Add remote')) self.name = lineedit(N_('Name for the new remote')) self.url = lineedit('git://git.example.com/repo.git') self._form = QtGui.QFormLayout() self._form.setMargin(defs.margin) self._form.setSpacing(defs.spacing) self._form.addRow(N_('Name'), self.name) self._form.addRow(N_('URL'), self.url) self._btn_layout = QtGui.QHBoxLayout() self._btn_layout.setMargin(0) self._btn_layout.setSpacing(defs.button_spacing) self._btn_layout.addStretch() self._btn_layout.addWidget(self.add_btn) self._btn_layout.addWidget(self.cancel_btn) self._layout = QtGui.QVBoxLayout() self._layout.setMargin(defs.margin) self._layout.setSpacing(defs.margin) self._layout.addLayout(self._form) self._layout.addLayout(self._btn_layout) self.setLayout(self._layout) self.connect(self.name, SIGNAL('textChanged(QString)'), self.validate) self.connect(self.url, SIGNAL('textChanged(QString)'), self.validate) self.add_btn.setEnabled(False) qtutils.connect_button(self.add_btn, self.accept) qtutils.connect_button(self.cancel_btn, self.reject)
def __init__(self, model, parent=None): standard.Dialog.__init__(self, parent=parent) self.setWindowTitle(N_("Preferences")) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(600, 360) self._tabbar = QtGui.QTabBar() self._tabbar.setDrawBase(False) self._tabbar.addTab(N_("All Repositories")) self._tabbar.addTab(N_("Current Repository")) self._tabbar.addTab(N_("Settings")) self._user_form = RepoFormWidget(model, self, source="user") self._repo_form = RepoFormWidget(model, self, source="repo") self._options_form = SettingsFormWidget(model, self) self._stackedwidget = QtGui.QStackedWidget() self._stackedwidget.addWidget(self._user_form) self._stackedwidget.addWidget(self._repo_form) self._stackedwidget.addWidget(self._options_form) self.close_button = QtGui.QPushButton(self) self.close_button.setText(N_("Close")) self.close_button.setIcon(qtutils.close_icon()) self._button_layt = QtGui.QHBoxLayout() self._button_layt.setMargin(0) self._button_layt.setSpacing(defs.spacing) self._button_layt.addStretch() self._button_layt.addWidget(self.close_button) self._layt = QtGui.QVBoxLayout() self._layt.setMargin(defs.margin) self._layt.setSpacing(defs.spacing) self._layt.addWidget(self._tabbar) self._layt.addWidget(self._stackedwidget) self._layt.addLayout(self._button_layt) self.setLayout(self._layt) self.connect(self._tabbar, SIGNAL("currentChanged(int)"), self._stackedwidget.setCurrentIndex) self.connect(self._stackedwidget, SIGNAL("currentChanged(int)"), self.update_widget) qtutils.connect_button(self.close_button, self.accept) qtutils.add_close_action(self) self.update_widget(0)
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowModality(Qt.WindowModal) self.add_btn = QtGui.QPushButton(N_("Add Remote")) self.add_btn.setIcon(qtutils.apply_icon()) self.cancel_btn = QtGui.QPushButton(N_("Cancel")) def lineedit(hint): widget = text.HintedLineEdit(hint) widget.enable_hint(True) metrics = QtGui.QFontMetrics(widget.font()) widget.setMinimumWidth(metrics.width("_" * 32)) return widget self.setWindowTitle(N_("Add remote")) self.name = lineedit(N_("Name for the new remote")) self.url = lineedit("git://git.example.com/repo.git") self._form = QtGui.QFormLayout() self._form.setMargin(defs.margin) self._form.setSpacing(defs.spacing) self._form.addRow(N_("Name"), self.name) self._form.addRow(N_("URL"), self.url) self._btn_layout = QtGui.QHBoxLayout() self._btn_layout.setMargin(0) self._btn_layout.setSpacing(defs.button_spacing) self._btn_layout.addStretch() self._btn_layout.addWidget(self.add_btn) self._btn_layout.addWidget(self.cancel_btn) self._layout = QtGui.QVBoxLayout() self._layout.setMargin(defs.margin) self._layout.setSpacing(defs.margin) self._layout.addLayout(self._form) self._layout.addLayout(self._btn_layout) self.setLayout(self._layout) self.connect(self.name, SIGNAL("textChanged(QString)"), self.validate) self.connect(self.url, SIGNAL("textChanged(QString)"), self.validate) self.add_btn.setEnabled(False) qtutils.connect_button(self.add_btn, self.accept) qtutils.connect_button(self.cancel_btn, self.reject)
def __init__(self, parent, revs): QtGui.QWidget.__init__(self, parent) self._revs = revs self._revdict = dict(revs) self._layt = QtGui.QVBoxLayout() self._layt.setMargin(0) self.setLayout(self._layt) self._rev_layt = QtGui.QHBoxLayout() self._rev_layt.setMargin(0) self._rev_label = QtGui.QLabel() self._rev_layt.addWidget(self._rev_label) self._revision = completion.GitRefLineEdit() self._rev_layt.addWidget(self._revision) self._layt.addLayout(self._rev_layt) self._radio_layt = QtGui.QHBoxLayout() self._radio_btns = {} # Create the radio buttons for label, rev_list in self._revs: radio = QtGui.QRadioButton() radio.setText(label) radio.setObjectName(label) qtutils.connect_button(radio, self._set_revision_list) self._radio_layt.addWidget(radio) self._radio_btns[label] = radio self._radio_layt.addStretch() self._layt.addLayout(self._radio_layt) self._rev_list = QtGui.QListWidget() self._layt.addWidget(self._rev_list) label, rev_list = self._revs[0] self._radio_btns[label].setChecked(True) qtutils.set_items(self._rev_list, rev_list) self.connect(self._rev_list, SIGNAL('itemSelectionChanged()'), self._rev_list_selection_changed)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle('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 = QtGui.QTextEdit() self.text.setReadOnly(True) self.text.setLineWrapMode(QtGui.QTextEdit.NoWrap) self.text.setAcceptRichText(False) self.text.setTextInteractionFlags(Qt.TextSelectableByKeyboard | Qt.TextSelectableByMouse) self.text.setFont(diff_font()) self.text.setPlainText(COPYRIGHT) self.close_button = QtGui.QPushButton() self.close_button.setText(self.tr('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)
def __init__(self, model, parent): SearchWidget.__init__(self, parent) self.model = model self.EXPR = N_('Search by Expression') self.PATH = N_('Search by Path') self.MESSAGE = N_('Search Commit Messages') self.DIFF = N_('Search Diffs') self.AUTHOR = N_('Search Authors') self.COMMITTER = N_('Search Committers') self.DATE_RANGE = N_('Search Date Range') # Each search type is handled by a distinct SearchEngine subclass self.engines = { self.EXPR: RevisionSearch, self.PATH: PathSearch, self.MESSAGE: MessageSearch, self.DIFF: DiffSearch, self.AUTHOR: AuthorSearch, self.COMMITTER: CommitterSearch, self.DATE_RANGE: DateRangeSearch, } self.modes = (self.EXPR, self.PATH, self.DATE_RANGE, self.DIFF, self.MESSAGE, self.AUTHOR, self.COMMITTER) self.mode_combo.addItems(self.modes) connect_button(self.search_button, self.search_callback) connect_button(self.browse_button, self.browse_callback) connect_button(self.button_export, self.export_patch) connect_button(self.button_cherrypick, self.cherry_pick) connect_button(self.button_close, self.accept) self.connect(self.mode_combo, SIGNAL('currentIndexChanged(int)'), self.mode_index_changed) self.connect(self.commit_list, SIGNAL('itemSelectionChanged()'), self.display) self.set_start_date(mkdate(time.time()-(87640*31))) self.set_end_date(mkdate(time.time()+87640)) self.set_mode(self.EXPR) self.query.setFocus()
def __init__(self, model, parent=None): standard.Dialog.__init__(self, parent=parent) self.setWindowTitle(N_('Preferences')) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(600, 360) self.tab_bar = QtGui.QTabBar() self.tab_bar.setDrawBase(False) self.tab_bar.addTab(N_('All Repositories')) self.tab_bar.addTab(N_('Current Repository')) self.tab_bar.addTab(N_('Settings')) self.user_form = RepoFormWidget(model, self, source='user') self.repo_form = RepoFormWidget(model, self, source='repo') self.options_form = SettingsFormWidget(model, self) self.stack_widget = QtGui.QStackedWidget() self.stack_widget.addWidget(self.user_form) self.stack_widget.addWidget(self.repo_form) self.stack_widget.addWidget(self.options_form) self.close_button = QtGui.QPushButton(self) self.close_button.setText(N_('Close')) self.close_button.setIcon(qtutils.close_icon()) self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.tab_bar, self.stack_widget, self.button_layout) self.setLayout(self.main_layout) self.connect(self.tab_bar, SIGNAL('currentChanged(int)'), self.stack_widget.setCurrentIndex) self.connect(self.stack_widget, SIGNAL('currentChanged(int)'), self.update_widget) qtutils.connect_button(self.close_button, self.accept) qtutils.add_close_action(self) self.update_widget(0)
def __init__(self, titlebar, parent=None): QtGui.QWidget.__init__(self, parent) tooltip = N_("Toggle the paths filter") icon = icons.ellipsis() self.filter_button = qtutils.create_action_button(tooltip=tooltip, icon=icon) self.filter_widget = StatusFilterWidget() self.filter_widget.hide() self.tree = StatusTreeWidget() self.setFocusProxy(self.tree) self.main_layout = qtutils.vbox(defs.no_margin, defs.no_spacing, self.filter_widget, self.tree) self.setLayout(self.main_layout) self.toggle_action = qtutils.add_action(self, tooltip, self.toggle_filter, hotkeys.FILTER) titlebar.add_corner_widget(self.filter_button) qtutils.connect_button(self.filter_button, self.toggle_filter)
def __init__(self, lineedit, title, button_text, parent): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(title) self.setMinimumWidth(333) self.label = QtGui.QLabel() self.label.setText(title) self.lineedit = lineedit(self) self.setFocusProxy(self.lineedit) self.ok_button = QtGui.QPushButton() self.ok_button.setText(button_text) self.ok_button.setIcon(qtutils.apply_icon()) self.close_button = QtGui.QPushButton() self.close_button.setText(N_('Close')) self.button_layout = QtGui.QHBoxLayout() self.button_layout.setMargin(defs.no_margin) self.button_layout.setSpacing(defs.button_spacing) self.button_layout.addStretch() self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.close_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.lineedit) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.ok_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.connect(self.lineedit, SIGNAL('textChanged(const QString&)'), self.text_changed) self.connect(self.lineedit, SIGNAL('returnPressed()'), self.accept) self.setWindowModality(Qt.WindowModal) self.ok_button.setEnabled(False)
def __init__(self, model, select_file=False, parent=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(Qt.WindowModal) # updated for use by commands self.model = model # widgets self.tree = GitTreeWidget(parent=self) self.close = qtutils.close_button() if select_file: text = N_('Select') else: text = N_('Save') self.save = qtutils.create_button(text=text, enabled=False, default=True) # layouts self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.close, self.save) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.tree, self.btnlayt) self.setLayout(self.layt) # connections if select_file: self.connect(self.tree, SIGNAL('path_chosen(PyQt_PyObject)'), self.path_chosen) else: self.connect(self.tree, SIGNAL('path_chosen(PyQt_PyObject)'), self.save_path) self.connect(self.tree, SIGNAL('selectionChanged()'), self.selection_changed, Qt.QueuedConnection) qtutils.connect_button(self.close, self.reject) qtutils.connect_button(self.save, self.save_blob)
def __init__(self, lineedit, title, button_text, parent): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(title) self.setMinimumWidth(333) self.label = QtGui.QLabel() self.label.setText(title) self.lineedit = lineedit(self) self.setFocusProxy(self.lineedit) self.ok_button = QtGui.QPushButton() self.ok_button.setText(button_text) self.ok_button.setIcon(qtutils.apply_icon()) self.close_button = QtGui.QPushButton() self.close_button.setText(N_('Close')) self.button_layout = QtGui.QHBoxLayout() self.button_layout.setMargin(defs.no_margin) self.button_layout.setSpacing(defs.button_spacing) self.button_layout.addStretch() self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.close_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.lineedit) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.ok_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.connect(self.lineedit, SIGNAL('textChanged(const QString&)'), self.text_changed) self.setWindowModality(Qt.WindowModal) self.ok_button.setEnabled(False)
def __init__(self, title, button_text, parent): super(GitRefDialog, self).__init__(parent) self.setWindowTitle(title) self.label = QtGui.QLabel() self.label.setText(title) self.lineedit = completion.GitRefLineEdit(self) self.setFocusProxy(self.lineedit) self.ok_button = QtGui.QPushButton() self.ok_button.setText(self.tr(button_text)) self.ok_button.setIcon(qtutils.apply_icon()) self.close_button = QtGui.QPushButton() self.close_button.setText(self.tr('Close')) self.button_layout = QtGui.QHBoxLayout() self.button_layout.setMargin(0) self.button_layout.setSpacing(defs.button_spacing) self.button_layout.addStretch() self.button_layout.addWidget(self.ok_button) self.button_layout.addWidget(self.close_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.label) self.main_layout.addWidget(self.lineedit) self.main_layout.addLayout(self.button_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.ok_button, self.accept) qtutils.connect_button(self.close_button, self.reject) self.connect(self.lineedit, SIGNAL('textChanged(QString)'), self.text_changed) self.setWindowModality(Qt.WindowModal) self.ok_button.setEnabled(False)
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)
def __init__(self, parent, title): QtGui.QWidget.__init__(self, parent) self.label = label = QtGui.QLabel() font = label.font() font.setCapitalization(QtGui.QFont.SmallCaps) label.setFont(font) label.setText(title) self.setCursor(QtCore.Qt.OpenHandCursor) self.close_button = QtGui.QPushButton() self.close_button.setCursor(QtCore.Qt.PointingHandCursor) self.close_button.setFlat(True) self.close_button.setFixedSize(QtCore.QSize(16, 16)) self.close_button.setIcon(qtutils.titlebar_close_icon()) self.close_button.setToolTip(N_('Close')) self.toggle_button = QtGui.QPushButton() self.toggle_button.setCursor(QtCore.Qt.PointingHandCursor) self.toggle_button.setFlat(True) self.toggle_button.setFixedSize(QtCore.QSize(16, 16)) self.toggle_button.setIcon(qtutils.titlebar_normal_icon()) self.toggle_button.setToolTip(N_('Detach')) self.corner_layout = QtGui.QHBoxLayout() self.corner_layout.setMargin(defs.no_margin) self.corner_layout.setSpacing(defs.spacing) self.main_layout = layout = QtGui.QHBoxLayout() self.main_layout.setMargin(defs.small_margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(label) self.main_layout.addStretch() self.main_layout.addLayout(self.corner_layout) self.main_layout.addWidget(self.toggle_button) self.main_layout.addWidget(self.close_button) self.setLayout(layout) qtutils.connect_button(self.toggle_button, self.toggle_floating) qtutils.connect_button(self.close_button, self.toggle_visibility)
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 __init__(self, titlebar, parent=None): QtGui.QWidget.__init__(self, parent) tooltip = N_('Toggle the paths filter') self.filter_button = qtutils.create_action_button( tooltip=tooltip, icon=qtutils.filter_icon()) self.filter_widget = StatusFilterWidget() self.filter_widget.hide() self.tree = StatusTreeWidget() self.main_layout = qtutils.vbox(defs.no_margin, defs.no_spacing, self.filter_widget, self.tree) self.setLayout(self.main_layout) self.toggle_action = qtutils.add_action(self, tooltip, self.toggle_filter, 'Shift+Ctrl+F') titlebar.add_corner_widget(self.filter_button) qtutils.connect_button(self.filter_button, self.toggle_filter)
def __init__(self, model, select_file=False, parent=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(Qt.WindowModal) # updated for use by commands self.model = model # widgets self.tree = GitTreeWidget(parent=self) self.close = QtGui.QPushButton(N_("Close")) self.save = QtGui.QPushButton(select_file and N_("Select") or N_("Save")) self.save.setDefault(True) self.save.setEnabled(False) # layouts self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.btnlayt.addWidget(self.close) self.btnlayt.addWidget(self.save) self.layt = QtGui.QVBoxLayout() self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.layt.addWidget(self.tree) self.layt.addLayout(self.btnlayt) self.setLayout(self.layt) # connections if select_file: self.connect(self.tree, SIGNAL("path_chosen"), self.path_chosen) else: self.connect(self.tree, SIGNAL("path_chosen"), self.save_path) self.connect(self.tree, SIGNAL("selectionChanged()"), self.selection_changed) qtutils.connect_button(self.close, self.reject) qtutils.connect_button(self.save, self.save_blob)
def __init__(self, model, select_file=False, parent=None): super(BrowseDialog, self).__init__(parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowModality(Qt.WindowModal) # updated for use by commands self.model = model # widgets self.tree = GitTreeWidget(model.ref, parent=self) self.close = QtGui.QPushButton('Close') self.save = QtGui.QPushButton(select_file and 'Select' or 'Save') self.save.setDefault(True) self.save.setEnabled(False) # layouts self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.btnlayt.addWidget(self.close) self.btnlayt.addWidget(self.save) self.layt = QtGui.QVBoxLayout() self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.layt.addWidget(self.tree) self.layt.addLayout(self.btnlayt) self.setLayout(self.layt) # connections if select_file: self.connect(self.tree, SIGNAL('path_chosen'), self.path_chosen) else: self.connect(self.tree, SIGNAL('path_chosen'), self.save_path) self.connect(self.tree, SIGNAL('selectionChanged()'), self.selection_changed) qtutils.connect_button(self.close, self.reject) qtutils.connect_button(self.save, self.save_blob)
def __init__(self, parent, revs): QtGui.QWidget.__init__(self, parent) self._revs = revs self._revdict = dict(revs) self._rev_label = QtGui.QLabel() self._revision = completion.GitRefLineEdit() # Create the radio buttons radio_btns = [] self._radio_btns = {} for label, rev_list in self._revs: radio = QtGui.QRadioButton() radio.setText(label) radio.setObjectName(label) qtutils.connect_button(radio, self._set_revision_list) radio_btns.append(radio) self._radio_btns[label] = radio radio_btns.append(qtutils.STRETCH) self._rev_list = QtGui.QListWidget() label, rev_list = self._revs[0] self._radio_btns[label].setChecked(True) qtutils.set_items(self._rev_list, rev_list) self._rev_layt = qtutils.hbox(defs.no_margin, defs.spacing, self._rev_label, self._revision) self._radio_layt = qtutils.hbox(defs.margin, defs.spacing, *radio_btns) self._layt = qtutils.vbox(defs.no_margin, defs.spacing, self._rev_layt, self._radio_layt, self._rev_list) self.setLayout(self._layt) self.connect(self._rev_list, SIGNAL('itemSelectionChanged()'), self._rev_list_selection_changed)
def __init__(self, model, select_file=False, parent=None): QtGui.QDialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowModality(Qt.WindowModal) # updated for use by commands self.model = model # widgets self.tree = GitTreeWidget(model.ref, parent=self) self.close = QtGui.QPushButton('Close') self.save = QtGui.QPushButton(select_file and 'Select' or 'Save') self.save.setDefault(True) self.save.setEnabled(False) # layouts self.btnlayt = QtGui.QHBoxLayout() self.btnlayt.addStretch() self.btnlayt.addWidget(self.close) self.btnlayt.addWidget(self.save) self.layt = QtGui.QVBoxLayout() self.layt.setMargin(defs.margin) self.layt.setSpacing(defs.spacing) self.layt.addWidget(self.tree) self.layt.addLayout(self.btnlayt) self.setLayout(self.layt) # connections if select_file: self.connect(self.tree, SIGNAL('path_chosen'), self.path_chosen) else: self.connect(self.tree, SIGNAL('path_chosen'), self.save_path) self.connect(self.tree, SIGNAL('selectionChanged()'), self.selection_changed) qtutils.connect_button(self.close, self.reject) qtutils.connect_button(self.save, self.save_blob)
def __init__(self, titlebar, parent=None): QtGui.QWidget.__init__(self, parent) tooltip = N_('Toggle the paths filter') icon = icons.ellipsis() self.filter_button = qtutils.create_action_button(tooltip=tooltip, icon=icon) self.filter_widget = StatusFilterWidget() self.filter_widget.hide() self.tree = StatusTreeWidget() self.setFocusProxy(self.tree) self.main_layout = qtutils.vbox(defs.no_margin, defs.no_spacing, self.filter_widget, self.tree) self.setLayout(self.main_layout) self.toggle_action = qtutils.add_action(self, tooltip, self.toggle_filter, hotkeys.FILTER) titlebar.add_corner_widget(self.filter_button) qtutils.connect_button(self.filter_button, self.toggle_filter)
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowModality(Qt.WindowModal) self.add_btn = QtGui.QPushButton(N_('Add Remote')) self.add_btn.setIcon(qtutils.apply_icon()) self.add_btn.setEnabled(False) self.cancel_btn = QtGui.QPushButton(N_('Cancel')) def lineedit(hint): widget = text.HintedLineEdit(hint) widget.enable_hint(True) metrics = QtGui.QFontMetrics(widget.font()) widget.setMinimumWidth(metrics.width('_' * 32)) return widget self.setWindowTitle(N_('Add remote')) self.name = lineedit(N_('Name for the new remote')) self.url = lineedit('git://git.example.com/repo.git') self._form = qtutils.form(defs.margin, defs.spacing, (N_('Name'), self.name), (N_('URL'), self.url)) self._btn_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.add_btn, self.cancel_btn) self._layout = qtutils.vbox(defs.margin, defs.spacing, self._form, self._btn_layout) self.setLayout(self._layout) self.connect(self.name, SIGNAL('textChanged(QString)'), self.validate) self.connect(self.url, SIGNAL('textChanged(QString)'), self.validate) qtutils.connect_button(self.add_btn, self.accept) qtutils.connect_button(self.cancel_btn, self.reject)
def __init__(self, parent): QtGui.QDialog.__init__(self, parent) self.setWindowModality(Qt.WindowModal) self.add_btn = qtutils.create_button(text=N_('Add Remote'), icon=icons.ok(), enabled=False) self.close_btn = qtutils.close_button() def lineedit(hint): widget = text.HintedLineEdit(hint) widget.hint.enable(True) metrics = QtGui.QFontMetrics(widget.font()) widget.setMinimumWidth(metrics.width('_' * 32)) return widget self.setWindowTitle(N_('Add remote')) self.name = lineedit(N_('Name for the new remote')) self.url = lineedit('git://git.example.com/repo.git') self._form = qtutils.form(defs.margin, defs.spacing, (N_('Name'), self.name), (N_('URL'), self.url)) self._btn_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.add_btn, self.close_btn) self._layout = qtutils.vbox(defs.margin, defs.spacing, self._form, self._btn_layout) self.setLayout(self._layout) self.connect(self.name, SIGNAL('textChanged(QString)'), self.validate) self.connect(self.url, SIGNAL('textChanged(QString)'), self.validate) qtutils.connect_button(self.add_btn, self.accept) qtutils.connect_button(self.close_btn, self.reject)
def __init__(self, parent, title, stretch=True): QtGui.QWidget.__init__(self, parent) self.label = label = QtGui.QLabel() font = label.font() font.setCapitalization(QtGui.QFont.SmallCaps) label.setFont(font) label.setText(title) self.setCursor(QtCore.Qt.OpenHandCursor) self.close_button = create_action_button(N_('Close'), qtutils.titlebar_close_icon()) self.toggle_button = create_action_button( N_('Detach'), qtutils.titlebar_normal_icon()) self.corner_layout = QtGui.QHBoxLayout() self.corner_layout.setMargin(defs.no_margin) self.corner_layout.setSpacing(defs.spacing) self.main_layout = QtGui.QHBoxLayout() self.main_layout.setMargin(defs.small_margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(label) self.main_layout.addSpacing(defs.spacing) if stretch: self.main_layout.addStretch() self.main_layout.addLayout(self.corner_layout) self.main_layout.addSpacing(defs.spacing) self.main_layout.addWidget(self.toggle_button) self.main_layout.addWidget(self.close_button) self.setLayout(self.main_layout) qtutils.connect_button(self.toggle_button, self.toggle_floating) qtutils.connect_button(self.close_button, self.toggle_visibility)
def __init__(self, style=BOOKMARKS, parent=None): QtGui.QWidget.__init__(self, parent) self.style = style self.settings = Settings() self.tree = BookmarksTreeWidget(style, self.settings, parent=self) self.add_button = qtutils.create_action_button( tooltip=N_('Add'), icon=qtutils.add_icon()) self.delete_button = qtutils.create_action_button( tooltip=N_('Delete'), icon=qtutils.remove_icon()) self.delete_button.setEnabled(False) self.open_button = qtutils.create_action_button( tooltip=N_('Open'), icon=qtutils.open_icon()) self.open_button.setEnabled(False) self.button_layout = QtGui.QHBoxLayout() self.button_layout.setMargin(defs.no_margin) self.button_layout.setSpacing(defs.spacing) self.button_layout.addWidget(self.open_button) self.button_layout.addWidget(self.add_button) self.button_layout.addWidget(self.delete_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.no_margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.tree) self.setLayout(self.main_layout) self.corner_widget = QtGui.QWidget(self) self.corner_widget.setLayout(self.button_layout) titlebar = parent.titleBarWidget() titlebar.add_corner_widget(self.corner_widget) self.setFocusProxy(self.tree) if style == BOOKMARKS: self.setToolTip(N_('Bookmarked repositories')) elif style == RECENT_REPOS: self.setToolTip(N_('Recent repositories')) self.add_button.hide() qtutils.connect_button(self.add_button, self.tree.add_bookmark) qtutils.connect_button(self.delete_button, self.tree.delete_bookmark) qtutils.connect_button(self.open_button, self.tree.open_repo) self.connect(self.tree, SIGNAL('itemSelectionChanged()'), self.tree_item_selection_changed) QtCore.QTimer.singleShot(0, self.reload_bookmarks)
def __init__(self, style=BOOKMARKS, parent=None): QtGui.QWidget.__init__(self, parent) self.style = style self.settings = Settings() self.tree = BookmarksTreeWidget(style, self.settings, parent=self) self.add_button = qtutils.create_action_button(tooltip=N_('Add'), icon=icons.add()) self.delete_button = qtutils.create_action_button(tooltip=N_('Delete'), icon=icons.remove()) self.open_button = qtutils.create_action_button(tooltip=N_('Open'), icon=icons.repo()) self.button_group = utils.Group(self.delete_button, self.open_button) self.button_group.setEnabled(False) self.setFocusProxy(self.tree) if style == BOOKMARKS: self.setToolTip(N_('Favorite repositories')) elif style == RECENT_REPOS: self.setToolTip(N_('Recent repositories')) self.add_button.hide() self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.open_button, self.add_button, self.delete_button) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.tree) self.setLayout(self.main_layout) self.corner_widget = QtGui.QWidget(self) self.corner_widget.setLayout(self.button_layout) titlebar = parent.titleBarWidget() titlebar.add_corner_widget(self.corner_widget) qtutils.connect_button(self.add_button, self.tree.add_bookmark) qtutils.connect_button(self.delete_button, self.tree.delete_bookmark) qtutils.connect_button(self.open_button, self.tree.open_repo) self.connect(self.tree, SIGNAL('itemSelectionChanged()'), self.tree_item_selection_changed) QtCore.QTimer.singleShot(0, self.reload_bookmarks)
def __init__(self, parent=None): QtGui.QWidget.__init__(self, parent) self.settings = Settings() self.tree = BookmarksTreeWidget(self.settings, parent=self) self.add_button = qtutils.create_action_button(tooltip=N_('Add'), icon=qtutils.add_icon()) self.delete_button = qtutils.create_action_button( tooltip=N_('Delete'), icon=qtutils.remove_icon()) self.delete_button.setEnabled(False) self.open_button = qtutils.create_action_button( tooltip=N_('Open'), icon=qtutils.open_icon()) self.open_button.setEnabled(False) qtutils.connect_button(self.add_button, self.tree.add_bookmark) qtutils.connect_button(self.delete_button, self.tree.delete_bookmark) qtutils.connect_button(self.open_button, self.tree.open_repo) self.connect(self.tree, SIGNAL('itemSelectionChanged()'), self.tree_item_selection_changed) self.button_layout = QtGui.QHBoxLayout() self.button_layout.setMargin(defs.no_margin) self.button_layout.setSpacing(defs.spacing) self.button_layout.addWidget(self.open_button) self.button_layout.addWidget(self.add_button) self.button_layout.addWidget(self.delete_button) self.main_layout = QtGui.QVBoxLayout() self.main_layout.setMargin(defs.no_margin) self.main_layout.setSpacing(defs.spacing) self.main_layout.addWidget(self.tree) self.setLayout(self.main_layout) self.corner_widget = QtGui.QWidget(self) self.corner_widget.setLayout(self.button_layout) titlebar = parent.titleBarWidget() titlebar.add_corner_widget(self.corner_widget) self.setFocusProxy(self.tree) QtCore.QTimer.singleShot(0, self.reload_bookmarks)
def __init__(self, model, parent=None): QtGui.QDialog.__init__(self, parent) self.model = model self.setWindowModality(Qt.WindowModal) self.resize(700, 400) # Widgets self.title_label = QtGui.QLabel() self.revision_label = QtGui.QLabel() self.revision_label.setText(N_('Revision To Merge')) self.revision = completion.GitRefLineEdit() self.radio_local = QtGui.QRadioButton() self.radio_local.setText(N_('Local Branch')) self.radio_local.setChecked(True) self.radio_remote = QtGui.QRadioButton() self.radio_remote.setText(N_('Tracking Branch')) self.radio_tag = QtGui.QRadioButton() self.radio_tag.setText(N_('Tag')) self.revisions = QtGui.QListWidget() self.revisions.setAlternatingRowColors(True) self.button_viz = QtGui.QPushButton(self) self.button_viz.setText(N_('Visualize')) self.checkbox_squash = QtGui.QCheckBox(self) self.checkbox_squash.setText(N_('Squash')) self.checkbox_commit = QtGui.QCheckBox(self) self.checkbox_commit.setText(N_('Commit')) self.checkbox_commit.setChecked(True) self.checkbox_commit_state = True self.button_cancel = QtGui.QPushButton(self) self.button_cancel.setText(N_('Cancel')) self.button_merge = QtGui.QPushButton(self) self.button_merge.setText(N_('Merge')) # Layouts self.revlayt = QtGui.QHBoxLayout() self.revlayt.addWidget(self.revision_label) self.revlayt.addWidget(self.revision) self.revlayt.addStretch() self.revlayt.addWidget(self.title_label) self.radiolayt = QtGui.QHBoxLayout() self.radiolayt.addWidget(self.radio_local) self.radiolayt.addWidget(self.radio_remote) self.radiolayt.addWidget(self.radio_tag) self.buttonlayt = QtGui.QHBoxLayout() self.buttonlayt.setSpacing(defs.button_spacing) self.buttonlayt.addWidget(self.button_viz) self.buttonlayt.addStretch() self.buttonlayt.addWidget(self.checkbox_squash) self.buttonlayt.addWidget(self.checkbox_commit) self.buttonlayt.addWidget(self.button_cancel) self.buttonlayt.addWidget(self.button_merge) self.mainlayt = QtGui.QVBoxLayout() self.mainlayt.setMargin(defs.margin) self.mainlayt.setSpacing(defs.spacing) self.mainlayt.addLayout(self.radiolayt) self.mainlayt.addWidget(self.revisions) self.mainlayt.addLayout(self.revlayt) self.mainlayt.addLayout(self.buttonlayt) self.setLayout(self.mainlayt) self.revision.setFocus() # Signal/slot connections self.connect(self.revision, SIGNAL('textChanged(QString)'), self.update_title) self.connect(self.revisions, SIGNAL('itemSelectionChanged()'), self.revision_selected) qtutils.connect_button(self.button_cancel, self.reject) qtutils.connect_button(self.checkbox_squash, self.toggle_squash) qtutils.connect_button(self.radio_local, self.update_revisions) qtutils.connect_button(self.radio_remote, self.update_revisions) qtutils.connect_button(self.radio_tag, self.update_revisions) qtutils.connect_button(self.button_merge, self.merge_revision) qtutils.connect_button(self.button_viz, self.viz_revision) # Observer messages model.add_observer(model.message_updated, self.update_all) self.update_all()
def __init__(self, parent=None): Dialog.__init__(self, parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Search')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.input_label = QtGui.QLabel('git grep') self.input_label.setFont(diff_font()) self.input_txt = HintedLineEdit(N_('command-line arguments'), self) self.input_txt.enable_hint(True) self.regexp_combo = combo = QtGui.QComboBox() combo.setToolTip(N_('Choose the "git grep" regular expression mode')) items = [N_('Basic Regexp'), N_('Extended Regexp'), N_('Fixed String')] combo.addItems(items) combo.setCurrentIndex(0) combo.setEditable(False) combo.setItemData(0, N_('Search using a POSIX basic regular expression'), Qt.ToolTipRole) combo.setItemData(1, N_('Search using a POSIX extended regular expression'), Qt.ToolTipRole) combo.setItemData(2, N_('Search for a fixed string'), Qt.ToolTipRole) combo.setItemData(0, '--basic-regexp', Qt.UserRole) combo.setItemData(1, '--extended-regexp', Qt.UserRole) combo.setItemData(2, '--fixed-strings', Qt.UserRole) self.result_txt = GrepTextView(N_('grep result...'), self) self.result_txt.enable_hint(True) self.edit_button = QtGui.QPushButton(N_('Edit')) self.edit_button.setIcon(qtutils.open_file_icon()) self.edit_button.setEnabled(False) self.edit_button.setShortcut(cmds.Edit.SHORTCUT) self.refresh_button = QtGui.QPushButton(N_('Refresh')) self.refresh_button.setIcon(qtutils.reload_icon()) self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh) self.shell_checkbox = QtGui.QCheckBox(N_('Shell arguments')) self.shell_checkbox.setToolTip( N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".')) self.shell_checkbox.setChecked(False) self.close_button = QtGui.QPushButton(N_('Close')) self.input_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.input_label, self.input_txt, self.regexp_combo) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.edit_button, self.refresh_button, self.shell_checkbox, qtutils.STRETCH, self.close_button) self.mainlayout = qtutils.vbox(defs.margin, defs.no_spacing, self.input_layout, self.result_txt, self.bottom_layout) self.setLayout(self.mainlayout) self.worker_thread = GrepThread(self) self.connect(self.worker_thread, SIGNAL('result'), self.process_result) self.connect(self.input_txt, SIGNAL('textChanged(QString)'), lambda s: self.search()) self.connect(self.regexp_combo, SIGNAL('currentIndexChanged(int)'), lambda x: self.search()) self.connect(self.result_txt, SIGNAL('leave()'), lambda: self.input_txt.setFocus()) qtutils.add_action(self.input_txt, 'Focus Results', self.focus_results, Qt.Key_Down, Qt.Key_Enter, Qt.Key_Return) qtutils.add_action(self, 'Focus Input', self.focus_input, 'Ctrl+L') qtutils.connect_button(self.edit_button, self.edit) qtutils.connect_button(self.refresh_button, self.search) qtutils.connect_toggle(self.shell_checkbox, lambda x: self.search()) qtutils.connect_button(self.close_button, self.close) qtutils.add_close_action(self) if not self.restore_state(): width, height = qtutils.default_size(parent, 666, 420) self.resize(width, height)
def __init__(self, parent=None): QtGui.QDialog.__init__(self, parent) self.setWindowTitle(N_('Edit Remotes')) if parent is not None: self.setWindowModality(Qt.WindowModal) width = max(640, parent.width()) height = max(480, parent.height()) self.resize(width, height) else: self.resize(720, 300) self.default_hint = N_( '' 'Add and remove remote repositories using the \n' 'Add(+) and Delete(-) buttons on the left-hand side.\n' '\n' 'Remotes can be renamed by selecting one from the list\n' 'and pressing "enter", or by double-clicking.') self.remote_list = [] self.remotes = QtGui.QListWidget() self.remotes.setToolTip( N_('Remote git repositories - double-click to rename')) self.info = text.HintedTextView(self.default_hint, self) font = self.info.font() metrics = QtGui.QFontMetrics(font) width = metrics.width('_' * 42) height = metrics.height() * 13 self.info.setMinimumWidth(width) self.info.setMinimumHeight(height) self.info_thread = RemoteInfoThread(self) icon = icons.add() tooltip = N_('Add new remote git repository') self.add_btn = qtutils.create_toolbutton(icon=icon, tooltip=tooltip) self.refresh_btn = qtutils.create_toolbutton(icon=icons.sync(), tooltip=N_('Refresh')) self.delete_btn = qtutils.create_toolbutton( icon=icons.remove(), tooltip=N_('Delete remote')) self.close_btn = qtutils.close_button() self._top_layout = qtutils.splitter(Qt.Horizontal, self.remotes, self.info) width = self._top_layout.width() self._top_layout.setSizes([width // 4, width * 3 // 4]) self._button_layout = qtutils.hbox(defs.margin, defs.spacing, self.add_btn, self.delete_btn, self.refresh_btn, qtutils.STRETCH, self.close_btn) self._layout = qtutils.vbox(defs.margin, defs.spacing, self._top_layout, self._button_layout) self.setLayout(self._layout) self.refresh() qtutils.connect_button(self.add_btn, self.add) qtutils.connect_button(self.delete_btn, self.delete) qtutils.connect_button(self.refresh_btn, self.refresh) qtutils.connect_button(self.close_btn, self.close) self.connect(self.info_thread, SIGNAL('info(PyQt_PyObject)'), self.info.set_value, Qt.QueuedConnection) self.connect(self.remotes, SIGNAL('itemChanged(QListWidgetItem*)'), self.remote_renamed) self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.selection_changed)