2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2014-01-07 13:27:11 +01:00
|
|
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
2012-10-02 09:12:39 +02:00
|
|
|
** Contact: http://www.qt-project.org/legal
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +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
|
|
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
|
|
|
|
** a written agreement between you and Digia. For licensing terms and
|
2014-10-01 13:21:18 +02:00
|
|
|
** conditions see http://www.qt.io/licensing. For further information
|
|
|
|
|
** use the contact form at http://www.qt.io/contact-us.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2009-02-25 09:15:00 +01:00
|
|
|
** GNU Lesser General Public License Usage
|
2012-10-02 09:12:39 +02:00
|
|
|
** Alternatively, this file may be used under the terms of the GNU Lesser
|
2014-10-01 13:21:18 +02:00
|
|
|
** 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.
|
2012-10-02 09:12:39 +02:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Digia gives you certain additional
|
|
|
|
|
** rights. These rights are described in the Digia Qt LGPL Exception
|
2010-12-17 16:01:08 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "runsettingspropertiespage.h"
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
#include "buildstepspage.h"
|
|
|
|
|
#include "deployconfiguration.h"
|
|
|
|
|
#include "deployconfigurationmodel.h"
|
2010-04-29 16:52:31 +02:00
|
|
|
#include "runconfigurationmodel.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "runconfiguration.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "target.h"
|
2009-09-29 11:39:55 +02:00
|
|
|
#include "project.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/buildmanager.h>
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QVariant>
|
|
|
|
|
#include <QAction>
|
|
|
|
|
#include <QComboBox>
|
|
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QInputDialog>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
|
|
|
|
#include <QSpacerItem>
|
|
|
|
|
#include <QWidget>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2010-01-07 18:17:24 +01:00
|
|
|
struct FactoryAndId
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
|
|
|
|
ProjectExplorer::IRunConfigurationFactory *factory;
|
2012-03-15 17:17:40 +01:00
|
|
|
Core::Id id;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
2008-12-09 15:25:01 +01:00
|
|
|
|
2013-03-04 14:48:24 +01:00
|
|
|
class DeployFactoryAndId
|
|
|
|
|
{
|
|
|
|
|
public:
|
2014-10-13 22:37:28 +03:00
|
|
|
DeployConfigurationFactory *factory;
|
2013-03-04 14:48:24 +01:00
|
|
|
Core::Id id;
|
|
|
|
|
};
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
|
2008-12-09 15:25:01 +01:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ProjectExplorer
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-12-16 11:25:28 +01:00
|
|
|
Q_DECLARE_METATYPE(ProjectExplorer::Internal::FactoryAndId)
|
2013-03-04 14:48:24 +01:00
|
|
|
Q_DECLARE_METATYPE(ProjectExplorer::Internal::DeployFactoryAndId)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
using ExtensionSystem::PluginManager;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// RunSettingsWidget
|
|
|
|
|
///
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
RunSettingsWidget::RunSettingsWidget(Target *target)
|
|
|
|
|
: m_target(target),
|
2010-04-29 16:52:31 +02:00
|
|
|
m_runConfigurationsModel(new RunConfigurationModel(target, this)),
|
2010-07-16 14:00:41 +02:00
|
|
|
m_deployConfigurationModel(new DeployConfigurationModel(target, this)),
|
2010-03-24 15:51:04 +01:00
|
|
|
m_runConfigurationWidget(0),
|
2013-03-06 14:55:15 +01:00
|
|
|
m_runConfiguration(0),
|
2010-08-04 11:48:50 +02:00
|
|
|
m_runLayout(0),
|
2010-07-16 14:00:41 +02:00
|
|
|
m_deployConfigurationWidget(0),
|
|
|
|
|
m_deployLayout(0),
|
|
|
|
|
m_deploySteps(0),
|
2010-03-24 15:51:04 +01:00
|
|
|
m_ignoreChange(false)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_ASSERT(m_target);
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_deployConfigurationCombo = new QComboBox(this);
|
|
|
|
|
m_addDeployToolButton = new QPushButton(tr("Add"), this);
|
|
|
|
|
m_removeDeployToolButton = new QPushButton(tr("Remove"), this);
|
2011-11-02 12:42:48 +01:00
|
|
|
m_renameDeployButton = new QPushButton(tr("Rename..."), this);
|
2011-09-28 16:35:01 +02:00
|
|
|
|
|
|
|
|
QWidget *deployWidget = new QWidget(this);
|
|
|
|
|
|
|
|
|
|
m_runConfigurationCombo = new QComboBox(this);
|
|
|
|
|
m_runConfigurationCombo->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
|
|
|
m_runConfigurationCombo->setMinimumContentsLength(15);
|
|
|
|
|
|
|
|
|
|
m_addRunToolButton = new QPushButton(tr("Add"), this);
|
|
|
|
|
m_removeRunToolButton = new QPushButton(tr("Remove"), this);
|
2011-11-02 12:42:48 +01:00
|
|
|
m_renameRunButton = new QPushButton(tr("Rename..."), this);
|
2011-09-28 16:35:01 +02:00
|
|
|
|
2011-10-19 09:38:35 +02:00
|
|
|
QSpacerItem *spacer1 =
|
|
|
|
|
new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
|
QSpacerItem *spacer2 =
|
|
|
|
|
new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
|
2011-09-28 16:35:01 +02:00
|
|
|
|
|
|
|
|
QWidget *runWidget = new QWidget(this);
|
|
|
|
|
|
2011-10-19 09:38:35 +02:00
|
|
|
QLabel *deployTitle = new QLabel(tr("Deployment"), this);
|
|
|
|
|
QLabel *deployLabel = new QLabel(tr("Method:"), this);
|
|
|
|
|
QLabel *runTitle = new QLabel(tr("Run"), this);
|
2011-09-28 16:35:01 +02:00
|
|
|
QLabel *runLabel = new QLabel(tr("Run configuration:"), this);
|
2011-10-19 09:38:35 +02:00
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
runLabel->setBuddy(m_runConfigurationCombo);
|
|
|
|
|
|
2011-10-19 09:38:35 +02:00
|
|
|
QFont f = runLabel->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.2);
|
|
|
|
|
|
|
|
|
|
runTitle->setFont(f);
|
|
|
|
|
deployTitle->setFont(f);
|
2011-09-28 16:35:01 +02:00
|
|
|
|
|
|
|
|
m_gridLayout = new QGridLayout(this);
|
2011-10-19 09:38:35 +02:00
|
|
|
m_gridLayout->setContentsMargins(0, 20, 0, 0);
|
2011-09-28 16:35:01 +02:00
|
|
|
m_gridLayout->setHorizontalSpacing(6);
|
2011-10-19 09:38:35 +02:00
|
|
|
m_gridLayout->setVerticalSpacing(8);
|
|
|
|
|
m_gridLayout->addWidget(deployTitle, 0, 0, 1, 6);
|
|
|
|
|
m_gridLayout->addWidget(deployLabel, 1, 0, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_deployConfigurationCombo, 1, 1, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_addDeployToolButton, 1, 2, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_removeDeployToolButton, 1, 3, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_renameDeployButton, 1, 4, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(deployWidget, 2, 0, 1, 6);
|
|
|
|
|
|
|
|
|
|
m_gridLayout->addWidget(runTitle, 3, 0, 1, 6);
|
|
|
|
|
m_gridLayout->addWidget(runLabel, 4, 0, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_runConfigurationCombo, 4, 1, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_addRunToolButton, 4, 2, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_removeRunToolButton, 4, 3, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_renameRunButton, 4, 4, 1, 1);
|
|
|
|
|
m_gridLayout->addItem(spacer1, 4, 5, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(runWidget, 5, 0, 1, 6);
|
|
|
|
|
m_gridLayout->addItem(spacer2, 6, 0, 1, 1);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2010-08-04 11:48:50 +02:00
|
|
|
// deploy part
|
2011-09-28 16:35:01 +02:00
|
|
|
deployWidget->setContentsMargins(0, 10, 0, 25);
|
|
|
|
|
m_deployLayout = new QVBoxLayout(deployWidget);
|
2010-07-16 14:00:41 +02:00
|
|
|
m_deployLayout->setMargin(0);
|
|
|
|
|
m_deployLayout->setSpacing(5);
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_deployConfigurationCombo->setModel(m_deployConfigurationModel);
|
|
|
|
|
|
|
|
|
|
m_addDeployMenu = new QMenu(m_addDeployToolButton);
|
|
|
|
|
m_addDeployToolButton->setMenu(m_addDeployMenu);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
updateDeployConfiguration(m_target->activeDeployConfiguration());
|
|
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
// Some projects may not support deployment, so we need this:
|
2011-09-28 16:35:01 +02:00
|
|
|
m_addDeployToolButton->setEnabled(m_target->activeDeployConfiguration());
|
|
|
|
|
m_deployConfigurationCombo->setEnabled(m_target->activeDeployConfiguration());
|
2010-08-18 15:37:26 +02:00
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().count() > 1);
|
|
|
|
|
m_renameDeployButton->setEnabled(m_target->activeDeployConfiguration());
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
connect(m_addDeployMenu, SIGNAL(aboutToShow()),
|
|
|
|
|
this, SLOT(aboutToShowDeployMenu()));
|
2011-09-28 16:35:01 +02:00
|
|
|
connect(m_deployConfigurationCombo, SIGNAL(currentIndexChanged(int)),
|
2010-07-16 14:00:41 +02:00
|
|
|
this, SLOT(currentDeployConfigurationChanged(int)));
|
2011-09-28 16:35:01 +02:00
|
|
|
connect(m_removeDeployToolButton, SIGNAL(clicked(bool)),
|
2010-07-16 14:00:41 +02:00
|
|
|
this, SLOT(removeDeployConfiguration()));
|
2011-09-28 16:35:01 +02:00
|
|
|
connect(m_renameDeployButton, SIGNAL(clicked()),
|
2010-08-18 15:37:26 +02:00
|
|
|
this, SLOT(renameDeployConfiguration()));
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
connect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(activeDeployConfigurationChanged()));
|
|
|
|
|
|
|
|
|
|
// run part
|
2011-09-28 16:35:01 +02:00
|
|
|
runWidget->setContentsMargins(0, 10, 0, 25);
|
|
|
|
|
m_runLayout = new QVBoxLayout(runWidget);
|
2010-08-04 11:48:50 +02:00
|
|
|
m_runLayout->setMargin(0);
|
|
|
|
|
m_runLayout->setSpacing(5);
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_addRunMenu = new QMenu(m_addRunToolButton);
|
|
|
|
|
m_addRunToolButton->setMenu(m_addRunMenu);
|
2013-10-18 17:46:04 +02:00
|
|
|
RunConfiguration *rc = m_target->activeRunConfiguration();
|
2011-09-28 16:35:01 +02:00
|
|
|
m_runConfigurationCombo->setModel(m_runConfigurationsModel);
|
|
|
|
|
m_runConfigurationCombo->setCurrentIndex(
|
2013-10-18 17:46:04 +02:00
|
|
|
m_runConfigurationsModel->indexFor(rc).row());
|
2010-03-24 15:51:04 +01:00
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
|
2013-10-18 17:46:04 +02:00
|
|
|
m_renameRunButton->setEnabled(rc);
|
2010-04-07 14:06:33 +02:00
|
|
|
|
2013-10-18 17:46:04 +02:00
|
|
|
setConfigurationWidget(rc);
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
connect(m_addRunMenu, SIGNAL(aboutToShow()),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SLOT(aboutToShowAddMenu()));
|
2011-09-28 16:35:01 +02:00
|
|
|
connect(m_runConfigurationCombo, SIGNAL(currentIndexChanged(int)),
|
2010-02-12 15:15:57 +01:00
|
|
|
this, SLOT(currentRunConfigurationChanged(int)));
|
2011-09-28 16:35:01 +02:00
|
|
|
connect(m_removeRunToolButton, SIGNAL(clicked(bool)),
|
2008-12-02 12:01:29 +01:00
|
|
|
this, SLOT(removeRunConfiguration()));
|
2011-09-28 16:35:01 +02:00
|
|
|
connect(m_renameRunButton, SIGNAL(clicked()),
|
2010-08-18 15:37:26 +02:00
|
|
|
this, SLOT(renameRunConfiguration()));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-08-23 11:13:04 +02:00
|
|
|
connect(m_target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(updateRemoveToolButton()));
|
|
|
|
|
connect(m_target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(updateRemoveToolButton()));
|
|
|
|
|
|
|
|
|
|
connect(m_target, SIGNAL(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(updateRemoveToolButton()));
|
|
|
|
|
connect(m_target, SIGNAL(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(updateRemoveToolButton()));
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
2010-02-01 15:12:38 +01:00
|
|
|
this, SLOT(activeRunConfigurationChanged()));
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RunSettingsWidget::~RunSettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::aboutToShowAddMenu()
|
|
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
m_addRunMenu->clear();
|
2014-01-14 15:13:26 +01:00
|
|
|
if (m_target->activeRunConfiguration()) {
|
|
|
|
|
m_addRunMenu->addAction(tr("&Clone Selected"),
|
|
|
|
|
this, SLOT(cloneRunConfiguration()));
|
|
|
|
|
}
|
2008-12-09 15:25:01 +01:00
|
|
|
QList<IRunConfigurationFactory *> factories =
|
2012-06-18 11:34:15 +02:00
|
|
|
ExtensionSystem::PluginManager::getObjects<IRunConfigurationFactory>();
|
2013-05-16 11:50:39 +02:00
|
|
|
|
|
|
|
|
QList<QAction *> menuActions;
|
2008-12-09 15:25:01 +01:00
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
2012-03-15 17:17:40 +01:00
|
|
|
QList<Core::Id> ids = factory->availableCreationIds(m_target);
|
|
|
|
|
foreach (Core::Id id, ids) {
|
2013-05-16 11:50:39 +02:00
|
|
|
QAction *action = new QAction(factory->displayNameForId(id), m_addRunMenu);
|
2014-09-11 11:05:45 +02:00
|
|
|
connect(action, &QAction::triggered, [factory, id, this]() {
|
|
|
|
|
RunConfiguration *newRC = factory->create(m_target, id);
|
|
|
|
|
if (!newRC)
|
|
|
|
|
return;
|
|
|
|
|
QTC_CHECK(newRC->id() == id);
|
|
|
|
|
m_target->addRunConfiguration(newRC);
|
|
|
|
|
m_target->setActiveRunConfiguration(newRC);
|
|
|
|
|
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
|
|
|
|
|
});
|
2013-05-16 11:50:39 +02:00
|
|
|
menuActions.append(action);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
2013-05-16 11:50:39 +02:00
|
|
|
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(menuActions, [](const QAction *l, const QAction *r) {
|
|
|
|
|
return l->text() < r->text();
|
|
|
|
|
});
|
2013-05-16 11:50:39 +02:00
|
|
|
foreach (QAction *action, menuActions)
|
|
|
|
|
m_addRunMenu->addAction(action);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2014-01-14 15:13:26 +01:00
|
|
|
void RunSettingsWidget::cloneRunConfiguration()
|
|
|
|
|
{
|
|
|
|
|
RunConfiguration* activeRunConfiguration = m_target->activeRunConfiguration();
|
|
|
|
|
IRunConfigurationFactory *factory = IRunConfigurationFactory::find(m_target,
|
|
|
|
|
activeRunConfiguration);
|
|
|
|
|
if (!factory)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-07-18 16:51:24 +02:00
|
|
|
//: Title of a the cloned RunConfiguration window, text of the window
|
|
|
|
|
QString name = uniqueRCName(QInputDialog::getText(this, tr("Clone Configuration"), tr("New configuration name:")));
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2014-01-14 15:13:26 +01:00
|
|
|
RunConfiguration *newRc = factory->clone(m_target, activeRunConfiguration);
|
|
|
|
|
if (!newRc)
|
|
|
|
|
return;
|
|
|
|
|
|
2014-07-18 16:51:24 +02:00
|
|
|
newRc->setDisplayName(name);
|
2014-01-14 15:13:26 +01:00
|
|
|
m_target->addRunConfiguration(newRc);
|
|
|
|
|
m_target->setActiveRunConfiguration(newRc);
|
|
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void RunSettingsWidget::removeRunConfiguration()
|
|
|
|
|
{
|
2010-03-24 15:51:04 +01:00
|
|
|
RunConfiguration *rc = m_target->activeRunConfiguration();
|
2010-08-30 12:05:31 +02:00
|
|
|
QMessageBox msgBox(QMessageBox::Question, tr("Remove Run Configuration?"),
|
2010-09-10 10:51:43 +02:00
|
|
|
tr("Do you really want to delete the run configuration <b>%1</b>?").arg(rc->displayName()),
|
2010-08-30 12:05:31 +02:00
|
|
|
QMessageBox::Yes|QMessageBox::No, this);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::No);
|
|
|
|
|
msgBox.setEscapeButton(QMessageBox::No);
|
2011-09-28 16:38:57 +02:00
|
|
|
if (msgBox.exec() == QMessageBox::No)
|
2010-08-30 12:05:31 +02:00
|
|
|
return;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_target->removeRunConfiguration(rc);
|
2011-09-28 16:35:01 +02:00
|
|
|
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
|
|
|
|
|
m_renameRunButton->setEnabled(m_target->activeRunConfiguration());
|
2010-02-01 15:12:38 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::activeRunConfigurationChanged()
|
|
|
|
|
{
|
2010-03-24 15:51:04 +01:00
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
|
|
|
|
QModelIndex actRc = m_runConfigurationsModel->indexFor(m_target->activeRunConfiguration());
|
|
|
|
|
m_ignoreChange = true;
|
2011-09-28 16:35:01 +02:00
|
|
|
m_runConfigurationCombo->setCurrentIndex(actRc.row());
|
2011-02-02 10:49:39 +01:00
|
|
|
setConfigurationWidget(m_runConfigurationsModel->runConfigurationAt(actRc.row()));
|
2010-03-24 15:51:04 +01:00
|
|
|
m_ignoreChange = false;
|
2012-08-23 11:13:59 +02:00
|
|
|
m_renameRunButton->setEnabled(m_target->activeRunConfiguration());
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
void RunSettingsWidget::renameRunConfiguration()
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
QString name = QInputDialog::getText(this, tr("Rename..."),
|
|
|
|
|
tr("New name for run configuration <b>%1</b>:").
|
|
|
|
|
arg(m_target->activeRunConfiguration()->displayName()),
|
|
|
|
|
QLineEdit::Normal,
|
|
|
|
|
m_target->activeRunConfiguration()->displayName(), &ok);
|
2011-09-28 16:38:57 +02:00
|
|
|
if (!ok)
|
2010-08-18 15:37:26 +02:00
|
|
|
return;
|
|
|
|
|
|
2010-10-04 17:50:55 +02:00
|
|
|
name = uniqueRCName(name);
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
return;
|
|
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
m_target->activeRunConfiguration()->setDisplayName(name);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-12 15:15:57 +01:00
|
|
|
void RunSettingsWidget::currentRunConfigurationChanged(int index)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-03-24 15:51:04 +01:00
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
2011-01-24 14:21:52 +01:00
|
|
|
|
|
|
|
|
RunConfiguration *selectedRunConfiguration = 0;
|
|
|
|
|
if (index >= 0)
|
|
|
|
|
selectedRunConfiguration = m_runConfigurationsModel->runConfigurationAt(index);
|
2010-03-24 15:51:04 +01:00
|
|
|
|
2013-03-08 17:14:04 +01:00
|
|
|
if (selectedRunConfiguration == m_runConfiguration)
|
2013-03-06 14:55:15 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-03-24 15:51:04 +01:00
|
|
|
m_ignoreChange = true;
|
|
|
|
|
m_target->setActiveRunConfiguration(selectedRunConfiguration);
|
|
|
|
|
m_ignoreChange = false;
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
// Update the run configuration configuration widget
|
2011-01-24 14:21:52 +01:00
|
|
|
setConfigurationWidget(selectedRunConfiguration);
|
2009-04-15 14:52:31 +02:00
|
|
|
}
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
void RunSettingsWidget::currentDeployConfigurationChanged(int index)
|
|
|
|
|
{
|
2012-08-23 11:14:48 +02:00
|
|
|
if (m_ignoreChange)
|
|
|
|
|
return;
|
2010-07-16 14:00:41 +02:00
|
|
|
if (index == -1)
|
2012-08-23 11:14:48 +02:00
|
|
|
m_target->setActiveDeployConfiguration(0);
|
2010-07-16 14:00:41 +02:00
|
|
|
else
|
|
|
|
|
m_target->setActiveDeployConfiguration(m_deployConfigurationModel->deployConfigurationAt(index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::aboutToShowDeployMenu()
|
|
|
|
|
{
|
|
|
|
|
m_addDeployMenu->clear();
|
2013-03-04 14:48:24 +01:00
|
|
|
QList<DeployConfigurationFactory *> factories = DeployConfigurationFactory::find(m_target);
|
|
|
|
|
if (factories.isEmpty())
|
2012-04-24 15:49:09 +02:00
|
|
|
return;
|
2013-03-04 14:48:24 +01:00
|
|
|
|
|
|
|
|
foreach (DeployConfigurationFactory *factory, factories) {
|
|
|
|
|
QList<Core::Id> ids = factory->availableCreationIds(m_target);
|
|
|
|
|
foreach (Core::Id id, ids) {
|
|
|
|
|
QAction *action = m_addDeployMenu->addAction(factory->displayNameForId(id));
|
|
|
|
|
DeployFactoryAndId data = { factory, id };
|
|
|
|
|
action->setData(QVariant::fromValue(data));
|
2014-09-11 11:05:45 +02:00
|
|
|
connect(action, &QAction::triggered, [factory, id, this]() {
|
|
|
|
|
if (!factory->canCreate(m_target, id))
|
|
|
|
|
return;
|
|
|
|
|
DeployConfiguration *newDc = factory->create(m_target, id);
|
|
|
|
|
if (!newDc)
|
|
|
|
|
return;
|
|
|
|
|
QTC_CHECK(!newDc || newDc->id() == id);
|
|
|
|
|
m_target->addDeployConfiguration(newDc);
|
|
|
|
|
m_target->setActiveDeployConfiguration(newDc);
|
|
|
|
|
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
|
|
|
|
|
});
|
2013-03-04 14:48:24 +01:00
|
|
|
}
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::removeDeployConfiguration()
|
|
|
|
|
{
|
|
|
|
|
DeployConfiguration *dc = m_target->activeDeployConfiguration();
|
2013-09-05 14:36:20 +02:00
|
|
|
if (BuildManager::isBuilding(dc)) {
|
2011-10-24 13:10:38 +00:00
|
|
|
QMessageBox box;
|
|
|
|
|
QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Remove Deploy Configuration"), QMessageBox::AcceptRole);
|
|
|
|
|
QPushButton *cancelClose = box.addButton(tr("Do Not Remove"), QMessageBox::RejectRole);
|
|
|
|
|
box.setDefaultButton(cancelClose);
|
|
|
|
|
box.setWindowTitle(tr("Remove Deploy Configuration %1?").arg(dc->displayName()));
|
|
|
|
|
box.setText(tr("The deploy configuration <b>%1</b> is currently being built.").arg(dc->displayName()));
|
|
|
|
|
box.setInformativeText(tr("Do you want to cancel the build process and remove the Deploy Configuration anyway?"));
|
|
|
|
|
box.exec();
|
|
|
|
|
if (box.clickedButton() != closeAnyway)
|
|
|
|
|
return;
|
2013-09-05 14:36:20 +02:00
|
|
|
BuildManager::cancel();
|
2011-10-24 13:10:38 +00:00
|
|
|
} else {
|
|
|
|
|
QMessageBox msgBox(QMessageBox::Question, tr("Remove Deploy Configuration?"),
|
|
|
|
|
tr("Do you really want to delete deploy configuration <b>%1</b>?").arg(dc->displayName()),
|
|
|
|
|
QMessageBox::Yes|QMessageBox::No, this);
|
|
|
|
|
msgBox.setDefaultButton(QMessageBox::No);
|
|
|
|
|
msgBox.setEscapeButton(QMessageBox::No);
|
|
|
|
|
if (msgBox.exec() == QMessageBox::No)
|
|
|
|
|
return;
|
|
|
|
|
}
|
2010-08-30 12:05:31 +02:00
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
m_target->removeDeployConfiguration(dc);
|
2011-10-24 13:10:38 +00:00
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
|
2010-07-16 14:00:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::activeDeployConfigurationChanged()
|
|
|
|
|
{
|
|
|
|
|
updateDeployConfiguration(m_target->activeDeployConfiguration());
|
|
|
|
|
}
|
|
|
|
|
|
2010-08-18 15:37:26 +02:00
|
|
|
void RunSettingsWidget::renameDeployConfiguration()
|
|
|
|
|
{
|
|
|
|
|
bool ok;
|
|
|
|
|
QString name = QInputDialog::getText(this, tr("Rename..."),
|
|
|
|
|
tr("New name for deploy configuration <b>%1</b>:").
|
|
|
|
|
arg(m_target->activeDeployConfiguration()->displayName()),
|
|
|
|
|
QLineEdit::Normal,
|
|
|
|
|
m_target->activeDeployConfiguration()->displayName(), &ok);
|
2011-09-28 16:38:57 +02:00
|
|
|
if (!ok)
|
2010-08-18 15:37:26 +02:00
|
|
|
return;
|
|
|
|
|
|
2010-10-04 17:50:55 +02:00
|
|
|
name = uniqueDCName(name);
|
|
|
|
|
if (name.isEmpty())
|
|
|
|
|
return;
|
2010-08-18 15:37:26 +02:00
|
|
|
m_target->activeDeployConfiguration()->setDisplayName(name);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-23 11:13:04 +02:00
|
|
|
void RunSettingsWidget::updateRemoveToolButton()
|
|
|
|
|
{
|
|
|
|
|
m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().count() > 1);
|
|
|
|
|
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc)
|
|
|
|
|
{
|
|
|
|
|
delete m_deployConfigurationWidget;
|
|
|
|
|
m_deployConfigurationWidget = 0;
|
|
|
|
|
delete m_deploySteps;
|
|
|
|
|
m_deploySteps = 0;
|
|
|
|
|
|
2012-08-23 11:14:48 +02:00
|
|
|
m_ignoreChange = true;
|
2011-09-28 16:35:01 +02:00
|
|
|
m_deployConfigurationCombo->setCurrentIndex(-1);
|
2012-08-23 11:14:48 +02:00
|
|
|
m_ignoreChange = false;
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2012-08-23 11:13:59 +02:00
|
|
|
m_renameDeployButton->setEnabled(dc);
|
|
|
|
|
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!dc)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QModelIndex actDc = m_deployConfigurationModel->indexFor(dc);
|
2012-08-23 11:14:48 +02:00
|
|
|
m_ignoreChange = true;
|
2011-09-28 16:35:01 +02:00
|
|
|
m_deployConfigurationCombo->setCurrentIndex(actDc.row());
|
2012-08-23 11:14:48 +02:00
|
|
|
m_ignoreChange = false;
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2012-11-08 15:19:40 +01:00
|
|
|
m_deployConfigurationWidget = dc->createConfigWidget();
|
2012-11-08 15:21:34 +01:00
|
|
|
if (m_deployConfigurationWidget)
|
2010-07-16 14:00:41 +02:00
|
|
|
m_deployLayout->addWidget(m_deployConfigurationWidget);
|
|
|
|
|
|
|
|
|
|
m_deploySteps = new BuildStepListWidget;
|
|
|
|
|
m_deploySteps->init(dc->stepList());
|
|
|
|
|
m_deployLayout->addWidget(m_deploySteps);
|
|
|
|
|
}
|
2010-10-04 17:50:55 +02:00
|
|
|
|
2011-01-24 14:21:52 +01:00
|
|
|
void RunSettingsWidget::setConfigurationWidget(RunConfiguration *rc)
|
|
|
|
|
{
|
2013-10-18 17:46:04 +02:00
|
|
|
if (rc == m_runConfiguration)
|
|
|
|
|
return;
|
|
|
|
|
|
2011-01-24 14:21:52 +01:00
|
|
|
delete m_runConfigurationWidget;
|
|
|
|
|
m_runConfigurationWidget = 0;
|
2011-02-28 12:23:12 +01:00
|
|
|
removeSubWidgets();
|
2011-01-24 14:21:52 +01:00
|
|
|
if (!rc)
|
|
|
|
|
return;
|
2011-02-28 12:23:12 +01:00
|
|
|
m_runConfigurationWidget = rc->createConfigurationWidget();
|
2013-10-18 17:46:04 +02:00
|
|
|
m_runConfiguration = rc;
|
2011-09-08 19:41:02 +02:00
|
|
|
if (m_runConfigurationWidget)
|
|
|
|
|
m_runLayout->addWidget(m_runConfigurationWidget);
|
2011-02-28 12:23:12 +01:00
|
|
|
|
|
|
|
|
addRunControlWidgets();
|
2011-01-24 14:21:52 +01:00
|
|
|
}
|
|
|
|
|
|
2010-10-04 17:50:55 +02:00
|
|
|
QString RunSettingsWidget::uniqueDCName(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QString result = name.trimmed();
|
|
|
|
|
if (!result.isEmpty()) {
|
|
|
|
|
QStringList dcNames;
|
|
|
|
|
foreach (DeployConfiguration *dc, m_target->deployConfigurations()) {
|
|
|
|
|
if (dc == m_target->activeDeployConfiguration())
|
|
|
|
|
continue;
|
|
|
|
|
dcNames.append(dc->displayName());
|
|
|
|
|
}
|
|
|
|
|
result = Project::makeUnique(result, dcNames);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString RunSettingsWidget::uniqueRCName(const QString &name)
|
|
|
|
|
{
|
|
|
|
|
QString result = name.trimmed();
|
|
|
|
|
if (!result.isEmpty()) {
|
|
|
|
|
QStringList rcNames;
|
|
|
|
|
foreach (RunConfiguration *rc, m_target->runConfigurations()) {
|
|
|
|
|
if (rc == m_target->activeRunConfiguration())
|
|
|
|
|
continue;
|
|
|
|
|
rcNames.append(rc->displayName());
|
|
|
|
|
}
|
|
|
|
|
result = Project::makeUnique(result, rcNames);
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
2011-02-28 12:23:12 +01:00
|
|
|
|
|
|
|
|
void RunSettingsWidget::addRunControlWidgets()
|
|
|
|
|
{
|
2013-10-18 17:46:04 +02:00
|
|
|
foreach (IRunConfigurationAspect *aspect, m_runConfiguration->extraAspects()) {
|
2014-10-13 22:37:28 +03:00
|
|
|
RunConfigWidget *rcw = aspect->createConfigurationWidget();
|
2011-02-28 12:23:12 +01:00
|
|
|
if (rcw)
|
|
|
|
|
addSubWidget(rcw);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::addSubWidget(RunConfigWidget *widget)
|
|
|
|
|
{
|
|
|
|
|
widget->setContentsMargins(0, 10, 0, 0);
|
|
|
|
|
|
|
|
|
|
QLabel *label = new QLabel(this);
|
|
|
|
|
label->setText(widget->displayName());
|
|
|
|
|
connect(widget, SIGNAL(displayNameChanged(QString)),
|
|
|
|
|
label, SLOT(setText(QString)));
|
|
|
|
|
QFont f = label->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.2);
|
|
|
|
|
label->setFont(f);
|
|
|
|
|
|
|
|
|
|
label->setContentsMargins(0, 10, 0, 0);
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
QGridLayout *l = m_gridLayout;
|
2011-02-28 12:23:12 +01:00
|
|
|
l->addWidget(label, l->rowCount(), 0, 1, -1);
|
|
|
|
|
l->addWidget(widget, l->rowCount(), 0, 1, -1);
|
|
|
|
|
|
|
|
|
|
m_subWidgets.append(qMakePair(widget, label));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::removeSubWidgets()
|
|
|
|
|
{
|
|
|
|
|
// foreach does not like commas in types, it's only a macro after all
|
|
|
|
|
foreach (const RunConfigItem &item, m_subWidgets) {
|
|
|
|
|
delete item.first;
|
|
|
|
|
delete item.second;
|
|
|
|
|
}
|
|
|
|
|
m_subWidgets.clear();
|
|
|
|
|
}
|