예제 #1
0
    def __init__(self, branch, ui_mode=None, immediate=False):

        super(QBzrUnbindDialog, self).__init__(gettext("Unbind branch"),
                                               name="unbind",
                                               default_size=(200, 200),
                                               ui_mode=ui_mode,
                                               dialog=True,
                                               parent=None,
                                               hide_progress=False,
                                               immediate=immediate)
        self.branch = branch

        gbBind = QtWidgets.QGroupBox(gettext("Unbind"), self)
        bind_box = QtWidgets.QFormLayout(gbBind)
        info_label = QtWidgets.QLabel(url_for_display(branch.base))
        bind_box.addRow(gettext("Branch:"), info_label)

        self.currbound = branch.get_bound_location()
        if self.currbound != None:
            curr_label = QtWidgets.QLabel(url_for_display(self.currbound))
            bind_box.addRow(gettext("Bound to:"), curr_label)

        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(gbBind)
        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)
예제 #2
0
    def __init__(self, branch, location=None, ui_mode = None):
        self.branch = branch
        super(QBzrBindDialog, self).__init__(
                                  gettext("Bind branch"),
                                  name = "bind",
                                  default_size = (400, 400),
                                  ui_mode = ui_mode,
                                  dialog = True,
                                  parent = None,
                                  hide_progress=False,
                                  )

        # Display information fields
        gbBind = QtWidgets.QGroupBox(gettext("Bind"), self)
        bind_box = QtWidgets.QFormLayout(gbBind)
        bind_box.addRow(gettext("Branch location:"),
            QtWidgets.QLabel(url_for_display(branch.base)))
        self.currbound = branch.get_bound_location()
        if self.currbound != None:
            bind_box.addRow(gettext("Currently bound to:"),
                QtWidgets.QLabel(url_for_display(self.currbound)))

        # Build the "Bind to" widgets
        branch_label = QtWidgets.QLabel(gettext("Bind to:"))
        branch_combo = QtWidgets.QComboBox()   
        branch_combo.setEditable(True)
        self.branch_combo = branch_combo
        browse_button = QtWidgets.QPushButton(gettext("Browse"))
        browse_button.clicked[bool].connect(self.browse_clicked)

        # Add some useful values into the combo box. If a location was given,
        # default to it. If an old bound location exists, suggest it.
        # Otherwise suggest the parent branch, if any.
        suggestions = []
        if location:
            suggestions.append(osutils.abspath(location))
        self._maybe_add_suggestion(suggestions, branch.get_old_bound_location())
        self._maybe_add_suggestion(suggestions, branch.get_parent())
        self._maybe_add_suggestion(suggestions, branch.get_push_location())
        if suggestions:
            branch_combo.addItems(suggestions)

        # Build the "Bind to" row/panel
        bind_hbox = QtWidgets.QHBoxLayout()
        bind_hbox.addWidget(branch_label)
        bind_hbox.addWidget(branch_combo)
        bind_hbox.addWidget(browse_button)
        bind_hbox.setStretchFactor(branch_label,0)
        bind_hbox.setStretchFactor(branch_combo,1)
        bind_hbox.setStretchFactor(browse_button,0)
        bind_box.addRow(bind_hbox)

        # Put the form together
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(gbBind)
        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)

        branch_combo.setFocus()
예제 #3
0
 def test_url_for_display(self):
     self.assertEqual(None, util.url_for_display(None))
     self.assertEqual('', util.url_for_display(''))
     self.assertEqual('http://bazaar.launchpad.net/~qbrz-dev/qbrz/trunk',
         util.url_for_display('http://bazaar.launchpad.net/%7Eqbrz-dev/qbrz/trunk'))
     if sys.platform == 'win32':
         self.assertEqual('C:/work/qbrz/',
             util.url_for_display('file:///C:/work/qbrz/'))
     else:
         self.assertEqual('/home/work/qbrz/',
             util.url_for_display('file:///home/work/qbrz/'))
예제 #4
0
파일: commit.py 프로젝트: breezy-team/qbrz
 def update_branch_groupbox(self):
     if not self.local_checkbox.isChecked():
         # commit to master branch selected
         loc = url_for_display(self.tree.branch.get_bound_location())
         desc = gettext("A commit will be made directly to "
                        "the master branch, keeping the local "
                        "and master branches in sync.")
     else:
         # local commit selected
         loc = url_for_display(self.tree.branch.base)
         desc = gettext("A local commit to the branch will be performed. "
                        "The master branch will not be updated until "
                        "a non-local commit is made.")
     # update GUI
     self.branch_location.setText(loc)
     self.commit_type_description.setText(desc)
