forked from qt-creator/qt-creator
Git: Add actions for changes in output window context menu
Change-Id: I5aa46f87b82670286ac225d71a3a045133976e86 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
committed by
Orgad Shaneh
parent
ab3e2ac0fc
commit
ba87fb2083
@@ -175,10 +175,17 @@ QString OutputWindowPlainTextEdit::identifierUnderCursor(const QPoint &widgetPos
|
||||
|
||||
void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu *menu = createStandardContextMenu();
|
||||
const QString href = anchorAt(event->pos());
|
||||
QMenu *menu = href.isEmpty() ? createStandardContextMenu(event->pos()) : new QMenu;
|
||||
// Add 'open file'
|
||||
QString repository;
|
||||
const QString token = identifierUnderCursor(event->pos(), &repository);
|
||||
if (!repository.isEmpty()) {
|
||||
if (VcsOutputFormatter *f = formatter()) {
|
||||
if (!href.isEmpty())
|
||||
f->fillLinkContextMenu(menu, repository, href);
|
||||
}
|
||||
}
|
||||
QAction *openAction = nullptr;
|
||||
if (!token.isEmpty()) {
|
||||
// Check for a file, expand via repository if relative
|
||||
@@ -192,9 +199,12 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
openAction->setData(fi.absoluteFilePath());
|
||||
}
|
||||
}
|
||||
// Add 'clear'
|
||||
menu->addSeparator();
|
||||
QAction *clearAction = menu->addAction(VcsOutputWindow::tr("Clear"));
|
||||
QAction *clearAction = nullptr;
|
||||
if (href.isEmpty()) {
|
||||
// Add 'clear'
|
||||
menu->addSeparator();
|
||||
clearAction = menu->addAction(VcsOutputWindow::tr("Clear"));
|
||||
}
|
||||
|
||||
// Run
|
||||
QAction *action = menu->exec(event->globalPos());
|
||||
|
||||
Reference in New Issue
Block a user