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=QtGui.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, 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 = QtGui.QVBoxLayout(self.centralwidget) self.vbox.addWidget(self.throbber) self.vbox.addStretch() hbox = QtGui.QHBoxLayout() hbox.addWidget(self.encoding_selector) hbox.addWidget(self.buttonbox) self.vbox.addLayout(hbox)
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, 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.set_title(gettext("Plugins")) self.restoreSize("plugins", (400, 256)) view = self.build_view() btns = self.create_button_box(BTN_CLOSE) layout = QtGui.QVBoxLayout(self.centralWidget()) layout.addWidget(view) layout.addWidget(btns) self.refresh_view()
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 = QtGui.QVBoxLayout(self.centralwidget) vbox.setMargin(2) self.throbber = ToolBarThrobberWidget(self) vbox.addWidget(self.throbber) self.tab = QtGui.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.connect(self.tab, QtCore.SIGNAL("currentChanged(int)"), self.current_tab_changed) self.connect(shelve_view, QtCore.SIGNAL("shelfCreated(int)"), self.shelf_created) self.connect(shelvelist_view, QtCore.SIGNAL("unshelved(int, QString*)"), 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 = QtGui.QStackedWidget(self.centralwidget) self.stack.addWidget(self.diffview) self.stack.addWidget(self.sdiffview) vbox = QtGui.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 __init__(self, title, name="genericsubprocess", args=None, dir=None, default_size=None, ui_mode=True, dialog=True, parent=None, hide_progress=False): QBzrWindow.__init__(self, title, parent) self.__init_internal__(title, name=name, args=args, dir=dir, default_size=default_size, ui_mode=ui_mode, dialog=dialog, parent=parent, hide_progress=hide_progress)
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 = QtGui.QVBoxLayout(self.centralwidget) self.vbox.addStretch() hbox = QtGui.QHBoxLayout() hbox.addWidget(self.encoding_selector) hbox.addWidget(self.buttonbox) self.vbox.addLayout(hbox)
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 = QtGui.QVBoxLayout(self.centralwidget) self.conflicts_list = QtGui.QTreeWidget(self) self.conflicts_list.setRootIsDecorated(False) self.conflicts_list.setUniformRowHeights(True) self.conflicts_list.setSelectionBehavior( QtGui.QAbstractItemView.SelectRows) self.conflicts_list.setSelectionMode( QtGui.QAbstractItemView.ExtendedSelection) self.conflicts_list.setHeaderLabels([ gettext("File"), gettext("Conflict"), ]) self.connect( self.conflicts_list.selectionModel(), QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.update_merge_tool_ui) self.connect(self.conflicts_list, QtCore.SIGNAL("customContextMenuRequested(QPoint)"), self.show_context_menu) self.connect( self.conflicts_list, QtCore.SIGNAL("itemDoubleClicked(QTreeWidgetItem *, int)"), 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.setResizeMode(0, QtGui.QHeaderView.Stretch) header.setResizeMode(1, QtGui.QHeaderView.ResizeToContents) vbox.addWidget(self.conflicts_list) hbox = QtGui.QHBoxLayout() self.merge_tools_combo = QtGui.QComboBox(self) self.merge_tools_combo.setEditable(False) self.connect(self.merge_tools_combo, QtCore.SIGNAL("currentIndexChanged(int)"), self.update_merge_tool_ui) self.merge_tool_error = QtGui.QLabel('', self) self.program_launch_button = QtGui.QPushButton(gettext("&Launch..."), self) self.program_launch_button.setEnabled(False) self.connect(self.program_launch_button, QtCore.SIGNAL("clicked()"), self.launch_merge_tool) self.program_label = QtGui.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, QtGui.QDialogButtonBox.ActionRole) self.connect(refresh, QtCore.SIGNAL("clicked()"), self.refresh) autobutton = QtGui.QPushButton(gettext('Auto-resolve'), self.centralwidget) self.connect(autobutton, QtCore.SIGNAL("clicked(bool)"), self.auto_resolve) hbox = QtGui.QHBoxLayout() hbox.addWidget(autobutton) hbox.addWidget(buttonbox) vbox.addLayout(hbox) self.initialize_ui()
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(QtGui.QFrame.NoFrame) self.text_edit.setTextInteractionFlags( QtCore.Qt.TextSelectableByMouse | QtCore.Qt.TextSelectableByKeyboard) self.text_edit.setLineWrapMode(QtGui.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 = QtGui.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.connect(self.text_edit, QtCore.SIGNAL("cursorPositionChanged()"), self.edit_cursorPositionChanged) self.connect(self.annotate_bar, QtCore.SIGNAL("cursorPositionChanged()"), self.edit_cursorPositionChanged) self.connect(self.text_edit, QtCore.SIGNAL("documentChangeFinished()"), 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.connect( self.log_list.selectionModel(), QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.log_list_selectionChanged) self.message = LogListRevisionMessageBrowser(self.log_list, self) self.encoding_selector = EncodingMenuSelector( self.encoding, gettext("Encoding"), self._on_encoding_changed) hsplitter = QtGui.QSplitter(QtCore.Qt.Horizontal) hsplitter.addWidget(self.log_list) hsplitter.addWidget(self.message) hsplitter.setStretchFactor(0, 2) hsplitter.setStretchFactor(1, 2) splitter = QtGui.QSplitter(QtCore.Qt.Vertical) splitter.addWidget(self.text_edit_frame) splitter.addWidget(hsplitter) splitter.setStretchFactor(0, 5) splitter.setStretchFactor(1, 2) vbox = QtGui.QVBoxLayout(self.centralwidget) #vbox.addWidget(self.toolbar) vbox.addWidget(splitter) self.text_edit.setFocus() self.show_find = QtGui.QAction(get_icon("edit-find"), gettext("Find"), self) self.show_find.setShortcuts(QtGui.QKeySequence.Find) self.show_find.setCheckable(True) self.show_goto_line = QtGui.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 = QtGui.QAction(get_icon("document-properties"), gettext("&View Options"), self) view_menu = QtGui.QMenu(gettext('View Options'), self) show_view_menu.setMenu(view_menu) word_wrap = QtGui.QAction(gettext("Word Wrap"), self) word_wrap.setCheckable(True) self.connect(word_wrap, QtCore.SIGNAL("toggled (bool)"), 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( QtGui.QToolButton.InstantPopup) spacer = QtGui.QWidget() spacer.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.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.connect(self.show_find, QtCore.SIGNAL("toggled (bool)"), 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.connect(self.show_goto_line, QtCore.SIGNAL("toggled (bool)"), self.show_goto_line_toggle) self.__hashes = {}
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 = QtGui.QVBoxLayout(self.centralwidget) self.throbber = ThrobberWidget(self) vbox.addWidget(self.throbber) hbox = QtGui.QHBoxLayout() hbox.addWidget(QtGui.QLabel(gettext("Location:"))) self.location_edit = QtGui.QLineEdit() self.location_edit.setReadOnly(True) self.location_edit.setText(self.location) hbox.addWidget(self.location_edit, 7) hbox.addWidget(QtGui.QLabel(gettext("Revision:"))) self.revision_edit = QtGui.QLineEdit() self.connect(self.revision_edit, QtCore.SIGNAL("returnPressed()"), self.reload_tree) hbox.addWidget(self.revision_edit, 1) self.show_button = QtGui.QPushButton(gettext("Show")) self.connect(self.show_button, QtCore.SIGNAL("clicked()"), self.reload_tree) hbox.addWidget(self.show_button, 0) self.filter_menu = TreeFilterMenu(self) self.filter_button = QtGui.QPushButton(gettext("&Filter")) self.filter_button.setMenu(self.filter_menu) hbox.addWidget(self.filter_button, 0) self.connect(self.filter_menu, QtCore.SIGNAL("triggered(int, bool)"), 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, QtGui.QDialogButtonBox.ActionRole) self.connect(self.refresh_button, QtCore.SIGNAL("clicked()"), self.file_tree.refresh) self.diffbuttons = DiffButtons(self.centralwidget) self.connect(self.diffbuttons, QtCore.SIGNAL("triggered(QString)"), self.file_tree.show_differences) hbox = QtGui.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, 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 = QtGui.QWidget() logbox = QtGui.QVBoxLayout(logwidget) logbox.setContentsMargins(0, 0, 0, 0) searchbox = QtGui.QHBoxLayout() self.search_label = QtGui.QLabel(gettext("&Search:")) self.search_edit = QtGui.QLineEdit() self.search_label.setBuddy(self.search_edit) self.connect(self.search_edit, QtCore.SIGNAL("textEdited(QString)"), self.set_search_timer) self.search_timer = QtCore.QTimer(self) self.search_timer.setSingleShot(True) self.connect(self.search_timer, QtCore.SIGNAL("timeout()"), self.update_search) searchbox.addWidget(self.search_label) searchbox.addWidget(self.search_edit) self.searchType = QtGui.QComboBox() self.searchType.addItem(gettext("Messages"), QtCore.QVariant(self.FilterMessageRole)) self.searchType.addItem(gettext("Authors"), QtCore.QVariant(self.FilterAuthorRole)) self.searchType.addItem(gettext("Revision IDs"), QtCore.QVariant(self.FilterIdRole)) self.searchType.addItem(gettext("Revision Numbers"), QtCore.QVariant(self.FilterRevnoRole)) self.searchType.addItem(gettext("Tags"), QtCore.QVariant(self.FilterTagRole)) self.searchType.addItem(gettext("Bugs"), QtCore.QVariant(self.FilterBugRole)) searchbox.addWidget(self.searchType) self.connect(self.searchType, QtCore.SIGNAL("currentIndexChanged(int)"), 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.connect( self.log_list.selectionModel(), QtCore.SIGNAL("selectionChanged(QItemSelection, QItemSelection)"), self.file_list_container.revision_selection_changed) hsplitter = QtGui.QSplitter(QtCore.Qt.Horizontal) hsplitter.addWidget(self.message_browser) hsplitter.addWidget(self.file_list_container) hsplitter.setStretchFactor(0, 3) hsplitter.setStretchFactor(1, 1) splitter = QtGui.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, QtGui.QDialogButtonBox.ActionRole) self.connect(self.refresh_button, QtCore.SIGNAL("clicked()"), self.refresh) self.diffbuttons = DiffButtons(self.centralwidget) self.diffbuttons.setEnabled(False) self.connect(self.diffbuttons, QtCore.SIGNAL("triggered(QString)"), self.log_list.show_diff_specified_files_ext) vbox = QtGui.QVBoxLayout(self.centralwidget) vbox.addWidget(splitter) hbox = QtGui.QHBoxLayout() hbox.addWidget(self.diffbuttons) hbox.addWidget(buttonbox) vbox.addLayout(hbox) self.windows = [] # set focus on search edit widget self.log_list.setFocus()