예제 #5
0
    def __init__(self, branch, ui_mode=True, parent=None):
        self.branch = branch
        super(UpdateCheckoutWindow, self).__init__(
                                  name = self.NAME,
                                  ui_mode = ui_mode,
                                  parent = parent)

        self.ui = Ui_UpdateCheckoutForm()
        self.ui.setupUi(self)
        # and add the subprocess widgets.
        for w in self.make_default_layout_widgets():
            self.layout().addWidget(w)
        # nuke existing items in the combo.
        while self.ui.location.count():
            self.ui.location.removeItem(0)
        # We don't look at 'related' branches etc when doing a 'pull' from
        # a checkout - the default is empty, but saved locations are used.
        fill_combo_with(self.ui.location,
                        '',
                        iter_saved_pull_locations())
        # and the directory picker for the pull location.
        hookup_directory_picker(self,
                                self.ui.location_picker,
                                self.ui.location,
                                DIRECTORYPICKER_SOURCE)

        # Our 'label' object is ready to have the bound location specified.
        loc = url_for_display(self.branch.get_bound_location())
        self.ui.label.setText(str(self.ui.label.text()) % loc)
        self.ui.but_pull.setChecked(False)
예제 #6
0
파일: switch.py 프로젝트: breezy-team/qbrz
 def _load_branch_names(self):
     branch_combo = self.branch_combo
     repo = self.branch.controldir.find_repository()
     if repo is not None:
         if getattr(repo, "iter_branches", None):
             for br in repo.iter_branches():
                 self.processEvents()
                 branch_combo.addItem(url_for_display(br.base))
예제 #7
0
파일: info.py 프로젝트: breezy-team/qbrz
 def _set_location(self, location):
     if not location:
         self.ui.local_location.setText('-')
         return
     if location != '.':
         self.ui.local_location.setText(url_for_display(location))
         return
     self.ui.local_location.setText(osutils.abspath(location))
예제 #8
0
파일: tag.py 프로젝트: breezy-team/qbrz
 def set_branch(self, branch):
     self.branch = branch
     self.tags = branch.tags.get_tag_dict()
     self.revno_map = None
     # update ui
     self.ui.branch_location.setText(url_for_display(branch.base))
     self.ui.cb_tag.clear()
     self.ui.cb_tag.addItems(sorted(list(self.tags.keys()), key=str.lower))
     self.ui.cb_tag.setEditText("")
     self.ui.cb_tag.setCurrentIndex(-1)
예제 #9
0
    def __init__(self,
                 location,
                 dialog=True,
                 ui_mode=True,
                 parent=None,
                 local=None,
                 message=None):
        super(QBzrUncommitWindow, self).__init__(
            gettext("Uncommit"),
            name="uncommit",
            default_size=(400, 400),
            ui_mode=ui_mode,
            dialog=dialog,
            parent=parent,
            hide_progress=True,
        )
        self.tree, self.branch = controldir.ControlDir.open_tree_or_branch(
            location)

        # Display the branch
        branch_label = QtWidgets.QLabel(
            gettext("Branch: %s") % url_for_display(self.branch.base))

        # Display the revision selection section. We nearly always
        # want to just uncommit the last revision (to tweak the
        # commit message say) so we make that the default.
        groupbox = QtWidgets.QGroupBox(gettext("Move tip to"), self)
        self.last_radio = QtWidgets.QRadioButton(
            gettext("Parent of current tip revision"))
        self.last_radio.setChecked(QtCore.Qt.Checked)
        self.other_radio = QtWidgets.QRadioButton(gettext("Other revision:"))
        self.other_revision = QtWidgets.QLineEdit()
        other = QtWidgets.QHBoxLayout()
        other.addWidget(self.other_radio)
        other.addWidget(self.other_revision)
        vbox = QtWidgets.QVBoxLayout(groupbox)
        vbox.addWidget(self.last_radio)
        vbox.addLayout(other)

        # If the user starts entering a value in the 'other revision' field,
        # set the matching radio button implicitly
        self.other_revision.textChanged['QString'].connect(
            self.do_other_revision_changed)

        # groupbox gets disabled as we are executing.
        self.subprocessStarted[bool].connect(groupbox.setDisabled)

        # Put the form together
        layout = QtWidgets.QVBoxLayout(self)
        layout.addWidget(branch_label)
        layout.addWidget(groupbox)
        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)
