예제 #1
0
    def __init__(self, parent=None):
        standard.TreeWidget.__init__(self, parent=parent)
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setHeaderHidden(True)

        self.open_action = qtutils.add_action(self,
                N_('Open'), self.open_repo, 'Return')
        self.open_action.setEnabled(False)

        self.open_default_action = qtutils.add_action(self,
                cmds.OpenDefaultApp.name(), self.open_default,
                cmds.OpenDefaultApp.SHORTCUT)
        self.open_default_action.setEnabled(False)

        self.launch_editor_action = qtutils.add_action(self,
                cmds.Edit.name(), self.launch_editor,
                cmds.Edit.SHORTCUT)
        self.launch_editor_action.setEnabled(False)

        self.launch_terminal_action = qtutils.add_action(self,
                cmds.LaunchTerminal.name(), self.launch_terminal,
                cmds.LaunchTerminal.SHORTCUT)
        self.launch_terminal_action.setEnabled(False)

        self.copy_action = qtutils.add_action(self,
                N_('Copy'), self.copy, QtGui.QKeySequence.Copy)
        self.copy_action.setEnabled(False)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self._tree_selection_changed)

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

        self.refresh()
예제 #2
0
파일: about.py 프로젝트: 1234-/git-cola
def show_shortcuts():
    try:
        from PyQt4 import QtWebKit
    except ImportError:
        # redhat disabled QtWebKit in their qt build but don't punish the
        # users
        qtutils.critical(N_('This PyQt4 does not include QtWebKit.\n'
                            'The keyboard shortcuts feature is unavailable.'))
        return

    try:
        html = show_shortcuts.html
    except AttributeError:
        hotkeys_html = resources.doc(N_('hotkeys.html'))
        html = show_shortcuts.html = core.read(hotkeys_html)

    try:
        widget = show_shortcuts.widget
    except AttributeError:
        parent = qtutils.active_window()
        widget = show_shortcuts.widget = QtGui.QDialog(parent)
        widget.setWindowModality(Qt.WindowModal)
        widget.setWindowTitle(N_('Shortcuts'))

        web = QtWebKit.QWebView(parent)
        web.setHtml(html)

        layout = qtutils.hbox(defs.no_margin, defs.spacing, web)
        widget.setLayout(layout)
        widget.resize(800, min(parent.height(), 600))
        qtutils.add_action(widget, N_('Close'), widget.accept,
                           hotkeys.QUESTION, *hotkeys.ACCEPT)
    widget.show()
    return widget
예제 #3
0
파일: about.py 프로젝트: ttimz1313/git-cola
def show_shortcuts():
    try:
        from PyQt4 import QtWebKit
    except ImportError:
        # redhat disabled QtWebKit in their qt build but don't punish the
        # users
        qtutils.critical(
            N_('This PyQt4 does not include QtWebKit.\n'
               'The keyboard shortcuts feature is unavailable.'))
        return

    try:
        html = show_shortcuts.html
    except AttributeError:
        hotkeys_html = resources.doc(N_('hotkeys.html'))
        html = show_shortcuts.html = core.read(hotkeys_html)

    try:
        widget = show_shortcuts.widget
    except AttributeError:
        parent = qtutils.active_window()
        widget = show_shortcuts.widget = QtGui.QDialog(parent)
        widget.setWindowModality(Qt.WindowModal)
        widget.setWindowTitle(N_('Shortcuts'))

        web = QtWebKit.QWebView(parent)
        web.setHtml(html)

        layout = qtutils.hbox(defs.no_margin, defs.spacing, web)
        widget.setLayout(layout)
        widget.resize(800, min(parent.height(), 600))
        qtutils.add_action(widget, N_('Close'), widget.accept,
                           hotkeys.QUESTION, *hotkeys.ACCEPT)
    widget.show()
    return widget
예제 #4
0
    def contextMenuEvent(self, event):
        menu = QtGui.QMenu(self)
        menu.addAction(qtutils.add_action(self, N_('Show history'),
                               self.show_file_history))
        menu.addAction(qtutils.add_action(self, N_('Launch Diff Tool'),
                               self.show_file_diff, hotkeys.DIFF))

        menu.exec_(self.mapToGlobal(event.pos()))
예제 #5
0
 def add_navigation(self, name, hotkey, shift=False):
     """Add a hotkey along with a shift-variant"""
     direction = getattr(QtGui.QTextCursor, name)
     qtutils.add_action(self, name, lambda: self.move(direction), hotkey)
     if shift:
         qtutils.add_action(self, 'Shift' + name,
                            lambda: self.move(direction, True),
                            Qt.ShiftModifier | hotkey)
예제 #6
0
 def add_navigation(self, name, hotkey, shift=False):
     """Add a hotkey along with a shift-variant"""
     direction = getattr(QtGui.QTextCursor, name)
     qtutils.add_action(self, name,
                        lambda: self.move(direction), hotkey)
     if shift:
         qtutils.add_action(self, 'Shift'+name,
                            lambda: self.move(direction, True),
                            Qt.ShiftModifier+hotkey)
예제 #7
0
파일: dag.py 프로젝트: PauloVAF/git-cola
 def context_menu_actions(self):
     return {
         'diff_this_selected':
         qtutils.add_action(self, N_('Diff this -> selected'),
                            self.diff_this_selected),
         'diff_selected_this':
         qtutils.add_action(self, N_('Diff selected -> this'),
                            self.diff_selected_this),
         'create_branch':
         qtutils.add_action(self, N_('Create Branch'), self.create_branch),
         'create_patch':
         qtutils.add_action(self, N_('Create Patch'), self.create_patch),
         'create_tag':
         qtutils.add_action(self, N_('Create Tag'), self.create_tag),
         'create_tarball':
         qtutils.add_action(self, N_('Save As Tarball/Zip...'),
                            self.create_tarball),
         'cherry_pick':
         qtutils.add_action(self, N_('Cherry Pick'), self.cherry_pick),
         'save_blob':
         qtutils.add_action(self, N_('Grab File...'),
                            self.save_blob_dialog),
         'copy':
         qtutils.add_action(self, N_('Copy SHA-1'), self.copy_to_clipboard,
                            QtGui.QKeySequence.Copy),
     }
예제 #8
0
파일: dag.py 프로젝트: B-Rich/git-cola
 def context_menu_actions(self):
     return {
     'diff_this_selected':
         qtutils.add_action(self, N_('Diff this -> selected'),
                            self.diff_this_selected),
     'diff_selected_this':
         qtutils.add_action(self, N_('Diff selected -> this'),
                            self.diff_selected_this),
     'create_branch':
         qtutils.add_action(self, N_('Create Branch'),
                            self.create_branch),
     'create_patch':
         qtutils.add_action(self, N_('Create Patch'),
                            self.create_patch),
     'create_tag':
         qtutils.add_action(self, N_('Create Tag'),
                            self.create_tag),
     'create_tarball':
         qtutils.add_action(self, N_('Save As Tarball/Zip...'),
                            self.create_tarball),
     'cherry_pick':
         qtutils.add_action(self, N_('Cherry Pick'),
                            self.cherry_pick),
     'save_blob':
         qtutils.add_action(self, N_('Grab File...'),
                            self.save_blob_dialog),
     'copy':
         qtutils.add_action(self, N_('Copy SHA-1'),
                            self.copy_to_clipboard,
                            QtGui.QKeySequence.Copy),
     }
예제 #9
0
    def __init__(self, parent):
        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.add_item('Staged', 'plus.png', hide=True)
        self.add_item('Unmerged', 'unmerged.png', hide=True)
        self.add_item('Modified', 'modified.png', hide=True)
        self.add_item('Untracked', 'untracked.png', hide=True)

        # Used to restore the selection
        self.old_scroll = None
        self.old_selection = None
        self.old_contents = None

        self.expanded_items = set()

        self.process_selection = qtutils.add_action(self,
                'Process Selection', self._process_selection, 'Ctrl+S')

        self.launch_difftool = qtutils.add_action(self,
                'Process Selection', self._launch_difftool, 'Ctrl+D')

        self.launch_difftool = qtutils.add_action(self,
                'Launch Editor', self._launch_editor, 'Ctrl+E')

        self.up = qtutils.add_action(self, 'Move Up', self.move_up, 'K')
        self.down = qtutils.add_action(self, 'Move Down', self.move_down, 'J')

        self.connect(self, SIGNAL('about_to_update'), self._about_to_update)
        self.connect(self, SIGNAL('updated'), self._updated)

        self.m = cola.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('itemClicked(QTreeWidgetItem*,int)'),
                     self.clicked)
