Ejemplo n.º 1
0
    def __init__(self, parent):
        standard.Dialog.__init__(self, parent=parent)

        self.BRANCH_POINT = N_('*** Branch Point ***')
        self.SANDBOX = N_('*** Sandbox ***')
        self.LOCAL = N_('Local')

        self.setWindowTitle(N_('Branch Diff Viewer'))

        self.remote_branches = gitcmds.branch_list(remote=True)
        self.local_branches = gitcmds.branch_list(remote=False)

        self.top_widget = QtGui.QWidget()
        self.bottom_widget = QtGui.QWidget()

        self.left_combo = QtGui.QComboBox()
        self.left_combo.addItem(N_('Local'))
        self.left_combo.addItem(N_('Remote'))
        self.left_combo.setCurrentIndex(0)

        self.right_combo = QtGui.QComboBox()
        self.right_combo.addItem(N_('Local'))
        self.right_combo.addItem(N_('Remote'))
        self.right_combo.setCurrentIndex(1)

        self.left_list = QtGui.QListWidget()
        self.right_list = QtGui.QListWidget()

        self.button_spacer = QtGui.QSpacerItem(1, 1,
                                               QtGui.QSizePolicy.Expanding,
                                               QtGui.QSizePolicy.Minimum)

        self.button_compare = qtutils.create_button(text=N_('Compare'),
                                                    icon=icons.diff())
        self.button_close = qtutils.close_button()

        self.diff_files = standard.TreeWidget()
        self.diff_files.headerItem().setText(0, N_('File Differences'))

        self.top_grid_layout = qtutils.grid(
                defs.no_margin, defs.spacing,
                (self.left_combo, 0, 0, 1, 1),
                (self.left_list, 1, 0, 1, 1),
                (self.right_combo, 0, 1, 1, 1),
                (self.right_list, 1, 1, 1, 1))
        self.top_widget.setLayout(self.top_grid_layout)

        self.bottom_grid_layout = qtutils.grid(
                defs.no_margin, defs.spacing,
                (self.diff_files, 0, 0, 1, 4),
                (self.button_spacer, 1, 1, 1, 1),
                (self.button_compare, 1, 2, 1, 1),
                (self.button_close, 1, 3, 1, 1))
        self.bottom_widget.setLayout(self.bottom_grid_layout)

        self.splitter = qtutils.splitter(Qt.Vertical,
                                         self.top_widget, self.bottom_widget)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.splitter)
        self.setLayout(self.main_layout)
        self.resize(658, 350)

        connect_button(self.button_close, self.accept)
        connect_button(self.button_compare, self.compare)

        self.connect(self.diff_files,
                     SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'),
                     self.compare)

        self.connect(self.left_combo,
                     SIGNAL('currentIndexChanged(int)'),
                     lambda x: self.update_combo_boxes(left=True))

        self.connect(self.right_combo,
                     SIGNAL('currentIndexChanged(int)'),
                     lambda x: self.update_combo_boxes(left=False))

        self.connect(self.left_list,
                     SIGNAL('itemSelectionChanged()'), self.update_diff_files)

        self.connect(self.right_list,
                     SIGNAL('itemSelectionChanged()'), self.update_diff_files)

        self.update_combo_boxes(left=True)
        self.update_combo_boxes(left=False)

        # Pre-select the 0th elements
        item = self.left_list.item(0)
        if item:
            self.left_list.setCurrentItem(item)
            self.left_list.setItemSelected(item, True)

        item = self.right_list.item(0)
        if item:
            self.right_list.setCurrentItem(item)
            self.right_list.setItemSelected(item, True)
Ejemplo n.º 2
0
    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())
Ejemplo n.º 3
0
    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())