예제 #10
0
    def __init__(self,
                 branch,
                 tree=None,
                 location=None,
                 create_prefix=None,
                 use_existing_dir=None,
                 remember=None,
                 overwrite=None,
                 ui_mode=True,
                 parent=None):

        self.branch = branch
        self.tree = tree
        self._no_strict = None
        super(QBzrPushWindow, self).__init__(name=self.NAME,
                                             ui_mode=ui_mode,
                                             parent=parent)

        self.ui = Ui_PushForm()
        self.setupUi(self.ui)
        # and add the subprocess widgets.
        for w in self.make_default_layout_widgets():
            self.layout().addWidget(w)

        self.default_location = self.branch.get_push_location()
        df = url_for_display(self.default_location
                             or self._suggested_push_location())
        fill_combo_with(self.ui.location, df,
                        iter_branch_related_locations(self.branch))
        if location:
            self.ui.location.setEditText(location)
        else:
            self.ui.location.setFocus()

        if remember:
            self.ui.remember.setCheckState(QtCore.Qt.Checked)
        if overwrite:
            self.ui.overwrite.setCheckState(QtCore.Qt.Checked)
        if create_prefix:
            self.ui.create_prefix.setCheckState(QtCore.Qt.Checked)
        if use_existing_dir:
            self.ui.use_existing_dir.setCheckState(QtCore.Qt.Checked)

        # One directory picker for the push location.
        hookup_directory_picker(self, self.ui.location_picker,
                                self.ui.location, DIRECTORYPICKER_TARGET)
예제 #11
0
    def do_start(self):
        args = []
        submit_branch = str(self.submit_branch_combo.currentText())
        public_branch = str(self.public_branch_combo.currentText())

        if public_branch:
            args.append(public_branch)

        mylocation = url_for_display(self.branch.base)
        args.append("-f")
        args.append(mylocation)

        if self.submit_email_radio.isChecked():
            location = str(self.mailto_edit.text())
            args.append("--mail-to=%s" % location)
        else:
            location = str(self.savefile_edit.text())
            args.append("-o")
            args.append(location)

        if self.remember_check.isChecked():
            args.append("--remember")

        if not self.patch_check.isChecked():
            args.append("--no-patch")

        if not self.bundle_check.isChecked():
            args.append("--no-bundle")

        if str(self.message_edit.text()):
            args.append("--message=%s" % str(self.message_edit.text()))

        revision = str(self.revisions_edit.text())
        if revision == '':
            args.append("--revision=-1")
        else:
            args.append("--revision=%s" % revision)

        self.process_widget.do_start(None, 'send', submit_branch, *args)
예제 #12
0
 def run(self, bug_id, open=False):
     # we import from qbrz.lib.util here because that module
     # has dependency on PyQt4 (see bug #327487)
     from breezy.plugins.qbrz.lib.util import open_browser, url_for_display
     try:
         branch = Branch.open_containing('.')[0]
     except errors.NotBranchError:
         branch = FakeBranchForBugs()
     tokens = bug_id.split(':')
     if len(tokens) != 2:
         raise errors.BzrCommandError(
             "Invalid bug %s. Must be in the form of 'tag:id'." % bug_id)
     tag, tag_bug_id = tokens
     try:
         bug_url = bugtracker.get_bug_url(tag, branch, tag_bug_id)
     except errors.UnknownBugTrackerAbbreviation:
         raise errors.BzrCommandError('Unrecognized bug %s.' % bug_id)
     except errors.MalformedBugIdentifier:
         raise errors.BzrCommandError("Invalid bug identifier for %s." %
                                      bug_id)
     self.outf.write(url_for_display(bug_url) + "\n")
     if open:
         open_browser(bug_url)