예제 #10
0
def context_menu_actions(self):
    return {
    'diff_this_selected':
        qtutils.add_action(self, 'Diff this -> selected',
                           self._diff_this_selected),
    'diff_selected_this':
        qtutils.add_action(self, 'Diff selected -> this',
                           self._diff_selected_this),
    'create_branch':
        qtutils.add_action(self, 'Create Branch',
                           self._create_branch),
    'create_patch':
        qtutils.add_action(self, 'Create Patch',
                           self._create_patch),
    'create_tag':
        qtutils.add_action(self, 'Create Tag',
                           self._create_tag),
    'create_tarball':
        qtutils.add_action(self, 'Save As Tarball/Zip...',
                           lambda: create_tarball(self)),
    'cherry_pick':
        qtutils.add_action(self, 'Cherry Pick',
                           self._cherry_pick),

    'save_blob':
        qtutils.add_action(self, 'Grab File...',
                           lambda: save_blob_dialog(self)),
    }
예제 #11
0
파일: diff.py 프로젝트: jmdcal/git-cola
    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)
예제 #12
0
    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)
예제 #13
0
파일: text.py 프로젝트: kensholiu/git-cola
    def __init__(self, base):
        self._base = base
        # Common vim/unix-ish keyboard actions
        self.add_navigation("Up", hotkeys.MOVE_UP, shift=True)
        self.add_navigation("Down", hotkeys.MOVE_DOWN, shift=True)
        self.add_navigation("Left", hotkeys.MOVE_LEFT, shift=True)
        self.add_navigation("Right", hotkeys.MOVE_RIGHT, shift=True)
        self.add_navigation("WordLeft", hotkeys.WORD_LEFT)
        self.add_navigation("WordRight", hotkeys.WORD_RIGHT)
        self.add_navigation("StartOfLine", hotkeys.START_OF_LINE)
        self.add_navigation("EndOfLine", hotkeys.END_OF_LINE)

        qtutils.add_action(self, "PageUp", lambda: self.page(-self.height() // 2), hotkeys.SECONDARY_ACTION)

        qtutils.add_action(self, "PageDown", lambda: self.page(self.height() // 2), hotkeys.PRIMARY_ACTION)
예제 #14
0
파일: view.py 프로젝트: termim/git-cola
 def context_menu_actions(self):
     return {
         "diff_this_selected": qtutils.add_action(self, "Diff this -> selected", self.diff_this_selected),
         "diff_selected_this": qtutils.add_action(self, "Diff selected -> this", self.diff_selected_this),
         "create_branch": qtutils.add_action(self, "Create Branch", self.create_branch),
         "create_patch": qtutils.add_action(self, "Create Patch", self.create_patch),
         "create_tag": qtutils.add_action(self, "Create Tag", self.create_tag),
         "create_tarball": qtutils.add_action(self, "Save As Tarball/Zip...", self.create_tarball),
         "cherry_pick": qtutils.add_action(self, "Cherry Pick", self.cherry_pick),
         "save_blob": qtutils.add_action(self, "Grab File...", self.save_blob_dialog),
         "copy": qtutils.add_action(self, "Copy SHA-1", self.copy_to_clipboard, QtGui.QKeySequence.Copy),
     }
예제 #15
0
파일: status.py 프로젝트: jmdcal/git-cola
    def __init__(self, titlebar, parent=None):
        QtGui.QWidget.__init__(self, parent)

        tooltip = N_('Toggle the paths filter')
        self.filter_button = qtutils.create_action_button(
                tooltip=tooltip,
                icon=qtutils.filter_icon())

        self.filter_widget = StatusFilterWidget(self)
        self.filter_widget.hide()

        self.tree = StatusTreeWidget(self)

        self.main_layout = QtGui.QVBoxLayout(self)
        self.main_layout.setMargin(defs.no_margin)
        self.main_layout.setSpacing(defs.no_spacing)

        self.main_layout.addWidget(self.filter_widget)
        self.main_layout.addWidget(self.tree)
        self.setLayout(self.main_layout)

        self.toggle_action = qtutils.add_action(self, tooltip,
                self.toggle_filter, 'Shift+Ctrl+F')

        titlebar.add_corner_widget(self.filter_button)
        qtutils.connect_button(self.filter_button, self.toggle_filter)
예제 #16
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []

        self.action_emit_leave = qtutils.add_action(self,
                'Shift Tab', self.emit_leave, 'Shift+tab')
예제 #17
0
def cmd_browse(args):
    from cola.widgets.browse import worktree_browser

    #context = cola.app.application_init(args)
    global context
    context = new_context(args)
    #view = worktree_browser(context, show=False, update=False, settings=args.settings)
    view = worktree_browser(context, show=False, update=False)
    #return cola.app.application_run(context, view)
    cola.app.initialize_view(context, view)
    cola.app.default_start(context, view)

    def open_repo(context):
        cola.guicmds.open_repo(context)

    view.open_repo_action = add_action(
        view, N_('Open...'), partial(cola.guicmds.open_repo, context))
    #	view, N_('Open...'), partial(open_repo, context))
    view.open_repo_action.triggered.connect(view.tree.action_refresh.trigger)
    actions.append(view.open_repo_action)
    #view.tree.update_actions()
    view.tree.action_refresh.trigger()
    #view.tree.model().refresh()
    view.refresh()
    #view.open_repo_action.trigger()
    #context.app.start()
    return view
예제 #18
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []

        self.action_emit_leave = qtutils.add_action(self,
                'Shift Tab', self.emit_leave, 'Shift+tab')
예제 #19
0
    def setup_dockwidget_view_menu(self):
        # Hotkeys for toggling the dock widgets
        if utils.is_darwin():
            optkey = 'Meta'
        else:
            optkey = 'Ctrl'
        dockwidgets = (
            (optkey + '+0', self.logdockwidget),
            (optkey + '+1', self.commitdockwidget),
            (optkey + '+2', self.statusdockwidget),
            (optkey + '+3', self.diffdockwidget),
            (optkey + '+4', self.actionsdockwidget),
            (optkey + '+5', self.bookmarksdockwidget),
            (optkey + '+6', self.recentdockwidget),
        )
        for shortcut, dockwidget in dockwidgets:
            # Associate the action with the shortcut
            toggleview = dockwidget.toggleViewAction()
            toggleview.setShortcut('Shift+' + shortcut)
            self.view_menu.addAction(toggleview)

            def showdock(show, dockwidget=dockwidget):
                if show:
                    dockwidget.raise_()
                    dockwidget.widget().setFocus()
                else:
                    self.setFocus()

            self.addAction(toggleview)
            qtutils.connect_action_bool(toggleview, showdock)

            # Create a new shortcut Shift+<shortcut> that gives focus
            toggleview = QtGui.QAction(self)
            toggleview.setShortcut(shortcut)

            def focusdock(dockwidget=dockwidget):
                focus_dock(dockwidget)
            self.addAction(toggleview)
            qtutils.connect_action(toggleview, focusdock)

        qtutils.add_action(self, 'Focus Commit Message',
                           lambda: focus_dock(self.commitdockwidget),
                           hotkeys.FOCUS)

        qtutils.add_action(self, 'Focus Status Window',
                           lambda: focus_dock(self.statusdockwidget),
                           hotkeys.FOCUS_STATUS)
예제 #20
0
파일: commitmsg.py 프로젝트: skopp/git-cola
    def __init__(self, parent=None):
        hint = u"Extended description..."
        HintedTextEdit.__init__(self, hint, parent)
        self.extra_actions = []
        self.setMinimumSize(QtCore.QSize(1, 1))

        self.action_emit_shift_tab = add_action(self, "Shift Tab", self.emit_shift_tab, "Shift+tab")

        self.installEventFilter(self)
예제 #21
0
파일: text.py 프로젝트: kensholiu/git-cola
def text_dialog(text, title):
    """Show a wall of text in a dialog"""
    parent = qtutils.active_window()
    label = QtGui.QLabel(parent)
    label.setFont(qtutils.diff_font())
    label.setText(text)
    label.setTextInteractionFlags(Qt.NoTextInteraction)

    widget = QtGui.QDialog(parent)
    widget.setWindowModality(Qt.WindowModal)
    widget.setWindowTitle(title)

    layout = qtutils.hbox(defs.margin, defs.spacing, label)
    widget.setLayout(layout)

    qtutils.add_action(widget, N_("Close"), widget.accept, Qt.Key_Question, Qt.Key_Enter, Qt.Key_Return)
    widget.show()
    return widget
예제 #22
0
    def __init__(self, parent=None):
        hint = u'Extended description...'
        super(CommitMessageTextEdit, self).__init__(hint, parent)
        self.setMinimumSize(QtCore.QSize(1, 1))

        self.action_emit_shift_tab = add_action(self,
                'Shift Tab', self.emit_shift_tab, 'Shift+tab')

        self.installEventFilter(self)
예제 #23
0
    def __init__(self, base):
        self._base = base
        # Common vim/unix-ish keyboard actions
        self.add_navigation('Up', hotkeys.MOVE_UP, shift=True)
        self.add_navigation('Down', hotkeys.MOVE_DOWN, shift=True)
        self.add_navigation('Left', hotkeys.MOVE_LEFT, shift=True)
        self.add_navigation('Right', hotkeys.MOVE_RIGHT, shift=True)
        self.add_navigation('WordLeft', hotkeys.WORD_LEFT)
        self.add_navigation('WordRight', hotkeys.WORD_RIGHT)
        self.add_navigation('StartOfLine', hotkeys.START_OF_LINE)
        self.add_navigation('EndOfLine', hotkeys.END_OF_LINE)

        qtutils.add_action(self, 'PageUp',
                           lambda: self.page(-self.height() // 2),
                           hotkeys.SECONDARY_ACTION)

        qtutils.add_action(self, 'PageDown',
                           lambda: self.page(self.height() // 2),
                           hotkeys.PRIMARY_ACTION)
예제 #24
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []
        self.setMinimumSize(QtCore.QSize(1, 1))

        self.action_emit_leave = add_action(self, 'Shift Tab', self.emit_leave,
                                            'Shift+tab')

        self.installEventFilter(self)
예제 #25
0
파일: main.py 프로젝트: jaiqc/git-cola
    def setup_dockwidget_view_menu(self):
        # Hotkeys for toggling the dock widgets
        if utils.is_darwin():
            optkey = "Meta"
        else:
            optkey = "Ctrl"
        dockwidgets = (
            (optkey + "+0", self.logdockwidget),
            (optkey + "+1", self.commitdockwidget),
            (optkey + "+2", self.statusdockwidget),
            (optkey + "+3", self.diffdockwidget),
            (optkey + "+4", self.actionsdockwidget),
            (optkey + "+5", self.bookmarksdockwidget),
            (optkey + "+6", self.recentdockwidget),
        )
        for shortcut, dockwidget in dockwidgets:
            # Associate the action with the shortcut
            toggleview = dockwidget.toggleViewAction()
            toggleview.setShortcut("Shift+" + shortcut)
            self.view_menu.addAction(toggleview)

            def showdock(show, dockwidget=dockwidget):
                if show:
                    dockwidget.raise_()
                    dockwidget.widget().setFocus()
                else:
                    self.setFocus()

            self.addAction(toggleview)
            qtutils.connect_action_bool(toggleview, showdock)

            # Create a new shortcut Shift+<shortcut> that gives focus
            toggleview = QtGui.QAction(self)
            toggleview.setShortcut(shortcut)

            def focusdock(dockwidget=dockwidget):
                focus_dock(dockwidget)

            self.addAction(toggleview)
            qtutils.connect_action(toggleview, focusdock)

        focus = lambda: focus_dock(self.commitdockwidget)
        qtutils.add_action(self, "Focus Commit Message", focus, hotkeys.FOCUS)
예제 #26
0
    def __init__(self, parent=None):
        hint = u'Extended description...'
        HintedTextEdit.__init__(self, hint, parent)
        self.extra_actions = []
        self.setMinimumSize(QtCore.QSize(1, 1))

        self.action_emit_shift_tab = add_action(self,
                'Shift Tab', self.emit_shift_tab, 'Shift+tab')

        self.installEventFilter(self)
예제 #27
0
def text_dialog(text, title):
    """Show a wall of text in a dialog"""
    parent = qtutils.active_window()
    label = QtGui.QLabel(parent)
    label.setFont(qtutils.diff_font())
    label.setText(text)
    label.setTextInteractionFlags(Qt.NoTextInteraction)

    widget = QtGui.QDialog(parent)
    widget.setWindowModality(Qt.WindowModal)
    widget.setWindowTitle(title)

    layout = qtutils.hbox(defs.margin, defs.spacing, label)
    widget.setLayout(layout)

    qtutils.add_action(widget, N_('Close'), widget.accept, Qt.Key_Question,
                       Qt.Key_Enter, Qt.Key_Return)
    widget.show()
    return widget
예제 #28
0
파일: dag.py 프로젝트: jalaludin/git-cola
    def __init__(self, notifier, parent):
        TreeWidget.__init__(self, parent)
        ViewerMixin.__init__(self)

        self.setSelectionMode(self.ContiguousSelection)
        self.setHeaderLabels([N_("Summary"), N_("Author"), N_("Date, Time")])

        self.sha1map = {}
        self.notifier = notifier
        self.selecting = False
        self.commits = []

        self.action_up = qtutils.add_action(self, N_("Go Up"), self.go_up, Qt.Key_K)

        self.action_down = qtutils.add_action(self, N_("Go Down"), self.go_down, Qt.Key_J)

        notifier.add_observer(COMMITS_SELECTED, self.commits_selected)

        self.connect(self, SIGNAL("itemSelectionChanged()"), self.selection_changed)
예제 #29
0
파일: diff.py 프로젝트: lucianosb/git-cola
    def __init__(self, parent):
        DiffTextEdit.__init__(self, parent)
        self.model = model = main.model()
        self.mode = self.model.mode_none

        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_mode_about_to_change,
                           self._mode_about_to_change)
        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)
예제 #30
0
    def __init__(self, parent=None):
        hint = N_('Extended description...')
        SpellCheckTextEdit.__init__(self, hint, parent)
        self.extra_actions = []
        self.setMinimumSize(QtCore.QSize(1, 1))

        self.action_emit_leave = add_action(self,
                'Shift Tab', self.emit_leave, 'Shift+tab')

        self.installEventFilter(self)
예제 #31
0
    def __init__(self, base):
        self._base = base
        # Common vim/unix-ish keyboard actions
        self.add_navigation('Up', Qt.Key_K, shift=True)
        self.add_navigation('Down', Qt.Key_J, shift=True)
        self.add_navigation('Left', Qt.Key_H, shift=True)
        self.add_navigation('Right', Qt.Key_L, shift=True)
        self.add_navigation('WordLeft', Qt.Key_B)
        self.add_navigation('WordRight', Qt.Key_W)
        self.add_navigation('StartOfLine', Qt.Key_0)
        self.add_navigation('EndOfLine', Qt.Key_Dollar)

        qtutils.add_action(self, 'PageUp',
                           lambda: self.page(-self.height()//2),
                           Qt.ShiftModifier + Qt.Key_Space)

        qtutils.add_action(self, 'PageDown',
                           lambda: self.page(self.height()//2),
                           Qt.Key_Space)
예제 #32
0
    def __init__(self, notifier, parent):
        TreeWidget.__init__(self, parent)
        self.notifier = notifier
        self.setHeaderLabels([N_('Filename'), N_('Additions'), N_('Deletions')])
        notifier.add_observer(COMMITS_SELECTED, self.commits_selected)

        self.show_history_action = (
                qtutils.add_action(self, N_('Show History'),
                                   self.show_file_history, hotkeys.HISTORY))

        self.launch_difftool_action = (
                qtutils.add_action(self, N_('Launch Diff Tool'),
                                   self.show_file_diff, hotkeys.DIFF))

        self.launch_editor_action = (
                qtutils.add_action(self, N_('Launch Diff Tool'),
                                   self.edit_paths, hotkeys.EDIT))

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.selection_changed)
예제 #33
0
    def __init__(self, style, settings, parent=None):
        standard.TreeWidget.__init__(self, parent=parent)
        self.style = style
        self.settings = settings

        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setHeaderHidden(True)

        self.open_action = qtutils.add_action(self, N_('Open'), self.open_repo,
                                              hotkeys.OPEN, *hotkeys.ACCEPT)

        self.open_new_action = qtutils.add_action(self,
                                                  N_('Open in New Window'),
                                                  self.open_new_repo,
                                                  hotkeys.NEW)

        self.set_default_repo_action = qtutils.add_action(
            self, N_('Set Default Repository'), self.set_default_repo)

        self.clear_default_repo_action = qtutils.add_action(
            self, N_('Clear Default Repository'), self.clear_default_repo)

        self.open_default_action = qtutils.add_action(
            self, cmds.OpenDefaultApp.name(), self.open_default,
            hotkeys.PRIMARY_ACTION)

        self.launch_editor_action = qtutils.add_action(self, cmds.Edit.name(),
                                                       self.launch_editor,
                                                       hotkeys.EDIT)

        self.launch_terminal_action = qtutils.add_action(
            self, cmds.LaunchTerminal.name(), self.launch_terminal,
            hotkeys.TERMINAL)

        self.copy_action = qtutils.add_action(self, N_('Copy'), self.copy,
                                              hotkeys.COPY)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.item_selection_changed)

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

        self.action_group = utils.Group(self.open_action, self.open_new_action,
                                        self.copy_action,
                                        self.launch_editor_action,
                                        self.launch_terminal_action,
                                        self.open_default_action)
        self.action_group.setEnabled(False)
        self.set_default_repo_action.setEnabled(False)
        self.clear_default_repo_action.setEnabled(False)
예제 #34
0
def show_shortcuts():
    try:
        from PyQt4 import QtWebKit
    except ImportError:
        # redhat disabled QtWebKit in their qt build but don't punish the
        # users
        qtutils.critical(N_('This PyQt4 does not include QtWebKit.\n'
                            'The keyboard shortcuts feature is unavailable.'))
        return

    try:
        html = show_shortcuts.html
    except AttributeError:
        hotkeys = resources.doc(N_('hotkeys.html'))
        html = show_shortcuts.html = utils.slurp(hotkeys)

    try:
        widget = show_shortcuts.widget
    except AttributeError:
        parent = qtutils.active_window()
        widget = show_shortcuts.widget = QtGui.QDialog(parent)
        widget.setWindowModality(Qt.WindowModal)

        web = QtWebKit.QWebView(parent)
        web.setHtml(html)

        layout = QtGui.QHBoxLayout()
        layout.setMargin(0)
        layout.setSpacing(0)
        layout.addWidget(web)

        widget.setWindowTitle(N_('Shortcuts'))
        widget.setLayout(layout)
        widget.resize(800, min(parent.height(), 600))

        qtutils.add_action(widget, N_('Close'), widget.accept,
                           Qt.Key_Question,
                           Qt.Key_Enter,
                           Qt.Key_Return)
    widget.show()
    return widget
예제 #35
0
파일: dag.py 프로젝트: sbabrass/git-cola
    def __init__(self, notifier, parent):
        standard.TreeWidget.__init__(self, parent)
        ViewerMixin.__init__(self)

        self.setSelectionMode(self.ExtendedSelection)
        self.setHeaderLabels([N_('Summary'), N_('Author'), N_('Date, Time')])

        self.sha1map = {}
        self.notifier = notifier
        self.selecting = False
        self.commits = []

        self.action_up = qtutils.add_action(self, N_('Go Up'),
                                            self.go_up, hotkeys.MOVE_UP)

        self.action_down = qtutils.add_action(self, N_('Go Down'),
                                              self.go_down, hotkeys.MOVE_DOWN)

        notifier.add_observer(diff.COMMITS_SELECTED, self.commits_selected)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.selection_changed)
예제 #36
0
    def __init__(self, style, settings, parent=None):
        standard.TreeWidget.__init__(self, parent=parent)
        self.style = style
        self.settings = settings

        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setHeaderHidden(True)

        self.open_action = qtutils.add_action(self,
                N_('Open'), self.open_repo, hotkeys.OPEN, *hotkeys.ACCEPT)

        self.open_new_action = qtutils.add_action(self,
                N_('Open in New Window'), self.open_new_repo, hotkeys.NEW)

        self.set_default_repo_action = qtutils.add_action(self,
                N_('Set Default Repository'), self.set_default_repo)

        self.clear_default_repo_action = qtutils.add_action(self,
                N_('Clear Default Repository'), self.clear_default_repo)

        self.open_default_action = qtutils.add_action(self,
                cmds.OpenDefaultApp.name(), self.open_default,
                hotkeys.PRIMARY_ACTION)

        self.launch_editor_action = qtutils.add_action(self,
                cmds.Edit.name(), self.launch_editor, hotkeys.EDIT)

        self.launch_terminal_action = qtutils.add_action(self,
                cmds.LaunchTerminal.name(), self.launch_terminal,
                hotkeys.TERMINAL)

        self.copy_action = qtutils.add_action(self,
                N_('Copy'), self.copy, hotkeys.COPY)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.item_selection_changed)

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

        self.action_group = utils.Group(self.open_action,
                                        self.open_new_action,
                                        self.copy_action,
                                        self.launch_editor_action,
                                        self.launch_terminal_action,
                                        self.open_default_action)
        self.action_group.setEnabled(False)
        self.set_default_repo_action.setEnabled(False)
        self.clear_default_repo_action.setEnabled(False)
예제 #37
0
파일: dag.py 프로젝트: artisdom/git-cola
    def __init__(self, notifier, parent):
        standard.TreeWidget.__init__(self, parent)
        ViewerMixin.__init__(self)

        self.setSelectionMode(self.ContiguousSelection)
        self.setHeaderLabels([N_('Summary'), N_('Author'), N_('Date, Time')])

        self.sha1map = {}
        self.notifier = notifier
        self.selecting = False
        self.commits = []

        self.action_up = qtutils.add_action(self, N_('Go Up'),
                                            self.go_up, hotkeys.MOVE_UP)

        self.action_down = qtutils.add_action(self, N_('Go Down'),
                                              self.go_down, hotkeys.MOVE_DOWN)

        notifier.add_observer(diff.COMMITS_SELECTED, self.commits_selected)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.selection_changed)
예제 #38
0
파일: dag.py 프로젝트: PauloVAF/git-cola
    def __init__(self, notifier, parent):
        TreeWidget.__init__(self, parent)
        ViewerMixin.__init__(self)

        self.setSelectionMode(self.ContiguousSelection)
        self.setHeaderLabels([N_('Summary'), N_('Author'), N_('Date, Time')])

        self.sha1map = {}
        self.notifier = notifier
        self.selecting = False
        self.commits = []

        self.action_up = qtutils.add_action(self, N_('Go Up'), self.go_up,
                                            Qt.Key_K)

        self.action_down = qtutils.add_action(self, N_('Go Down'),
                                              self.go_down, Qt.Key_J)

        notifier.add_observer(COMMITS_SELECTED, self.commits_selected)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self.selection_changed)
