示例#1
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = N_(
                ""
                "Please supply a commit message.\n\n"
                "A good commit message has the following format:\n\n"
                "- First line: Describe in one sentence what you did.\n"
                "- Second line: Blank\n"
                "- Remaining lines: Describe why this change is good.\n"
            )
            Interaction.log(error_msg)
            Interaction.information(N_("Missing Commit Message"), error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = N_("" "No changes to commit.\n\n" "You must stage at least 1 file before you can commit.")
            if self.model.modified:
                informative_text = N_("Would you like to stage and " "commit all modified files?")
                if not qtutils.confirm(
                    N_("Stage and commit?"),
                    error_msg,
                    informative_text,
                    N_("Stage and Commit"),
                    default=True,
                    icon=qtutils.save_icon(),
                ):
                    return
            else:
                Interaction.information(N_("Nothing to commit"), error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (
            amend
            and self.model.is_commit_published()
            and not qtutils.confirm(
                N_("Rewrite Published Commit?"),
                N_(
                    "This commit has already been published.\n"
                    "This operation will rewrite published history.\n"
                    "You probably don't want to do this."
                ),
                N_("Amend the published commit?"),
                N_("Amend Commit"),
                default=False,
                icon=qtutils.save_icon(),
            )
        ):
            return
        no_verify = self.bypass_commit_hooks_action.isChecked()
        sign = self.sign_action.isChecked()
        status, out, err = cmds.do(cmds.Commit, amend, msg, sign, no_verify=no_verify)
        if status != 0:
            Interaction.critical(N_("Commit failed"), N_('"git commit" returned exit code %s') % (status,), out + err)
示例#2
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = N_(''
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            Interaction.log(error_msg)
            Interaction.information(N_('Missing Commit Message'), error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = N_(''
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = N_('Would you like to stage and '
                                      'commit all modified files?')
                if not qtutils.confirm(
                        N_('Stage and commit?'),
                        error_msg, informative_text,
                        N_('Stage and Commit'),
                        default=True,
                        icon=qtutils.save_icon()):
                    return
            else:
                Interaction.information(N_('Nothing to commit'), error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and
            not qtutils.confirm(
                        N_('Rewrite Published Commit?'),
                        N_('This commit has already been published.\n'
                           'This operation will rewrite published history.\n'
                           'You probably don\'t want to do this.'),
                        N_('Amend the published commit?'),
                        N_('Amend Commit'),
                        default=False, icon=qtutils.save_icon())):
            return
        no_verify = self.bypass_commit_hooks_action.isChecked()
        sign = self.sign_action.isChecked()
        status, out, err = cmds.do(cmds.Commit, amend, msg, sign,
                                   no_verify=no_verify)
        if status != 0:
            Interaction.critical(N_('Commit failed'),
                                 N_('"git commit" returned exit code %s') %
                                    (status,),
                                 out + err)
示例#3
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = tr(
                ''
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            log(1, error_msg)
            cola.notifier().broadcast(signals.information,
                                      'Missing Commit Message', error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = tr(
                ''
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = tr('Would you like to stage and '
                                      'commit all modified files?')
                if not confirm('Stage and commit?',
                               error_msg,
                               informative_text,
                               'Stage and Commit',
                               default=False,
                               icon=save_icon()):
                    return
            else:
                cola.notifier().broadcast(signals.information,
                                          'Nothing to commit', error_msg)
                return
            cola.notifier().broadcast(signals.stage_modified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and
                not confirm('Rewrite Published Commit?',
                            'This commit has already been published.\n'
                            'This operation will rewrite published history.\n'
                            'You probably don\'t want to do this.',
                            'Amend the published commit?',
                            'Amend Commit',
                            default=False,
                            icon=save_icon())):
            return
        # Perform the commit
        cola.notifier().broadcast(signals.commit, amend, msg)
示例#4
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = tr(''
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            log(1, error_msg)
            cola.notifier().broadcast(signals.information,
                                      'Missing Commit Message',
                                      error_msg)
            return

        msg = self.commit_message()

        if not self.model.staged:
            error_msg = tr(''
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = tr('Would you like to stage and '
                                      'commit all modified files?')
                if not confirm('Stage and commit?',
                               error_msg,
                               informative_text,
                               'Stage and Commit',
                               default=False,
                               icon=save_icon()):
                    return
            else:
                cola.notifier().broadcast(signals.information,
                                          'Nothing to commit',
                                          error_msg)
                return
            cola.notifier().broadcast(signals.stage_modified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and
            not confirm('Rewrite Published Commit?',
                        'This commit has already been published.\n'
                        'This operation will rewrite published history.\n'
                        'You probably don\'t want to do this.',
                        'Amend the published commit?',
                        'Amend Commit',
                        default=False, icon=save_icon())):
            return
        # Perform the commit
        cola.notifier().broadcast(signals.commit, amend, msg)
示例#5
0
    def commit(self):
        """Attempt to create a commit from the index and commit message."""
        if not bool(self.summary.value()):
            # Describe a good commit message
            error_msg = N_(''
                'Please supply a commit message.\n\n'
                'A good commit message has the following format:\n\n'
                '- First line: Describe in one sentence what you did.\n'
                '- Second line: Blank\n'
                '- Remaining lines: Describe why this change is good.\n')
            Interaction.log(error_msg)
            Interaction.information(N_('Missing Commit Message'), error_msg)
            return

        msg = self.commit_message(raw=False)

        if not self.model.staged:
            error_msg = N_(''
                'No changes to commit.\n\n'
                'You must stage at least 1 file before you can commit.')
            if self.model.modified:
                informative_text = N_('Would you like to stage and '
                                      'commit all modified files?')
                if not confirm(N_('Stage and commit?'),
                               error_msg,
                               informative_text,
                               N_('Stage and Commit'),
                               default=False,
                               icon=save_icon()):
                    return
            else:
                Interaction.information(N_('Nothing to commit'), error_msg)
                return
            cmds.do(cmds.StageModified)

        # Warn that amending published commits is generally bad
        amend = self.amend_action.isChecked()
        if (amend and self.model.is_commit_published() and
            not confirm(N_('Rewrite Published Commit?'),
                        N_('This commit has already been published.\n'
                           'This operation will rewrite published history.\n'
                           'You probably don\'t want to do this.'),
                        N_('Amend the published commit?'),
                        N_('Amend Commit'),
                        default=False, icon=save_icon())):
            return
        status, output = cmds.do(cmds.Commit, amend, msg)
        if status != 0:
            Interaction.critical(N_('Commit failed'),
                                 N_('"git commit" returned exit code %s') %
                                    (status,),
                                 output)
示例#6
0
    def create_tag(self):
        """Verifies inputs and emits a notifier tag message."""

        revision = self.revision.value()
        tag_name = self.tag_name.value()
        tag_msg = self.tag_msg.value()
        sign_tag = self.sign_tag.isChecked()

        if not revision:
            critical('Missing Revision', 'Please specify a revision to tag.')
            return
        elif not tag_name:
            critical('Missing Name', 'Please specify a name for the new tag.')
            return
        elif (sign_tag and not tag_msg and
                not qtutils.confirm('Missing Tag Message',
                                    'Tag-signing was requested but the tag '
                                    'message is empty.',
                                    'An unsigned, lightweight tag will be '
                                    'created instead.\n'
                                    'Create an unsigned tag?',
                                    'Create Unsigned Tag',
                                    default=False,
                                    icon=qtutils.save_icon())):
            return

        cola.notifier().broadcast(signals.tag, tag_name, revision,
                                  sign=sign_tag, message=tag_msg)
        information('Tag Created', 'Created a new tag named "%s"' % tag_name,
                    details=tag_msg or None)
        self.accept()
示例#7
0
 def create_tag(self):
     """Verifies inputs and emits a notifier tag message."""
     if not self.model.tag_name:
         cola.notifier().broadcast(signals.critical,
                                   'Missing Name',
                                   'You must name the tag.')
         return
     if (self.model.sign_tag and
             not self.model.tag_msg and
             not qtutils.confirm('Missing Tag Message',
                                 'Tag-signing was requested but the tag '
                                 'message is empty.',
                                 'An unsigned, lightweight tag will be '
                                 'created instead.\n'
                                 'Create an unsigned tag?',
                                 'Create Unsigned Tag',
                                 default=False,
                                 icon=qtutils.save_icon())):
         return
     cola.notifier().broadcast(signals.tag,
                               self.model.tag_name,
                               self.model.revision_item,
                               sign=self.model.sign_tag,
                               message=self.model.tag_msg)
     self.view.accept()
示例#8
0
    def __init__(self, parent):
        standard.Dialog.__init__(self, parent=parent)
        self.model = settings.Settings()

        self.resize(494, 238)
        self.setWindowTitle(N_('Bookmarks'))
        if parent is not None:
            self.setWindowModality(Qt.WindowModal)
        self.layt = QtGui.QVBoxLayout(self)
        self.layt.setMargin(defs.margin)
        self.layt.setSpacing(defs.spacing)

        self.bookmarks = QtGui.QListWidget(self)
        self.bookmarks.setAlternatingRowColors(True)
        self.bookmarks.setSelectionMode(QtGui.QAbstractItemView
                                             .ExtendedSelection)

        self.layt.addWidget(self.bookmarks)
        self.button_layout = QtGui.QHBoxLayout()

        self.open_button = QtGui.QPushButton(self)
        self.open_button.setText(N_('Open'))
        self.open_button.setIcon(qtutils.open_icon())
        self.open_button.setEnabled(False)
        self.button_layout.addWidget(self.open_button)

        self.add_button = QtGui.QPushButton(self)
        self.add_button.setText(N_('Add'))
        self.add_button.setIcon(qtutils.icon('add.svg'))
        self.button_layout.addWidget(self.add_button)

        self.delete_button = QtGui.QPushButton(self)
        self.delete_button.setText(N_('Delete'))
        self.delete_button.setIcon(qtutils.discard_icon())
        self.delete_button.setEnabled(False)
        self.button_layout.addWidget(self.delete_button)
        self.button_layout.addStretch()

        self.save_button = QtGui.QPushButton(self)
        self.save_button.setText(N_('Save'))
        self.save_button.setIcon(qtutils.save_icon())
        self.save_button.setEnabled(False)
        self.button_layout.addWidget(self.save_button)

        self.close_button = QtGui.QPushButton(self)
        self.close_button.setText(N_('Close'))
        self.button_layout.addWidget(self.close_button)

        self.layt.addLayout(self.button_layout)

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

        qtutils.connect_button(self.open_button, self.open_repo)
        qtutils.connect_button(self.add_button, self.add)
        qtutils.connect_button(self.delete_button, self.delete)
        qtutils.connect_button(self.save_button, self.save)
        qtutils.connect_button(self.close_button, self.accept)

        self.update_bookmarks()
示例#9
0
    def create_tag(self):
        """Verifies inputs and emits a notifier tag message."""

        revision = self.revision.value()
        tag_name = self.tag_name.value()
        tag_msg = self.tag_msg.value()
        sign_tag = self.sign_tag.isChecked()

        if not revision:
            critical(N_('Missing Revision'),
                     N_('Please specify a revision to tag.'))
            return
        elif not tag_name:
            critical(N_('Missing Name'),
                     N_('Please specify a name for the new tag.'))
            return
        elif (sign_tag and not tag_msg and
              not qtutils.confirm(N_('Missing Tag Message'),
                                  N_('Tag-signing was requested but the tag '
                                     'message is empty.'),
                                  N_('An unsigned, lightweight tag will be '
                                     'created instead.\n'
                                     'Create an unsigned tag?'),
                                  N_('Create Unsigned Tag'),
                                  default=False,
                                  icon=qtutils.save_icon())):
            return

        cmds.do(cmds.Tag, tag_name, revision, sign=sign_tag, message=tag_msg)
        information(N_('Tag Created'),
                    N_('Created a new tag named "%s"') % tag_name,
                    details=tag_msg or None)
        self.accept()
示例#10
0
    def __init__(self, parent):
        standard.Dialog.__init__(self, parent=parent)
        self.settings = Settings()
        self.settings.load()

        self.resize(494, 238)
        self.setWindowTitle(N_('Bookmarks'))
        if parent is not None:
            self.setWindowModality(Qt.WindowModal)
        self.layt = QtGui.QVBoxLayout(self)
        self.layt.setMargin(defs.margin)
        self.layt.setSpacing(defs.spacing)

        self.bookmarks = QtGui.QListWidget(self)
        self.bookmarks.setAlternatingRowColors(True)
        self.bookmarks.setSelectionMode(QtGui.QAbstractItemView
                                             .ExtendedSelection)

        self.layt.addWidget(self.bookmarks)
        self.button_layout = QtGui.QHBoxLayout()

        self.open_button = qtutils.create_button(text=N_('Open'),
                icon=qtutils.open_icon())
        self.open_button.setEnabled(False)
        self.button_layout.addWidget(self.open_button)

        self.add_button = qtutils.create_button(text=N_('Add'),
                icon=qtutils.add_icon())
        self.button_layout.addWidget(self.add_button)

        self.delete_button = QtGui.QPushButton(self)
        self.delete_button.setText(N_('Delete'))
        self.delete_button.setIcon(qtutils.discard_icon())
        self.delete_button.setEnabled(False)
        self.button_layout.addWidget(self.delete_button)
        self.button_layout.addStretch()

        self.save_button = QtGui.QPushButton(self)
        self.save_button.setText(N_('Save'))
        self.save_button.setIcon(qtutils.save_icon())
        self.save_button.setEnabled(False)
        self.button_layout.addWidget(self.save_button)

        self.close_button = QtGui.QPushButton(self)
        self.close_button.setText(N_('Close'))
        self.button_layout.addWidget(self.close_button)

        self.layt.addLayout(self.button_layout)

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

        qtutils.connect_button(self.open_button, self.open_repo)
        qtutils.connect_button(self.add_button, self.add)
        qtutils.connect_button(self.delete_button, self.delete)
        qtutils.connect_button(self.save_button, self.save)
        qtutils.connect_button(self.close_button, self.accept)

        self.update_bookmarks()
示例#11
0
    def __init__(self, parent=None):
        standard.StandardDialog.__init__(self, parent=parent)

        self.setWindowModality(QtCore.Qt.WindowModal)
        self.setWindowTitle(self.tr('Stash'))
        self.resize(600, 200)

        self._label = QtGui.QLabel()
        self._label.setText('<center>Stash List</center>')

        self.stash_list = QtGui.QListWidget(self)

        self.button_apply =\
            self.toolbutton(self.tr('Apply'),
                            self.tr('Apply the selected stash'),
                            qtutils.apply_icon())
        self.button_save =\
            self.toolbutton(self.tr('Save'),
                            self.tr('Save modified state to new stash'),
                            qtutils.save_icon())
        self.button_remove = \
            self.toolbutton(self.tr('Remove'),
                            self.tr('Remove the selected stash'),
                            qtutils.discard_icon())
        self.button_close = \
            self.pushbutton(self.tr('Close'),
                            self.tr('Close'), qtutils.close_icon())

        self.keep_index = QtGui.QCheckBox(self)
        self.keep_index.setText(self.tr('Keep Index'))
        self.keep_index.setChecked(True)

        self.setTabOrder(self.button_save, self.button_apply)
        self.setTabOrder(self.button_apply, self.button_remove)
        self.setTabOrder(self.button_remove, self.keep_index)
        self.setTabOrder(self.keep_index, self.button_close)

        # Arrange layouts
        self._main_layt = QtGui.QVBoxLayout(self)
        self._main_layt.setMargin(6)
        self._main_layt.setSpacing(6)

        self._btn_layt = QtGui.QHBoxLayout()
        self._btn_layt.setMargin(0)
        self._btn_layt.setSpacing(4)

        self._btn_layt.addWidget(self.button_save)
        self._btn_layt.addWidget(self.button_apply)
        self._btn_layt.addWidget(self.button_remove)
        self._btn_layt.addWidget(self.keep_index)
        self._btn_layt.addStretch()
        self._btn_layt.addWidget(self.button_close)

        self._main_layt.addWidget(self._label)
        self._main_layt.addWidget(self.stash_list)
        self._main_layt.addItem(self._btn_layt)
示例#12
0
 def save_archive(self):
     filename = self.filename
     if not filename:
         return
     if core.exists(filename):
         title = N_("Overwrite File?")
         msg = N_('The file "%s" exists and will be overwritten.') % filename
         info_txt = N_('Overwrite "%s"?') % filename
         ok_txt = N_("Overwrite")
         icon = qtutils.save_icon()
         if not qtutils.confirm(title, msg, info_txt, ok_txt, default=False, icon=icon):
             return
     self.accept()
示例#13
0
 def save_archive(self):
     filename = self.filename
     if not filename:
         return
     if os.path.exists(filename):
         title = 'Overwrite File?'
         msg = 'The file "%s" exists and will be overwritten.' % filename
         info_txt = 'Overwrite "%s"?' % filename
         ok_txt = 'Overwrite'
         icon = qtutils.save_icon()
         if not qtutils.confirm(
                 title, msg, info_txt, ok_txt, default=False, icon=icon):
             return
     self.accept()
示例#14
0
文件: archive.py 项目: mwh/git-cola
 def save_archive(self):
     filename = self.filename
     if not filename:
         return
     if os.path.exists(filename):
         title = 'Overwrite File?'
         msg = 'The file "%s" exists and will be overwritten.' % filename
         info_txt = 'Overwrite "%s"?' % filename
         ok_txt = 'Overwrite'
         icon = qtutils.save_icon()
         if not qtutils.confirm(title, msg, info_txt, ok_txt,
                                default=False, icon=icon):
             return
     self.accept()
示例#15
0
    def create_tag(self):
        """Verifies inputs and emits a notifier tag message."""

        revision = self.revision.value()
        tag_name = self.tag_name.value()
        tag_msg = self.tag_msg.value()
        sign_tag = self.sign_tag.isChecked()

        if not revision:
            critical(N_('Missing Revision'),
                     N_('Please specify a revision to tag.'))
            return
        elif not tag_name:
            critical(N_('Missing Name'),
                     N_('Please specify a name for the new tag.'))
            return
        elif (sign_tag and not tag_msg and
                not qtutils.confirm(N_('Missing Tag Message'),
                                    N_('Tag-signing was requested but the tag '
                                       'message is empty.'),
                                    N_('An unsigned, lightweight tag will be '
                                       'created instead.\n'
                                       'Create an unsigned tag?'),
                                    N_('Create Unsigned Tag'),
                                    default=False,
                                    icon=qtutils.save_icon())):
            return

        status, output, err = cmds.do(cmds.Tag, tag_name, revision,
                                      sign=sign_tag, message=tag_msg)

        if status == 0:
            information(N_('Tag Created'),
                        N_('Created a new tag named "%s"') % tag_name,
                        details=tag_msg or None)
            self.accept()
        else:
            critical(N_('Error: could not create tag "%s"') % tag_name,
                    (N_('git tag returned exit code %s') % status) +
                    ((output+err) and ('\n\n' + output + err) or ''))
示例#16
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False
        self.spellcheck_initialized = False

        self._linebreak = None
        self._textwidth = None
        self._tabwidth = None

        # Actions
        self.signoff_action = add_action(self, cmds.SignOff.name(),
                                         cmds.run(cmds.SignOff),
                                         cmds.SignOff.SHORTCUT)
        self.signoff_action.setToolTip(N_('Sign off on this commit'))

        self.commit_action = add_action(self,
                                        N_('Commit@@verb'),
                                        self.commit,
                                        cmds.Commit.SHORTCUT)
        self.commit_action.setToolTip(N_('Commit staged changes'))

        # Widgets
        self.summary = CommitSummaryLineEdit()
        self.summary.extra_actions.append(self.signoff_action)
        self.summary.extra_actions.append(self.commit_action)

        self.description = CommitMessageTextEdit()
        self.description.extra_actions.append(self.signoff_action)
        self.description.extra_actions.append(self.commit_action)

        commit_button_tooltip = N_('Commit staged changes\n'
                                   'Shortcut: Ctrl+Enter')
        self.commit_button = create_toolbutton(text=N_('Commit@@verb'),
                                               tooltip=commit_button_tooltip,
                                               icon=save_icon())

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

        self.actions_menu.addAction(self.signoff_action)
        self.actions_menu.addAction(self.commit_action)
        self.actions_menu.addSeparator()

        # Amend checkbox
        self.amend_action = self.actions_menu.addAction(
                N_('Amend Last Commit'))
        self.amend_action.setCheckable(True)
        self.amend_action.setShortcut(cmds.AmendMode.SHORTCUT)
        self.amend_action.setShortcutContext(Qt.ApplicationShortcut)

        # Spell checker
        self.check_spelling_action = self.actions_menu.addAction(
                N_('Check Spelling'))
        self.check_spelling_action.setCheckable(True)
        self.check_spelling_action.setChecked(False)

        # Line wrapping
        self.actions_menu.addSeparator()
        self.autowrap_action = self.actions_menu.addAction(
                N_('Auto-Wrap Lines'))
        self.autowrap_action.setCheckable(True)
        self.autowrap_action.setChecked(linebreak())

        self.prev_commits_menu = self.actions_menu.addMenu(
                N_('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)

        connect_button(self.commit_button, self.commit)

        notifier = cola.notifier()
        notifier.connect(notifier.AMEND, self.amend_action.setChecked)

        # Broadcast the amend mode
        connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode))
        connect_action_bool(self.check_spelling_action,
                            self.toggle_check_spelling)

        # Handle the one-off autowrapping
        connect_action_bool(self.autowrap_action, self.set_linebreak)

        add_action(self.summary, N_('Move Down'), self.focus_description,
                Qt.Key_Down, Qt.Key_Return, Qt.Key_Enter)

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

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

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

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

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

        self.connect(self.description, SIGNAL('leave()'),
                     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)

        self.set_tabwidth(tabwidth())
        self.set_textwidth(textwidth())
        self.set_linebreak(linebreak())

        # Loading message
        commit_msg = ""
        commit_msg_path = commit_message_path()
        if commit_msg_path:
            commit_msg = utils.slurp(commit_msg_path)
        self.set_commit_message(commit_msg)

        # Allow tab to jump from the summary to the description
        self.setTabOrder(self.summary, self.description)
示例#17
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False

        self._linebreak = None
        self._textwidth = None
        self._tabwidth = None

        # Actions
        self.signoff_action = add_action(self, cmds.SignOff.NAME, cmds.run(cmds.SignOff), cmds.SignOff.SHORTCUT)
        self.signoff_action.setToolTip("Sign off on this commit")

        self.commit_action = add_action(self, "Commit@@verb", self.commit, "Ctrl+Return")
        self.commit_action.setToolTip(tr("Commit staged changes"))

        # Widgets
        self.summary = CommitSummaryLineEdit()
        self.summary.extra_actions.append(self.signoff_action)
        self.summary.extra_actions.append(self.commit_action)

        self.description = CommitMessageTextEdit()
        self.description.extra_actions.append(self.signoff_action)
        self.description.extra_actions.append(self.commit_action)

        commit_button_tooltip = "Commit staged changes\nShortcut: Ctrl+Enter"
        self.commit_button = create_toolbutton(text="Commit@@verb", tooltip=commit_button_tooltip, 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)

        self.actions_menu.addAction(self.signoff_action)
        self.actions_menu.addAction(self.commit_action)
        self.actions_menu.addSeparator()

        # Amend checkbox
        self.amend_action = self.actions_menu.addAction(tr("Amend Last Commit"))
        self.amend_action.setCheckable(True)

        # Line wrapping
        self.actions_menu.addSeparator()
        self.autowrap_action = self.actions_menu.addAction(tr("Auto-Wrap Lines"))
        self.autowrap_action.setCheckable(True)
        self.autowrap_action.setChecked(linebreak())

        self.prev_commits_menu = self.actions_menu.addMenu(tr("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)

        connect_button(self.commit_button, self.commit)

        notifier = cola.notifier()
        notifier.connect(notifier.AMEND, self.amend_action.setChecked)

        # Broadcast the amend mode
        connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode))

        # Handle the one-off autowrapping
        connect_action_bool(self.autowrap_action, self.set_linebreak)

        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)

        self.set_tabwidth(tabwidth())
        self.set_textwidth(textwidth())
        self.set_linebreak(linebreak())

        # Allow tab to jump from the summary to the description
        self.setTabOrder(self.summary, self.description)
示例#18
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False
        self.spellcheck_initialized = False

        self._linebreak = None
        self._textwidth = None
        self._tabwidth = None

        # Actions
        self.signoff_action = qtutils.add_action(self, cmds.SignOff.name(),
                                                 cmds.run(cmds.SignOff),
                                                 cmds.SignOff.SHORTCUT)
        self.signoff_action.setToolTip(N_('Sign off on this commit'))

        self.commit_action = qtutils.add_action(self,
                                                N_('Commit@@verb'),
                                                self.commit,
                                                cmds.Commit.SHORTCUT)
        self.commit_action.setToolTip(N_('Commit staged changes'))

        # Widgets
        self.summary = CommitSummaryLineEdit()
        self.summary.setMinimumHeight(defs.tool_button_height)
        self.summary.extra_actions.append(self.signoff_action)
        self.summary.extra_actions.append(self.commit_action)

        self.description = CommitMessageTextEdit()
        self.description.extra_actions.append(self.signoff_action)
        self.description.extra_actions.append(self.commit_action)

        commit_button_tooltip = N_('Commit staged changes\n'
                                   'Shortcut: Ctrl+Enter')
        self.commit_button = qtutils.create_toolbutton(
                text=N_('Commit@@verb'), tooltip=commit_button_tooltip,
                icon=qtutils.save_icon())

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

        self.actions_menu.addAction(self.signoff_action)
        self.actions_menu.addAction(self.commit_action)
        self.actions_menu.addSeparator()

        # Amend checkbox
        self.amend_action = self.actions_menu.addAction(
                N_('Amend Last Commit'))
        self.amend_action.setCheckable(True)
        self.amend_action.setShortcut(cmds.AmendMode.SHORTCUT)
        self.amend_action.setShortcutContext(Qt.ApplicationShortcut)

        # Bypass hooks
        self.bypass_commit_hooks_action = self.actions_menu.addAction(
                N_('Bypass Commit Hooks'))
        self.bypass_commit_hooks_action.setCheckable(True)
        self.bypass_commit_hooks_action.setChecked(False)

        # Sign commits
        cfg = gitcfg.current()
        self.sign_action = self.actions_menu.addAction(
                N_('Create Signed Commit'))
        self.sign_action.setCheckable(True)
        self.sign_action.setChecked(cfg.get('cola.signcommits', False))

        # Spell checker
        self.check_spelling_action = self.actions_menu.addAction(
                N_('Check Spelling'))
        self.check_spelling_action.setCheckable(True)
        self.check_spelling_action.setChecked(False)

        # Line wrapping
        self.autowrap_action = self.actions_menu.addAction(
                N_('Auto-Wrap Lines'))
        self.autowrap_action.setCheckable(True)
        self.autowrap_action.setChecked(prefs.linebreak())

        # Commit message
        self.actions_menu.addSeparator()
        self.load_commitmsg_menu = self.actions_menu.addMenu(
                N_('Load Previous Commit Message'))
        self.connect(self.load_commitmsg_menu, SIGNAL('aboutToShow()'),
                     self.build_commitmsg_menu)

        self.fixup_commit_menu = self.actions_menu.addMenu(
                N_('Fixup Previous Commit'))
        self.connect(self.fixup_commit_menu, SIGNAL('aboutToShow()'),
                     self.build_fixup_menu)

        self.toplayout = qtutils.hbox(defs.no_margin, defs.spacing,
                                      self.actions_button, self.summary,
                                      self.commit_button)
        self.toplayout.setContentsMargins(defs.margin, defs.no_margin,
                                          defs.no_margin, defs.no_margin)

        self.mainlayout = qtutils.vbox(defs.no_margin, defs.spacing,
                                       self.toplayout, self.description)
        self.setLayout(self.mainlayout)

        qtutils.connect_button(self.commit_button, self.commit)

        # Broadcast the amend mode
        qtutils.connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode))
        qtutils.connect_action_bool(self.check_spelling_action,
                                    self.toggle_check_spelling)

        # Handle the one-off autowrapping
        qtutils.connect_action_bool(self.autowrap_action, self.set_linebreak)

        qtutils.add_action(self.summary, N_('Move Down'),
                           self.focus_description,
                           Qt.Key_Return, Qt.Key_Enter)

        qtutils.add_action(self.summary, N_('Move Down'),
                           self.summary_cursor_down,
                           Qt.Key_Down)

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

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

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

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

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

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

        self.setFont(qtutils.diff_font())

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

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

        self.setFocusProxy(self.summary)

        self.set_tabwidth(prefs.tabwidth())
        self.set_textwidth(prefs.textwidth())
        self.set_linebreak(prefs.linebreak())

        # Loading message
        commit_msg = ''
        commit_msg_path = commit_message_path()
        if commit_msg_path:
            commit_msg = core.read(commit_msg_path)
        self.set_commit_message(commit_msg)

        # Allow tab to jump from the summary to the description
        self.setTabOrder(self.summary, self.description)
示例#19
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)
示例#20
0
    def __init__(self, parent=None):
        MainWindowBase.__init__(self, parent)
        # Default size; this is thrown out when save/restore is used
        self.resize(987, 610)

        # Dockwidget options
        qtcompat.set_common_dock_options(self)

        self.classic_dockable = gitcfg.instance().get('cola.classicdockable')

        if self.classic_dockable:
            self.classicdockwidget = self.create_dock('Cola Classic')
            self.classicwidget = classic.widget(parent=self)
            self.classicdockwidget.setWidget(self.classicwidget)

        # "Actions" widget
        self.actiondockwidget = self.create_dock('Actions')
        self.actiondockwidgetcontents = qt.QFlowLayoutWidget(parent=self)
        layout = self.actiondockwidgetcontents.layout()
        self.rescan_button = qt.create_button('Rescan', layout)
        self.stage_button = qt.create_button('Stage', layout)
        self.unstage_button = qt.create_button('Unstage', layout)
        self.fetch_button = qt.create_button('Fetch...', layout)
        self.push_button = qt.create_button('Push...', layout)
        self.pull_button = qt.create_button('Pull...', layout)
        self.stash_button = qt.create_button('Stash...', layout)
        self.alt_button = qt.create_button('Exit Diff Mode', layout)
        self.alt_button.hide()
        layout.addStretch()
        self.actiondockwidget.setWidget(self.actiondockwidgetcontents)

        # "Repository Status" widget
        self.statusdockwidget = self.create_dock('Repository Status')
        self.statusdockwidget.setWidget(status.StatusWidget(self))

        # "Commit Message Editor" widget
        self.commitdockwidget = self.create_dock('Commit Message Editor')
        self.commitdockwidgetcontents = QtGui.QWidget()

        self.commitdockwidgetlayout = QtGui.QVBoxLayout(self.commitdockwidgetcontents)
        self.commitdockwidgetlayout.setMargin(0)
        self.commitdockwidgetlayout.setSpacing(0)

        self.commitmsg = QtGui.QTextEdit(self.commitdockwidgetcontents)
        self.commitmsg.setMinimumSize(QtCore.QSize(1, 1))
        policy = QtGui.QSizePolicy(QtGui.QSizePolicy.Minimum,
                                   QtGui.QSizePolicy.Minimum)
        self.commitmsg.setSizePolicy(policy)
        self.commitmsg.setLineWrapMode(QtGui.QTextEdit.NoWrap)
        self.commitmsg.setAcceptRichText(False)

        self.commit_ctrls_layt = QtGui.QHBoxLayout()
        self.commit_ctrls_layt.setSpacing(4)
        self.commit_ctrls_layt.setMargin(4)

        # Sign off and commit buttons
        self.signoff_button = qt.create_toolbutton(self,
                                                   text='Sign Off',
                                                   tooltip='Sign off on this commit',
                                                   icon=qtutils.apply_icon())

        self.commit_button = qt.create_toolbutton(self,
                                                  text='Commit@@verb',
                                                  tooltip='Commit staged changes',
                                                  icon=qtutils.save_icon())
        # Position display
        self.position_label = QtGui.QLabel(self.actiondockwidgetcontents)
        self.position_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)

        # Amend checkbox
        self.amend_checkbox = QtGui.QCheckBox(self.commitdockwidgetcontents)
        self.amend_checkbox.setText(tr('Amend Last Commit'))

        self.commit_ctrls_layt.addWidget(self.signoff_button)
        self.commit_ctrls_layt.addWidget(self.commit_button)
        self.commit_ctrls_layt.addWidget(self.position_label)
        self.commit_ctrls_layt.addStretch()
        self.commit_ctrls_layt.addWidget(self.amend_checkbox)

        self.commitdockwidgetlayout.addWidget(self.commitmsg)
        self.commitdockwidgetlayout.addLayout(self.commit_ctrls_layt)

        self.commitdockwidget.setWidget(self.commitdockwidgetcontents)

        # "Command Output" widget
        logwidget = qtutils.logger()
        self.logdockwidget = self.create_dock('Command Output')
        self.logdockwidget.setWidget(logwidget)

        # "Diff Viewer" widget
        self.diffdockwidget = self.create_dock('Diff Viewer')
        self.diffdockwidgetcontents = QtGui.QWidget()
        self.diffdockwidgetlayout = QtGui.QVBoxLayout(self.diffdockwidgetcontents)
        self.diffdockwidgetlayout.setMargin(0)

        self.display_text = QtGui.QTextEdit(self.diffdockwidgetcontents)
        self.display_text.setMinimumSize(QtCore.QSize(1, 1))
        self.display_text.setLineWrapMode(QtGui.QTextEdit.NoWrap)
        self.display_text.setReadOnly(True)
        self.display_text.setAcceptRichText(False)
        self.display_text.setCursorWidth(2)
        self.display_text.setTextInteractionFlags(Qt.LinksAccessibleByKeyboard |
                                                  Qt.LinksAccessibleByMouse |
                                                  Qt.TextBrowserInteraction |
                                                  Qt.TextSelectableByKeyboard |
                                                  Qt.TextSelectableByMouse)

        self.diffdockwidgetlayout.addWidget(self.display_text)
        self.diffdockwidget.setWidget(self.diffdockwidgetcontents)

        # All Actions
        self.menu_unstage_selected = self.create_action('Unstage From Commit')
        self.menu_show_diffstat = self.create_action('Diffstat')
        self.menu_stage_modified =\
                self.create_action('Stage Changed Files To Commit')
        self.menu_stage_untracked = self.create_action('Stage All Untracked')
        self.menu_export_patches = self.create_action('Export Patches...')
        self.menu_cut = self.create_action('Cut')
        self.menu_copy = self.create_action('Copy', local=True)
        self.menu_paste = self.create_action('Paste')
        self.menu_select_all = self.create_action('Select All')
        self.menu_options = self.create_action('Preferences')
        self.menu_delete = self.create_action('Delete')
        self.menu_undo = self.create_action('Undo')
        self.menu_redo = self.create_action('Redo')
        self.menu_rescan = self.create_action('Rescan')
        self.menu_cherry_pick = self.create_action('Cherry-Pick...')
        self.menu_unstage_all = self.create_action('Unstage All')
        self.menu_load_commitmsg = self.create_action('Load Commit Message...')
        self.menu_quit = self.create_action('Quit')
        self.menu_search_revision = self.create_action('Revision ID...')
        self.menu_search_path =\
                self.create_action('Commits Touching Path(s)...')
        self.menu_search_revision_range =\
                self.create_action('Revision Range...')
        self.menu_search_date_range = self.create_action('Latest Commits...')
        self.menu_search_diff =\
                self.create_action('Content Introduced in Commit...')
        self.menu_search_author = self.create_action('Commits By Author...')
        self.menu_search_committer =\
                self.create_action('Commits By Committer...')
        self.menu_manage_bookmarks = self.create_action('Bookmarks...')
        self.menu_save_bookmark = self.create_action('Bookmark Current...')
        self.menu_grep = self.create_action('Grep')
        self.menu_merge_local = self.create_action('Merge...')
        self.menu_merge_abort = self.create_action('Abort Merge...')
        self.menu_fetch = self.create_action('Fetch...')
        self.menu_push = self.create_action('Push...')
        self.menu_pull = self.create_action('Pull...')
        self.menu_open_repo = self.create_action('Open...')
        self.menu_stash = self.create_action('Stash...')
        self.menu_diff_branch =\
                self.create_action('Apply Changes From Branch...')
        self.menu_branch_compare = self.create_action('Branches...')
        self.menu_clone_repo = self.create_action('Clone...')
        self.menu_help_docs = self.create_action('Documentation')
        self.menu_commit_compare = self.create_action('Commits...')
        self.menu_visualize_current =\
                self.create_action('Visualize Current Branch...')
        self.menu_visualize_all =\
                self.create_action('Visualize All Branches...')
        self.menu_browse_commits = self.create_action('Browse...')
        self.menu_search_commits = self.create_action('Search...')
        self.menu_browse_branch =\
                self.create_action('Browse Current Branch...')
        self.menu_browse_other_branch =\
                self.create_action('Browse Other Branch...')
        self.menu_load_commitmsg_template =\
                self.create_action('Get Commit Message Template')
        self.menu_commit_compare_file =\
                self.create_action('Commits Touching File...')
        self.menu_help_about = self.create_action('About')
        self.menu_branch_diff = self.create_action('SHA-1...')
        self.menu_diff_expression = self.create_action('Expression...')
        self.menu_create_tag = self.create_action('Create Tag...')
        self.menu_create_branch = self.create_action('Create...')
        self.menu_delete_branch = self.create_action('Delete...')
        self.menu_checkout_branch = self.create_action('Checkout...')
        self.menu_rebase_branch = self.create_action('Rebase...')
        self.menu_branch_review = self.create_action('Review...')
        self.menu_classic = self.create_action('Cola Classic...')
        self.menu_dag = self.create_action('DAG...')

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

        # File Menu
        self.file_menu = self.create_menu('&File', self.menubar)
        self.file_menu.addAction(self.menu_open_repo)
        self.file_menu.addAction(self.menu_clone_repo)
        self.file_menu.addSeparator()
        self.file_menu.addAction(self.menu_rescan)
        self.file_menu.addSeparator()
        self.file_menu.addAction(self.menu_manage_bookmarks)
        self.file_menu.addAction(self.menu_save_bookmark)
        self.file_menu.addSeparator()
        self.file_menu.addAction(self.menu_load_commitmsg)
        self.file_menu.addAction(self.menu_load_commitmsg_template)
        self.file_menu.addSeparator()
        self.file_menu.addAction(self.menu_quit)
        # Add to menubar
        self.menubar.addAction(self.file_menu.menuAction())

        # Edit Menu
        self.edit_menu = self.create_menu('&Edit', self.menubar)
        self.edit_menu.addAction(self.menu_undo)
        self.edit_menu.addAction(self.menu_redo)
        self.edit_menu.addSeparator()
        self.edit_menu.addAction(self.menu_cut)
        self.edit_menu.addAction(self.menu_copy)
        self.edit_menu.addAction(self.menu_paste)
        self.edit_menu.addAction(self.menu_delete)
        self.edit_menu.addSeparator()
        self.edit_menu.addAction(self.menu_select_all)
        self.edit_menu.addSeparator()
        self.edit_menu.addAction(self.menu_options)
        # Add to menubar
        self.menubar.addAction(self.edit_menu.menuAction())

        # Commit Menu
        self.commit_menu = self.create_menu('Co&mmit', self.menubar)
        self.commit_menu.addAction(self.menu_stage_modified)
        self.commit_menu.addAction(self.menu_stage_untracked)
        self.commit_menu.addSeparator()
        self.commit_menu.addAction(self.menu_unstage_all)
        self.commit_menu.addAction(self.menu_unstage_selected)
        self.commit_menu.addSeparator()
        self.commit_menu.addAction(self.menu_browse_commits)
        self.commit_menu.addAction(self.menu_search_commits)
        # Add to menubar
        self.menubar.addAction(self.commit_menu.menuAction())

        # Branch Menu
        self.branch_menu = self.create_menu('B&ranch', self.menubar)
        self.branch_menu.addAction(self.menu_branch_review)
        self.branch_menu.addSeparator()
        self.branch_menu.addAction(self.menu_create_branch)
        self.branch_menu.addAction(self.menu_checkout_branch)
        self.branch_menu.addAction(self.menu_rebase_branch)
        self.branch_menu.addAction(self.menu_delete_branch)
        self.branch_menu.addSeparator()
        self.branch_menu.addAction(self.menu_browse_branch)
        self.branch_menu.addAction(self.menu_browse_other_branch)
        self.branch_menu.addSeparator()
        self.branch_menu.addAction(self.menu_visualize_current)
        self.branch_menu.addAction(self.menu_visualize_all)
        self.branch_menu.addSeparator()
        self.branch_menu.addAction(self.menu_diff_branch)
        # Add to menubar
        self.menubar.addAction(self.branch_menu.menuAction())

        # Actions menu
        self.actions_menu = self.create_menu('Act&ions', self.menubar)
        self.actions_menu.addAction(self.menu_merge_local)
        self.actions_menu.addAction(self.menu_stash)
        self.actions_menu.addSeparator()
        self.actions_menu.addAction(self.menu_fetch)
        self.actions_menu.addAction(self.menu_push)
        self.actions_menu.addAction(self.menu_pull)
        self.actions_menu.addSeparator()
        self.actions_menu.addAction(self.menu_create_tag)
        self.actions_menu.addSeparator()
        self.actions_menu.addAction(self.menu_export_patches)
        self.actions_menu.addAction(self.menu_cherry_pick)
        self.actions_menu.addSeparator()
        self.actions_menu.addAction(self.menu_merge_abort)
        self.actions_menu.addAction(self.menu_grep)
        # Add to menubar
        self.menubar.addAction(self.actions_menu.menuAction())

        # Diff Menu
        self.diff_menu = self.create_menu('&Diff', self.menubar)
        self.diff_menu.addAction(self.menu_branch_diff)
        self.diff_menu.addAction(self.menu_diff_expression)
        self.diff_menu.addSeparator()
        self.diff_menu.addAction(self.menu_branch_compare)
        self.diff_menu.addAction(self.menu_commit_compare)
        self.diff_menu.addAction(self.menu_commit_compare_file)
        self.diff_menu.addSeparator()
        self.diff_menu.addAction(self.menu_show_diffstat)
        # Add to menubar
        self.menubar.addAction(self.diff_menu.menuAction())

        # Tools Menu
        self.tools_menu = self.create_menu('&Tools', self.menubar)
        self.tools_menu.addAction(self.menu_classic)
        self.tools_menu.addAction(self.menu_dag)
        self.tools_menu.addSeparator()
        if self.classic_dockable:
            self.tools_menu.addAction(self.classicdockwidget.toggleViewAction())
        self.tools_menu.addAction(self.diffdockwidget.toggleViewAction())
        self.tools_menu.addAction(self.actiondockwidget.toggleViewAction())
        self.tools_menu.addAction(self.commitdockwidget.toggleViewAction())
        self.tools_menu.addAction(self.statusdockwidget.toggleViewAction())
        self.tools_menu.addAction(self.logdockwidget.toggleViewAction())
        self.menubar.addAction(self.tools_menu.menuAction())

        # Help Menu
        self.help_menu = self.create_menu('&Help', self.menubar)
        self.help_menu.addAction(self.menu_help_docs)
        self.help_menu.addAction(self.menu_help_about)
        # Add to menubar
        self.menubar.addAction(self.help_menu.menuAction())

        # Set main menu
        self.setMenuBar(self.menubar)

        # Shortcuts
        self.menu_show_diffstat.setShortcut(tr('Ctrl+D'))
        self.menu_stage_modified.setShortcut(tr('Alt+A'))
        self.menu_stage_untracked.setShortcut(tr('Alt+U'))
        self.menu_export_patches.setShortcut(tr('Ctrl+E'))
        self.menu_cut.setShortcut(QtGui.QKeySequence.Cut)
        self.menu_copy.setShortcut(QtGui.QKeySequence.Copy)
        self.menu_paste.setShortcut(QtGui.QKeySequence.Paste)
        self.menu_select_all.setShortcut(QtGui.QKeySequence.SelectAll)
        self.menu_options.setShortcut(tr('Ctrl+O'))
        self.menu_delete.setShortcut(tr('Del'))
        self.menu_undo.setShortcut(tr('Ctrl+Z'))
        self.menu_redo.setShortcut(tr('Ctrl+Shift+Z'))
        self.menu_rescan.setShortcut(tr('Ctrl+R'))
        self.menu_cherry_pick.setShortcut(tr('Ctrl+P'))
        self.menu_quit.setShortcut(tr('Ctrl+Q'))
        self.menu_create_branch.setShortcut(tr('Ctrl+B'))
        self.menu_checkout_branch.setShortcut(tr('Alt+B'))
        self.menu_stash.setShortcut(tr('Alt+Shift+S'))
        self.menu_help_docs.setShortcut(tr('F1'))

        # Arrange dock widgets
        top = Qt.TopDockWidgetArea
        bottom = Qt.BottomDockWidgetArea

        self.addDockWidget(top, self.commitdockwidget)
        if self.classic_dockable:
            self.addDockWidget(top, self.classicdockwidget)
        self.addDockWidget(top, self.statusdockwidget)
        self.addDockWidget(top, self.actiondockwidget)
        self.addDockWidget(bottom, self.logdockwidget)
        if self.classic_dockable:
            self.tabifyDockWidget(self.classicdockwidget, self.commitdockwidget)
        self.tabifyDockWidget(self.logdockwidget, self.diffdockwidget)
示例#21
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False
        self.spellcheck_initialized = False

        self._linebreak = None
        self._textwidth = None
        self._tabwidth = None

        # Actions
        self.signoff_action = qtutils.add_action(self, cmds.SignOff.name(),
                                                 cmds.run(cmds.SignOff),
                                                 cmds.SignOff.SHORTCUT)
        self.signoff_action.setToolTip(N_('Sign off on this commit'))

        self.commit_action = qtutils.add_action(self,
                                                N_('Commit@@verb'),
                                                self.commit,
                                                cmds.Commit.SHORTCUT)
        self.commit_action.setToolTip(N_('Commit staged changes'))
        self.clear_action = qtutils.add_action(self, N_('Clear...'), self.clear)

        # Widgets
        self.summary = CommitSummaryLineEdit()
        self.summary.setMinimumHeight(defs.tool_button_height)
        self.summary.extra_actions.append(self.clear_action)
        self.summary.extra_actions.append(None)
        self.summary.extra_actions.append(self.signoff_action)
        self.summary.extra_actions.append(self.commit_action)

        self.description = CommitMessageTextEdit()
        self.description.extra_actions.append(self.clear_action)
        self.description.extra_actions.append(None)
        self.description.extra_actions.append(self.signoff_action)
        self.description.extra_actions.append(self.commit_action)

        commit_button_tooltip = N_('Commit staged changes\n'
                                   'Shortcut: Ctrl+Enter')
        self.commit_button = qtutils.create_toolbutton(
                text=N_('Commit@@verb'), tooltip=commit_button_tooltip,
                icon=qtutils.save_icon())

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

        self.actions_menu.addAction(self.signoff_action)
        self.actions_menu.addAction(self.commit_action)
        self.actions_menu.addSeparator()

        # Amend checkbox
        self.amend_action = self.actions_menu.addAction(
                N_('Amend Last Commit'))
        self.amend_action.setCheckable(True)
        self.amend_action.setShortcut(cmds.AmendMode.SHORTCUT)
        self.amend_action.setShortcutContext(Qt.ApplicationShortcut)

        # Bypass hooks
        self.bypass_commit_hooks_action = self.actions_menu.addAction(
                N_('Bypass Commit Hooks'))
        self.bypass_commit_hooks_action.setCheckable(True)
        self.bypass_commit_hooks_action.setChecked(False)

        # Sign commits
        cfg = gitcfg.current()
        self.sign_action = self.actions_menu.addAction(
                N_('Create Signed Commit'))
        self.sign_action.setCheckable(True)
        self.sign_action.setChecked(cfg.get('cola.signcommits', False))

        # Spell checker
        self.check_spelling_action = self.actions_menu.addAction(
                N_('Check Spelling'))
        self.check_spelling_action.setCheckable(True)
        self.check_spelling_action.setChecked(False)

        # Line wrapping
        self.autowrap_action = self.actions_menu.addAction(
                N_('Auto-Wrap Lines'))
        self.autowrap_action.setCheckable(True)
        self.autowrap_action.setChecked(prefs.linebreak())

        # Commit message
        self.actions_menu.addSeparator()
        self.load_commitmsg_menu = self.actions_menu.addMenu(
                N_('Load Previous Commit Message'))
        self.connect(self.load_commitmsg_menu, SIGNAL('aboutToShow()'),
                     self.build_commitmsg_menu)

        self.fixup_commit_menu = self.actions_menu.addMenu(
                N_('Fixup Previous Commit'))
        self.connect(self.fixup_commit_menu, SIGNAL('aboutToShow()'),
                     self.build_fixup_menu)

        self.toplayout = qtutils.hbox(defs.no_margin, defs.spacing,
                                      self.actions_button, self.summary,
                                      self.commit_button)
        self.toplayout.setContentsMargins(defs.margin, defs.no_margin,
                                          defs.no_margin, defs.no_margin)

        self.mainlayout = qtutils.vbox(defs.no_margin, defs.spacing,
                                       self.toplayout, self.description)
        self.setLayout(self.mainlayout)

        qtutils.connect_button(self.commit_button, self.commit)

        # Broadcast the amend mode
        qtutils.connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode))
        qtutils.connect_action_bool(self.check_spelling_action,
                                    self.toggle_check_spelling)

        # Handle the one-off autowrapping
        qtutils.connect_action_bool(self.autowrap_action, self.set_linebreak)

        qtutils.add_action(self.summary, N_('Move Down'),
                           self.focus_description,
                           Qt.Key_Return, Qt.Key_Enter)

        qtutils.add_action(self.summary, N_('Move Down'),
                           self.summary_cursor_down,
                           Qt.Key_Down)

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

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

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

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

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

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

        self.setFont(qtutils.diff_font())

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

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

        self.setFocusProxy(self.summary)

        self.set_tabwidth(prefs.tabwidth())
        self.set_textwidth(prefs.textwidth())
        self.set_linebreak(prefs.linebreak())

        # Loading message
        commit_msg = ''
        commit_msg_path = commit_message_path()
        if commit_msg_path:
            commit_msg = core.read(commit_msg_path)
        self.set_commit_message(commit_msg)

        # Allow tab to jump from the summary to the description
        self.setTabOrder(self.summary, self.description)
示例#22
0
    def __init__(self, model, parent=None):
        Dialog.__init__(self, parent=parent)
        self.setAttribute(QtCore.Qt.WA_MacMetalStyle)
        self.model = model
        self.stashes = []
        self.revids = []
        self.names = []

        self.setWindowModality(QtCore.Qt.WindowModal)
        self.setWindowTitle(N_('Stash'))
        if parent:
            self.resize(parent.width(), 420)
        else:
            self.resize(700, 420)

        self.stash_list = QtGui.QListWidget(self)
        self.stash_text = DiffTextEdit(self)

        self.button_apply =\
            self.toolbutton(N_('Apply'),
                            N_('Apply the selected stash'),
                            qtutils.apply_icon())
        self.button_save =\
            self.toolbutton(N_('Save'),
                            N_('Save modified state to new stash'),
                            qtutils.save_icon())
        self.button_drop = \
            self.toolbutton(N_('Drop'),
                            N_('Drop the selected stash'),
                            qtutils.discard_icon())
        self.button_close = \
            self.pushbutton(N_('Close'),
                            N_('Close'), qtutils.close_icon())

        self.keep_index = QtGui.QCheckBox(self)
        self.keep_index.setText(N_('Keep Index'))
        self.keep_index.setChecked(True)

        # Arrange layouts
        self.main_layt = QtGui.QVBoxLayout()
        self.main_layt.setMargin(defs.margin)
        self.main_layt.setSpacing(defs.spacing)

        self.btn_layt = QtGui.QHBoxLayout()
        self.btn_layt.setMargin(0)
        self.btn_layt.setSpacing(defs.spacing)

        self.splitter = QtGui.QSplitter()
        self.splitter.setHandleWidth(defs.handle_width)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setChildrenCollapsible(True)
        self.splitter.setStretchFactor(0, 1)
        self.splitter.setStretchFactor(1, 1)
        self.splitter.insertWidget(0, self.stash_list)
        self.splitter.insertWidget(1, self.stash_text)

        self.btn_layt.addWidget(self.button_save)
        self.btn_layt.addWidget(self.button_apply)
        self.btn_layt.addWidget(self.button_drop)
        self.btn_layt.addWidget(self.keep_index)
        self.btn_layt.addStretch()
        self.btn_layt.addWidget(self.button_close)

        self.main_layt.addWidget(self.splitter)
        self.main_layt.addLayout(self.btn_layt)
        self.setLayout(self.main_layt)

        self.splitter.setSizes([self.width() / 3, self.width() * 2 / 3])

        self.update_from_model()
        self.update_actions()

        self.setTabOrder(self.button_save, self.button_apply)
        self.setTabOrder(self.button_apply, self.button_drop)
        self.setTabOrder(self.button_drop, self.keep_index)
        self.setTabOrder(self.keep_index, self.button_close)

        self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'),
                     self.item_selected)

        qtutils.connect_button(self.button_apply, self.stash_apply)
        qtutils.connect_button(self.button_save, self.stash_save)
        qtutils.connect_button(self.button_drop, self.stash_drop)
        qtutils.connect_button(self.button_close, self.close)
示例#23
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self._layt = QtGui.QVBoxLayout()
        self._layt.setMargin(0)
        self._layt.setSpacing(0)

        self.commitmsg = CommitMessageTextEdit(model, self)
        self.commitmsg.setFont(diff_font())

        self._ctrls_layt = QtGui.QHBoxLayout()
        self._ctrls_layt.setSpacing(4)
        self._ctrls_layt.setMargin(4)

        # Sign off and commit buttons
        self.signoff_button = create_toolbutton(self,
                                                text='Sign Off',
                                                tooltip='Sign off on this commit',
                                                icon=apply_icon())

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

        # Position display
        self.position_label = QtGui.QLabel()
        self.position_label.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)

        # Amend checkbox
        self.amend_checkbox = QtGui.QCheckBox()
        self.amend_checkbox.setText(tr('Amend Last Commit'))

        self._ctrls_layt.addWidget(self.signoff_button)
        self._ctrls_layt.addWidget(self.commit_button)
        self._ctrls_layt.addWidget(self.position_label)
        self._ctrls_layt.addStretch()
        self._ctrls_layt.addWidget(self.amend_checkbox)

        self._layt.addWidget(self.commitmsg)
        self._layt.addLayout(self._ctrls_layt)
        self.setLayout(self._layt)

        relay_signal(self, self.commitmsg,
                     SIGNAL(signals.load_previous_message))
        connect_button(self.commit_button, self.commit)

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

        # Broadcast the amend mode
        self.connect(self.amend_checkbox,
                     SIGNAL('toggled(bool)'), emit(self, signals.amend_mode))
        self.connect(self.signoff_button,
                     SIGNAL('clicked()'), emit(self, signals.signoff))

        # Display the current column
        self.connect(self.commitmsg, SIGNAL('cursorPositionChanged()'),
                     self.show_cursor_position)

        # Initialize the GUI to show 'Column: 00'
        self.show_cursor_position()
示例#24
0
    def __init__(self, model, parent=None):
        Dialog.__init__(self, parent=parent)
        self.model = model
        self.stashes = []
        self.revids = []
        self.names = []

        self.setWindowTitle(N_('Stash'))
        self.setAttribute(QtCore.Qt.WA_MacMetalStyle)
        if parent is not None:
            self.setWindowModality(QtCore.Qt.WindowModal)
            self.resize(parent.width(), 420)
        else:
            self.resize(700, 420)

        self.stash_list = QtGui.QListWidget(self)
        self.stash_text = DiffTextEdit(self)

        self.button_apply =\
            self.toolbutton(N_('Apply'),
                            N_('Apply the selected stash'),
                            qtutils.apply_icon())
        self.button_save =\
            self.toolbutton(N_('Save'),
                            N_('Save modified state to new stash'),
                            qtutils.save_icon())
        self.button_drop = \
            self.toolbutton(N_('Drop'),
                            N_('Drop the selected stash'),
                            qtutils.discard_icon())
        self.button_close = \
            self.pushbutton(N_('Close'),
                            N_('Close'), qtutils.close_icon())

        self.keep_index = QtGui.QCheckBox(self)
        self.keep_index.setText(N_('Keep Index'))
        self.keep_index.setChecked(True)

        # Arrange layouts
        self.splitter = qtutils.splitter(Qt.Horizontal, self.stash_list,
                                         self.stash_text)

        self.btn_layt = qtutils.hbox(defs.no_margin, defs.spacing,
                                     self.button_save, self.button_apply,
                                     self.button_drop, self.keep_index,
                                     qtutils.STRETCH, self.button_close)

        self.main_layt = qtutils.vbox(defs.margin, defs.spacing, self.splitter,
                                      self.btn_layt)
        self.setLayout(self.main_layt)

        self.splitter.setSizes([self.width() // 3, self.width() * 2 // 3])

        self.update_from_model()
        self.update_actions()

        self.setTabOrder(self.button_save, self.button_apply)
        self.setTabOrder(self.button_apply, self.button_drop)
        self.setTabOrder(self.button_drop, self.keep_index)
        self.setTabOrder(self.keep_index, self.button_close)

        self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'),
                     self.item_selected)

        qtutils.connect_button(self.button_apply, self.stash_apply)
        qtutils.connect_button(self.button_save, self.stash_save)
        qtutils.connect_button(self.button_drop, self.stash_drop)
        qtutils.connect_button(self.button_close, self.close)
示例#25
0
    def __init__(self, model, parent):
        QtGui.QWidget.__init__(self, parent)

        self.model = model
        self.notifying = False

        self._linebreak = None
        self._textwidth = None
        self._tabwidth = None

        # Actions
        self.signoff_action = add_action(self, cmds.SignOff.NAME,
                                         cmds.run(cmds.SignOff),
                                         cmds.SignOff.SHORTCUT)
        self.signoff_action.setToolTip('Sign off on this commit')

        self.commit_action = add_action(self, 'Commit@@verb', self.commit,
                                        'Ctrl+Return')
        self.commit_action.setToolTip(tr('Commit staged changes'))

        # Widgets
        self.summary = CommitSummaryLineEdit()
        self.summary.extra_actions.append(self.signoff_action)
        self.summary.extra_actions.append(self.commit_action)

        self.description = CommitMessageTextEdit()
        self.description.extra_actions.append(self.signoff_action)
        self.description.extra_actions.append(self.commit_action)

        commit_button_tooltip = 'Commit staged changes\nShortcut: Ctrl+Enter'
        self.commit_button = create_toolbutton(text='Commit@@verb',
                                               tooltip=commit_button_tooltip,
                                               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)

        self.actions_menu.addAction(self.signoff_action)
        self.actions_menu.addAction(self.commit_action)
        self.actions_menu.addSeparator()

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

        # Line wrapping
        self.actions_menu.addSeparator()
        self.autowrap_action = self.actions_menu.addAction(
            tr('Auto-Wrap Lines'))
        self.autowrap_action.setCheckable(True)
        self.autowrap_action.setChecked(linebreak())

        self.prev_commits_menu = self.actions_menu.addMenu(
            tr('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)

        connect_button(self.commit_button, self.commit)

        notifier = cola.notifier()
        notifier.connect(notifier.AMEND, self.amend_action.setChecked)

        # Broadcast the amend mode
        connect_action_bool(self.amend_action, cmds.run(cmds.AmendMode))

        # Handle the one-off autowrapping
        connect_action_bool(self.autowrap_action, self.set_linebreak)

        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)

        self.set_tabwidth(tabwidth())
        self.set_textwidth(textwidth())
        self.set_linebreak(linebreak())

        # Allow tab to jump from the summary to the description
        self.setTabOrder(self.summary, self.description)
示例#26
0
文件: stash.py 项目: jmdcal/git-cola
    def __init__(self, model, parent=None):
        Dialog.__init__(self, parent=parent)
        self.model = model
        self.stashes = []
        self.revids = []
        self.names = []

        self.setWindowTitle(N_('Stash'))
        self.setAttribute(QtCore.Qt.WA_MacMetalStyle)
        if parent is not None:
            self.setWindowModality(QtCore.Qt.WindowModal)
            self.resize(parent.width(), 420)
        else:
            self.resize(700, 420)

        self.stash_list = QtGui.QListWidget(self)
        self.stash_text = DiffTextEdit(self)

        self.button_apply =\
            self.toolbutton(N_('Apply'),
                            N_('Apply the selected stash'),
                            qtutils.apply_icon())
        self.button_save =\
            self.toolbutton(N_('Save'),
                            N_('Save modified state to new stash'),
                            qtutils.save_icon())
        self.button_drop = \
            self.toolbutton(N_('Drop'),
                            N_('Drop the selected stash'),
                            qtutils.discard_icon())
        self.button_close = \
            self.pushbutton(N_('Close'),
                            N_('Close'), qtutils.close_icon())

        self.keep_index = QtGui.QCheckBox(self)
        self.keep_index.setText(N_('Keep Index'))
        self.keep_index.setChecked(True)

        # Arrange layouts
        self.main_layt = QtGui.QVBoxLayout()
        self.main_layt.setMargin(defs.margin)
        self.main_layt.setSpacing(defs.spacing)

        self.btn_layt = QtGui.QHBoxLayout()
        self.btn_layt.setMargin(defs.no_margin)
        self.btn_layt.setSpacing(defs.spacing)

        self.splitter = QtGui.QSplitter()
        self.splitter.setHandleWidth(defs.handle_width)
        self.splitter.setOrientation(QtCore.Qt.Horizontal)
        self.splitter.setChildrenCollapsible(True)
        self.splitter.setStretchFactor(0, 1)
        self.splitter.setStretchFactor(1, 1)
        self.splitter.insertWidget(0, self.stash_list)
        self.splitter.insertWidget(1, self.stash_text)

        self.btn_layt.addWidget(self.button_save)
        self.btn_layt.addWidget(self.button_apply)
        self.btn_layt.addWidget(self.button_drop)
        self.btn_layt.addWidget(self.keep_index)
        self.btn_layt.addStretch()
        self.btn_layt.addWidget(self.button_close)

        self.main_layt.addWidget(self.splitter)
        self.main_layt.addLayout(self.btn_layt)
        self.setLayout(self.main_layt)

        self.splitter.setSizes([self.width()//3, self.width()*2//3])

        self.update_from_model()
        self.update_actions()

        self.setTabOrder(self.button_save, self.button_apply)
        self.setTabOrder(self.button_apply, self.button_drop)
        self.setTabOrder(self.button_drop, self.keep_index)
        self.setTabOrder(self.keep_index, self.button_close)

        self.connect(self.stash_list, SIGNAL('itemSelectionChanged()'),
                     self.item_selected)

        qtutils.connect_button(self.button_apply, self.stash_apply)
        qtutils.connect_button(self.button_save, self.stash_save)
        qtutils.connect_button(self.button_drop, self.stash_drop)
        qtutils.connect_button(self.button_close, self.close)
示例#27
0
文件: commitmsg.py 项目: mwh/git-cola
    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)