runsettingspropertiespage.cpp 18.1 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** 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.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
hjk's avatar
hjk committed
32

con's avatar
con committed
33
#include "runsettingspropertiespage.h"
Tobias Hunger's avatar
Tobias Hunger committed
34 35 36 37

#include "buildstepspage.h"
#include "deployconfiguration.h"
#include "deployconfigurationmodel.h"
dt's avatar
dt committed
38
#include "runconfigurationmodel.h"
con's avatar
con committed
39
#include "runconfiguration.h"
Tobias Hunger's avatar
Tobias Hunger committed
40
#include "target.h"
41
#include "project.h"
con's avatar
con committed
42

43
#include <coreplugin/coreconstants.h>
con's avatar
con committed
44
#include <extensionsystem/pluginmanager.h>
hjk's avatar
hjk committed
45
#include <utils/qtcassert.h>
con's avatar
con committed
46 47

#include <QtCore/QPair>
48 49 50 51 52 53
#include <QtCore/QVariant>
#include <QtGui/QAction>
#include <QtGui/QButtonGroup>
#include <QtGui/QComboBox>
#include <QtGui/QGridLayout>
#include <QtGui/QHeaderView>
54
#include <QtGui/QInputDialog>
55
#include <QtGui/QLabel>
56
#include <QtGui/QMenu>
57
#include <QtGui/QMessageBox>
58 59 60
#include <QtGui/QPushButton>
#include <QtGui/QSpacerItem>
#include <QtGui/QWidget>
con's avatar
con committed
61 62 63

namespace ProjectExplorer {
namespace Internal {
hjk's avatar
hjk committed
64

65
struct FactoryAndId
con's avatar
con committed
66 67
{
    ProjectExplorer::IRunConfigurationFactory *factory;
68
    QString id;
con's avatar
con committed
69
};
hjk's avatar
hjk committed
70

71

hjk's avatar
hjk committed
72 73
} // namespace Internal
} // namespace ProjectExplorer
con's avatar
con committed
74

75
Q_DECLARE_METATYPE(ProjectExplorer::Internal::FactoryAndId)
con's avatar
con committed
76 77 78 79 80 81 82 83 84

using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal;
using ExtensionSystem::PluginManager;

///
/// RunSettingsPanelFactory
///

Tobias Hunger's avatar
Tobias Hunger committed
85 86 87 88 89
QString RunSettingsPanelFactory::id() const
{
    return QLatin1String(RUNSETTINGS_PANEL_ID);
}

con's avatar
con committed
90 91
QString RunSettingsPanelFactory::displayName() const
{
Friedemann Kleint's avatar
Friedemann Kleint committed
92
    return RunSettingsWidget::tr("Run Settings");
con's avatar
con committed
93 94
}

Tobias Hunger's avatar
Tobias Hunger committed
95
bool RunSettingsPanelFactory::supports(Target *target)
con's avatar
con committed
96
{
Tobias Hunger's avatar
Tobias Hunger committed
97
    Q_UNUSED(target);
con's avatar
con committed
98 99 100
    return true;
}

101
PropertiesPanel *RunSettingsPanelFactory::createPanel(Target *target)
Tobias Hunger's avatar
Tobias Hunger committed
102
{
103
    PropertiesPanel *panel = new PropertiesPanel;
Jarek Kobus's avatar
Jarek Kobus committed
104 105 106 107 108 109 110
    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);
Friedemann Kleint's avatar
Friedemann Kleint committed
111 112
    panel->setIcon(QIcon(QLatin1String(":/projectexplorer/images/RunSettings.png")));
    panel->setDisplayName(RunSettingsWidget::tr("Run Settings"));
113
    return panel;
114 115
}

con's avatar
con committed
116 117 118 119
///
/// RunSettingsWidget
///

Tobias Hunger's avatar
Tobias Hunger committed
120 121
RunSettingsWidget::RunSettingsWidget(Target *target)
    : m_target(target),
dt's avatar
dt committed
122
      m_runConfigurationsModel(new RunConfigurationModel(target, this)),
Tobias Hunger's avatar
Tobias Hunger committed
123
      m_deployConfigurationModel(new DeployConfigurationModel(target, this)),
124
      m_runConfigurationWidget(0),
125
      m_runLayout(0),
Tobias Hunger's avatar
Tobias Hunger committed
126 127 128
      m_deployConfigurationWidget(0),
      m_deployLayout(0),
      m_deploySteps(0),
129
      m_ignoreChange(false)
con's avatar
con committed
130
{
Tobias Hunger's avatar
Tobias Hunger committed
131 132
    Q_ASSERT(m_target);

133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
    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);

