Пример #1
0
 def setup_tab_width(self):
     tabWidths = self.custom_tab_widths
     if tabWidths[0] < 0:
         tabWidths[0] = get_set_tab_width_chars(branch=self.branches[0])
         self.tab_width_selector_left.setTabWidth(tabWidths[0])
     if tabWidths[1] < 0:
         tabWidths[1] = get_set_tab_width_chars(branch=self.branches[1])
         self.tab_width_selector_right.setTabWidth(tabWidths[1])
     if tabWidths[2] < 0:
         tabWidths[2] = get_set_tab_width_chars(branch=self.branches[0])
         self.tab_width_selector_unidiff.setTabWidth(tabWidths[2])
     tabWidthsPixels = [get_tab_width_pixels(tab_width_chars=i) for i in tabWidths]
     self.diffview.setTabStopWidths(tabWidthsPixels)
     self.sdiffview.setTabStopWidth(tabWidthsPixels[2])
Пример #2
0
    def refresh(self):
        self.loaded = False
        self.clear()
        tree = WorkingTree.open_containing(self.directory)[0]
        tree.lock_read()
        try:
            manager = tree.get_shelf_manager()
            shelves = manager.active_shelves()
            for shelf_id in reversed(shelves):
                message = manager.get_metadata(shelf_id).get('message')
                item = QtWidgets.QTreeWidgetItem()
                item.setText(0, str(shelf_id))
                item.setText(1, message or gettext('<no message>'))
                item.setIcon(0, get_icon("folder", 16))
                item.shelf_id = shelf_id
                self.shelve_view.addTopLevelItem(item)
            self.tree = tree
            self.manager = manager

            branch = tree.branch
            if self.initial_encoding is None:
                encoding = get_set_encoding(None, branch)
                self.initial_encoding = encoding            # save real encoding for the next time
                self.encoding_selector.encoding = encoding  # set encoding selector
            tabwidth = get_set_tab_width_chars(branch)
            self.tabwidth_selector.setTabWidth(tabwidth)
            self._on_tabwidth_changed(tabwidth)

        finally:
            tree.unlock()
        self.update()
        self.loaded = True
Пример #3
0
    def refresh(self):
        cleanup = []
        try:
            old_rev = self.revision
            old_changes = self._get_change_dictionary()
            self.clear(clear_message=False)

            shelver, creator = self._create_shelver_and_creator()
            cleanup.append(shelver.finalize)
            cleanup.append(creator.finalize)

            file_list = shelver.file_list
            if file_list:
                nfiles = len(file_list)
                if nfiles > 2:
                    self.files_str = ngettext("%d file", "%d files",
                                              nfiles) % nfiles
                else:
                    self.files_str = ", ".join(file_list)

            self.trees = (shelver.target_tree, shelver.work_tree)
            branch = shelver.work_tree.branch  # current branch corresponding to working tree
            if self.initial_encoding is None:
                encoding = get_set_encoding(None, branch)
                self.initial_encoding = encoding  # save real encoding for the next time
                self.encoding_selector.encoding = encoding  # set encoding selector
            self.editor_available = (shelver.change_editor is not None)
            self.editor_button.setVisible(self.editor_available)
            tabwidth = get_set_tab_width_chars(branch)
            self.tabwidth_selector.setTabWidth(tabwidth)
            self._on_tabwidth_changed(tabwidth)
            self.revision = self.trees[0].get_revision_id()
            if self.revision != old_rev:
                old_changes = None
            for change in creator.iter_shelvable():
                item = self._create_item(change, shelver, self.trees,
                                         old_changes)
                self.file_view.addTopLevelItem(item)

        finally:
            for func in cleanup:
                func()

        if self.select_all:
            self.check_all(True)
            self.select_all = False

        self.loaded = True
Пример #4
0
 def on_tabwidth_changed(self, width):
     get_set_tab_width_chars(self.trees[1].branch, tab_width_chars=width)
     self._on_tabwidth_changed(width)
Пример #5
0
 def test_get_set_tab_width_chars(self):
     br = FakeBranch()
     w = util.get_set_tab_width_chars(br)
     self.assertEqual(8, w)
Пример #6
0
 def setTabStopWidth(tw):
     self.text_edit.setTabStopWidth(get_tab_width_pixels(tab_width_chars=tw))
     get_set_tab_width_chars(branch=self.branch,tab_width_chars=tw)
