def __init__(self, parent, titlebar): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action(self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action(self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action(self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action(self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button( tooltip=N_('Diff Options'), icon=options_icon()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar.add_corner_widget(self.diffopts_button) self.action_apply_selection = qtutils.add_action(self, '', self.apply_selection, Qt.Key_S) self.action_revert_selection = qtutils.add_action(self, '', self.revert_selection) self.action_revert_selection.setIcon(qtutils.icon('undo.svg')) self.launch_editor = qtutils.add_action(self, cmds.LaunchEditor.name(), run(cmds.LaunchEditor), cmds.LaunchEditor.SHORTCUT, 'Return', 'Enter') self.launch_editor.setIcon(qtutils.options_icon()) self.launch_difftool = qtutils.add_action(self, cmds.LaunchDifftool.name(), run(cmds.LaunchDifftool), cmds.LaunchDifftool.SHORTCUT) self.launch_difftool.setIcon(qtutils.icon('git.svg')) model.add_observer(model.message_diff_text_changed, self._emit_text) self.connect(self, SIGNAL('set_text'), self.setPlainText)
def __init__(self, parent, titlebar): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action( self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action( self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action( self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action( self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button(tooltip=N_('Diff Options'), icon=options_icon()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar.add_corner_widget(self.diffopts_button) self.action_apply_selection = qtutils.add_action( self, '', self.apply_selection, Qt.Key_S) self.action_revert_selection = qtutils.add_action( self, '', self.revert_selection) self.action_revert_selection.setIcon(qtutils.icon('undo.svg')) self.launch_editor = qtutils.add_action(self, cmds.LaunchEditor.name(), run(cmds.LaunchEditor), cmds.LaunchEditor.SHORTCUT, 'Return', 'Enter') self.launch_editor.setIcon(qtutils.options_icon()) self.launch_difftool = qtutils.add_action(self, cmds.LaunchDifftool.name(), run(cmds.LaunchDifftool), cmds.LaunchDifftool.SHORTCUT) self.launch_difftool.setIcon(qtutils.git_icon()) model.add_observer(model.message_diff_text_changed, self._emit_text) self.connect(self, SIGNAL('set_text'), self.setPlainText)
def __init__(self, model, parent): QtGui.QWidget.__init__(self, parent) self.model = model self.notifying = False self.spellcheck_initialized = False self._linebreak = None self._textwidth = None self._tabwidth = None # Actions self.signoff_action = qtutils.add_action(self, cmds.SignOff.name(), cmds.run(cmds.SignOff), cmds.SignOff.SHORTCUT) self.signoff_action.setToolTip(N_('Sign off on this commit')) self.commit_action = qtutils.add_action(self, N_('Commit@@verb'), self.commit, cmds.Commit.SHORTCUT) self.commit_action.setToolTip(N_('Commit staged changes')) # Widgets self.summary = CommitSummaryLineEdit() self.summary.setMinimumHeight(defs.tool_button_height) self.summary.extra_actions.append(self.signoff_action) self.summary.extra_actions.append(self.commit_action) self.description = CommitMessageTextEdit() self.description.extra_actions.append(self.signoff_action) self.description.extra_actions.append(self.commit_action) commit_button_tooltip = N_('Commit staged changes\n' 'Shortcut: Ctrl+Enter') self.commit_button = qtutils.create_toolbutton( text=N_('Commit@@verb'), tooltip=commit_button_tooltip, icon=qtutils.save_icon()) self.actions_menu = QtGui.QMenu() self.actions_button = qtutils.create_toolbutton( icon=qtutils.options_icon(), tooltip=N_('Actions...')) self.actions_button.setMenu(self.actions_menu) self.actions_button.setPopupMode(QtGui.QToolButton.InstantPopup) qtutils.hide_button_menu_indicator(self.actions_button) self.actions_menu.addAction(self.signoff_action) self.actions_menu.addAction(self.commit_action) self.actions_menu.addSeparator() # Amend checkbox self.amend_action = self.actions_menu.addAction( N_('Amend Last Commit')) self.amend_action.setCheckable(True) self.amend_action.setShortcut(cmds.AmendMode.SHORTCUT) self.amend_action.setShortcutContext(Qt.ApplicationShortcut) # Bypass hooks self.bypass_commit_hooks_action = self.actions_menu.addAction( N_('Bypass Commit Hooks')) self.bypass_commit_hooks_action.setCheckable(True) self.bypass_commit_hooks_action.setChecked(False) # Sign commits cfg = gitcfg.current() self.sign_action = self.actions_menu.addAction( N_('Create Signed Commit')) self.sign_action.setCheckable(True) self.sign_action.setChecked(cfg.get('cola.signcommits', False)) # Spell checker self.check_spelling_action = self.actions_menu.addAction( N_('Check Spelling')) self.check_spelling_action.setCheckable(True) self.check_spelling_action.setChecked(False) # Line wrapping self.autowrap_action = self.actions_menu.addAction( N_('Auto-Wrap Lines')) self.autowrap_action.setCheckable(True) self.autowrap_action.setChecked(prefs.linebreak()) # Commit message self.actions_menu.addSeparator() self.load_commitmsg_menu = self.actions_menu.addMenu( N_('Load Previous Commit Message')) self.connect(self.load_commitmsg_menu, SIGNAL('aboutToShow()'), self.build_commitmsg_menu) self.fixup_commit_menu = self.actions_menu.addMenu( N_('Fixup Previous Commit')) self.connect(self.fixup_commit_menu, SIGNAL('aboutToShow()'), self.build_fixup_menu) self.toplayout = qtutils.hbox(defs.no_margin, defs.spacing, self.actions_button, self.summary, self.commit_button) self.toplayout.setContentsMargins(defs.margin, defs.no_margin, defs.no_margin, defs.no_margin) self.mainlayout = qtutils.vbox(defs.no_margin, defs.spacing, self.toplayout, self.description) self.setLayout(self.mainlayout) qtutils.connect_button(self.commit_button, self.commit) # Broadcast the amend mode qtutils.connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode)) qtutils.connect_action_bool(self.check_spelling_action, self.toggle_check_spelling) # Handle the one-off autowrapping qtutils.connect_action_bool(self.autowrap_action, self.set_linebreak) qtutils.add_action(self.summary, N_('Move Down'), self.focus_description, Qt.Key_Return, Qt.Key_Enter) qtutils.add_action(self.summary, N_('Move Down'), self.summary_cursor_down, Qt.Key_Down) self.model.add_observer(self.model.message_commit_message_changed, self.set_commit_message) self.connect(self.summary, SIGNAL('cursorPosition(int,int)'), self.emit_position) self.connect(self.description, SIGNAL('cursorPosition(int,int)'), # description starts at line 2 lambda row, col: self.emit_position(row + 2, col)) # Keep model informed of changes self.connect(self.summary, SIGNAL('textChanged(QString)'), self.commit_summary_changed) self.connect(self.description, SIGNAL('textChanged()'), self.commit_message_changed) self.connect(self.description, SIGNAL('leave()'), self.focus_summary) self.setFont(qtutils.diff_font()) self.summary.enable_hint(True) self.description.enable_hint(True) self.commit_button.setEnabled(False) self.commit_action.setEnabled(False) self.setFocusProxy(self.summary) self.set_tabwidth(prefs.tabwidth()) self.set_textwidth(prefs.textwidth()) self.set_linebreak(prefs.linebreak()) # Loading message commit_msg = '' commit_msg_path = commit_message_path() if commit_msg_path: commit_msg = core.read(commit_msg_path) self.set_commit_message(commit_msg) # Allow tab to jump from the summary to the description self.setTabOrder(self.summary, self.description)
def __init__(self, parent): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action(self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action(self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action(self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action(self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button( tooltip=N_('Diff Options'), icon=options_icon()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar = parent.titleBarWidget() titlebar.add_corner_widget(self.diffopts_button) self.action_process_section = qtutils.add_action(self, N_('Process Diff Region'), self.apply_section, Qt.Key_H) self.action_process_selection = qtutils.add_action(self, N_('Process Selection'), self.apply_selection, Qt.Key_S) self.launch_editor = qtutils.add_action(self, cmds.LaunchEditor.name(), run(cmds.LaunchEditor), cmds.LaunchEditor.SHORTCUT, 'Return', 'Enter') self.launch_editor.setIcon(qtutils.options_icon()) self.launch_difftool = qtutils.add_action(self, cmds.LaunchDifftool.name(), run(cmds.LaunchDifftool), cmds.LaunchDifftool.SHORTCUT) self.launch_difftool.setIcon(qtutils.icon('git.svg')) self.action_stage_selection = qtutils.add_action(self, N_('Stage &Selected Lines'), self.stage_selection) self.action_stage_selection.setIcon(qtutils.icon('add.svg')) self.action_stage_selection.setShortcut(Qt.Key_S) self.action_revert_selection = qtutils.add_action(self, N_('Revert Selected Lines...'), self.revert_selection) self.action_revert_selection.setIcon(qtutils.icon('undo.svg')) self.action_unstage_selection = qtutils.add_action(self, N_('Unstage &Selected Lines'), self.unstage_selection) self.action_unstage_selection.setIcon(qtutils.icon('remove.svg')) self.action_unstage_selection.setShortcut(Qt.Key_S) self.action_apply_selection = qtutils.add_action(self, N_('Apply Diff Selection to Work Tree'), self.stage_selection) self.action_apply_selection.setIcon(qtutils.apply_icon()) model.add_observer(model.message_diff_text_changed, self._emit_text) self.connect(self, SIGNAL('copyAvailable(bool)'), self.enable_selection_actions) self.connect(self, SIGNAL('set_text'), self.setPlainText)
def __init__(self, model, parent): QtGui.QWidget.__init__(self, parent) self.model = model self.notifying = False self.spellcheck_initialized = False self._linebreak = None self._textwidth = None self._tabwidth = None # Actions self.signoff_action = qtutils.add_action(self, cmds.SignOff.name(), cmds.run(cmds.SignOff), cmds.SignOff.SHORTCUT) self.signoff_action.setToolTip(N_('Sign off on this commit')) self.commit_action = qtutils.add_action(self, N_('Commit@@verb'), self.commit, cmds.Commit.SHORTCUT) self.commit_action.setToolTip(N_('Commit staged changes')) self.clear_action = qtutils.add_action(self, N_('Clear...'), self.clear) # Widgets self.summary = CommitSummaryLineEdit() self.summary.setMinimumHeight(defs.tool_button_height) self.summary.extra_actions.append(self.clear_action) self.summary.extra_actions.append(None) self.summary.extra_actions.append(self.signoff_action) self.summary.extra_actions.append(self.commit_action) self.description = CommitMessageTextEdit() self.description.extra_actions.append(self.clear_action) self.description.extra_actions.append(None) self.description.extra_actions.append(self.signoff_action) self.description.extra_actions.append(self.commit_action) commit_button_tooltip = N_('Commit staged changes\n' 'Shortcut: Ctrl+Enter') self.commit_button = qtutils.create_toolbutton( text=N_('Commit@@verb'), tooltip=commit_button_tooltip, icon=qtutils.save_icon()) self.actions_menu = QtGui.QMenu() self.actions_button = qtutils.create_toolbutton( icon=qtutils.options_icon(), tooltip=N_('Actions...')) self.actions_button.setMenu(self.actions_menu) self.actions_button.setPopupMode(QtGui.QToolButton.InstantPopup) qtutils.hide_button_menu_indicator(self.actions_button) self.actions_menu.addAction(self.signoff_action) self.actions_menu.addAction(self.commit_action) self.actions_menu.addSeparator() # Amend checkbox self.amend_action = self.actions_menu.addAction( N_('Amend Last Commit')) self.amend_action.setCheckable(True) self.amend_action.setShortcut(cmds.AmendMode.SHORTCUT) self.amend_action.setShortcutContext(Qt.ApplicationShortcut) # Bypass hooks self.bypass_commit_hooks_action = self.actions_menu.addAction( N_('Bypass Commit Hooks')) self.bypass_commit_hooks_action.setCheckable(True) self.bypass_commit_hooks_action.setChecked(False) # Sign commits cfg = gitcfg.current() self.sign_action = self.actions_menu.addAction( N_('Create Signed Commit')) self.sign_action.setCheckable(True) self.sign_action.setChecked(cfg.get('cola.signcommits', False)) # Spell checker self.check_spelling_action = self.actions_menu.addAction( N_('Check Spelling')) self.check_spelling_action.setCheckable(True) self.check_spelling_action.setChecked(False) # Line wrapping self.autowrap_action = self.actions_menu.addAction( N_('Auto-Wrap Lines')) self.autowrap_action.setCheckable(True) self.autowrap_action.setChecked(prefs.linebreak()) # Commit message self.actions_menu.addSeparator() self.load_commitmsg_menu = self.actions_menu.addMenu( N_('Load Previous Commit Message')) self.connect(self.load_commitmsg_menu, SIGNAL('aboutToShow()'), self.build_commitmsg_menu) self.fixup_commit_menu = self.actions_menu.addMenu( N_('Fixup Previous Commit')) self.connect(self.fixup_commit_menu, SIGNAL('aboutToShow()'), self.build_fixup_menu) self.toplayout = qtutils.hbox(defs.no_margin, defs.spacing, self.actions_button, self.summary, self.commit_button) self.toplayout.setContentsMargins(defs.margin, defs.no_margin, defs.no_margin, defs.no_margin) self.mainlayout = qtutils.vbox(defs.no_margin, defs.spacing, self.toplayout, self.description) self.setLayout(self.mainlayout) qtutils.connect_button(self.commit_button, self.commit) # Broadcast the amend mode qtutils.connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode)) qtutils.connect_action_bool(self.check_spelling_action, self.toggle_check_spelling) # Handle the one-off autowrapping qtutils.connect_action_bool(self.autowrap_action, self.set_linebreak) qtutils.add_action(self.summary, N_('Move Down'), self.focus_description, Qt.Key_Return, Qt.Key_Enter) qtutils.add_action(self.summary, N_('Move Down'), self.summary_cursor_down, Qt.Key_Down) self.model.add_observer(self.model.message_commit_message_changed, self.set_commit_message) self.connect(self.summary, SIGNAL('cursorPosition(int,int)'), self.emit_position) self.connect(self.description, SIGNAL('cursorPosition(int,int)'), # description starts at line 2 lambda row, col: self.emit_position(row + 2, col)) # Keep model informed of changes self.connect(self.summary, SIGNAL('textChanged(QString)'), self.commit_summary_changed) self.connect(self.description, SIGNAL('textChanged()'), self.commit_message_changed) self.connect(self.description, SIGNAL('leave()'), self.focus_summary) self.setFont(qtutils.diff_font()) self.summary.enable_hint(True) self.description.enable_hint(True) self.commit_button.setEnabled(False) self.commit_action.setEnabled(False) self.setFocusProxy(self.summary) self.set_tabwidth(prefs.tabwidth()) self.set_textwidth(prefs.textwidth()) self.set_linebreak(prefs.linebreak()) # Loading message commit_msg = '' commit_msg_path = commit_message_path() if commit_msg_path: commit_msg = core.read(commit_msg_path) self.set_commit_message(commit_msg) # Allow tab to jump from the summary to the description self.setTabOrder(self.summary, self.description)
def __init__(self, parent): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action( self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action( self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action( self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action( self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button(tooltip=N_('Diff Options'), icon=options_icon()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar = parent.titleBarWidget() titlebar.add_corner_widget(self.diffopts_button) self.action_process_section = qtutils.add_action( self, N_('Process Section'), self.apply_section, Qt.Key_H) self.action_process_selection = qtutils.add_action( self, N_('Process Selection'), self.apply_selection, Qt.Key_S) self.launch_editor = qtutils.add_action(self, cmds.LaunchEditor.name(), run(cmds.LaunchEditor), cmds.LaunchEditor.SHORTCUT, 'Return', 'Enter') self.launch_editor.setIcon(qtutils.options_icon()) self.launch_difftool = qtutils.add_action(self, cmds.LaunchDifftool.name(), run(cmds.LaunchDifftool), cmds.LaunchDifftool.SHORTCUT) self.launch_difftool.setIcon(qtutils.icon('git.svg')) self.action_stage_selection = qtutils.add_action( self, N_('Stage &Selected Lines'), self.stage_selection) self.action_stage_selection.setIcon(qtutils.icon('add.svg')) self.action_stage_selection.setShortcut(Qt.Key_S) self.action_revert_selection = qtutils.add_action( self, N_('Revert Selected Lines...'), self.revert_selection) self.action_revert_selection.setIcon(qtutils.icon('undo.svg')) self.action_unstage_selection = qtutils.add_action( self, N_('Unstage &Selected Lines'), self.unstage_selection) self.action_unstage_selection.setIcon(qtutils.icon('remove.svg')) self.action_unstage_selection.setShortcut(Qt.Key_S) self.action_apply_selection = qtutils.add_action( self, N_('Apply Diff Selection to Work Tree'), self.stage_selection) self.action_apply_selection.setIcon(qtutils.apply_icon()) model.add_observer(model.message_diff_text_changed, self._emit_text) self.connect(self, SIGNAL('copyAvailable(bool)'), self.enable_selection_actions) self.connect(self, SIGNAL('set_text'), self.setPlainText)
def __init__(self, parent, titlebar): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action( self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action( self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action( self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action( self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button( tooltip=N_('Diff Options'), icon=icons.configure()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar.add_corner_widget(self.diffopts_button) self.action_apply_selection = qtutils.add_action( self, 'Apply', self.apply_selection, hotkeys.STAGE_DIFF) self.action_revert_selection = qtutils.add_action( self, 'Revert', self.revert_selection, hotkeys.REVERT) self.action_revert_selection.setIcon(icons.undo()) self.launch_editor = actions.launch_editor(self, 'Return', 'Enter') self.launch_difftool = actions.launch_difftool(self) self.stage_or_unstage = actions.stage_or_unstage(self) # Emit up/down signals so that they can be routed by the main widget self.move_down = actions.move_down(self) self.move_up = actions.move_up(self) model.add_observer(model.message_diff_text_changed, self._emit_text) self.selection_model = selection_model = selection.selection_model() selection_model.add_observer(selection_model.message_selection_changed, self._update) self.connect(self, SIGNAL('update()'), self._update_callback, Qt.QueuedConnection) self.connect(self, SIGNAL('set_text(PyQt_PyObject)'), self.setPlainText)
def __init__(self, parent, titlebar): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action(self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action(self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action(self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action(self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button( tooltip=N_('Diff Options'), icon=options_icon()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar.add_corner_widget(self.diffopts_button) self.action_apply_selection = qtutils.add_action(self, '', self.apply_selection, Qt.Key_S) self.action_revert_selection = qtutils.add_action(self, '', self.revert_selection) self.action_revert_selection.setIcon(qtutils.theme_icon('edit-undo.svg')) self.launch_editor = qtutils.add_action(self, cmds.LaunchEditor.name(), run(cmds.LaunchEditor), cmds.LaunchEditor.SHORTCUT, 'Return', 'Enter') self.launch_editor.setIcon(qtutils.options_icon()) self.launch_difftool = qtutils.add_action(self, cmds.LaunchDifftool.name(), run(cmds.LaunchDifftool), cmds.LaunchDifftool.SHORTCUT) self.launch_difftool.setIcon(qtutils.git_icon()) # Emit up/down signals so that they can be routed by the main widget self.move_down = qtutils.add_action(self, N_('Next File'), lambda: self.emit(SIGNAL('move_down()')), Qt.AltModifier + Qt.Key_J) self.move_up = qtutils.add_action(self, N_('Previous File'), lambda: self.emit(SIGNAL('move_up()')), Qt.AltModifier + Qt.Key_K) self.stage_or_unstage = qtutils.add_action(self, cmds.StageOrUnstage.name(), cmds.run(cmds.StageOrUnstage), cmds.StageOrUnstage.SHORTCUT) model.add_observer(model.message_diff_text_changed, self._emit_text) self.connect(self, SIGNAL('set_text(PyQt_PyObject)'), self.setPlainText)
def __init__(self, parent, titlebar): DiffTextEdit.__init__(self, parent) self.model = model = main.model() # "Diff Options" tool menu self.diff_ignore_space_at_eol_action = add_action( self, N_('Ignore changes in whitespace at EOL'), self._update_diff_opts) self.diff_ignore_space_at_eol_action.setCheckable(True) self.diff_ignore_space_change_action = add_action( self, N_('Ignore changes in amount of whitespace'), self._update_diff_opts) self.diff_ignore_space_change_action.setCheckable(True) self.diff_ignore_all_space_action = add_action( self, N_('Ignore all whitespace'), self._update_diff_opts) self.diff_ignore_all_space_action.setCheckable(True) self.diff_function_context_action = add_action( self, N_('Show whole surrounding functions of changes'), self._update_diff_opts) self.diff_function_context_action.setCheckable(True) self.diffopts_button = create_action_button(tooltip=N_('Diff Options'), icon=icons.configure()) self.diffopts_menu = create_menu(N_('Diff Options'), self.diffopts_button) self.diffopts_menu.addAction(self.diff_ignore_space_at_eol_action) self.diffopts_menu.addAction(self.diff_ignore_space_change_action) self.diffopts_menu.addAction(self.diff_ignore_all_space_action) self.diffopts_menu.addAction(self.diff_function_context_action) self.diffopts_button.setMenu(self.diffopts_menu) qtutils.hide_button_menu_indicator(self.diffopts_button) titlebar.add_corner_widget(self.diffopts_button) self.action_apply_selection = qtutils.add_action( self, 'Apply', self.apply_selection, hotkeys.STAGE_DIFF) self.action_revert_selection = qtutils.add_action( self, 'Revert', self.revert_selection, hotkeys.REVERT) self.action_revert_selection.setIcon(icons.undo()) self.launch_editor = actions.launch_editor(self, 'Return', 'Enter') self.launch_difftool = actions.launch_difftool(self) self.stage_or_unstage = actions.stage_or_unstage(self) # Emit up/down signals so that they can be routed by the main widget self.move_down = actions.move_down(self) self.move_up = actions.move_up(self) model.add_observer(model.message_diff_text_changed, self._emit_text) self.selection_model = selection_model = selection.selection_model() selection_model.add_observer(selection_model.message_selection_changed, self._update) self.connect(self, SIGNAL('update()'), self._update_callback, Qt.QueuedConnection) self.connect(self, SIGNAL('set_text(PyQt_PyObject)'), self.setPlainText)