2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2010-02-08 15:50:06 +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
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2012-10-02 09:12:39 +02:00
|
|
|
** This file is part of Qt Creator.
|
2010-02-08 15:50:06 +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
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/contact-us.
|
2010-02-08 15:50:06 +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
|
|
|
|
|
** 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.
|
|
|
|
|
**
|
|
|
|
|
** 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
|
|
|
****************************************************************************/
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
#include "targetsettingspanel.h"
|
|
|
|
|
|
2014-02-11 13:21:06 +01:00
|
|
|
#include "buildinfo.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "buildsettingspropertiespage.h"
|
2014-02-20 11:05:25 +01:00
|
|
|
#include "ipotentialkit.h"
|
2012-09-06 20:54:31 +02:00
|
|
|
#include "kitoptionspage.h"
|
2014-07-11 16:54:04 +02:00
|
|
|
#include "panelswidget.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "project.h"
|
2014-02-11 13:21:06 +01:00
|
|
|
#include "projectimporter.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "projectwindow.h"
|
|
|
|
|
#include "runsettingspropertiespage.h"
|
|
|
|
|
#include "target.h"
|
|
|
|
|
#include "targetsettingswidget.h"
|
|
|
|
|
|
2012-08-10 03:01:56 +02:00
|
|
|
#include <coreplugin/icore.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/projectexplorer.h>
|
2012-09-03 18:31:44 +02:00
|
|
|
#include <projectexplorer/kit.h>
|
|
|
|
|
#include <projectexplorer/kitmanager.h>
|
2011-10-24 13:10:38 +00:00
|
|
|
#include <projectexplorer/buildmanager.h>
|
2012-09-20 14:42:57 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
|
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2012-04-24 15:49:09 +02:00
|
|
|
#include <utils/qtcassert.h>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2014-02-11 13:21:06 +01:00
|
|
|
#include <QFileDialog>
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QMenu>
|
|
|
|
|
#include <QMessageBox>
|
|
|
|
|
#include <QPushButton>
|
2012-09-06 14:46:28 +02:00
|
|
|
#include <QStackedWidget>
|
|
|
|
|
#include <QToolTip>
|
|
|
|
|
#include <QVBoxLayout>
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
|
2012-12-29 01:31:08 +01:00
|
|
|
using namespace Core;
|
|
|
|
|
|
|
|
|
|
namespace ProjectExplorer {
|
|
|
|
|
namespace Internal {
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2014-07-11 13:08:09 +02:00
|
|
|
int TargetSettingsPanelWidget::s_targetSubIndex = -1;
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
///
|
|
|
|
|
// TargetSettingsWidget
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
TargetSettingsPanelWidget::TargetSettingsPanelWidget(Project *project) :
|
2010-02-26 13:45:07 +01:00
|
|
|
m_currentTarget(0),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_project(project),
|
2014-02-11 13:21:06 +01:00
|
|
|
m_importer(project->createProjectImporter()),
|
2010-02-08 15:50:06 +01:00
|
|
|
m_selector(0),
|
2012-09-20 11:16:47 +02:00
|
|
|
m_centralWidget(0),
|
2012-09-20 14:42:57 +02:00
|
|
|
m_changeMenu(0),
|
|
|
|
|
m_duplicateMenu(0),
|
2014-02-11 13:21:06 +01:00
|
|
|
m_lastAction(0),
|
|
|
|
|
m_importAction(0)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2010-03-15 10:52:18 +01:00
|
|
|
Q_ASSERT(m_project);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_panelWidgets[0] = 0;
|
|
|
|
|
m_panelWidgets[1] = 0;
|
|
|
|
|
|
2010-06-29 12:56:08 +02:00
|
|
|
m_addMenu = new QMenu(this);
|
2012-09-20 14:42:57 +02:00
|
|
|
m_targetMenu = new QMenu(this);
|
2010-06-29 12:56:08 +02:00
|
|
|
|
2014-02-11 13:21:06 +01:00
|
|
|
if (m_importer) {
|
|
|
|
|
m_importAction = new QAction(tr("Import existing build..."), this);
|
|
|
|
|
connect(m_importAction, SIGNAL(triggered()), this, SLOT(importTarget()));
|
|
|
|
|
}
|
|
|
|
|
|
2012-02-16 16:22:53 +01:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
setupUi();
|
|
|
|
|
|
|
|
|
|
connect(m_project, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(targetAdded(ProjectExplorer::Target*)));
|
2010-03-25 17:27:59 +01:00
|
|
|
connect(m_project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(removedTarget(ProjectExplorer::Target*)));
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
connect(m_project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged(ProjectExplorer::Target*)));
|
2010-12-10 19:02:19 +01:00
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
connect(KitManager::instance(), SIGNAL(kitsChanged()),
|
2012-09-20 14:42:57 +02:00
|
|
|
this, SLOT(updateTargetButtons()));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TargetSettingsPanelWidget::~TargetSettingsPanelWidget()
|
|
|
|
|
{
|
2014-02-11 13:21:06 +01:00
|
|
|
delete m_importer;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 11:16:47 +02:00
|
|
|
bool TargetSettingsPanelWidget::event(QEvent *event)
|
|
|
|
|
{
|
|
|
|
|
if (event->type() == QEvent::StatusTip) {
|
2012-09-20 14:42:57 +02:00
|
|
|
QAction *act = 0;
|
|
|
|
|
QMenu *menu = 0;
|
|
|
|
|
if (m_addMenu->activeAction()) {
|
|
|
|
|
menu = m_addMenu;
|
|
|
|
|
act = m_addMenu->activeAction();
|
|
|
|
|
} else if (m_changeMenu && m_changeMenu->activeAction()) {
|
|
|
|
|
menu = m_changeMenu;
|
|
|
|
|
act = m_changeMenu->activeAction();
|
|
|
|
|
} else if (m_duplicateMenu && m_duplicateMenu->activeAction()) {
|
|
|
|
|
menu = m_duplicateMenu;
|
|
|
|
|
act = m_duplicateMenu->activeAction();
|
|
|
|
|
} else {
|
|
|
|
|
return QWidget::event(event);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-20 11:16:47 +02:00
|
|
|
QStatusTipEvent *ev = static_cast<QStatusTipEvent *>(event);
|
|
|
|
|
ev->accept();
|
|
|
|
|
|
|
|
|
|
if (act != m_lastAction)
|
|
|
|
|
QToolTip::showText(QPoint(), QString());
|
|
|
|
|
m_lastAction = act;
|
|
|
|
|
if (act) {
|
2012-09-20 14:42:57 +02:00
|
|
|
QRect actionRect = menu->actionGeometry(act);
|
|
|
|
|
actionRect.translate(menu->pos());
|
2012-09-20 11:16:47 +02:00
|
|
|
QPoint p = QCursor::pos();
|
|
|
|
|
if (!actionRect.contains(p))
|
|
|
|
|
p = actionRect.center();
|
|
|
|
|
p.setY(actionRect.center().y());
|
2012-09-20 14:42:57 +02:00
|
|
|
QToolTip::showText(p, ev->tip(), menu, menu->actionGeometry(act));
|
2012-09-20 11:16:47 +02:00
|
|
|
} else {
|
|
|
|
|
QToolTip::showText(QPoint(), QString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return QWidget::event(event);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void TargetSettingsPanelWidget::setupUi()
|
|
|
|
|
{
|
|
|
|
|
QVBoxLayout *viewLayout = new QVBoxLayout(this);
|
|
|
|
|
viewLayout->setMargin(0);
|
|
|
|
|
viewLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_selector = new TargetSettingsWidget(this);
|
|
|
|
|
viewLayout->addWidget(m_selector);
|
|
|
|
|
|
|
|
|
|
// Setup our container for the contents:
|
|
|
|
|
m_centralWidget = new QStackedWidget(this);
|
|
|
|
|
m_selector->setCentralWidget(m_centralWidget);
|
|
|
|
|
|
2010-09-14 17:49:11 +02:00
|
|
|
// no target label:
|
2010-02-08 15:50:06 +01:00
|
|
|
m_noTargetLabel = new QWidget;
|
2010-09-14 17:49:11 +02:00
|
|
|
QVBoxLayout *noTargetLayout = new QVBoxLayout(m_noTargetLabel);
|
2010-02-08 15:50:06 +01:00
|
|
|
noTargetLayout->setMargin(0);
|
|
|
|
|
QLabel *label = new QLabel(m_noTargetLabel);
|
2012-09-06 16:19:14 +02:00
|
|
|
label->setText(tr("No kit defined in this project."));
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
QFont f = label->font();
|
|
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
label->setFont(f);
|
|
|
|
|
}
|
|
|
|
|
label->setMargin(10);
|
|
|
|
|
label->setAlignment(Qt::AlignTop);
|
|
|
|
|
noTargetLayout->addWidget(label);
|
|
|
|
|
noTargetLayout->addStretch(10);
|
|
|
|
|
m_centralWidget->addWidget(m_noTargetLabel);
|
|
|
|
|
|
|
|
|
|
foreach (Target *t, m_project->targets())
|
|
|
|
|
targetAdded(t);
|
|
|
|
|
|
2010-06-15 14:44:15 +02:00
|
|
|
// Now set the correct target
|
|
|
|
|
int index = m_targets.indexOf(m_project->activeTarget());
|
|
|
|
|
m_selector->setCurrentIndex(index);
|
2014-07-11 13:08:09 +02:00
|
|
|
m_selector->setCurrentSubIndex(s_targetSubIndex);
|
2013-11-01 11:57:59 +01:00
|
|
|
currentTargetChanged(index, m_selector->currentSubIndex());
|
2010-06-15 14:44:15 +02:00
|
|
|
|
|
|
|
|
connect(m_selector, SIGNAL(currentChanged(int,int)),
|
|
|
|
|
this, SLOT(currentTargetChanged(int,int)));
|
2012-08-10 03:01:56 +02:00
|
|
|
connect(m_selector, SIGNAL(manageButtonClicked()),
|
|
|
|
|
this, SLOT(openTargetPreferences()));
|
2012-09-06 14:46:28 +02:00
|
|
|
connect(m_selector, SIGNAL(toolTipRequested(QPoint,int)),
|
|
|
|
|
this, SLOT(showTargetToolTip(QPoint,int)));
|
2012-09-20 14:42:57 +02:00
|
|
|
connect(m_selector, SIGNAL(menuShown(int)),
|
|
|
|
|
this, SLOT(menuShown(int)));
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-06-29 12:56:08 +02:00
|
|
|
connect(m_addMenu, SIGNAL(triggered(QAction*)),
|
2012-09-20 14:42:57 +02:00
|
|
|
this, SLOT(addActionTriggered(QAction*)));
|
2010-06-29 12:56:08 +02:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
m_selector->setAddButtonMenu(m_addMenu);
|
|
|
|
|
m_selector->setTargetMenu(m_targetMenu);
|
|
|
|
|
|
|
|
|
|
updateTargetButtons();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-02-26 13:45:07 +01:00
|
|
|
void TargetSettingsPanelWidget::currentTargetChanged(int targetIndex, int subIndex)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2010-02-23 14:33:18 +01:00
|
|
|
if (targetIndex < -1 || targetIndex >= m_targets.count())
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
if (subIndex < -1 || subIndex >= 2)
|
|
|
|
|
return;
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
if (targetIndex == -1 || subIndex == -1) { // no more kits!
|
2010-03-30 13:23:11 +02:00
|
|
|
delete m_panelWidgets[0];
|
|
|
|
|
m_panelWidgets[0] = 0;
|
|
|
|
|
delete m_panelWidgets[1];
|
|
|
|
|
m_panelWidgets[1] = 0;
|
|
|
|
|
|
|
|
|
|
m_centralWidget->setCurrentWidget(m_noTargetLabel);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2014-07-11 13:08:09 +02:00
|
|
|
s_targetSubIndex = subIndex;
|
|
|
|
|
|
2010-03-26 12:44:55 +01:00
|
|
|
Target *target = m_targets.at(targetIndex);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
|
|
|
|
// Target was not actually changed:
|
2010-02-26 13:45:07 +01:00
|
|
|
if (m_currentTarget == target) {
|
2010-02-23 14:33:18 +01:00
|
|
|
if (m_panelWidgets[subIndex])
|
|
|
|
|
m_centralWidget->setCurrentWidget(m_panelWidgets[subIndex]);
|
|
|
|
|
else
|
|
|
|
|
m_centralWidget->setCurrentWidget(m_noTargetLabel);
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-23 14:33:18 +01:00
|
|
|
// Target has changed:
|
2010-03-30 13:23:11 +02:00
|
|
|
m_currentTarget = target;
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-03-26 12:44:55 +01:00
|
|
|
PanelsWidget *buildPanel = new PanelsWidget(m_centralWidget);
|
|
|
|
|
PanelsWidget *runPanel = new PanelsWidget(m_centralWidget);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2012-06-18 11:34:15 +02:00
|
|
|
foreach (ITargetPanelFactory *panelFactory, ExtensionSystem::PluginManager::getObjects<ITargetPanelFactory>()) {
|
2010-02-08 15:50:06 +01:00
|
|
|
if (panelFactory->id() == QLatin1String(BUILDSETTINGS_PANEL_ID)) {
|
2011-04-14 13:32:30 +02:00
|
|
|
PropertiesPanel *panel = panelFactory->createPanel(target);
|
2010-02-08 15:50:06 +01:00
|
|
|
buildPanel->addPropertiesPanel(panel);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
if (panelFactory->id() == QLatin1String(RUNSETTINGS_PANEL_ID)) {
|
2011-04-14 13:32:30 +02:00
|
|
|
PropertiesPanel *panel = panelFactory->createPanel(target);
|
2010-02-08 15:50:06 +01:00
|
|
|
runPanel->addPropertiesPanel(panel);
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
m_centralWidget->addWidget(buildPanel);
|
|
|
|
|
m_centralWidget->addWidget(runPanel);
|
|
|
|
|
|
2010-02-23 14:33:18 +01:00
|
|
|
m_centralWidget->setCurrentWidget(subIndex == 0 ? buildPanel : runPanel);
|
|
|
|
|
|
|
|
|
|
delete m_panelWidgets[0];
|
2010-02-08 15:50:06 +01:00
|
|
|
m_panelWidgets[0] = buildPanel;
|
2010-02-23 14:33:18 +01:00
|
|
|
delete m_panelWidgets[1];
|
2010-02-08 15:50:06 +01:00
|
|
|
m_panelWidgets[1] = runPanel;
|
2010-03-26 12:44:55 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
|
m_project->setActiveTarget(target);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
void TargetSettingsPanelWidget::menuShown(int targetIndex)
|
|
|
|
|
{
|
|
|
|
|
m_menuTargetIndex = targetIndex;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::changeActionTriggered(QAction *action)
|
|
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
Kit *k = KitManager::find(action->data().value<Core::Id>());
|
2012-09-20 14:42:57 +02:00
|
|
|
Target *sourceTarget = m_targets.at(m_menuTargetIndex);
|
|
|
|
|
Target *newTarget = cloneTarget(sourceTarget, k);
|
|
|
|
|
|
|
|
|
|
if (newTarget) {
|
|
|
|
|
m_project->addTarget(newTarget);
|
|
|
|
|
m_project->setActiveTarget(newTarget);
|
|
|
|
|
m_project->removeTarget(sourceTarget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::duplicateActionTriggered(QAction *action)
|
|
|
|
|
{
|
2013-08-21 12:48:46 +02:00
|
|
|
Kit *k = KitManager::find(action->data().value<Core::Id>());
|
2012-09-20 14:42:57 +02:00
|
|
|
Target *newTarget = cloneTarget(m_targets.at(m_menuTargetIndex), k);
|
|
|
|
|
|
|
|
|
|
if (newTarget) {
|
|
|
|
|
m_project->addTarget(newTarget);
|
|
|
|
|
m_project->setActiveTarget(newTarget);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::addActionTriggered(QAction *action)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2014-02-20 11:05:25 +01:00
|
|
|
const QVariant data = action->data();
|
|
|
|
|
if (data.canConvert<Core::Id>()) { // id of kit
|
|
|
|
|
Kit *k = KitManager::find(action->data().value<Core::Id>());
|
|
|
|
|
QTC_ASSERT(!m_project->target(k), return);
|
2010-12-06 16:15:41 +01:00
|
|
|
|
2014-02-20 11:05:25 +01:00
|
|
|
Target *target = m_project->createTarget(k);
|
|
|
|
|
if (!target)
|
|
|
|
|
return;
|
|
|
|
|
m_project->addTarget(target);
|
|
|
|
|
} else {
|
|
|
|
|
QTC_ASSERT(data.canConvert<IPotentialKit *>(), return);
|
|
|
|
|
IPotentialKit *potentialKit = data.value<IPotentialKit *>();
|
|
|
|
|
potentialKit->executeFromMenu();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
Target *TargetSettingsPanelWidget::cloneTarget(Target *sourceTarget, Kit *k)
|
|
|
|
|
{
|
|
|
|
|
Target *newTarget = new Target(m_project, k);
|
|
|
|
|
|
|
|
|
|
QStringList buildconfigurationError;
|
|
|
|
|
QStringList deployconfigurationError;
|
|
|
|
|
QStringList runconfigurationError;
|
|
|
|
|
|
|
|
|
|
foreach (BuildConfiguration *sourceBc, sourceTarget->buildConfigurations()) {
|
|
|
|
|
IBuildConfigurationFactory *factory = IBuildConfigurationFactory::find(newTarget, sourceBc);
|
|
|
|
|
if (!factory) {
|
|
|
|
|
buildconfigurationError << sourceBc->displayName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
BuildConfiguration *newBc = factory->clone(newTarget, sourceBc);
|
|
|
|
|
if (!newBc) {
|
|
|
|
|
buildconfigurationError << sourceBc->displayName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
newBc->setDisplayName(sourceBc->displayName());
|
|
|
|
|
newTarget->addBuildConfiguration(newBc);
|
|
|
|
|
if (sourceTarget->activeBuildConfiguration() == sourceBc)
|
|
|
|
|
newTarget->setActiveBuildConfiguration(newBc);
|
|
|
|
|
}
|
|
|
|
|
if (!newTarget->activeBuildConfiguration()) {
|
|
|
|
|
QList<BuildConfiguration *> bcs = newTarget->buildConfigurations();
|
|
|
|
|
if (!bcs.isEmpty())
|
|
|
|
|
newTarget->setActiveBuildConfiguration(bcs.first());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (DeployConfiguration *sourceDc, sourceTarget->deployConfigurations()) {
|
|
|
|
|
DeployConfigurationFactory *factory = DeployConfigurationFactory::find(newTarget, sourceDc);
|
|
|
|
|
if (!factory) {
|
|
|
|
|
deployconfigurationError << sourceDc->displayName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
DeployConfiguration *newDc = factory->clone(newTarget, sourceDc);
|
|
|
|
|
if (!newDc) {
|
|
|
|
|
deployconfigurationError << sourceDc->displayName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
newDc->setDisplayName(sourceDc->displayName());
|
|
|
|
|
newTarget->addDeployConfiguration(newDc);
|
|
|
|
|
if (sourceTarget->activeDeployConfiguration() == sourceDc)
|
|
|
|
|
newTarget->setActiveDeployConfiguration(newDc);
|
|
|
|
|
}
|
|
|
|
|
if (!newTarget->activeBuildConfiguration()) {
|
|
|
|
|
QList<DeployConfiguration *> dcs = newTarget->deployConfigurations();
|
|
|
|
|
if (!dcs.isEmpty())
|
|
|
|
|
newTarget->setActiveDeployConfiguration(dcs.first());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach (RunConfiguration *sourceRc, sourceTarget->runConfigurations()) {
|
|
|
|
|
IRunConfigurationFactory *factory = IRunConfigurationFactory::find(newTarget, sourceRc);
|
|
|
|
|
if (!factory) {
|
|
|
|
|
runconfigurationError << sourceRc->displayName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
RunConfiguration *newRc = factory->clone(newTarget, sourceRc);
|
|
|
|
|
if (!newRc) {
|
|
|
|
|
runconfigurationError << sourceRc->displayName();
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
newRc->setDisplayName(sourceRc->displayName());
|
|
|
|
|
newTarget->addRunConfiguration(newRc);
|
|
|
|
|
if (sourceTarget->activeRunConfiguration() == sourceRc)
|
|
|
|
|
newTarget->setActiveRunConfiguration(newRc);
|
|
|
|
|
}
|
|
|
|
|
if (!newTarget->activeRunConfiguration()) {
|
|
|
|
|
QList<RunConfiguration *> rcs = newTarget->runConfigurations();
|
|
|
|
|
if (!rcs.isEmpty())
|
|
|
|
|
newTarget->setActiveRunConfiguration(rcs.first());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool fatalError = false;
|
|
|
|
|
if (buildconfigurationError.count() == sourceTarget->buildConfigurations().count())
|
|
|
|
|
fatalError = true;
|
|
|
|
|
|
|
|
|
|
if (deployconfigurationError.count() == sourceTarget->deployConfigurations().count())
|
|
|
|
|
fatalError = true;
|
|
|
|
|
|
|
|
|
|
if (runconfigurationError.count() == sourceTarget->runConfigurations().count())
|
|
|
|
|
fatalError = true;
|
|
|
|
|
|
|
|
|
|
if (fatalError) {
|
|
|
|
|
// That could be a more granular error message
|
|
|
|
|
QMessageBox::critical(Core::ICore::mainWindow(),
|
|
|
|
|
tr("Incompatible Kit"),
|
2013-02-08 17:24:10 +01:00
|
|
|
tr("Kit %1 is incompatible with kit %2.")
|
2012-09-20 14:42:57 +02:00
|
|
|
.arg(sourceTarget->kit()->displayName())
|
|
|
|
|
.arg(k->displayName()));
|
|
|
|
|
|
|
|
|
|
delete newTarget;
|
|
|
|
|
newTarget = 0;
|
|
|
|
|
} else if (!buildconfigurationError.isEmpty()
|
|
|
|
|
|| !deployconfigurationError.isEmpty()
|
|
|
|
|
|| ! runconfigurationError.isEmpty()) {
|
|
|
|
|
|
|
|
|
|
QString error;
|
|
|
|
|
if (!buildconfigurationError.isEmpty())
|
2013-10-17 13:48:04 +02:00
|
|
|
error += tr("Build configurations:")
|
|
|
|
|
+ QLatin1Char('\n')
|
2012-09-20 14:42:57 +02:00
|
|
|
+ buildconfigurationError.join(QLatin1String("\n"));
|
|
|
|
|
|
|
|
|
|
if (!deployconfigurationError.isEmpty()) {
|
|
|
|
|
if (!error.isEmpty())
|
|
|
|
|
error.append(QLatin1Char('\n'));
|
2013-10-17 13:48:04 +02:00
|
|
|
error += tr("Deploy configurations:")
|
|
|
|
|
+ QLatin1Char('\n')
|
2012-09-20 14:42:57 +02:00
|
|
|
+ deployconfigurationError.join(QLatin1String("\n"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!runconfigurationError.isEmpty()) {
|
|
|
|
|
if (!error.isEmpty())
|
|
|
|
|
error.append(QLatin1Char('\n'));
|
2013-10-17 14:52:10 +02:00
|
|
|
error += tr("Run configurations") + QLatin1Char(' ')
|
2012-09-20 14:42:57 +02:00
|
|
|
+ runconfigurationError.join(QLatin1String("\n"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QMessageBox msgBox(Core::ICore::mainWindow());
|
|
|
|
|
msgBox.setIcon(QMessageBox::Warning);
|
2013-02-08 17:24:10 +01:00
|
|
|
msgBox.setWindowTitle(tr("Partially Incompatible Kit"));
|
2012-09-20 14:42:57 +02:00
|
|
|
msgBox.setText(tr("Some configurations could not be copied."));
|
|
|
|
|
msgBox.setDetailedText(error);
|
|
|
|
|
msgBox.setStandardButtons(QMessageBox::Ok | QMessageBox::Cancel);
|
|
|
|
|
if (msgBox.exec() != QDialog::Accepted) {
|
|
|
|
|
delete newTarget;
|
|
|
|
|
newTarget = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return newTarget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::removeTarget()
|
2010-02-10 17:29:08 +01:00
|
|
|
{
|
2012-09-20 14:42:57 +02:00
|
|
|
Target *t = m_targets.at(m_menuTargetIndex);
|
|
|
|
|
removeTarget(t);
|
|
|
|
|
}
|
2011-10-24 13:10:38 +00:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
void TargetSettingsPanelWidget::removeTarget(Target *t)
|
|
|
|
|
{
|
2013-09-05 14:36:20 +02:00
|
|
|
if (BuildManager::isBuilding(t)) {
|
2011-10-24 13:10:38 +00:00
|
|
|
QMessageBox box;
|
2012-09-03 18:31:44 +02:00
|
|
|
QPushButton *closeAnyway = box.addButton(tr("Cancel Build && Remove Kit"), QMessageBox::AcceptRole);
|
2011-10-24 13:10:38 +00:00
|
|
|
QPushButton *cancelClose = box.addButton(tr("Do Not Remove"), QMessageBox::RejectRole);
|
|
|
|
|
box.setDefaultButton(cancelClose);
|
2012-09-03 18:31:44 +02:00
|
|
|
box.setWindowTitle(tr("Remove Kit %1?").arg(t->displayName()));
|
|
|
|
|
box.setText(tr("The kit <b>%1</b> is currently being built.").arg(t->displayName()));
|
2013-02-08 17:24:10 +01:00
|
|
|
box.setInformativeText(tr("Do you want to cancel the build process and remove the kit anyway?"));
|
2011-10-24 13:10:38 +00:00
|
|
|
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 {
|
|
|
|
|
// We don't show the generic message box on removing the target, if we showed the still building one
|
|
|
|
|
int ret = QMessageBox::warning(this, tr("Qt Creator"),
|
|
|
|
|
tr("Do you really want to remove the\n"
|
2012-09-03 18:31:44 +02:00
|
|
|
"\"%1\" kit?").arg(t->displayName()),
|
2011-10-24 13:10:38 +00:00
|
|
|
QMessageBox::Yes | QMessageBox::No,
|
|
|
|
|
QMessageBox::No);
|
|
|
|
|
if (ret != QMessageBox::Yes)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
m_project->removeTarget(t);
|
|
|
|
|
|
2010-02-10 17:29:08 +01:00
|
|
|
}
|
|
|
|
|
|
2012-09-06 14:46:28 +02:00
|
|
|
void TargetSettingsPanelWidget::showTargetToolTip(const QPoint &globalPos, int targetIndex)
|
|
|
|
|
{
|
|
|
|
|
QTC_ASSERT(targetIndex >= 0 && targetIndex < m_targets.count(), return);
|
|
|
|
|
Target *target = m_targets.at(targetIndex);
|
|
|
|
|
QToolTip::showText(globalPos, target->kit()->toHtml());
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
void TargetSettingsPanelWidget::targetAdded(ProjectExplorer::Target *target)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(m_project == target->project());
|
|
|
|
|
Q_ASSERT(m_selector);
|
|
|
|
|
|
2010-02-22 14:42:37 +01:00
|
|
|
for (int pos = 0; pos <= m_targets.count(); ++pos) {
|
|
|
|
|
if (m_targets.count() == pos ||
|
|
|
|
|
m_targets.at(pos)->displayName() > target->displayName()) {
|
|
|
|
|
m_targets.insert(pos, target);
|
2013-11-01 11:57:59 +01:00
|
|
|
m_selector->insertTarget(pos, m_project->hasActiveBuildSettings() ? 0 : 1,
|
|
|
|
|
target->displayName());
|
|
|
|
|
|
2010-02-22 14:42:37 +01:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
connect(target, SIGNAL(displayNameChanged()), this, SLOT(renameTarget()));
|
2012-09-20 14:42:57 +02:00
|
|
|
updateTargetButtons();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-25 17:27:59 +01:00
|
|
|
void TargetSettingsPanelWidget::removedTarget(ProjectExplorer::Target *target)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
Q_ASSERT(m_project == target->project());
|
|
|
|
|
Q_ASSERT(m_selector);
|
|
|
|
|
|
2010-02-22 14:42:37 +01:00
|
|
|
int index(m_targets.indexOf(target));
|
2010-02-08 15:50:06 +01:00
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
2010-02-22 14:42:37 +01:00
|
|
|
m_targets.removeAt(index);
|
|
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
m_selector->removeTarget(index);
|
2010-03-15 10:52:18 +01:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
updateTargetButtons();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::activeTargetChanged(ProjectExplorer::Target *target)
|
|
|
|
|
{
|
|
|
|
|
Q_ASSERT(m_selector);
|
|
|
|
|
|
2010-03-26 12:44:55 +01:00
|
|
|
int index = m_targets.indexOf(target);
|
|
|
|
|
m_selector->setCurrentIndex(index);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-03-15 10:52:18 +01:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
void TargetSettingsPanelWidget::createAction(Kit *k, QMenu *menu)
|
|
|
|
|
{
|
|
|
|
|
QAction *action = new QAction(k->displayName(), menu);
|
|
|
|
|
action->setData(QVariant::fromValue(k->id()));
|
2013-04-03 15:07:56 +02:00
|
|
|
QString statusTip = QLatin1String("<html><body>");
|
2012-09-20 14:42:57 +02:00
|
|
|
QString errorMessage;
|
|
|
|
|
if (!m_project->supportsKit(k, &errorMessage)) {
|
|
|
|
|
action->setEnabled(false);
|
2013-04-03 15:07:56 +02:00
|
|
|
statusTip += errorMessage;
|
2012-09-20 14:42:57 +02:00
|
|
|
}
|
2013-04-03 15:07:56 +02:00
|
|
|
statusTip += k->toHtml();
|
|
|
|
|
action->setStatusTip(statusTip);
|
|
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
menu->addAction(action);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::updateTargetButtons()
|
2010-03-15 10:52:18 +01:00
|
|
|
{
|
|
|
|
|
if (!m_selector)
|
|
|
|
|
return;
|
|
|
|
|
|
2010-06-29 12:56:08 +02:00
|
|
|
m_addMenu->clear();
|
2012-09-20 14:42:57 +02:00
|
|
|
m_targetMenu->clear();
|
2010-06-29 12:56:08 +02:00
|
|
|
|
2014-02-20 11:05:25 +01:00
|
|
|
if (m_importAction)
|
2014-02-11 13:21:06 +01:00
|
|
|
m_addMenu->addAction(m_importAction);
|
2014-02-20 11:05:25 +01:00
|
|
|
const QList<IPotentialKit *> potentialKits
|
|
|
|
|
= ExtensionSystem::PluginManager::getObjects<IPotentialKit>();
|
|
|
|
|
foreach (IPotentialKit *potentialKit, potentialKits) {
|
|
|
|
|
if (!potentialKit->isEnabled())
|
|
|
|
|
continue;
|
|
|
|
|
QAction *action = new QAction(potentialKit->displayName(), m_addMenu);
|
|
|
|
|
action->setData(QVariant::fromValue(potentialKit));
|
|
|
|
|
m_addMenu->addAction(action);
|
2014-02-11 13:21:06 +01:00
|
|
|
}
|
2014-02-20 11:05:25 +01:00
|
|
|
if (!m_addMenu->actions().isEmpty())
|
|
|
|
|
m_addMenu->addSeparator();
|
2014-02-11 13:21:06 +01:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
m_changeMenu = m_targetMenu->addMenu(tr("Change Kit"));
|
|
|
|
|
m_duplicateMenu = m_targetMenu->addMenu(tr("Copy to Kit"));
|
|
|
|
|
QAction *removeAction = m_targetMenu->addAction(tr("Remove Kit"));
|
2010-12-06 16:15:41 +01:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
if (m_project->targets().size() < 2)
|
|
|
|
|
removeAction->setEnabled(false);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2012-09-20 14:42:57 +02:00
|
|
|
connect(m_changeMenu, SIGNAL(triggered(QAction*)),
|
|
|
|
|
this, SLOT(changeActionTriggered(QAction*)));
|
|
|
|
|
connect(m_duplicateMenu, SIGNAL(triggered(QAction*)),
|
|
|
|
|
this, SLOT(duplicateActionTriggered(QAction*)));
|
|
|
|
|
connect(removeAction, SIGNAL(triggered()), this, SLOT(removeTarget()));
|
|
|
|
|
|
2013-08-21 12:48:46 +02:00
|
|
|
QList<Kit *> kits = KitManager::kits();
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(kits, [](const Kit *a, const Kit *b) {
|
|
|
|
|
return a->displayName() < b->displayName();
|
|
|
|
|
});
|
2012-09-20 14:42:57 +02:00
|
|
|
foreach (Kit *k, kits) {
|
|
|
|
|
if (m_project->target(k))
|
|
|
|
|
continue;
|
|
|
|
|
createAction(k, m_addMenu);
|
|
|
|
|
createAction(k, m_changeMenu);
|
|
|
|
|
createAction(k, m_duplicateMenu);
|
2010-06-29 12:56:08 +02:00
|
|
|
}
|
2012-09-20 14:42:57 +02:00
|
|
|
if (m_changeMenu->actions().isEmpty())
|
|
|
|
|
m_changeMenu->setEnabled(false);
|
|
|
|
|
if (m_duplicateMenu->actions().isEmpty())
|
|
|
|
|
m_duplicateMenu->setEnabled(false);
|
|
|
|
|
|
2010-06-29 12:56:08 +02:00
|
|
|
m_selector->setAddButtonEnabled(!m_addMenu->actions().isEmpty());
|
2010-03-15 10:52:18 +01:00
|
|
|
}
|
2010-10-06 11:15:01 +02:00
|
|
|
|
2012-04-24 15:49:09 +02:00
|
|
|
void TargetSettingsPanelWidget::renameTarget()
|
|
|
|
|
{
|
|
|
|
|
Target *t = qobject_cast<Target *>(sender());
|
|
|
|
|
if (!t)
|
|
|
|
|
return;
|
|
|
|
|
const int pos = m_targets.indexOf(t);
|
|
|
|
|
if (pos < 0)
|
|
|
|
|
return;
|
|
|
|
|
m_selector->renameTarget(pos, t->displayName());
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-10 03:01:56 +02:00
|
|
|
void TargetSettingsPanelWidget::openTargetPreferences()
|
|
|
|
|
{
|
2012-09-06 20:54:31 +02:00
|
|
|
int targetIndex = m_selector->currentIndex();
|
|
|
|
|
if (targetIndex >= 0 && targetIndex < m_targets.size()) {
|
2012-12-29 01:31:08 +01:00
|
|
|
KitOptionsPage *page = ExtensionSystem::PluginManager::getObject<ProjectExplorer::KitOptionsPage>();
|
2012-09-06 20:54:31 +02:00
|
|
|
if (page)
|
|
|
|
|
page->showKit(m_targets.at(targetIndex)->kit());
|
|
|
|
|
}
|
2012-12-29 01:31:08 +01:00
|
|
|
ICore::showOptionsDialog(Constants::PROJECTEXPLORER_SETTINGS_CATEGORY,
|
2014-07-14 14:47:24 +02:00
|
|
|
Constants::KITS_SETTINGS_PAGE_ID,
|
|
|
|
|
this);
|
2012-08-10 03:01:56 +02:00
|
|
|
}
|
|
|
|
|
|
2014-02-11 13:21:06 +01:00
|
|
|
void TargetSettingsPanelWidget::importTarget()
|
|
|
|
|
{
|
2014-05-02 12:53:36 +02:00
|
|
|
QString toImport = QFileDialog::getExistingDirectory(this, tr("Import directory"), m_project->projectDirectory().toString());
|
2014-02-11 13:21:06 +01:00
|
|
|
importTarget(Utils::FileName::fromString(toImport));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::importTarget(const Utils::FileName &path)
|
|
|
|
|
{
|
|
|
|
|
if (!m_importer)
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
Target *target = 0;
|
|
|
|
|
BuildConfiguration *bc = 0;
|
|
|
|
|
QList<BuildInfo *> toImport = m_importer->import(path, false);
|
|
|
|
|
foreach (BuildInfo *info, toImport) {
|
|
|
|
|
target = m_project->target(info->kitId);
|
|
|
|
|
if (!target) {
|
|
|
|
|
target = new Target(m_project, KitManager::find(info->kitId));
|
|
|
|
|
m_project->addTarget(target);
|
|
|
|
|
}
|
|
|
|
|
bc = info->factory()->create(target, info);
|
|
|
|
|
QTC_ASSERT(bc, continue);
|
|
|
|
|
target->addBuildConfiguration(bc);
|
|
|
|
|
}
|
|
|
|
|
m_project->setActiveTarget(target);
|
|
|
|
|
if (target && bc)
|
|
|
|
|
target->setActiveBuildConfiguration(bc);
|
|
|
|
|
|
|
|
|
|
qDeleteAll(toImport);
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-06 11:15:01 +02:00
|
|
|
int TargetSettingsPanelWidget::currentSubIndex() const
|
|
|
|
|
{
|
|
|
|
|
return m_selector->currentSubIndex();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void TargetSettingsPanelWidget::setCurrentSubIndex(int subIndex)
|
|
|
|
|
{
|
|
|
|
|
m_selector->setCurrentSubIndex(subIndex);
|
|
|
|
|
}
|
2012-12-29 01:31:08 +01:00
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace ProjectExplorer
|