def __init__(self, process, command_string, parent=None): config_key = "layout/window/process" super(ProcessDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Running: %s" % command_string) self.proc = process self.ended = False self.output_ended = False self.capture_output = True self.buffer = [] self.bar = QtGui.QProgressBar() self.bar.setRange(0, 0) self.edit = StreamableTextEdit() close_btn = QtGui.QPushButton("Close") btn_pane = create_pane([None, close_btn], True) create_pane([self.bar, self.edit, btn_pane], False, parent_widget=self) self.lock = Lock() self.stdout_thread = Thread(target=self._read_output, args=(self.proc.stdout, )) self.stderr_thread = Thread(target=self._read_output, args=(self.proc.stderr, )) self.timer = QtCore.QTimer() self.timer.setInterval(100) self.timer.timeout.connect(self._update) self.timer.start() self.stdout_thread.start() self.stderr_thread.start() close_btn.clicked.connect(self.close)
def __init__(self, context_model=None, read_only=False, parent=None): super(PackageSelectWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.edit = PackageLineEdit(self.context_model, read_only=read_only, parent=self) self.edit.setStyleSheet("QLineEdit { border : 0px;}") self.btn = IconButton("package", "browse packages") self.btn.hide() create_pane([(self.edit, 1), self.btn, 2], True, compact=True, compact_spacing=0, parent_widget=self) if read_only: self.edit.setReadOnly(True) update_font(self.edit, italic=True) else: self.edit.focusIn.connect(self._focusIn) self.edit.focusOut.connect(self._focusOut) self.edit.focusOutViaKeyPress.connect(self._focusOutViaKeyPress) self.edit.textChanged.connect(self._textChanged) self.btn.clicked.connect(self._browse_package)
def __init__(self, parent=None): super(VariantSummaryWidget, self).__init__(parent) self.variant = None self.label = QtWidgets.QLabel() self.table = QtWidgets.QTableWidget(0, 1) self.table.setGridStyle(QtCore.Qt.DotLine) self.table.setFocusPolicy(QtCore.Qt.NoFocus) self.table.setSelectionMode(QtWidgets.QAbstractItemView.NoSelection) self.table.setAlternatingRowColors(True) hh = self.table.horizontalHeader() hh.setStretchLastSection(True) hh.setVisible(False) vh = self.table.verticalHeader() QtCompat.QHeaderView.setSectionResizeMode( vh, QtWidgets.QHeaderView.ResizeToContents) create_pane([self.label, self.table], False, compact=True, parent_widget=self) self.clear()
def __init__(self, pivot_widget, width=240, height=160, parent=None): super(TimeSelecterPopup, self).__init__(parent) self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised) self.setWindowFlags(QtCore.Qt.Popup) self.seconds = None self.label = QtGui.QLabel("") canvas_frame = QtGui.QFrame() canvas_frame.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken) canvas = Canvas(width, height) layout = QtGui.QVBoxLayout() layout.setSpacing(2) layout.setContentsMargins(2, 2, 2, 2) layout.addWidget(canvas) canvas_frame.setLayout(layout) create_pane([self.label, canvas_frame], False, compact=True, parent_widget=self) self.adjustSize() pt = pivot_widget.rect().topLeft() global_pt = pivot_widget.mapToGlobal(pt) self.move(global_pt - QtCore.QPoint(0, self.height())) canvas.secondsHover.connect(self._secondsHover) canvas.secondsClicked.connect(self._secondsClicked)
def __init__(self, pivot_widget, width=240, height=160, parent=None): super(TimeSelecterPopup, self).__init__(parent) self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised) self.setWindowFlags(QtCore.Qt.Popup) self.seconds = None self.label = QtWidgets.QLabel("") canvas_frame = QtWidgets.QFrame() canvas_frame.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken) canvas = Canvas(width, height) layout = QtWidgets.QVBoxLayout() layout.setSpacing(2) layout.setContentsMargins(2, 2, 2, 2) layout.addWidget(canvas) canvas_frame.setLayout(layout) create_pane([self.label, canvas_frame], False, compact=True, parent_widget=self) self.adjustSize() pt = pivot_widget.rect().topLeft() global_pt = pivot_widget.mapToGlobal(pt) self.move(global_pt - QtCore.QPoint(0, self.height())) canvas.secondsHover.connect(self._secondsHover) canvas.secondsClicked.connect(self._secondsClicked)
def __init__(self, pivot_widget, pivot_position=None, words=None, initial_word=None, close_on_find=True, parent=None): super(FindPopup, self).__init__(parent) self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Raised) self.setWindowFlags(QtCore.Qt.Popup) self.close_on_find = close_on_find self.edit = QtWidgets.QLineEdit() self.btn = QtWidgets.QPushButton("Find") create_pane([self.edit, self.btn], True, compact=True, compact_spacing=0, parent_widget=self) self.edit.setFocus() if initial_word: self.edit.setText(initial_word) self.edit.selectAll() self.completer = None if words: self.completer = QtWidgets.QCompleter(self) self.completer.setCompletionMode(QtWidgets.QCompleter.PopupCompletion) self.completions = QtCore.QStringListModel(words, self.completer) self.completer.setModel(self.completions) self.edit.setCompleter(self.completer) pt = getattr(pivot_widget.rect(), pivot_position)() global_pt = pivot_widget.mapToGlobal(pt) self.move(global_pt) self.btn.clicked.connect(self._find) self.edit.returnPressed.connect(self._find) find_shortcut = QtWidgets.QShortcut(QtGui.QKeySequence("Ctrl+F"), self) find_shortcut.activated.connect(self._find_again)
def __init__(self, context_model, variant, reference_variant=None, hide_locks=False, read_only=False, parent=None): super(VariantCellWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.variant = variant self.reference_variant = reference_variant self.stale = False self.lock_status = None self.lock_icon = None self.hide_locks = hide_locks self.read_only = read_only self.icons = [] # 3-tuples: widget, name, tooltip qname = self.variant.qualified_package_name self.label = QtGui.QLabel(qname) desc = "%s@%s" % (qname, self.variant.wrapped.location) self.label.setToolTip(desc) self.depends_icon = get_icon_widget("depends", "dependent package") self.depends_icon.hide() create_pane([self.label, self.depends_icon, None], True, compact=True, parent_widget=self) self.refresh()
def __init__(self, pivot_widget, pivot_position=None, words=None, initial_word=None, close_on_find=True, parent=None): super(FindPopup, self).__init__(parent) self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised) self.setWindowFlags(QtCore.Qt.Popup) self.close_on_find = close_on_find self.edit = QtGui.QLineEdit() self.btn = QtGui.QPushButton("Find") create_pane([self.edit, self.btn], True, compact=True, compact_spacing=0, parent_widget=self) self.edit.setFocus() if initial_word: self.edit.setText(initial_word) self.edit.selectAll() self.completer = None if words: self.completer = QtGui.QCompleter(self) self.completer.setCompletionMode(QtGui.QCompleter.PopupCompletion) self.completions = QtGui.QStringListModel(words, self.completer) self.completer.setModel(self.completions) self.edit.setCompleter(self.completer) pt = getattr(pivot_widget.rect(), pivot_position)() global_pt = pivot_widget.mapToGlobal(pt) self.move(global_pt) self.btn.clicked.connect(self._find) self.edit.returnPressed.connect(self._find) find_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self) find_shortcut.activated.connect(self._find_again)
def __init__(self, process, command_string, parent=None): config_key = "layout/window/process" super(ProcessDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Running: %s" % command_string) self.proc = process self.ended = False self.output_ended = False self.capture_output = True self.buffer = [] self.bar = QtGui.QProgressBar() self.bar.setRange(0, 0) self.edit = StreamableTextEdit() close_btn = QtGui.QPushButton("Close") btn_pane = create_pane([None, close_btn], True) create_pane([self.bar, self.edit, btn_pane], False, parent_widget=self) self.lock = Lock() self.stdout_thread = Thread(target=self._read_output, args=(self.proc.stdout,)) self.stderr_thread = Thread(target=self._read_output, args=(self.proc.stderr,)) self.timer = QtCore.QTimer() self.timer.setInterval(100) self.timer.timeout.connect(self._update) self.timer.start() self.stdout_thread.start() self.stderr_thread.start() close_btn.clicked.connect(self.close)
def __init__(self, help_, index, parent=None): super(HelpEntryWidget, self).__init__(parent) self.help_ = help_ self.index = index icon = get_icon_widget("help") label = self.help_.sections[self.index][0] label_widget = QtGui.QLabel(label) self.setCursor(QtCore.Qt.PointingHandCursor) create_pane([icon, label_widget, None], True, compact=True, parent_widget=self)
def __init__(self, context_model=None, reference_variant=None, in_window=False, parent=None): """ Args: reference_variant (`Variant`): Used to show the difference between two variants. in_window (bool): If True, the 'view changelogs' option turns into a checkbox, dropping the 'View in window' option. """ super(VariantVersionsWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.in_window = in_window self.variant = None self.reference_variant = reference_variant self.pending_changelog_packages = None self.label = QtGui.QLabel() self.changelog_edit = ChangelogEdit() self.table = VariantVersionsTable(self.context_model, reference_variant=reference_variant) self.tab = QtGui.QTabWidget() self.tab.addTab(self.table, "list view") self.tab.addTab(self.changelog_edit, "changelogs") self.tab.currentChanged.connect(self._tabIndexChanged) buttons = [None] if self.in_window: close_btn = QtGui.QPushButton("Close") buttons.append(close_btn) close_btn.clicked.connect(self._close_window) else: browse_versions_btn = QtGui.QPushButton("Browse Versions...") browse_versions_btn.clicked.connect(self._browseVersions) buttons.append(browse_versions_btn) window_btn = QtGui.QPushButton("View In Window...") window_btn.clicked.connect(self._view_changelogs_window) buttons.append(window_btn) btn_pane = create_pane(buttons, True, compact=not self.in_window) pane = create_pane([self.label, self.tab, btn_pane], False, compact=True) self.set_main_widget(pane) self.set_loader_swap_delay(300) self.clear()
def __init__(self, context_model=None, parent=None): super(VariantDetailsWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.variant = None self.edit = StreamableTextEdit() self.edit.setStyleSheet("font: 9pt 'Courier'") self.view_graph_btn = ViewGraphButton(context_model) self._update_graph_btn_visibility() btn_pane = create_pane([None, self.view_graph_btn], True, compact=True) create_pane([self.edit, btn_pane], False, compact=True, parent_widget=self) self.clear()
def __init__(self, help_, index, parent=None): super(HelpEntryWidget, self).__init__(parent) self.help_ = help_ self.index = index icon = get_icon_widget("help") label = self.help_.sections[self.index][0] label_widget = QtWidgets.QLabel(label) self.setCursor(QtCore.Qt.PointingHandCursor) create_pane([icon, label_widget, None], True, compact=True, parent_widget=self)
def __init__(self, parent=None): super(PackageLoadingWidget, self).__init__(parent) self.main_widget = None self.worker = None self.swap_delay = 0 self.threads = [] self.timer = None label = QtGui.QLabel("Loading Packages...") self.bar = QtGui.QProgressBar() self.loading_widget = create_pane([label, self.bar, None], False, compact=True) create_pane([self.loading_widget], True, compact=True, compact_spacing=0, parent_widget=self)
def __init__(self, image_file, parent=None): config_key = "layout/window/resolve_graph" super(ImageViewerDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Resolve Graph") self.image_viewer = ImageViewerWidget(image_file) close_btn = QtGui.QPushButton("Close") fit_checkbox = QtGui.QCheckBox("Fit to window") btn_pane = create_pane([None, fit_checkbox, 10, close_btn], True) create_pane([(self.image_viewer, 1), btn_pane], False, parent_widget=self) close_btn.clicked.connect(self.close) fit_checkbox.stateChanged.connect(self.image_viewer.fit_to_window) app.config.attach(fit_checkbox, "resolve/fit_graph")
def __init__(self, request, type_, parent=None): super(EffectivePackageCellWidget, self).__init__(parent) if type_ == "implicit": icon_name = "cog" tooltip = "implicit package" else: icon_name = type_ tooltip = PatchLock[type_].description icon_widget = get_icon_widget(icon_name, tooltip) label = QtWidgets.QLabel(str(request)) update_font(label, italic=True) create_pane([icon_widget, (label, 1)], True, parent_widget=self, compact=True) self.setEnabled(False) # this widget always disabled by design
def __init__(self, request, type_, parent=None): super(EffectivePackageCellWidget, self).__init__(parent) if type_ == "implicit": icon_name = "cog" tooltip = "implicit package" else: icon_name = type_ tooltip = PatchLock[type_].description icon_widget = get_icon_widget(icon_name, tooltip) label = QtGui.QLabel(str(request)) update_font(label, italic=True) create_pane([icon_widget, (label, 1)], True, parent_widget=self, compact=True) self.setEnabled(False) # this widget always disabled by design
def __init__(self, graph_str, filepath, parent=None, prune_to=None): super(WriteGraphDialog, self).__init__(parent) self.setWindowTitle("Rendering graph...") self.writer = Writer(graph_str, filepath, prune_to) self.thread = None self._finished = False self.success = False self.busy_cursor = QtGui.QCursor(QtCore.Qt.WaitCursor) self.bar = QtGui.QProgressBar() self.bar.setRange(0, 0) self.cancel_btn = QtGui.QPushButton("Cancel") pane = create_pane([None, self.cancel_btn], True) create_pane([self.bar, pane], False, parent_widget=self) self.writer.graph_written.connect(self._graph_written) self.cancel_btn.clicked.connect(self._cancel)
def __init__(self, image_file, parent=None): super(ImageViewerWidget, self).__init__(parent) self.fit = False self.prev_scale = 1.0 self.scene = QtGui.QGraphicsScene() image = QtGui.QPixmap(image_file) self.image_item = self.scene.addPixmap(image) self.image_item.setTransformationMode(QtCore.Qt.SmoothTransformation) npix = max(image.width(), image.height()) max_scale = npix / 200.0 self.view = GraphicsView(self.scene, max_scale=max_scale) create_pane([self.view], False, parent_widget=self) self.view.setRenderHints(QtGui.QPainter.Antialiasing | QtGui.QPainter.SmoothPixmapTransform) self.view.show() self._fit_in_view()
def __init__(self, graph_str, filepath, parent=None, prune_to=None): super(WriteGraphDialog, self).__init__(parent) self.setWindowTitle("Rendering graph...") self.writer = Writer(graph_str, filepath, prune_to) self.thread = None self._finished = False self.success = False self.busy_cursor = QtGui.QCursor(QtCore.Qt.WaitCursor) self.bar = QtWidgets.QProgressBar() self.bar.setRange(0, 0) self.cancel_btn = QtWidgets.QPushButton("Cancel") pane = create_pane([None, self.cancel_btn], True) create_pane([self.bar, pane], False, parent_widget=self) self.writer.graph_written.connect(self._graph_written) self.cancel_btn.clicked.connect(self._cancel)
def __init__(self, parent=None): super(PackageLoadingWidget, self).__init__(parent) self.main_widget = None self.worker = None self.swap_delay = 0 self.threads = [] self.timer = None label = QtWidgets.QLabel("Loading Packages...") self.bar = QtWidgets.QProgressBar() self.loading_widget = create_pane([label, self.bar, None], False, compact=True) create_pane([self.loading_widget], True, compact=True, compact_spacing=0, parent_widget=self)
def __init__(self, parent=None): super(VariantSummaryWidget, self).__init__(parent) self.variant = None self.label = QtGui.QLabel() self.table = QtGui.QTableWidget(0, 1) self.table.setGridStyle(QtCore.Qt.DotLine) self.table.setFocusPolicy(QtCore.Qt.NoFocus) self.table.setSelectionMode(QtGui.QAbstractItemView.NoSelection) self.table.setAlternatingRowColors(True) hh = self.table.horizontalHeader() hh.setStretchLastSection(True) hh.setVisible(False) vh = self.table.verticalHeader() vh.setResizeMode(QtGui.QHeaderView.ResizeToContents) create_pane([self.label, self.table], False, compact=True, parent_widget=self) self.clear()
def __init__(self, parent=None): super(AboutDialog, self).__init__(parent) self.setWindowTitle("About Rez") version = Version(__version__) public_version = version.trim(2) label = QtGui.QLabel( "<font size='+2'><b>Rez version %s</b></font><br><br>" "Build version %s." % (str(public_version), str(version))) close_btn = QtGui.QPushButton("Close") github_btn = QtGui.QPushButton("Github") github_icon = get_icon("github_32", as_qicon=True) github_btn.setIcon(github_icon) btn_pane = create_pane([None, github_btn, close_btn], True, compact=True) create_pane([label, None, btn_pane], False, parent_widget=self) github_btn.clicked.connect(self._goto_github) close_btn.clicked.connect(self.close) close_btn.setFocus()
def __init__(self, context_model=None, parent=None): super(ContextDetailsWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.code_pending = True self.overview_edit = StreamableTextEdit() self.overview_edit.setStyleSheet("font: 12pt 'Courier'") self.graph_btn = ViewGraphButton(context_model) btn_pane = create_pane([None, self.graph_btn], True) overview_pane = create_pane([self.overview_edit, btn_pane], False) self.code_edit = SearchableTextEdit() self.code_edit.setStyleSheet("font: 12pt 'Courier'") self.code_combo = QtWidgets.QComboBox() # strip out 'sh' and 'csh', they only differ from bash and tcsh in shell # startup behaviour, which is irrelevant here code_types = set(get_shell_types()) - set([system.shell, "sh", "csh"]) code_types = [system.shell] + sorted(code_types) + ["python dict"] for code_type in code_types: self.code_combo.addItem(code_type) label = QtWidgets.QLabel("Format:") btn_pane = create_pane([None, label, self.code_combo], True) code_pane = create_pane([self.code_edit, btn_pane], False) self.environ_widget = ContextEnvironWidget() self.addTab(overview_pane, "overview") self.addTab(code_pane, "shell code") self.addTab(self.environ_widget, "environment") self.code_combo.currentIndexChanged.connect(self._update_code) self.currentChanged.connect(self._currentTabChanged) self.refresh()
def __init__(self, context_model=None, parent=None): super(ContextDetailsWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.code_pending = True self.overview_edit = StreamableTextEdit() self.overview_edit.setStyleSheet("font: 9pt 'Courier'") self.graph_btn = ViewGraphButton(context_model) btn_pane = create_pane([None, self.graph_btn], True) overview_pane = create_pane([self.overview_edit, btn_pane], False) self.code_edit = SearchableTextEdit() self.code_edit.setStyleSheet("font: 9pt 'Courier'") self.code_combo = QtGui.QComboBox() # strip out 'sh' and 'csh', they only differ from bash and tcsh in shell # startup behaviour, which is irrelevant here code_types = set(get_shell_types()) - set([system.shell, "sh", "csh"]) code_types = [system.shell] + sorted(code_types) + ["python dict"] for code_type in code_types: self.code_combo.addItem(code_type) label = QtGui.QLabel("Format:") btn_pane = create_pane([None, label, self.code_combo], True) code_pane = create_pane([self.code_edit, btn_pane], False) self.environ_widget = ContextEnvironWidget() self.addTab(overview_pane, "overview") self.addTab(code_pane, "shell code") self.addTab(self.environ_widget, "environment") self.code_combo.currentIndexChanged.connect(self._update_code) self.currentChanged.connect(self._currentTabChanged) self.refresh()
def __init__(self, context_model, parent=None): super(TimestampWidget, self).__init__(parent) self.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken) self.context_model = context_model self.popup = None self.package_btn = IconButton("package", "select package release date") self.clock_btn = IconButton("clock", "select time in the past") self.checkbox = QtGui.QCheckBox("ignore packages released after:") pane = create_pane([None, self.checkbox, self.package_btn, self.clock_btn], True, compact=True) self.edit = QtGui.QDateTimeEdit() self.edit.setCalendarPopup(True) self.edit.setDateTime(QtCore.QDateTime.currentDateTime()) create_pane([pane, self.edit], False, compact=True, parent_widget=self) self.checkbox.stateChanged.connect(self._stateChanged) self.package_btn.clicked.connect(self._selectPackage) self.clock_btn.clicked.connect(self._selectTime) self.refresh()
def __init__(self, context_model, parent=None): super(TimestampWidget, self).__init__(parent) self.setFrameStyle(QtWidgets.QFrame.Panel | QtWidgets.QFrame.Sunken) self.context_model = context_model self.popup = None self.package_btn = IconButton("package", "select package release date") self.clock_btn = IconButton("clock", "select time in the past") self.checkbox = QtWidgets.QCheckBox("ignore packages released after:") pane = create_pane( [None, self.checkbox, self.package_btn, self.clock_btn], True, compact=True) self.edit = QtWidgets.QDateTimeEdit() self.edit.setCalendarPopup(True) self.edit.setDateTime(QtCore.QDateTime.currentDateTime()) create_pane([pane, self.edit], False, compact=True, parent_widget=self) self.checkbox.stateChanged.connect(self._stateChanged) self.package_btn.clicked.connect(self._selectPackage) self.clock_btn.clicked.connect(self._selectTime) self.refresh()
def __init__(self, parent=None): super(ContextEnvironWidget, self).__init__(parent) self.table = ContextEnvironTable() self.split_combo = QtGui.QComboBox() for label, _ in self.split_entries: self.split_combo.addItem(label) label = QtGui.QLabel("split values by:") btn_pane = create_pane([None, label, self.split_combo], True) self.layout = QtGui.QVBoxLayout() self.layout.addWidget(self.table) self.layout.addWidget(btn_pane) self.setLayout(self.layout) self.split_combo.currentIndexChanged.connect(self._set_split_char) app.config.attach(self.split_combo, "split_char")
def __init__(self, context_model, package_text=None, parent=None, close_only=False, lock_package=False, package_selectable_callback=None): config_key = "layout/window/browse_package" super(BrowsePackageDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Find Package") self.package = None self.widget = BrowsePackageWidget( context_model, self, lock_package=lock_package, package_selectable_callback=package_selectable_callback) self.ok_btn = QtWidgets.QPushButton("Ok") buttons = [self.ok_btn] if close_only: close_btn = QtWidgets.QPushButton("Close") buttons.insert(0, close_btn) close_btn.clicked.connect(self.close) self.ok_btn.hide() else: cancel_btn = QtWidgets.QPushButton("Cancel") cancel_btn.clicked.connect(self.close) buttons.insert(0, cancel_btn) self.ok_btn.setEnabled(False) btn_pane = create_pane([None] + buttons, True) layout = QtWidgets.QVBoxLayout() layout.addWidget(self.widget) layout.addWidget(btn_pane) self.setLayout(layout) self.ok_btn.clicked.connect(self._ok) self.widget.packageSelected.connect(self._set_package) self.widget.set_package_text(package_text)
def __init__(self, context_model=None, parent=None): super(VariantHelpWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.variant = None self.help_1 = None self.help_2 = None self.table_1 = self._create_table() self.table_2 = self._create_table() self.tab = QtGui.QTabWidget() self.tab.addTab(self.table_1, "latest help") self.tab.addTab(self.table_2, "help") self.no_help_label = QtGui.QLabel("No help found.") self.no_help_label.setAlignment(QtCore.Qt.AlignCenter) pane = create_pane([self.no_help_label, self.tab], False, compact=True) self.set_main_widget(pane) self.set_loader_swap_delay(300) self.clear()
def __init__(self, context_model=None, parent=None): super(VariantHelpWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.variant = None self.help_1 = None self.help_2 = None self.table_1 = self._create_table() self.table_2 = self._create_table() self.tab = QtWidgets.QTabWidget() self.tab.addTab(self.table_1, "latest help") self.tab.addTab(self.table_2, "help") self.no_help_label = QtWidgets.QLabel("No help found.") self.no_help_label.setAlignment(QtCore.Qt.AlignCenter) pane = create_pane([self.no_help_label, self.tab], False, compact=True) self.set_main_widget(pane) self.set_loader_swap_delay(300) self.clear()
def __init__(self, context_model=None, attributes=None, parent=None): """ Args: attributes (list of str): Select only certain settings to expose. If None, all settings are exposed. """ super(ContextSettingsWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.schema_keys = set(self.schema_dict.iterkeys()) if attributes: self.schema_keys &= set(attributes) assert self.schema_keys schema_dict = dict((k, v) for k, v in self.schema_dict.iteritems() if k in self.schema_keys) self.schema = Schema(schema_dict) self.edit = QtGui.QTextEdit() self.edit.setStyleSheet("font: 12pt 'Courier'") self.default_btn = QtGui.QPushButton("Set To Defaults") self.discard_btn = QtGui.QPushButton("Discard Changes...") self.apply_btn = QtGui.QPushButton("Apply") self.discard_btn.setEnabled(False) self.apply_btn.setEnabled(False) btn_pane = create_pane([None, self.default_btn, self.discard_btn, self.apply_btn], True) layout = QtGui.QVBoxLayout() layout.addWidget(self.edit) layout.addWidget(btn_pane) self.setLayout(layout) self.apply_btn.clicked.connect(self.apply_changes) self.default_btn.clicked.connect(self.set_defaults) self.discard_btn.clicked.connect(partial(self.discard_changes, True)) self.edit.textChanged.connect(self._settingsChanged) self._update_text()
def __init__(self, context_model=None, attributes=None, parent=None): """ Args: attributes (list of str): Select only certain settings to expose. If None, all settings are exposed. """ super(ContextSettingsWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) self.schema_keys = set(self.schema_dict.iterkeys()) if attributes: self.schema_keys &= set(attributes) assert self.schema_keys schema_dict = dict((k, v) for k, v in self.schema_dict.iteritems() if k in self.schema_keys) self.schema = Schema(schema_dict) self.edit = QtGui.QTextEdit() self.edit.setStyleSheet("font: 9pt 'Courier'") self.default_btn = QtGui.QPushButton("Set To Defaults") self.discard_btn = QtGui.QPushButton("Discard Changes...") self.apply_btn = QtGui.QPushButton("Apply") self.discard_btn.setEnabled(False) self.apply_btn.setEnabled(False) btn_pane = create_pane([None, self.default_btn, self.discard_btn, self.apply_btn], True) layout = QtGui.QVBoxLayout() layout.addWidget(self.edit) layout.addWidget(btn_pane) self.setLayout(layout) self.apply_btn.clicked.connect(self.apply_changes) self.default_btn.clicked.connect(self.set_defaults) self.discard_btn.clicked.connect(partial(self.discard_changes, True)) self.edit.textChanged.connect(self._settingsChanged) self._update_text()
def __init__(self, context_model, package_text=None, parent=None, close_only=False, lock_package=False, package_selectable_callback=None): config_key = "layout/window/browse_package" super(BrowsePackageDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Find Package") self.package = None self.widget = BrowsePackageWidget( context_model, self, lock_package=lock_package, package_selectable_callback=package_selectable_callback) self.ok_btn = QtGui.QPushButton("Ok") buttons = [self.ok_btn] if close_only: close_btn = QtGui.QPushButton("Close") buttons.insert(0, close_btn) close_btn.clicked.connect(self.close) self.ok_btn.hide() else: cancel_btn = QtGui.QPushButton("Cancel") cancel_btn.clicked.connect(self.close) buttons.insert(0, cancel_btn) self.ok_btn.setEnabled(False) btn_pane = create_pane([None] + buttons, True) layout = QtGui.QVBoxLayout() layout.addWidget(self.widget) layout.addWidget(btn_pane) self.setLayout(layout) self.ok_btn.clicked.connect(self._ok) self.widget.packageSelected.connect(self._set_package) self.widget.set_package_text(package_text)
def __init__(self, context_model, parent=None, advanced=False): config_key = ("layout/window/advanced_resolve" if advanced else "layout/window/resolve") super(ResolveDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Resolve") self.setContentsMargins(0, 0, 0, 0) self.context_model = context_model self.advanced = advanced self.resolver = None self.thread = None self.started = False self._finished = False self.busy_cursor = QtGui.QCursor(QtCore.Qt.WaitCursor) self.edit = StreamableTextEdit() self.edit.setStyleSheet("font: 9pt 'Courier'") self.bar = QtGui.QProgressBar() self.bar.setRange(0, 10) self.save_context_btn = QtGui.QPushButton("Save Context As...") self.graph_btn = QtGui.QPushButton("View Graph...") self.ok_btn = QtGui.QPushButton("Ok") self.start_again_btn = QtGui.QPushButton("Start Again") self.cancel_btn = QtGui.QPushButton("Cancel") self.resolve_btn = QtGui.QPushButton("Resolve") self.ok_btn.hide() self.graph_btn.hide() self.start_again_btn.hide() self.save_context_btn.hide() btn_pane = create_pane([None, self.save_context_btn, self.graph_btn, self.start_again_btn, self.ok_btn, self.cancel_btn, self.resolve_btn], not self.advanced) layout = QtGui.QVBoxLayout() layout.addWidget(self.bar) layout.addWidget(self.edit, 1) self.resolve_group = None self.max_fails_combo = None self.verbosity_combo = None self.show_package_loads_checkbox = None # this is solely to execute _start_resolve() as soon as the dialog opens self.timer = QtCore.QTimer() self.timer.setInterval(1) self.timer.setSingleShot(True) self.timer.timeout.connect(self._on_dialog_open) if self.advanced: self.resolve_group = QtGui.QGroupBox("resolve settings") label = QtGui.QLabel("maximum fails:") self.max_fails_combo = QtGui.QComboBox() self.max_fails_combo.setEditable(True) self.max_fails_combo.addItem("-") self.max_fails_combo.addItem("1") self.max_fails_combo.addItem("2") self.max_fails_combo.addItem("3") app.config.attach(self.max_fails_combo, "resolve/max_fails") max_fails_pane = create_pane([None, label, self.max_fails_combo], True) label = QtGui.QLabel("verbosity:") self.verbosity_combo = QtGui.QComboBox() self.verbosity_combo.addItem("0") self.verbosity_combo.addItem("1") self.verbosity_combo.addItem("2") app.config.attach(self.verbosity_combo, "resolve/verbosity") verbosity_pane = create_pane([None, label, self.verbosity_combo], True) self.show_package_loads_checkbox = QtGui.QCheckBox("show package loads") self.show_package_loads_checkbox.setLayoutDirection(QtCore.Qt.RightToLeft) app.config.attach(self.show_package_loads_checkbox, "resolve/show_package_loads") show_loads_pane = create_pane([None, self.show_package_loads_checkbox], True) self.timestamp_widget = TimestampWidget(self.context_model) context = self.context_model.context() if context and context.requested_timestamp: self.timestamp_widget.set_time(context.requested_timestamp) left_pane = create_pane([self.timestamp_widget, None], False, compact=True) right_pane = create_pane([max_fails_pane, verbosity_pane, show_loads_pane, None], False, compact=True) create_pane([left_pane, right_pane], True, parent_widget=self.resolve_group) pane = create_pane([self.resolve_group, None, btn_pane], True) self.cancel_btn.hide() layout.addWidget(pane) else: self.resolve_btn.hide() layout.addWidget(btn_pane) self.setLayout(layout) self.cancel_btn.clicked.connect(self._cancel_resolve) self.resolve_btn.clicked.connect(self._start_resolve) self.graph_btn.clicked.connect(self._view_graph) self.save_context_btn.clicked.connect(self._save_context) self.start_again_btn.clicked.connect(self._reset) self.ok_btn.clicked.connect(self.close)
def __init__(self, context_model=None, parent=None): super(ContextManagerWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) # widgets self.popup = None self.context_table = ContextTableWidget(self.context_model) self.show_effective_request_checkbox = QtGui.QCheckBox("show effective request") resolve_time_label = ContextResolveTimeLabel(self.context_model) self.time_lock_tbtn = QtGui.QToolButton() icon = get_icon("time_lock", as_qicon=True) self.time_lock_tbtn.setIcon(icon) self.find_tbtn = QtGui.QToolButton() self.find_tbtn.setToolTip("find resolved package") icon = get_icon("find", as_qicon=True) self.find_tbtn.setIcon(icon) self.shell_tbtn = QtGui.QToolButton() self.shell_tbtn.setToolTip("open shell") icon = get_icon("terminal", as_qicon=True) self.shell_tbtn.setIcon(icon) self.diff_tbtn = QtGui.QToolButton() self.diff_tbtn.setToolTip("enter diff mode") self.diff_tbtn.setPopupMode(QtGui.QToolButton.MenuButtonPopup) self.diff_menu = QtGui.QMenu() self.diff_action = add_menu_action( self.diff_menu, "Diff Against Current", self._diff_with_last_resolve, "diff") self.diff_to_disk_action = add_menu_action( self.diff_menu, "Diff Against Disk", self._diff_with_disk, "diff_to_disk") self.diff_to_other_action = add_menu_action( self.diff_menu, "Diff Against Other...", self._diff_with_other, "diff_to_other") self.diff_tbtn.setMenu(self.diff_menu) self.diff_tbtn.setDefaultAction(self.diff_action) self.undiff_tbtn = QtGui.QToolButton() self.undiff_tbtn.setToolTip("leave diff mode") icon = get_icon("diff", as_qicon=True) self.undiff_tbtn.setIcon(icon) self.undiff_tbtn.setCheckable(True) self.lock_tbtn = QtGui.QToolButton() self.lock_tbtn.setToolTip("locking") icon = get_icon("no_lock", as_qicon=True) self.lock_tbtn.setIcon(icon) self.lock_tbtn.setPopupMode(QtGui.QToolButton.InstantPopup) menu = QtGui.QMenu() for lock_type in PatchLock: fn = partial(self._set_lock_type, lock_type) add_menu_action(menu, lock_type.description, fn, lock_type.name) menu.addSeparator() add_menu_action(menu, "Remove Explicit Locks", self._removeExplicitLocks) self.lock_tbtn.setMenu(menu) self.revert_tbtn = QtGui.QToolButton() self.revert_tbtn.setToolTip("revert") icon = get_icon("revert", as_qicon=True) self.revert_tbtn.setIcon(icon) self.revert_tbtn.setPopupMode(QtGui.QToolButton.InstantPopup) self.revert_menu = QtGui.QMenu() self.revert_action = add_menu_action( self.revert_menu, "Revert To Last Resolve...", self._revert_to_last_resolve, "revert") self.revert_diff_action = add_menu_action( self.revert_menu, "Revert To Reference...", self._revert_to_diff, "revert_to_diff") self.revert_disk_action = add_menu_action( self.revert_menu, "Revert To Disk...", self._revert_to_disk, "revert_to_disk") self.revert_tbtn.setMenu(self.revert_menu) resolve_tbtn = QtGui.QToolButton() resolve_tbtn.setPopupMode(QtGui.QToolButton.MenuButtonPopup) menu = QtGui.QMenu() default_resolve_action = add_menu_action(menu, "Resolve", self._resolve, "resolve") add_menu_action(menu, "Advanced Resolve...", partial(self._resolve, advanced=True), "advanced_resolve") resolve_tbtn.setDefaultAction(default_resolve_action) resolve_tbtn.setMenu(menu) toolbar = QtGui.QToolBar() toolbar.addWidget(resolve_time_label) self.time_lock_tbtn_action = toolbar.addWidget(self.time_lock_tbtn) toolbar.addSeparator() toolbar.addWidget(self.find_tbtn) toolbar.addWidget(self.shell_tbtn) self.diff_tbtn_action = toolbar.addWidget(self.diff_tbtn) self.undiff_tbtn_action = toolbar.addWidget(self.undiff_tbtn) toolbar.addWidget(self.lock_tbtn) toolbar.addWidget(self.revert_tbtn) toolbar.addWidget(resolve_tbtn) self.time_lock_tbtn_action.setVisible(False) self.undiff_tbtn_action.setVisible(False) self.time_lock_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.find_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.shell_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.diff_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.lock_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.revert_tbtn.setCursor(QtCore.Qt.PointingHandCursor) resolve_tbtn.setCursor(QtCore.Qt.PointingHandCursor) btn_pane = create_pane([self.show_effective_request_checkbox, None, toolbar], True, compact=True, compact_spacing=0) context_pane = create_pane([btn_pane, self.context_table], False, compact=True, compact_spacing=0) self.package_tab = PackageTabWidget( self.context_model, versions_tab=True) context_splitter = ConfiguredSplitter(app.config, "layout/splitter/main") context_splitter.setOrientation(QtCore.Qt.Vertical) context_splitter.addWidget(context_pane) context_splitter.addWidget(self.package_tab) if not context_splitter.apply_saved_layout(): context_splitter.setStretchFactor(0, 2) context_splitter.setStretchFactor(1, 1) self.settings = ContextSettingsWidget(self.context_model) self.tools_list = ContextToolsWidget(self.context_model) self.resolve_details = ContextDetailsWidget(self.context_model) self.tab = QtGui.QTabWidget() icon = get_icon("context", as_qicon=True) self.tab.addTab(context_splitter, icon, "context") icon = get_icon("context_settings", as_qicon=True) self.tab.addTab(self.settings, icon, "settings") icon = get_icon("tools", as_qicon=True) self.tab.addTab(self.tools_list, icon, "tools") icon = get_icon("info", as_qicon=True) self.tab.addTab(self.resolve_details, icon, "resolve details") self.tab.setTabEnabled(2, False) self.tab.setTabEnabled(3, False) # layout layout = QtGui.QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.tab) self.setLayout(layout) # shortcuts find_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self) find_shortcut.activated.connect(self._search) # widget signals self.context_table.variantSelected.connect(self._variantSelected) self.find_tbtn.clicked.connect(self._search_variant) self.shell_tbtn.clicked.connect(self._open_shell) self.undiff_tbtn.clicked.connect(self._leave_diff_mode) self.time_lock_tbtn.clicked.connect(self._timelockClicked) self.tools_list.toolsChanged.connect(self._updateToolsCount) self.diff_menu.aboutToShow.connect(self._aboutToShowDiffMenu) self.revert_menu.aboutToShow.connect(self._aboutToShowRevertMenu) self.show_effective_request_checkbox.stateChanged.connect( self._effectiveRequestStateChanged) self.refresh() self._updateToolsCount()
def __init__(self, context_model=None, parent=None): super(ContextManagerWidget, self).__init__(parent) ContextViewMixin.__init__(self, context_model) # widgets self.popup = None self.context_table = ContextTableWidget(self.context_model) self.show_effective_request_checkbox = QtGui.QCheckBox( "show effective request") resolve_time_label = ContextResolveTimeLabel(self.context_model) self.time_lock_tbtn = QtGui.QToolButton() icon = get_icon("time_lock", as_qicon=True) self.time_lock_tbtn.setIcon(icon) self.find_tbtn = QtGui.QToolButton() self.find_tbtn.setToolTip("find resolved package") icon = get_icon("find", as_qicon=True) self.find_tbtn.setIcon(icon) self.shell_tbtn = QtGui.QToolButton() self.shell_tbtn.setToolTip("open shell") icon = get_icon("terminal", as_qicon=True) self.shell_tbtn.setIcon(icon) self.diff_tbtn = QtGui.QToolButton() self.diff_tbtn.setToolTip("enter diff mode") self.diff_tbtn.setPopupMode(QtGui.QToolButton.MenuButtonPopup) self.diff_menu = QtGui.QMenu() self.diff_action = add_menu_action(self.diff_menu, "Diff Against Current", self._diff_with_last_resolve, "diff") self.diff_to_disk_action = add_menu_action(self.diff_menu, "Diff Against Disk", self._diff_with_disk, "diff_to_disk") self.diff_to_other_action = add_menu_action(self.diff_menu, "Diff Against Other...", self._diff_with_other, "diff_to_other") self.diff_tbtn.setMenu(self.diff_menu) self.diff_tbtn.setDefaultAction(self.diff_action) self.undiff_tbtn = QtGui.QToolButton() self.undiff_tbtn.setToolTip("leave diff mode") icon = get_icon("diff", as_qicon=True) self.undiff_tbtn.setIcon(icon) self.undiff_tbtn.setCheckable(True) self.lock_tbtn = QtGui.QToolButton() self.lock_tbtn.setToolTip("locking") icon = get_icon("no_lock", as_qicon=True) self.lock_tbtn.setIcon(icon) self.lock_tbtn.setPopupMode(QtGui.QToolButton.InstantPopup) menu = QtGui.QMenu() for lock_type in PatchLock: fn = partial(self._set_lock_type, lock_type) add_menu_action(menu, lock_type.description, fn, lock_type.name) menu.addSeparator() add_menu_action(menu, "Remove Explicit Locks", self._removeExplicitLocks) self.lock_tbtn.setMenu(menu) self.revert_tbtn = QtGui.QToolButton() self.revert_tbtn.setToolTip("revert") icon = get_icon("revert", as_qicon=True) self.revert_tbtn.setIcon(icon) self.revert_tbtn.setPopupMode(QtGui.QToolButton.InstantPopup) self.revert_menu = QtGui.QMenu() self.revert_action = add_menu_action(self.revert_menu, "Revert To Last Resolve...", self._revert_to_last_resolve, "revert") self.revert_diff_action = add_menu_action(self.revert_menu, "Revert To Reference...", self._revert_to_diff, "revert_to_diff") self.revert_disk_action = add_menu_action(self.revert_menu, "Revert To Disk...", self._revert_to_disk, "revert_to_disk") self.revert_tbtn.setMenu(self.revert_menu) resolve_tbtn = QtGui.QToolButton() resolve_tbtn.setPopupMode(QtGui.QToolButton.MenuButtonPopup) menu = QtGui.QMenu() default_resolve_action = add_menu_action(menu, "Resolve", self._resolve, "resolve") add_menu_action(menu, "Advanced Resolve...", partial(self._resolve, advanced=True), "advanced_resolve") resolve_tbtn.setDefaultAction(default_resolve_action) resolve_tbtn.setMenu(menu) toolbar = QtGui.QToolBar() toolbar.addWidget(resolve_time_label) self.time_lock_tbtn_action = toolbar.addWidget(self.time_lock_tbtn) toolbar.addSeparator() toolbar.addWidget(self.find_tbtn) toolbar.addWidget(self.shell_tbtn) self.diff_tbtn_action = toolbar.addWidget(self.diff_tbtn) self.undiff_tbtn_action = toolbar.addWidget(self.undiff_tbtn) toolbar.addWidget(self.lock_tbtn) toolbar.addWidget(self.revert_tbtn) toolbar.addWidget(resolve_tbtn) self.time_lock_tbtn_action.setVisible(False) self.undiff_tbtn_action.setVisible(False) self.time_lock_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.find_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.shell_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.diff_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.lock_tbtn.setCursor(QtCore.Qt.PointingHandCursor) self.revert_tbtn.setCursor(QtCore.Qt.PointingHandCursor) resolve_tbtn.setCursor(QtCore.Qt.PointingHandCursor) btn_pane = create_pane( [self.show_effective_request_checkbox, None, toolbar], True, compact=True, compact_spacing=0) context_pane = create_pane([btn_pane, self.context_table], False, compact=True, compact_spacing=0) self.package_tab = PackageTabWidget(self.context_model, versions_tab=True) context_splitter = ConfiguredSplitter(app.config, "layout/splitter/main") context_splitter.setOrientation(QtCore.Qt.Vertical) context_splitter.addWidget(context_pane) context_splitter.addWidget(self.package_tab) if not context_splitter.apply_saved_layout(): context_splitter.setStretchFactor(0, 2) context_splitter.setStretchFactor(1, 1) self.settings = ContextSettingsWidget(self.context_model) self.tools_list = ContextToolsWidget(self.context_model) self.resolve_details = ContextDetailsWidget(self.context_model) self.tab = QtGui.QTabWidget() icon = get_icon("context", as_qicon=True) self.tab.addTab(context_splitter, icon, "context") icon = get_icon("context_settings", as_qicon=True) self.tab.addTab(self.settings, icon, "settings") icon = get_icon("tools", as_qicon=True) self.tab.addTab(self.tools_list, icon, "tools") icon = get_icon("info", as_qicon=True) self.tab.addTab(self.resolve_details, icon, "resolve details") self.tab.setTabEnabled(2, False) self.tab.setTabEnabled(3, False) # layout layout = QtGui.QVBoxLayout() layout.setSpacing(0) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.tab) self.setLayout(layout) # shortcuts find_shortcut = QtGui.QShortcut(QtGui.QKeySequence("Ctrl+F"), self) find_shortcut.activated.connect(self._search) # widget signals self.context_table.variantSelected.connect(self._variantSelected) self.find_tbtn.clicked.connect(self._search_variant) self.shell_tbtn.clicked.connect(self._open_shell) self.undiff_tbtn.clicked.connect(self._leave_diff_mode) self.time_lock_tbtn.clicked.connect(self._timelockClicked) self.tools_list.toolsChanged.connect(self._updateToolsCount) self.diff_menu.aboutToShow.connect(self._aboutToShowDiffMenu) self.revert_menu.aboutToShow.connect(self._aboutToShowRevertMenu) self.show_effective_request_checkbox.stateChanged.connect( self._effectiveRequestStateChanged) self.refresh() self._updateToolsCount()
def __init__(self, context_model, variant_left=None, variant_right=None, parent=None): super(CompareCell, self).__init__(parent) self.context_model = context_model self.left_variant = variant_left self.right_variant = variant_right self.color = None self.side = None self.mode = None self.comparable = False package_paths = self.context_model.packages_path widget = None if self.left_variant and self.right_variant: self.side = "both" equal_versions = ( self.left_variant.version == self.right_variant.version) right_variant_visible = (self.right_variant.wrapped.location in package_paths) self.comparable = right_variant_visible and not equal_versions if self.comparable: # determine how far apart the variant versions are versions = sorted( [self.left_variant.version, self.right_variant.version]) range_ = VersionRange.as_span(*versions) it = iter_packages(name=self.left_variant.name, paths=package_paths, range_=range_) diff_num = sum(1 for x in it) - 1 unit = "version" if diff_num == 1 else "versions" icon_suffixes = {1: "_1", 2: "_2", 3: "_3"} icon_suffix = icon_suffixes.get(diff_num, "") if self.left_variant == self.right_variant: self.mode = "equal_to" self._set_color(0.7, 0.7, 0.7) widget = IconButton("equal_to", "packages are equal") elif self.left_variant.version == self.right_variant.version: # same version, but package is different. This can happen when # a local package is released which then hides a central package # of the same version self.mode = "equalish" self._set_color(1, 1, 0) widget = IconButton( "equalish", "packages versions are equal, but package is different") elif self.left_variant.version > self.right_variant.version: self.mode = "greater_than" self._set_color(0, 1, 0) if self.comparable: desc = "package is %d %s ahead" % (diff_num, unit) widget = IconButton("greater_than" + icon_suffix, desc) else: widget = IconButton("greater_than", "package is newer") else: self.mode = "less_than" self._set_color(1, 0, 0) if self.comparable: desc = "package is %d %s behind" % (diff_num, unit) widget = IconButton("less_than" + icon_suffix, desc) else: widget = IconButton("less_than", "package is older") elif self.right_variant: self.side = "right" self.mode = "missing" self._set_color(1, 0, 0) widget = IconButton("missing", "package is missing") elif self.left_variant: self.side = "left" self.mode = "new" self._set_color(0, 1, 0) widget = IconButton("new", "package is new") if widget: create_pane([None, widget, None], True, compact=True, parent_widget=self) widget.clicked.connect(self._clicked)
def _set_variant(self, variant, preloaded_packages=None): self.clear() hh = self.horizontalHeader() self.setHorizontalHeaderLabels(["path", "released"]) hh.setResizeMode(0, QtGui.QHeaderView.Interactive) hh.setStretchLastSection(True) hh.setVisible(True) package_paths = self.context_model.packages_path package_filter = PackageFilterList.from_pod( self.context_model.package_filter) if variant and variant.wrapped.location in package_paths: self.version_index = -1 self.reference_version_index = -1 reference_version = None range_ = None if self.reference_variant and self.reference_variant.name == variant.name: reference_version = self.reference_variant.version versions = sorted([reference_version, variant.version]) range_ = VersionRange.as_span(*versions) timestamp = self.context().timestamp if preloaded_packages is not None: if range_ is None: packages = preloaded_packages else: packages = [ x for x in preloaded_packages if x.version in range_ ] else: it = iter_packages(name=variant.name, paths=package_paths, range_=range_) packages = sorted(it, key=lambda x: x.version, reverse=True) self.setRowCount(len(packages)) brush = self.palette().brush(QtGui.QPalette.Active, QtGui.QPalette.Base) for row, package in enumerate(packages): version_str = str(package.version) + ' ' item = QtGui.QTableWidgetItem(version_str) item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.setVerticalHeaderItem(row, item) if package.version == variant.version: self.version_index = row update_font(item, bold=True) if reference_version is not None \ and package.version == reference_version: self.reference_version_index = row update_font(item, bold=True, italic=True) def _item(): item_ = QtGui.QTableWidgetItem() item_.setBackground( brush) # get rid of mouse-hover coloring return item_ if package.timestamp: release_str = get_timestamp_str(package.timestamp) in_future = (package.timestamp > timestamp) else: release_str = '-' in_future = False item = _item() txt = package.uri + " " icons = [] if in_future: icon = get_icon_widget( "clock_warning", "package did not exist at time of resolve") icons.append(icon) rule = package_filter.excludes(package) if rule: icon = get_icon_widget( "excluded", "package was excluded by rule %s" % str(rule)) icons.append(icon) if icons: label = QtGui.QLabel(txt) pane = create_pane(icons + [label, None], True, compact=True) self.setCellWidget(row, 0, pane) else: item.setText(txt) self.setItem(row, 0, item) item = _item() item.setText(release_str) self.setItem(row, 1, item) vh = self.verticalHeader() vh.setVisible(True) self.resizeColumnsToContents() hh.setStretchLastSection(True) self.update() self.allow_selection = True self.selectRow(self.version_index) self.allow_selection = False self.variant = variant
def _set_variant(self, variant, preloaded_packages=None): self.clear() hh = self.horizontalHeader() self.setHorizontalHeaderLabels(["path", "released"]) hh.setResizeMode(0, QtGui.QHeaderView.Interactive) hh.setStretchLastSection(True) hh.setVisible(True) package_paths = self.context_model.packages_path package_filter = PackageFilterList.from_pod(self.context_model.package_filter) if variant and variant.wrapped.location in package_paths: self.version_index = -1 self.reference_version_index = -1 reference_version = None range_ = None if self.reference_variant and self.reference_variant.name == variant.name: reference_version = self.reference_variant.version versions = sorted([reference_version, variant.version]) range_ = VersionRange.as_span(*versions) timestamp = self.context().timestamp if preloaded_packages is not None: if range_ is None: packages = preloaded_packages else: packages = [x for x in preloaded_packages if x.version in range_] else: it = iter_packages(name=variant.name, paths=package_paths, range_=range_) packages = sorted(it, key=lambda x: x.version, reverse=True) self.setRowCount(len(packages)) brush = self.palette().brush(QtGui.QPalette.Active, QtGui.QPalette.Base) for row, package in enumerate(packages): version_str = str(package.version) + ' ' item = QtGui.QTableWidgetItem(version_str) item.setTextAlignment(QtCore.Qt.AlignRight | QtCore.Qt.AlignVCenter) self.setVerticalHeaderItem(row, item) if package.version == variant.version: self.version_index = row update_font(item, bold=True) if reference_version is not None \ and package.version == reference_version: self.reference_version_index = row update_font(item, bold=True, italic=True) def _item(): item_ = QtGui.QTableWidgetItem() item_.setBackground(brush) # get rid of mouse-hover coloring return item_ if package.timestamp: release_str = get_timestamp_str(package.timestamp) in_future = (package.timestamp > timestamp) else: release_str = '-' in_future = False item = _item() txt = package.uri + " " icons = [] if in_future: icon = get_icon_widget( "clock_warning", "package did not exist at time of resolve") icons.append(icon) rule = package_filter.excludes(package) if rule: icon = get_icon_widget( "excluded", "package was excluded by rule %s" % str(rule)) icons.append(icon) if icons: label = QtGui.QLabel(txt) pane = create_pane(icons + [label, None], True, compact=True) self.setCellWidget(row, 0, pane) else: item.setText(txt) self.setItem(row, 0, item) item = _item() item.setText(release_str) self.setItem(row, 1, item) vh = self.verticalHeader() vh.setVisible(True) self.resizeColumnsToContents() hh.setStretchLastSection(True) self.update() self.allow_selection = True self.selectRow(self.version_index) self.allow_selection = False self.variant = variant
def __init__(self, context_model, variant_left=None, variant_right=None, parent=None): super(CompareCell, self).__init__(parent) self.context_model = context_model self.left_variant = variant_left self.right_variant = variant_right self.color = None self.side = None self.mode = None self.comparable = False package_paths = self.context_model.packages_path widget = None if self.left_variant and self.right_variant: self.side = "both" equal_versions = (self.left_variant.version == self.right_variant.version) right_variant_visible = (self.right_variant.wrapped.location in package_paths) self.comparable = right_variant_visible and not equal_versions if self.comparable: # determine how far apart the variant versions are versions = sorted([self.left_variant.version, self.right_variant.version]) range_ = VersionRange.as_span(*versions) it = iter_packages(name=self.left_variant.name, paths=package_paths, range_=range_) diff_num = sum(1 for x in it) - 1 unit = "version" if diff_num == 1 else "versions" icon_suffixes = {1: "_1", 2: "_2", 3: "_3"} icon_suffix = icon_suffixes.get(diff_num, "") if self.left_variant == self.right_variant: self.mode = "equal_to" self._set_color(0.7, 0.7, 0.7) widget = IconButton("equal_to", "packages are equal") elif self.left_variant.version == self.right_variant.version: # same version, but package is different. This can happen when # a local package is released which then hides a central package # of the same version self.mode = "equalish" self._set_color(1, 1, 0) widget = IconButton( "equalish", "packages versions are equal, but package is different") elif self.left_variant.version > self.right_variant.version: self.mode = "greater_than" self._set_color(0, 1, 0) if self.comparable: desc = "package is %d %s ahead" % (diff_num, unit) widget = IconButton("greater_than" + icon_suffix, desc) else: widget = IconButton("greater_than", "package is newer") else: self.mode = "less_than" self._set_color(1, 0, 0) if self.comparable: desc = "package is %d %s behind" % (diff_num, unit) widget = IconButton("less_than" + icon_suffix, desc) else: widget = IconButton("less_than", "package is older") elif self.right_variant: self.side = "right" self.mode = "missing" self._set_color(1, 0, 0) widget = IconButton("missing", "package is missing") elif self.left_variant: self.side = "left" self.mode = "new" self._set_color(0, 1, 0) widget = IconButton("new", "package is new") if widget: create_pane([None, widget, None], True, compact=True, parent_widget=self) widget.clicked.connect(self._clicked)
def __init__(self, context_model, parent=None, advanced=False): config_key = ("layout/window/advanced_resolve" if advanced else "layout/window/resolve") super(ResolveDialog, self).__init__(parent) StoreSizeMixin.__init__(self, app.config, config_key) self.setWindowTitle("Resolve") self.setContentsMargins(0, 0, 0, 0) self.context_model = context_model self.advanced = advanced self.resolver = None self.thread = None self.started = False self._finished = False #self.busy_cursor = QtGui.QCursor(QtCore.Qt.WaitCursor) self.edit = StreamableTextEdit() self.edit.setStyleSheet("font: 9pt 'Courier'") self.bar = QtGui.QProgressBar() self.bar.setRange(0, 10) self.save_context_btn = QtGui.QPushButton("Save Context As...") self.graph_btn = QtGui.QPushButton("View Graph...") self.ok_btn = QtGui.QPushButton("Ok") self.start_again_btn = QtGui.QPushButton("Start Again") self.cancel_btn = QtGui.QPushButton("Cancel") self.resolve_btn = QtGui.QPushButton("Resolve") self.ok_btn.hide() self.graph_btn.hide() self.start_again_btn.hide() self.save_context_btn.hide() btn_pane = create_pane([None, self.save_context_btn, self.graph_btn, self.start_again_btn, self.ok_btn, self.cancel_btn, self.resolve_btn], not self.advanced) layout = QtGui.QVBoxLayout() layout.addWidget(self.bar) layout.addWidget(self.edit, 1) self.resolve_group = None self.max_fails_combo = None self.verbosity_combo = None self.show_package_loads_checkbox = None # this is solely to execute _start_resolve() as soon as the dialog opens self.timer = QtCore.QTimer() self.timer.setInterval(1) self.timer.setSingleShot(True) self.timer.timeout.connect(self._on_dialog_open) if self.advanced: self.resolve_group = QtGui.QGroupBox("resolve settings") label = QtGui.QLabel("maximum fails:") self.max_fails_combo = QtGui.QComboBox() self.max_fails_combo.setEditable(True) self.max_fails_combo.addItem("-") self.max_fails_combo.addItem("1") self.max_fails_combo.addItem("2") self.max_fails_combo.addItem("3") app.config.attach(self.max_fails_combo, "resolve/max_fails") max_fails_pane = create_pane([None, label, self.max_fails_combo], True) label = QtGui.QLabel("verbosity:") self.verbosity_combo = QtGui.QComboBox() self.verbosity_combo.addItem("0") self.verbosity_combo.addItem("1") self.verbosity_combo.addItem("2") app.config.attach(self.verbosity_combo, "resolve/verbosity") verbosity_pane = create_pane([None, label, self.verbosity_combo], True) self.show_package_loads_checkbox = QtGui.QCheckBox("show package loads") self.show_package_loads_checkbox.setLayoutDirection(QtCore.Qt.RightToLeft) app.config.attach(self.show_package_loads_checkbox, "resolve/show_package_loads") show_loads_pane = create_pane([None, self.show_package_loads_checkbox], True) self.timestamp_widget = TimestampWidget(self.context_model) context = self.context_model.context() if context and context.requested_timestamp: self.timestamp_widget.set_time(context.requested_timestamp) left_pane = create_pane([self.timestamp_widget, None], False, compact=True) right_pane = create_pane([max_fails_pane, verbosity_pane, show_loads_pane, None], False, compact=True) create_pane([left_pane, right_pane], True, parent_widget=self.resolve_group) pane = create_pane([self.resolve_group, None, btn_pane], True) self.cancel_btn.hide() layout.addWidget(pane) else: self.resolve_btn.hide() layout.addWidget(btn_pane) self.setLayout(layout) self.cancel_btn.clicked.connect(self._cancel_resolve) self.resolve_btn.clicked.connect(self._start_resolve) self.graph_btn.clicked.connect(self._view_graph) self.save_context_btn.clicked.connect(self._save_context) self.start_again_btn.clicked.connect(self._reset) self.ok_btn.clicked.connect(self.close)