148 149 150 151
    QSpacerItem *spacer1 =
        new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum);
    QSpacerItem *spacer2 =
        new QSpacerItem(10, 10, QSizePolicy::Minimum, QSizePolicy::Expanding);
152 153 154

    QWidget *runWidget = new QWidget(this);

155 156 157
    QLabel *deployTitle = new QLabel(tr("Deployment"), this);
    QLabel *deployLabel = new QLabel(tr("Method:"), this);
    QLabel *runTitle = new QLabel(tr("Run"), this);
158
    QLabel *runLabel = new QLabel(tr("Run configuration:"), this);
159

160 161
    runLabel->setBuddy(m_runConfigurationCombo);

162 163 164 165 166 167
    QFont f = runLabel->font();
    f.setBold(true);
    f.setPointSizeF(f.pointSizeF() * 1.2);

    runTitle->setFont(f);
    deployTitle->setFont(f);
168 169

    m_gridLayout = new QGridLayout(this);
170
    m_gridLayout->setContentsMargins(0, 20, 0, 0);
171
    m_gridLayout->setHorizontalSpacing(6);
172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189
    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);
Tobias Hunger's avatar
Tobias Hunger committed
190

191
    // deploy part
192 193
    deployWidget->setContentsMargins(0, 10, 0, 25);
    m_deployLayout = new QVBoxLayout(deployWidget);
Tobias Hunger's avatar
Tobias Hunger committed
194 195 196
    m_deployLayout->setMargin(0);
    m_deployLayout->setSpacing(5);

197 198 199 200
    m_deployConfigurationCombo->setModel(m_deployConfigurationModel);

    m_addDeployMenu = new QMenu(m_addDeployToolButton);
    m_addDeployToolButton->setMenu(m_addDeployMenu);
Tobias Hunger's avatar
Tobias Hunger committed
201 202 203

    updateDeployConfiguration(m_target->activeDeployConfiguration());

204
    // Some projects may not support deployment, so we need this:
205 206
    m_addDeployToolButton->setEnabled(m_target->activeDeployConfiguration());
    m_deployConfigurationCombo->setEnabled(m_target->activeDeployConfiguration());
207

208 209
    m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().count() > 1);
    m_renameDeployButton->setEnabled(m_target->activeDeployConfiguration());
Tobias Hunger's avatar
Tobias Hunger committed
210 211 212

    connect(m_addDeployMenu, SIGNAL(aboutToShow()),
            this, SLOT(aboutToShowDeployMenu()));
213
    connect(m_deployConfigurationCombo, SIGNAL(currentIndexChanged(int)),
Tobias Hunger's avatar
Tobias Hunger committed
214
            this, SLOT(currentDeployConfigurationChanged(int)));
215
    connect(m_removeDeployToolButton, SIGNAL(clicked(bool)),
Tobias Hunger's avatar
Tobias Hunger committed
216
            this, SLOT(removeDeployConfiguration()));
217
    connect(m_renameDeployButton, SIGNAL(clicked()),
218
            this, SLOT(renameDeployConfiguration()));
Tobias Hunger's avatar
Tobias Hunger committed
219 220 221 222 223

    connect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
            this, SLOT(activeDeployConfigurationChanged()));

    // run part
224 225
    runWidget->setContentsMargins(0, 10, 0, 25);
    m_runLayout = new QVBoxLayout(runWidget);
226 227 228
    m_runLayout->setMargin(0);
    m_runLayout->setSpacing(5);

229 230 231 232
    m_addRunMenu = new QMenu(m_addRunToolButton);
    m_addRunToolButton->setMenu(m_addRunMenu);
    m_runConfigurationCombo->setModel(m_runConfigurationsModel);
    m_runConfigurationCombo->setCurrentIndex(
dt's avatar
dt committed
233
            m_runConfigurationsModel->indexFor(m_target->activeRunConfiguration()).row());
234

235 236
    m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
    m_renameRunButton->setEnabled(m_target->activeRunConfiguration());
dt's avatar
dt committed
237

238
    setConfigurationWidget(m_target->activeRunConfiguration());
con's avatar
con committed
239

Tobias Hunger's avatar
Tobias Hunger committed
240
    connect(m_addRunMenu, SIGNAL(aboutToShow()),
con's avatar
con committed
241
            this, SLOT(aboutToShowAddMenu()));
242
    connect(m_runConfigurationCombo, SIGNAL(currentIndexChanged(int)),
243
            this, SLOT(currentRunConfigurationChanged(int)));
