forked from qt-creator/qt-creator
Make CMakeTool known to the Kits
This patch adds support for binding a specific CMakeTool to a Kit. When creating a new Kit or loading a existing one without a valid CMakeTool, the default CMakeTool will be set. Change-Id: I28d0843a01c583c4b31fc680a0ec556b40cd9c0d Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
@@ -33,11 +33,20 @@
|
|||||||
#include "cmakeprojectmanager.h"
|
#include "cmakeprojectmanager.h"
|
||||||
#include "cmakesettingspage.h"
|
#include "cmakesettingspage.h"
|
||||||
#include "cmaketoolmanager.h"
|
#include "cmaketoolmanager.h"
|
||||||
|
#include "cmakekitinformation.h"
|
||||||
|
|
||||||
#include <texteditor/codeassist/keywordscompletionassist.h>
|
#include <texteditor/codeassist/assistinterface.h>
|
||||||
|
#include <projectexplorer/projecttree.h>
|
||||||
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/kit.h>
|
||||||
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
|
#include <coreplugin/editormanager/editormanager.h>
|
||||||
|
#include <projectexplorer/session.h>
|
||||||
|
|
||||||
using namespace CMakeProjectManager::Internal;
|
using namespace CMakeProjectManager::Internal;
|
||||||
using namespace TextEditor;
|
using namespace TextEditor;
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
// -------------------------------
|
// -------------------------------
|
||||||
// CMakeFileCompletionAssistProvider
|
// CMakeFileCompletionAssistProvider
|
||||||
@@ -55,10 +64,31 @@ bool CMakeFileCompletionAssistProvider::supportsEditor(Core::Id editorId) const
|
|||||||
|
|
||||||
IAssistProcessor *CMakeFileCompletionAssistProvider::createProcessor() const
|
IAssistProcessor *CMakeFileCompletionAssistProvider::createProcessor() const
|
||||||
{
|
{
|
||||||
TextEditor::Keywords keywords = TextEditor::Keywords(QStringList(), QStringList(), QMap<QString, QStringList>());
|
return new CMakeFileCompletionAssist();
|
||||||
CMakeTool *cmake = CMakeToolManager::defaultCMakeTool();
|
}
|
||||||
if (cmake && cmake->isValid())
|
|
||||||
keywords = cmake->keywords();
|
|
||||||
|
CMakeFileCompletionAssist::CMakeFileCompletionAssist() :
|
||||||
return new KeywordsCompletionAssistProcessor(keywords);
|
KeywordsCompletionAssistProcessor(Keywords())
|
||||||
|
{}
|
||||||
|
|
||||||
|
IAssistProposal *CMakeFileCompletionAssist::perform(const AssistInterface *interface)
|
||||||
|
{
|
||||||
|
TextEditor::Keywords keywords;
|
||||||
|
|
||||||
|
QString fileName = interface->fileName();
|
||||||
|
if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) {
|
||||||
|
Utils::FileName file = Utils::FileName::fromString(fileName);
|
||||||
|
if (Project *p = SessionManager::projectForFile(file)) {
|
||||||
|
if (Target *t = p->activeTarget()) {
|
||||||
|
if (CMakeTool *cmake = CMakeKitInformation::cmakeTool(t->kit())) {
|
||||||
|
if (cmake->isValid())
|
||||||
|
keywords = cmake->keywords();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setKeywords(keywords);
|
||||||
|
return KeywordsCompletionAssistProcessor::perform(interface);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -32,12 +32,22 @@
|
|||||||
#define CMAKEFILECOMPLETIONASSIST_H
|
#define CMAKEFILECOMPLETIONASSIST_H
|
||||||
|
|
||||||
#include <texteditor/codeassist/completionassistprovider.h>
|
#include <texteditor/codeassist/completionassistprovider.h>
|
||||||
|
#include <texteditor/codeassist/keywordscompletionassist.h>
|
||||||
|
|
||||||
namespace CMakeProjectManager {
|
namespace CMakeProjectManager {
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
class CMakeSettingsPage;
|
class CMakeSettingsPage;
|
||||||
|
|
||||||
|
class CMakeFileCompletionAssist : public TextEditor::KeywordsCompletionAssistProcessor
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
CMakeFileCompletionAssist();
|
||||||
|
|
||||||
|
// IAssistProcessor interface
|
||||||
|
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
class CMakeFileCompletionAssistProvider : public TextEditor::CompletionAssistProvider
|
class CMakeFileCompletionAssistProvider : public TextEditor::CompletionAssistProvider
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|||||||
195
src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp
Normal file
195
src/plugins/cmakeprojectmanager/cmakekitconfigwidget.cpp
Normal file
@@ -0,0 +1,195 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Canonical Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmakeprojectconstants.h"
|
||||||
|
#include "cmakekitconfigwidget.h"
|
||||||
|
#include "cmakekitinformation.h"
|
||||||
|
#include "cmaketoolmanager.h"
|
||||||
|
#include "cmaketool.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <coreplugin/icore.h>
|
||||||
|
#include <projectexplorer/kit.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
|
namespace CMakeProjectManager {
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
CMakeKitConfigWidget::CMakeKitConfigWidget(ProjectExplorer::Kit *kit,
|
||||||
|
const ProjectExplorer::KitInformation *ki) :
|
||||||
|
ProjectExplorer::KitConfigWidget(kit, ki),
|
||||||
|
m_removingItem(false)
|
||||||
|
{
|
||||||
|
m_comboBox = new QComboBox;
|
||||||
|
m_comboBox->setEnabled(false);
|
||||||
|
m_comboBox->setToolTip(toolTip());
|
||||||
|
|
||||||
|
foreach (CMakeTool *tool, CMakeToolManager::cmakeTools())
|
||||||
|
cmakeToolAdded(tool->id());
|
||||||
|
|
||||||
|
updateComboBox();
|
||||||
|
|
||||||
|
refresh();
|
||||||
|
connect(m_comboBox, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
|
||||||
|
this, &CMakeKitConfigWidget::currentCMakeToolChanged);
|
||||||
|
|
||||||
|
m_manageButton = new QPushButton(KitConfigWidget::msgManage());
|
||||||
|
m_manageButton->setContentsMargins(0, 0, 0, 0);
|
||||||
|
connect(m_manageButton, &QPushButton::clicked,
|
||||||
|
this, &CMakeKitConfigWidget::manageCMakeTools);
|
||||||
|
|
||||||
|
CMakeToolManager *cmakeMgr = CMakeToolManager::instance();
|
||||||
|
connect(cmakeMgr, &CMakeToolManager::cmakeAdded,
|
||||||
|
this, &CMakeKitConfigWidget::cmakeToolAdded);
|
||||||
|
connect(cmakeMgr, &CMakeToolManager::cmakeRemoved,
|
||||||
|
this, &CMakeKitConfigWidget::cmakeToolRemoved);
|
||||||
|
connect(cmakeMgr, &CMakeToolManager::cmakeUpdated,
|
||||||
|
this, &CMakeKitConfigWidget::cmakeToolUpdated);
|
||||||
|
}
|
||||||
|
|
||||||
|
CMakeKitConfigWidget::~CMakeKitConfigWidget()
|
||||||
|
{
|
||||||
|
delete m_comboBox;
|
||||||
|
delete m_manageButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CMakeKitConfigWidget::displayName() const
|
||||||
|
{
|
||||||
|
return tr("CMake Tool:");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::makeReadOnly()
|
||||||
|
{
|
||||||
|
m_comboBox->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::refresh()
|
||||||
|
{
|
||||||
|
CMakeTool *tool = CMakeKitInformation::cmakeTool(m_kit);
|
||||||
|
m_comboBox->setCurrentIndex(tool == 0 ? -1 : indexOf(tool->id()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *CMakeKitConfigWidget::mainWidget() const
|
||||||
|
{
|
||||||
|
return m_comboBox;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget *CMakeKitConfigWidget::buttonWidget() const
|
||||||
|
{
|
||||||
|
return m_manageButton;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CMakeKitConfigWidget::toolTip() const
|
||||||
|
{
|
||||||
|
return tr("The CMake Tool to use when building a project with CMake.<br>"
|
||||||
|
"This setting is ignored when using other build systems.");
|
||||||
|
}
|
||||||
|
|
||||||
|
int CMakeKitConfigWidget::indexOf(const Core::Id &id)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < m_comboBox->count(); ++i) {
|
||||||
|
if (id == Core::Id::fromSetting(m_comboBox->itemData(i)))
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::cmakeToolAdded(const Core::Id &id)
|
||||||
|
{
|
||||||
|
const CMakeTool *tool = CMakeToolManager::findById(id);
|
||||||
|
QTC_ASSERT(tool, return);
|
||||||
|
|
||||||
|
m_comboBox->addItem(tool->displayName(), tool->id().toSetting());
|
||||||
|
updateComboBox();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::cmakeToolUpdated(const Core::Id &id)
|
||||||
|
{
|
||||||
|
const int pos = indexOf(id);
|
||||||
|
QTC_ASSERT(pos >= 0, return);
|
||||||
|
|
||||||
|
const CMakeTool *tool = CMakeToolManager::findById(id);
|
||||||
|
QTC_ASSERT(tool, return);
|
||||||
|
|
||||||
|
m_comboBox->setItemText(pos, tool->displayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::cmakeToolRemoved(const Core::Id &id)
|
||||||
|
{
|
||||||
|
const int pos = indexOf(id);
|
||||||
|
QTC_ASSERT(pos >= 0, return);
|
||||||
|
|
||||||
|
// do not handle the current index changed signal
|
||||||
|
m_removingItem = true;
|
||||||
|
m_comboBox->removeItem(pos);
|
||||||
|
m_removingItem = false;
|
||||||
|
|
||||||
|
// update the checkbox and set the current index
|
||||||
|
updateComboBox();
|
||||||
|
refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::updateComboBox()
|
||||||
|
{
|
||||||
|
// remove unavailable cmake tool:
|
||||||
|
int pos = indexOf(Core::Id());
|
||||||
|
if (pos >= 0)
|
||||||
|
m_comboBox->removeItem(pos);
|
||||||
|
|
||||||
|
if (m_comboBox->count() == 0) {
|
||||||
|
m_comboBox->addItem(tr("<No CMake Tool available>"),
|
||||||
|
Core::Id().toSetting());
|
||||||
|
m_comboBox->setEnabled(false);
|
||||||
|
} else {
|
||||||
|
m_comboBox->setEnabled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::currentCMakeToolChanged(int index)
|
||||||
|
{
|
||||||
|
if (m_removingItem)
|
||||||
|
return;
|
||||||
|
|
||||||
|
const Core::Id id = Core::Id::fromSetting(m_comboBox->itemData(index));
|
||||||
|
CMakeKitInformation::setCMakeTool(m_kit, id);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitConfigWidget::manageCMakeTools()
|
||||||
|
{
|
||||||
|
Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID,
|
||||||
|
buttonWidget());
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace CMakeProjectManager
|
||||||
82
src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h
Normal file
82
src/plugins/cmakeprojectmanager/cmakekitconfigwidget.h
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Canonical Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef CMAKEPROJECTMANAGER_INTERNAL_CMAKEKITCONFIGWIDGET_H
|
||||||
|
#define CMAKEPROJECTMANAGER_INTERNAL_CMAKEKITCONFIGWIDGET_H
|
||||||
|
|
||||||
|
#include <projectexplorer/kitconfigwidget.h>
|
||||||
|
|
||||||
|
namespace ProjectExplorer {
|
||||||
|
class Kit;
|
||||||
|
class KitInformation;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QComboBox)
|
||||||
|
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||||
|
|
||||||
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
|
class CMakeTool;
|
||||||
|
|
||||||
|
namespace Internal {
|
||||||
|
|
||||||
|
class CMakeKitConfigWidget : public ProjectExplorer::KitConfigWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CMakeKitConfigWidget(ProjectExplorer::Kit *kit, const ProjectExplorer::KitInformation *ki);
|
||||||
|
virtual ~CMakeKitConfigWidget();
|
||||||
|
|
||||||
|
// KitConfigWidget interface
|
||||||
|
QString displayName() const Q_DECL_OVERRIDE;
|
||||||
|
void makeReadOnly() Q_DECL_OVERRIDE;
|
||||||
|
void refresh() Q_DECL_OVERRIDE;
|
||||||
|
QWidget *mainWidget() const Q_DECL_OVERRIDE;
|
||||||
|
QWidget *buttonWidget() const Q_DECL_OVERRIDE;
|
||||||
|
QString toolTip() const Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
|
private:
|
||||||
|
int indexOf(const Core::Id &id);
|
||||||
|
void updateComboBox();
|
||||||
|
void cmakeToolAdded(const Core::Id &id);
|
||||||
|
void cmakeToolUpdated(const Core::Id &id);
|
||||||
|
void cmakeToolRemoved(const Core::Id &id);
|
||||||
|
void currentCMakeToolChanged(int index);
|
||||||
|
void manageCMakeTools();
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool m_removingItem;
|
||||||
|
QComboBox *m_comboBox;
|
||||||
|
QPushButton *m_manageButton;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Internal
|
||||||
|
} // namespace CMakeProjectManager
|
||||||
|
|
||||||
|
#endif // CMAKEPROJECTMANAGER_INTERNAL_CMAKEKITCONFIGWIDGET_H
|
||||||
144
src/plugins/cmakeprojectmanager/cmakekitinformation.cpp
Normal file
144
src/plugins/cmakeprojectmanager/cmakekitinformation.cpp
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Canonical Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#include "cmakekitinformation.h"
|
||||||
|
#include "cmakekitconfigwidget.h"
|
||||||
|
#include "cmaketoolmanager.h"
|
||||||
|
#include "cmaketool.h"
|
||||||
|
|
||||||
|
#include <utils/qtcassert.h>
|
||||||
|
#include <projectexplorer/task.h>
|
||||||
|
#include <projectexplorer/kit.h>
|
||||||
|
#include <projectexplorer/projectexplorerconstants.h>
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
|
CMakeKitInformation::CMakeKitInformation()
|
||||||
|
{
|
||||||
|
setObjectName(QLatin1String("CMakeKitInformation"));
|
||||||
|
setId(CMakeKitInformation::id());
|
||||||
|
|
||||||
|
//make sure the default value is set if a selected CMake is removed
|
||||||
|
connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeRemoved,
|
||||||
|
[this]() { foreach (Kit *k, KitManager::kits()) fix(k); });
|
||||||
|
|
||||||
|
//make sure the default value is set if a new default CMake is set
|
||||||
|
connect(CMakeToolManager::instance(), &CMakeToolManager::defaultCMakeChanged,
|
||||||
|
[this]() { foreach (Kit *k, KitManager::kits()) fix(k); });
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Id CMakeKitInformation::id()
|
||||||
|
{
|
||||||
|
return "CMakeProjectManager.CMakeKitInformation";
|
||||||
|
}
|
||||||
|
|
||||||
|
CMakeTool *CMakeKitInformation::cmakeTool(const Kit *k)
|
||||||
|
{
|
||||||
|
if (!k)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
const QVariant id = k->value(CMakeKitInformation::id());
|
||||||
|
return CMakeToolManager::findById(Core::Id::fromSetting(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitInformation::setCMakeTool(Kit *k, const Core::Id id)
|
||||||
|
{
|
||||||
|
QTC_ASSERT(k, return);
|
||||||
|
|
||||||
|
if (id.isValid()) {
|
||||||
|
// Only set cmake tools that are known to the manager
|
||||||
|
QTC_ASSERT(CMakeToolManager::findById(id), return);
|
||||||
|
k->setValue(CMakeKitInformation::id(), id.toSetting());
|
||||||
|
} else {
|
||||||
|
//setting a empty Core::Id will reset to the default value
|
||||||
|
k->setValue(CMakeKitInformation::id(),defaultValue().toSetting());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Core::Id CMakeKitInformation::defaultValue()
|
||||||
|
{
|
||||||
|
CMakeTool *defaultTool = CMakeToolManager::defaultCMakeTool();
|
||||||
|
if (defaultTool)
|
||||||
|
return defaultTool->id();
|
||||||
|
|
||||||
|
return Core::Id();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant CMakeKitInformation::defaultValue(Kit *) const
|
||||||
|
{
|
||||||
|
return defaultValue().toSetting();
|
||||||
|
}
|
||||||
|
|
||||||
|
QList<Task> CMakeKitInformation::validate(const Kit *k) const
|
||||||
|
{
|
||||||
|
CMakeTool *tool = CMakeKitInformation::cmakeTool(k);
|
||||||
|
QList<Task> result;
|
||||||
|
if (!tool) {
|
||||||
|
result.append(Task(Task::Warning,
|
||||||
|
tr("No CMake tool set."),
|
||||||
|
Utils::FileName(),
|
||||||
|
-1,
|
||||||
|
Core::Id(Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitInformation::setup(Kit *k)
|
||||||
|
{
|
||||||
|
CMakeTool *tool = CMakeKitInformation::cmakeTool(k);
|
||||||
|
if (tool)
|
||||||
|
return;
|
||||||
|
|
||||||
|
setCMakeTool(k, defaultValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
void CMakeKitInformation::fix(Kit *k)
|
||||||
|
{
|
||||||
|
CMakeTool *tool = CMakeKitInformation::cmakeTool(k);
|
||||||
|
if (!tool)
|
||||||
|
setup(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
KitInformation::ItemList CMakeKitInformation::toUserOutput(const Kit *k) const
|
||||||
|
{
|
||||||
|
CMakeTool *tool = cmakeTool(k);
|
||||||
|
return ItemList() << qMakePair(tr("CMake"), tool == 0 ? tr("Unconfigured") : tool->displayName());
|
||||||
|
}
|
||||||
|
|
||||||
|
KitConfigWidget *CMakeKitInformation::createConfigWidget(Kit *k) const
|
||||||
|
{
|
||||||
|
return new Internal::CMakeKitConfigWidget(k, this);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace CMakeProjectManager
|
||||||
64
src/plugins/cmakeprojectmanager/cmakekitinformation.h
Normal file
64
src/plugins/cmakeprojectmanager/cmakekitinformation.h
Normal file
@@ -0,0 +1,64 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
**
|
||||||
|
** Copyright (C) 2015 Canonical Ltd.
|
||||||
|
** Contact: http://www.qt.io/licensing
|
||||||
|
**
|
||||||
|
** This file is part of Qt Creator.
|
||||||
|
**
|
||||||
|
** Commercial License Usage
|
||||||
|
** Licensees holding valid commercial Qt licenses may use this file in
|
||||||
|
** accordance with the commercial license agreement provided with the
|
||||||
|
** Software or, alternatively, in accordance with the terms contained in
|
||||||
|
** a written agreement between you and The Qt Company. For licensing terms and
|
||||||
|
** conditions see http://www.qt.io/terms-conditions. For further information
|
||||||
|
** use the contact form at http://www.qt.io/contact-us.
|
||||||
|
**
|
||||||
|
** GNU Lesser General Public License Usage
|
||||||
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||||
|
** General Public License version 2.1 or version 3 as published by the Free
|
||||||
|
** Software Foundation and appearing in the file LICENSE.LGPLv21 and
|
||||||
|
** LICENSE.LGPLv3 included in the packaging of this file. Please review the
|
||||||
|
** following information to ensure the GNU Lesser General Public License
|
||||||
|
** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
|
||||||
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||||
|
**
|
||||||
|
** In addition, as a special exception, The Qt Company gives you certain additional
|
||||||
|
** rights. These rights are described in The Qt Company LGPL Exception
|
||||||
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
|
**
|
||||||
|
****************************************************************************/
|
||||||
|
#ifndef CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H
|
||||||
|
#define CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H
|
||||||
|
|
||||||
|
#include "cmake_global.h"
|
||||||
|
|
||||||
|
#include <projectexplorer/kitmanager.h>
|
||||||
|
|
||||||
|
namespace CMakeProjectManager {
|
||||||
|
|
||||||
|
class CMakeTool;
|
||||||
|
|
||||||
|
class CMAKE_EXPORT CMakeKitInformation : public ProjectExplorer::KitInformation
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
CMakeKitInformation();
|
||||||
|
|
||||||
|
static Core::Id id();
|
||||||
|
|
||||||
|
static CMakeTool *cmakeTool(const ProjectExplorer::Kit *k);
|
||||||
|
static void setCMakeTool(ProjectExplorer::Kit *k, const Core::Id id);
|
||||||
|
static Core::Id defaultValue();
|
||||||
|
|
||||||
|
// KitInformation interface
|
||||||
|
QVariant defaultValue(ProjectExplorer::Kit *) const Q_DECL_OVERRIDE;
|
||||||
|
QList<ProjectExplorer::Task> validate(const ProjectExplorer::Kit *k) const Q_DECL_OVERRIDE;
|
||||||
|
void setup(ProjectExplorer::Kit *k) Q_DECL_OVERRIDE;
|
||||||
|
void fix(ProjectExplorer::Kit *k) Q_DECL_OVERRIDE;
|
||||||
|
virtual ItemList toUserOutput(const ProjectExplorer::Kit *k) const Q_DECL_OVERRIDE;
|
||||||
|
virtual ProjectExplorer::KitConfigWidget *createConfigWidget(ProjectExplorer::Kit *k) const Q_DECL_OVERRIDE;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace CMakeProjectManager
|
||||||
|
|
||||||
|
#endif // CMAKEPROJECTMANAGER_CMAKEKITINFORMATION_H
|
||||||
@@ -28,11 +28,14 @@
|
|||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakeopenprojectwizard.h"
|
#include "cmakeopenprojectwizard.h"
|
||||||
#include "cmakeprojectmanager.h"
|
#include "cmakeprojectmanager.h"
|
||||||
#include "cmaketoolmanager.h"
|
#include "cmaketoolmanager.h"
|
||||||
#include "cmakebuildconfiguration.h"
|
#include "cmakebuildconfiguration.h"
|
||||||
#include "cmakebuildinfo.h"
|
#include "cmakebuildinfo.h"
|
||||||
|
#include "cmakekitinformation.h"
|
||||||
|
#include "cmaketool.h"
|
||||||
#include "generatorinfo.h"
|
#include "generatorinfo.h"
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
@@ -85,6 +88,9 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm
|
|||||||
m_useNinja(false),
|
m_useNinja(false),
|
||||||
m_kit(0)
|
m_kit(0)
|
||||||
{
|
{
|
||||||
|
if (CMakeToolManager::cmakeTools().isEmpty())
|
||||||
|
addPage(new NoCMakePage(this));
|
||||||
|
|
||||||
if (!compatibleKitExist())
|
if (!compatibleKitExist())
|
||||||
addPage(new NoKitPage(this));
|
addPage(new NoKitPage(this));
|
||||||
|
|
||||||
@@ -96,9 +102,6 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm
|
|||||||
addPage(new ShadowBuildPage(this));
|
addPage(new ShadowBuildPage(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_cmakeManager->isCMakeExecutableValid())
|
|
||||||
addPage(new ChooseCMakePage(this));
|
|
||||||
|
|
||||||
addPage(new CMakeRunPage(this));
|
addPage(new CMakeRunPage(this));
|
||||||
|
|
||||||
init();
|
init();
|
||||||
@@ -129,8 +132,9 @@ CMakeOpenProjectWizard::CMakeOpenProjectWizard(QWidget *parent, CMakeManager *cm
|
|||||||
m_buildDirectory = info->buildDirectory.toString();
|
m_buildDirectory = info->buildDirectory.toString();
|
||||||
addPage(new ShadowBuildPage(this, true));
|
addPage(new ShadowBuildPage(this, true));
|
||||||
}
|
}
|
||||||
if (!m_cmakeManager->isCMakeExecutableValid())
|
|
||||||
addPage(new ChooseCMakePage(this));
|
if (CMakeToolManager::cmakeTools().isEmpty())
|
||||||
|
addPage(new NoCMakePage(this));
|
||||||
|
|
||||||
addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString()));
|
addPage(new CMakeRunPage(this, rmode, info->buildDirectory.toString()));
|
||||||
init();
|
init();
|
||||||
@@ -153,13 +157,17 @@ bool CMakeOpenProjectWizard::hasInSourceBuild() const
|
|||||||
|
|
||||||
bool CMakeOpenProjectWizard::compatibleKitExist() const
|
bool CMakeOpenProjectWizard::compatibleKitExist() const
|
||||||
{
|
{
|
||||||
bool hasCodeBlocksGenerator = m_cmakeManager->hasCodeBlocksMsvcGenerator();
|
|
||||||
bool hasNinjaGenerator = m_cmakeManager->hasCodeBlocksNinjaGenerator();
|
|
||||||
bool preferNinja = m_cmakeManager->preferNinja();
|
bool preferNinja = m_cmakeManager->preferNinja();
|
||||||
|
|
||||||
QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits();
|
QList<ProjectExplorer::Kit *> kitList = ProjectExplorer::KitManager::kits();
|
||||||
|
|
||||||
foreach (ProjectExplorer::Kit *k, kitList) {
|
foreach (ProjectExplorer::Kit *k, kitList) {
|
||||||
|
CMakeTool *cmake = CMakeKitInformation::cmakeTool(k);
|
||||||
|
if (!cmake)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool hasCodeBlocksGenerator = cmake->hasCodeBlocksMsvcGenerator();
|
||||||
|
bool hasNinjaGenerator = cmake->hasCodeBlocksNinjaGenerator();
|
||||||
|
|
||||||
// OfferNinja and ForceNinja differ in what they return
|
// OfferNinja and ForceNinja differ in what they return
|
||||||
// but not whether the list is empty or not, which is what we
|
// but not whether the list is empty or not, which is what we
|
||||||
// are interested in here
|
// are interested in here
|
||||||
@@ -288,6 +296,12 @@ bool NoKitPage::isComplete() const
|
|||||||
return m_cmakeWizard->compatibleKitExist();
|
return m_cmakeWizard->compatibleKitExist();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void NoKitPage::initializePage()
|
||||||
|
{
|
||||||
|
//if the NoCMakePage was added, we need to recheck if kits exist
|
||||||
|
kitsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
void NoKitPage::showOptions()
|
void NoKitPage::showOptions()
|
||||||
{
|
{
|
||||||
Core::ICore::showOptionsDialog(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID, this);
|
Core::ICore::showOptionsDialog(ProjectExplorer::Constants::KITS_SETTINGS_PAGE_ID, this);
|
||||||
@@ -338,67 +352,60 @@ void ShadowBuildPage::buildDirectoryChanged()
|
|||||||
m_cmakeWizard->setBuildDirectory(m_pc->path());
|
m_cmakeWizard->setBuildDirectory(m_pc->path());
|
||||||
}
|
}
|
||||||
|
|
||||||
ChooseCMakePage::ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard)
|
//////
|
||||||
: QWizardPage(cmakeWizard), m_cmakeWizard(cmakeWizard)
|
// NoCMakePage
|
||||||
|
/////
|
||||||
|
|
||||||
|
NoCMakePage::NoCMakePage(CMakeOpenProjectWizard *cmakeWizard)
|
||||||
|
: QWizardPage(cmakeWizard)
|
||||||
{
|
{
|
||||||
QFormLayout *fl = new QFormLayout;
|
QVBoxLayout *layout = new QVBoxLayout;
|
||||||
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
setLayout(layout);
|
||||||
setLayout(fl);
|
|
||||||
|
|
||||||
m_cmakeLabel = new QLabel;
|
m_descriptionLabel = new QLabel(this);
|
||||||
m_cmakeLabel->setWordWrap(true);
|
m_descriptionLabel->setWordWrap(true);
|
||||||
fl->addRow(m_cmakeLabel);
|
layout->addWidget(m_descriptionLabel);
|
||||||
// Show a field for the user to enter
|
|
||||||
m_cmakeExecutable = new Utils::PathChooser(this);
|
|
||||||
m_cmakeExecutable->setExpectedKind(Utils::PathChooser::ExistingCommand);
|
|
||||||
m_cmakeExecutable->setHistoryCompleter(QLatin1String("Cmake.Command.History"));
|
|
||||||
fl->addRow(tr("CMake Executable:"), m_cmakeExecutable);
|
|
||||||
|
|
||||||
connect(m_cmakeExecutable, SIGNAL(editingFinished()),
|
m_optionsButton = new QPushButton;
|
||||||
this, SLOT(cmakeExecutableChanged()));
|
m_optionsButton->setText(Core::ICore::msgShowOptionsDialog());
|
||||||
connect(m_cmakeExecutable, SIGNAL(browsingFinished()),
|
|
||||||
this, SLOT(cmakeExecutableChanged()));
|
|
||||||
|
|
||||||
setTitle(tr("Choose CMake Executable"));
|
connect(m_optionsButton, SIGNAL(clicked()),
|
||||||
|
this, SLOT(showOptions()));
|
||||||
|
|
||||||
|
QHBoxLayout *hbox = new QHBoxLayout;
|
||||||
|
hbox->addWidget(m_optionsButton);
|
||||||
|
hbox->addStretch();
|
||||||
|
|
||||||
|
layout->addLayout(hbox);
|
||||||
|
|
||||||
|
setTitle(tr("Check CMake Tools"));
|
||||||
|
|
||||||
|
connect(CMakeToolManager::instance(), &CMakeToolManager::cmakeToolsChanged,
|
||||||
|
this, &NoCMakePage::cmakeToolsChanged);
|
||||||
|
|
||||||
|
cmakeToolsChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
void ChooseCMakePage::updateErrorText()
|
void NoCMakePage::cmakeToolsChanged()
|
||||||
{
|
{
|
||||||
QString cmakeExecutable = m_cmakeWizard->cmakeManager()->cmakeExecutable();
|
if (isComplete()) {
|
||||||
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
|
m_descriptionLabel->setText(tr("There are CMake Tools registered."));
|
||||||
m_cmakeLabel->setText(tr("The CMake executable is valid."));
|
m_optionsButton->setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
QString text = tr("Specify the path to the CMake executable. No CMake executable was found in the path.");
|
m_descriptionLabel->setText(tr("Qt Creator has no CMake Tools that are required for CMake projects. Please configure at least one."));
|
||||||
if (!cmakeExecutable.isEmpty()) {
|
m_optionsButton->setVisible(true);
|
||||||
text += QLatin1Char(' ');
|
|
||||||
QFileInfo fi(cmakeExecutable);
|
|
||||||
if (!fi.exists())
|
|
||||||
text += tr("The CMake executable (%1) does not exist.").arg(cmakeExecutable);
|
|
||||||
else if (!fi.isExecutable())
|
|
||||||
text += tr("The path %1 is not an executable.").arg(cmakeExecutable);
|
|
||||||
else
|
|
||||||
text += tr("The path %1 is not a valid CMake executable.").arg(cmakeExecutable);
|
|
||||||
}
|
|
||||||
m_cmakeLabel->setText(text);
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void ChooseCMakePage::cmakeExecutableChanged()
|
|
||||||
{
|
|
||||||
CMakeTool *cmake = CMakeToolManager::defaultCMakeTool();
|
|
||||||
if (!cmake) {
|
|
||||||
Core::Id id = CMakeToolManager::registerOrFindCMakeTool(m_cmakeExecutable->fileName());
|
|
||||||
CMakeToolManager::setDefaultCMakeTool(id);
|
|
||||||
} else {
|
|
||||||
cmake->setCMakeExecutable(m_cmakeExecutable->fileName());
|
|
||||||
}
|
|
||||||
updateErrorText();
|
|
||||||
emit completeChanged();
|
emit completeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ChooseCMakePage::isComplete() const
|
bool NoCMakePage::isComplete() const
|
||||||
{
|
{
|
||||||
return m_cmakeWizard->cmakeManager()->isCMakeExecutableValid();
|
return !CMakeToolManager::cmakeTools().isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
void NoCMakePage::showOptions()
|
||||||
|
{
|
||||||
|
Core::ICore::showOptionsDialog(Constants::CMAKE_SETTINGSPAGE_ID, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory)
|
CMakeRunPage::CMakeRunPage(CMakeOpenProjectWizard *cmakeWizard, Mode mode, const QString &buildDirectory)
|
||||||
@@ -531,8 +538,6 @@ void CMakeRunPage::initializePage()
|
|||||||
// Build the list of generators/toolchains we want to offer
|
// Build the list of generators/toolchains we want to offer
|
||||||
m_generatorComboBox->clear();
|
m_generatorComboBox->clear();
|
||||||
|
|
||||||
bool hasCodeBlocksGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksMsvcGenerator();
|
|
||||||
bool hasNinjaGenerator = m_cmakeWizard->cmakeManager()->hasCodeBlocksNinjaGenerator();
|
|
||||||
bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja();
|
bool preferNinja = m_cmakeWizard->cmakeManager()->preferNinja();
|
||||||
|
|
||||||
if (m_mode == Initial) {
|
if (m_mode == Initial) {
|
||||||
@@ -544,6 +549,13 @@ void CMakeRunPage::initializePage()
|
|||||||
int defaultIndex = 0;
|
int defaultIndex = 0;
|
||||||
|
|
||||||
foreach (ProjectExplorer::Kit *k, kitList) {
|
foreach (ProjectExplorer::Kit *k, kitList) {
|
||||||
|
CMakeTool *cmake = CMakeKitInformation::cmakeTool(k);
|
||||||
|
if (!cmake)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
bool hasCodeBlocksGenerator = cmake->hasCodeBlocksMsvcGenerator();
|
||||||
|
bool hasNinjaGenerator = cmake->hasCodeBlocksNinjaGenerator();
|
||||||
|
|
||||||
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
|
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(k,
|
||||||
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
|
hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja,
|
||||||
preferNinja,
|
preferNinja,
|
||||||
@@ -568,22 +580,26 @@ void CMakeRunPage::initializePage()
|
|||||||
|
|
||||||
m_generatorComboBox->setCurrentIndex(defaultIndex);
|
m_generatorComboBox->setCurrentIndex(defaultIndex);
|
||||||
} else {
|
} else {
|
||||||
// Note: We don't compare the actually cached generator to what is set in the buildconfiguration
|
QList<GeneratorInfo> infos;
|
||||||
// We assume that the buildconfiguration is correct
|
CMakeTool *cmake = CMakeKitInformation::cmakeTool(m_cmakeWizard->kit());
|
||||||
GeneratorInfo::Ninja ninja;
|
if (cmake) {
|
||||||
if (m_mode == CMakeRunPage::NeedToUpdate || m_mode == CMakeRunPage::WantToUpdate) {
|
// Note: We don't compare the actually cached generator to what is set in the buildconfiguration
|
||||||
ninja = m_cmakeWizard->useNinja() ? GeneratorInfo::ForceNinja : GeneratorInfo::NoNinja;
|
// We assume that the buildconfiguration is correct
|
||||||
} else { // Recreate, ChangeDirectory
|
GeneratorInfo::Ninja ninja;
|
||||||
// Note: ReCreate is technically just a removed .cbp file, we assume the cache
|
if (m_mode == CMakeRunPage::NeedToUpdate || m_mode == CMakeRunPage::WantToUpdate) {
|
||||||
// got removed too. If the cache still exists the error message from cmake should
|
ninja = m_cmakeWizard->useNinja() ? GeneratorInfo::ForceNinja : GeneratorInfo::NoNinja;
|
||||||
// be a good hint to change the generator
|
} else { // Recreate, ChangeDirectory
|
||||||
ninja = hasNinjaGenerator ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja;
|
// Note: ReCreate is technically just a removed .cbp file, we assume the cache
|
||||||
}
|
// got removed too. If the cache still exists the error message from cmake should
|
||||||
|
// be a good hint to change the generator
|
||||||
|
ninja = cmake->hasCodeBlocksNinjaGenerator() ? GeneratorInfo::OfferNinja : GeneratorInfo::NoNinja;
|
||||||
|
}
|
||||||
|
|
||||||
QList<GeneratorInfo> infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(),
|
infos = GeneratorInfo::generatorInfosFor(m_cmakeWizard->kit(),
|
||||||
ninja,
|
ninja,
|
||||||
preferNinja,
|
preferNinja,
|
||||||
true);
|
true);
|
||||||
|
}
|
||||||
foreach (const GeneratorInfo &info, infos)
|
foreach (const GeneratorInfo &info, infos)
|
||||||
m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info));
|
m_generatorComboBox->addItem(info.displayName(), qVariantFromValue(info));
|
||||||
}
|
}
|
||||||
@@ -626,19 +642,21 @@ void CMakeRunPage::runCMake()
|
|||||||
|
|
||||||
m_output->clear();
|
m_output->clear();
|
||||||
|
|
||||||
|
CMakeTool *cmake = CMakeKitInformation::cmakeTool(generatorInfo.kit());
|
||||||
CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager();
|
CMakeManager *cmakeManager = m_cmakeWizard->cmakeManager();
|
||||||
if (m_cmakeWizard->cmakeManager()->isCMakeExecutableValid()) {
|
if (cmake && cmake->isValid()) {
|
||||||
m_cmakeProcess = new Utils::QtcProcess();
|
m_cmakeProcess = new Utils::QtcProcess();
|
||||||
connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput()));
|
connect(m_cmakeProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(cmakeReadyReadStandardOutput()));
|
||||||
connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError()));
|
connect(m_cmakeProcess, SIGNAL(readyReadStandardError()), this, SLOT(cmakeReadyReadStandardError()));
|
||||||
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
|
connect(m_cmakeProcess, SIGNAL(finished(int)), this, SLOT(cmakeFinished()));
|
||||||
cmakeManager->createXmlFile(m_cmakeProcess, m_argumentsLineEdit->text(), m_cmakeWizard->sourceDirectory(),
|
cmakeManager->createXmlFile(m_cmakeProcess, cmake->cmakeExecutable().toString(), m_argumentsLineEdit->text(),
|
||||||
m_buildDirectory, env, QString::fromLatin1(generatorInfo.generatorArgument()));
|
m_cmakeWizard->sourceDirectory(), m_buildDirectory, env,
|
||||||
|
QString::fromLatin1(generatorInfo.generatorArgument()));
|
||||||
} else {
|
} else {
|
||||||
m_runCMake->setEnabled(true);
|
m_runCMake->setEnabled(true);
|
||||||
m_argumentsLineEdit->setEnabled(true);
|
m_argumentsLineEdit->setEnabled(true);
|
||||||
m_generatorComboBox->setEnabled(true);
|
m_generatorComboBox->setEnabled(true);
|
||||||
m_output->appendPlainText(tr("No valid CMake executable specified."));
|
m_output->appendPlainText(tr("Selected Kit has no valid CMake executable specified."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -109,7 +109,8 @@ class NoKitPage : public QWizardPage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
NoKitPage(CMakeOpenProjectWizard *cmakeWizard);
|
NoKitPage(CMakeOpenProjectWizard *cmakeWizard);
|
||||||
bool isComplete() const;
|
bool isComplete() const Q_DECL_OVERRIDE;
|
||||||
|
void initializePage() Q_DECL_OVERRIDE;
|
||||||
private slots:
|
private slots:
|
||||||
void kitsChanged();
|
void kitsChanged();
|
||||||
void showOptions();
|
void showOptions();
|
||||||
@@ -140,20 +141,18 @@ private:
|
|||||||
Utils::PathChooser *m_pc;
|
Utils::PathChooser *m_pc;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ChooseCMakePage : public QWizardPage
|
class NoCMakePage : public QWizardPage
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
ChooseCMakePage(CMakeOpenProjectWizard *cmakeWizard);
|
NoCMakePage(CMakeOpenProjectWizard *cmakeWizard);
|
||||||
|
bool isComplete() const;
|
||||||
virtual bool isComplete() const;
|
private slots:
|
||||||
public slots:
|
void cmakeToolsChanged();
|
||||||
void cmakeExecutableChanged();
|
void showOptions();
|
||||||
private:
|
private:
|
||||||
void updateErrorText();
|
QLabel *m_descriptionLabel;
|
||||||
QLabel *m_cmakeLabel;
|
QPushButton *m_optionsButton;
|
||||||
CMakeOpenProjectWizard *m_cmakeWizard;
|
|
||||||
Utils::PathChooser *m_cmakeExecutable;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class CMakeRunPage : public QWizardPage
|
class CMakeRunPage : public QWizardPage
|
||||||
|
|||||||
@@ -51,6 +51,9 @@ const char CMAKE_BC_ID[] = "CMakeProjectManager.CMakeBuildConfiguration";
|
|||||||
// Menu
|
// Menu
|
||||||
const char M_CONTEXT[] = "CMakeEditor.ContextMenu";
|
const char M_CONTEXT[] = "CMakeEditor.ContextMenu";
|
||||||
|
|
||||||
|
// Settings page
|
||||||
|
const char CMAKE_SETTINGSPAGE_ID[] = "Z.CMake";
|
||||||
|
|
||||||
} // namespace Constants
|
} // namespace Constants
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
|
||||||
|
|||||||
@@ -128,38 +128,6 @@ QString CMakeManager::mimeType() const
|
|||||||
return QLatin1String(Constants::CMAKEPROJECTMIMETYPE);
|
return QLatin1String(Constants::CMAKEPROJECTMIMETYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString CMakeManager::cmakeExecutable() const
|
|
||||||
{
|
|
||||||
CMakeTool *cmake = CMakeToolManager::defaultCMakeTool();
|
|
||||||
if (cmake)
|
|
||||||
return cmake->cmakeExecutable().toString();
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeManager::isCMakeExecutableValid() const
|
|
||||||
{
|
|
||||||
CMakeTool *cmake = CMakeToolManager::defaultCMakeTool();
|
|
||||||
if (cmake)
|
|
||||||
return cmake->isValid();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeManager::hasCodeBlocksMsvcGenerator() const
|
|
||||||
{
|
|
||||||
CMakeTool *cmake = CMakeToolManager::defaultCMakeTool();
|
|
||||||
if (cmake)
|
|
||||||
return cmake->hasCodeBlocksMsvcGenerator();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeManager::hasCodeBlocksNinjaGenerator() const
|
|
||||||
{
|
|
||||||
CMakeTool *cmake = CMakeToolManager::defaultCMakeTool();
|
|
||||||
if (cmake)
|
|
||||||
return cmake->hasCodeBlocksNinjaGenerator();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CMakeManager::preferNinja() const
|
bool CMakeManager::preferNinja() const
|
||||||
{
|
{
|
||||||
return CMakeToolManager::preferNinja();
|
return CMakeToolManager::preferNinja();
|
||||||
@@ -169,7 +137,7 @@ bool CMakeManager::preferNinja() const
|
|||||||
// we probably want the process instead of this function
|
// we probably want the process instead of this function
|
||||||
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
|
// cmakeproject then could even run the cmake process in the background, adding the files afterwards
|
||||||
// sounds like a plan
|
// sounds like a plan
|
||||||
void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &arguments,
|
void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &executable, const QString &arguments,
|
||||||
const QString &sourceDirectory, const QDir &buildDirectory,
|
const QString &sourceDirectory, const QDir &buildDirectory,
|
||||||
const Utils::Environment &env, const QString &generator)
|
const Utils::Environment &env, const QString &generator)
|
||||||
{
|
{
|
||||||
@@ -184,7 +152,7 @@ void CMakeManager::createXmlFile(Utils::QtcProcess *proc, const QString &argumen
|
|||||||
Utils::QtcProcess::addArg(&args, srcdir);
|
Utils::QtcProcess::addArg(&args, srcdir);
|
||||||
Utils::QtcProcess::addArgs(&args, arguments);
|
Utils::QtcProcess::addArgs(&args, arguments);
|
||||||
Utils::QtcProcess::addArg(&args, generator);
|
Utils::QtcProcess::addArg(&args, generator);
|
||||||
proc->setCommand(cmakeExecutable(), args);
|
proc->setCommand(executable, args);
|
||||||
proc->start();
|
proc->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,17 +58,13 @@ public:
|
|||||||
virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
|
virtual ProjectExplorer::Project *openProject(const QString &fileName, QString *errorString);
|
||||||
virtual QString mimeType() const;
|
virtual QString mimeType() const;
|
||||||
|
|
||||||
QString cmakeExecutable() const;
|
|
||||||
bool isCMakeExecutableValid() const;
|
|
||||||
|
|
||||||
void createXmlFile(Utils::QtcProcess *process,
|
void createXmlFile(Utils::QtcProcess *process,
|
||||||
|
const QString &executable,
|
||||||
const QString &arguments,
|
const QString &arguments,
|
||||||
const QString &sourceDirectory,
|
const QString &sourceDirectory,
|
||||||
const QDir &buildDirectory,
|
const QDir &buildDirectory,
|
||||||
const Utils::Environment &env,
|
const Utils::Environment &env,
|
||||||
const QString &generator);
|
const QString &generator);
|
||||||
bool hasCodeBlocksMsvcGenerator() const;
|
|
||||||
bool hasCodeBlocksNinjaGenerator() const;
|
|
||||||
bool preferNinja() const;
|
bool preferNinja() const;
|
||||||
static QString findCbpFile(const QDir &);
|
static QString findCbpFile(const QDir &);
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,9 @@ HEADERS = cmakebuildinfo.h \
|
|||||||
generatorinfo.h \
|
generatorinfo.h \
|
||||||
cmakesettingspage.h \
|
cmakesettingspage.h \
|
||||||
cmaketoolmanager.h \
|
cmaketoolmanager.h \
|
||||||
cmake_global.h
|
cmake_global.h \
|
||||||
|
cmakekitinformation.h \
|
||||||
|
cmakekitconfigwidget.h
|
||||||
|
|
||||||
SOURCES = cmakeproject.cpp \
|
SOURCES = cmakeproject.cpp \
|
||||||
cmakeprojectplugin.cpp \
|
cmakeprojectplugin.cpp \
|
||||||
@@ -36,7 +38,9 @@ SOURCES = cmakeproject.cpp \
|
|||||||
cmakeparser.cpp \
|
cmakeparser.cpp \
|
||||||
generatorinfo.cpp \
|
generatorinfo.cpp \
|
||||||
cmakesettingspage.cpp \
|
cmakesettingspage.cpp \
|
||||||
cmaketoolmanager.cpp
|
cmaketoolmanager.cpp \
|
||||||
|
cmakekitinformation.cpp \
|
||||||
|
cmakekitconfigwidget.cpp
|
||||||
|
|
||||||
|
|
||||||
RESOURCES += cmakeproject.qrc
|
RESOURCES += cmakeproject.qrc
|
||||||
|
|||||||
@@ -26,6 +26,10 @@ QtcPlugin {
|
|||||||
"cmakeeditor.h",
|
"cmakeeditor.h",
|
||||||
"cmakefilecompletionassist.cpp",
|
"cmakefilecompletionassist.cpp",
|
||||||
"cmakefilecompletionassist.h",
|
"cmakefilecompletionassist.h",
|
||||||
|
"cmakekitconfigwidget.h",
|
||||||
|
"cmakekitconfigwidget.cpp",
|
||||||
|
"cmakekitinformation.h",
|
||||||
|
"cmakekitinformation.cpp",
|
||||||
"cmakelocatorfilter.cpp",
|
"cmakelocatorfilter.cpp",
|
||||||
"cmakelocatorfilter.h",
|
"cmakelocatorfilter.h",
|
||||||
"cmakeopenprojectwizard.cpp",
|
"cmakeopenprojectwizard.cpp",
|
||||||
|
|||||||
@@ -37,12 +37,13 @@
|
|||||||
#include "makestep.h"
|
#include "makestep.h"
|
||||||
#include "cmakeprojectconstants.h"
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakelocatorfilter.h"
|
#include "cmakelocatorfilter.h"
|
||||||
#include "cmakefilecompletionassist.h"
|
|
||||||
#include "cmakesettingspage.h"
|
#include "cmakesettingspage.h"
|
||||||
#include "cmaketoolmanager.h"
|
#include "cmaketoolmanager.h"
|
||||||
|
#include "cmakekitinformation.h"
|
||||||
|
|
||||||
#include <coreplugin/featureprovider.h>
|
#include <coreplugin/featureprovider.h>
|
||||||
#include <utils/mimetypes/mimedatabase.h>
|
#include <utils/mimetypes/mimedatabase.h>
|
||||||
|
#include <projectexplorer/kitmanager.h>
|
||||||
|
|
||||||
#include <QtPlugin>
|
#include <QtPlugin>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
@@ -70,11 +71,12 @@ bool CMakeProjectPlugin::initialize(const QStringList & /*arguments*/, QString *
|
|||||||
addAutoReleasedObject(new CMakeBuildConfigurationFactory);
|
addAutoReleasedObject(new CMakeBuildConfigurationFactory);
|
||||||
addAutoReleasedObject(new CMakeEditorFactory);
|
addAutoReleasedObject(new CMakeEditorFactory);
|
||||||
addAutoReleasedObject(new CMakeLocatorFilter);
|
addAutoReleasedObject(new CMakeLocatorFilter);
|
||||||
addAutoReleasedObject(new CMakeFileCompletionAssistProvider);
|
|
||||||
|
|
||||||
new CMakeToolManager(this);
|
new CMakeToolManager(this);
|
||||||
CMakeToolManager::restoreCMakeTools();
|
CMakeToolManager::restoreCMakeTools();
|
||||||
|
|
||||||
|
ProjectExplorer::KitManager::registerKitInformation(new CMakeKitInformation);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||||
**
|
**
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#include "cmakeprojectconstants.h"
|
||||||
#include "cmakesettingspage.h"
|
#include "cmakesettingspage.h"
|
||||||
#include "cmaketoolmanager.h"
|
#include "cmaketoolmanager.h"
|
||||||
|
|
||||||
@@ -393,6 +394,7 @@ public:
|
|||||||
|
|
||||||
m_makeDefButton = new QPushButton(tr("Make Default"), this);
|
m_makeDefButton = new QPushButton(tr("Make Default"), this);
|
||||||
m_makeDefButton->setEnabled(false);
|
m_makeDefButton->setEnabled(false);
|
||||||
|
m_makeDefButton->setToolTip(tr("Set as the default CMake Tool to use when creating a new Kit, or no value is set."));
|
||||||
|
|
||||||
m_preferNinjaCheckBox = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
|
m_preferNinjaCheckBox = new QCheckBox(tr("Prefer Ninja generator (CMake 2.8.9 or higher required)"));
|
||||||
m_preferNinjaCheckBox->setChecked(CMakeToolManager::preferNinja());
|
m_preferNinjaCheckBox->setChecked(CMakeToolManager::preferNinja());
|
||||||
@@ -539,7 +541,7 @@ void CMakeToolConfigWidget::currentCMakeToolChanged(const QModelIndex &newCurren
|
|||||||
|
|
||||||
CMakeSettingsPage::CMakeSettingsPage() : m_widget(0)
|
CMakeSettingsPage::CMakeSettingsPage() : m_widget(0)
|
||||||
{
|
{
|
||||||
setId("Z.CMake");
|
setId(Constants::CMAKE_SETTINGSPAGE_ID);
|
||||||
setDisplayName(tr("CMake"));
|
setDisplayName(tr("CMake"));
|
||||||
setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
|
setCategory(ProjectExplorer::Constants::PROJECTEXPLORER_SETTINGS_CATEGORY);
|
||||||
setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
|
setDisplayCategory(QCoreApplication::translate("ProjectExplorer",
|
||||||
|
|||||||
@@ -29,6 +29,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "cmaketool.h"
|
#include "cmaketool.h"
|
||||||
|
#include "cmaketoolmanager.h"
|
||||||
|
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
|
|
||||||
@@ -106,6 +107,8 @@ void CMakeTool::setCMakeExecutable(const Utils::FileName &executable)
|
|||||||
} else {
|
} else {
|
||||||
m_state = CMakeTool::Invalid;
|
m_state = CMakeTool::Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMakeToolManager::notifyAboutUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CMakeTool::finished(int exitCode)
|
void CMakeTool::finished(int exitCode)
|
||||||
@@ -274,6 +277,7 @@ QString CMakeTool::displayName() const
|
|||||||
void CMakeTool::setDisplayName(const QString &displayName)
|
void CMakeTool::setDisplayName(const QString &displayName)
|
||||||
{
|
{
|
||||||
m_displayName = displayName;
|
m_displayName = displayName;
|
||||||
|
CMakeToolManager::notifyAboutUpdate(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -72,11 +72,11 @@ static void addCMakeTool(CMakeTool *item)
|
|||||||
{
|
{
|
||||||
QTC_ASSERT(item->id().isValid(), return);
|
QTC_ASSERT(item->id().isValid(), return);
|
||||||
|
|
||||||
|
d->m_cmakeTools.append(item);
|
||||||
|
|
||||||
//set the first registered cmake tool as default if there is not already one
|
//set the first registered cmake tool as default if there is not already one
|
||||||
if (!d->m_defaultCMake.isValid())
|
if (!d->m_defaultCMake.isValid())
|
||||||
d->m_defaultCMake = item->id();
|
CMakeToolManager::setDefaultCMakeTool(item->id());
|
||||||
|
|
||||||
d->m_cmakeTools.append(item);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static FileName userSettingsFileName()
|
static FileName userSettingsFileName()
|
||||||
@@ -189,12 +189,22 @@ static QList<CMakeTool *> autoDetectCMakeTools()
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeToolManager::CMakeToolManager(QObject *parent) : QObject(parent)
|
CMakeToolManager *CMakeToolManager::m_instance = 0;
|
||||||
|
|
||||||
|
CMakeToolManager::CMakeToolManager(QObject *parent) :
|
||||||
|
QObject(parent)
|
||||||
{
|
{
|
||||||
|
QTC_ASSERT(!m_instance, return);
|
||||||
|
m_instance = this;
|
||||||
|
|
||||||
d = new CMakeToolManagerPrivate;
|
d = new CMakeToolManagerPrivate;
|
||||||
d->m_writer = new PersistentSettingsWriter(userSettingsFileName(), QStringLiteral("QtCreatorCMakeTools"));
|
d->m_writer = new PersistentSettingsWriter(userSettingsFileName(), QStringLiteral("QtCreatorCMakeTools"));
|
||||||
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
connect(ICore::instance(), &ICore::saveSettingsRequested,
|
||||||
this, &CMakeToolManager::saveCMakeTools);
|
this, &CMakeToolManager::saveCMakeTools);
|
||||||
|
|
||||||
|
connect(this, &CMakeToolManager::cmakeAdded, this, &CMakeToolManager::cmakeToolsChanged);
|
||||||
|
connect(this, &CMakeToolManager::cmakeRemoved, this, &CMakeToolManager::cmakeToolsChanged);
|
||||||
|
connect(this, &CMakeToolManager::cmakeUpdated, this, &CMakeToolManager::cmakeToolsChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeToolManager::~CMakeToolManager()
|
CMakeToolManager::~CMakeToolManager()
|
||||||
@@ -204,6 +214,11 @@ CMakeToolManager::~CMakeToolManager()
|
|||||||
d = 0;
|
d = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CMakeToolManager *CMakeToolManager::instance()
|
||||||
|
{
|
||||||
|
return m_instance;
|
||||||
|
}
|
||||||
|
|
||||||
QList<CMakeTool *> CMakeToolManager::cmakeTools()
|
QList<CMakeTool *> CMakeToolManager::cmakeTools()
|
||||||
{
|
{
|
||||||
return d->m_cmakeTools;
|
return d->m_cmakeTools;
|
||||||
@@ -228,8 +243,9 @@ Id CMakeToolManager::registerOrFindCMakeTool(const FileName &command)
|
|||||||
cmake = new CMakeTool(CMakeTool::ManualDetection);
|
cmake = new CMakeTool(CMakeTool::ManualDetection);
|
||||||
cmake->setCMakeExecutable(command);
|
cmake->setCMakeExecutable(command);
|
||||||
cmake->setDisplayName(tr("CMake at %1").arg(command.toUserOutput()));
|
cmake->setDisplayName(tr("CMake at %1").arg(command.toUserOutput()));
|
||||||
addCMakeTool(cmake);
|
|
||||||
|
|
||||||
|
addCMakeTool(cmake);
|
||||||
|
emit m_instance->cmakeAdded(cmake->id());
|
||||||
return cmake->id();
|
return cmake->id();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -247,6 +263,7 @@ bool CMakeToolManager::registerCMakeTool(CMakeTool *tool)
|
|||||||
}
|
}
|
||||||
|
|
||||||
addCMakeTool(tool);
|
addCMakeTool(tool);
|
||||||
|
emit m_instance->cmakeAdded(tool->id());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -260,7 +277,11 @@ void CMakeToolManager::deregisterCMakeTool(const Id &id)
|
|||||||
d->m_defaultCMake = Id();
|
d->m_defaultCMake = Id();
|
||||||
else
|
else
|
||||||
d->m_defaultCMake = d->m_cmakeTools.first()->id();
|
d->m_defaultCMake = d->m_cmakeTools.first()->id();
|
||||||
|
|
||||||
|
emit m_instance->defaultCMakeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emit m_instance->cmakeRemoved(id);
|
||||||
delete toRemove;
|
delete toRemove;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -272,6 +293,8 @@ CMakeTool *CMakeToolManager::defaultCMakeTool()
|
|||||||
//if the id is not valid, we set the firstly registered one as default
|
//if the id is not valid, we set the firstly registered one as default
|
||||||
if (!d->m_cmakeTools.isEmpty()) {
|
if (!d->m_cmakeTools.isEmpty()) {
|
||||||
d->m_defaultCMake = d->m_cmakeTools.first()->id();
|
d->m_defaultCMake = d->m_cmakeTools.first()->id();
|
||||||
|
emit m_instance->defaultCMakeChanged();
|
||||||
|
|
||||||
return d->m_cmakeTools.first();
|
return d->m_cmakeTools.first();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,8 +306,10 @@ void CMakeToolManager::setDefaultCMakeTool(const Id &id)
|
|||||||
if (d->m_defaultCMake == id)
|
if (d->m_defaultCMake == id)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (findById(id))
|
if (findById(id)) {
|
||||||
d->m_defaultCMake = id;
|
d->m_defaultCMake = id;
|
||||||
|
emit m_instance->defaultCMakeChanged();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CMakeTool *CMakeToolManager::findByCommand(const FileName &command)
|
CMakeTool *CMakeToolManager::findByCommand(const FileName &command)
|
||||||
@@ -365,6 +390,13 @@ void CMakeToolManager::restoreCMakeTools()
|
|||||||
readAndDeleteLegacyCMakeSettings();
|
readAndDeleteLegacyCMakeSettings();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CMakeToolManager::notifyAboutUpdate(CMakeTool *tool)
|
||||||
|
{
|
||||||
|
if (!tool || !d->m_cmakeTools.contains(tool))
|
||||||
|
return;
|
||||||
|
emit m_instance->cmakeUpdated(tool->id());
|
||||||
|
}
|
||||||
|
|
||||||
void CMakeToolManager::saveCMakeTools()
|
void CMakeToolManager::saveCMakeTools()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(d->m_writer, return);
|
QTC_ASSERT(d->m_writer, return);
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public:
|
|||||||
CMakeToolManager(QObject *parent);
|
CMakeToolManager(QObject *parent);
|
||||||
~CMakeToolManager();
|
~CMakeToolManager();
|
||||||
|
|
||||||
|
static CMakeToolManager *instance();
|
||||||
|
|
||||||
static QList<CMakeTool *> cmakeTools();
|
static QList<CMakeTool *> cmakeTools();
|
||||||
static void setPreferNinja(bool set);
|
static void setPreferNinja(bool set);
|
||||||
static bool preferNinja();
|
static bool preferNinja();
|
||||||
@@ -62,8 +64,19 @@ public:
|
|||||||
static CMakeTool *findById(const Core::Id &id);
|
static CMakeTool *findById(const Core::Id &id);
|
||||||
static void restoreCMakeTools();
|
static void restoreCMakeTools();
|
||||||
|
|
||||||
|
static void notifyAboutUpdate(CMakeTool *);
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void cmakeAdded (const Core::Id &id);
|
||||||
|
void cmakeRemoved (const Core::Id &id);
|
||||||
|
void cmakeUpdated (const Core::Id &id);
|
||||||
|
void cmakeToolsChanged ();
|
||||||
|
void defaultCMakeChanged ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void saveCMakeTools();
|
static void saveCMakeTools();
|
||||||
|
|
||||||
|
static CMakeToolManager *m_instance;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace CMakeProjectManager
|
} // namespace CMakeProjectManager
|
||||||
|
|||||||
@@ -209,6 +209,11 @@ QChar KeywordsCompletionAssistProcessor::startOfCommentChar() const
|
|||||||
return QLatin1Char('#');
|
return QLatin1Char('#');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KeywordsCompletionAssistProcessor::setKeywords(Keywords keywords)
|
||||||
|
{
|
||||||
|
m_keywords = keywords;
|
||||||
|
}
|
||||||
|
|
||||||
bool KeywordsCompletionAssistProcessor::acceptsIdleEditor()
|
bool KeywordsCompletionAssistProcessor::acceptsIdleEditor()
|
||||||
{
|
{
|
||||||
const int pos = m_interface->position();
|
const int pos = m_interface->position();
|
||||||
|
|||||||
@@ -92,6 +92,9 @@ public:
|
|||||||
IAssistProposal *perform(const AssistInterface *interface) Q_DECL_OVERRIDE;
|
IAssistProposal *perform(const AssistInterface *interface) Q_DECL_OVERRIDE;
|
||||||
QChar startOfCommentChar() const;
|
QChar startOfCommentChar() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void setKeywords (Keywords keywords);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool acceptsIdleEditor();
|
bool acceptsIdleEditor();
|
||||||
int findStartOfName(int pos = -1);
|
int findStartOfName(int pos = -1);
|
||||||
|
|||||||
Reference in New Issue
Block a user