def __init__(self, parent=None): """Create help window. @param parent: If None, a normal top-level window will be opened. If not None, a 'tool' style window will be opened, be 'always on top' of the parent and have no taskbar entry. """ if parent is None: # a normal window. window_id = "help" default_size = (780, 580) else: # a smallish tooltop window. window_id = "help-popup" default_size = (500, 400) QBzrWindow.__init__(self, [gettext("Help")], parent, centralwidget=QtWidgets.QTextBrowser()) self.restoreSize(window_id, default_size) if parent is not None: # make it a tool window for the parent. self.setWindowFlags(QtCore.Qt.Tool) # Without this, the window object remains alive even after its closed. # There's no good reason for that... self.setAttribute(QtCore.Qt.WA_DeleteOnClose)
def __init__(self, location, parent=None): QBzrWindow.__init__(self, [gettext("Info")], parent) self.restoreSize("info", (580, 250)) self.buttonbox = self.create_button_box(BTN_CLOSE) self.ui = Ui_InfoForm() self.ui.setupUi(self.centralwidget) self.ui.verticalLayout.addWidget(self.buttonbox) self.refresh_view(location) self.ui.tabWidget.setCurrentIndex(0)
def __init__(self, parent=None): QBzrWindow.__init__(self, [], parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.set_title(gettext("System Information")) self.restoreSize("sysinfo", (400, 256)) btns = self.create_button_box(BTN_CLOSE) self.ui.vboxlayout.addWidget(btns) self.display_sys_info(get_sys_info())
def __init__(self, parent=None): QBzrWindow.__init__(self, [], parent) self.set_title(gettext("Plugins")) self.restoreSize("plugins", (400,256)) view = self.build_view() btns = self.create_button_box(BTN_CLOSE) layout = QtWidgets.QVBoxLayout(self.centralWidget()) layout.addWidget(view) layout.addWidget(btns) self.refresh_view()
def __init__(self, parent=None): QBzrWindow.__init__(self, [], parent) self.loadIcons() self.createActions() self.createMenuBar() self.createToolBar() self.createStatusBar() self.createUi() self.restoreSize("main", (800, 600)) self.cache = StatusCache(self) self.currentDirectory = None
def __init__(self, initial_tab=0, directory=None, file_list=None, complete=False, ignore_whitespace=False, encoding=None, parent=None, ui_mode=True, select_all=False, message=None): QBzrWindow.__init__(self, [gettext("Shelve Manager")], parent, ui_mode=ui_mode) self.restoreSize("shelve", (780, 680)) vbox = QtWidgets.QVBoxLayout(self.centralwidget) vbox.setContentsMargins(2, 2, 2, 2) self.throbber = ToolBarThrobberWidget(self) vbox.addWidget(self.throbber) self.tab = QtWidgets.QTabWidget(self) vbox.addWidget(self.tab) self.splitters = Splitters("shelve") self.directory = directory or '.' shelve_view = ShelveWidget(file_list=file_list, directory=self.directory, complete=complete, encoding=encoding, splitters=self.splitters, parent=self, select_all=select_all, init_msg=message) shelvelist_view = ShelveListWidget(directory=self.directory, complete=complete, ignore_whitespace=ignore_whitespace, encoding=encoding, splitters=self.splitters, parent=self) self.tab.addTab(shelve_view, gettext('Shelve')) self.tab.addTab(shelvelist_view, gettext('View shelved changes')) self.tab.setCurrentIndex(initial_tab) self.tab.currentChanged[int].connect(self.current_tab_changed) shelve_view.shelfCreated[int].connect(self.shelf_created) shelvelist_view.unshelved[int, 'QString'].connect(self.unshelved) self.splitters.restore_state()
def __init__(self, arg_provider, parent=None, complete=False, encoding=None, filter_options=None, ui_mode=True, allow_refresh=True): title = [gettext("Diff"), gettext("Loading...")] QBzrWindow.__init__(self, title, parent, ui_mode=ui_mode) self.restoreSize("diff", (780, 580)) self.trees = None self.encoding = encoding self.arg_provider = arg_provider self.filter_options = filter_options if filter_options is None: self.filter_options = FilterOptions(all_enable=True) self.complete = complete self.ignore_whitespace = False self.delayed_signal_connections = [] self.diffview = SidebySideDiffView(self) self.sdiffview = SimpleDiffView(self) self.views = (self.diffview, self.sdiffview) for view in self.views: view.set_complete(complete) self.stack = QtWidgets.QStackedWidget(self.centralwidget) self.stack.addWidget(self.diffview) self.stack.addWidget(self.sdiffview) vbox = QtWidgets.QVBoxLayout(self.centralwidget) vbox.addWidget(self.stack) # Don't use a custom tab width by default # Indices are left side, right side and unidiff # respectively self.custom_tab_widths = [-1,-1,-1] for browser in self.diffview.browsers: browser.installEventFilter(self) self.create_main_toolbar(allow_refresh) self.addToolBarBreak() self.find_toolbar = FindToolbar(self, self.diffview.browsers, self.show_find) self.find_toolbar.hide() self.addToolBar(self.find_toolbar) setup_guidebar_for_find(self.sdiffview, self.find_toolbar, 1) for gb in self.diffview.guidebar_panels: setup_guidebar_for_find(gb, self.find_toolbar, 1) self.diff_context = ExtDiffContext(self)
def restoreSize(self, name, defaultSize): config = QBzrWindow.restoreSize(self, name, defaultSize) name = self._window_name value = config.get_option(name + "_vsplitter_state") # We get a utf-8 string, but need some bytes... if value: self.vsplitter.restoreState(b64decode(value)) value = config.get_option(name + "_hsplitter_state") if value: self.hsplitter.restoreState(b64decode(value)) value = config.get_option(name + "_file_list_header_state") if value: self.fileListView.header().restoreState(b64decode(value))
def __init__(self, filename=None, revision=None, tree=None, file_id=None, encoding=None, parent=None): """Create qcat window.""" self.filename = filename self.revision = revision self.tree = tree if tree: self.branch = getattr(tree, 'branch', None) if self.branch is None: self.branch = FakeBranch() self.file_id = file_id self.encoding = encoding if (not self.filename) and self.tree and self.file_id: self.filename = self.tree.id2path(self.file_id) QBzrWindow.__init__(self, [gettext("View"), self.filename], parent) self.restoreSize("cat", (780, 580)) self.throbber = ThrobberWidget(self) self.buttonbox = self.create_button_box(BTN_CLOSE) self.encoding_selector = self._create_encoding_selector() self.vbox = QtWidgets.QVBoxLayout(self.centralwidget) self.vbox.addWidget(self.throbber) self.vbox.addStretch() hbox = QtWidgets.QHBoxLayout() hbox.addWidget(self.encoding_selector) hbox.addWidget(self.buttonbox) self.vbox.addLayout(hbox)
def __init__(self, filename=None, encoding=None, parent=None): """Construct GUI. @param filename: filesystem object to view. @param encoding: use this encoding to decode text file content to unicode. @param parent: parent widget. """ QBzrWindow.__init__(self, [gettext("View"), filename], parent) self.restoreSize("cat", (780, 580)) self.filename = filename self.encoding = encoding self.buttonbox = self.create_button_box(BTN_CLOSE) self.encoding_selector = self._create_encoding_selector() self.branch = FakeBranch() self.vbox = QtWidgets.QVBoxLayout(self.centralwidget) self.vbox.addStretch() hbox = QtWidgets.QHBoxLayout() hbox.addWidget(self.encoding_selector) hbox.addWidget(self.buttonbox) self.vbox.addLayout(hbox)
def hideEvent(self, event): self.splitters.save_state() QBzrWindow.hideEvent(self, event)
def show(self): # we show the bare form as soon as possible. QBzrWindow.show(self) QtCore.QTimer.singleShot(0, self.load)
def eventFilter(self, object, event): if event.type() == QtCore.QEvent.FocusIn: if object in self.diffview.browsers: self.find_toolbar.set_text_edit(object) return QBzrWindow.eventFilter(self, object, event)
def __init__(self, locations=None, branch=None, tree=None, specific_file_ids=None, parent=None, ui_mode=True, no_graph=False, show_trees=False): """Create qlog window. Note: you must use either locations or branch+tree+specific_file_id arguments, but not both. @param locations: list of locations to show log (either list of URL/paths for several branches, or list of filenames from one branch). This list used when branch argument is None. @param branch: branch object to show the log. Could be None, in this case locations list will be used to open branch(es). @param specific_file_ids: file ids from the branch to filter the log. @param parent: parent widget. @param ui_mode: for compatibility with TortoiseBzr. @param no_graph: don't show the graph of revisions (make sense for `bzr qlog FILE` to force plain log a-la `bzr log`). """ self.title = gettext("Log") QBzrWindow.__init__(self, [self.title], parent, ui_mode=ui_mode) self.restoreSize("log", (710, 580)) self.no_graph = no_graph self.show_trees = show_trees if branch: self.branch = branch self.tree = tree self.locations = (branch, ) self.specific_file_ids = specific_file_ids assert locations is None, "can't specify both branch and locations" else: self.branch = None self.locations = locations # if self.locations is None: # self.locations = [u"."] assert specific_file_ids is None, "specific_file_ids is ignored if branch is None" self.branches = None self.replace = {} self.throbber = ThrobberWidget(self) logwidget = QtWidgets.QWidget() logbox = QtWidgets.QVBoxLayout(logwidget) logbox.setContentsMargins(0, 0, 0, 0) searchbox = QtWidgets.QHBoxLayout() self.search_label = QtWidgets.QLabel(gettext("&Search:")) self.search_edit = QtWidgets.QLineEdit() self.search_label.setBuddy(self.search_edit) self.search_edit.textEdited['QString'].connect(self.set_search_timer) self.search_timer = QtCore.QTimer(self) self.search_timer.setSingleShot(True) self.search_timer.timeout.connect(self.update_search) searchbox.addWidget(self.search_label) searchbox.addWidget(self.search_edit) self.searchType = QtWidgets.QComboBox() self.searchType.addItem(gettext("Messages"), self.FilterMessageRole) self.searchType.addItem(gettext("Authors"), self.FilterAuthorRole) self.searchType.addItem(gettext("Revision IDs"), self.FilterIdRole) self.searchType.addItem(gettext("Revision Numbers"), self.FilterRevnoRole) self.searchType.addItem(gettext("Tags"), self.FilterTagRole) self.searchType.addItem(gettext("Bugs"), self.FilterBugRole) searchbox.addWidget(self.searchType) self.searchType.currentIndexChanged[int].connect(self.updateSearchType) logbox.addLayout(searchbox) self.log_list = LogList(self.processEvents, self.throbber, self, action_commands=True) logbox.addWidget(self.throbber) logbox.addWidget(self.log_list) self.current_rev = None self.message = QtGui.QTextDocument() self.message_browser = LogListRevisionMessageBrowser( self.log_list, self) self.message_browser.setDocument(self.message) self.file_list_container = FileListContainer(self.log_list, self) self.log_list.selectionModel().selectionChanged[ QtCore.QItemSelection, QtCore.QItemSelection].connect( self.file_list_container.revision_selection_changed) hsplitter = QtWidgets.QSplitter(QtCore.Qt.Horizontal) hsplitter.addWidget(self.message_browser) hsplitter.addWidget(self.file_list_container) hsplitter.setStretchFactor(0, 3) hsplitter.setStretchFactor(1, 1) splitter = QtWidgets.QSplitter(QtCore.Qt.Vertical) splitter.addWidget(logwidget) splitter.addWidget(hsplitter) splitter.setStretchFactor(0, 5) splitter.setStretchFactor(1, 3) 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.refresh) self.diffbuttons = DiffButtons(self.centralwidget) self.diffbuttons.setEnabled(False) self.diffbuttons._triggered['QString'].connect( self.log_list.show_diff_specified_files_ext) vbox = QtWidgets.QVBoxLayout(self.centralwidget) vbox.addWidget(splitter) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(self.diffbuttons) hbox.addWidget(buttonbox) vbox.addLayout(hbox) self.windows = [] # set focus on search edit widget self.log_list.setFocus()
def show(self): QBzrWindow.show(self) QtCore.QTimer.singleShot(1, self.load)
def __init__(self, wt_dir, parent=None): self.merge_action = None self.wt = None self.wt_dir = wt_dir QBzrWindow.__init__(self, [gettext("Conflicts")], parent) self.restoreSize("conflicts", (550, 380)) vbox = QtWidgets.QVBoxLayout(self.centralwidget) self.conflicts_list = QtWidgets.QTreeWidget(self) self.conflicts_list.setRootIsDecorated(False) self.conflicts_list.setUniformRowHeights(True) self.conflicts_list.setSelectionBehavior( QtWidgets.QAbstractItemView.SelectRows) self.conflicts_list.setSelectionMode( QtWidgets.QAbstractItemView.ExtendedSelection) self.conflicts_list.setHeaderLabels([ gettext("File"), gettext("Conflict"), ]) self.conflicts_list.selectionModel().selectionChanged[ QItemSelection, QItemSelection].connect(self.update_merge_tool_ui) self.conflicts_list.customContextMenuRequested[QPoint].connect( self.show_context_menu) self.conflicts_list.itemDoubleClicked[QTreeWidgetItem, int].connect( self.launch_merge_tool) self.conflicts_list.setContextMenuPolicy(QtCore.Qt.CustomContextMenu) self.conflicts_list.setSortingEnabled(True) self.conflicts_list.sortByColumn(0, QtCore.Qt.AscendingOrder) header = self.conflicts_list.header() header.setStretchLastSection(False) header.setSectionResizeMode(0, QtWidgets.QHeaderView.Stretch) header.setSectionResizeMode(1, QtWidgets.QHeaderView.ResizeToContents) vbox.addWidget(self.conflicts_list) hbox = QtWidgets.QHBoxLayout() self.merge_tools_combo = QtWidgets.QComboBox(self) self.merge_tools_combo.setEditable(False) self.merge_tools_combo.currentIndexChanged[int].connect( self.update_merge_tool_ui) self.merge_tool_error = QtWidgets.QLabel('', self) self.program_launch_button = QtWidgets.QPushButton( gettext("&Launch..."), self) self.program_launch_button.setEnabled(False) self.program_launch_button.clicked.connect(self.launch_merge_tool) self.program_label = QtWidgets.QLabel(gettext("M&erge tool:"), self) self.program_label.setBuddy(self.merge_tools_combo) hbox.addWidget(self.program_label) hbox.addWidget(self.merge_tools_combo) hbox.addWidget(self.merge_tool_error) hbox.addStretch(1) hbox.addWidget(self.program_launch_button) vbox.addLayout(hbox) self.create_context_menu() buttonbox = self.create_button_box(BTN_CLOSE) refresh = StandardButton(BTN_REFRESH) buttonbox.addButton(refresh, QtWidgets.QDialogButtonBox.ActionRole) refresh.clicked.connect(self.refresh) autobutton = QtWidgets.QPushButton(gettext('Auto-resolve'), self.centralwidget) autobutton.clicked[bool].connect(self.auto_resolve) hbox = QtWidgets.QHBoxLayout() hbox.addWidget(autobutton) hbox.addWidget(buttonbox) vbox.addLayout(hbox) self.initialize_ui()
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
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 = {}
def show(self): QBzrWindow.show(self) QtCore.QTimer.singleShot(0, self.initial_load)