예제 #39
0
파일: view.py 프로젝트: termim/git-cola
    def __init__(self, notifier, parent):
        QtGui.QTreeWidget.__init__(self, parent)
        ViewerMixin.__init__(self)

        self.setSelectionMode(self.ContiguousSelection)
        self.setUniformRowHeights(True)
        self.setAllColumnsShowFocus(True)
        self.setAlternatingRowColors(True)
        self.setRootIsDecorated(False)
        self.setHeaderLabels(["Summary", "Author", "Age"])

        self.sha1map = {}
        self.notifier = notifier
        self.selecting = False
        self.commits = []

        self.action_up = qtutils.add_action(self, "Go Up", self.go_up, Qt.Key_K)

        self.action_down = qtutils.add_action(self, "Go Down", self.go_down, Qt.Key_J)

        sig = signals.commits_selected
        notifier.add_observer(sig, self.commits_selected)

        self.connect(self, SIGNAL("itemSelectionChanged()"), self.selection_changed)
예제 #40
0
파일: status.py 프로젝트: assem-ch/git-cola
    def __init__(self, titlebar, parent=None):
        QtGui.QWidget.__init__(self, parent)

        tooltip = N_("Toggle the paths filter")
        icon = icons.ellipsis()
        self.filter_button = qtutils.create_action_button(tooltip=tooltip, icon=icon)
        self.filter_widget = StatusFilterWidget()
        self.filter_widget.hide()
        self.tree = StatusTreeWidget()
        self.setFocusProxy(self.tree)

        self.main_layout = qtutils.vbox(defs.no_margin, defs.no_spacing, self.filter_widget, self.tree)
        self.setLayout(self.main_layout)

        self.toggle_action = qtutils.add_action(self, tooltip, self.toggle_filter, hotkeys.FILTER)

        titlebar.add_corner_widget(self.filter_button)
        qtutils.connect_button(self.filter_button, self.toggle_filter)
