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
|
|
|
|
|
** conditions see http://qt.digia.com/licensing. For further information
|
|
|
|
|
** use the contact form at http://qt.digia.com/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
|
|
|
|
|
** 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
|
|
|
****************************************************************************/
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectwindow.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
#include "doubletabwidget.h"
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
#include "kitmanager.h"
|
2008-12-02 16:19:05 +01:00
|
|
|
#include "project.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
#include "projectexplorer.h"
|
|
|
|
|
#include "session.h"
|
2010-11-02 16:14:00 +01:00
|
|
|
#include "iprojectproperties.h"
|
2010-02-08 15:50:06 +01:00
|
|
|
#include "targetsettingspanel.h"
|
2010-12-10 19:02:19 +01:00
|
|
|
#include "target.h"
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-14 16:43:51 +01:00
|
|
|
#include <coreplugin/idocument.h>
|
2009-01-19 12:39:20 +01:00
|
|
|
#include <extensionsystem/pluginmanager.h>
|
2014-06-16 18:25:52 +04:00
|
|
|
#include <utils/algorithm.h>
|
2009-11-30 16:23:28 +01:00
|
|
|
#include <utils/qtcassert.h>
|
2009-09-29 18:06:13 +02:00
|
|
|
#include <utils/stylehelper.h>
|
2008-12-02 12:01:29 +01:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QGridLayout>
|
|
|
|
|
#include <QLabel>
|
|
|
|
|
#include <QPainter>
|
|
|
|
|
#include <QStackedWidget>
|
2009-09-29 18:06:13 +02:00
|
|
|
|
2008-12-02 12:01:29 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
|
|
|
|
namespace {
|
2009-11-25 16:01:46 +01:00
|
|
|
const int ICON_SIZE(64);
|
2009-11-30 16:23:28 +01:00
|
|
|
|
|
|
|
|
const int ABOVE_HEADING_MARGIN(10);
|
|
|
|
|
const int ABOVE_CONTENTS_MARGIN(4);
|
|
|
|
|
const int BELOW_CONTENTS_MARGIN(16);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-03-25 16:16:38 +01:00
|
|
|
} // anonymous namespace
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2009-11-25 15:12:34 +01:00
|
|
|
///
|
|
|
|
|
// OnePixelBlackLine
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
class OnePixelBlackLine : public QWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
OnePixelBlackLine(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
|
|
|
setMinimumHeight(1);
|
|
|
|
|
setMaximumHeight(1);
|
|
|
|
|
}
|
|
|
|
|
void paintEvent(QPaintEvent *e)
|
|
|
|
|
{
|
2009-11-30 16:23:28 +01:00
|
|
|
Q_UNUSED(e);
|
2009-11-25 15:12:34 +01:00
|
|
|
QPainter p(this);
|
2010-03-10 19:19:46 +01:00
|
|
|
QColor fillColor = Utils::StyleHelper::mergedColors(
|
2012-06-20 16:04:12 +02:00
|
|
|
palette().button().color(), Qt::black, 80);
|
2010-03-10 19:19:46 +01:00
|
|
|
p.fillRect(contentsRect(), fillColor);
|
2009-11-25 15:12:34 +01:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2010-03-10 13:27:52 +01:00
|
|
|
class RootWidget : public QWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
2012-02-16 16:22:53 +01:00
|
|
|
RootWidget(QWidget *parent) : QWidget(parent) {
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
}
|
2010-03-10 13:27:52 +01:00
|
|
|
void paintEvent(QPaintEvent *);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void RootWidget::paintEvent(QPaintEvent *e)
|
|
|
|
|
{
|
|
|
|
|
QWidget::paintEvent(e);
|
|
|
|
|
|
|
|
|
|
QPainter painter(this);
|
2010-03-10 19:19:46 +01:00
|
|
|
QColor light = Utils::StyleHelper::mergedColors(
|
2012-06-20 16:04:12 +02:00
|
|
|
palette().button().color(), Qt::white, 30);
|
2010-03-10 19:19:46 +01:00
|
|
|
QColor dark = Utils::StyleHelper::mergedColors(
|
2012-06-20 16:04:12 +02:00
|
|
|
palette().button().color(), Qt::black, 85);
|
2010-03-10 19:19:46 +01:00
|
|
|
|
|
|
|
|
painter.setPen(light);
|
2010-03-10 13:27:52 +01:00
|
|
|
painter.drawLine(rect().topRight(), rect().bottomRight());
|
2010-03-10 19:19:46 +01:00
|
|
|
painter.setPen(dark);
|
2010-03-10 13:27:52 +01:00
|
|
|
painter.drawLine(rect().topRight() - QPoint(1,0), rect().bottomRight() - QPoint(1,0));
|
|
|
|
|
}
|
|
|
|
|
|
2009-11-25 15:12:34 +01:00
|
|
|
///
|
|
|
|
|
// PanelsWidget
|
|
|
|
|
///
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
PanelsWidget::PanelsWidget(QWidget *parent) :
|
|
|
|
|
QScrollArea(parent),
|
2010-03-10 13:27:52 +01:00
|
|
|
m_root(new RootWidget(this))
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
2009-12-07 15:24:57 +01:00
|
|
|
// We want a 900px wide widget with and the scrollbar at the
|
2009-11-25 16:01:46 +01:00
|
|
|
// side of the screen.
|
2014-01-24 12:50:04 +01:00
|
|
|
m_root->setMaximumWidth(900);
|
2010-03-10 19:19:46 +01:00
|
|
|
m_root->setContentsMargins(0, 0, 40, 0);
|
2012-04-24 15:49:09 +02:00
|
|
|
|
2014-01-07 20:38:32 +01:00
|
|
|
QPalette pal;
|
2010-03-10 19:19:46 +01:00
|
|
|
QColor background = Utils::StyleHelper::mergedColors(
|
2012-06-20 16:04:12 +02:00
|
|
|
palette().window().color(), Qt::white, 85);
|
2010-03-10 19:19:46 +01:00
|
|
|
pal.setColor(QPalette::All, QPalette::Window, background.darker(102));
|
2010-03-10 13:27:52 +01:00
|
|
|
setPalette(pal);
|
2010-03-10 19:19:46 +01:00
|
|
|
pal.setColor(QPalette::All, QPalette::Window, background);
|
|
|
|
|
m_root->setPalette(pal);
|
2013-02-14 16:04:27 +01:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// The layout holding the individual panels:
|
2013-02-14 16:04:27 +01:00
|
|
|
QVBoxLayout *topLayout = new QVBoxLayout(m_root);
|
|
|
|
|
topLayout->setMargin(0);
|
|
|
|
|
topLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_layout = new QGridLayout;
|
2009-11-30 16:23:28 +01:00
|
|
|
m_layout->setColumnMinimumWidth(0, ICON_SIZE + 4);
|
|
|
|
|
m_layout->setSpacing(0);
|
2013-02-14 16:04:27 +01:00
|
|
|
topLayout->addLayout(m_layout);
|
|
|
|
|
topLayout->addStretch(100);
|
2009-11-25 16:01:46 +01:00
|
|
|
|
2009-12-09 13:01:09 +01:00
|
|
|
setWidget(m_root);
|
2009-07-16 15:33:19 +02:00
|
|
|
setFrameStyle(QFrame::NoFrame);
|
2009-08-11 16:37:24 +02:00
|
|
|
setWidgetResizable(true);
|
2011-10-28 10:15:04 +00:00
|
|
|
setFocusPolicy(Qt::NoFocus);
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PanelsWidget::~PanelsWidget()
|
|
|
|
|
{
|
2010-01-21 13:46:19 +01:00
|
|
|
qDeleteAll(m_panels);
|
2009-09-17 13:59:10 +02:00
|
|
|
}
|
|
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
/*
|
|
|
|
|
* Add a widget with heading information into the grid
|
|
|
|
|
* layout of the PanelsWidget.
|
|
|
|
|
*
|
|
|
|
|
* ...
|
2009-11-30 16:23:28 +01:00
|
|
|
* +--------+-------------------------------------------+ ABOVE_HEADING_MARGIN
|
2009-11-25 16:01:46 +01:00
|
|
|
* | icon | name |
|
|
|
|
|
* + +-------------------------------------------+
|
2009-11-30 16:23:28 +01:00
|
|
|
* | | line |
|
2013-03-06 17:38:47 +01:00
|
|
|
* + +-------------------------------------------+ ABOVE_CONTENTS_MARGIN
|
|
|
|
|
* | | widget (with contentsmargins adjusted!) |
|
2009-11-30 16:23:28 +01:00
|
|
|
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
2009-11-25 16:01:46 +01:00
|
|
|
*/
|
2011-04-14 13:32:30 +02:00
|
|
|
void PanelsWidget::addPropertiesPanel(PropertiesPanel *panel)
|
2009-07-16 15:33:19 +02:00
|
|
|
{
|
2010-01-21 13:46:19 +01:00
|
|
|
QTC_ASSERT(panel, return);
|
2009-11-25 16:01:46 +01:00
|
|
|
|
2013-03-06 17:38:47 +01:00
|
|
|
const int headerRow = m_layout->rowCount();
|
2009-11-30 16:23:28 +01:00
|
|
|
|
2010-02-08 15:50:06 +01:00
|
|
|
// icon:
|
2010-01-21 13:46:19 +01:00
|
|
|
if (!panel->icon().isNull()) {
|
|
|
|
|
QLabel *iconLabel = new QLabel(m_root);
|
|
|
|
|
iconLabel->setPixmap(panel->icon().pixmap(ICON_SIZE, ICON_SIZE));
|
|
|
|
|
iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
2010-02-19 14:16:37 +01:00
|
|
|
m_layout->addWidget(iconLabel, headerRow, 0, 3, 1, Qt::AlignTop | Qt::AlignHCenter);
|
2009-11-25 16:01:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// name:
|
2010-01-21 13:46:19 +01:00
|
|
|
QLabel *nameLabel = new QLabel(m_root);
|
|
|
|
|
nameLabel->setText(panel->displayName());
|
2010-03-10 19:19:46 +01:00
|
|
|
QPalette palette = nameLabel->palette();
|
2013-03-11 14:11:39 +01:00
|
|
|
for (int i = QPalette::Active; i < QPalette::NColorGroups; ++i ) {
|
|
|
|
|
QColor foregroundColor = palette.color(QPalette::ColorGroup(i), QPalette::Foreground);
|
|
|
|
|
foregroundColor.setAlpha(110);
|
|
|
|
|
palette.setBrush(QPalette::ColorGroup(i), QPalette::Foreground, foregroundColor);
|
|
|
|
|
}
|
2010-03-10 19:19:46 +01:00
|
|
|
nameLabel->setPalette(palette);
|
2010-01-21 13:46:19 +01:00
|
|
|
nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
|
|
|
|
QFont f = nameLabel->font();
|
2009-07-16 15:33:19 +02:00
|
|
|
f.setBold(true);
|
2010-02-19 14:16:37 +01:00
|
|
|
f.setPointSizeF(f.pointSizeF() * 1.6);
|
2010-01-21 13:46:19 +01:00
|
|
|
nameLabel->setFont(f);
|
2010-02-19 14:16:37 +01:00
|
|
|
m_layout->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignVCenter | Qt::AlignLeft);
|
2009-11-25 16:01:46 +01:00
|
|
|
|
|
|
|
|
// line:
|
|
|
|
|
const int lineRow(headerRow + 1);
|
2010-02-19 14:16:37 +01:00
|
|
|
QWidget *line = new OnePixelBlackLine(m_root);
|
|
|
|
|
m_layout->addWidget(line, lineRow, 1, 1, -1, Qt::AlignTop);
|
2009-11-25 16:01:46 +01:00
|
|
|
|
2009-11-30 16:23:28 +01:00
|
|
|
// add the widget:
|
2009-11-25 16:01:46 +01:00
|
|
|
const int widgetRow(lineRow + 1);
|
2010-01-21 13:46:19 +01:00
|
|
|
addPanelWidget(panel, widgetRow);
|
2009-07-16 15:33:19 +02:00
|
|
|
}
|
|
|
|
|
|
2011-04-14 13:32:30 +02:00
|
|
|
void PanelsWidget::addPanelWidget(PropertiesPanel *panel, int row)
|
2009-11-30 16:23:28 +01:00
|
|
|
{
|
2010-01-21 13:46:19 +01:00
|
|
|
QWidget *widget = panel->widget();
|
2010-05-21 14:29:11 +02:00
|
|
|
widget->setContentsMargins(Constants::PANEL_LEFT_MARGIN,
|
2010-02-08 15:50:06 +01:00
|
|
|
ABOVE_CONTENTS_MARGIN, 0,
|
|
|
|
|
BELOW_CONTENTS_MARGIN);
|
2010-01-21 13:46:19 +01:00
|
|
|
widget->setParent(m_root);
|
|
|
|
|
m_layout->addWidget(widget, row, 0, 1, 2);
|
2009-11-30 16:23:28 +01:00
|
|
|
|
|
|
|
|
m_panels.append(panel);
|
|
|
|
|
}
|
|
|
|
|
|
2009-08-06 15:31:32 +02:00
|
|
|
///
|
|
|
|
|
// ProjectWindow
|
|
|
|
|
///
|
|
|
|
|
|
2009-06-08 19:13:46 +02:00
|
|
|
ProjectWindow::ProjectWindow(QWidget *parent)
|
2010-01-21 13:46:19 +01:00
|
|
|
: QWidget(parent),
|
2010-10-06 11:15:01 +02:00
|
|
|
m_currentWidget(0),
|
|
|
|
|
m_previousTargetSubIndex(-1)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2009-11-25 16:01:46 +01:00
|
|
|
// Setup overall layout:
|
|
|
|
|
QVBoxLayout *viewLayout = new QVBoxLayout(this);
|
|
|
|
|
viewLayout->setMargin(0);
|
|
|
|
|
viewLayout->setSpacing(0);
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
m_tabWidget = new DoubleTabWidget(this);
|
|
|
|
|
viewLayout->addWidget(m_tabWidget);
|
2009-10-07 15:46:07 +02:00
|
|
|
|
2009-11-25 16:01:46 +01:00
|
|
|
// Setup our container for the contents:
|
2010-01-21 13:46:19 +01:00
|
|
|
m_centralWidget = new QStackedWidget(this);
|
|
|
|
|
viewLayout->addWidget(m_centralWidget);
|
2009-11-25 16:01:46 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
// Connections
|
2010-01-21 13:46:19 +01:00
|
|
|
connect(m_tabWidget, SIGNAL(currentIndexChanged(int,int)),
|
|
|
|
|
this, SLOT(showProperties(int,int)));
|
2009-09-17 13:59:10 +02:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
QObject *sessionManager = SessionManager::instance();
|
|
|
|
|
connect(sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
2010-03-11 13:42:41 +01:00
|
|
|
this, SLOT(registerProject(ProjectExplorer::Project*)));
|
2013-09-05 11:46:07 +02:00
|
|
|
connect(sessionManager, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
|
2010-03-11 13:42:41 +01:00
|
|
|
this, SLOT(deregisterProject(ProjectExplorer::Project*)));
|
2009-11-25 15:18:51 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
connect(sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
2012-03-05 22:30:59 +01:00
|
|
|
this, SLOT(startupProjectChanged(ProjectExplorer::Project*)));
|
2010-03-24 18:36:06 +01:00
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
connect(sessionManager, SIGNAL(projectDisplayNameChanged(ProjectExplorer::Project*)),
|
2012-04-16 19:18:26 +04:00
|
|
|
this, SLOT(projectUpdated(ProjectExplorer::Project*)));
|
|
|
|
|
|
2009-11-25 15:18:51 +01:00
|
|
|
// Update properties to empty project for now:
|
2010-01-21 13:46:19 +01:00
|
|
|
showProperties(-1, -1);
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ProjectWindow::~ProjectWindow()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-10 19:02:19 +01:00
|
|
|
void ProjectWindow::extensionsInitialized()
|
|
|
|
|
{
|
2012-09-03 18:31:44 +02:00
|
|
|
connect(KitManager::instance(), SIGNAL(kitsChanged()), this, SLOT(handleKitChanges()));
|
2010-12-10 19:02:19 +01:00
|
|
|
}
|
|
|
|
|
|
2010-04-28 16:59:03 +02:00
|
|
|
void ProjectWindow::aboutToShutdown()
|
2009-10-07 15:46:07 +02:00
|
|
|
{
|
2012-05-03 16:10:00 +02:00
|
|
|
showProperties(-1, -1); // that's a bit stupid, but otherwise stuff is still
|
|
|
|
|
// connected to the session
|
2013-10-11 16:18:04 +02:00
|
|
|
disconnect(KitManager::instance(), 0, this, 0);
|
2013-09-05 11:46:07 +02:00
|
|
|
disconnect(SessionManager::instance(), 0, this, 0);
|
2009-10-07 15:46:07 +02:00
|
|
|
}
|
|
|
|
|
|
2012-07-16 15:12:58 +02:00
|
|
|
void ProjectWindow::removedTarget(Target *)
|
2012-07-12 13:31:35 +02:00
|
|
|
{
|
|
|
|
|
Project *p = qobject_cast<Project *>(sender());
|
|
|
|
|
QTC_ASSERT(p, return);
|
|
|
|
|
if (p->targets().isEmpty())
|
|
|
|
|
projectUpdated(p);
|
|
|
|
|
}
|
|
|
|
|
|
2011-10-28 10:15:04 +00:00
|
|
|
void ProjectWindow::projectUpdated(Project *p)
|
|
|
|
|
{
|
|
|
|
|
// Called after a project was configured
|
|
|
|
|
int index = m_tabWidget->currentIndex();
|
2014-07-03 16:36:17 +02:00
|
|
|
if (deregisterProject(p)) // might return false if the project is unloading
|
|
|
|
|
registerProject(p);
|
2011-10-28 10:15:04 +00:00
|
|
|
m_tabWidget->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2012-09-03 18:31:44 +02:00
|
|
|
void ProjectWindow::handleKitChanges()
|
2010-12-10 19:02:19 +01:00
|
|
|
{
|
|
|
|
|
bool changed = false;
|
|
|
|
|
int index = m_tabWidget->currentIndex();
|
|
|
|
|
QList<Project *> projects = m_tabIndexToProject;
|
|
|
|
|
foreach (ProjectExplorer::Project *project, projects) {
|
2012-08-07 10:05:19 +02:00
|
|
|
if (m_hasTarget.value(project) != hasTarget(project)) {
|
2010-12-10 19:02:19 +01:00
|
|
|
changed = true;
|
2014-07-03 16:36:17 +02:00
|
|
|
if (deregisterProject(project))
|
|
|
|
|
registerProject(project);
|
2010-12-10 19:02:19 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (changed)
|
|
|
|
|
m_tabWidget->setCurrentIndex(index);
|
|
|
|
|
}
|
|
|
|
|
|
2012-08-07 10:05:19 +02:00
|
|
|
bool ProjectWindow::hasTarget(ProjectExplorer::Project *project)
|
2010-12-10 19:02:19 +01:00
|
|
|
{
|
2012-08-07 10:05:19 +02:00
|
|
|
return !project->targets().isEmpty();
|
2010-12-10 19:02:19 +01:00
|
|
|
}
|
|
|
|
|
|
2010-03-11 13:42:41 +01:00
|
|
|
void ProjectWindow::registerProject(ProjectExplorer::Project *project)
|
2009-10-07 15:46:07 +02:00
|
|
|
{
|
2010-03-05 09:36:05 +01:00
|
|
|
if (!project || m_tabIndexToProject.contains(project))
|
2010-02-08 15:50:06 +01:00
|
|
|
return;
|
|
|
|
|
|
2010-03-05 09:36:05 +01:00
|
|
|
// find index to insert:
|
|
|
|
|
int index = -1;
|
|
|
|
|
for (int i = 0; i <= m_tabIndexToProject.count(); ++i) {
|
|
|
|
|
if (i == m_tabIndexToProject.count() ||
|
|
|
|
|
m_tabIndexToProject.at(i)->displayName() > project->displayName()) {
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
QStringList subtabs;
|
2010-12-10 19:02:19 +01:00
|
|
|
|
2012-08-07 10:05:19 +02:00
|
|
|
bool projectHasTarget = hasTarget(project);
|
|
|
|
|
m_hasTarget.insert(project, projectHasTarget);
|
2010-03-25 16:16:38 +01:00
|
|
|
|
2012-08-07 10:05:19 +02:00
|
|
|
if (projectHasTarget) // Use the Targets page
|
2012-09-03 18:31:44 +02:00
|
|
|
subtabs << QCoreApplication::translate("TargetSettingsPanelFactory", "Build & Run");
|
2010-03-25 16:16:38 +01:00
|
|
|
|
|
|
|
|
// Add the project specific pages
|
2012-06-18 11:34:15 +02:00
|
|
|
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(factories, &IPanelFactory::prioritySort);
|
2010-03-25 16:16:38 +01:00
|
|
|
foreach (IProjectPanelFactory *panelFactory, factories) {
|
|
|
|
|
if (panelFactory->supports(project))
|
|
|
|
|
subtabs << panelFactory->displayName();
|
2009-10-07 15:46:07 +02:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
m_tabIndexToProject.insert(index, project);
|
2014-05-02 12:22:58 +02:00
|
|
|
m_tabWidget->insertTab(index, project->displayName(), project->projectFilePath().toString(), subtabs);
|
2012-07-12 13:31:35 +02:00
|
|
|
|
|
|
|
|
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(removedTarget(ProjectExplorer::Target*)));
|
2010-01-21 13:46:19 +01:00
|
|
|
}
|
|
|
|
|
|
2014-07-03 16:36:17 +02:00
|
|
|
bool ProjectWindow::deregisterProject(ProjectExplorer::Project *project)
|
2010-01-21 13:46:19 +01:00
|
|
|
{
|
|
|
|
|
int index = m_tabIndexToProject.indexOf(project);
|
2010-03-05 09:36:05 +01:00
|
|
|
if (index < 0)
|
2014-07-03 16:36:17 +02:00
|
|
|
return false;
|
2010-03-11 13:42:41 +01:00
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
m_tabIndexToProject.removeAt(index);
|
|
|
|
|
m_tabWidget->removeTab(index);
|
2012-07-12 13:31:35 +02:00
|
|
|
disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(removedTarget(ProjectExplorer::Target*)));
|
2014-07-03 16:36:17 +02:00
|
|
|
return true;
|
2009-10-07 15:46:07 +02:00
|
|
|
}
|
|
|
|
|
|
2010-03-24 18:36:06 +01:00
|
|
|
void ProjectWindow::startupProjectChanged(ProjectExplorer::Project *p)
|
|
|
|
|
{
|
|
|
|
|
int index = m_tabIndexToProject.indexOf(p);
|
2010-03-26 11:01:47 +01:00
|
|
|
if (index != -1)
|
|
|
|
|
m_tabWidget->setCurrentIndex(index);
|
2010-03-11 13:42:41 +01:00
|
|
|
}
|
|
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
void ProjectWindow::showProperties(int index, int subIndex)
|
2008-12-02 12:01:29 +01:00
|
|
|
{
|
2010-08-26 18:47:32 +02:00
|
|
|
if (index < 0 || index >= m_tabIndexToProject.count()) {
|
|
|
|
|
removeCurrentWidget();
|
2010-01-21 13:46:19 +01:00
|
|
|
return;
|
2010-08-26 18:47:32 +02:00
|
|
|
}
|
2010-02-22 15:47:47 +01:00
|
|
|
|
2010-01-21 13:46:19 +01:00
|
|
|
Project *project = m_tabIndexToProject.at(index);
|
2009-11-04 18:50:37 +01:00
|
|
|
|
2009-11-25 15:18:51 +01:00
|
|
|
// Set up custom panels again:
|
2010-02-08 15:50:06 +01:00
|
|
|
int pos = 0;
|
2014-07-11 11:54:49 +02:00
|
|
|
IProjectPanelFactory *fac = 0;
|
2010-10-06 11:15:01 +02:00
|
|
|
// remember previous sub index state of target settings page
|
|
|
|
|
if (TargetSettingsPanelWidget *previousPanelWidget
|
|
|
|
|
= qobject_cast<TargetSettingsPanelWidget*>(m_currentWidget)) {
|
|
|
|
|
m_previousTargetSubIndex = previousPanelWidget->currentSubIndex();
|
|
|
|
|
}
|
2010-12-10 19:02:19 +01:00
|
|
|
|
2014-07-11 12:04:30 +02:00
|
|
|
if (m_hasTarget.value(project) || project->requiresTargetPanel()) {
|
2010-03-25 16:16:38 +01:00
|
|
|
if (subIndex == 0) {
|
|
|
|
|
// Targets page
|
2010-02-08 15:50:06 +01:00
|
|
|
removeCurrentWidget();
|
2010-10-06 11:15:01 +02:00
|
|
|
TargetSettingsPanelWidget *panelWidget = new TargetSettingsPanelWidget(project);
|
|
|
|
|
if (m_previousTargetSubIndex >= 0)
|
|
|
|
|
panelWidget->setCurrentSubIndex(m_previousTargetSubIndex);
|
|
|
|
|
m_currentWidget = panelWidget;
|
2010-02-08 15:50:06 +01:00
|
|
|
m_centralWidget->addWidget(m_currentWidget);
|
|
|
|
|
m_centralWidget->setCurrentWidget(m_currentWidget);
|
2010-01-21 13:46:19 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
++pos;
|
2010-03-25 16:16:38 +01:00
|
|
|
}
|
|
|
|
|
|
2012-08-07 10:05:19 +02:00
|
|
|
QList<IProjectPanelFactory *> factories = ExtensionSystem::PluginManager::getObjects<IProjectPanelFactory>();
|
2014-06-16 18:25:52 +04:00
|
|
|
Utils::sort(factories, &IPanelFactory::prioritySort);
|
2012-08-07 10:05:19 +02:00
|
|
|
foreach (IProjectPanelFactory *panelFactory, factories) {
|
|
|
|
|
if (panelFactory->supports(project)) {
|
|
|
|
|
if (subIndex == pos) {
|
|
|
|
|
fac = panelFactory;
|
|
|
|
|
break;
|
2010-03-25 16:16:38 +01:00
|
|
|
}
|
2012-08-07 10:05:19 +02:00
|
|
|
++pos;
|
2010-03-25 16:16:38 +01:00
|
|
|
}
|
2010-01-21 13:46:19 +01:00
|
|
|
}
|
2010-03-25 16:16:38 +01:00
|
|
|
|
|
|
|
|
if (fac) {
|
|
|
|
|
removeCurrentWidget();
|
|
|
|
|
|
2014-07-11 11:54:49 +02:00
|
|
|
PropertiesPanel *panel = fac->createPanel(project);
|
2010-03-25 16:16:38 +01:00
|
|
|
Q_ASSERT(panel);
|
|
|
|
|
|
|
|
|
|
PanelsWidget *panelsWidget = new PanelsWidget(m_centralWidget);
|
|
|
|
|
panelsWidget->addPropertiesPanel(panel);
|
|
|
|
|
m_currentWidget = panelsWidget;
|
|
|
|
|
m_centralWidget->addWidget(m_currentWidget);
|
|
|
|
|
m_centralWidget->setCurrentWidget(m_currentWidget);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2013-09-05 11:46:07 +02:00
|
|
|
SessionManager::setStartupProject(project);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectWindow::removeCurrentWidget()
|
|
|
|
|
{
|
|
|
|
|
if (m_currentWidget) {
|
|
|
|
|
m_centralWidget->removeWidget(m_currentWidget);
|
2010-03-25 16:16:38 +01:00
|
|
|
if (m_currentWidget) {
|
2010-02-08 15:50:06 +01:00
|
|
|
delete m_currentWidget;
|
|
|
|
|
m_currentWidget = 0;
|
2008-12-02 12:01:29 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|