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): 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=None): QtGui.QTreeWidget.__init__(self, parent) self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.headerItem().setHidden(True) self.setAllColumnsShowFocus(True) self.setSortingEnabled(False) self.setUniformRowHeights(True) self.setAnimated(True) self.setRootIsDecorated(False) self.setIndentation(0) self.setDragEnabled(True) ok = icons.ok() compare = icons.compare() question = icons.question() self.add_toplevel_item(N_('Staged'), ok, hide=True) self.add_toplevel_item(N_('Unmerged'), compare, hide=True) self.add_toplevel_item(N_('Modified'), compare, hide=True) self.add_toplevel_item(N_('Untracked'), question, hide=True) # Used to restore the selection self.old_scroll = None self.old_selection = None self.old_contents = None self.old_current_item = None self.expanded_items = set() self.process_selection_action = qtutils.add_action( self, cmds.StageOrUnstage.name(), cmds.run(cmds.StageOrUnstage), hotkeys.STAGE_SELECTION) self.revert_unstaged_edits_action = qtutils.add_action( self, cmds.RevertUnstagedEdits.name(), cmds.run(cmds.RevertUnstagedEdits), hotkeys.REVERT) self.revert_unstaged_edits_action.setIcon(icons.undo()) self.launch_difftool_action = qtutils.add_action( self, cmds.LaunchDifftool.name(), cmds.run(cmds.LaunchDifftool), hotkeys.DIFF) self.launch_difftool_action.setIcon(icons.diff()) self.launch_editor_action = qtutils.add_action( self, cmds.LaunchEditor.name(), cmds.run(cmds.LaunchEditor), hotkeys.EDIT, *hotkeys.ACCEPT) self.launch_editor_action.setIcon(icons.edit()) if not utils.is_win32(): self.open_using_default_app = qtutils.add_action( self, cmds.OpenDefaultApp.name(), self._open_using_default_app, hotkeys.PRIMARY_ACTION) self.open_using_default_app.setIcon(icons.default_app()) self.open_parent_dir_action = qtutils.add_action( self, cmds.OpenParentDir.name(), self._open_parent_dir, hotkeys.SECONDARY_ACTION) self.open_parent_dir_action.setIcon(icons.folder()) self.up_action = qtutils.add_action(self, N_('Move Up'), self.move_up, hotkeys.MOVE_UP, hotkeys.MOVE_UP_SECONDARY) self.down_action = qtutils.add_action(self, N_('Move Down'), self.move_down, hotkeys.MOVE_DOWN, hotkeys.MOVE_DOWN_SECONDARY) self.copy_path_action = qtutils.add_action( self, N_('Copy Path to Clipboard'), self.copy_path, hotkeys.COPY) self.copy_path_action.setIcon(icons.copy()) self.copy_relpath_action = qtutils.add_action( self, N_('Copy Relative Path to Clipboard'), self.copy_relpath, hotkeys.CUT) self.copy_relpath_action.setIcon(icons.copy()) self.view_history_action = qtutils.add_action(self, N_('View History...'), self.view_history, hotkeys.HISTORY) # MoveToTrash and Delete use the same shortcut. # We will only bind one of them, depending on whether or not the # MoveToTrash command is avaialble. When available, the hotkey # is bound to MoveToTrash, otherwise it is bound to Delete. if cmds.MoveToTrash.AVAILABLE: self.move_to_trash_action = qtutils.add_action( self, N_('Move file(s) to trash'), self._trash_untracked_files, hotkeys.TRASH) self.move_to_trash_action.setIcon(icons.discard()) delete_shortcut = hotkeys.DELETE_FILE else: self.move_to_trash_action = None delete_shortcut = hotkeys.DELETE_FILE_SECONDARY self.delete_untracked_files_action = qtutils.add_action( self, N_('Delete File(s)...'), self._delete_untracked_files, delete_shortcut) self.delete_untracked_files_action.setIcon(icons.discard()) self.connect(self, SIGNAL('about_to_update()'), self._about_to_update, Qt.QueuedConnection) self.connect(self, SIGNAL('updated()'), self._updated, Qt.QueuedConnection) self.m = main.model() self.m.add_observer(self.m.message_about_to_update, self.about_to_update) self.m.add_observer(self.m.message_updated, self.updated) self.connect(self, SIGNAL('itemSelectionChanged()'), self.show_selection) self.connect(self, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.double_clicked) self.connect(self, SIGNAL('itemCollapsed(QTreeWidgetItem*)'), lambda x: self.update_column_widths()) self.connect(self, SIGNAL('itemExpanded(QTreeWidgetItem*)'), lambda x: self.update_column_widths())
def ok_button(text, default=False, enabled=True): return create_button(text=text, icon=icons.ok(), default=default, enabled=enabled)
def __init__(self, parent=None): super(ApplyPatches, self).__init__(parent=parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Apply Patches')) self.setAcceptDrops(True) if parent is not None: self.setWindowModality(Qt.WindowModal) self.curdir = core.getcwd() self.inner_drag = False self.usage = QtGui.QLabel() self.usage.setText( N_(""" <p> Drag and drop or use the <strong>Add</strong> button to add patches to the list </p> """)) self.tree = PatchTreeWidget(parent=self) self.tree.setHeaderHidden(True) self.add_button = qtutils.create_toolbutton( text=N_('Add'), icon=icons.add(), tooltip=N_('Add patches (+)')) self.remove_button = qtutils.create_toolbutton( text=N_('Remove'), icon=icons.remove(), tooltip=N_('Remove selected (Delete)')) self.apply_button = qtutils.create_button(text=N_('Apply'), icon=icons.ok()) self.close_button = qtutils.close_button() self.add_action = qtutils.add_action(self, N_('Add'), self.add_files, hotkeys.ADD_ITEM) self.remove_action = qtutils.add_action(self, N_('Remove'), self.tree.remove_selected, hotkeys.DELETE, hotkeys.BACKSPACE, hotkeys.REMOVE_ITEM) self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.add_button, self.remove_button, qtutils.STRETCH, self.usage) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.apply_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.top_layout, self.tree, self.bottom_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.add_button, self.add_files) qtutils.connect_button(self.remove_button, self.tree.remove_selected) qtutils.connect_button(self.apply_button, self.apply_patches) qtutils.connect_button(self.close_button, self.close) if not self.restore_state(): self.resize(666, 420)
def __init__(self, parent=None): QtGui.QTreeWidget.__init__(self, parent) self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection) self.headerItem().setHidden(True) self.setAllColumnsShowFocus(True) self.setSortingEnabled(False) self.setUniformRowHeights(True) self.setAnimated(True) self.setRootIsDecorated(False) self.setIndentation(0) self.setDragEnabled(True) self.setAutoScroll(False) ok = icons.ok() compare = icons.compare() question = icons.question() self.add_toplevel_item(N_('Staged'), ok, hide=True) self.add_toplevel_item(N_('Unmerged'), compare, hide=True) self.add_toplevel_item(N_('Modified'), compare, hide=True) self.add_toplevel_item(N_('Untracked'), question, hide=True) # Used to restore the selection self.old_vscroll = None self.old_hscroll = None self.old_selection = None self.old_contents = None self.old_current_item = None self.expanded_items = set() self.process_selection_action = qtutils.add_action( self, cmds.StageOrUnstage.name(), cmds.run(cmds.StageOrUnstage), hotkeys.STAGE_SELECTION) self.revert_unstaged_edits_action = qtutils.add_action( self, cmds.RevertUnstagedEdits.name(), cmds.run(cmds.RevertUnstagedEdits), hotkeys.REVERT) self.revert_unstaged_edits_action.setIcon(icons.undo()) self.launch_difftool_action = qtutils.add_action( self, cmds.LaunchDifftool.name(), cmds.run(cmds.LaunchDifftool), hotkeys.DIFF) self.launch_difftool_action.setIcon(icons.diff()) self.launch_editor_action = qtutils.add_action( self, cmds.LaunchEditor.name(), cmds.run(cmds.LaunchEditor), hotkeys.EDIT, *hotkeys.ACCEPT) self.launch_editor_action.setIcon(icons.edit()) if not utils.is_win32(): self.open_using_default_app = qtutils.add_action( self, cmds.OpenDefaultApp.name(), self._open_using_default_app, hotkeys.PRIMARY_ACTION) self.open_using_default_app.setIcon(icons.default_app()) self.open_parent_dir_action = qtutils.add_action( self, cmds.OpenParentDir.name(), self._open_parent_dir, hotkeys.SECONDARY_ACTION) self.open_parent_dir_action.setIcon(icons.folder()) self.up_action = qtutils.add_action( self, N_('Move Up'), self.move_up, hotkeys.MOVE_UP, hotkeys.MOVE_UP_SECONDARY) self.down_action = qtutils.add_action( self, N_('Move Down'), self.move_down, hotkeys.MOVE_DOWN, hotkeys.MOVE_DOWN_SECONDARY) self.copy_path_action = qtutils.add_action( self, N_('Copy Path to Clipboard'), self.copy_path, hotkeys.COPY) self.copy_path_action.setIcon(icons.copy()) self.copy_relpath_action = qtutils.add_action( self, N_('Copy Relative Path to Clipboard'), self.copy_relpath, hotkeys.CUT) self.copy_relpath_action.setIcon(icons.copy()) self.view_history_action = qtutils.add_action( self, N_('View History...'), self.view_history, hotkeys.HISTORY) self.view_blame_action = qtutils.add_action( self, N_('Blame...'), self.view_blame, hotkeys.BLAME) # MoveToTrash and Delete use the same shortcut. # We will only bind one of them, depending on whether or not the # MoveToTrash command is avaialble. When available, the hotkey # is bound to MoveToTrash, otherwise it is bound to Delete. if cmds.MoveToTrash.AVAILABLE: self.move_to_trash_action = qtutils.add_action( self, N_('Move file(s) to trash'), self._trash_untracked_files, hotkeys.TRASH) self.move_to_trash_action.setIcon(icons.discard()) delete_shortcut = hotkeys.DELETE_FILE else: self.move_to_trash_action = None delete_shortcut = hotkeys.DELETE_FILE_SECONDARY self.delete_untracked_files_action = qtutils.add_action( self, N_('Delete File(s)...'), self._delete_untracked_files, delete_shortcut) self.delete_untracked_files_action.setIcon(icons.discard()) self.connect(self, SIGNAL('about_to_update()'), self._about_to_update, Qt.QueuedConnection) self.connect(self, SIGNAL('updated()'), self._updated, Qt.QueuedConnection) self.m = main.model() self.m.add_observer(self.m.message_about_to_update, self.about_to_update) self.m.add_observer(self.m.message_updated, self.updated) self.connect(self, SIGNAL('itemSelectionChanged()'), self.show_selection) self.connect(self, SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'), self.double_clicked) self.connect(self, SIGNAL('itemCollapsed(QTreeWidgetItem*)'), lambda x: self.update_column_widths()) self.connect(self, SIGNAL('itemExpanded(QTreeWidgetItem*)'), lambda x: self.update_column_widths())
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, 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, context, filename, parent=None): super(Editor, self).__init__(parent) self.widget_version = 1 self.status = 1 self.context = context self.filename = filename self.comment_char = comment_char = prefs.comment_char(context) self.cancel_action = core.getenv('GIT_COLA_SEQ_EDITOR_CANCEL_ACTION', 'abort') self.diff = diff.DiffWidget(context, self) self.tree = RebaseTreeWidget(context, comment_char, self) self.filewidget = filelist.FileWidget(context, self) self.setFocusProxy(self.tree) self.rebase_button = qtutils.create_button( text=core.getenv('GIT_COLA_SEQ_EDITOR_ACTION', N_('Rebase')), tooltip=N_('Accept changes and rebase\n' 'Shortcut: Ctrl+Enter'), icon=icons.ok(), default=True, ) self.extdiff_button = qtutils.create_button( text=N_('Launch Diff Tool'), tooltip=N_('Launch external diff tool\n' 'Shortcut: Ctrl+D'), ) self.extdiff_button.setEnabled(False) self.help_button = qtutils.create_button( text=N_('Help'), tooltip=N_('Show help\nShortcut: ?'), icon=icons.question()) self.cancel_button = qtutils.create_button( text=N_('Cancel'), tooltip=N_('Cancel rebase\nShortcut: Ctrl+Q'), icon=icons.close(), ) top = qtutils.splitter(Qt.Horizontal, self.tree, self.filewidget) top.setSizes([75, 25]) main_split = qtutils.splitter(Qt.Vertical, top, self.diff) main_split.setSizes([25, 75]) controls_layout = qtutils.hbox( defs.no_margin, defs.button_spacing, self.cancel_button, qtutils.STRETCH, self.help_button, self.extdiff_button, self.rebase_button, ) layout = qtutils.vbox(defs.no_margin, defs.spacing, main_split, controls_layout) self.setLayout(layout) self.action_rebase = qtutils.add_action(self, N_('Rebase'), self.rebase, hotkeys.CTRL_RETURN, hotkeys.CTRL_ENTER) self.tree.commits_selected.connect(self.commits_selected) self.tree.commits_selected.connect(self.filewidget.commits_selected) self.tree.commits_selected.connect(self.diff.commits_selected) self.tree.external_diff.connect(self.external_diff) self.filewidget.files_selected.connect(self.diff.files_selected) qtutils.connect_button(self.rebase_button, self.rebase) qtutils.connect_button(self.extdiff_button, self.external_diff) qtutils.connect_button(self.help_button, partial(show_help, context)) qtutils.connect_button(self.cancel_button, self.cancel)
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, parent=None): super(ApplyPatches, self).__init__(parent=parent) self.setAttribute(Qt.WA_MacMetalStyle) self.setWindowTitle(N_('Apply Patches')) self.setAcceptDrops(True) if parent is not None: self.setWindowModality(Qt.WindowModal) self.curdir = core.getcwd() self.inner_drag = False self.usage = QtGui.QLabel() self.usage.setText(N_(""" <p> Drag and drop or use the <strong>Add</strong> button to add patches to the list </p> """)) self.tree = PatchTreeWidget(parent=self) self.tree.setHeaderHidden(True) self.add_button = qtutils.create_toolbutton( text=N_('Add'), icon=icons.add(), tooltip=N_('Add patches (+)')) self.remove_button = qtutils.create_toolbutton( text=N_('Remove'), icon=icons.remove(), tooltip=N_('Remove selected (Delete)')) self.apply_button = qtutils.create_button( text=N_('Apply'), icon=icons.ok()) self.close_button = qtutils.close_button() self.add_action = qtutils.add_action(self, N_('Add'), self.add_files, hotkeys.ADD_ITEM) self.remove_action = qtutils.add_action(self, N_('Remove'), self.tree.remove_selected, hotkeys.DELETE, hotkeys.BACKSPACE, hotkeys.REMOVE_ITEM) self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.add_button, self.remove_button, qtutils.STRETCH, self.usage) self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing, self.apply_button, qtutils.STRETCH, self.close_button) self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.top_layout, self.tree, self.bottom_layout) self.setLayout(self.main_layout) qtutils.connect_button(self.add_button, self.add_files) qtutils.connect_button(self.remove_button, self.tree.remove_selected) qtutils.connect_button(self.apply_button, self.apply_patches) qtutils.connect_button(self.close_button, self.close) if not self.restore_state(): self.resize(666, 420)
def __init__(self, parent, name, opts): standard.Dialog.__init__(self, parent) self.name = name self.opts = opts try: values = self.VALUES[name] except KeyError: values = self.VALUES[name] = {} self.setWindowModality(Qt.ApplicationModal) title = opts.get('title') if title: self.setWindowTitle(os.path.expandvars(title)) self.prompt = QtGui.QLabel() prompt = opts.get('prompt') if prompt: self.prompt.setText(os.path.expandvars(prompt)) self.argslabel = QtGui.QLabel() if 'argprompt' not in opts or opts.get('argprompt') is True: argprompt = N_('Arguments') else: argprompt = opts.get('argprompt') self.argslabel.setText(argprompt) self.argstxt = QtGui.QLineEdit() if self.opts.get('argprompt'): try: # Remember the previous value saved_value = values['argstxt'] self.argstxt.setText(saved_value) except KeyError: pass else: self.argslabel.setMinimumSize(1, 1) self.argstxt.setMinimumSize(1, 1) self.argstxt.hide() self.argslabel.hide() revs = ( (N_('Local Branch'), gitcmds.branch_list(remote=False)), (N_('Tracking Branch'), gitcmds.branch_list(remote=True)), (N_('Tag'), gitcmds.tag_list()), ) if 'revprompt' not in opts or opts.get('revprompt') is True: revprompt = N_('Revision') else: revprompt = opts.get('revprompt') self.revselect = RevisionSelector(self, revs) self.revselect.set_revision_label(revprompt) if not opts.get('revprompt'): self.revselect.hide() # Close/Run buttons self.closebtn = qtutils.close_button() self.runbtn = qtutils.create_button(text=N_('Run'), default=True, icon=icons.ok()) self.argslayt = qtutils.hbox(defs.margin, defs.spacing, self.argslabel, self.argstxt) self.btnlayt = qtutils.hbox(defs.margin, defs.spacing, qtutils.STRETCH, self.closebtn, self.runbtn) self.layt = qtutils.vbox(defs.margin, defs.spacing, self.prompt, self.argslayt, self.revselect, self.btnlayt) self.setLayout(self.layt) self.connect(self.argstxt, SIGNAL('textChanged(QString)'), self._argstxt_changed) qtutils.connect_button(self.closebtn, self.reject) qtutils.connect_button(self.runbtn, self.accept) # Widen the dialog by default self.resize(666, self.height())