forked from qt-creator/qt-creator
CMakePM: Add options link to the CMake offline/online documentation
This way a user can quickly find out which options can be used. Change-Id: I6347759689a4a1431a82ff9414da0c79e357eb45 Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -215,7 +215,11 @@ void BaseAspect::setupLabel()
|
|||||||
if (d->m_labelText.isEmpty() && d->m_labelPixmap.isNull())
|
if (d->m_labelText.isEmpty() && d->m_labelPixmap.isNull())
|
||||||
return;
|
return;
|
||||||
d->m_label = new QLabel(d->m_labelText);
|
d->m_label = new QLabel(d->m_labelText);
|
||||||
d->m_label->setTextInteractionFlags(Qt::TextSelectableByMouse);
|
d->m_label->setTextInteractionFlags(d->m_label->textInteractionFlags()
|
||||||
|
| Qt::TextSelectableByMouse);
|
||||||
|
connect(d->m_label, &QLabel::linkActivated, this, [this](const QString &link) {
|
||||||
|
emit labelLinkActivated(link);
|
||||||
|
});
|
||||||
if (!d->m_labelPixmap.isNull())
|
if (!d->m_labelPixmap.isNull())
|
||||||
d->m_label->setPixmap(d->m_labelPixmap);
|
d->m_label->setPixmap(d->m_labelPixmap);
|
||||||
registerSubWidget(d->m_label);
|
registerSubWidget(d->m_label);
|
||||||
|
@@ -142,6 +142,7 @@ public:
|
|||||||
|
|
||||||
signals:
|
signals:
|
||||||
void changed();
|
void changed();
|
||||||
|
void labelLinkActivated(const QString &link);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QLabel *label() const;
|
QLabel *label() const;
|
||||||
|
@@ -492,6 +492,18 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
|||||||
updateInitialCMakeArguments();
|
updateInitialCMakeArguments();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
auto handleOptionsLink = [this](const QString &link) {
|
||||||
|
const CMakeTool *tool = CMakeKitAspect::cmakeTool(m_buildConfiguration->target()->kit());
|
||||||
|
if (tool)
|
||||||
|
tool->openCMakeHelpUrl("%1/manual/cmake.1.html#options");
|
||||||
|
};
|
||||||
|
connect(bc->aspect<InitialCMakeArgumentsAspect>(),
|
||||||
|
&Utils::BaseAspect::labelLinkActivated,
|
||||||
|
[=](const QString &link) { handleOptionsLink(link); });
|
||||||
|
connect(bc->aspect<AdditionalCMakeOptionsAspect>(),
|
||||||
|
&Utils::BaseAspect::labelLinkActivated,
|
||||||
|
[=](const QString &link) { handleOptionsLink(link); });
|
||||||
|
|
||||||
updateSelection();
|
updateSelection();
|
||||||
updateConfigurationStateSelection();
|
updateConfigurationStateSelection();
|
||||||
}
|
}
|
||||||
@@ -1717,7 +1729,7 @@ void InitialCMakeArgumentsAspect::toMap(QVariantMap &map) const
|
|||||||
InitialCMakeArgumentsAspect::InitialCMakeArgumentsAspect()
|
InitialCMakeArgumentsAspect::InitialCMakeArgumentsAspect()
|
||||||
{
|
{
|
||||||
setSettingsKey("CMake.Initial.Parameters");
|
setSettingsKey("CMake.Initial.Parameters");
|
||||||
setLabelText(tr("Additional CMake options:"));
|
setLabelText(tr("Additional CMake <a href=\"options\">options</a>:"));
|
||||||
setDisplayStyle(LineEditDisplay);
|
setDisplayStyle(LineEditDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1728,7 +1740,7 @@ InitialCMakeArgumentsAspect::InitialCMakeArgumentsAspect()
|
|||||||
AdditionalCMakeOptionsAspect::AdditionalCMakeOptionsAspect()
|
AdditionalCMakeOptionsAspect::AdditionalCMakeOptionsAspect()
|
||||||
{
|
{
|
||||||
setSettingsKey("CMake.Additional.Options");
|
setSettingsKey("CMake.Additional.Options");
|
||||||
setLabelText(tr("Additional CMake options:"));
|
setLabelText(tr("Additional CMake <a href=\"options\">options</a>:"));
|
||||||
setDisplayStyle(LineEditDisplay);
|
setDisplayStyle(LineEditDisplay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -942,7 +942,12 @@ private:
|
|||||||
|
|
||||||
m_additionalEditor = new QLineEdit;
|
m_additionalEditor = new QLineEdit;
|
||||||
auto additionalLabel = new QLabel(m_dialog);
|
auto additionalLabel = new QLabel(m_dialog);
|
||||||
additionalLabel->setText(tr("Additional CMake options: "));
|
additionalLabel->setText(tr("Additional CMake <a href=\"options\">options</a>:"));
|
||||||
|
connect(additionalLabel, &QLabel::linkActivated, this, [this](const QString &link) {
|
||||||
|
const CMakeTool *tool = CMakeKitAspect::cmakeTool(kit());
|
||||||
|
if (tool)
|
||||||
|
tool->openCMakeHelpUrl("%1/manual/cmake.1.html#options");
|
||||||
|
});
|
||||||
|
|
||||||
auto additionalChooser = new VariableChooser(m_dialog);
|
auto additionalChooser = new VariableChooser(m_dialog);
|
||||||
additionalChooser->addSupportedWidget(m_additionalEditor);
|
additionalChooser->addSupportedWidget(m_additionalEditor);
|
||||||
|
@@ -27,6 +27,8 @@
|
|||||||
|
|
||||||
#include "cmaketoolmanager.h"
|
#include "cmaketoolmanager.h"
|
||||||
|
|
||||||
|
#include <coreplugin/helpmanager.h>
|
||||||
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
@@ -380,6 +382,28 @@ FilePath CMakeTool::searchQchFile(const FilePath &executable)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString CMakeTool::documentationUrl(bool online) const
|
||||||
|
{
|
||||||
|
if (online)
|
||||||
|
return QString("https://cmake.org/cmake/help/v%1.%2")
|
||||||
|
.arg(version().major)
|
||||||
|
.arg(version().minor);
|
||||||
|
|
||||||
|
return QString("qthelp://org.cmake.%1.%2.%3/doc")
|
||||||
|
.arg(version().major)
|
||||||
|
.arg(version().minor)
|
||||||
|
.arg(version().patch);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeTool::openCMakeHelpUrl(const QString &linkUrl) const
|
||||||
|
{
|
||||||
|
if (!isValid())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const bool online = qchFilePath().isEmpty();
|
||||||
|
Core::HelpManager::showHelpUrl(linkUrl.arg(documentationUrl(online)));
|
||||||
|
}
|
||||||
|
|
||||||
void CMakeTool::readInformation() const
|
void CMakeTool::readInformation() const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(m_introspection, return );
|
QTC_ASSERT(m_introspection, return );
|
||||||
|
@@ -112,6 +112,9 @@ public:
|
|||||||
QString detectionSource() const { return m_detectionSource; }
|
QString detectionSource() const { return m_detectionSource; }
|
||||||
void setDetectionSource(const QString &source) { m_detectionSource = source; }
|
void setDetectionSource(const QString &source) { m_detectionSource = source; }
|
||||||
|
|
||||||
|
QString documentationUrl(bool online) const;
|
||||||
|
void openCMakeHelpUrl(const QString &linkUrl) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void readInformation() const;
|
void readInformation() const;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user