예제 #13
0
    def __init__(self, branch, ui_mode=False, parent=None):

        title = "%s: %s" % (gettext("Send"), url_for_display(branch.base))
        super(SendWindow, self).__init__(
            title,
            name="send",
            default_size=(400, 400),
            ui_mode=ui_mode,
            dialog=True,
            parent=parent,
            hide_progress=False,
        )

        self.branch = branch

        gbMergeDirective = QtWidgets.QGroupBox(
            gettext("Merge Directive Options"), self)
        vboxMergeDirective = QtWidgets.QVBoxLayout(gbMergeDirective)
        vboxMergeDirective.addStrut(0)

        submit_hbox = QtWidgets.QHBoxLayout()

        submit_branch_label = QtWidgets.QLabel(gettext("Submit Branch:"))
        submit_branch_combo = QtWidgets.QComboBox()
        submit_branch_combo.setEditable(True)

        submitbranch = branch.get_submit_branch()
        if submitbranch != None:
            submit_branch_combo.addItem(submitbranch)

        self.submit_branch_combo = submit_branch_combo  # to allow access from another function
        browse_submit_button = QtWidgets.QPushButton(gettext("Browse"))
        browse_submit_button.clicked[bool].connect(self.browse_submit_clicked)

        submit_hbox.addWidget(submit_branch_label)
        submit_hbox.addWidget(submit_branch_combo)
        submit_hbox.addWidget(browse_submit_button)

        submit_hbox.setStretchFactor(submit_branch_label, 0)
        submit_hbox.setStretchFactor(submit_branch_combo, 1)
        submit_hbox.setStretchFactor(browse_submit_button, 0)

        vboxMergeDirective.addLayout(submit_hbox)

        public_hbox = QtWidgets.QHBoxLayout()

        public_branch_label = QtWidgets.QLabel(gettext("Public Branch:"))
        public_branch_combo = QtWidgets.QComboBox()
        public_branch_combo.setEditable(True)

        publicbranch = branch.get_public_branch()
        if publicbranch != None:
            public_branch_combo.addItem(publicbranch)

        self.public_branch_combo = public_branch_combo  # to allow access from another function
        browse_public_button = QtWidgets.QPushButton(gettext("Browse"))
        browse_public_button.clicked[bool].connect(self.browse_public_clicked)

        public_hbox.addWidget(public_branch_label)
        public_hbox.addWidget(public_branch_combo)
        public_hbox.addWidget(browse_public_button)

        public_hbox.setStretchFactor(public_branch_label, 0)
        public_hbox.setStretchFactor(public_branch_combo, 1)
        public_hbox.setStretchFactor(browse_public_button, 0)

        vboxMergeDirective.addLayout(public_hbox)

        remember_check = QtWidgets.QCheckBox(
            gettext("Remember these locations as defaults"))
        self.remember_check = remember_check
        vboxMergeDirective.addWidget(remember_check)

        bundle_check = QtWidgets.QCheckBox(
            gettext("Include a bundle in the merge directive"))
        bundle_check.setChecked(True)
        self.bundle_check = bundle_check
        vboxMergeDirective.addWidget(bundle_check)
        patch_check = QtWidgets.QCheckBox(
            gettext("Include a preview patch in the merge directive"))
        patch_check.setChecked(True)
        self.patch_check = patch_check
        vboxMergeDirective.addWidget(patch_check)

        gbAction = QtWidgets.QGroupBox(gettext("Action"), self)
        vboxAction = QtWidgets.QVBoxLayout(gbAction)

        submit_email_radio = QtWidgets.QRadioButton("Send e-mail")
        submit_email_radio.toggle()
        self.submit_email_radio = submit_email_radio
        vboxAction.addWidget(submit_email_radio)

        mailto_hbox = QtWidgets.QHBoxLayout()

        mailto_label = QtWidgets.QLabel(gettext("Address:"))
        mailto_edit = QtWidgets.QLineEdit()
        self.mailto_edit = mailto_edit
        mailto_hbox.insertSpacing(0, 50)
        mailto_hbox.addWidget(mailto_label)
        mailto_hbox.addWidget(mailto_edit)

        vboxAction.addLayout(mailto_hbox)

        message_hbox = QtWidgets.QHBoxLayout()
        message_label = QtWidgets.QLabel(gettext("Message:"))
        message_edit = QtWidgets.QLineEdit()
        self.message_edit = message_edit

        message_hbox.insertSpacing(0, 50)
        message_hbox.addWidget(message_label)
        message_hbox.addWidget(message_edit)

        vboxAction.addLayout(message_hbox)

        save_file_radio = QtWidgets.QRadioButton("Save to file")
        self.save_file_radio = save_file_radio

        vboxAction.addWidget(save_file_radio)

        savefile_hbox = QtWidgets.QHBoxLayout()

        savefile_label = QtWidgets.QLabel(gettext("Filename:"))
        savefile_edit = QtWidgets.QLineEdit()
        self.savefile_edit = savefile_edit  # to allow access from callback function
        savefile_button = QtWidgets.QPushButton(gettext("Browse"))
        savefile_button.clicked[bool].connect(self.savefile_button_clicked)

        savefile_hbox.insertSpacing(0, 50)
        savefile_hbox.addWidget(savefile_label)
        savefile_hbox.addWidget(savefile_edit)
        savefile_hbox.addWidget(savefile_button)

        vboxAction.addLayout(savefile_hbox)

        revisions_hbox = QtWidgets.QHBoxLayout()
        revisions_label = QtWidgets.QLabel(gettext("Revisions:"))
        revisions_edit = QtWidgets.QLineEdit()
        self.revisions_edit = revisions_edit

        revisions_hbox.addWidget(revisions_label)
        revisions_hbox.addWidget(revisions_edit)

        vboxAction.addLayout(revisions_hbox)

        layout = QtWidgets.QVBoxLayout(self)

        self.splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        self.splitter.addWidget(gbAction)
        self.splitter.addWidget(gbMergeDirective)

        self.splitter.addWidget(self.make_default_status_box())

        self.splitter.setStretchFactor(0, 10)
        self.restoreSplitterSizes([150, 150])

        layout.addWidget(self.splitter)
        layout.addWidget(self.buttonbox)
