2010-02-08 15:50:06 +01:00
|
|
|
/**************************************************************************
|
|
|
|
|
**
|
|
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
2012-01-26 18:33:46 +01:00
|
|
|
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
2011-11-02 15:59:12 +01:00
|
|
|
** Contact: Nokia Corporation (qt-info@nokia.com)
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
|
|
|
|
**
|
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.
|
2010-02-08 15:50:06 +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-11-02 15:59:12 +01:00
|
|
|
** Nokia at qt-info@nokia.com.
|
2010-02-08 15:50:06 +01:00
|
|
|
**
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
#include "miniprojecttargetselector.h"
|
2010-07-13 16:36:37 +02:00
|
|
|
#include "target.h"
|
2010-01-21 21:12:40 +01:00
|
|
|
|
|
|
|
|
#include <utils/qtcassert.h>
|
|
|
|
|
#include <utils/styledbar.h>
|
|
|
|
|
#include <utils/stylehelper.h>
|
|
|
|
|
|
2011-03-30 16:33:31 +02:00
|
|
|
#include <coreplugin/ifile.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
#include <coreplugin/icore.h>
|
2010-02-09 19:05:15 +01:00
|
|
|
#include <coreplugin/coreconstants.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
|
|
|
|
#include <projectexplorer/projectexplorer.h>
|
|
|
|
|
#include <projectexplorer/session.h>
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2011-09-26 14:48:12 +02:00
|
|
|
#include <projectexplorer/deployconfiguration.h>
|
|
|
|
|
#include <projectexplorer/runconfiguration.h>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
#include <QtCore/QTimer>
|
2010-01-21 21:12:40 +01:00
|
|
|
#include <QtGui/QLayout>
|
|
|
|
|
#include <QtGui/QLabel>
|
|
|
|
|
#include <QtGui/QListWidget>
|
|
|
|
|
#include <QtGui/QStatusBar>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <QtGui/QKeyEvent>
|
2010-02-09 19:05:15 +01:00
|
|
|
#include <QtGui/QPainter>
|
2010-05-27 13:28:07 +02:00
|
|
|
#include <QtGui/QAction>
|
2010-02-24 19:23:40 +01:00
|
|
|
#include <QtGui/QItemDelegate>
|
2010-11-01 16:29:45 +01:00
|
|
|
#include <QtGui/QMainWindow>
|
2010-02-08 15:50:06 +01:00
|
|
|
#include <QtGui/QApplication>
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2010-02-23 16:52:03 +01:00
|
|
|
static QIcon createCenteredIcon(const QIcon &icon, const QIcon &overlay)
|
|
|
|
|
{
|
|
|
|
|
QPixmap targetPixmap;
|
|
|
|
|
targetPixmap = QPixmap(Core::Constants::TARGET_ICON_SIZE, Core::Constants::TARGET_ICON_SIZE);
|
|
|
|
|
targetPixmap.fill(Qt::transparent);
|
|
|
|
|
QPainter painter(&targetPixmap);
|
|
|
|
|
|
2010-02-24 19:54:35 +01:00
|
|
|
QPixmap pixmap = icon.pixmap(Core::Constants::TARGET_ICON_SIZE);
|
|
|
|
|
painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width())/2,
|
|
|
|
|
(Core::Constants::TARGET_ICON_SIZE - pixmap.height())/2, pixmap);
|
2010-02-23 16:52:03 +01:00
|
|
|
if (!overlay.isNull()) {
|
2010-02-24 19:54:35 +01:00
|
|
|
pixmap = overlay.pixmap(Core::Constants::TARGET_ICON_SIZE);
|
|
|
|
|
painter.drawPixmap((Core::Constants::TARGET_ICON_SIZE - pixmap.width())/2,
|
|
|
|
|
(Core::Constants::TARGET_ICON_SIZE - pixmap.height())/2, pixmap);
|
2010-02-23 16:52:03 +01:00
|
|
|
}
|
|
|
|
|
return QIcon(targetPixmap);
|
|
|
|
|
}
|
|
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
using namespace ProjectExplorer::Internal;
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
////////
|
|
|
|
|
// TargetSelectorDelegate
|
|
|
|
|
////////
|
2010-02-24 19:23:40 +01:00
|
|
|
class TargetSelectorDelegate : public QItemDelegate
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
TargetSelectorDelegate(QObject *parent) : QItemDelegate(parent) { }
|
|
|
|
|
private:
|
2011-09-26 14:48:12 +02:00
|
|
|
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const;
|
2010-02-24 19:23:40 +01:00
|
|
|
void paint(QPainter *painter,
|
|
|
|
|
const QStyleOptionViewItem &option,
|
|
|
|
|
const QModelIndex &index) const;
|
|
|
|
|
mutable QImage selectionGradient;
|
|
|
|
|
};
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QSize TargetSelectorDelegate::sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(option)
|
|
|
|
|
Q_UNUSED(index)
|
|
|
|
|
return QSize(190, 30);
|
|
|
|
|
}
|
|
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
void TargetSelectorDelegate::paint(QPainter *painter,
|
|
|
|
|
const QStyleOptionViewItem &option,
|
2011-09-26 14:48:12 +02:00
|
|
|
const QModelIndex &index) const
|
2010-02-24 19:23:40 +01:00
|
|
|
{
|
|
|
|
|
painter->save();
|
|
|
|
|
painter->setClipping(false);
|
|
|
|
|
|
|
|
|
|
if (selectionGradient.isNull())
|
|
|
|
|
selectionGradient.load(QLatin1String(":/projectexplorer/images/targetpanel_gradient.png"));
|
|
|
|
|
|
|
|
|
|
if (option.state & QStyle::State_Selected) {
|
2010-03-09 11:14:19 +01:00
|
|
|
QColor color =(option.state & QStyle::State_HasFocus) ?
|
|
|
|
|
option.palette.highlight().color() :
|
|
|
|
|
option.palette.dark().color();
|
|
|
|
|
painter->fillRect(option.rect, color.darker(140));
|
2010-02-24 19:23:40 +01:00
|
|
|
Utils::StyleHelper::drawCornerImage(selectionGradient, painter, option.rect.adjusted(0, 0, 0, -1), 5, 5, 5, 5);
|
|
|
|
|
painter->setPen(QColor(255, 255, 255, 60));
|
|
|
|
|
painter->drawLine(option.rect.topLeft(), option.rect.topRight());
|
|
|
|
|
painter->setPen(QColor(255, 255, 255, 30));
|
|
|
|
|
painter->drawLine(option.rect.bottomLeft() - QPoint(0,1), option.rect.bottomRight() - QPoint(0,1));
|
|
|
|
|
painter->setPen(QColor(0, 0, 0, 80));
|
|
|
|
|
painter->drawLine(option.rect.bottomLeft(), option.rect.bottomRight());
|
|
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
QFontMetrics fm(option.font);
|
|
|
|
|
QString text = index.data(Qt::DisplayRole).toString();
|
|
|
|
|
painter->setPen(QColor(255, 255, 255, 160));
|
|
|
|
|
QString elidedText = fm.elidedText(text, Qt::ElideMiddle, option.rect.width() - 12);
|
|
|
|
|
if (elidedText != text)
|
|
|
|
|
const_cast<QAbstractItemModel *>(index.model())->setData(index, text, Qt::ToolTipRole);
|
|
|
|
|
else
|
2012-01-09 16:30:33 +01:00
|
|
|
const_cast<QAbstractItemModel *>(index.model())->setData(index, QString(), Qt::ToolTipRole);
|
2011-09-26 14:48:12 +02:00
|
|
|
painter->drawText(option.rect.left() + 6, option.rect.top() + (option.rect.height() - fm.height()) / 2 + fm.ascent(), elidedText);
|
|
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
painter->restore();
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
////////
|
|
|
|
|
// ListWidget
|
|
|
|
|
////////
|
|
|
|
|
ListWidget::ListWidget(QWidget *parent)
|
|
|
|
|
: QListWidget(parent), m_maxCount(0)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
|
|
|
|
setFocusPolicy(Qt::NoFocus);
|
|
|
|
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
|
|
|
|
setAlternatingRowColors(false);
|
|
|
|
|
setFocusPolicy(Qt::WheelFocus);
|
2010-02-24 19:23:40 +01:00
|
|
|
setItemDelegate(new TargetSelectorDelegate(this));
|
2010-02-25 13:07:50 +01:00
|
|
|
setAttribute(Qt::WA_MacShowFocusRect, false);
|
2011-09-26 14:48:12 +02:00
|
|
|
setStyleSheet(QString::fromLatin1("QListWidget { background: #464646; border-style: none; }"));
|
|
|
|
|
setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QSize ListWidget::sizeHint() const
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
int height = m_maxCount * 30;
|
|
|
|
|
int width = 190;
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
// We try to keep the height of the popup equal to the actionbar
|
2011-03-24 17:05:51 +01:00
|
|
|
QSize size(width, height);
|
2012-01-24 15:36:40 +01:00
|
|
|
static QStatusBar *statusBar = Core::ICore::statusBar();
|
|
|
|
|
static QWidget *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
2010-02-24 19:23:40 +01:00
|
|
|
Q_ASSERT(actionBar);
|
|
|
|
|
|
|
|
|
|
QMargins popupMargins = window()->contentsMargins();
|
2011-09-26 14:48:12 +02:00
|
|
|
int alignedWithActionHeight
|
|
|
|
|
= actionBar->height() - statusBar->height() - (popupMargins.top() + popupMargins.bottom());
|
|
|
|
|
size.setHeight(qBound(alignedWithActionHeight, height, 2 * alignedWithActionHeight));
|
2010-02-24 19:23:40 +01:00
|
|
|
return size;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ListWidget::keyPressEvent(QKeyEvent *event)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (event->key() == Qt::Key_Left)
|
|
|
|
|
focusPreviousChild();
|
|
|
|
|
else if (event->key() == Qt::Key_Right)
|
|
|
|
|
focusNextChild();
|
|
|
|
|
else
|
|
|
|
|
QListWidget::keyPressEvent(event);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ListWidget::keyReleaseEvent(QKeyEvent *event)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (event->key() != Qt::LeftArrow && event->key() != Qt::RightArrow)
|
|
|
|
|
QListWidget::keyReleaseEvent(event);
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ListWidget::setMaxCount(int maxCount)
|
|
|
|
|
{
|
|
|
|
|
// Note: the current assumption is that, this is not called while the listwidget is visible
|
|
|
|
|
// Otherwise we would need to add code to MiniProjectTargetSelector reacting to the
|
|
|
|
|
// updateGeometry (which then would jump ugly)
|
|
|
|
|
m_maxCount = maxCount;
|
|
|
|
|
updateGeometry();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
////////
|
|
|
|
|
// ProjectListWidget
|
|
|
|
|
////////
|
|
|
|
|
ProjectListWidget::ProjectListWidget(SessionManager *sessionManager, QWidget *parent)
|
|
|
|
|
: ListWidget(parent), m_sessionManager(sessionManager), m_ignoreIndexChange(false)
|
|
|
|
|
{
|
|
|
|
|
connect(m_sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(addProject(ProjectExplorer::Project*)));
|
|
|
|
|
connect(m_sessionManager, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(removeProject(ProjectExplorer::Project*)));
|
|
|
|
|
connect(m_sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(changeStartupProject(ProjectExplorer::Project*)));
|
|
|
|
|
connect(this, SIGNAL(currentRowChanged(int)),
|
|
|
|
|
this, SLOT(setProject(int)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *ProjectListWidget::itemForProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
QListWidgetItem *currentItem = item(i);
|
|
|
|
|
if (currentItem->data(Qt::UserRole).value<Project*>() == project)
|
|
|
|
|
return currentItem;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QString ProjectListWidget::fullName(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
return tr("%1 (%2)").arg(project->displayName(), project->file()->fileName());
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ProjectListWidget::addProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreIndexChange = true;
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QString sortName = fullName(project);
|
|
|
|
|
int pos = 0;
|
|
|
|
|
for (int i=0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
|
|
|
|
QString itemSortName = fullName(p);
|
|
|
|
|
if (itemSortName > sortName)
|
|
|
|
|
pos = i;
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
bool useFullName = false;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project*>();
|
|
|
|
|
if (p->displayName() == project->displayName()) {
|
|
|
|
|
useFullName = true;
|
|
|
|
|
item(i)->setText(fullName(p));
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QString displayName = useFullName ? fullName(project) : project->displayName();
|
|
|
|
|
QListWidgetItem *item = new QListWidgetItem();
|
|
|
|
|
item->setData(Qt::UserRole, QVariant::fromValue(project));
|
|
|
|
|
item->setText(displayName);
|
|
|
|
|
insertItem(pos, item);
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
if (project == ProjectExplorerPlugin::instance()->startupProject()) {
|
|
|
|
|
setCurrentItem(item);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ProjectListWidget::removeProject(Project *project)
|
|
|
|
|
{
|
|
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
|
|
|
|
|
QListWidgetItem *listItem = itemForProject(project);
|
|
|
|
|
delete listItem;
|
|
|
|
|
|
|
|
|
|
// Update display names
|
|
|
|
|
QString name = project->displayName();
|
|
|
|
|
int countDisplayName = 0;
|
|
|
|
|
int otherIndex = -1;
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
Project *p = item(i)->data(Qt::UserRole).value<Project *>();
|
|
|
|
|
if (p->displayName() == name) {
|
|
|
|
|
++countDisplayName;
|
|
|
|
|
otherIndex = i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (countDisplayName == 1) {
|
|
|
|
|
Project *p = item(otherIndex)->data(Qt::UserRole).value<Project *>();
|
|
|
|
|
item(otherIndex)->setText(p->displayName());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = false;
|
|
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ProjectListWidget::setProject(int index)
|
2010-02-09 19:05:15 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_ignoreIndexChange)
|
|
|
|
|
return;
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
Project *p = item(index)->data(Qt::UserRole).value<Project *>();
|
|
|
|
|
m_sessionManager->setStartupProject(p);
|
2010-02-09 19:05:15 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void ProjectListWidget::changeStartupProject(Project *project)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
setCurrentItem(itemForProject(project));
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
/////////
|
|
|
|
|
// GenericListWidget
|
|
|
|
|
/////////
|
|
|
|
|
|
|
|
|
|
GenericListWidget::GenericListWidget(QWidget *parent)
|
|
|
|
|
: ListWidget(parent), m_ignoreIndexChange(false)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(this, SIGNAL(currentRowChanged(int)),
|
|
|
|
|
this, SLOT(rowChanged(int)));
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::setProjectConfigurations(const QList<ProjectConfiguration *> &list, ProjectConfiguration *active)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
clear();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
disconnect(p, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(displayNameChanged()));
|
|
|
|
|
}
|
|
|
|
|
foreach (ProjectConfiguration *pc, list)
|
|
|
|
|
addProjectConfiguration(pc);
|
|
|
|
|
setActiveProjectConfiguration(active);
|
|
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
2010-04-29 16:52:31 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::setActiveProjectConfiguration(ProjectConfiguration *active)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
QListWidgetItem *item = itemForProjectConfiguration(active);
|
|
|
|
|
setCurrentItem(item);
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::addProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
QListWidgetItem *lwi = new QListWidgetItem();
|
|
|
|
|
lwi->setText(pc->displayName());
|
|
|
|
|
lwi->setData(Qt::UserRole, QVariant::fromValue(pc));
|
|
|
|
|
|
|
|
|
|
// Figure out pos
|
|
|
|
|
int pos = count();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
if (pc->displayName() < p->displayName()) {
|
|
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
insertItem(pos, lwi);
|
|
|
|
|
|
|
|
|
|
connect(pc, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(displayNameChanged()));
|
|
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::removeProjectConfiguration(ProjectExplorer::ProjectConfiguration *pc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
disconnect(pc, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(displayNameChanged()));
|
|
|
|
|
delete itemForProjectConfiguration(pc);
|
|
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::rowChanged(int index)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_ignoreIndexChange)
|
|
|
|
|
return;
|
|
|
|
|
if (index < 0)
|
|
|
|
|
return;
|
|
|
|
|
emit changeActiveProjectConfiguration(item(index)->data(Qt::UserRole).value<ProjectConfiguration *>());
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void GenericListWidget::displayNameChanged()
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
m_ignoreIndexChange = true;
|
|
|
|
|
ProjectConfiguration *pc = qobject_cast<ProjectConfiguration *>(sender());
|
|
|
|
|
int index = -1;
|
|
|
|
|
int i = 0;
|
|
|
|
|
for (; i < count(); ++i) {
|
|
|
|
|
QListWidgetItem *lwi = item(i);
|
|
|
|
|
if (lwi->data(Qt::UserRole).value<ProjectConfiguration *>() == pc) {
|
|
|
|
|
index = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (index == -1)
|
|
|
|
|
return;
|
|
|
|
|
QListWidgetItem *lwi = takeItem(i);
|
|
|
|
|
lwi->setText(pc->displayName());
|
|
|
|
|
int pos = count();
|
|
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
ProjectConfiguration *p = item(i)->data(Qt::UserRole).value<ProjectConfiguration *>();
|
|
|
|
|
if (pc->displayName() < p->displayName()) {
|
|
|
|
|
pos = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
insertItem(pos, lwi);
|
|
|
|
|
m_ignoreIndexChange = false;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QListWidgetItem *GenericListWidget::itemForProjectConfiguration(ProjectConfiguration *pc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
for (int i = 0; i < count(); ++i) {
|
|
|
|
|
QListWidgetItem *lwi = item(i);
|
|
|
|
|
if (lwi->data(Qt::UserRole).value<ProjectConfiguration *>() == pc) {
|
|
|
|
|
return lwi;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QWidget *createTitleLabel(const QString &text)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
Utils::StyledBar *bar = new Utils::StyledBar;
|
|
|
|
|
bar->setSingleRow(true);
|
|
|
|
|
QVBoxLayout *toolLayout = new QVBoxLayout(bar);
|
|
|
|
|
toolLayout->setMargin(0);
|
|
|
|
|
toolLayout->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
QLabel *l = new QLabel(text);
|
|
|
|
|
l->setIndent(6);
|
|
|
|
|
QFont f = l->font();
|
|
|
|
|
f.setBold(true);
|
|
|
|
|
l->setFont(f);
|
|
|
|
|
toolLayout->addWidget(l);
|
|
|
|
|
|
|
|
|
|
int panelHeight = l->fontMetrics().height() + 12;
|
|
|
|
|
bar->ensurePolished(); // Required since manhattanstyle overrides height
|
|
|
|
|
bar->setFixedHeight(panelHeight);
|
|
|
|
|
return bar;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
class OnePixelGreyLine : public QWidget
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
public:
|
|
|
|
|
OnePixelGreyLine(QWidget *parent)
|
|
|
|
|
: QWidget(parent)
|
|
|
|
|
{
|
|
|
|
|
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
|
|
|
|
|
setMinimumWidth(1);
|
|
|
|
|
setMaximumWidth(1);
|
|
|
|
|
}
|
|
|
|
|
void paintEvent(QPaintEvent *e)
|
|
|
|
|
{
|
|
|
|
|
Q_UNUSED(e);
|
|
|
|
|
QPainter p(this);
|
|
|
|
|
p.fillRect(contentsRect(), QColor(160, 160, 160, 255));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorAction, SessionManager *sessionManager, QWidget *parent) :
|
|
|
|
|
QWidget(parent), m_projectAction(targetSelectorAction), m_sessionManager(sessionManager),
|
|
|
|
|
m_project(0),
|
|
|
|
|
m_target(0),
|
|
|
|
|
m_buildConfiguration(0),
|
|
|
|
|
m_deployConfiguration(0),
|
|
|
|
|
m_runConfiguration(0),
|
|
|
|
|
m_hideOnRelease(false)
|
|
|
|
|
{
|
|
|
|
|
QPalette p = palette();
|
|
|
|
|
p.setColor(QPalette::Text, QColor(255, 255, 255, 160));
|
|
|
|
|
setPalette(p);
|
2010-02-24 19:23:40 +01:00
|
|
|
setProperty("panelwidget", true);
|
|
|
|
|
setContentsMargins(QMargins(0, 1, 1, 8));
|
2010-01-21 21:12:40 +01:00
|
|
|
setWindowFlags(Qt::Popup);
|
|
|
|
|
|
|
|
|
|
targetSelectorAction->setIcon(style()->standardIcon(QStyle::SP_ComputerIcon));
|
|
|
|
|
targetSelectorAction->setProperty("titledAction", true);
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QGridLayout *grid = new QGridLayout(this);
|
|
|
|
|
grid->setMargin(0);
|
|
|
|
|
grid->setSpacing(0);
|
|
|
|
|
|
|
|
|
|
m_summaryLabel = new QLabel(this);
|
|
|
|
|
m_summaryLabel->setMargin(3);
|
|
|
|
|
m_summaryLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
|
m_summaryLabel->setStyleSheet(QString::fromLatin1("background: #464646;"));
|
|
|
|
|
|
|
|
|
|
grid->addWidget(m_summaryLabel, 0, 0, 1, 2 * LAST - 1);
|
|
|
|
|
|
|
|
|
|
m_listWidgets.resize(LAST);
|
|
|
|
|
m_titleWidgets.resize(LAST);
|
|
|
|
|
m_separators.resize(LAST);
|
|
|
|
|
m_listWidgets[PROJECT] = 0; //project is not a generic list widget
|
|
|
|
|
|
|
|
|
|
m_titleWidgets[PROJECT] = createTitleLabel(tr("Project"));
|
|
|
|
|
grid->addWidget(m_titleWidgets[PROJECT], 1, 0, 1, 2);
|
|
|
|
|
m_projectListWidget = new ProjectListWidget(m_sessionManager, this);
|
|
|
|
|
grid->addWidget(m_projectListWidget, 2, 0);
|
|
|
|
|
m_separators[PROJECT] = new OnePixelGreyLine(this);
|
|
|
|
|
grid->addWidget(m_separators[PROJECT], 2, 1);
|
|
|
|
|
|
|
|
|
|
QStringList titles;
|
|
|
|
|
titles << tr("Target") << tr("Build")
|
|
|
|
|
<< tr("Deploy") << tr("Run");
|
|
|
|
|
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i) {
|
|
|
|
|
m_titleWidgets[i] = createTitleLabel(titles.at(i -1));
|
|
|
|
|
grid->addWidget(m_titleWidgets[i], 1, 2 * i, 1, 2);
|
|
|
|
|
m_listWidgets[i] = new GenericListWidget(this);
|
|
|
|
|
grid->addWidget(m_listWidgets[i], 2, 2 *i);
|
|
|
|
|
m_separators[i] = new OnePixelGreyLine(this);
|
|
|
|
|
grid->addWidget(m_separators[i], 2, 1 + 2 * i);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
changeStartupProject(m_sessionManager->startupProject());
|
|
|
|
|
if (m_sessionManager->startupProject())
|
|
|
|
|
activeTargetChanged(m_sessionManager->startupProject()->activeTarget());
|
|
|
|
|
|
|
|
|
|
connect(m_sessionManager, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(changeStartupProject(ProjectExplorer::Project*)));
|
|
|
|
|
|
|
|
|
|
connect(m_sessionManager, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
|
|
|
connect(m_sessionManager, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
|
|
|
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
|
|
|
|
|
|
|
|
connect(m_listWidgets[TARGET], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
|
|
|
|
this, SLOT(setActiveTarget(ProjectExplorer::ProjectConfiguration *)));
|
|
|
|
|
connect(m_listWidgets[BUILD], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
|
|
|
|
this, SLOT(setActiveBuildConfiguration(ProjectExplorer::ProjectConfiguration *)));
|
|
|
|
|
connect(m_listWidgets[DEPLOY], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
|
|
|
|
this, SLOT(setActiveDeployConfiguration(ProjectExplorer::ProjectConfiguration *)));
|
|
|
|
|
connect(m_listWidgets[RUN], SIGNAL(changeActiveProjectConfiguration(ProjectExplorer::ProjectConfiguration*)),
|
|
|
|
|
this, SLOT(setActiveRunConfiguration(ProjectExplorer::ProjectConfiguration *)));
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::setActiveTarget(ProjectExplorer::ProjectConfiguration *pc)
|
|
|
|
|
{
|
|
|
|
|
m_project->setActiveTarget(static_cast<Target *>(pc));
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::setActiveBuildConfiguration(ProjectExplorer::ProjectConfiguration *pc)
|
|
|
|
|
{
|
|
|
|
|
m_target->setActiveBuildConfiguration(static_cast<BuildConfiguration *>(pc));
|
|
|
|
|
}
|
2010-02-24 19:23:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::setActiveDeployConfiguration(ProjectExplorer::ProjectConfiguration *pc)
|
|
|
|
|
{
|
|
|
|
|
m_target->setActiveDeployConfiguration(static_cast<DeployConfiguration *>(pc));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MiniProjectTargetSelector::setActiveRunConfiguration(ProjectExplorer::ProjectConfiguration *pc)
|
|
|
|
|
{
|
|
|
|
|
m_target->setActiveRunConfiguration(static_cast<RunConfiguration *>(pc));
|
|
|
|
|
}
|
2010-02-24 19:23:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::projectAdded(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
connect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(addedTarget(ProjectExplorer::Target*)));
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(removedTarget(ProjectExplorer::Target*)));
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, project->targets())
|
|
|
|
|
addedTarget(t);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
updateProjectListVisible();
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::projectRemoved(ProjectExplorer::Project *project)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(project, SIGNAL(addedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(addedTarget(ProjectExplorer::Target*)));
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(project, SIGNAL(removedTarget(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(removedTarget(ProjectExplorer::Target*)));
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
foreach (Target *t, project->targets())
|
|
|
|
|
removedTarget(t);
|
2010-02-18 17:36:58 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
updateProjectListVisible();
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::addedTarget(ProjectExplorer::Target *target)
|
2010-03-02 18:38:58 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
connect(target, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
connect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
|
|
|
|
|
connect(target, SIGNAL(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
connect(target, SIGNAL(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
|
|
|
|
|
connect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
|
|
|
|
connect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(removedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
|
|
|
|
|
|
|
|
|
if (target->project() == m_project)
|
|
|
|
|
m_listWidgets[TARGET]->addProjectConfiguration(target);
|
|
|
|
|
|
|
|
|
|
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
|
|
|
|
addedBuildConfiguration(bc);
|
|
|
|
|
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
|
|
|
|
addedDeployConfiguration(dc);
|
|
|
|
|
foreach (RunConfiguration *rc, target->runConfigurations())
|
|
|
|
|
addedRunConfiguration(rc);
|
|
|
|
|
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2010-03-02 18:38:58 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::removedTarget(ProjectExplorer::Target *target)
|
2011-03-30 16:33:31 +02:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
disconnect(target, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
disconnect(target, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
|
|
|
|
|
disconnect(target, SIGNAL(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(addedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
disconnect(target, SIGNAL(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(removedDeployConfiguration(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
|
|
|
|
|
disconnect(target, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
|
|
|
|
disconnect(target, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(removedRunConfiguration(ProjectExplorer::RunConfiguration*)));
|
|
|
|
|
|
|
|
|
|
if (target->project() == m_project)
|
|
|
|
|
m_listWidgets[TARGET]->removeProjectConfiguration(target);
|
|
|
|
|
|
|
|
|
|
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
|
|
|
|
removedBuildConfiguration(bc);
|
|
|
|
|
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
|
|
|
|
removedDeployConfiguration(dc);
|
|
|
|
|
foreach (RunConfiguration *rc, target->runConfigurations())
|
|
|
|
|
removedRunConfiguration(rc);
|
|
|
|
|
|
|
|
|
|
updateTargetListVisible();
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
updateRunListVisible();
|
2011-03-30 16:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (bc->target() == m_target)
|
|
|
|
|
m_listWidgets[BUILD]->addProjectConfiguration(bc);
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc)
|
|
|
|
|
{
|
|
|
|
|
if (bc->target() == m_target)
|
|
|
|
|
m_listWidgets[BUILD]->removeProjectConfiguration(bc);
|
|
|
|
|
updateBuildListVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::addedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc)
|
|
|
|
|
{
|
|
|
|
|
if (dc->target() == m_target)
|
|
|
|
|
m_listWidgets[DEPLOY]->addProjectConfiguration(dc);
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::removedDeployConfiguration(ProjectExplorer::DeployConfiguration *dc)
|
|
|
|
|
{
|
|
|
|
|
if (dc->target() == m_target)
|
|
|
|
|
m_listWidgets[DEPLOY]->removeProjectConfiguration(dc);
|
|
|
|
|
updateDeployListVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::addedRunConfiguration(ProjectExplorer::RunConfiguration *rc)
|
|
|
|
|
{
|
|
|
|
|
if (rc->target() == m_target)
|
|
|
|
|
m_listWidgets[RUN]->addProjectConfiguration(rc);
|
|
|
|
|
updateRunListVisible();
|
|
|
|
|
}
|
2011-03-30 16:33:31 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::removedRunConfiguration(ProjectExplorer::RunConfiguration *rc)
|
|
|
|
|
{
|
|
|
|
|
if (rc->target() == m_target)
|
|
|
|
|
m_listWidgets[RUN]->removeProjectConfiguration(rc);
|
|
|
|
|
updateRunListVisible();
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateProjectListVisible()
|
|
|
|
|
{
|
|
|
|
|
bool visible = m_sessionManager->projects().size() > 1;
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_projectListWidget->setVisible(visible);
|
|
|
|
|
m_projectListWidget->setMaxCount(m_sessionManager->projects().size());
|
|
|
|
|
m_titleWidgets[PROJECT]->setVisible(visible);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
updateSummary();
|
|
|
|
|
updateSeparatorVisible();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateTargetListVisible()
|
|
|
|
|
{
|
|
|
|
|
int maxCount = 0;
|
|
|
|
|
foreach (Project *p, m_sessionManager->projects())
|
|
|
|
|
maxCount = qMax(p->targets().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[TARGET]->setVisible(visible);
|
|
|
|
|
m_listWidgets[TARGET]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[TARGET]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
updateSeparatorVisible();
|
|
|
|
|
}
|
2010-08-30 17:12:40 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateBuildListVisible()
|
|
|
|
|
{
|
|
|
|
|
int maxCount = 0;
|
|
|
|
|
foreach (Project *p, m_sessionManager->projects())
|
|
|
|
|
foreach (Target *t, p->targets())
|
|
|
|
|
maxCount = qMax(t->buildConfigurations().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[BUILD]->setVisible(visible);
|
|
|
|
|
m_listWidgets[BUILD]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[BUILD]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
updateSeparatorVisible();
|
|
|
|
|
}
|
2010-03-08 14:39:38 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateDeployListVisible()
|
|
|
|
|
{
|
|
|
|
|
int maxCount = 0;
|
|
|
|
|
foreach (Project *p, m_sessionManager->projects())
|
|
|
|
|
foreach (Target *t, p->targets())
|
|
|
|
|
maxCount = qMax(t->deployConfigurations().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[DEPLOY]->setVisible(visible);
|
|
|
|
|
m_listWidgets[DEPLOY]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[DEPLOY]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
updateSeparatorVisible();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateRunListVisible()
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
int maxCount = 0;
|
|
|
|
|
foreach (Project *p, m_sessionManager->projects())
|
|
|
|
|
foreach (Target *t, p->targets())
|
|
|
|
|
maxCount = qMax(t->runConfigurations().size(), maxCount);
|
|
|
|
|
|
|
|
|
|
bool visible = maxCount > 1;
|
|
|
|
|
m_listWidgets[RUN]->setVisible(visible);
|
|
|
|
|
m_listWidgets[RUN]->setMaxCount(maxCount);
|
|
|
|
|
m_titleWidgets[RUN]->setVisible(visible);
|
|
|
|
|
updateSummary();
|
|
|
|
|
updateSeparatorVisible();
|
|
|
|
|
}
|
2010-08-30 14:32:23 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::changeStartupProject(ProjectExplorer::Project *project)
|
|
|
|
|
{
|
|
|
|
|
if (m_project) {
|
|
|
|
|
disconnect(m_project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged(ProjectExplorer::Target*)));
|
|
|
|
|
}
|
|
|
|
|
m_project = project;
|
|
|
|
|
if (m_project) {
|
|
|
|
|
connect(m_project, SIGNAL(activeTargetChanged(ProjectExplorer::Target*)),
|
|
|
|
|
this, SLOT(activeTargetChanged(ProjectExplorer::Target*)));
|
|
|
|
|
activeTargetChanged(m_project->activeTarget());
|
|
|
|
|
} else {
|
|
|
|
|
activeTargetChanged(0);
|
|
|
|
|
}
|
2011-03-30 16:33:31 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
if (project) {
|
|
|
|
|
QList<ProjectConfiguration *> list;
|
|
|
|
|
foreach (Target *t, project->targets())
|
|
|
|
|
list.append(t);
|
|
|
|
|
m_listWidgets[TARGET]->setProjectConfigurations(list, project->activeTarget());
|
|
|
|
|
} else {
|
|
|
|
|
m_listWidgets[TARGET]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
2011-03-30 16:33:31 +02:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
|
|
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MiniProjectTargetSelector::activeTargetChanged(ProjectExplorer::Target *target)
|
|
|
|
|
{
|
|
|
|
|
if (m_target) {
|
|
|
|
|
disconnect(m_target, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
disconnect(m_target, SIGNAL(toolTipChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
disconnect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
disconnect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
disconnect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)));
|
2011-03-30 16:33:31 +02:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
m_target = target;
|
|
|
|
|
|
|
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
disconnect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
disconnect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
disconnect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
|
|
|
|
|
if (m_target) {
|
|
|
|
|
QList<ProjectConfiguration *> bl;
|
|
|
|
|
foreach (BuildConfiguration *bc, target->buildConfigurations())
|
|
|
|
|
bl.append(bc);
|
|
|
|
|
m_listWidgets[BUILD]->setProjectConfigurations(bl, target->activeBuildConfiguration());
|
|
|
|
|
|
|
|
|
|
QList<ProjectConfiguration *> dl;
|
|
|
|
|
foreach (DeployConfiguration *dc, target->deployConfigurations())
|
|
|
|
|
dl.append(dc);
|
|
|
|
|
m_listWidgets[DEPLOY]->setProjectConfigurations(dl, target->activeDeployConfiguration());
|
|
|
|
|
|
|
|
|
|
QList<ProjectConfiguration *> rl;
|
|
|
|
|
foreach (RunConfiguration *rc, target->runConfigurations())
|
|
|
|
|
rl.append(rc);
|
|
|
|
|
m_listWidgets[RUN]->setProjectConfigurations(rl, target->activeRunConfiguration());
|
|
|
|
|
|
|
|
|
|
m_buildConfiguration = m_target->activeBuildConfiguration();
|
|
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
connect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_deployConfiguration = m_target->activeDeployConfiguration();
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
connect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_runConfiguration = m_target->activeRunConfiguration();
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
connect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
|
|
|
|
|
connect(m_target, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
connect(m_target, SIGNAL(toolTipChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
connect(m_target, SIGNAL(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)),
|
|
|
|
|
this, SLOT(activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration*)));
|
|
|
|
|
connect(m_target, SIGNAL(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)),
|
|
|
|
|
this, SLOT(activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration*)));
|
|
|
|
|
connect(m_target, SIGNAL(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)),
|
|
|
|
|
this, SLOT(activeRunConfigurationChanged(ProjectExplorer::RunConfiguration*)));
|
|
|
|
|
} else {
|
|
|
|
|
m_listWidgets[BUILD]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
|
|
|
|
m_listWidgets[DEPLOY]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
|
|
|
|
m_listWidgets[RUN]->setProjectConfigurations(QList<ProjectConfiguration *>(), 0);
|
|
|
|
|
m_buildConfiguration = 0;
|
|
|
|
|
m_deployConfiguration = 0;
|
|
|
|
|
m_runConfiguration = 0;
|
|
|
|
|
}
|
|
|
|
|
updateActionAndSummary();
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::activeBuildConfigurationChanged(ProjectExplorer::BuildConfiguration *bc)
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
disconnect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_buildConfiguration = bc;
|
|
|
|
|
if (m_buildConfiguration)
|
|
|
|
|
connect(m_buildConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_listWidgets[BUILD]->setActiveProjectConfiguration(bc);
|
|
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::activeDeployConfigurationChanged(ProjectExplorer::DeployConfiguration *dc)
|
|
|
|
|
{
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
disconnect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_deployConfiguration = dc;
|
|
|
|
|
if (m_deployConfiguration)
|
|
|
|
|
connect(m_deployConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_listWidgets[DEPLOY]->setActiveProjectConfiguration(dc);
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::activeRunConfigurationChanged(ProjectExplorer::RunConfiguration *rc)
|
|
|
|
|
{
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
disconnect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_runConfiguration = rc;
|
|
|
|
|
if (m_runConfiguration)
|
|
|
|
|
connect(m_runConfiguration, SIGNAL(displayNameChanged()),
|
|
|
|
|
this, SLOT(updateActionAndSummary()));
|
|
|
|
|
m_listWidgets[RUN]->setActiveProjectConfiguration(rc);
|
|
|
|
|
updateActionAndSummary();
|
|
|
|
|
}
|
2010-02-22 14:39:59 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateSeparatorVisible()
|
|
|
|
|
{
|
|
|
|
|
QVector<bool> visibility;
|
|
|
|
|
visibility.resize(LAST);
|
|
|
|
|
visibility[PROJECT] = m_projectListWidget->isVisibleTo(this);
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i)
|
|
|
|
|
visibility[i] = m_listWidgets[i]->isVisibleTo(this);
|
|
|
|
|
int lastVisible = visibility.lastIndexOf(true);
|
|
|
|
|
if (lastVisible != -1)
|
|
|
|
|
visibility[lastVisible] = false;
|
|
|
|
|
|
|
|
|
|
for (int i = PROJECT; i < LAST; ++i)
|
|
|
|
|
m_separators[i]->setVisible(visibility[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MiniProjectTargetSelector::setVisible(bool visible)
|
|
|
|
|
{
|
|
|
|
|
if (visible) {
|
2012-01-24 15:36:40 +01:00
|
|
|
QStatusBar *statusBar = Core::ICore::statusBar();
|
2011-09-26 14:48:12 +02:00
|
|
|
QPoint moveTo = statusBar->mapToGlobal(QPoint(0,0));
|
|
|
|
|
moveTo -= QPoint(0, sizeHint().height());
|
|
|
|
|
move(moveTo);
|
|
|
|
|
if (!focusWidget() || !focusWidget()->isVisibleTo(this)) { // Does the second part actually work?
|
|
|
|
|
if (m_projectListWidget->isVisibleTo(this))
|
|
|
|
|
m_projectListWidget->setFocus();
|
|
|
|
|
for (int i = TARGET; i < LAST; ++i) {
|
|
|
|
|
if (m_listWidgets[i]->isVisibleTo(this)) {
|
|
|
|
|
m_listWidgets[i]->setFocus();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-22 14:39:59 +01:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QWidget::setVisible(visible);
|
|
|
|
|
m_projectAction->setChecked(visible);
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::toggleVisible()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
setVisible(!isVisible());
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::nextOrShow()
|
|
|
|
|
{
|
|
|
|
|
if (!isVisible()) {
|
|
|
|
|
show();
|
|
|
|
|
} else {
|
|
|
|
|
m_hideOnRelease = true;
|
|
|
|
|
m_earliestHidetime = QDateTime::currentDateTime().addMSecs(800);
|
|
|
|
|
if (ListWidget *lw = qobject_cast<ListWidget *>(focusWidget())) {
|
|
|
|
|
if (lw->currentRow() < lw->count() -1)
|
|
|
|
|
lw->setCurrentRow(lw->currentRow() + 1);
|
|
|
|
|
else
|
|
|
|
|
lw->setCurrentRow(0);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::keyReleaseEvent(QKeyEvent *ke)
|
|
|
|
|
{
|
|
|
|
|
if (m_hideOnRelease) {
|
|
|
|
|
if (ke->modifiers() == 0
|
|
|
|
|
/*HACK this is to overcome some event inconsistencies between platforms*/
|
|
|
|
|
|| (ke->modifiers() == Qt::AltModifier
|
|
|
|
|
&& (ke->key() == Qt::Key_Alt || ke->key() == -1))) {
|
|
|
|
|
delayedHide();
|
|
|
|
|
m_hideOnRelease = false;
|
|
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
QWidget::keyReleaseEvent(ke);
|
|
|
|
|
}
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
QSize MiniProjectTargetSelector::sizeHint() const
|
|
|
|
|
{
|
2012-01-24 15:36:40 +01:00
|
|
|
static QStatusBar *statusBar = Core::ICore::statusBar();
|
|
|
|
|
static QWidget *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
2011-09-26 14:48:12 +02:00
|
|
|
Q_ASSERT(actionBar);
|
2011-04-12 16:35:50 +02:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
int alignedWithActionHeight
|
|
|
|
|
= actionBar->height() - statusBar->height();
|
|
|
|
|
QSize s = QWidget::sizeHint();
|
|
|
|
|
if (s.height() < alignedWithActionHeight)
|
|
|
|
|
s.setHeight(alignedWithActionHeight);
|
|
|
|
|
return s;
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::delayedHide()
|
2010-04-12 18:18:45 +02:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
QDateTime current = QDateTime::currentDateTime();
|
|
|
|
|
if (m_earliestHidetime > current) {
|
|
|
|
|
// schedule for later
|
|
|
|
|
QTimer::singleShot(current.msecsTo(m_earliestHidetime) + 50, this, SLOT(delayedHide()));
|
|
|
|
|
} else {
|
|
|
|
|
hide();
|
2010-04-12 18:18:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
// This is a workaround for the problem that Windows
|
|
|
|
|
// will let the mouse events through when you click
|
|
|
|
|
// outside a popup to close it. This causes the popup
|
|
|
|
|
// to open on mouse release if you hit the button, which
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// A similar case can be found in QComboBox
|
|
|
|
|
void MiniProjectTargetSelector::mousePressEvent(QMouseEvent *e)
|
2010-01-21 21:12:40 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
setAttribute(Qt::WA_NoMouseReplay);
|
|
|
|
|
QWidget::mousePressEvent(e);
|
|
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateActionAndSummary()
|
|
|
|
|
{
|
|
|
|
|
QString projectName;
|
2010-02-04 11:54:49 +01:00
|
|
|
QString targetName;
|
2010-02-09 19:05:15 +01:00
|
|
|
QString targetToolTipText;
|
2010-02-04 11:54:49 +01:00
|
|
|
QString buildConfig;
|
2011-09-26 14:48:12 +02:00
|
|
|
QString deployConfig;
|
2010-02-04 11:54:49 +01:00
|
|
|
QString runConfig;
|
2010-03-19 18:40:00 +01:00
|
|
|
QIcon targetIcon = style()->standardIcon(QStyle::SP_ComputerIcon);
|
2010-01-21 21:12:40 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
Project *project = ProjectExplorerPlugin::instance()->startupProject();
|
2010-01-21 21:12:40 +01:00
|
|
|
if (project) {
|
|
|
|
|
projectName = project->displayName();
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-04 11:54:49 +01:00
|
|
|
if (Target *target = project->activeTarget()) {
|
2011-09-26 14:48:12 +02:00
|
|
|
targetName = project->activeTarget()->displayName();
|
|
|
|
|
|
|
|
|
|
if (BuildConfiguration *bc = target->activeBuildConfiguration())
|
2010-02-08 15:50:06 +01:00
|
|
|
buildConfig = bc->displayName();
|
2010-02-04 11:54:49 +01:00
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
if (DeployConfiguration *dc = target->activeDeployConfiguration())
|
|
|
|
|
deployConfig = dc->displayName();
|
|
|
|
|
|
|
|
|
|
if (RunConfiguration *rc = target->activeRunConfiguration())
|
2010-02-04 11:54:49 +01:00
|
|
|
runConfig = rc->displayName();
|
2011-09-26 14:48:12 +02:00
|
|
|
|
2010-02-09 19:05:15 +01:00
|
|
|
targetToolTipText = target->toolTip();
|
2010-02-23 16:52:03 +01:00
|
|
|
targetIcon = createCenteredIcon(target->icon(), target->overlayIcon());
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
m_projectAction->setProperty("heading", projectName);
|
|
|
|
|
m_projectAction->setProperty("subtitle", buildConfig);
|
2010-02-09 19:05:15 +01:00
|
|
|
m_projectAction->setIcon(targetIcon);
|
2010-02-04 11:54:49 +01:00
|
|
|
QString targetTip = targetName.isEmpty() ? QLatin1String("")
|
|
|
|
|
: tr("<b>Target:</b> %1<br/>").arg(targetName);
|
|
|
|
|
QString buildTip = buildConfig.isEmpty() ? QLatin1String("")
|
2011-09-26 14:48:12 +02:00
|
|
|
: tr("<b>Build:</b> %1<br/>").arg(buildConfig);
|
|
|
|
|
QString deployTip = deployConfig.isEmpty() ? QLatin1String("")
|
2011-12-08 17:05:27 +01:00
|
|
|
: tr("<b>Deploy:</b> %1<br/>").arg(deployConfig);
|
2010-02-09 19:05:15 +01:00
|
|
|
QString targetToolTip = targetToolTipText.isEmpty() ? QLatin1String("")
|
|
|
|
|
: tr("<br/>%1").arg(targetToolTipText);
|
2011-09-26 14:48:12 +02:00
|
|
|
QString toolTip = tr("<html><nobr><b>Project:</b> %1<br/>%2%3%4<b>Run:</b> %5%6</html>");
|
|
|
|
|
m_projectAction->setToolTip(toolTip.arg(projectName, targetTip, buildTip, deployTip, runConfig, targetToolTip));
|
|
|
|
|
updateSummary();
|
2010-02-08 15:50:06 +01:00
|
|
|
}
|
|
|
|
|
|
2011-09-26 14:48:12 +02:00
|
|
|
void MiniProjectTargetSelector::updateSummary()
|
2010-02-08 15:50:06 +01:00
|
|
|
{
|
2011-09-26 14:48:12 +02:00
|
|
|
QString summary;
|
|
|
|
|
if (Project *startupProject = m_sessionManager->startupProject()) {
|
|
|
|
|
if (!m_projectListWidget->isVisibleTo(this))
|
|
|
|
|
summary.append(tr("Project: <b>%1</b><br/>").arg(startupProject->displayName()));
|
|
|
|
|
if (Target *activeTarget = m_sessionManager->startupProject()->activeTarget()) {
|
|
|
|
|
if (!m_listWidgets[TARGET]->isVisibleTo(this))
|
|
|
|
|
summary.append(tr("Target: <b>%1</b><br/>").arg( activeTarget->displayName()));
|
|
|
|
|
if (!m_listWidgets[BUILD]->isVisibleTo(this) && activeTarget->activeBuildConfiguration())
|
|
|
|
|
summary.append(tr("Build: <b>%1</b><br/>").arg(
|
|
|
|
|
activeTarget->activeBuildConfiguration()->displayName()));
|
|
|
|
|
if (!m_listWidgets[DEPLOY]->isVisibleTo(this) && activeTarget->activeDeployConfiguration())
|
|
|
|
|
summary.append(tr("Deploy: <b>%1</b><br/>").arg(
|
|
|
|
|
activeTarget->activeDeployConfiguration()->displayName()));
|
|
|
|
|
if (!m_listWidgets[RUN]->isVisibleTo(this) && activeTarget->activeRunConfiguration())
|
|
|
|
|
summary.append(tr("Run: <b>%1</b><br/>").arg(
|
|
|
|
|
activeTarget->activeRunConfiguration()->displayName()));
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
|
|
|
|
}
|
2011-09-26 14:48:12 +02:00
|
|
|
m_summaryLabel->setText(summary);
|
|
|
|
|
|
2010-01-21 21:12:40 +01:00
|
|
|
}
|
2010-02-08 15:50:06 +01:00
|
|
|
|
2010-02-24 19:23:40 +01:00
|
|
|
void MiniProjectTargetSelector::paintEvent(QPaintEvent *)
|
|
|
|
|
{
|
|
|
|
|
QPainter painter(this);
|
|
|
|
|
painter.setPen(Utils::StyleHelper::borderColor());
|
|
|
|
|
painter.drawLine(rect().topLeft(), rect().topRight());
|
|
|
|
|
painter.drawLine(rect().topRight(), rect().bottomRight());
|
|
|
|
|
|
|
|
|
|
QRect bottomRect(0, rect().height() - 8, rect().width(), 8);
|
|
|
|
|
static QImage image(QLatin1String(":/projectexplorer/images/targetpanel_bottom.png"));
|
|
|
|
|
Utils::StyleHelper::drawCornerImage(image, &painter, bottomRect, 1, 1, 1, 1);
|
|
|
|
|
}
|