Ejemplo n.º 4
0
    def __init__(self, parent):
        standard.Dialog.__init__(self, parent)
        self.setAttribute(Qt.WA_MacMetalStyle)
        self.setWindowTitle(N_('Search'))

        self.mode_combo = QtGui.QComboBox()
        self.browse_button = create_toolbutton(icon=icons.folder(),
                                               tooltip=N_('Browse...'))
        self.query = QtGui.QLineEdit()

        self.start_date = QtGui.QDateEdit()
        self.start_date.setCurrentSection(QtGui.QDateTimeEdit.YearSection)
        self.start_date.setCalendarPopup(True)
        self.start_date.setDisplayFormat(N_('yyyy-MM-dd'))

        self.end_date = QtGui.QDateEdit()
        self.end_date.setCurrentSection(QtGui.QDateTimeEdit.YearSection)
        self.end_date.setCalendarPopup(True)
        self.end_date.setDisplayFormat(N_('yyyy-MM-dd'))

        icon = icons.search()
        self.search_button = qtutils.create_button(text=N_('Search'),
                                                   icon=icon,
                                                   default=True)

        self.max_count = QtGui.QSpinBox()
        self.max_count.setMinimum(5)
        self.max_count.setMaximum(9995)
        self.max_count.setSingleStep(5)
        self.max_count.setValue(500)

        self.commit_list = QtGui.QListWidget()
        self.commit_list.setMinimumSize(QtCore.QSize(1, 1))
        self.commit_list.setAlternatingRowColors(True)
        selection_mode = QtGui.QAbstractItemView.SingleSelection
        self.commit_list.setSelectionMode(selection_mode)

        self.commit_text = DiffTextEdit(self, whitespace=False)

        self.button_export = qtutils.create_button(text=N_('Export Patches'),
                                                   icon=icons.diff())

        self.button_cherrypick = qtutils.create_button(text=N_('Cherry Pick'),
                                                       icon=icons.save())
        self.button_close = qtutils.close_button()

        self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing,
                                       self.query, self.start_date,
                                       self.end_date, self.browse_button,
                                       self.search_button, qtutils.STRETCH,
                                       self.mode_combo, self.max_count)

        self.splitter = qtutils.splitter(Qt.Vertical, self.commit_list,
                                         self.commit_text)

        self.bottom_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                          self.button_export,
                                          self.button_cherrypick,
                                          qtutils.STRETCH, self.button_close)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing,
                                        self.top_layout, self.splitter,
                                        self.bottom_layout)
        self.setLayout(self.main_layout)

        if self.parent():
            self.resize(self.parent().width(), self.parent().height())
        else:
            self.resize(720, 500)
Ejemplo n.º 5
0
def launch_difftool(widget):
    icon = icons.diff()
    return cmd_action(widget, cmds.LaunchDifftool, icon, hotkeys.DIFF)
Ejemplo n.º 6
0
    def __init__(self, parent):
        standard.Dialog.__init__(self, parent)
        self.setAttribute(Qt.WA_MacMetalStyle)
        self.setWindowTitle(N_('Search'))

        self.mode_combo = QtGui.QComboBox()
        self.browse_button = create_toolbutton(icon=icons.folder(),
                                               tooltip=N_('Browse...'))
        self.query = QtGui.QLineEdit()

        self.start_date = QtGui.QDateEdit()
        self.start_date.setCurrentSection(QtGui.QDateTimeEdit.YearSection)
        self.start_date.setCalendarPopup(True)
        self.start_date.setDisplayFormat(N_('yyyy-MM-dd'))

        self.end_date = QtGui.QDateEdit()
        self.end_date.setCurrentSection(QtGui.QDateTimeEdit.YearSection)
        self.end_date.setCalendarPopup(True)
        self.end_date.setDisplayFormat(N_('yyyy-MM-dd'))

        icon = icons.search()
        self.search_button = qtutils.create_button(text=N_('Search'),
                                                   icon=icon, default=True)

        self.max_count = QtGui.QSpinBox()
        self.max_count.setMinimum(5)
        self.max_count.setMaximum(9995)
        self.max_count.setSingleStep(5)
        self.max_count.setValue(500)

        self.commit_list = QtGui.QListWidget()
        self.commit_list.setMinimumSize(QtCore.QSize(1, 1))
        self.commit_list.setAlternatingRowColors(True)
        selection_mode = QtGui.QAbstractItemView.SingleSelection
        self.commit_list.setSelectionMode(selection_mode)

        self.commit_text = DiffTextEdit(self, whitespace=False)

        self.button_export = qtutils.create_button(text=N_('Export Patches'),
                                                   icon=icons.diff())

        self.button_cherrypick = qtutils.create_button(text=N_('Cherry Pick'),
                                                       icon=icons.save())
        self.button_close = qtutils.close_button()

        self.top_layout = qtutils.hbox(defs.no_margin, defs.button_spacing,
                                       self.query, self.start_date,
                                       self.end_date, self.browse_button,
                                       self.search_button, qtutils.STRETCH,
                                       self.mode_combo, self.max_count)

        self.splitter = qtutils.splitter(Qt.Vertical,
                                         self.commit_list, self.commit_text)

        self.bottom_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                          self.button_export,
                                          self.button_cherrypick,
                                          qtutils.STRETCH, self.button_close)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing,
                                        self.top_layout, self.splitter,
                                        self.bottom_layout)
        self.setLayout(self.main_layout)

        if self.parent():
            self.resize(self.parent().width(), self.parent().height())
        else:
            self.resize(720, 500)