예제 #14
0
 def title_for_location(location):
     if isinstance(location, str):
         return url_for_display(location)
     if isinstance(location, Branch):
         return url_for_display(location.base)
     return str(location)
예제 #15
0
파일: switch.py 프로젝트: breezy-team/qbrz
    def __init__(self, branch, controldir, location, ui_mode = None):

        super(QBzrSwitchWindow, self).__init__(
                                  gettext("Switch"),
                                  name = "switch",
                                  default_size = (400, 400),
                                  ui_mode = ui_mode,
                                  dialog = True,
                                  parent = None,
                                  hide_progress=False,
                                  )

        self.branch = branch

        gbSwitch = QtWidgets.QGroupBox(gettext("Switch checkout"), self)

        switch_box = QtWidgets.QFormLayout(gbSwitch)

        branchbase = None

        boundloc = branch.get_bound_location()
        if boundloc is not None:
            label = gettext("Heavyweight checkout:")
            branchbase = branch.base
        else:
            if controldir.root_transport.base != branch.controldir.root_transport.base:
                label = gettext("Lightweight checkout:")
                boundloc = branch.controldir.root_transport.base
                branchbase = controldir.root_transport.base
            else:
                raise errors.BzrError("This branch is not checkout.")

        switch_box.addRow(label, QtWidgets.QLabel(url_for_display(branchbase)))
        switch_box.addRow(gettext("Checkout of branch:"),
                          QtWidgets.QLabel(url_for_display(boundloc)))
        self.boundloc = url_for_display(boundloc)

        throb_hbox = QtWidgets.QHBoxLayout()

        self.throbber = ThrobberWidget(self)
        throb_hbox.addWidget(self.throbber)
        self.throbber.hide()
        switch_box.addRow(throb_hbox)

        switch_hbox = QtWidgets.QHBoxLayout()

        branch_label = QtWidgets.QLabel(gettext("Switch to branch:"))
        branch_combo = QtWidgets.QComboBox()   
        branch_combo.setEditable(True)

        self.branch_combo = branch_combo

        if location is not None:
            branch_combo.addItem(osutils.abspath(location))
        elif boundloc is not None:
            branch_combo.addItem(url_for_display(boundloc))

        browse_button = QtWidgets.QPushButton(gettext("Browse"))
        browse_button.clicked[bool].connect(self.browse_clicked)

        switch_hbox.addWidget(branch_label)
        switch_hbox.addWidget(branch_combo)
        switch_hbox.addWidget(browse_button)

        switch_hbox.setStretchFactor(branch_label,0)
        switch_hbox.setStretchFactor(branch_combo,1)
        switch_hbox.setStretchFactor(browse_button,0)

        switch_box.addRow(switch_hbox)

        create_branch_box = QtWidgets.QCheckBox(gettext("Create Branch before switching"))
        create_branch_box.setChecked(False)
        switch_box.addRow(create_branch_box)
        self.create_branch_box = create_branch_box

        layout = QtWidgets.QVBoxLayout(self)

        layout.addWidget(gbSwitch)

        layout.addWidget(self.make_default_status_box())
        layout.addWidget(self.buttonbox)
        self.branch_combo.setFocus()
