def __init__(self, model, parent): FormWidget.__init__(self, model, parent) self.fixed_font = QtGui.QFontComboBox() self.fixed_font.setFontFilters(QtGui.QFontComboBox.MonospacedFonts) self.font_size = QtGui.QSpinBox() self.font_size.setMinimum(8) self.font_size.setProperty('value', QtCore.QVariant(12)) self._font_str = None self.tabwidth = QtGui.QSpinBox() self.tabwidth.setWrapping(True) self.tabwidth.setMaximum(42) self.textwidth = QtGui.QSpinBox() self.textwidth.setWrapping(True) self.textwidth.setMaximum(150) self.linebreak = qtutils.checkbox() self.editor = QtGui.QLineEdit() self.historybrowser = QtGui.QLineEdit() self.difftool = QtGui.QLineEdit() self.mergetool = QtGui.QLineEdit() self.keep_merge_backups = qtutils.checkbox() self.sort_bookmarks = qtutils.checkbox() self.save_gui_settings = qtutils.checkbox() self.add_row(N_('Fixed-Width Font'), self.fixed_font) self.add_row(N_('Font Size'), self.font_size) self.add_row(N_('Tab Width'), self.tabwidth) self.add_row(N_('Text Width'), self.textwidth) self.add_row(N_('Auto-Wrap Lines'), self.linebreak) self.add_row(N_('Editor'), self.editor) self.add_row(N_('History Browser'), self.historybrowser) self.add_row(N_('Diff Tool'), self.difftool) self.add_row(N_('Merge Tool'), self.mergetool) self.add_row(N_('Keep *.orig Merge Backups'), self.keep_merge_backups) self.add_row(N_('Sort bookmarks alphabetically'), self.sort_bookmarks) self.add_row(N_('Save GUI Settings'), self.save_gui_settings) self.set_config({ prefs.SAVEWINDOWSETTINGS: (self.save_gui_settings, True), prefs.TABWIDTH: (self.tabwidth, 8), prefs.TEXTWIDTH: (self.textwidth, 72), prefs.LINEBREAK: (self.linebreak, True), prefs.SORT_BOOKMARKS: (self.sort_bookmarks, True), prefs.DIFFTOOL: (self.difftool, 'xxdiff'), prefs.EDITOR: (self.editor, os.getenv('VISUAL', 'gvim')), prefs.HISTORY_BROWSER: (self.historybrowser, prefs.default_history_browser()), prefs.MERGE_KEEPBACKUP: (self.keep_merge_backups, True), prefs.MERGETOOL: (self.mergetool, 'xxdiff'), }) self.connect(self.fixed_font, SIGNAL('currentFontChanged(QFont)'), self.current_font_changed) self.connect(self.font_size, SIGNAL('valueChanged(int)'), self.font_size_changed)
def __init__(self, model, parent, source): FormWidget.__init__(self, model, parent, source=source) self.name = QtGui.QLineEdit() self.email = QtGui.QLineEdit() self.merge_verbosity = QtGui.QSpinBox() self.merge_verbosity.setMinimum(0) self.merge_verbosity.setMaximum(5) self.merge_verbosity.setProperty('value', QtCore.QVariant(5)) self.diff_context = QtGui.QSpinBox() self.diff_context.setMinimum(2) self.diff_context.setMaximum(99) self.diff_context.setProperty('value', QtCore.QVariant(5)) self.merge_summary = qtutils.checkbox(checked=True) self.merge_diffstat = qtutils.checkbox(checked=True) self.display_untracked = qtutils.checkbox(checked=True) tooltip = N_('Detect conflict markers in unmerged files') self.check_conflicts = qtutils.checkbox(checked=True, tooltip=tooltip) self.add_row(N_('User Name'), self.name) self.add_row(N_('Email Address'), self.email) self.add_row(N_('Merge Verbosity'), self.merge_verbosity) self.add_row(N_('Number of Diff Context Lines'), self.diff_context) self.add_row(N_('Summarize Merge Commits'), self.merge_summary) self.add_row(N_('Show Diffstat After Merge'), self.merge_diffstat) self.add_row(N_('Display Untracked Files'), self.display_untracked) self.add_row(N_('Detect Conflict Markers'), self.check_conflicts) self.set_config({ prefs.CHECKCONFLICTS: (self.check_conflicts, True), prefs.DIFFCONTEXT: (self.diff_context, 5), prefs.DISPLAY_UNTRACKED: (self.display_untracked, True), prefs.USER_NAME: (self.name, ''), prefs.USER_EMAIL: (self.email, ''), prefs.MERGE_DIFFSTAT: (self.merge_diffstat, True), prefs.MERGE_SUMMARY: (self.merge_summary, True), prefs.MERGE_VERBOSITY: (self.merge_verbosity, 5), })
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.edit_action = qtutils.add_action( self, N_('Edit'), self.edit, hotkeys.EDIT) self.refresh_action = qtutils.add_action( self, N_('Refresh'), self.search, *hotkeys.REFRESH_HOTKEYS) 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.hint.enable(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.hint.enable(True) self.edit_button = qtutils.edit_button() qtutils.button_action(self.edit_button, self.edit_action) self.refresh_button = qtutils.refresh_button() qtutils.button_action(self.refresh_button, self.refresh_action) text = N_('Shell arguments') tooltip = N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".') self.shell_checkbox = qtutils.checkbox(text=text, tooltip=tooltip, checked=False) self.close_button = qtutils.close_button() self.refresh_group = Group(self.refresh_action, self.refresh_button) self.refresh_group.setEnabled(False) self.edit_group = Group(self.edit_action, self.edit_button) self.edit_group.setEnabled(False) 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(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)'), self.process_result, Qt.QueuedConnection) 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, hotkeys.DOWN, *hotkeys.ACCEPT) qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS) 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, opts, settings=None, parent=None): standard.Dialog.__init__(self, parent=parent) self.opts = opts self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Create Tag')) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) # Tag label self.tag_name_label = QtGui.QLabel(self) self.tag_name_label.setText(N_('Name')) self.tag_name = text.HintedLineEdit(N_('vX.Y.Z'), self) self.tag_name.set_value(opts.name) self.tag_name.setToolTip(N_('Specifies the tag name')) # Sign Tag self.sign_label = QtGui.QLabel(self) self.sign_label.setText(N_('Sign Tag')) tooltip = N_('Whether to sign the tag (git tag -s)') self.sign_tag = qtutils.checkbox(checked=True, tooltip=tooltip) # Tag message self.tag_msg_label = QtGui.QLabel(self) self.tag_msg_label.setText(N_('Message')) self.tag_msg = text.HintedTextEdit(N_('Tag message...'), self) self.tag_msg.setToolTip(N_('Specifies the tag message')) self.tag_msg.hint.enable(True) # Revision self.rev_label = QtGui.QLabel(self) self.rev_label.setText(N_('Revision')) self.revision = completion.GitRefLineEdit() self.revision.setText(self.opts.ref) self.revision.setToolTip(N_('Specifies the SHA-1 to tag')) # Buttons self.create_button = qtutils.create_button(text=N_('Create Tag'), icon=icons.tag()) self.close_button = qtutils.close_button() # Form layout for inputs self.input_layout = qtutils.form(defs.margin, defs.spacing, (self.tag_name_label, self.tag_name), (self.tag_msg_label, self.tag_msg), (self.rev_label, self.revision), (self.sign_label, self.sign_tag)) self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing, qtutils.STRETCH, self.create_button, self.close_button) self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.input_layout, self.button_layout) self.setLayout(self.main_layt) qtutils.connect_button(self.close_button, self.close) qtutils.connect_button(self.create_button, self.create_tag) if not self.restore_state(settings=settings): self.resize(defs.scale(720), defs.scale(210))
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.edit_action = qtutils.add_action(self, N_('Edit'), self.edit, hotkeys.EDIT) self.refresh_action = qtutils.add_action(self, N_('Refresh'), self.search, *hotkeys.REFRESH_HOTKEYS) 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.hint.enable(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.hint.enable(True) self.edit_button = qtutils.edit_button() qtutils.button_action(self.edit_button, self.edit_action) self.refresh_button = qtutils.refresh_button() qtutils.button_action(self.refresh_button, self.refresh_action) text = N_('Shell arguments') tooltip = N_('Parse arguments using a shell.\n' 'Queries with spaces will require "double quotes".') self.shell_checkbox = qtutils.checkbox(text=text, tooltip=tooltip, checked=False) self.close_button = qtutils.close_button() self.refresh_group = Group(self.refresh_action, self.refresh_button) self.refresh_group.setEnabled(False) self.edit_group = Group(self.edit_action, self.edit_button) self.edit_group.setEnabled(False) 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(PyQt_PyObject,PyQt_PyObject,PyQt_PyObject)'), self.process_result, Qt.QueuedConnection) 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, hotkeys.DOWN, *hotkeys.ACCEPT) qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS) 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, model, parent=None): Dialog.__init__(self, parent=parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Create Branch')) if parent is not None: self.setWindowModality(Qt.WindowModal) self.model = model self.opts = CreateOpts(model) self.thread = CreateThread(self.opts, self) self.progress = QtGui.QProgressDialog(self) self.progress.setRange(0, 0) self.progress.setCancelButton(None) self.progress.setWindowTitle(N_('Create Branch')) self.progress.setWindowModality(Qt.WindowModal) self.branch_name_label = QtGui.QLabel() self.branch_name_label.setText(N_('Branch Name')) self.branch_name = QtGui.QLineEdit() self.rev_label = QtGui.QLabel() self.rev_label.setText(N_('Starting Revision')) self.revision = completion.GitRefLineEdit() current = gitcmds.current_branch() if current: self.revision.setText(current) self.local_radio = qtutils.radio(text=N_('Local branch'), checked=True) self.remote_radio = qtutils.radio(text=N_('Tracking branch')) self.tag_radio = qtutils.radio(text=N_('Tag')) self.branch_list = QtGui.QListWidget() self.update_existing_label = QtGui.QLabel() self.update_existing_label.setText(N_('Update Existing Branch:')) self.no_update_radio = qtutils.radio(text=N_('No')) self.ffwd_only_radio = qtutils.radio(text=N_('Fast Forward Only'), checked=True) self.reset_radio = qtutils.radio(text=N_('Reset')) text = N_('Fetch Tracking Branch') self.fetch_checkbox = qtutils.checkbox(text=text, checked=True) text = N_('Checkout After Creation') self.checkout_checkbox = qtutils.checkbox(text=text, checked=True) icon = icons.branch() self.create_button = qtutils.create_button(text=N_('Create Branch'), icon=icon, default=True) self.close_button = qtutils.close_button() self.rev_start_group = QtGui.QGroupBox() self.rev_start_group.setTitle(N_('Starting Revision')) self.option_group = QtGui.QGroupBox() self.option_group.setTitle(N_('Options')) self.options_checkbox_layout = qtutils.vbox(defs.margin, defs.spacing, self.fetch_checkbox, self.checkout_checkbox) self.options_bottom_layout = qtutils.hbox(defs.margin, defs.spacing, self.options_checkbox_layout, qtutils.STRETCH) self.branch_name_layout = qtutils.hbox(defs.margin, defs.spacing, self.branch_name_label, self.branch_name) self.rev_start_radiobtn_layout = qtutils.hbox(defs.margin, defs.spacing, self.local_radio, self.remote_radio, self.tag_radio, qtutils.STRETCH) self.rev_start_textinput_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.rev_label, self.revision) self.rev_start_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.rev_start_radiobtn_layout, self.branch_list, self.rev_start_textinput_layout) self.rev_start_group.setLayout(self.rev_start_layout) self.options_radio_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.update_existing_label, self.no_update_radio, self.ffwd_only_radio, self.reset_radio) self.options_grp_layout = qtutils.vbox(defs.no_margin, defs.spacing, self.options_radio_layout, self.options_bottom_layout) self.option_group.setLayout(self.options_grp_layout) self.buttons_layout = qtutils.hbox(defs.margin, defs.spacing, self.create_button, self.close_button) self.options_section_layout = qtutils.hbox(defs.no_margin, defs.spacing, self.option_group, self.buttons_layout) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.branch_name_layout, self.rev_start_group, self.options_section_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.close_button, self.reject) qtutils.connect_button(self.create_button, self.create_branch) qtutils.connect_button(self.local_radio, self.display_model) qtutils.connect_button(self.remote_radio, self.display_model) qtutils.connect_button(self.tag_radio, self.display_model) self.connect(self.branch_list, SIGNAL('itemSelectionChanged()'), self.branch_item_changed) self.connect(self.thread, SIGNAL(COMMAND_SIGNAL), self.thread_command, Qt.QueuedConnection) self.connect(self.thread, SIGNAL('done(PyQt_PyObject)'), self.thread_done, Qt.QueuedConnection) self.resize(555, 333) self.display_model()
def __init__(self, model, action, title, parent=None, icon=None): """Customizes the dialog based on the remote action """ standard.Dialog.__init__(self, parent=parent) self.model = model self.action = action self.filtered_remote_branches = [] self.selected_remotes = [] self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(title) if parent is not None: self.setWindowModality(Qt.WindowModal) self.runtask = qtutils.RunTask(parent=self) self.progress = ProgressDialog(title, N_('Updating'), self) self.local_label = QtGui.QLabel() self.local_label.setText(N_('Local Branch')) self.local_branch = QtGui.QLineEdit() self.local_branches = QtGui.QListWidget() self.local_branches.addItems(self.model.local_branches) self.remote_label = QtGui.QLabel() self.remote_label.setText(N_('Remote')) self.remote_name = QtGui.QLineEdit() self.remotes = QtGui.QListWidget() if action == PUSH: self.remotes.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.remotes.addItems(self.model.remotes) self.remote_branch_label = QtGui.QLabel() self.remote_branch_label.setText(N_('Remote Branch')) self.remote_branch = QtGui.QLineEdit() self.remote_branches = QtGui.QListWidget() self.remote_branches.addItems(self.model.remote_branches) text = N_('Fast Forward Only ') self.ffwd_only_checkbox = qtutils.checkbox(text=text, checked=True) self.tags_checkbox = qtutils.checkbox(text=N_('Include tags ')) self.rebase_checkbox = qtutils.checkbox(text=N_('Rebase ')) if icon is None: icon = icons.ok() self.action_button = qtutils.create_button(text=title, icon=icon) self.close_button = qtutils.close_button() self.buttons = utils.Group(self.action_button, self.close_button) self.local_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.local_label, self.local_branch) self.remote_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_label, self.remote_name) self.remote_branches_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_branch_label, self.remote_branch) self.options_layout = qtutils.hbox( defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ffwd_only_checkbox, self.tags_checkbox, self.rebase_checkbox, self.action_button, self.close_button) if action == PUSH: widgets = ( self.remote_branch_layout, self.remotes, self.local_branch_layout, self.local_branches, self.remote_branches_layout, self.remote_branches, self.options_layout, ) else: # fetch and pull widgets = ( self.remote_branch_layout, self.remotes, self.remote_branches_layout, self.remote_branches, self.local_branch_layout, self.local_branches, self.options_layout, ) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, *widgets) self.setLayout(self.main_layout) default_remote = gitcmds.default_remote() or 'origin' remotes = self.model.remotes if default_remote in remotes: idx = remotes.index(default_remote) if self.select_remote(idx): self.remote_name.setText(default_remote) else: if self.select_first_remote(): self.remote_name.setText(remotes[0]) # Trim the remote list to just the default remote self.update_remotes() self.set_field_defaults() # Setup signals and slots self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.update_remotes) self.connect(self.local_branches, SIGNAL('itemSelectionChanged()'), self.update_local_branches) self.connect(self.remote_branches, SIGNAL('itemSelectionChanged()'), self.update_remote_branches) connect_button(self.action_button, self.action_callback) connect_button(self.close_button, self.close) qtutils.add_action(self, N_('Close'), self.close, QtGui.QKeySequence.Close, 'Esc') if action == PULL: self.tags_checkbox.hide() self.ffwd_only_checkbox.hide() self.local_label.hide() self.local_branch.hide() self.local_branches.hide() self.remote_branch.setFocus() else: self.rebase_checkbox.hide() if not self.restore_state(): self.resize(666, 420) self.remote_name.setFocus()
def __init__(self, model, action, title, parent=None, icon=None): """Customizes the dialog based on the remote action """ standard.Dialog.__init__(self, parent=parent) self.model = model self.action = action self.filtered_remote_branches = [] self.selected_remotes = [] self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(title) if parent is not None: self.setWindowModality(Qt.WindowModal) self.runtask = qtutils.RunTask(parent=self) self.progress = ProgressDialog(title, N_('Updating'), self) self.local_label = QtGui.QLabel() self.local_label.setText(N_('Local Branch')) self.local_branch = QtGui.QLineEdit() self.local_branches = QtGui.QListWidget() self.local_branches.addItems(self.model.local_branches) self.remote_label = QtGui.QLabel() self.remote_label.setText(N_('Remote')) self.remote_name = QtGui.QLineEdit() self.remotes = QtGui.QListWidget() if action == PUSH: self.remotes.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.remotes.addItems(self.model.remotes) self.remote_branch_label = QtGui.QLabel() self.remote_branch_label.setText(N_('Remote Branch')) self.remote_branch = QtGui.QLineEdit() self.remote_branches = QtGui.QListWidget() self.remote_branches.addItems(self.model.remote_branches) text = N_('Fast Forward Only ') self.ffwd_only_checkbox = qtutils.checkbox(text=text, checked=True) self.tags_checkbox = qtutils.checkbox(text=N_('Include tags ')) self.rebase_checkbox = qtutils.checkbox(text=N_('Rebase ')) if icon is None: icon = icons.ok() self.action_button = qtutils.create_button(text=title, icon=icon) self.close_button = qtutils.close_button() self.buttons = utils.Group(self.action_button, self.close_button) self.local_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.local_label, self.local_branch) self.remote_branch_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_label, self.remote_name) self.remote_branches_layout = qtutils.hbox(defs.small_margin, defs.spacing, self.remote_branch_label, self.remote_branch) self.options_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, qtutils.STRETCH, self.ffwd_only_checkbox, self.tags_checkbox, self.rebase_checkbox, self.action_button, self.close_button) if action == PUSH: widgets = ( self.remote_branch_layout, self.remotes, self.local_branch_layout, self.local_branches, self.remote_branches_layout, self.remote_branches, self.options_layout, ) else: # fetch and pull widgets = ( self.remote_branch_layout, self.remotes, self.remote_branches_layout, self.remote_branches, self.local_branch_layout, self.local_branches, self.options_layout, ) self.main_layout = qtutils.vbox(defs.no_margin, defs.spacing, *widgets) self.setLayout(self.main_layout) default_remote = gitcmds.default_remote() or 'origin' remotes = self.model.remotes if default_remote in remotes: idx = remotes.index(default_remote) if self.select_remote(idx): self.remote_name.setText(default_remote) else: if self.select_first_remote(): self.remote_name.setText(remotes[0]) # Trim the remote list to just the default remote self.update_remotes() self.set_field_defaults() # Setup signals and slots self.connect(self.remotes, SIGNAL('itemSelectionChanged()'), self.update_remotes) self.connect(self.local_branches, SIGNAL('itemSelectionChanged()'), self.update_local_branches) self.connect(self.remote_branches, SIGNAL('itemSelectionChanged()'), self.update_remote_branches) connect_button(self.action_button, self.action_callback) connect_button(self.close_button, self.close) qtutils.add_action(self, N_('Close'), self.close, QtGui.QKeySequence.Close, 'Esc') if action == PULL: self.tags_checkbox.hide() self.ffwd_only_checkbox.hide() self.local_label.hide() self.local_branch.hide() self.local_branches.hide() self.remote_branch.setFocus() else: self.rebase_checkbox.hide() if not self.restore_state(): self.resize(666, 420) self.remote_name.setFocus()
def __init__(self, cfg, model, parent=None): QtGui.QDialog.__init__(self, parent) self.cfg = cfg self.model = model if parent is not None: self.setWindowModality(Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) # Widgets self.title_label = QtGui.QLabel() self.revision_label = QtGui.QLabel() self.revision_label.setText(N_("Revision to Merge")) self.revision = completion.GitRefLineEdit() self.revision.setFocus() self.revision.setToolTip(N_("Revision to Merge")) self.radio_local = qtutils.radio(text=N_("Local Branch"), checked=True) self.radio_remote = qtutils.radio(text=N_("Tracking Branch")) self.radio_tag = qtutils.radio(text=N_("Tag")) self.revisions = QtGui.QListWidget() self.revisions.setAlternatingRowColors(True) self.button_viz = qtutils.create_button(text=N_("Visualize"), icon=icons.visualize()) tooltip = N_("Squash the merged commit(s) into a single commit") self.checkbox_squash = qtutils.checkbox(text=N_("Squash"), tooltip=tooltip) tooltip = N_("Always create a merge commit when enabled, " "even when the merge is a fast-forward update") self.checkbox_noff = qtutils.checkbox(text=N_("No fast forward"), tooltip=tooltip, checked=False) self.checkbox_noff_state = False tooltip = N_("Commit the merge if there are no conflicts. " "Uncheck to leave the merge uncommitted") self.checkbox_commit = qtutils.checkbox(text=N_("Commit"), tooltip=tooltip, checked=True) self.checkbox_commit_state = True text = N_("Create Signed Commit") checked = cfg.get("cola.signcommits", False) tooltip = N_("GPG-sign the merge commit") self.checkbox_sign = qtutils.checkbox(text=text, checked=checked, tooltip=tooltip) self.button_close = qtutils.close_button() icon = icons.merge() self.button_merge = qtutils.create_button(text=N_("Merge"), icon=icon) # Layouts self.revlayt = qtutils.hbox( defs.no_margin, defs.spacing, self.revision_label, self.revision, qtutils.STRETCH, self.title_label ) self.radiolayt = qtutils.hbox(defs.no_margin, defs.spacing, self.radio_local, self.radio_remote, self.radio_tag) self.buttonlayt = qtutils.hbox( defs.no_margin, defs.button_spacing, self.button_viz, qtutils.STRETCH, self.checkbox_squash, self.checkbox_noff, self.checkbox_commit, self.checkbox_sign, self.button_close, self.button_merge, ) self.mainlayt = qtutils.vbox( defs.margin, defs.spacing, self.radiolayt, self.revisions, self.revlayt, self.buttonlayt ) self.setLayout(self.mainlayt) # 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_close, 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() self.resize(700, 400)
def __init__(self, cfg, model, parent=None): QtGui.QDialog.__init__(self, parent) self.cfg = cfg self.model = model if parent is not None: self.setWindowModality(Qt.WindowModal) self.setAttribute(Qt.WA_MacMetalStyle) # Widgets self.title_label = QtGui.QLabel() self.revision_label = QtGui.QLabel() self.revision_label.setText(N_('Revision to Merge')) self.revision = completion.GitRefLineEdit() self.revision.setFocus() self.revision.setToolTip(N_('Revision to Merge')) self.radio_local = qtutils.radio(text=N_('Local Branch'), checked=True) self.radio_remote = qtutils.radio(text=N_('Tracking Branch')) self.radio_tag = qtutils.radio(text=N_('Tag')) self.revisions = QtGui.QListWidget() self.revisions.setAlternatingRowColors(True) self.button_viz = qtutils.create_button(text=N_('Visualize'), icon=icons.visualize()) tooltip = N_('Squash the merged commit(s) into a single commit') self.checkbox_squash = qtutils.checkbox(text=N_('Squash'), tooltip=tooltip) tooltip = N_('Always create a merge commit when enabled, ' 'even when the merge is a fast-forward update') self.checkbox_noff = qtutils.checkbox(text=N_('No fast forward'), tooltip=tooltip, checked=False) self.checkbox_noff_state = False tooltip = N_('Commit the merge if there are no conflicts. ' 'Uncheck to leave the merge uncommitted') self.checkbox_commit = qtutils.checkbox(text=N_('Commit'), tooltip=tooltip, checked=True) self.checkbox_commit_state = True text = N_('Create Signed Commit') checked = cfg.get('cola.signcommits', False) tooltip = N_('GPG-sign the merge commit') self.checkbox_sign = qtutils.checkbox(text=text, checked=checked, tooltip=tooltip) self.button_close = qtutils.close_button() icon = icons.merge() self.button_merge = qtutils.create_button(text=N_('Merge'), icon=icon) # Layouts self.revlayt = qtutils.hbox(defs.no_margin, defs.spacing, self.revision_label, self.revision, qtutils.STRETCH, self.title_label) self.radiolayt = qtutils.hbox(defs.no_margin, defs.spacing, self.radio_local, self.radio_remote, self.radio_tag) self.buttonlayt = qtutils.hbox( defs.no_margin, defs.button_spacing, self.button_viz, qtutils.STRETCH, self.checkbox_squash, self.checkbox_noff, self.checkbox_commit, self.checkbox_sign, self.button_close, self.button_merge) self.mainlayt = qtutils.vbox(defs.margin, defs.spacing, self.radiolayt, self.revisions, self.revlayt, self.buttonlayt) self.setLayout(self.mainlayt) # 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_close, 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() self.resize(700, 400)
def __init__(self, model, parent=None): Dialog.__init__(self, parent=parent) self.model = model self.stashes = [] self.revids = [] self.names = [] self.setWindowTitle(N_('Stash')) self.setAttribute(QtCore.Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(parent.width(), 420) else: self.resize(700, 420) self.stash_list = QtGui.QListWidget(self) self.stash_text = DiffTextEdit(self) self.button_apply = qtutils.create_toolbutton( text=N_('Apply'), tooltip=N_('Apply the selected stash'), icon=icons.ok()) self.button_save = qtutils.create_toolbutton( text=N_('Save'), tooltip=N_('Save modified state to new stash'), icon=icons.save()) self.button_drop = qtutils.create_toolbutton( text=N_('Drop'), tooltip=N_('Drop the selected stash'), icon=icons.discard()) self.button_close = qtutils.close_button() self.keep_index = qtutils.checkbox(text=N_('Keep Index'), checked=True) # Arrange layouts self.splitter = qtutils.splitter(Qt.Horizontal, self.stash_list, self.stash_text) self.btn_layt = qtutils.hbox(defs.no_margin, defs.spacing, self.button_save, self.button_apply, self.button_drop, self.keep_index, qtutils.STRETCH, self.button_close) self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.splitter, self.btn_layt) self.setLayout(self.main_layt) self.splitter.setSizes([self.width() // 3, self.width() * 2 // 3]) self.update_from_model() self.update_actions() self.setTabOrder(self.button_save, self.button_apply) self.setTabOrder(self.button_apply, self.button_drop) self.setTabOrder(self.button_drop, self.keep_index) self.setTabOrder(self.keep_index, self.button_close) self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'), self.item_selected) qtutils.connect_button(self.button_apply, self.stash_apply) qtutils.connect_button(self.button_save, self.stash_save) qtutils.connect_button(self.button_drop, self.stash_drop) qtutils.connect_button(self.button_close, self.close)
def __init__(self, model, parent=None): Dialog.__init__(self, parent=parent) self.model = model self.stashes = [] self.revids = [] self.names = [] self.setWindowTitle(N_('Stash')) self.setAttribute(QtCore.Qt.WA_MacMetalStyle) if parent is not None: self.setWindowModality(QtCore.Qt.WindowModal) self.resize(parent.width(), 420) else: self.resize(700, 420) self.stash_list = QtGui.QListWidget(self) self.stash_text = DiffTextEdit(self) self.button_apply = qtutils.create_toolbutton( text=N_('Apply'), tooltip=N_('Apply the selected stash'), icon=icons.ok()) self.button_save = qtutils.create_toolbutton( text=N_('Save'), tooltip=N_('Save modified state to new stash'), icon=icons.save()) self.button_drop = qtutils.create_toolbutton( text=N_('Drop'), tooltip=N_('Drop the selected stash'), icon=icons.discard()) self.button_close = qtutils.close_button() self.keep_index = qtutils.checkbox(text=N_('Keep Index'), checked=True) # Arrange layouts self.splitter = qtutils.splitter(Qt.Horizontal, self.stash_list, self.stash_text) self.btn_layt = qtutils.hbox(defs.no_margin, defs.spacing, self.button_save, self.button_apply, self.button_drop, self.keep_index, qtutils.STRETCH, self.button_close) self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.splitter, self.btn_layt) self.setLayout(self.main_layt) self.splitter.setSizes([self.width()//3, self.width()*2//3]) self.update_from_model() self.update_actions() self.setTabOrder(self.button_save, self.button_apply) self.setTabOrder(self.button_apply, self.button_drop) self.setTabOrder(self.button_drop, self.keep_index) self.setTabOrder(self.keep_index, self.button_close) self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'), self.item_selected) qtutils.connect_button(self.button_apply, self.stash_apply) qtutils.connect_button(self.button_save, self.stash_save) qtutils.connect_button(self.button_drop, self.stash_drop) qtutils.connect_button(self.button_close, self.close)