2009-02-25 09:15:00 +01:00
|
|
|
/**************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2011-01-11 16:28:15 +01:00
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2010-12-17 16:01:08 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
**************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "buildsettingspropertiespage.h"
|
|
|
|
|
#include "buildstep.h"
|
|
|
|
|
#include "buildstepspage.h"
|
|
|
|
|
#include "project.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
#include "projectexplorerconstants.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2009-09-21 17:54:02 +02:00
|
|
|
#include "buildconfiguration.h"
|
2010-04-29 16:52:31 +02:00
|
|
|
#include "buildconfigurationmodel.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-01-12 15:06:43 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2009-10-29 15:17:21 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
#include <QtCore/QMargins>
|
|
|
|
|
#include <QtCore/QTimer>
|
2010-02-24 16:34:22 +01:00
|
|
|
#include <QtCore/QCoreApplication>
|
2009-11-30 16:44:22 +01:00
|
|
|
#include <QtGui/QComboBox>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <QtGui/QInputDialog>
|
|
|
|
|
#include <QtGui/QLabel>
|
2009-09-29 11:39:55 +02:00
|
|
|
#include <QtGui/QMenu>
|
2010-08-30 12:05:31 +02:00
|
|
|
#include <QtGui/QMessageBox>
|
2009-11-30 16:44:22 +01:00
|
|
|
#include <QtGui/QPushButton>
|
|
|
|
|
#include <QtGui/QVBoxLayout>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
|
|
|
|
///
|
2009-11-30 16:44:22 +01:00
|
|
|
// BuildSettingsPanelFactory
|
2008-12-02 12:01:29 +01:00
|
|
|
///
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QString BuildSettingsPanelFactory::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(BUILDSETTINGS_PANEL_ID);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
QString BuildSettingsPanelFactory::displayName() const
|
|
|
|
|
{
|
2010-02-24 16:34:22 +01:00
|
|
|
return QCoreApplication::translate("BuildSettingsPanelFactory", "Build Settings");
|
2010-01-21 13:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool BuildSettingsPanelFactory::supports(Target *target)
|
|
|
|
|
{
|
|
|
|
|
return target->buildConfigurationFactory();
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
IPropertiesPanel *BuildSettingsPanelFactory::createPanel(Target *target)
|
|
|
|
|
{
|
|
|
|
|
return new BuildSettingsPanel(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///
|
2009-11-30 16:44:22 +01:00
|
|
|
// BuildSettingsPanel
|
2008-12-02 12:01:29 +01:00
|
|
|
///
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildSettingsPanel::BuildSettingsPanel(Target *target) :
|
|
|
|
|
m_widget(new BuildSettingsWidget(target)),
|
2010-02-19 14:16:37 +01:00
|
|
|
m_icon(":/projectexplorer/images/BuildSettings.png")
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BuildSettingsPanel::~BuildSettingsPanel()
|
|
|
|
|
{
|
2009-11-25 15:18:51 +01:00
|
|
|
delete m_widget;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
QString BuildSettingsPanel::displayName() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-24 16:34:22 +01:00
|
|
|
return QCoreApplication::translate("BuildSettingsPanel", "Build Settings");
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 15:57:09 +01:00
|
|
|
QWidget *BuildSettingsPanel::widget() const
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
return m_widget;
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 15:57:09 +01:00
|
|
|
QIcon BuildSettingsPanel::icon() const
|
|
|
|
|
{
|
|
|
|
|
return m_icon;
|
|
|
|
|
}
|
|
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
///
|
2009-11-30 16:44:22 +01:00
|
|
|
// BuildSettingsWidget
|
2009-07-16 15:33:19 +02:00
|
|
|
///
|
|
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
BuildSettingsWidget::~BuildSettingsWidget()
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
|
|
|
|
clear();
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildSettingsWidget::BuildSettingsWidget(Target *target) :
|
|
|
|
|
m_target(target),
|
2010-05-21 14:29:11 +02:00
|
|
|
m_buildConfiguration(0)
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(m_target);
|
|
|
|
|
setupUi();
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
2009-12-07 15:17:37 +01:00
|
|
|
void BuildSettingsWidget::setupUi()
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
|
|
|
|
QVBoxLayout *vbox = new QVBoxLayout(this);
|
2009-11-30 16:44:22 +01:00
|
|
|
vbox->setContentsMargins(0, 0, 0, 0);
|
2009-10-29 15:17:21 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!m_target->buildConfigurationFactory()) {
|
|
|
|
|
QLabel * noSettingsLabel(new QLabel(this));
|
2010-05-14 15:45:43 +02:00
|
|
|
noSettingsLabel->setText(tr("No build settings available"));
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
QFont f(noSettingsLabel->font());
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.2);
|
|
|
|
|
noSettingsLabel->setFont(f);
|
|
|
|
|
}
|
|
|
|
|
vbox->addWidget(noSettingsLabel);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2009-10-29 15:17:21 +01:00
|
|
|
{ // Edit Build Configuration row
|
|
|
|
|
QHBoxLayout *hbox = new QHBoxLayout();
|
2010-05-21 14:29:11 +02:00
|
|
|
hbox->setContentsMargins(0, 0, 0, 0);
|
2010-05-14 15:45:43 +02:00
|
|
|
hbox->addWidget(new QLabel(tr("Edit build configuration:"), this));
|
2009-10-29 15:17:21 +01:00
|
|
|
m_buildConfigurationComboBox = new QComboBox(this);
|
|
|
|
|
m_buildConfigurationComboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
2010-04-29 16:52:31 +02:00
|
|
|
m_buildConfigurationComboBox->setModel(new BuildConfigurationModel(m_target, this));
|
2009-10-29 15:17:21 +01:00
|
|
|
hbox->addWidget(m_buildConfigurationComboBox);
|
|
|
|
|
|
|
|
|
|
m_addButton = new QPushButton(this);
|
|
|
|
|
m_addButton->setText(tr("Add"));
|
|
|
|
|
m_addButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
hbox->addWidget(m_addButton);
|
2009-11-30 16:44:22 +01:00
|
|
|
m_addButtonMenu = new QMenu(this);
|
|
|
|
|
m_addButton->setMenu(m_addButtonMenu);
|
2009-10-29 15:17:21 +01:00
|
|
|
|
|
|
|
|
m_removeButton = new QPushButton(this);
|
|
|
|
|
m_removeButton->setText(tr("Remove"));
|
|
|
|
|
m_removeButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
hbox->addWidget(m_removeButton);
|
2010-02-12 15:15:57 +01:00
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
m_renameButton = new QPushButton(this);
|
|
|
|
|
m_renameButton->setText(tr("Rename"));
|
|
|
|
|
m_renameButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
hbox->addWidget(m_renameButton);
|
|
|
|
|
|
2009-10-29 15:17:21 +01:00
|
|
|
hbox->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Expanding, QSizePolicy::Fixed));
|
|
|
|
|
vbox->addLayout(hbox);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_buildConfiguration = m_target->activeBuildConfiguration();
|
2010-04-29 16:52:31 +02:00
|
|
|
BuildConfigurationModel *model = static_cast<BuildConfigurationModel *>(m_buildConfigurationComboBox->model());
|
|
|
|
|
m_buildConfigurationComboBox->setCurrentIndex(model->indexFor(m_buildConfiguration).row());
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2010-03-12 14:58:51 +01:00
|
|
|
updateAddButtonMenu();
|
|
|
|
|
updateBuildSettings();
|
|
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
connect(m_buildConfigurationComboBox, SIGNAL(currentIndexChanged(int)),
|
|
|
|
|
this, SLOT(currentIndexChanged(int)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
connect(m_removeButton, SIGNAL(clicked()),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SLOT(deleteConfiguration()));
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
connect(m_renameButton, SIGNAL(clicked()),
|
|
|
|
|
this, SLOT(renameConfiguration()));
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
2010-02-12 15:15:57 +01:00
|
|
|
this, SLOT(updateActiveConfiguration()));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
if (m_target->buildConfigurationFactory())
|
|
|
|
|
connect(m_target->buildConfigurationFactory(), SIGNAL(availableCreationIdsChanged()),
|
|
|
|
|
SLOT(updateAddButtonMenu()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void BuildSettingsWidget::addSubWidget(BuildConfigWidget *widget)
|
2009-11-30 16:44:22 +01:00
|
|
|
{
|
2010-05-21 14:29:11 +02:00
|
|
|
widget->setContentsMargins(0, 10, 0, 0);
|
2009-11-30 16:44:22 +01:00
|
|
|
|
|
|
|
|
QLabel *label = new QLabel(this);
|
2010-07-16 14:00:41 +02:00
|
|
|
label->setText(widget->displayName());
|
|
|
|
|
connect(widget, SIGNAL(displayNameChanged(QString)),
|
|
|
|
|
label, SLOT(setText(QString)));
|
2009-11-30 16:44:22 +01:00
|
|
|
QFont f = label->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.2);
|
|
|
|
|
label->setFont(f);
|
|
|
|
|
|
2010-05-21 14:29:11 +02:00
|
|
|
label->setContentsMargins(0, 10, 0, 0);
|
2009-11-30 16:44:22 +01:00
|
|
|
|
|
|
|
|
layout()->addWidget(label);
|
|
|
|
|
layout()->addWidget(widget);
|
|
|
|
|
|
|
|
|
|
m_labels.append(label);
|
|
|
|
|
m_subWidgets.append(widget);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildSettingsWidget::clear()
|
|
|
|
|
{
|
|
|
|
|
qDeleteAll(m_subWidgets);
|
|
|
|
|
m_subWidgets.clear();
|
|
|
|
|
qDeleteAll(m_labels);
|
|
|
|
|
m_labels.clear();
|
|
|
|
|
}
|
|
|
|
|
|
2010-03-12 14:58:51 +01:00
|
|
|
QList<BuildConfigWidget *> BuildSettingsWidget::subWidgets() const
|
2009-11-30 16:44:22 +01:00
|
|
|
{
|
|
|
|
|
return m_subWidgets;
|
|
|
|
|
}
|
|
|
|
|
|
2009-09-28 17:30:11 +02:00
|
|
|
void BuildSettingsWidget::updateAddButtonMenu()
|
2009-09-28 15:02:12 +02:00
|
|
|
{
|
2009-09-28 17:30:11 +02:00
|
|
|
m_addButtonMenu->clear();
|
2010-06-11 13:41:07 +10:00
|
|
|
if (m_target) {
|
|
|
|
|
if (m_target->activeBuildConfiguration()) {
|
|
|
|
|
m_addButtonMenu->addAction(tr("&Clone Selected"),
|
|
|
|
|
this, SLOT(cloneConfiguration()));
|
|
|
|
|
}
|
|
|
|
|
IBuildConfigurationFactory *factory = m_target->buildConfigurationFactory();
|
|
|
|
|
if (factory) {
|
|
|
|
|
foreach (const QString &id, factory->availableCreationIds(m_target)) {
|
|
|
|
|
QAction *action = m_addButtonMenu->addAction(factory->displayNameForId(id), this, SLOT(createConfiguration()));
|
|
|
|
|
action->setData(id);
|
|
|
|
|
}
|
2009-09-28 15:02:12 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BuildSettingsWidget::updateBuildSettings()
|
|
|
|
|
{
|
2009-11-30 16:44:22 +01:00
|
|
|
clear();
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
// update buttons
|
2010-02-08 15:50:06 +01:00
|
|
|
m_removeButton->setEnabled(m_target->buildConfigurations().size() > 1);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Add pages
|
2010-12-06 12:45:05 +01:00
|
|
|
BuildConfigWidget *generalConfigWidget = m_target->createConfigWidget();
|
2010-07-16 14:00:41 +02:00
|
|
|
addSubWidget(generalConfigWidget);
|
2009-07-16 15:33:19 +02:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
addSubWidget(new BuildStepsPage(m_target, QLatin1String(Constants::BUILDSTEPS_BUILD)));
|
|
|
|
|
addSubWidget(new BuildStepsPage(m_target, QLatin1String(Constants::BUILDSTEPS_CLEAN)));
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QList<BuildConfigWidget *> subConfigWidgets = m_target->project()->subConfigWidgets();
|
2009-08-06 15:31:32 +02:00
|
|
|
foreach (BuildConfigWidget *subConfigWidget, subConfigWidgets)
|
2010-07-16 14:00:41 +02:00
|
|
|
addSubWidget(subConfigWidget);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-03-12 14:58:51 +01:00
|
|
|
foreach (BuildConfigWidget *widget, subWidgets())
|
|
|
|
|
widget->init(m_buildConfiguration);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-07-16 15:33:19 +02:00
|
|
|
void BuildSettingsWidget::currentIndexChanged(int index)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-04-29 16:52:31 +02:00
|
|
|
BuildConfigurationModel *model = static_cast<BuildConfigurationModel *>(m_buildConfigurationComboBox->model());
|
|
|
|
|
BuildConfiguration *buildConfiguration = model->buildConfigurationAt(index);
|
2010-03-12 14:58:51 +01:00
|
|
|
m_target->setActiveBuildConfiguration(buildConfiguration);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-12 14:58:51 +01:00
|
|
|
void BuildSettingsWidget::updateActiveConfiguration()
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-12 14:58:51 +01:00
|
|
|
if (!m_buildConfiguration || m_buildConfiguration == m_target->activeBuildConfiguration())
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-03-12 14:58:51 +01:00
|
|
|
m_buildConfiguration = m_target->activeBuildConfiguration();
|
|
|
|
|
|
2010-04-29 16:52:31 +02:00
|
|
|
BuildConfigurationModel *model = static_cast<BuildConfigurationModel *>(m_buildConfigurationComboBox->model());
|
|
|
|
|
m_buildConfigurationComboBox->setCurrentIndex(model->indexFor(m_buildConfiguration).row());
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2009-11-30 16:44:22 +01:00
|
|
|
foreach (QWidget *widget, subWidgets()) {
|
2009-08-06 15:31:32 +02:00
|
|
|
if (BuildConfigWidget *buildStepWidget = qobject_cast<BuildConfigWidget*>(widget)) {
|
2009-09-17 13:59:10 +02:00
|
|
|
buildStepWidget->init(m_buildConfiguration);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2009-10-29 15:17:21 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void BuildSettingsWidget::createConfiguration()
|
|
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!m_target->buildConfigurationFactory())
|
|
|
|
|
return;
|
|
|
|
|
|
2009-09-28 15:02:12 +02:00
|
|
|
QAction *action = qobject_cast<QAction *>(sender());
|
2010-02-08 15:50:06 +01:00
|
|
|
const QString &id = action->data().toString();
|
|
|
|
|
BuildConfiguration *bc = m_target->buildConfigurationFactory()->create(m_target, id);
|
2009-11-24 15:36:31 +01:00
|
|
|
if (bc) {
|
2010-04-15 14:12:37 +02:00
|
|
|
m_target->setActiveBuildConfiguration(bc);
|
2009-09-28 15:02:12 +02:00
|
|
|
updateBuildSettings();
|
|
|
|
|
}
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildSettingsWidget::cloneConfiguration()
|
|
|
|
|
{
|
2010-03-12 14:58:51 +01:00
|
|
|
cloneConfiguration(m_buildConfiguration);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BuildSettingsWidget::deleteConfiguration()
|
|
|
|
|
{
|
2010-09-13 16:51:18 +02:00
|
|
|
QMessageBox msgBox(QMessageBox::Question, tr("Remove Build Configuration"),
|
|
|
|
|
tr("Do you really want to delete the build configuration <b>%1</b>?").arg(m_buildConfiguration->displayName()),
|
2010-08-30 12:05:31 +02:00
|
|
|
QMessageBox::Yes|QMessageBox::No, this);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::No);
|
|
|
|
|
msgBox.setEscapeButton(QMessageBox::No);
|
|
|
|
|
if (!this || msgBox.exec() == QMessageBox::No)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-03-12 14:58:51 +01:00
|
|
|
deleteConfiguration(m_buildConfiguration);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 17:50:55 +02:00
|
|
|
QString BuildSettingsWidget::uniqueName(const QString & name)
|
|
|
|
|
{
|
|
|
|
|
QString result = name.trimmed();
|
|
|
|
|
if (!result.isEmpty()) {
|
|
|
|
|
QStringList bcNames;
|
|
|
|
|
foreach (BuildConfiguration *bc, m_target->buildConfigurations()) {
|
|
|
|
|
if (bc == m_buildConfiguration)
|
|
|
|
|
continue;
|
|
|
|
|
bcNames.append(bc->displayName());
|
|
|
|
|
}
|
|
|
|
|
result = Project::makeUnique(result, bcNames);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
void BuildSettingsWidget::renameConfiguration()
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
QString name = QInputDialog::getText(this, tr("Rename..."),
|
|
|
|
|
tr("New name for build configuration <b>%1</b>:").
|
|
|
|
|
arg(m_buildConfiguration->displayName()),
|
|
|
|
|
QLineEdit::Normal,
|
|
|
|
|
m_buildConfiguration->displayName(), &ok);
|
2010-08-19 12:26:21 +02:00
|
|
|
if (!ok || !this)
|
2010-08-18 15:37:26 +02:00
|
|
|
return;
|
|
|
|
|
|
2010-10-04 17:50:55 +02:00
|
|
|
name = uniqueName(name);
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
m_buildConfiguration->setDisplayName(name);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
void BuildSettingsWidget::cloneConfiguration(BuildConfiguration *sourceConfiguration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!sourceConfiguration ||
|
|
|
|
|
!m_target->buildConfigurationFactory())
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-08-19 12:26:21 +02:00
|
|
|
//: Title of a the cloned BuildConfiguration window, text of the window
|
2010-10-04 17:50:55 +02:00
|
|
|
QString name = uniqueName(QInputDialog::getText(this, tr("Clone Configuration"), tr("New configuration name:")));
|
|
|
|
|
if (name.isEmpty())
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
BuildConfiguration * bc(m_target->buildConfigurationFactory()->clone(m_target, sourceConfiguration));
|
|
|
|
|
if (!bc)
|
2010-01-18 12:11:04 +01:00
|
|
|
return;
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-10-04 17:50:55 +02:00
|
|
|
bc->setDisplayName(name);
|
2010-04-15 13:54:32 +02:00
|
|
|
m_target->addBuildConfiguration(bc);
|
2008-12-02 12:01:29 +01:00
|
|
|
updateBuildSettings();
|
2010-04-15 13:54:32 +02:00
|
|
|
|
|
|
|
|
m_target->setActiveBuildConfiguration(bc);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2009-11-24 15:36:31 +01:00
|
|
|
void BuildSettingsWidget::deleteConfiguration(BuildConfiguration *deleteConfiguration)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
if (!deleteConfiguration ||
|
|
|
|
|
m_target->buildConfigurations().size() <= 1)
|
2008-12-02 12:01:29 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_target->removeBuildConfiguration(deleteConfiguration);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
updateBuildSettings();
|
|
|
|
|
}
|