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
|
2011-05-06 15:05:37 +02:00
|
|
|
** Nokia at info@qt.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 "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
|
|
|
|
2009-01-12 15:06:43 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2008-12-09 15:25:01 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
#include <QtCore/QPair>
|
2011-09-28 16:35:01 +02:00
|
|
|
#include <QtCore/QVariant>
|
|
|
|
|
#include <QtGui/QAction>
|
|
|
|
|
#include <QtGui/QButtonGroup>
|
|
|
|
|
#include <QtGui/QComboBox>
|
|
|
|
|
#include <QtGui/QGridLayout>
|
|
|
|
|
#include <QtGui/QHeaderView>
|
2010-08-18 15:37:26 +02:00
|
|
|
#include <QtGui/QInputDialog>
|
2011-09-28 16:35:01 +02:00
|
|
|
#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>
|
2011-09-28 16:35:01 +02:00
|
|
|
#include <QtGui/QPushButton>
|
|
|
|
|
#include <QtGui/QSpacerItem>
|
|
|
|
|
#include <QtGui/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;
|
2010-01-07 18:17:24 +01:00
|
|
|
QString id;
|
2008-12-02 12:01:29 +01:00
|
|
|
};
|
2008-12-09 15:25:01 +01:00
|
|
|
|
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)
|
2008-12-02 12:01:29 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
using ExtensionSystem::PluginManager;
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
/// RunSettingsPanelFactory
|
|
|
|
|
///
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
QString RunSettingsPanelFactory::id() const
|
|
|
|
|
{
|
|
|
|
|
return QLatin1String(RUNSETTINGS_PANEL_ID);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
QString RunSettingsPanelFactory::displayName() const
|
|
|
|
|
{
|
2011-10-06 17:05:38 +02:00
|
|
|
return RunSettingsWidget::tr("Run Settings");
|
2010-01-21 13:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
bool RunSettingsPanelFactory::supports(Target *target)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-02-08 15:50:06 +01:00
|
|
|
Q_UNUSED(target);
|
2008-12-02 12:01:29 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-14 13:32:30 +02:00
|
|
|
PropertiesPanel *RunSettingsPanelFactory::createPanel(Target *target)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-04-14 13:32:30 +02:00
|
|
|
PropertiesPanel *panel = new PropertiesPanel;
|
2011-08-16 10:45:23 +02:00
|
|
|
QWidget *w = new QWidget();
|
|
|
|
|
QVBoxLayout *l = new QVBoxLayout(w);
|
|
|
|
|
QWidget *b = new RunSettingsWidget(target);
|
|
|
|
|
l->addWidget(b);
|
|
|
|
|
l->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding));
|
|
|
|
|
l->setContentsMargins(QMargins());
|
|
|
|
|
panel->setWidget(w);
|
2011-10-06 17:05:38 +02:00
|
|
|
panel->setIcon(QIcon(QLatin1String(":/projectexplorer/images/RunSettings.png")));
|
|
|
|
|
panel->setDisplayName(RunSettingsWidget::tr("Run Settings"));
|
2011-04-14 13:32:30 +02:00
|
|
|
return panel;
|
2009-11-25 15:57:09 +01:00
|
|
|
}
|
|
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
///
|
|
|
|
|
/// 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),
|
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);
|
|
|
|
|
m_renameDeployButton = new QPushButton(tr("Rename"), this);
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
m_renameRunButton = new QPushButton(tr("Rename"), this);
|
|
|
|
|
|
|
|
|
|
QSpacerItem *runHorizontalSpacer =
|
|
|
|
|
new QSpacerItem(17, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
|
|
|
|
|
|
|
|
|
|
QWidget *runWidget = new QWidget(this);
|
|
|
|
|
|
|
|
|
|
QLabel *runLabel = new QLabel(tr("Run configuration:"), this);
|
|
|
|
|
runLabel->setBuddy(m_runConfigurationCombo);
|
|
|
|
|
|
|
|
|
|
QLabel *deployLabel = new QLabel(tr("Deployment:"), this);
|
|
|
|
|
|
|
|
|
|
m_gridLayout = new QGridLayout(this);
|
|
|
|
|
m_gridLayout->setSpacing(0);
|
|
|
|
|
m_gridLayout->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
m_gridLayout->setHorizontalSpacing(6);
|
|
|
|
|
m_gridLayout->addWidget(deployLabel, 0, 0, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_deployConfigurationCombo, 0, 1, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_addDeployToolButton, 0, 2, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_removeDeployToolButton, 0, 3, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_renameDeployButton, 0, 4, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(deployWidget, 1, 0, 1, 6);
|
|
|
|
|
m_gridLayout->addWidget(runLabel, 2, 0, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_runConfigurationCombo, 2, 1, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_addRunToolButton, 2, 2, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_removeRunToolButton, 2, 3, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(m_renameRunButton, 2, 4, 1, 1);
|
|
|
|
|
m_gridLayout->addItem(runHorizontalSpacer, 2, 5, 1, 1);
|
|
|
|
|
m_gridLayout->addWidget(runWidget, 3, 0, 1, 6);
|
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);
|
|
|
|
|
m_runConfigurationCombo->setModel(m_runConfigurationsModel);
|
|
|
|
|
m_runConfigurationCombo->setCurrentIndex(
|
2010-04-29 16:52:31 +02:00
|
|
|
m_runConfigurationsModel->indexFor(m_target->activeRunConfiguration()).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);
|
|
|
|
|
m_renameRunButton->setEnabled(m_target->activeRunConfiguration());
|
2010-04-07 14:06:33 +02:00
|
|
|
|
2011-01-24 14:21:52 +01:00
|
|
|
setConfigurationWidget(m_target->activeRunConfiguration());
|
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
|
|
|
|
|
|
|
|
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()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
void RunSettingsWidget::aboutToShowAddMenu()
|
|
|
|
|
{
|
2010-07-16 14:00:41 +02:00
|
|
|
m_addRunMenu->clear();
|
2008-12-09 15:25:01 +01:00
|
|
|
QList<IRunConfigurationFactory *> factories =
|
|
|
|
|
ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
|
|
|
|
|
foreach (IRunConfigurationFactory *factory, factories) {
|
2010-02-08 15:50:06 +01:00
|
|
|
QStringList ids = factory->availableCreationIds(m_target);
|
2010-01-07 18:17:24 +01:00
|
|
|
foreach (const QString &id, ids) {
|
2010-07-16 14:00:41 +02:00
|
|
|
QAction *action = m_addRunMenu->addAction(factory->displayNameForId(id));;
|
2010-01-07 18:17:24 +01:00
|
|
|
FactoryAndId fai;
|
|
|
|
|
fai.factory = factory;
|
|
|
|
|
fai.id = id;
|
2008-12-02 12:01:29 +01:00
|
|
|
QVariant v;
|
2010-01-07 18:17:24 +01:00
|
|
|
v.setValue(fai);
|
2008-12-02 12:01:29 +01:00
|
|
|
action->setData(v);
|
|
|
|
|
connect(action, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(addRunConfiguration()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::addRunConfiguration()
|
|
|
|
|
{
|
|
|
|
|
QAction *act = qobject_cast<QAction *>(sender());
|
|
|
|
|
if (!act)
|
|
|
|
|
return;
|
2010-01-07 18:17:24 +01:00
|
|
|
FactoryAndId fai = act->data().value<FactoryAndId>();
|
2010-02-08 15:50:06 +01:00
|
|
|
RunConfiguration *newRC = fai.factory->create(m_target, fai.id);
|
2008-12-02 12:01:29 +01:00
|
|
|
if (!newRC)
|
|
|
|
|
return;
|
2010-02-08 15:50:06 +01:00
|
|
|
m_target->addRunConfiguration(newRC);
|
2010-03-24 15:51:04 +01:00
|
|
|
m_target->setActiveRunConfiguration(newRC);
|
2011-09-28 16:35:01 +02:00
|
|
|
m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
|
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;
|
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
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
if (index == -1)
|
|
|
|
|
updateDeployConfiguration(0);
|
|
|
|
|
else
|
|
|
|
|
m_target->setActiveDeployConfiguration(m_deployConfigurationModel->deployConfigurationAt(index));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::aboutToShowDeployMenu()
|
|
|
|
|
{
|
|
|
|
|
m_addDeployMenu->clear();
|
2011-03-09 12:07:35 +01:00
|
|
|
QStringList ids = m_target->availableDeployConfigurationIds();
|
2010-07-16 14:00:41 +02:00
|
|
|
foreach (const QString &id, ids) {
|
2011-03-09 12:07:35 +01:00
|
|
|
QAction *action = m_addDeployMenu->addAction(m_target->displayNameForDeployConfigurationId(id));
|
2010-07-16 14:00:41 +02:00
|
|
|
action->setData(QVariant(id));
|
|
|
|
|
connect(action, SIGNAL(triggered()),
|
|
|
|
|
this, SLOT(addDeployConfiguration()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void RunSettingsWidget::addDeployConfiguration()
|
|
|
|
|
{
|
|
|
|
|
QAction *act = qobject_cast<QAction *>(sender());
|
|
|
|
|
if (!act)
|
|
|
|
|
return;
|
|
|
|
|
QString id = act->data().toString();
|
2011-03-09 12:07:35 +01:00
|
|
|
DeployConfiguration *newDc = m_target->createDeployConfiguration(id);
|
2010-07-16 14:00:41 +02:00
|
|
|
if (!newDc)
|
|
|
|
|
return;
|
|
|
|
|
m_target->addDeployConfiguration(newDc);
|
|
|
|
|
m_target->setActiveDeployConfiguration(newDc);
|
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::removeDeployConfiguration()
|
|
|
|
|
{
|
|
|
|
|
DeployConfiguration *dc = m_target->activeDeployConfiguration();
|
2010-08-30 12:05:31 +02:00
|
|
|
QMessageBox msgBox(QMessageBox::Question, tr("Remove Deploy Configuration?"),
|
2010-09-13 16:51:18 +02:00
|
|
|
tr("Do you really want to delete deploy configuration <b>%1</b>?").arg(dc->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-07-16 14:00:41 +02:00
|
|
|
m_target->removeDeployConfiguration(dc);
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
|
2011-09-28 16:35:01 +02:00
|
|
|
m_deployConfigurationCombo->setCurrentIndex(-1);
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
if (!dc)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
QModelIndex actDc = m_deployConfigurationModel->indexFor(dc);
|
2011-09-28 16:35:01 +02:00
|
|
|
m_deployConfigurationCombo->setCurrentIndex(actDc.row());
|
2010-07-16 14:00:41 +02:00
|
|
|
|
|
|
|
|
m_deployConfigurationWidget = dc->configurationWidget();
|
|
|
|
|
if (m_deployConfigurationWidget) {
|
|
|
|
|
m_deployConfigurationWidget->init(dc);
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
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();
|
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()
|
|
|
|
|
{
|
|
|
|
|
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
|
|
|
|
|
foreach (IRunControlFactory *f, pm->getObjects<IRunControlFactory>()) {
|
|
|
|
|
ProjectExplorer::RunConfigWidget *rcw =
|
|
|
|
|
f->createConfigurationWidget(m_target->activeRunConfiguration());
|
|
|
|
|
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();
|
|
|
|
|
}
|