Files
qt-creator/src/plugins/clangtools/clangtoolsplugin.cpp

147 lines
4.1 KiB
C++
Raw Normal View History

2014-09-25 11:11:58 +02:00
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
2014-09-25 11:11:58 +02:00
**
** This file is part of Qt Creator.
2014-09-25 11:11:58 +02:00
**
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
2014-09-25 11:11:58 +02:00
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
2014-09-25 11:11:58 +02:00
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
2014-09-25 11:11:58 +02:00
**
****************************************************************************/
#include "clangtoolsplugin.h"
2014-09-25 11:11:58 +02:00
#include "clangtoolsconfigwidget.h"
#include "clangtoolsconstants.h"
#include "clangtoolsprojectsettingswidget.h"
#include "clangtidyclazytool.h"
#include "clangtoolsprojectsettings.h"
2014-09-25 11:11:58 +02:00
#ifdef WITH_TESTS
#include "clangtoolspreconfiguredsessiontests.h"
#include "clangtoolsunittests.h"
#endif
#include <debugger/analyzer/analyzericons.h>
#include <utils/qtcassert.h>
2014-09-25 11:11:58 +02:00
#include <coreplugin/icore.h>
#include <coreplugin/icontext.h>
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/actionmanager/command.h>
#include <coreplugin/actionmanager/actioncontainer.h>
#include <coreplugin/coreconstants.h>
#include <coreplugin/dialogs/ioptionspage.h>
#include <cpptools/cpptoolsconstants.h>
#include <cpptools/cppmodelmanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/projectpanelfactory.h>
#include <projectexplorer/target.h>
2014-09-25 11:11:58 +02:00
#include <QAction>
#include <QDebug>
#include <QMainWindow>
#include <QMessageBox>
#include <QMenu>
#include <QtPlugin>
using namespace ProjectExplorer;
2014-09-25 11:11:58 +02:00
namespace ClangTools {
2014-09-25 11:11:58 +02:00
namespace Internal {
class ClangToolsOptionsPage : public Core::IOptionsPage
2014-09-25 11:11:58 +02:00
{
public:
explicit ClangToolsOptionsPage()
2014-09-25 11:11:58 +02:00
{
setId("Analyzer.ClangTools.Settings");
2014-09-25 11:11:58 +02:00
setDisplayName(QCoreApplication::translate(
"ClangTools::Internal::ClangToolsOptionsPage",
"Clang Tools"));
2014-09-25 11:11:58 +02:00
setCategory("T.Analyzer");
setDisplayCategory(QCoreApplication::translate("Analyzer", "Analyzer"));
setCategoryIcon(Analyzer::Icons::SETTINGSCATEGORY_ANALYZER);
2014-09-25 11:11:58 +02:00
}
QWidget *widget() override
2014-09-25 11:11:58 +02:00
{
if (!m_widget)
m_widget = new ClangToolsConfigWidget(ClangToolsSettings::instance());
2014-09-25 11:11:58 +02:00
return m_widget;
}
void apply() override
2014-09-25 11:11:58 +02:00
{
ClangToolsSettings::instance()->writeSettings();
2014-09-25 11:11:58 +02:00
}
void finish() override
2014-09-25 11:11:58 +02:00
{
delete m_widget;
}
private:
QPointer<QWidget> m_widget;
};
class ClangToolsPluginPrivate
2014-09-25 11:11:58 +02:00
{
public:
ClangTidyClazyTool clangTidyClazyTool;
ClangToolsOptionsPage optionsPage;
ClangToolsProjectSettingsManager settingsManager;
};
2014-09-25 11:11:58 +02:00
ClangToolsPlugin::~ClangToolsPlugin()
2014-09-25 11:11:58 +02:00
{
delete d;
2014-09-25 11:11:58 +02:00
}
bool ClangToolsPlugin::initialize(const QStringList &arguments, QString *errorString)
2014-09-25 11:11:58 +02:00
{
Q_UNUSED(arguments);
Q_UNUSED(errorString);
d = new ClangToolsPluginPrivate;
auto panelFactory = new ProjectPanelFactory();
panelFactory->setPriority(100);
panelFactory->setDisplayName(tr("Clang Tools"));
panelFactory->setCreateWidgetFunction([](Project *project) { return new ProjectSettingsWidget(project); });
ProjectPanelFactory::registerFactory(panelFactory);
2014-09-25 11:11:58 +02:00
return true;
}
QList<QObject *> ClangToolsPlugin::createTestObjects() const
{
QList<QObject *> tests;
#ifdef WITH_TESTS
tests << new PreconfiguredSessionTests;
tests << new ClangToolsUnitTests;
#endif
return tests;
}
2014-09-25 11:11:58 +02:00
} // namespace Internal
} // namespace ClangTools