Esempio n. 1
0
 def load_settings(self):
     config = get_qbrz_config()
     layout = config.get_option("shelvelist_layout")
     if layout not in ("2", "3"):
         layout = "1"
     self.current_layout = int(layout)
     self.show_files = not not config.get_option_as_bool("shelvelist_show_filelist")
Esempio n. 2
0
 def closeEvent(self, event):
     self._save_or_wipe_commit_data()
     qbrz_config = get_qbrz_config()
     qbrz_config.set_option(self._window_name + "_show_nonversioned",
                            self.show_nonversioned_checkbox.isChecked())
     qbrz_config.save()  # do I need this or is .saveSize() enough?
     return SubProcessDialog.closeEvent(self, event)
Esempio n. 3
0
 def addBookmark(self):
     dialog = BookmarkDialog(gettext("Add Bookmark"), self)
     if dialog.exec_() == QtWidgets.QDialog.Accepted:
         name, location = list(dialog.values())
         config = get_qbrz_config()
         config.add_bookmark(name, location)
         config.save()
         self.sideBarModel.refresh(self.sideBarModel.bookmarksItem)
Esempio n. 4
0
 def editBookmark(self, pos):
     config = get_qbrz_config()
     bookmarks = list(config.getBookmarks())
     dialog = BookmarkDialog(gettext("Edit Bookmark"), self)
     dialog.setValues(*bookmarks[pos])
     if dialog.exec_() == QtWidgets.QDialog.Accepted:
         bookmarks[pos] = list(dialog.values())
         config.set_bookmarks(bookmarks)
         config.save()
         self.sideBarModel.refresh(self.sideBarModel.bookmarksItem)
Esempio n. 5
0
 def removeBookmark(self, pos):
     res = QtWidgets.QMessageBox.question(
         self, gettext("Remove Bookmark"),
         gettext("Do you really want to remove the selected bookmark?"),
         QtWidgets.QMessageBox.Yes | QtWidgets.QMessageBox.No)
     if res == QtWidgets.QMessageBox.Yes:
         config = get_qbrz_config()
         bookmarks = list(config.getBookmarks())
         del bookmarks[pos]
         config.set_bookmarks(bookmarks)
         config.save()
         self.sideBarModel.refresh(self.sideBarModel.bookmarksItem)
Esempio n. 6
0
    def __init__(self, to_location, ui_mode=True, parent=None):
        config = get_qbrz_config()
        checkout_basedir = config.get_option("checkout_basedir")
        branchsource_basedir = config.get_option("branchsource_basedir")
        if not to_location:
            to_location = checkout_basedir or '.'
        self.to_location = os.path.abspath(to_location)
        super(GetNewWorkingTreeWindow, self).__init__(name=self.NAME,
                                                      ui_mode=ui_mode,
                                                      parent=parent)

        self.ui = Ui_NewWorkingTreeForm()
        self.ui.setupUi(self)
        fill_pull_combo(self.ui.from_location, None)
        # and add the subprocess widgets.
        for w in self.make_default_layout_widgets():
            self.layout().addWidget(w)

        # Our 2 directory pickers hook up to our combos.
        hookup_directory_picker(self, self.ui.from_picker,
                                self.ui.from_location, DIRECTORYPICKER_SOURCE)

        hookup_directory_picker(self, self.ui.to_picker, self.ui.to_location,
                                DIRECTORYPICKER_TARGET)

        # signal to manage updating the 'location' on the fly.
        self.ui.from_location.editTextChanged['QString'].connect(
            self.from_location_changed)
        self.ui.to_location.textChanged['QString'].connect(
            self.to_location_changed)

        self.ui.but_checkout.setChecked(True)
        self.ui.but_rev_tip.setChecked(True)
        self.ui.to_location.setText(self.to_location)
        if branchsource_basedir is not None:
            self.from_location = branchsource_basedir
            self.ui.from_location.setEditText(self.from_location)