244
    connect(m_removeRunToolButton, SIGNAL(clicked(bool)),
con's avatar
con committed
245
            this, SLOT(removeRunConfiguration()));
246
    connect(m_renameRunButton, SIGNAL(clicked()),
247
            this, SLOT(renameRunConfiguration()));
Tobias Hunger's avatar
Tobias Hunger committed
248 249

    connect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
250
            this, SLOT(activeRunConfigurationChanged()));
con's avatar
con committed
251 252 253 254 255 256
}

RunSettingsWidget::~RunSettingsWidget()
{
}

257

con's avatar
con committed
258 259
void RunSettingsWidget::aboutToShowAddMenu()
{
Tobias Hunger's avatar
Tobias Hunger committed
260
    m_addRunMenu->clear();
hjk's avatar
hjk committed
261 262 263
    QList<IRunConfigurationFactory *> factories =
        ExtensionSystem::PluginManager::instance()->getObjects<IRunConfigurationFactory>();
    foreach (IRunConfigurationFactory *factory, factories) {
Tobias Hunger's avatar
Tobias Hunger committed
264
        QStringList ids = factory->availableCreationIds(m_target);
265
        foreach (const QString &id, ids) {
Tobias Hunger's avatar
Tobias Hunger committed
266
            QAction *action = m_addRunMenu->addAction(factory->displayNameForId(id));;
267 268 269
            FactoryAndId fai;
            fai.factory = factory;
            fai.id = id;
con's avatar
con committed
270
            QVariant v;
271
            v.setValue(fai);
con's avatar
con committed
272 273 274 275 276 277 278 279 280 281 282 283
            action->setData(v);
            connect(action, SIGNAL(triggered()),
                    this, SLOT(addRunConfiguration()));
        }
    }
}

void RunSettingsWidget::addRunConfiguration()
{
    QAction *act = qobject_cast<QAction *>(sender());
    if (!act)
        return;
284
    FactoryAndId fai = act->data().value<FactoryAndId>();
Tobias Hunger's avatar
Tobias Hunger committed
285
    RunConfiguration *newRC = fai.factory->create(m_target, fai.id);
con's avatar
con committed
286 287
    if (!newRC)
        return;
Tobias Hunger's avatar
Tobias Hunger committed
288
    m_target->addRunConfiguration(newRC);
289
    m_target->setActiveRunConfiguration(newRC);
290
    m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
con's avatar
con committed
291 292 293 294
}

void RunSettingsWidget::removeRunConfiguration()
{
295
    RunConfiguration *rc = m_target->activeRunConfiguration();
296
    QMessageBox msgBox(QMessageBox::Question, tr("Remove Run Configuration?"),
297
                       tr("Do you really want to delete the run configuration <b>%1</b>?").arg(rc->displayName()),
298 299 300
                       QMessageBox::Yes|QMessageBox::No, this);
    msgBox.setDefaultButton(QMessageBox::No);
    msgBox.setEscapeButton(QMessageBox::No);
hjk's avatar
hjk committed
301
    if (msgBox.exec() == QMessageBox::No)
302 303
        return;

Tobias Hunger's avatar
Tobias Hunger committed
304
    m_target->removeRunConfiguration(rc);
305 306
    m_removeRunToolButton->setEnabled(m_target->runConfigurations().size() > 1);
    m_renameRunButton->setEnabled(m_target->activeRunConfiguration());
307 308 309 310
}

void RunSettingsWidget::activeRunConfigurationChanged()
{
311 312 313 314
    if (m_ignoreChange)
        return;
    QModelIndex actRc = m_runConfigurationsModel->indexFor(m_target->activeRunConfiguration());
    m_ignoreChange = true;
315
    m_runConfigurationCombo->setCurrentIndex(actRc.row());
316
    setConfigurationWidget(m_runConfigurationsModel->runConfigurationAt(actRc.row()));
317
    m_ignoreChange = false;
con's avatar
con committed
318 319
}

320 321 322 323 324 325 326 327
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);
hjk's avatar
hjk committed
328
    if (!ok)
329 330
        return;

331 332 333 334
    name = uniqueRCName(name);
    if (name.isEmpty())
        return;

335 336 337
    m_target->activeRunConfiguration()->setDisplayName(name);
}

338
void RunSettingsWidget::currentRunConfigurationChanged(int index)
con's avatar
con committed
339
{
340 341
    if (m_ignoreChange)
        return;
342 343 344 345

    RunConfiguration *selectedRunConfiguration = 0;
    if (index >= 0)
        selectedRunConfiguration = m_runConfigurationsModel->runConfigurationAt(index);
346 347 348 349

    m_ignoreChange = true;
    m_target->setActiveRunConfiguration(selectedRunConfiguration);
    m_ignoreChange = false;
con's avatar
con committed
350 351

    // Update the run configuration configuration widget
352
    setConfigurationWidget(selectedRunConfiguration);
353
}
Tobias Hunger's avatar
Tobias Hunger committed
354 355 356 357 358 359 360 361 362 363 364 365

