2015-03-10 10:22:38 +01:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2015-03-10 10:22:38 +01:00
|
|
|
**
|
|
|
|
|
** 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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2015-03-10 10:22:38 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01: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.
|
2015-03-10 10:22:38 +01:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "cmakebuildsettingswidget.h"
|
|
|
|
|
#include "cmakeproject.h"
|
|
|
|
|
#include "cmakebuildconfiguration.h"
|
|
|
|
|
#include "cmakebuildinfo.h"
|
|
|
|
|
#include "cmakeopenprojectwizard.h"
|
|
|
|
|
#include "cmakeprojectmanager.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/target.h>
|
|
|
|
|
|
2016-01-06 15:41:09 +01:00
|
|
|
#include <utils/detailswidget.h>
|
|
|
|
|
|
2015-03-10 10:22:38 +01:00
|
|
|
#include <QFormLayout>
|
|
|
|
|
|
|
|
|
|
namespace CMakeProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc) :
|
|
|
|
|
m_pathLineEdit(new QLineEdit),
|
|
|
|
|
m_changeButton(new QPushButton)
|
2015-03-10 10:22:38 +01:00
|
|
|
{
|
2016-01-07 15:22:53 +01:00
|
|
|
auto vbox = new QVBoxLayout(this);
|
2016-01-06 15:41:09 +01:00
|
|
|
vbox->setMargin(0);
|
2016-01-07 15:22:53 +01:00
|
|
|
auto container = new Utils::DetailsWidget;
|
2016-01-06 15:41:09 +01:00
|
|
|
container->setState(Utils::DetailsWidget::NoSummary);
|
|
|
|
|
vbox->addWidget(container);
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto details = new QWidget(container);
|
2016-01-06 15:41:09 +01:00
|
|
|
container->setWidget(details);
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto fl = new QFormLayout(details);
|
2016-01-06 15:41:09 +01:00
|
|
|
fl->setMargin(0);
|
2015-03-10 10:22:38 +01:00
|
|
|
fl->setFieldGrowthPolicy(QFormLayout::ExpandingFieldsGrow);
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto runCmakeButton = new QPushButton(tr("Run CMake..."));
|
2016-01-05 12:35:02 +01:00
|
|
|
connect(runCmakeButton, &QAbstractButton::clicked, this, &CMakeBuildSettingsWidget::runCMake);
|
2015-03-10 10:22:38 +01:00
|
|
|
fl->addRow(tr("Reconfigure project:"), runCmakeButton);
|
|
|
|
|
|
|
|
|
|
m_pathLineEdit->setReadOnly(true);
|
|
|
|
|
|
2016-01-07 15:22:53 +01:00
|
|
|
auto hbox = new QHBoxLayout();
|
2015-03-10 10:22:38 +01:00
|
|
|
hbox->addWidget(m_pathLineEdit);
|
|
|
|
|
|
|
|
|
|
m_changeButton->setText(tr("&Change"));
|
2016-01-05 12:35:02 +01:00
|
|
|
connect(m_changeButton, &QAbstractButton::clicked, this,
|
|
|
|
|
&CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog);
|
2015-03-10 10:22:38 +01:00
|
|
|
hbox->addWidget(m_changeButton);
|
|
|
|
|
|
|
|
|
|
fl->addRow(tr("Build directory:"), hbox);
|
|
|
|
|
|
|
|
|
|
m_buildConfiguration = bc;
|
|
|
|
|
m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString());
|
|
|
|
|
if (m_buildConfiguration->buildDirectory() == bc->target()->project()->projectDirectory())
|
|
|
|
|
m_changeButton->setEnabled(false);
|
|
|
|
|
else
|
|
|
|
|
m_changeButton->setEnabled(true);
|
|
|
|
|
|
|
|
|
|
setDisplayName(tr("CMake"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::openChangeBuildDirectoryDialog()
|
|
|
|
|
{
|
|
|
|
|
CMakeBuildInfo info(m_buildConfiguration);
|
2016-01-07 17:30:49 +01:00
|
|
|
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), CMakeOpenProjectWizard::ChangeDirectory,
|
2016-01-06 16:23:23 +01:00
|
|
|
&info);
|
2015-03-10 10:22:38 +01:00
|
|
|
if (copw.exec() == QDialog::Accepted) {
|
2016-01-07 17:30:49 +01:00
|
|
|
auto project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
|
2015-03-10 10:22:38 +01:00
|
|
|
project->changeBuildDirectory(m_buildConfiguration, copw.buildDirectory());
|
|
|
|
|
m_pathLineEdit->setText(m_buildConfiguration->rawBuildDirectory().toString());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CMakeBuildSettingsWidget::runCMake()
|
|
|
|
|
{
|
|
|
|
|
if (!ProjectExplorer::ProjectExplorerPlugin::saveModifiedFiles())
|
|
|
|
|
return;
|
|
|
|
|
CMakeBuildInfo info(m_buildConfiguration);
|
2016-01-07 17:30:49 +01:00
|
|
|
CMakeOpenProjectWizard copw(Core::ICore::mainWindow(), CMakeOpenProjectWizard::WantToUpdate,
|
|
|
|
|
&info);
|
|
|
|
|
if (copw.exec() == QDialog::Accepted) {
|
|
|
|
|
auto project = static_cast<CMakeProject *>(m_buildConfiguration->target()->project());
|
2015-03-10 10:22:38 +01:00
|
|
|
project->parseCMakeLists();
|
2016-01-07 17:30:49 +01:00
|
|
|
}
|
2015-03-10 10:22:38 +01:00
|
|
|
}
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace CMakeProjectManager
|