예제 #41
0
    def __init__(self, context, parent=None):
        super(MainWindow, self).__init__(parent)
        self.context = context
        self.status = 1
        self.editor = None
        default_title = '%s - git cola seqeuence editor' % core.getcwd()
        title = core.getenv('GIT_COLA_SEQ_EDITOR_TITLE', default_title)
        self.setWindowTitle(title)

        self.show_help_action = qtutils.add_action(self, N_('Show Help'),
                                                   partial(show_help, context),
                                                   hotkeys.QUESTION)

        self.menubar = QtWidgets.QMenuBar(self)
        self.help_menu = self.menubar.addMenu(N_('Help'))
        self.help_menu.addAction(self.show_help_action)
        self.setMenuBar(self.menubar)

        qtutils.add_close_action(self)
        self.init_state(context.settings, self.init_window_size)
예제 #42
0
    def __init__(self, parent=None):
        standard.TreeWidget.__init__(self, parent=parent)
        self.setSelectionMode(QtGui.QAbstractItemView.SingleSelection)
        self.setHeaderHidden(True)

        self.open_action = qtutils.add_action(self,
                N_('Open'), self.open_repo, QtGui.QKeySequence.Open)
        self.open_action.setEnabled(False)

        self.open_new_action = qtutils.add_action(self,
                N_('Open in New Window'), self.open_new_repo,
                QtGui.QKeySequence.New)
        self.open_new_action.setEnabled(False)

        self.open_default_action = qtutils.add_action(self,
                cmds.OpenDefaultApp.name(), self.open_default,
                cmds.OpenDefaultApp.SHORTCUT)
        self.open_default_action.setEnabled(False)

        self.edit_bookmarks_action = qtutils.add_action(self,
                N_('Edit'), self.edit_bookmarks)
        self.edit_bookmarks_action.setEnabled(False)

        self.launch_editor_action = qtutils.add_action(self,
                cmds.Edit.name(), self.launch_editor,
                cmds.Edit.SHORTCUT)
        self.launch_editor_action.setEnabled(False)

        self.launch_terminal_action = qtutils.add_action(self,
                cmds.LaunchTerminal.name(), self.launch_terminal,
                cmds.LaunchTerminal.SHORTCUT)
        self.launch_terminal_action.setEnabled(False)

        self.copy_action = qtutils.add_action(self,
                N_('Copy'), self.copy, QtGui.QKeySequence.Copy)
        self.copy_action.setEnabled(False)

        self.connect(self, SIGNAL('itemSelectionChanged()'),
                     self._tree_selection_changed)

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

        self.refresh()
