Exemplo n.º 1
0
    def setup_dockwidget_tools_menu(self):
        # Hotkeys for toggling the dock widgets
        dockwidgets = (
            ('Alt+0', self.logdockwidget),
            ('Alt+1', self.commitdockwidget),
            ('Alt+2', self.statusdockwidget),
            ('Alt+3', self.diffdockwidget),
            ('Alt+4', self.actionsdockwidget),
        )
        for shortcut, dockwidget in dockwidgets:
            # Associate the action with the shortcut
            action = dockwidget.toggleViewAction()
            action.setShortcut(shortcut)
            self.tools_menu.addAction(action)
            def showdock(show, dockwidget=dockwidget):
                if show:
                    dockwidget.raise_()
                    dockwidget.widget().setFocus()
                else:
                    self.setFocus()
            self.addAction(action)
            connect_action_bool(action, showdock)

            # Create a new shortcut Shift+<shortcut> that gives focus
            action = QtGui.QAction(self)
            action.setShortcut('Shift+' + shortcut)
            def focusdock(dockwidget=dockwidget, showdock=showdock):
                if dockwidget.toggleViewAction().isChecked():
                    showdock(True)
                else:
                    dockwidget.toggleViewAction().trigger()
            self.addAction(action)
            connect_action(action, focusdock)
Exemplo n.º 2
0
 def _create_action(self, name, tooltip, slot, shortcut):
     """Create an action with a shortcut, tooltip, and callback slot."""
     action = QtGui.QAction(self.tr(name), self)
     action.setStatusTip(self.tr(tooltip))
     if hasattr(Qt, 'WidgetWithChildrenShortcut'):
         action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
     action.setShortcut(shortcut)
     self.addAction(action)
     qtutils.connect_action(action, slot)
     return action
Exemplo n.º 3
0
 def _create_action(self, name, tooltip, slot, shortcut=None):
     """Create an action with a shortcut, tooltip, and callback slot."""
     action = QtGui.QAction(self.tr(name), self)
     action.setStatusTip(self.tr(tooltip))
     if shortcut is not None:
         if hasattr(Qt, 'WidgetWithChildrenShortcut'):
             action.setShortcutContext(Qt.WidgetWithChildrenShortcut)
         action.setShortcut(shortcut)
     self.addAction(action)
     qtutils.connect_action(action, slot)
     return action
Exemplo n.º 4
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)
Exemplo n.º 5
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)

        focus = lambda: focus_dock(self.commitdockwidget)
        qtutils.add_action(self, "Focus Commit Message", focus, hotkeys.FOCUS)
Exemplo n.º 6
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)
            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, showdock=showdock):
                if dockwidget.toggleViewAction().isChecked():
                    showdock(True)
                else:
                    dockwidget.toggleViewAction().trigger()

            self.addAction(toggleview)
            connect_action(toggleview, focusdock)
Exemplo n.º 7
0
    def setup_dockwidget_tools_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),
        )
        for shortcut, dockwidget in dockwidgets:
            # Associate the action with the shortcut
            toggleview = dockwidget.toggleViewAction()
            toggleview.setShortcut(shortcut)
            self.tools_menu.addAction(toggleview)

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

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

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

            def focusdock(dockwidget=dockwidget, showdock=showdock):
                if dockwidget.toggleViewAction().isChecked():
                    showdock(True)
                else:
                    dockwidget.toggleViewAction().trigger()

            self.addAction(toggleview)
            connect_action(toggleview, focusdock)
Exemplo n.º 8
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)
            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, showdock=showdock):
                if dockwidget.toggleViewAction().isChecked():
                    showdock(True)
                else:
                    dockwidget.toggleViewAction().trigger()
            self.addAction(toggleview)
            connect_action(toggleview, focusdock)
Exemplo n.º 9
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False

        self.summary = CommitSummaryLineEdit()
        self.description = CommitMessageTextEdit()

        self.commit_button = create_toolbutton(text='Commit@@verb',
                                               tooltip='Commit staged changes',
                                               icon=save_icon())

        self.actions_menu = QtGui.QMenu()
        self.actions_button = create_toolbutton(icon=options_icon(),
                                                tooltip='Actions...')
        self.actions_button.setMenu(self.actions_menu)
        self.actions_button.setPopupMode(QtGui.QToolButton.InstantPopup)

        # Amend checkbox
        self.signoff_action = self.actions_menu.addAction(tr('Sign Off'))
        self.signoff_action.setToolTip('Sign off on this commit')
        self.signoff_action.setShortcut('Ctrl+i')

        self.commit_action = self.actions_menu.addAction(tr('Commit@@verb'))
        self.commit_action.setToolTip(tr('Commit staged changes'))
        self.commit_action.setShortcut('Ctrl+Return')

        self.actions_menu.addSeparator()
        self.amend_action = self.actions_menu.addAction(tr('Amend Last Commit'))
        self.amend_action.setCheckable(True)

        self.prev_commits_menu = self.actions_menu.addMenu(
                    'Load Previous Commit Message')
        self.connect(self.prev_commits_menu, SIGNAL('aboutToShow()'),
                     self.build_prev_commits_menu)

        self.toplayout = QtGui.QHBoxLayout()
        self.toplayout.setMargin(0)
        self.toplayout.setSpacing(defs.spacing)
        self.toplayout.addWidget(self.actions_button)
        self.toplayout.addWidget(self.summary)
        self.toplayout.addWidget(self.commit_button)

        self.mainlayout = QtGui.QVBoxLayout()
        self.mainlayout.setMargin(defs.margin)
        self.mainlayout.setSpacing(defs.spacing)
        self.mainlayout.addLayout(self.toplayout)
        self.mainlayout.addWidget(self.description)
        self.setLayout(self.mainlayout)

        relay_signal(self, self.description,
                     SIGNAL(signals.load_previous_message))

        connect_button(self.commit_button, self.commit)
        connect_action(self.commit_action, self.commit)
        connect_action(self.signoff_action, emit(self, signals.signoff))

        cola.notifier().connect(signals.amend, self.amend_action.setChecked)

        # Broadcast the amend mode
        connect_action_bool(self.amend_action, emit(self, signals.amend_mode))

        self.model.add_observer(self.model.message_commit_message_changed,
                                self.set_commit_message)

        self.connect(self.summary, SIGNAL('returnPressed()'),
                     self.focus_description)

        self.connect(self.summary, SIGNAL('downPressed()'),
                     self.focus_description)

        self.connect(self.summary, SIGNAL('cursorPosition(int,int)'),
                     self.emit_position)

        self.connect(self.description, SIGNAL('cursorPosition(int,int)'),
                     # description starts at line 2
                     lambda row, col: self.emit_position(row + 2, col))

        # Keep model informed of changes
        self.connect(self.summary, SIGNAL('textChanged(QString)'),
                     self.commit_message_changed)

        self.connect(self.description, SIGNAL('textChanged()'),
                     self.commit_message_changed)

        self.connect(self.description, SIGNAL('shiftTab()'),
                     self.focus_summary)

        self.setFont(diff_font())

        self.summary.enable_hint(True)
        self.description.enable_hint(True)

        self.commit_button.setEnabled(False)
        self.commit_action.setEnabled(False)

        self.setFocusProxy(self.summary)