예제 #16
0
파일: commit.py 프로젝트: breezy-team/qbrz
    def __init__(self,
                 tree,
                 selected_list,
                 dialog=True,
                 parent=None,
                 local=None,
                 message=None,
                 ui_mode=True):
        super(CommitWindow, self).__init__(gettext("Commit"),
                                           name="commit",
                                           default_size=(540, 540),
                                           ui_mode=ui_mode,
                                           dialog=dialog,
                                           parent=parent)
        self.tree = tree
        self.ci_data = QBzrCommitData(tree=tree)
        self.ci_data.load()

        self.is_bound = bool(tree.branch.get_bound_location())
        self.has_pending_merges = len(tree.get_parent_ids()) > 1

        if self.has_pending_merges and selected_list:
            raise errors.CannotCommitSelectedFileMerge(selected_list)

        self.windows = []
        self.initial_selected_list = selected_list

        self.process_widget.failed['QString'].connect(self.on_failed)

        self.throbber = ThrobberWidget(self)

        # commit to branch location
        branch_groupbox = QtWidgets.QGroupBox(gettext("Branch"), self)
        branch_layout = QtWidgets.QGridLayout(branch_groupbox)
        self.branch_location = QtWidgets.QLineEdit()
        self.branch_location.setReadOnly(True)
        #
        branch_base = url_for_display(tree.branch.base)
        master_branch = url_for_display(tree.branch.get_bound_location())
        if not master_branch:
            self.branch_location.setText(branch_base)
            branch_layout.addWidget(self.branch_location, 0, 0, 1, 2)
        else:
            self.local_checkbox = QtWidgets.QCheckBox(gettext("&Local commit"))
            self.local_checkbox.setToolTip(
                gettext(
                    "Local commits are not pushed to the master branch until a normal commit is performed"
                ))
            branch_layout.addWidget(self.local_checkbox, 0, 0, 1, 2)
            branch_layout.addWidget(self.branch_location, 1, 0, 1, 2)
            branch_layout.addWidget(QtWidgets.QLabel(gettext('Description:')),
                                    2, 0,
                                    QtCore.Qt.AlignLeft | QtCore.Qt.AlignTop)
            self.commit_type_description = QtWidgets.QLabel()
            self.commit_type_description.setWordWrap(True)
            branch_layout.addWidget(self.commit_type_description, 2, 1)
            branch_layout.setColumnStretch(1, 10)
            self.local_checkbox.stateChanged[int].connect(
                self.update_branch_groupbox)
            if local:
                self.local_checkbox.setChecked(True)
            self.update_branch_groupbox()

        self.not_uptodate_errors = {
            'BoundBranchOutOfDate':
            gettext(
                'Local branch is out of date with master branch.\n'
                'To commit to master branch, update the local branch.\n'
                'You can also pass select local to commit to continue working disconnected.'
            ),
            'OutOfDateTree':
            gettext(
                'Working tree is out of date. To commit, update the working tree.'
            )
        }
        self.not_uptodate_info = InfoWidget(branch_groupbox)
        not_uptodate_layout = QtWidgets.QHBoxLayout(self.not_uptodate_info)

        # XXX this is to big. Resize
        not_uptodate_icon = QtWidgets.QLabel()
        not_uptodate_icon.setPixmap(self.style().standardPixmap(
            QtWidgets.QStyle.SP_MessageBoxWarning))
        not_uptodate_layout.addWidget(not_uptodate_icon)

        self.not_uptodate_label = QtWidgets.QLabel('error message goes here')
        not_uptodate_layout.addWidget(self.not_uptodate_label, 2)

        update_button = QtWidgets.QPushButton(gettext('Update'))
        update_button.clicked[bool].connect(self.open_update_win)

        not_uptodate_layout.addWidget(update_button)

        self.not_uptodate_info.hide()
        branch_layout.addWidget(self.not_uptodate_info, 3, 0, 1, 2)

        splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical, self)

        message_groupbox = QtWidgets.QGroupBox(gettext("Message"), splitter)
        splitter.addWidget(message_groupbox)
        self.tabWidget = QtWidgets.QTabWidget()
        splitter.addWidget(self.tabWidget)
        splitter.setStretchFactor(0, 1)
        splitter.setStretchFactor(1, 8)

        grid = QtWidgets.QGridLayout(message_groupbox)

        self.show_nonversioned_checkbox = QtWidgets.QCheckBox(
            gettext("Show non-versioned files"))
        show_nonversioned = get_qbrz_config().get_option_as_bool(
            self._window_name + "_show_nonversioned")
        if show_nonversioned:
            self.show_nonversioned_checkbox.setChecked(QtCore.Qt.Checked)
        else:
            self.show_nonversioned_checkbox.setChecked(QtCore.Qt.Unchecked)

        self.filelist_widget = TreeWidget(self)
        self.filelist_widget.throbber = self.throbber
        if show_nonversioned:
            self.filelist_widget.tree_model.set_select_all_kind('all')
        else:
            self.filelist_widget.tree_model.set_select_all_kind('versioned')

        self.file_words = {}
        self.filelist_widget.tree_model.dataChanged[
            QtCore.QModelIndex,
            QtCore.QModelIndex].connect(self.on_filelist_data_changed)

        self.selectall_checkbox = SelectAllCheckBox(self.filelist_widget, self)
        self.selectall_checkbox.setCheckState(QtCore.Qt.Checked)

        language = get_global_config().get_user_option(
            'spellcheck_language') or 'en'
        spell_checker = SpellChecker(language)

        # Equivalent for 'bzr commit --message'
        self.message = TextEdit(spell_checker,
                                message_groupbox,
                                main_window=self)
        self.message.setToolTip(gettext("Enter the commit message"))
        self.message.messageEntered.connect(self.do_accept)
        self.completer = QtWidgets.QCompleter()
        self.completer_model = QtCore.QStringListModel(self.completer)
        self.completer.setModel(self.completer_model)
        self.message.setCompleter(self.completer)
        self.message.setAcceptRichText(False)

        SpellCheckHighlighter(self.message.document(), spell_checker)

        grid.addWidget(self.message, 0, 0, 1, 2)

        # Equivalent for 'bzr commit --fixes'
        self.bugsCheckBox = QtWidgets.QCheckBox(gettext("&Fixed bugs:"))
        self.bugsCheckBox.setToolTip(
            gettext("Set the IDs of bugs fixed by this commit"))
        self.bugs = QtWidgets.QLineEdit()
        self.bugs.setToolTip(
            gettext("Enter the list of bug IDs in format "
                    "<i>tag:id</i> separated by a space, "
                    "e.g. <i>project:123 project:765</i>"))
        self.bugs.setEnabled(False)
        self.bugsCheckBox.stateChanged[int].connect(self.enableBugs)
        grid.addWidget(self.bugsCheckBox, 1, 0)
        grid.addWidget(self.bugs, 1, 1)

        # Equivalent for 'bzr commit --author'
        self.authorCheckBox = QtWidgets.QCheckBox(gettext("&Author:"))
        self.authorCheckBox.setToolTip(
            gettext("Set the author of this change,"
                    " if it's different from the committer"))
        self.author = QtWidgets.QLineEdit()
        self.author.setToolTip(
            gettext("Enter the author's name, "
                    "e.g. <i>John Doe &lt;[email protected]&gt;</i>"))
        self.author.setEnabled(False)
        self.authorCheckBox.stateChanged[int].connect(self.enableAuthor)
        grid.addWidget(self.authorCheckBox, 2, 0)
        grid.addWidget(self.author, 2, 1)
        # default author from config
        config = self.tree.branch.get_config()
        self.default_author = config.username()
        self.custom_author = ''
        self.author.setText(self.default_author)

        # Display the list of changed files
        files_tab = QtWidgets.QWidget()
        self.tabWidget.addTab(files_tab, gettext("Changes"))

        vbox = QtWidgets.QVBoxLayout(files_tab)
        vbox.addWidget(self.filelist_widget)
        self.show_nonversioned_checkbox.toggled[bool].connect(
            self.show_nonversioned)
        vbox.addWidget(self.show_nonversioned_checkbox)

        vbox.addWidget(self.selectall_checkbox)

        # Display a list of pending merges
        if self.has_pending_merges:
            self.selectall_checkbox.setCheckState(QtCore.Qt.Checked)
            self.selectall_checkbox.setEnabled(False)
            self.pending_merges_list = PendingMergesList(
                self.processEvents, self.throbber, self)

            self.tabWidget.addTab(self.pending_merges_list,
                                  gettext("Pending Merges"))
            self.tabWidget.setCurrentWidget(self.pending_merges_list)

            # Pending-merge widget gets disabled as we are executing.
            self.disableUi[bool].connect(self.pending_merges_list.setDisabled)
        else:
            self.pending_merges_list = False

        self.process_panel = self.make_process_panel()
        self.tabWidget.addTab(self.process_panel, gettext("Status"))

        splitter.setStretchFactor(0, 3)

        vbox = QtWidgets.QVBoxLayout(self)
        vbox.addWidget(self.throbber)
        vbox.addWidget(branch_groupbox)
        vbox.addWidget(splitter)

        # Diff button to view changes in files selected to commit
        self.diffbuttons = DiffButtons(self)
        self.diffbuttons.setToolTip(
            gettext("View changes in files selected to commit"))
        self.diffbuttons._triggered['QString'].connect(
            self.show_diff_for_checked)

        self.refresh_button = StandardButton(BTN_REFRESH)
        self.refresh_button.clicked.connect(self.refresh)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.diffbuttons)
        hbox.addWidget(self.refresh_button)
        hbox.addWidget(self.buttonbox)
        vbox.addLayout(hbox)

        # groupbox and tabbox signals handling.
        for w in (message_groupbox, files_tab):
            # when operation started we need to disable widgets
            self.disableUi[bool].connect(w.setDisabled)

        self.restore_commit_data()
        if message:
            self.message.setText(message)

        # Try to be smart: if there is no saved message
        # then set focus on Edit Area; otherwise on OK button.
        if str(self.message.toPlainText()).strip():
            self.buttonbox.setFocus()
        else:
            self.message.setFocus()