예제 #43
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)

        self.tree = BookmarksTreeWidget(parent=self)
        self.open_button = qtutils.create_action_button(
                N_('Open'), qtutils.open_icon())
        self.open_button.setEnabled(False)

        self.open_action = qtutils.add_action(self,
                N_('Open'), self.open_repo, 'Return')
        self.open_action.setEnabled(False)

        self.edit_button = qtutils.create_action_button(
                N_('Bookmarks...'), qtutils.add_icon())

        qtutils.connect_button(self.open_button, self.open_repo)
        qtutils.connect_button(self.edit_button, self.manage_bookmarks)

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

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

        self.button_layout = QtGui.QHBoxLayout()
        self.button_layout.setMargin(defs.no_margin)
        self.button_layout.setSpacing(defs.spacing)
        self.button_layout.addWidget(self.open_button)
        self.button_layout.addWidget(self.edit_button)

        self.layout = QtGui.QVBoxLayout()
        self.layout.setMargin(defs.no_margin)
        self.layout.setSpacing(defs.spacing)
        self.layout.addWidget(self.tree)
        self.setLayout(self.layout)

        self.corner_widget = QtGui.QWidget(self)
        self.corner_widget.setLayout(self.button_layout)
        titlebar = parent.titleBarWidget()
        titlebar.add_corner_widget(self.corner_widget)
예제 #44
0
파일: status.py 프로젝트: PauloVAF/git-cola
    def __init__(self, titlebar, parent=None):
        QtGui.QWidget.__init__(self, parent)

        tooltip = N_('Toggle the paths filter')
        self.filter_button = qtutils.create_action_button(
            tooltip=tooltip, icon=qtutils.filter_icon())

        self.filter_widget = StatusFilterWidget()
        self.filter_widget.hide()
        self.tree = StatusTreeWidget()

        self.main_layout = qtutils.vbox(defs.no_margin, defs.no_spacing,
                                        self.filter_widget, self.tree)
        self.setLayout(self.main_layout)

        self.toggle_action = qtutils.add_action(self, tooltip,
                                                self.toggle_filter,
                                                'Shift+Ctrl+F')

        titlebar.add_corner_widget(self.filter_button)
        qtutils.connect_button(self.filter_button, self.toggle_filter)
예제 #45
0
    def __init__(self, titlebar, parent=None):
        QtGui.QWidget.__init__(self, parent)

        tooltip = N_('Toggle the paths filter')
        icon = icons.ellipsis()
        self.filter_button = qtutils.create_action_button(tooltip=tooltip,
                                                          icon=icon)
        self.filter_widget = StatusFilterWidget()
        self.filter_widget.hide()
        self.tree = StatusTreeWidget()
        self.setFocusProxy(self.tree)

        self.main_layout = qtutils.vbox(defs.no_margin, defs.no_spacing,
                                        self.filter_widget, self.tree)
        self.setLayout(self.main_layout)

        self.toggle_action = qtutils.add_action(self, tooltip,
                                                self.toggle_filter,
                                                hotkeys.FILTER)

        titlebar.add_corner_widget(self.filter_button)
        qtutils.connect_button(self.filter_button, self.toggle_filter)