Exemplo n.º 10
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False
        self.summary_placeholder = u'Commit summary'
        self.description_placeholder = u'Extended description...'

        # Palette for normal text
        self.default_palette = QtGui.QPalette(self.palette())

        # Palette used for the placeholder text
        self.placeholder_palette = pal = QtGui.QPalette(self.palette())
        color = pal.text().color()
        color.setAlpha(128)
        pal.setColor(QtGui.QPalette.Active, QtGui.QPalette.Text, color)
        pal.setColor(QtGui.QPalette.Inactive, QtGui.QPalette.Text, color)

        self.summary = QtGui.QLineEdit()
        self.description = CommitMessageTextEdit()

        self.commit_button = create_toolbutton(text='Commit@@verb',
                                               tooltip='Commit staged changes',
                                               icon=save_icon())

        self.actions_menu = QtGui.QMenu()
        self.actions_button = create_toolbutton(icon=options_icon(),
                                                tooltip='Actions...')
        self.actions_button.setMenu(self.actions_menu)
        self.actions_button.setPopupMode(QtGui.QToolButton.InstantPopup)

        # Amend checkbox
        self.signoff_action = self.actions_menu.addAction(tr('Sign Off'))
        self.signoff_action.setToolTip('Sign off on this commit')
        self.signoff_action.setShortcut('Ctrl+i')

        self.commit_action = self.actions_menu.addAction(tr('Commit@@verb'))
        self.commit_action.setToolTip(tr('Commit staged changes'))
        self.commit_action.setShortcut('Ctrl+m')

        self.actions_menu.addSeparator()
        self.amend_action = self.actions_menu.addAction(tr('Amend Last Commit'))
        self.amend_action.setCheckable(True)

        self.prev_commits_menu = self.actions_menu.addMenu(
                    'Load Previous Commit Message')
        self.connect(self.prev_commits_menu, SIGNAL('aboutToShow()'),
                     self.build_prev_commits_menu)

        self.toplayout = QtGui.QHBoxLayout()
        self.toplayout.setMargin(0)
        self.toplayout.setSpacing(defs.spacing)
        self.toplayout.addWidget(self.actions_button)
        self.toplayout.addWidget(self.summary)
        self.toplayout.addWidget(self.commit_button)

        self.mainlayout = QtGui.QVBoxLayout()
        self.mainlayout.setMargin(defs.margin)
        self.mainlayout.setSpacing(defs.spacing)
        self.mainlayout.addLayout(self.toplayout)
        self.mainlayout.addWidget(self.description)
        self.setLayout(self.mainlayout)

        relay_signal(self, self.description,
                     SIGNAL(signals.load_previous_message))

        connect_button(self.commit_button, self.commit)
        connect_action(self.commit_action, self.commit)
        connect_action(self.signoff_action, emit(self, signals.signoff))

        cola.notifier().connect(signals.amend, self.amend_action.setChecked)

        # Broadcast the amend mode
        connect_action_bool(self.amend_action, emit(self, signals.amend_mode))

        self.model.add_message_observer(self.model.message_commit_message_changed,
                                        self.set_commit_message)

        self.connect(self.summary, SIGNAL('returnPressed()'),
                     self.summary_return_pressed)

        # Keep model informed of changes
        self.connect(self.summary, SIGNAL('textChanged(QString)'),
                     self.commit_message_changed)

        self.connect(self.description, SIGNAL('textChanged()'),
                     self.commit_message_changed)

        self.setFocusProxy(self.summary)
        self.setFont(diff_font())

        self.summary.installEventFilter(self)
        self.description.installEventFilter(self)

        self.enable_placeholder_summary(True)
        self.enable_placeholder_description(True)

        self.commit_button.setEnabled(False)
        self.commit_action.setEnabled(False)