diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2020-09-30 13:47:17 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2020-09-30 20:17:31 (GMT) |
commit | 0fe2ee3d4393177a4850a3da3e9b0df89239f294 (patch) | |
tree | 21c4d5255319c70c1572dd36a264564158f118b6 | |
parent | 391ff1ec518bea4bbaac95b6a3737b82c65656d3 (diff) | |
download | CMake-0fe2ee3d4393177a4850a3da3e9b0df89239f294.zip CMake-0fe2ee3d4393177a4850a3da3e9b0df89239f294.tar.gz CMake-0fe2ee3d4393177a4850a3da3e9b0df89239f294.tar.bz2 |
CMake GUI: Add "CMake Reference Manual" help item
And switch the ordering of "Help" and "About".
-rw-r--r-- | Source/QtDialog/CMakeSetupDialog.cxx | 18 | ||||
-rw-r--r-- | Source/cmConfigure.cmake.h.in | 1 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 16 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 1 |
4 files changed, 34 insertions, 2 deletions
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx index a904b94..df22028 100644 --- a/Source/QtDialog/CMakeSetupDialog.cxx +++ b/Source/QtDialog/CMakeSetupDialog.cxx @@ -181,11 +181,25 @@ CMakeSetupDialog::CMakeSetupDialog() &QCMakeCacheView::collapseAll); QMenu* HelpMenu = this->menuBar()->addMenu(tr("&Help")); - a = HelpMenu->addAction(tr("About")); - QObject::connect(a, &QAction::triggered, this, &CMakeSetupDialog::doAbout); a = HelpMenu->addAction(tr("Help")); 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, []() { + QString urlFormat("https://cmake.org/cmake/help/v%1.%2/"); + QUrl url(urlFormat.arg(QString::number(cmVersion::GetMajorVersion()), + QString::number(cmVersion::GetMinorVersion()))); + + if (!cmSystemTools::GetHTMLDoc().empty()) { + url = QUrl::fromLocalFile( + QDir(QString::fromLocal8Bit(cmSystemTools::GetHTMLDoc().data())) + .filePath("index.html")); + } + + QDesktopServices::openUrl(url); + }); + a = HelpMenu->addAction(tr("About")); + QObject::connect(a, &QAction::triggered, this, &CMakeSetupDialog::doAbout); this->setAcceptDrops(true); diff --git a/Source/cmConfigure.cmake.h.in b/Source/cmConfigure.cmake.h.in index ceb2a32..cf32b05 100644 --- a/Source/cmConfigure.cmake.h.in +++ b/Source/cmConfigure.cmake.h.in @@ -21,6 +21,7 @@ #define CMake_DEFAULT_RECURSION_LIMIT @CMake_DEFAULT_RECURSION_LIMIT@ #define CMAKE_BIN_DIR "/@CMAKE_BIN_DIR@" #define CMAKE_DATA_DIR "/@CMAKE_DATA_DIR@" +#define CMAKE_DOC_DIR "/@CMAKE_DOC_DIR@" #define CM_FALLTHROUGH cmsys_FALLTHROUGH diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7d2dd54..97440d2 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2077,6 +2077,7 @@ static std::string cmSystemToolsCMakeCursesCommand; static std::string cmSystemToolsCMakeGUICommand; static std::string cmSystemToolsCMClDepsCommand; static std::string cmSystemToolsCMakeRoot; +static std::string cmSystemToolsHTMLDoc; void cmSystemTools::FindCMakeResources(const char* argv0) { std::string exe_dir; @@ -2166,10 +2167,15 @@ void cmSystemTools::FindCMakeResources(const char* argv0) // Install tree has // - "<prefix><CMAKE_BIN_DIR>/cmake" // - "<prefix><CMAKE_DATA_DIR>" + // - "<prefix><CMAKE_DOC_DIR>" if (cmHasLiteralSuffix(exe_dir, CMAKE_BIN_DIR)) { std::string const prefix = exe_dir.substr(0, exe_dir.size() - cmStrLen(CMAKE_BIN_DIR)); cmSystemToolsCMakeRoot = cmStrCat(prefix, CMAKE_DATA_DIR); + if (cmSystemTools::FileExists( + cmStrCat(prefix, CMAKE_DOC_DIR "/html/index.html"))) { + cmSystemToolsHTMLDoc = cmStrCat(prefix, CMAKE_DOC_DIR "/html"); + } } if (cmSystemToolsCMakeRoot.empty() || !cmSystemTools::FileExists( @@ -2192,6 +2198,11 @@ void cmSystemTools::FindCMakeResources(const char* argv0) cmSystemToolsCMakeRoot = src_dir; } } + if (!cmSystemToolsCMakeRoot.empty() && cmSystemToolsHTMLDoc.empty() && + cmSystemTools::FileExists( + cmStrCat(dir, "/Utilities/Sphinx/html/index.html"))) { + cmSystemToolsHTMLDoc = cmStrCat(dir, "/Utilities/Sphinx/html"); + } } #else // Bootstrap build knows its source. @@ -2234,6 +2245,11 @@ std::string const& cmSystemTools::GetCMakeRoot() return cmSystemToolsCMakeRoot; } +std::string const& cmSystemTools::GetHTMLDoc() +{ + return cmSystemToolsHTMLDoc; +} + std::string cmSystemTools::GetCurrentWorkingDirectory() { return cmSystemTools::CollapseFullPath( diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index d571b96..1100f05 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -389,6 +389,7 @@ public: static std::string const& GetCMakeCursesCommand(); static std::string const& GetCMClDepsCommand(); static std::string const& GetCMakeRoot(); + static std::string const& GetHTMLDoc(); /** Get the CWD mapped through the KWSys translation map. */ static std::string GetCurrentWorkingDirectory(); |