def __init__(self, parent=None, hidable=False): super(SearchToolBar, self).__init__(_('Search'), parent, objectName='search', iconSize=QSize(16, 16)) if hidable: self._close_button = QToolButton( icon=qtlib.geticon('window-close'), shortcut=Qt.Key_Escape) self._close_button.clicked.connect(self.hide) self.addWidget(self._close_button) self.addWidget(qtlib.Spacer(2, 2)) self._le = QLineEdit() if hasattr(self._le, 'setPlaceholderText'): # Qt >= 4.7 self._le.setPlaceholderText(_('### regular expression ###')) else: self._lbl = QLabel(_('Regexp:'), toolTip=_('Regular expression search pattern')) self.addWidget(self._lbl) self._lbl.setBuddy(self._le) self._le.returnPressed.connect(self._emitSearchRequested) self.addWidget(self._le) self.addWidget(qtlib.Spacer(4, 4)) self._chk = QCheckBox(_('Ignore case')) self.addWidget(self._chk) self._wrapchk = QCheckBox(_('Wrap search')) self.addWidget(self._wrapchk) self._btprev = QPushButton(_('Prev'), icon=qtlib.geticon('go-up'), iconSize=QSize(16, 16)) self._btprev.clicked.connect( lambda: self._emitSearchRequested(forward=False)) self.addWidget(self._btprev) self._bt = QPushButton(_('Next'), icon=qtlib.geticon('go-down'), iconSize=QSize(16, 16)) self._bt.clicked.connect(self._emitSearchRequested) self._le.textChanged.connect(self._updateSearchButtons) self.addWidget(self._bt) self.setFocusProxy(self._le) self.setStyleSheet(qtlib.tbstylesheet) self._settings = QSettings() self._settings.beginGroup('searchtoolbar') self.searchRequested.connect(self._writesettings) self._readsettings() self._le.textChanged.connect(self._emitConditionChanged) self._chk.toggled.connect(self._emitConditionChanged) self._wrapchk.toggled.connect(self._emitConditionChanged) self._updateSearchButtons()
def _initBranchFilter(self): self._branchLabel = QToolButton( text=_('Branch'), popupMode=QToolButton.MenuButtonPopup, statusTip=_('Display graph the named branch only')) self._branchLabel.clicked.connect(self._branchLabel.showMenu) self._branchMenu = QMenu(self._branchLabel) self._abranchAction = self._branchMenu.addAction( _('Display only active branches'), self.refresh) self._abranchAction.setCheckable(True) self._cbranchAction = self._branchMenu.addAction( _('Display closed branches'), self.refresh) self._cbranchAction.setCheckable(True) self._allparAction = self._branchMenu.addAction( _('Include all ancestors'), self._emitBranchChanged) self._allparAction.setCheckable(True) self._branchLabel.setMenu(self._branchMenu) self._branchCombo = QComboBox() self._branchCombo.setMinimumContentsLength(10) self._branchCombo.setMaxVisibleItems(30) self._branchCombo.currentIndexChanged.connect(self._emitBranchChanged) self.addWidget(self._branchLabel) self.addWidget(qtlib.Spacer(2, 2)) self.addWidget(self._branchCombo)
def _initbranchfilter(self): self._branchLabel = QToolButton( text=_('Branch'), popupMode=QToolButton.MenuButtonPopup, statusTip=_('Display graph the named branch only')) self._branchLabel.clicked.connect(self._branchLabel.showMenu) self._branchMenu = QMenu(self._branchLabel) self._abranchAction = self._branchMenu.addAction( _('Display only active branches'), self.refresh) self._abranchAction.setCheckable(True) self._cbranchAction = self._branchMenu.addAction( _('Display closed branches'), self.refresh) self._cbranchAction.setCheckable(True) self._allparAction = self._branchMenu.addAction( _('Include all ancestors'), self._emitBranchChanged) self._allparAction.setCheckable(True) self._branchLabel.setMenu(self._branchMenu) self._branchCombo = QComboBox() self._branchCombo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) self._branchCombo.setSizeAdjustPolicy(QComboBox.AdjustToMinimumContentsLength) self._branchCombo.currentIndexChanged.connect(self._emitBranchChanged) self._branchReloading = False self.addWidget(self._branchLabel) self.addWidget(qtlib.Spacer(2, 2)) self.addWidget(self._branchCombo)
def __init__(self, repo, parent=None): super(RepoFilterBar, self).__init__(parent) self.layout().setContentsMargins(0, 0, 0, 0) self.setIconSize(QSize(16,16)) self.setFloatable(False) self.setMovable(False) self._repo = repo self._permanent_queries = list(_permanent_queries) username = repo.ui.config('ui', 'username') if username: self._permanent_queries.insert(0, hgrevset.formatspec('author(%s)', os.path.expandvars(username))) self.filterEnabled = True #Check if the font contains the glyph needed by the branch combo if not QFontMetrics(self.font()).inFont(QString(u'\u2605').at(0)): self._allBranchesLabel = u'*** %s ***' % _('Show all') self.entrydlg = revset.RevisionSetQuery(repo, self) self.entrydlg.progress.connect(self.progress) self.entrydlg.showMessage.connect(self.showMessage) self.entrydlg.queryIssued.connect(self.queryIssued) self.entrydlg.hide() self.revsetcombo = combo = QComboBox() combo.setEditable(True) combo.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Fixed) combo.setMinimumContentsLength(10) qtlib.allowCaseChangingInput(combo) le = combo.lineEdit() le.returnPressed.connect(self.runQuery) le.selectionChanged.connect(self.selectionChanged) if hasattr(le, 'setPlaceholderText'): # Qt >= 4.7 le.setPlaceholderText(_('### revision set query ###')) combo.activated.connect(self.runQuery) self._revsettypelabel = QLabel(le) self._revsettypetimer = QTimer(self, interval=200, singleShot=True) self._revsettypetimer.timeout.connect(self._updateQueryType) combo.editTextChanged.connect(self._revsettypetimer.start) self._updateQueryType() le.installEventFilter(self) self.clearBtn = QToolButton(self) self.clearBtn.setIcon(qtlib.geticon('filedelete')) self.clearBtn.setToolTip(_('Clear current query and query text')) self.clearBtn.clicked.connect(self.onClearButtonClicked) self.addWidget(self.clearBtn) self.addWidget(qtlib.Spacer(2, 2)) self.addWidget(combo) self.addWidget(qtlib.Spacer(2, 2)) self.searchBtn = QToolButton(self) self.searchBtn.setIcon(qtlib.geticon('view-filter')) self.searchBtn.setToolTip(_('Trigger revision set query')) self.searchBtn.clicked.connect(self.runQuery) self.addWidget(self.searchBtn) self.editorBtn = QToolButton() self.editorBtn.setText('...') self.editorBtn.setToolTip(_('Open advanced query editor')) self.editorBtn.clicked.connect(self.openEditor) self.addWidget(self.editorBtn) icon = QIcon() icon.addPixmap(QApplication.style().standardPixmap(QStyle.SP_TrashIcon)) self.deleteBtn = QToolButton() self.deleteBtn.setIcon(icon) self.deleteBtn.setToolTip(_('Delete selected query from history')) self.deleteBtn.clicked.connect(self.deleteFromHistory) self.deleteBtn.setEnabled(False) self.addWidget(self.deleteBtn) self.addSeparator() self.filtercb = f = QCheckBox(_('filter')) f.toggled.connect(self.filterToggled) f.setToolTip(_('Toggle filtering of non-matched changesets')) self.addWidget(f) self.addSeparator() self.showHiddenBtn = QToolButton() self.showHiddenBtn.setIcon(qtlib.geticon('view-hidden')) self.showHiddenBtn.setCheckable(True) self.showHiddenBtn.setToolTip(_('Show/Hide hidden changesets')) self.showHiddenBtn.clicked.connect(self.showHiddenChanged) self.addWidget(self.showHiddenBtn) self.addSeparator() self._initBranchFilter() self.refresh()
def __init__(self, repoagent, pats, opts, parent=None, checkable=True, defcheck='commit'): QWidget.__init__(self, parent) self.opts = dict(modified=True, added=True, removed=True, deleted=True, unknown=True, clean=False, ignored=False, subrepo=True) self.opts.update(opts) self._repoagent = repoagent self.pats = pats self.checkable = checkable self.defcheck = defcheck self.pctx = None self.savechecks = True self.refthread = None self.refreshWctxLater = QTimer(self, interval=10, singleShot=True) self.refreshWctxLater.timeout.connect(self.refreshWctx) self.partials = {} self.manualCheckAllUpdate = False # determine the user configured status colors # (in the future, we could support full rich-text tags) labels = [(stat, val.uilabel) for stat, val in statusTypes.items()] labels.extend([('r', 'resolve.resolved'), ('u', 'resolve.unresolved')]) for stat, label in labels: effect = qtlib.geteffect(label) for e in effect.split(';'): if e.startswith('color:'): _colors[stat] = QColor(e[7:]) break SP = QSizePolicy split = QSplitter(Qt.Horizontal) split.setChildrenCollapsible(False) layout = QVBoxLayout() layout.setMargin(0) layout.addWidget(split) self.setLayout(layout) vbox = QVBoxLayout() vbox.setMargin(0) frame = QFrame(split) sp = SP(SP.Expanding, SP.Expanding) sp.setHorizontalStretch(0) sp.setVerticalStretch(0) frame.setSizePolicy(sp) frame.setLayout(vbox) hbox = QHBoxLayout() hbox.setMargin(4) hbox.setContentsMargins(0, 0, 0, 0) self.refreshBtn = tb = QToolButton() tb.setToolTip(_('Refresh file list')) tb.setIcon(qtlib.geticon('view-refresh')) tb.clicked.connect(self.refreshWctx) le = QLineEdit() if hasattr(le, 'setPlaceholderText'): # Qt >= 4.7 le.setPlaceholderText(_('### filter text ###')) else: lbl = QLabel(_('Filter:')) hbox.addWidget(lbl) st = '' for s in statusTypes: val = statusTypes[s] if self.opts[val.name]: st = st + s self.statusfilter = StatusFilterButton(statustext=st, types=StatusType.preferredOrder) if self.checkable: self.checkAllTT = _('Check all files') self.checkNoneTT = _('Uncheck all files') self.checkAllNoneBtn = QCheckBox() self.checkAllNoneBtn.setToolTip(self.checkAllTT) self.checkAllNoneBtn.stateChanged.connect(self.checkAllNone) self.filelistToolbar = QToolBar(_('Status File List Toolbar')) self.filelistToolbar.setIconSize(QSize(16, 16)) self.filelistToolbar.setStyleSheet(qtlib.tbstylesheet) hbox.addWidget(self.filelistToolbar) if self.checkable: self.filelistToolbar.addWidget(qtlib.Spacer(3, 2)) self.filelistToolbar.addWidget(self.checkAllNoneBtn) self.filelistToolbar.addSeparator() self.filelistToolbar.addWidget(le) self.filelistToolbar.addSeparator() self.filelistToolbar.addWidget(self.statusfilter) self.filelistToolbar.addSeparator() self.filelistToolbar.addWidget(self.refreshBtn) self.actions = wctxactions.WctxActions(self._repoagent, self, checkable) self.actions.refreshNeeded.connect(self.refreshWctx) self.actions.runCustomCommandRequested.connect( self.runCustomCommandRequested) tv = WctxFileTree(self.repo, checkable=checkable) vbox.addLayout(hbox) vbox.addWidget(tv) split.addWidget(frame) self.clearPatternBtn = QPushButton(_('Remove filter, show root')) vbox.addWidget(self.clearPatternBtn) self.clearPatternBtn.clicked.connect(self.clearPattern) self.clearPatternBtn.setVisible(bool(self.pats)) tv.setItemsExpandable(False) tv.setRootIsDecorated(False) tv.sortByColumn(COL_STATUS, Qt.AscendingOrder) tv.clicked.connect(self.onRowClicked) tv.doubleClicked.connect(self.onRowDoubleClicked) tv.menuRequest.connect(self.onMenuRequest) le.textEdited.connect(self.setFilter) self.statusfilter.statusChanged.connect(self.setStatusFilter) self.tv = tv self.le = le # Diff panel side of splitter vbox = QVBoxLayout() vbox.setSpacing(0) vbox.setContentsMargins(0, 0, 0, 0) docf = QFrame(split) sp = SP(SP.Expanding, SP.Expanding) sp.setHorizontalStretch(1) sp.setVerticalStretch(0) docf.setSizePolicy(sp) docf.setLayout(vbox) self.docf = docf self.fileview = fileview.HgFileView(self._repoagent, self) self.fileview.showMessage.connect(self.showMessage) self.fileview.linkActivated.connect(self.linkActivated) self.fileview.fileDisplayed.connect(self.fileDisplayed) self.fileview.shelveToolExited.connect(self.refreshWctx) self.fileview.newChunkList.connect(self.updatePartials) self.fileview.chunkSelectionChanged.connect(self.chunkSelectionChanged) self.fileview.grepRequested.connect(self.grepRequested) self.fileview.setContext(self.repo[None]) self.fileview.setMinimumSize(QSize(16, 16)) vbox.addWidget(self.fileview, 1) self.split = split self.diffvbox = vbox