VCS: Pass links to the correct VCS

Current implementation requires each VCS to connect to the referenceClicked
signal. Only Git does it, but this is conceptually wrong. If other VCSs
would connect to the same signal, all of them will act upon clicking a
link, which can result in multiple editors, most of them are likely to be
invalid anyway.

By default executes vcsDescribe. Can be extended or modified by subclasses.

Change-Id: Ib953009efd77446a4b2963f0aa8a2f3f3d26509f
Reviewed-by: Artur Shepilko <artur.shepilko@nomadbyte.com>
Reviewed-by: André Hartmann <aha_1980@gmx.de>
This commit is contained in:
Orgad Shaneh
2020-06-18 00:04:17 +03:00
committed by Orgad Shaneh
parent cb0b8556c8
commit 92a4c0d38a
11 changed files with 70 additions and 37 deletions

View File

@@ -104,6 +104,7 @@ public:
protected:
void contextMenuEvent(QContextMenuEvent *event) override;
void handleLink(const QPoint &pos) override;
private:
void setFormat(VcsOutputWindow::MessageStyle style);
@@ -214,6 +215,23 @@ void OutputWindowPlainTextEdit::contextMenuEvent(QContextMenuEvent *event)
delete menu;
}
void OutputWindowPlainTextEdit::handleLink(const QPoint &pos)
{
const QString href = anchorAt(pos);
if (href.isEmpty())
return;
QString repository;
identifierUnderCursor(pos, &repository);
if (repository.isEmpty()) {
OutputWindow::handleLink(pos);
return;
}
if (outputFormatter()->handleFileLink(href))
return;
if (VcsOutputLineParser * const p = parser())
p->handleVcsLink(repository, href);
}
void OutputWindowPlainTextEdit::appendLines(const QString &s, const QString &repository)
{
if (s.isEmpty())
@@ -310,8 +328,6 @@ VcsOutputWindow::VcsOutputWindow()
connect(this, &IOutputPane::resetZoom, &d->widget, &Core::OutputWindow::resetZoom);
connect(TextEditor::TextEditorSettings::instance(), &TextEditor::TextEditorSettings::behaviorSettingsChanged,
this, updateBehaviorSettings);
connect(d->widget.parser(), &VcsOutputLineParser::referenceClicked,
VcsOutputWindow::instance(), &VcsOutputWindow::referenceClicked);
}
static QString filterPasswordFromUrls(QString input)