Пример #7
0
    def __init__(self, branch, working_tree, annotate_tree, path, fileId,
                 encoding=None, parent=None, ui_mode=True, no_graph=False,
                 loader=None, loader_args=None, activate_line=None):
        QBzrWindow.__init__(self, [gettext("Annotate"), gettext("Loading...")], parent, ui_mode=ui_mode)
        self.restoreSize("annotate", (780, 680))

        self.activate_line_after_load = activate_line

        self.windows = []

        self.branch = branch
        self.annotate_tree = annotate_tree
        self.working_tree = working_tree
        if (self.working_tree is None and isinstance(annotate_tree, WorkingTree)):
            self.working_tree = annotate_tree

        self.no_graph = no_graph
        self.old_lines = None

        self.fileId = fileId
        self.path = path
        self.encoding = encoding
        self.loader_func = loader
        self.loader_args = loader_args

        self.throbber = ToolBarThrobberWidget(self)

        self.text_edit_frame = AnnotateEditerFrameBase(self)
        self.text_edit = AnnotatedTextEdit(self)
        self.text_edit.setFrameStyle(QtWidgets.QFrame.NoFrame)
        self.text_edit.setTextInteractionFlags(QtCore.Qt.TextSelectableByMouse | QtCore.Qt.TextSelectableByKeyboard)
        self.text_edit.setLineWrapMode(QtWidgets.QPlainTextEdit.NoWrap)

        self.text_edit.document().setDefaultFont(get_monospace_font())

        self.guidebar_panel = GuideBarPanel(self.text_edit, parent=self)
        self.guidebar_panel.add_entry('annotate', QtGui.QColor(255, 160, 180))
        self.annotate_bar = AnnotateBar(self.text_edit, self, self.get_revno)
        annotate_spliter = QtWidgets.QSplitter(QtCore.Qt.Horizontal, self)
        annotate_spliter.addWidget(self.annotate_bar)
        annotate_spliter.addWidget(self.guidebar_panel)
        self.annotate_bar.splitter = annotate_spliter
        self.text_edit_frame.hbox.addWidget(annotate_spliter)

        self.text_edit.cursorPositionChanged.connect(self.edit_cursorPositionChanged)
        self.annotate_bar.cursorPositionChanged.connect(self.edit_cursorPositionChanged)
        self.text_edit.documentChangeFinished.connect(self.edit_documentChangeFinished)

        self.log_list = AnnotateLogList(self.processEvents, self.throbber, self)
        self.log_list.header().hideSection(logmodel.COL_DATE)
        self.log_list.parent_annotate_window = self
        self.log_branch_loaded = False

        self.log_list.selectionModel().selectionChanged[QtCore.QItemSelection, QtCore.QItemSelection].connect(self.log_list_selectionChanged)

        self.message = LogListRevisionMessageBrowser(self.log_list, self)

        self.encoding_selector = EncodingMenuSelector(self.encoding, gettext("Encoding"), self._on_encoding_changed)

        hsplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal)
        hsplitter.addWidget(self.log_list)
        hsplitter.addWidget(self.message)

        hsplitter.setStretchFactor(0, 2)
        hsplitter.setStretchFactor(1, 2)

        splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical)
        splitter.addWidget(self.text_edit_frame)
        splitter.addWidget(hsplitter)

        splitter.setStretchFactor(0, 5)
        splitter.setStretchFactor(1, 2)

        vbox = QtWidgets.QVBoxLayout(self.centralwidget)
        #vbox.addWidget(self.toolbar)
        vbox.addWidget(splitter)
        self.text_edit.setFocus()

        self.show_find = QtWidgets.QAction(get_icon("edit-find"), gettext("Find"), self)
        self.show_find.setShortcuts(QtGui.QKeySequence.Find)
        self.show_find.setCheckable(True)

        self.show_goto_line = QtWidgets.QAction(get_icon("go-jump"), gettext("Goto Line"), self)
        self.show_goto_line.setShortcuts((QtCore.Qt.CTRL + QtCore.Qt.Key_L,))
        self.show_goto_line.setCheckable(True)

        show_view_menu = QtWidgets.QAction(get_icon("document-properties"), gettext("&View Options"), self)
        view_menu = QtWidgets.QMenu(gettext('View Options'), self)
        show_view_menu.setMenu(view_menu)

        word_wrap = QtWidgets.QAction(gettext("Word Wrap"), self)
        word_wrap.setCheckable(True)
        word_wrap.toggled [bool].connect(self.word_wrap_toggle)

        def setTabStopWidth(tw):
            self.text_edit.setTabStopWidth(get_tab_width_pixels(tab_width_chars=tw))
            get_set_tab_width_chars(branch=self.branch,tab_width_chars=tw)
        self.tab_width_selector = TabWidthMenuSelector(get_set_tab_width_chars(branch=branch), gettext("Tab Width"), setTabStopWidth)

        view_menu.addMenu(self.tab_width_selector)
        view_menu.addMenu(self.encoding_selector)
        view_menu.addAction(word_wrap)

        toolbar = self.addToolBar(gettext("Annotate"))
        toolbar.setMovable (False)
        toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)

        #self.toolbar.setToolButtonStyle(QtCore.Qt.ToolButtonTextBesideIcon)
        toolbar.addAction(self.show_find)
        toolbar.addAction(self.show_goto_line)
        toolbar.addAction(show_view_menu)
        toolbar.widgetForAction(show_view_menu).setPopupMode(QtWidgets.QToolButton.InstantPopup)

        spacer = QtWidgets.QWidget()
        spacer.setSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
        toolbar.addWidget(spacer)
        toolbar.addWidget(self.throbber)

        self.addToolBarBreak()

        self.find_toolbar = FindToolbar(self, self.text_edit, self.show_find)
        self.find_toolbar.hide()
        self.addToolBar(self.find_toolbar)
        self.show_find.toggled [bool].connect(self.show_find_toggle)
        setup_guidebar_for_find(self.guidebar_panel, self.find_toolbar, index=1)

        self.goto_line_toolbar = GotoLineToolbar(self, self.show_goto_line)
        self.goto_line_toolbar.hide()
        self.addToolBar(self.goto_line_toolbar)

        self.show_goto_line.toggled [bool].connect(self.show_goto_line_toggle)

        self.__hashes = {}
Пример #8
0
 def on_right_tab_width_changed(tabwidth):
     if self.branches:
         get_set_tab_width_chars(branch=self.branches[1],tab_width_chars=tabwidth)
     self.custom_tab_widths[1] = tabwidth
     self.setup_tab_width()
Пример #9
0
 def on_unidiff_tab_width_changed(tabwidth):
     if self.branches:
         get_set_tab_width_chars(branch=self.branches[0],tab_width_chars=tabwidth)
     self.custom_tab_widths[2] = tabwidth
     self.setup_tab_width()