Ejemplo n.º 7
0
def launch_difftool(widget):
    icon = icons.diff()
    return cmd_action(widget, cmds.LaunchDifftool, icon, hotkeys.DIFF)
Ejemplo n.º 8
0
    def __init__(self,
                 parent,
                 a=None,
                 b=None,
                 expr=None,
                 title=None,
                 hide_expr=False):
        QtGui.QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_MacMetalStyle)

        self.a = a
        self.b = b
        self.diff_expr = expr

        if title is None:
            title = N_('git-cola diff')

        self.setWindowTitle(title)
        self.setWindowModality(QtCore.Qt.WindowModal)

        self.expr = completion.GitRefLineEdit(parent=self)
        if expr is not None:
            self.expr.setText(expr)

        if expr is None or hide_expr:
            self.expr.hide()

        self.tree = filetree.FileTree(parent=self)

        self.diff_button = qtutils.create_button(text=N_('Compare'),
                                                 icon=icons.diff(),
                                                 enabled=False)
        self.close_button = qtutils.close_button()

        self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                          qtutils.STRETCH, self.diff_button,
                                          self.close_button)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing, self.expr,
                                        self.tree, self.button_layout)
        self.setLayout(self.main_layout)

        self.connect(self.tree, SIGNAL('itemSelectionChanged()'),
                     self.tree_selection_changed)

        self.connect(self.tree,
                     SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'),
                     self.tree_double_clicked)

        self.connect(self.expr, SIGNAL('textChanged(QString)'),
                     self.text_changed)
        self.connect(self.tree, SIGNAL('up()'), self.focus_input)

        self.connect(self.expr, SIGNAL('activated()'), self.focus_tree)
        self.connect(self.expr, SIGNAL('down()'), self.focus_tree)
        self.connect(self.expr, SIGNAL('enter()'), self.focus_tree)
        self.connect(self.expr, SIGNAL('return()'), self.focus_tree)

        qtutils.connect_button(self.diff_button, self.diff)
        qtutils.connect_button(self.close_button, self.close)

        qtutils.add_action(self, 'Focus Input', self.focus_input,
                           hotkeys.FOCUS)
        qtutils.add_close_action(self)

        self.resize(720, 420)
        self.refresh()
Ejemplo n.º 9
0
    def __init__(self, parent, a=None, b=None, expr=None, title=None,
                 hide_expr=False):
        QtGui.QDialog.__init__(self, parent)
        self.setAttribute(Qt.WA_MacMetalStyle)

        self.a = a
        self.b = b
        self.diff_expr = expr

        if title is None:
            title = N_('git-cola diff')

        self.setWindowTitle(title)
        self.setWindowModality(QtCore.Qt.WindowModal)

        self.expr = completion.GitRefLineEdit(parent=self)
        if expr is not None:
            self.expr.setText(expr)

        if expr is None or hide_expr:
            self.expr.hide()

        self.tree = filetree.FileTree(parent=self)

        self.diff_button = qtutils.create_button(text=N_('Compare'),
                                                 icon=icons.diff(),
                                                 enabled=False)
        self.close_button = qtutils.close_button()

        self.button_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                          qtutils.STRETCH,
                                          self.diff_button, self.close_button)

        self.main_layout = qtutils.vbox(defs.margin, defs.spacing,
                                        self.expr, self.tree,
                                        self.button_layout)
        self.setLayout(self.main_layout)

        self.connect(self.tree, SIGNAL('itemSelectionChanged()'),
                     self.tree_selection_changed)

        self.connect(self.tree,
                     SIGNAL('itemDoubleClicked(QTreeWidgetItem*,int)'),
                     self.tree_double_clicked)

        self.connect(self.expr, SIGNAL('textChanged(QString)'),
                     self.text_changed)
        self.connect(self.tree, SIGNAL('up()'), self.focus_input)

        self.connect(self.expr, SIGNAL('activated()'), self.focus_tree)
        self.connect(self.expr, SIGNAL('down()'), self.focus_tree)
        self.connect(self.expr, SIGNAL('enter()'), self.focus_tree)
        self.connect(self.expr, SIGNAL('return()'), self.focus_tree)

        qtutils.connect_button(self.diff_button, self.diff)
        qtutils.connect_button(self.close_button, self.close)

        qtutils.add_action(self, 'Focus Input', self.focus_input, hotkeys.FOCUS)
        qtutils.add_close_action(self)

        self.resize(720, 420)
        self.refresh()