void RunSettingsWidget::currentDeployConfigurationChanged(int index)
{
    if (index == -1)
        updateDeployConfiguration(0);
    else
        m_target->setActiveDeployConfiguration(m_deployConfigurationModel->deployConfigurationAt(index));
}

void RunSettingsWidget::aboutToShowDeployMenu()
{
    m_addDeployMenu->clear();
366
    QStringList ids = m_target->availableDeployConfigurationIds();
Tobias Hunger's avatar
Tobias Hunger committed
367
    foreach (const QString &id, ids) {
368
        QAction *action = m_addDeployMenu->addAction(m_target->displayNameForDeployConfigurationId(id));
Tobias Hunger's avatar
Tobias Hunger committed
369 370 371 372 373 374 375 376 377 378 379 380
        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();
381
    DeployConfiguration *newDc = m_target->createDeployConfiguration(id);
Tobias Hunger's avatar
Tobias Hunger committed
382 383 384 385
    if (!newDc)
        return;
    m_target->addDeployConfiguration(newDc);
    m_target->setActiveDeployConfiguration(newDc);
386
    m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
Tobias Hunger's avatar
Tobias Hunger committed
387 388 389 390 391
}

void RunSettingsWidget::removeDeployConfiguration()
{
    DeployConfiguration *dc = m_target->activeDeployConfiguration();
392
    QMessageBox msgBox(QMessageBox::Question, tr("Remove Deploy Configuration?"),
Friedemann Kleint's avatar
Friedemann Kleint committed
393
                       tr("Do you really want to delete deploy configuration <b>%1</b>?").arg(dc->displayName()),
394 395 396
                       QMessageBox::Yes|QMessageBox::No, this);
    msgBox.setDefaultButton(QMessageBox::No);
    msgBox.setEscapeButton(QMessageBox::No);
hjk's avatar
hjk committed
397
    if (msgBox.exec() == QMessageBox::No)
398 399
        return;

Tobias Hunger's avatar
Tobias Hunger committed
400
    m_target->removeDeployConfiguration(dc);
401
    m_removeDeployToolButton->setEnabled(m_target->deployConfigurations().size() > 1);
Tobias Hunger's avatar
Tobias Hunger committed
402 403 404 405 406 407 408
}

void RunSettingsWidget::activeDeployConfigurationChanged()
{
    updateDeployConfiguration(m_target->activeDeployConfiguration());
}

409 410 411 412 413 414 415 416
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);
hjk's avatar
hjk committed
417
    if (!ok)
418 419
        return;

420 421 422
    name = uniqueDCName(name);
    if (name.isEmpty())
        return;
423 424 425
    m_target->activeDeployConfiguration()->setDisplayName(name);
}

Tobias Hunger's avatar
Tobias Hunger committed
426 427 428 429 430 431 432
void RunSettingsWidget::updateDeployConfiguration(DeployConfiguration *dc)
{
    delete m_deployConfigurationWidget;
    m_deployConfigurationWidget = 0;
    delete m_deploySteps;
    m_deploySteps = 0;

433
    m_deployConfigurationCombo->setCurrentIndex(-1);
Tobias Hunger's avatar
Tobias Hunger committed
434 435 436 437 438

    if (!dc)
        return;

    QModelIndex actDc = m_deployConfigurationModel->indexFor(dc);
439
    m_deployConfigurationCombo->setCurrentIndex(actDc.row());
Tobias Hunger's avatar
Tobias Hunger committed
440 441 442 443 444 445 446 447 448 449 450

    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);
}
451

452 453 454 455
void RunSettingsWidget::setConfigurationWidget(RunConfiguration *rc)
{
    delete m_runConfigurationWidget;
    m_runConfigurationWidget = 0;
456
    removeSubWidgets();
457 458
    if (!rc)
        return;
459
    m_runConfigurationWidget = rc->createConfigurationWidget();
460 461
    if (m_runConfigurationWidget)
        m_runLayout->addWidget(m_runConfigurationWidget);
462 463

    addRunControlWidgets();
464 465
}

466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494
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;
}
495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521

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);

522
    QGridLayout *l = m_gridLayout;
523 524 525 526 527 528 529 530 531 532 533 534 535 536 537
    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();
}