Skip to content

Commit

Permalink
Transform doc.qt.io/qt-creator links to internal qthelp links, for links
Browse files Browse the repository at this point in the history
that are found locally in the documentation. That opens such links in Qt
Creator, instead of in the web, if possible.

Change-Id: I2270c6947db22f4aeb4968bf5b7245de57521c92
Reviewed-by: Cristian Adam <[email protected]>
  • Loading branch information
e4z9 committed Nov 24, 2022
1 parent 7a2901d commit 2ff5f18
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/plugins/coreplugin/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "externaltoolmanager.h"
#include "fancytabwidget.h"
#include "generalsettings.h"
#include "helpmanager.h"
#include "icore.h"
#include "idocumentfactory.h"
#include "jsexpander.h"
Expand Down Expand Up @@ -1516,8 +1517,17 @@ void MainWindow::changeLog()
return;
const FilePath file = versionedFiles.at(index).second;
QString contents = QString::fromUtf8(file.fileContents().value_or(QByteArray()));
contents.replace(QRegularExpression("(QT(CREATOR)?BUG-[0-9]+)"),
"[\\1](https://bugreports.qt.io/browse/\\1)");
static const QRegularExpression bugexpr("(QT(CREATOR)?BUG-[0-9]+)");
contents.replace(bugexpr, "[\\1](https://bugreports.qt.io/browse/\\1)");
static const QRegularExpression docexpr("https://doc[.]qt[.]io/qtcreator/([.a-zA-Z/_-]*)");
QList<QRegularExpressionMatch> matches;
for (const QRegularExpressionMatch &m : docexpr.globalMatch(contents))
matches.append(m);
Utils::reverseForeach(matches, [&contents](const QRegularExpressionMatch &match) {
const QString qthelpUrl = "qthelp://org.qt-project.qtcreator/doc/" + match.captured(1);
if (!HelpManager::fileData(qthelpUrl).isEmpty())
contents.replace(match.capturedStart(), match.capturedLength(), qthelpUrl);
});
textEdit->setMarkdown(contents);
};
connect(versionCombo, &QComboBox::currentIndexChanged, textEdit, showLog);
Expand Down

0 comments on commit 2ff5f18

Please sign in to comment.