Esempio n. 7
0
    def __init__(self, parent=None):
        QtWidgets.QSplitter.__init__(self, QtCore.Qt.Horizontal, parent)
        self.setHandleWidth(30)
        self.complete = False

        titleFont = QtGui.QFont(self.font())
        titleFont.setPointSize(titleFont.pointSize() * 140 / 100)
        titleFont.setBold(True)

        self.monospacedFont = get_monospace_font()
        metadataFont = QtGui.QFont(self.font())
        metadataFont.setPointSize(titleFont.pointSize() * 70 / 100)
        metadataLabelFont = QtGui.QFont(metadataFont)
        metadataLabelFont.setBold(True)

        self.monospacedFormat = QtGui.QTextCharFormat()
        self.monospacedFormat.setFont(self.monospacedFont)
        self.ttype_formater = CachedTTypeFormater(
                                QtGui.QTextCharFormat(self.monospacedFormat))
        self.background = self.monospacedFormat.background()

        self.titleFormat = QtGui.QTextCharFormat()
        self.titleFormat.setFont(titleFont)
        self.metadataFormat = QtGui.QTextCharFormat()
        self.metadataFormat.setFont(metadataFont)
        self.metadataLabelFormat = QtGui.QTextCharFormat()
        self.metadataLabelFormat.setFont(metadataLabelFont)

        self.docs = (QtGui.QTextDocument(), QtGui.QTextDocument())
        self.browsers = (DiffSourceView(self), DiffSourceView(self))

        self.guidebar_panels = [
            GuideBarPanel(b, align=a)
            for (b, a) in zip(self.browsers, (GBAR_LEFT, GBAR_RIGHT))
        ]
        for g in self.guidebar_panels:
            setup_guidebar_entries(g.bar)

        self.reset_guidebar_data()

        for b in self.browsers:
            b.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)

        self.cursors = [QtGui.QTextCursor(doc) for doc in self.docs]

        for i, (panel, doc, cursor) in enumerate(zip(self.guidebar_panels,
                                                     self.docs, self.cursors)):
            doc.setUndoRedoEnabled(False)
            doc.setDefaultFont(self.monospacedFont)

            panel.edit.setDocument(doc)
            self.addWidget(panel)
            self.setCollapsible(i, False)

            format = QtGui.QTextCharFormat()
            format.setAnchorNames(["top"])
            cursor.insertText("", format)

        self.scrollbar = SidebySideDiffViewScrollBar(self.handle(1), self.browsers)

        self.ignoreUpdate = False
        self.browsers[0].horizontalScrollBar().valueChanged[int].connect(self.syncHorizontalSlider1)
        self.browsers[1].horizontalScrollBar().valueChanged[int].connect(self.syncHorizontalSlider2)

        self.rewinded = False

        self.lastModifiedLabel = gettext('Last modified:')
        self.statusLabel = gettext('Status:')
        self.kindLabel = gettext('Kind:')
        self.propertiesLabel = gettext('Properties:')

        self.image_exts = ['.'+str(i)
            for i in QtGui.QImageReader.supportedImageFormats()]

        config = get_qbrz_config()
        self.show_intergroup_colors = config.get_option("diff_show_intergroup_colors") in ("True", "1")
Esempio n. 8
0
    'insert': [QtGui.QColor(180, 255, 180), QtGui.QColor(80, 210, 80)],
    'replace': [QtGui.QColor(206, 226, 250), QtGui.QColor(90, 130, 180)],
    'blank': [QtGui.QColor(240, 240, 240), QtGui.QColor(171, 171, 171)],
    'dummy': [QtGui.QColor(0, 0, 0, 0), QtGui.QColor(0, 0, 0, 0)],
}
#The background color of the replacement text in a replacement group.
interline_changes_background = QtGui.QColor(180, 210, 250)

#load user-defined color mapping from configuration file.

#For each kind, there can be two entries in the configuration file,
#under the [QDIFF COLORS] section:
#  kind_bound -- the color of the boundary of the rectangle this kind refers to.
#  kind_fill  -- the color of the filling of that same rectangle.

config = get_qbrz_config()
component_dict = {0:'fill', 1:'bound'}
for key in colors.keys():
    for comp in [0,1]:
        color = None
        try:
            color = config.get_color(key + '_' + component_dict[comp],
                                        'QDIFF COLORS')
        except ValueError as msg:
            #error handling.
            mutter(str(msg))
        if None != color:
            colors[key][comp] = color


#Get a user-defined replacement text background
Esempio n. 9
0
 def save_settings(self):
     config = get_qbrz_config()
     config.set_option("shelve_layout", str(self.current_layout))
     config.save()
Esempio n. 10
0
 def load_settings(self):
     config = get_qbrz_config()
     layout = config.get_option("shelve_layout")
     if layout not in ("1", "3"):
         layout = "2"
     self.current_layout = int(layout)
Esempio n. 11
0
 def load(self, sidebar):
     config = get_qbrz_config()
     self.children = []
     for name, path in config.get_bookmarks():
         item = BookmarkItem(name, path, self, sidebar)
         self.children.append(item)
Esempio n. 12
0
    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()
Esempio n. 13
0
 def save_state(self):
     config = get_qbrz_config()
     for name, splitter in self.splitters:
         value = splitter.saveState().toBase64().data()
         config.set_option('%s_%s' % (self.prefix, name), value)
     config.save()
Esempio n. 14
0
 def restore_state(self):
     config = get_qbrz_config()
     for name, splitter in self.splitters:
         data = config.get_option('%s_%s' % (self.prefix, name))
         if data:
             splitter.restoreState(QtCore.QByteArray.fromBase64(data))