cmake-gui: Add optional filename argument to --browse-manual

This commit is contained in:
Kyle Edwards
2023-02-09 11:31:04 -05:00
parent 536f35c4f1
commit b5383bc767
3 changed files with 17 additions and 9 deletions

View File

@@ -11,7 +11,7 @@ Synopsis
cmake-gui [<options>]
cmake-gui [<options>] <path-to-source | path-to-existing-build>
cmake-gui [<options>] -S <path-to-source> -B <path-to-build>
cmake-gui [<options>] --browse-manual
cmake-gui [<options>] --browse-manual [<filename>]
Description
===========
@@ -46,9 +46,11 @@ Options
Name of the preset to use from the project's
:manual:`presets <cmake-presets(7)>` files, if it has them.
.. option:: --browse-manual
.. option:: --browse-manual [<filename>]
Open the CMake reference manual in a browser and immediately exit.
Open the CMake reference manual in a browser and immediately exit. If
``<filename>`` is specified, open that file within the reference manual
instead of ``index.html``.
.. include:: OPTIONS_HELP.txt

View File

@@ -34,7 +34,7 @@ const cmDocumentationEntry cmDocumentationUsage = {
" cmake-gui [options] <path-to-source>\n"
" cmake-gui [options] <path-to-existing-build>\n"
" cmake-gui [options] -S <path-to-source> -B <path-to-build>\n"
" cmake-gui [options] --browse-manual"
" cmake-gui [options] --browse-manual [<filename>]"
};
const cmDocumentationEntry cmDocumentationOptions[3] = {
@@ -62,7 +62,7 @@ Q_IMPORT_PLUGIN(QWindowsVistaStylePlugin);
int CMakeGUIExec(CMakeSetupDialog* window);
void SetupDefaultQSettings();
void OpenReferenceManual();
void OpenReferenceManual(const QString& filename);
int main(int argc, char** argv)
{
@@ -199,7 +199,12 @@ int main(int argc, char** argv)
}
presetName = preset.toStdString();
} else if (arg == "--browse-manual") {
OpenReferenceManual();
++i;
if (i >= args.size()) {
OpenReferenceManual("index.html");
} else {
OpenReferenceManual(args[i]);
}
return 0;
}
}

View File

@@ -42,7 +42,7 @@
#include "RegexExplorer.h"
#include "WarningMessagesDialog.h"
void OpenReferenceManual()
void OpenReferenceManual(const QString& filename)
{
QString urlFormat("https://cmake.org/cmake/help/v%1.%2/");
QUrl url(urlFormat.arg(QString::number(cmVersion::GetMajorVersion()),
@@ -51,7 +51,7 @@ void OpenReferenceManual()
if (!cmSystemTools::GetHTMLDoc().empty()) {
url = QUrl::fromLocalFile(
QDir(QString::fromStdString(cmSystemTools::GetHTMLDoc()))
.filePath("index.html"));
.filePath(filename));
}
QDesktopServices::openUrl(url);
@@ -212,7 +212,8 @@ CMakeSetupDialog::CMakeSetupDialog()
QObject::connect(a, &QAction::triggered, this, &CMakeSetupDialog::doHelp);
a->setShortcut(QKeySequence::HelpContents);
a = HelpMenu->addAction(tr("CMake Reference Manual"));
QObject::connect(a, &QAction::triggered, this, OpenReferenceManual);
QObject::connect(a, &QAction::triggered, this,
[] { OpenReferenceManual("index.html"); });
a = HelpMenu->addAction(tr("About"));
QObject::connect(a, &QAction::triggered, this, &CMakeSetupDialog::doAbout);