예제 #46
0
파일: diff.py 프로젝트: haffmans/git-cola
    def __init__(self, parent):
        DiffTextEdit.__init__(self, parent)
        self.model = model = cola.model()
        self.mode = self.model.mode_none

        # Install diff shortcut keys for stage/unstage
        self.action_process_section = qtutils.add_action(self,
                'Process Section',
                self.apply_section, Qt.Key_H)
        self.action_process_selection = qtutils.add_action(self,
                'Process Selection',
                self.apply_selection, Qt.Key_S)

        # Context menu actions
        self.action_stage_selection = qtutils.add_action(self,
                self.tr('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,
                self.tr('Revert Selected Lines...'),
                self.revert_selection)
        self.action_revert_selection.setIcon(qtutils.icon('undo.svg'))

        self.action_unstage_selection = qtutils.add_action(self,
                self.tr('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,
                self.tr('Apply Diff Selection to Work Tree'),
                self.stage_selection)
        self.action_apply_selection.setIcon(qtutils.apply_icon())

        model.add_observer(model.message_mode_about_to_change,
                           self._mode_about_to_change)
        model.add_observer(model.message_diff_text_changed, self.setPlainText)

        self.connect(self, SIGNAL('copyAvailable(bool)'),
                     self.enable_selection_actions)
예제 #47
0
파일: diff.py 프로젝트: moreati/git-cola
    def __init__(self, parent):
        DiffTextEdit.__init__(self, parent)
        self.model = model = cola.model()
        self.mode = self.model.mode_none

        # Install diff shortcut keys for stage/unstage
        self.action_process_section = qtutils.add_action(
            self, 'Process Section', self.apply_section, Qt.Key_H)
        self.action_process_selection = qtutils.add_action(
            self, 'Process Selection', self.apply_selection, Qt.Key_S)

        # Context menu actions
        self.action_stage_selection = qtutils.add_action(
            self, self.tr('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, self.tr('Revert Selected Lines...'), self.revert_selection)
        self.action_revert_selection.setIcon(qtutils.icon('undo.svg'))

        self.action_unstage_selection = qtutils.add_action(
            self, self.tr('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, self.tr('Apply Diff Selection to Work Tree'),
            self.stage_selection)
        self.action_apply_selection.setIcon(qtutils.apply_icon())

        model.add_observer(model.message_mode_about_to_change,
                           self._mode_about_to_change)
        model.add_observer(model.message_diff_text_changed, self.setPlainText)

        self.connect(self, SIGNAL('copyAvailable(bool)'),
                     self.enable_selection_actions)
예제 #48
0
    def __init__(self, hint, parent):
        HintedTextView.__init__(self, hint, parent)
        self.goto_action = qtutils.add_action(self, 'Launch Editor', self.edit)
        self.goto_action.setShortcut(cmds.Edit.SHORTCUT)

        qtutils.add_action(self, 'Up',
                lambda: self.move(QtGui.QTextCursor.Up),
                Qt.Key_K)

        qtutils.add_action(self, 'Down',
                lambda: self.move(QtGui.QTextCursor.Down),
                Qt.Key_J)

        qtutils.add_action(self, 'Left',
                lambda: self.move(QtGui.QTextCursor.Left),
                Qt.Key_H)

        qtutils.add_action(self, 'Right',
                lambda: self.move(QtGui.QTextCursor.Right),
                Qt.Key_L)

        qtutils.add_action(self, 'StartOfLine',
                lambda: self.move(QtGui.QTextCursor.StartOfLine),
                Qt.Key_0)

        qtutils.add_action(self, 'EndOfLine',
                lambda: self.move(QtGui.QTextCursor.EndOfLine),
                Qt.Key_Dollar)

        qtutils.add_action(self, 'WordLeft',
                lambda: self.move(QtGui.QTextCursor.WordLeft),
                Qt.Key_B)

        qtutils.add_action(self, 'WordRight',
                lambda: self.move(QtGui.QTextCursor.WordRight),
                Qt.Key_W)

        qtutils.add_action(self, 'PageUp',
                lambda: self.page(-self.height()/2),
                'Shift+Space')

        qtutils.add_action(self, 'PageDown',
                lambda: self.page(self.height()/2),
                Qt.Key_Space)
예제 #49
0
    def __init__(self, parent=None):
        Dialog.__init__(self, parent)
        self.setAttribute(Qt.WA_MacMetalStyle)
        self.setWindowTitle(N_('Search'))
        if parent is not None:
            self.setWindowModality(Qt.WindowModal)

        self.input_label = QtGui.QLabel('git grep')
        self.input_label.setFont(diff_font())

        self.input_txt = HintedLineEdit(N_('command-line arguments'), self)
        self.input_txt.enable_hint(True)

        self.regexp_combo = combo = QtGui.QComboBox()
        combo.setToolTip(N_('Choose the "git grep" regular expression mode'))
        items = [N_('Basic Regexp'), N_('Extended Regexp'), N_('Fixed String')]
        combo.addItems(items)
        combo.setCurrentIndex(0)
        combo.setEditable(False)
        combo.setItemData(0,
                N_('Search using a POSIX basic regular expression'),
                Qt.ToolTipRole)
        combo.setItemData(1,
                N_('Search using a POSIX extended regular expression'),
                Qt.ToolTipRole)
        combo.setItemData(2,
                N_('Search for a fixed string'),
                Qt.ToolTipRole)
        combo.setItemData(0, '--basic-regexp', Qt.UserRole)
        combo.setItemData(1, '--extended-regexp', Qt.UserRole)
        combo.setItemData(2, '--fixed-strings', Qt.UserRole)

        self.result_txt = GrepTextView(N_('grep result...'), self)
        self.result_txt.enable_hint(True)

        self.edit_button = QtGui.QPushButton(N_('Edit'))
        self.edit_button.setIcon(qtutils.open_file_icon())
        self.edit_button.setEnabled(False)
        self.edit_button.setShortcut(cmds.Edit.SHORTCUT)

        self.refresh_button = QtGui.QPushButton(N_('Refresh'))
        self.refresh_button.setIcon(qtutils.reload_icon())
        self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh)

        self.shell_checkbox = QtGui.QCheckBox(N_('Shell arguments'))
        self.shell_checkbox.setToolTip(
                N_('Parse arguments using a shell.\n'
                   'Queries with spaces will require "double quotes".'))
        self.shell_checkbox.setChecked(False)

        self.close_button = QtGui.QPushButton(N_('Close'))

        self.input_layout = qtutils.hbox(defs.no_margin, defs.button_spacing,
                                         self.input_label, self.input_txt,
                                         self.regexp_combo)

        self.bottom_layout = qtutils.hbox(defs.no_margin, defs.button_spacing,
                                          self.edit_button, self.refresh_button,
                                          self.shell_checkbox, qtutils.STRETCH,
                                          self.close_button)

        self.mainlayout = qtutils.vbox(defs.margin, defs.no_spacing,
                                       self.input_layout, self.result_txt,
                                       self.bottom_layout)
        self.setLayout(self.mainlayout)

        self.worker_thread = GrepThread(self)
        self.connect(self.worker_thread, SIGNAL('result'), self.process_result)

        self.connect(self.input_txt, SIGNAL('textChanged(QString)'),
                     lambda s: self.search())

        self.connect(self.regexp_combo, SIGNAL('currentIndexChanged(int)'),
                     lambda x: self.search())

        self.connect(self.result_txt, SIGNAL('leave()'),
                     lambda: self.input_txt.setFocus())

        qtutils.add_action(self.input_txt, 'Focus Results', self.focus_results,
                           Qt.Key_Down, Qt.Key_Enter, Qt.Key_Return)
        qtutils.add_action(self, 'Focus Input', self.focus_input, 'Ctrl+L')

        qtutils.connect_button(self.edit_button, self.edit)
        qtutils.connect_button(self.refresh_button, self.search)
        qtutils.connect_toggle(self.shell_checkbox, lambda x: self.search())
        qtutils.connect_button(self.close_button, self.close)
        qtutils.add_close_action(self)

        if not self.restore_state():
            width, height = qtutils.default_size(parent, 666, 420)
            self.resize(width, height)
예제 #50
0
    def __init__(self, hint, parent):
        HintedTextView.__init__(self, hint, parent)
        self.goto_action = qtutils.add_action(self, 'Launch Editor', self.edit)
        self.goto_action.setShortcut(cmds.Edit.SHORTCUT)

        qtutils.add_action(self, 'Up',
                lambda: self.move(QtGui.QTextCursor.Up),
                Qt.Key_K)

        qtutils.add_action(self, 'Down',
                lambda: self.move(QtGui.QTextCursor.Down),
                Qt.Key_J)

        qtutils.add_action(self, 'Left',
                lambda: self.move(QtGui.QTextCursor.Left),
                Qt.Key_H)

        qtutils.add_action(self, 'Right',
                lambda: self.move(QtGui.QTextCursor.Right),
                Qt.Key_L)

        qtutils.add_action(self, 'StartOfLine',
                lambda: self.move(QtGui.QTextCursor.StartOfLine),
                Qt.Key_0)

        qtutils.add_action(self, 'EndOfLine',
                lambda: self.move(QtGui.QTextCursor.EndOfLine),
                Qt.Key_Dollar)

        qtutils.add_action(self, 'WordLeft',
                lambda: self.move(QtGui.QTextCursor.WordLeft),
                Qt.Key_B)

        qtutils.add_action(self, 'WordRight',
                lambda: self.move(QtGui.QTextCursor.WordRight),
                Qt.Key_W)

        qtutils.add_action(self, 'PageUp',
                lambda: self.page(-self.height()//2),
                'Shift+Space')

        qtutils.add_action(self, 'PageDown',
                lambda: self.page(self.height()//2),
                Qt.Key_Space)
예제 #51
0
    def __init__(self, parent):
        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.add_item(N_('Staged'), hide=True)
        self.add_item(N_('Unmerged'), hide=True)
        self.add_item(N_('Modified'), hide=True)
        self.add_item(N_('Untracked'), 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 = qtutils.add_action(self,
                                                    N_('Stage / Unstage'),
                                                    self._process_selection,
                                                    cmds.Stage.SHORTCUT)

        self.revert_unstaged_edits_action = qtutils.add_action(
            self, N_('Revert Unstaged Edits...'),
            cmds.run(cmds.RevertUnstagedEdits),
            cmds.RevertUnstagedEdits.SHORTCUT)
        self.revert_unstaged_edits_action.setIcon(qtutils.icon('undo.svg'))

        self.launch_difftool = qtutils.add_action(
            self, cmds.LaunchDifftool.name(), cmds.run(cmds.LaunchDifftool),
            cmds.LaunchDifftool.SHORTCUT)
        self.launch_difftool.setIcon(qtutils.icon('git.svg'))

        self.launch_editor = qtutils.add_action(self, cmds.LaunchEditor.name(),
                                                cmds.run(cmds.LaunchEditor),
                                                cmds.LaunchEditor.SHORTCUT,
                                                'Return', 'Enter')
        self.launch_editor.setIcon(qtutils.options_icon())

        if not utils.is_win32():
            self.open_using_default_app = qtutils.add_action(
                self, cmds.OpenDefaultApp.name(), self._open_using_default_app,
                cmds.OpenDefaultApp.SHORTCUT)
            self.open_using_default_app.setIcon(qtutils.file_icon())

            self.open_parent_dir = qtutils.add_action(
                self, cmds.OpenParentDir.name(), self._open_parent_dir,
                cmds.OpenParentDir.SHORTCUT)
            self.open_parent_dir.setIcon(qtutils.open_file_icon())

        self.up = qtutils.add_action(self, N_('Move Up'), self.move_up,
                                     Qt.Key_K)

        self.down = qtutils.add_action(self, N_('Move Down'), self.move_down,
                                       Qt.Key_J)

        self.copy_path_action = qtutils.add_action(
            self, N_('Copy Path to Clipboard'), self.copy_path,
            QtGui.QKeySequence.Copy)
        self.copy_path_action.setIcon(qtutils.theme_icon('edit-copy.svg'))

        self.connect(self, SIGNAL('about_to_update'), self._about_to_update)
        self.connect(self, SIGNAL('updated'), self._updated)

        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())
예제 #52
0
    def __init__(self, parent):
        Dialog.__init__(self, parent)
        self.setAttribute(Qt.WA_MacMetalStyle)
        self.setWindowModality(Qt.WindowModal)

        self.input_label = QtGui.QLabel('git grep')
        self.input_label.setFont(diff_font())

        hint = N_('command-line arguments')
        self.input_txt = HintedLineEdit(hint, self)
        self.input_txt.enable_hint(True)

        hint = N_('grep result...')
        self.result_txt = GrepTextView(hint, self)
        self.result_txt.enable_hint(True)

        self.edit_button = QtGui.QPushButton(N_('Edit'))
        self.edit_button.setIcon(qtutils.open_file_icon())
        self.edit_button.setEnabled(False)
        self.edit_button.setShortcut(cmds.Edit.SHORTCUT)

        self.refresh_button = QtGui.QPushButton(N_('Refresh'))
        self.refresh_button.setIcon(qtutils.reload_icon())
        self.refresh_button.setShortcut(QtGui.QKeySequence.Refresh)

        self.shell_checkbox = QtGui.QCheckBox(N_('Shell arguments'))
        self.shell_checkbox.setToolTip(
            N_('Parse arguments using a shell.\n'
               'Queries with spaces will require "double quotes".'))
        self.shell_checkbox.setChecked(False)

        self.close_button = QtGui.QPushButton(N_('Close'))

        self.input_layout = QtGui.QHBoxLayout()
        self.input_layout.setMargin(0)
        self.input_layout.setSpacing(defs.button_spacing)

        self.bottom_layout = QtGui.QHBoxLayout()
        self.bottom_layout.setMargin(0)
        self.bottom_layout.setSpacing(defs.button_spacing)

        self.mainlayout = QtGui.QVBoxLayout()
        self.mainlayout.setMargin(defs.margin)
        self.mainlayout.setSpacing(defs.spacing)

        self.input_layout.addWidget(self.input_label)
        self.input_layout.addWidget(self.input_txt)

        self.bottom_layout.addWidget(self.edit_button)
        self.bottom_layout.addWidget(self.refresh_button)
        self.bottom_layout.addWidget(self.shell_checkbox)
        self.bottom_layout.addStretch()
        self.bottom_layout.addWidget(self.close_button)

        self.mainlayout.addLayout(self.input_layout)
        self.mainlayout.addWidget(self.result_txt)
        self.mainlayout.addLayout(self.bottom_layout)
        self.setLayout(self.mainlayout)

        self.grep_thread = GrepThread(self)

        self.connect(self.grep_thread, SIGNAL('result'), self.process_result)

        self.connect(self.input_txt, SIGNAL('textChanged(QString)'),
                     self.input_txt_changed)

        self.connect(self.result_txt, SIGNAL('leave()'),
                     lambda: self.input_txt.setFocus())

        qtutils.add_action(self.input_txt, 'FocusResults',
                           lambda: self.result_txt.setFocus(), Qt.Key_Down,
                           Qt.Key_Enter, Qt.Key_Return)
        qtutils.connect_button(self.edit_button, self.edit)
        qtutils.connect_button(self.refresh_button, self.search)
        qtutils.connect_button(self.close_button, self.close)
        qtutils.add_close_action(self)

        if not qtutils.apply_state(self):
            self.resize(666, 420)
예제 #53
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())
예제 #54
0
파일: dag.py 프로젝트: PauloVAF/git-cola
    def __init__(self, notifier, parent):
        QtGui.QGraphicsView.__init__(self, parent)
        ViewerMixin.__init__(self)

        highlight = self.palette().color(QtGui.QPalette.Highlight)
        Commit.commit_selected_color = highlight
        Commit.selected_outline_color = highlight.darker()

        self.selection_list = []
        self.notifier = notifier
        self.commits = []
        self.items = {}
        self.saved_matrix = QtGui.QMatrix(self.matrix())

        self.x_offsets = collections.defaultdict(int)

        self.is_panning = False
        self.pressed = False
        self.selecting = False
        self.last_mouse = [0, 0]
        self.zoom = 2
        self.setDragMode(self.RubberBandDrag)

        scene = QtGui.QGraphicsScene(self)
        scene.setItemIndexMethod(QtGui.QGraphicsScene.NoIndex)
        self.setScene(scene)

        self.setRenderHint(QtGui.QPainter.Antialiasing)
        self.setViewportUpdateMode(self.BoundingRectViewportUpdate)
        self.setCacheMode(QtGui.QGraphicsView.CacheBackground)
        self.setTransformationAnchor(QtGui.QGraphicsView.AnchorUnderMouse)
        self.setResizeAnchor(QtGui.QGraphicsView.NoAnchor)
        self.setBackgroundBrush(QtGui.QColor(Qt.white))

        qtutils.add_action(self, N_('Zoom In'), self.zoom_in, Qt.Key_Plus,
                           Qt.Key_Equal)

        qtutils.add_action(self, N_('Zoom Out'), self.zoom_out, Qt.Key_Minus)

        qtutils.add_action(self, N_('Zoom to Fit'), self.zoom_to_fit, Qt.Key_F)

        qtutils.add_action(self, N_('Select Parent'), self.select_parent,
                           'Shift+J')

        qtutils.add_action(self, N_('Select Oldest Parent'),
                           self.select_oldest_parent, Qt.Key_J)

        qtutils.add_action(self, N_('Select Child'), self.select_child,
                           'Shift+K')

        qtutils.add_action(self, N_('Select Newest Child'),
                           self.select_newest_child, Qt.Key_K)

        notifier.add_observer(COMMITS_SELECTED, self.commits_selected)
예제 #55
0
파일: dag.py 프로젝트: PauloVAF/git-cola
    def __init__(self, model, dag, parent=None, settings=None):
        MainWindow.__init__(self, parent)

        self.setAttribute(Qt.WA_MacMetalStyle)
        self.setMinimumSize(420, 420)

        # change when widgets are added/removed
        self.widget_version = 2
        self.model = model
        self.dag = dag
        self.settings = settings

        self.commits = {}
        self.commit_list = []

        self.thread = ReaderThread(dag, self)
        self.revtext = completion.GitLogLineEdit()
        self.maxresults = standard.SpinBox()

        self.zoom_out = qtutils.create_action_button(
            tooltip=N_('Zoom Out'), icon=qtutils.theme_icon('zoom-out.png'))

        self.zoom_in = qtutils.create_action_button(
            tooltip=N_('Zoom In'), icon=qtutils.theme_icon('zoom-in.png'))

        self.zoom_to_fit = qtutils.create_action_button(
            tooltip=N_('Zoom to Fit'),
            icon=qtutils.theme_icon('zoom-fit-best.png'))

        self.notifier = notifier = observable.Observable()
        self.notifier.refs_updated = refs_updated = 'refs_updated'
        self.notifier.add_observer(refs_updated, self.display)

        self.treewidget = CommitTreeWidget(notifier, self)
        self.diffwidget = DiffWidget(notifier, self)
        self.filewidget = FileWidget(notifier, self)
        self.graphview = GraphView(notifier, self)

        self.controls_layout = qtutils.hbox(defs.no_margin, defs.spacing,
                                            self.revtext, self.maxresults)

        self.controls_widget = QtGui.QWidget()
        self.controls_widget.setLayout(self.controls_layout)

        self.log_dock = qtutils.create_dock(N_('Log'), self, stretch=False)
        self.log_dock.setWidget(self.treewidget)
        log_dock_titlebar = self.log_dock.titleBarWidget()
        log_dock_titlebar.add_corner_widget(self.controls_widget)

        self.file_dock = qtutils.create_dock(N_('Files'), self)
        self.file_dock.setWidget(self.filewidget)

        self.diff_dock = qtutils.create_dock(N_('Diff'), self)
        self.diff_dock.setWidget(self.diffwidget)

        self.graph_controls_layout = qtutils.hbox(defs.no_margin,
                                                  defs.button_spacing,
                                                  self.zoom_out, self.zoom_in,
                                                  self.zoom_to_fit)

        self.graph_controls_widget = QtGui.QWidget()
        self.graph_controls_widget.setLayout(self.graph_controls_layout)

        self.graphview_dock = qtutils.create_dock(N_('Graph'), self)
        self.graphview_dock.setWidget(self.graphview)
        graph_titlebar = self.graphview_dock.titleBarWidget()
        graph_titlebar.add_corner_widget(self.graph_controls_widget)

        self.lock_layout_action = qtutils.add_action_bool(
            self, N_('Lock Layout'), self.set_lock_layout, False)

        self.refresh_action = qtutils.add_action(self, N_('Refresh'),
                                                 self.refresh, 'Ctrl+R')

        # Create the application menu
        self.menubar = QtGui.QMenuBar(self)

        # View Menu
        self.view_menu = qtutils.create_menu(N_('View'), self.menubar)
        self.view_menu.addAction(self.refresh_action)

        self.view_menu.addAction(self.log_dock.toggleViewAction())
        self.view_menu.addAction(self.graphview_dock.toggleViewAction())
        self.view_menu.addAction(self.diff_dock.toggleViewAction())
        self.view_menu.addAction(self.file_dock.toggleViewAction())
        self.view_menu.addSeparator()
        self.view_menu.addAction(self.lock_layout_action)

        self.menubar.addAction(self.view_menu.menuAction())
        self.setMenuBar(self.menubar)

        left = Qt.LeftDockWidgetArea
        right = Qt.RightDockWidgetArea
        self.addDockWidget(left, self.log_dock)
        self.addDockWidget(left, self.diff_dock)
        self.addDockWidget(right, self.graphview_dock)
        self.addDockWidget(right, self.file_dock)

        # Update fields affected by model
        self.revtext.setText(dag.ref)
        self.maxresults.setValue(dag.count)
        self.update_window_title()

        # Also re-loads dag.* from the saved state
        if not self.restore_state(settings=settings):
            self.resize_to_desktop()

        qtutils.connect_button(self.zoom_out, self.graphview.zoom_out)
        qtutils.connect_button(self.zoom_in, self.graphview.zoom_in)
        qtutils.connect_button(self.zoom_to_fit, self.graphview.zoom_to_fit)

        self.thread.connect(self.thread, self.thread.commits_ready,
                            self.add_commits)

        self.thread.connect(self.thread, self.thread.done, self.thread_done)

        self.connect(self.treewidget, SIGNAL('diff_commits'),
                     self.diff_commits)

        self.connect(self.graphview, SIGNAL('diff_commits'), self.diff_commits)

        self.connect(self.maxresults, SIGNAL('editingFinished()'),
                     self.display)

        self.connect(self.revtext, SIGNAL('changed()'), self.display)

        self.connect(self.revtext, SIGNAL('textChanged(QString)'),
                     self.text_changed)

        self.connect(self.revtext, SIGNAL('returnPressed()'), self.display)

        # The model is updated in another thread so use
        # signals/slots to bring control back to the main GUI thread
        self.model.add_observer(self.model.message_updated,
                                self.emit_model_updated)

        self.connect(self, SIGNAL('model_updated'), self.model_updated)

        qtutils.add_action(self, 'Focus search field',
                           lambda: self.revtext.setFocus(), 'Ctrl+L')

        qtutils.add_close_action(self)
예제 #56
0
    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=qtutils.add_icon(),
            tooltip=N_('Add patches (+)'))

        self.remove_button = qtutils.create_toolbutton(
            text=N_('Remove'),
            icon=qtutils.remove_icon(),
            tooltip=N_('Remove selected (Delete)'))

        self.apply_button = qtutils.create_button(text=N_('Apply'),
                                                  icon=qtutils.apply_icon())

        self.close_button = qtutils.create_button(text=N_('Close'),
                                                  icon=qtutils.close_icon())

        self.add_action = qtutils.add_action(self, N_('Add'), self.add_files,
                                             Qt.Key_Plus)

        self.remove_action = qtutils.add_action(self, N_('Remove'),
                                                self.tree.remove_selected,
                                                QtGui.QKeySequence.Delete,
                                                Qt.Key_Backspace, Qt.Key_Minus)

        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)