예제 #17
0
    def __init__(self,
                 branch=None,
                 location=None,
                 revision=None,
                 revision_id=None,
                 revision_spec=None,
                 parent=None):
        if branch:
            self.branch = branch
            self.location = url_for_display(branch.base)
        else:
            self.branch = None
            if location is None:
                location = osutils.getcwd()
            self.location = location

        self.workingtree = None
        self.revision_id = revision_id
        self.revision_spec = revision_spec
        self.revision = revision

        QBzrWindow.__init__(self, [gettext("Browse"), self.location], parent)
        self.restoreSize("browse", (780, 580))

        vbox = QtWidgets.QVBoxLayout(self.centralwidget)

        self.throbber = ThrobberWidget(self)
        vbox.addWidget(self.throbber)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(QtWidgets.QLabel(gettext("Location:")))
        self.location_edit = QtWidgets.QLineEdit()
        self.location_edit.setReadOnly(True)
        self.location_edit.setText(self.location)
        hbox.addWidget(self.location_edit, 7)
        hbox.addWidget(QtWidgets.QLabel(gettext("Revision:")))
        self.revision_edit = QtWidgets.QLineEdit()
        self.revision_edit.returnPressed.connect(self.reload_tree)
        hbox.addWidget(self.revision_edit, 1)
        self.show_button = QtWidgets.QPushButton(gettext("Show"))
        self.show_button.clicked.connect(self.reload_tree)
        hbox.addWidget(self.show_button, 0)

        self.filter_menu = TreeFilterMenu(self)
        self.filter_button = QtWidgets.QPushButton(gettext("&Filter"))
        self.filter_button.setMenu(self.filter_menu)
        hbox.addWidget(self.filter_button, 0)
        self.filter_menu.triggered[int, bool].connect(self.filter_triggered)

        vbox.addLayout(hbox)

        self.file_tree = TreeWidget(self)
        self.file_tree.throbber = self.throbber
        vbox.addWidget(self.file_tree)

        self.filter_menu.set_filters(self.file_tree.tree_filter_model.filters)

        buttonbox = self.create_button_box(BTN_CLOSE)

        self.refresh_button = StandardButton(BTN_REFRESH)
        buttonbox.addButton(self.refresh_button,
                            QtWidgets.QDialogButtonBox.ActionRole)
        self.refresh_button.clicked.connect(self.file_tree.refresh)

        self.diffbuttons = DiffButtons(self.centralwidget)
        self.diffbuttons._triggered['QString'].connect(
            self.file_tree.show_differences)

        hbox = QtWidgets.QHBoxLayout()
        hbox.addWidget(self.diffbuttons)
        hbox.addWidget(buttonbox)
        vbox.addLayout(hbox)

        self.windows = []

        self.file_tree.setFocus(
        )  # set focus so keyboard navigation will work from the beginning
예제 #18
0
 def _maybe_add_suggestion(self, suggestions, location):
     if location:
         url = url_for_display(location)
         if url not in suggestions:
             suggestions.append(url)