forked from qt-creator/qt-creator
MiniProjectTargetSelector: Add UI for mutable elements in the kits
Not perfect yet, but mostly working. Change-Id: Ie7525671b9b3e522197d0d8cbb6096c52e88dea7 Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
@@ -28,6 +28,9 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#include "miniprojecttargetselector.h"
|
#include "miniprojecttargetselector.h"
|
||||||
|
#include "kit.h"
|
||||||
|
#include "kitconfigwidget.h"
|
||||||
|
#include "kitmanager.h"
|
||||||
#include "target.h"
|
#include "target.h"
|
||||||
|
|
||||||
#include <utils/styledbar.h>
|
#include <utils/styledbar.h>
|
||||||
@@ -520,6 +523,81 @@ QListWidgetItem *GenericListWidget::itemForProjectConfiguration(ProjectConfigura
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/////////
|
||||||
|
// KitAreaWidget
|
||||||
|
/////////
|
||||||
|
|
||||||
|
KitAreaWidget::KitAreaWidget(QWidget *parent) : QWidget(parent),
|
||||||
|
m_layout(new QGridLayout(this)), m_kit(0)
|
||||||
|
{
|
||||||
|
m_layout->setMargin(3);
|
||||||
|
setKit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitAreaWidget::setKit(Kit *k)
|
||||||
|
{
|
||||||
|
foreach (KitConfigWidget *w, m_widgets)
|
||||||
|
w->deleteLater();
|
||||||
|
m_widgets.clear();
|
||||||
|
foreach (QLabel *l, m_labels)
|
||||||
|
l->deleteLater();
|
||||||
|
m_labels.clear();
|
||||||
|
|
||||||
|
if (m_kit) {
|
||||||
|
disconnect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
||||||
|
this, SLOT(updateKit(ProjectExplorer::Kit*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
||||||
|
if (k && k->isMutable(ki->id())) {
|
||||||
|
KitConfigWidget *widget = ki->createConfigWidget(k);
|
||||||
|
m_widgets << widget;
|
||||||
|
QLabel *label = new QLabel(widget->displayName());
|
||||||
|
m_labels << label;
|
||||||
|
|
||||||
|
m_layout->addWidget(label, row, 0);
|
||||||
|
m_layout->addWidget(widget->mainWidget(), row, 1);
|
||||||
|
++row;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
m_kit = k;
|
||||||
|
|
||||||
|
if (m_kit) {
|
||||||
|
connect(KitManager::instance(), SIGNAL(kitUpdated(ProjectExplorer::Kit*)),
|
||||||
|
this, SLOT(updateKit(ProjectExplorer::Kit*)));
|
||||||
|
}
|
||||||
|
|
||||||
|
setHidden(m_widgets.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
void KitAreaWidget::updateKit(Kit *k)
|
||||||
|
{
|
||||||
|
if (!m_kit || m_kit != k)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Check whether our widgets changed
|
||||||
|
bool mustRegenerate = false;
|
||||||
|
QList<Core::Id> knownIdList;
|
||||||
|
foreach (KitConfigWidget *w, m_widgets)
|
||||||
|
knownIdList << w->kitInformationId();
|
||||||
|
|
||||||
|
foreach (KitInformation *ki, KitManager::kitInformation()) {
|
||||||
|
Core::Id currentId = ki->id();
|
||||||
|
if (m_kit->isMutable(currentId) && !knownIdList.removeOne(currentId)) {
|
||||||
|
mustRegenerate = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mustRegenerate || !knownIdList.isEmpty())
|
||||||
|
setKit(m_kit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/////////
|
||||||
|
// MiniProjectTargetSelector
|
||||||
|
/////////
|
||||||
|
|
||||||
QWidget *MiniProjectTargetSelector::createTitleLabel(const QString &text)
|
QWidget *MiniProjectTargetSelector::createTitleLabel(const QString &text)
|
||||||
{
|
{
|
||||||
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
Utils::StyledBar *bar = new Utils::StyledBar(this);
|
||||||
@@ -559,6 +637,8 @@ MiniProjectTargetSelector::MiniProjectTargetSelector(QAction *targetSelectorActi
|
|||||||
targetSelectorAction->setIcon(style()->standardIcon(QStyle::SP_ComputerIcon));
|
targetSelectorAction->setIcon(style()->standardIcon(QStyle::SP_ComputerIcon));
|
||||||
targetSelectorAction->setProperty("titledAction", true);
|
targetSelectorAction->setProperty("titledAction", true);
|
||||||
|
|
||||||
|
m_kitAreaWidget = new KitAreaWidget(this);
|
||||||
|
|
||||||
m_summaryLabel = new QLabel(this);
|
m_summaryLabel = new QLabel(this);
|
||||||
m_summaryLabel->setMargin(3);
|
m_summaryLabel->setMargin(3);
|
||||||
m_summaryLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
m_summaryLabel->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
||||||
@@ -747,8 +827,15 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
static QWidget *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
static QWidget *actionBar = Core::ICore::mainWindow()->findChild<QWidget*>(QLatin1String("actionbar"));
|
||||||
Q_ASSERT(actionBar);
|
Q_ASSERT(actionBar);
|
||||||
|
|
||||||
|
m_kitAreaWidget->move(0, 0);
|
||||||
|
|
||||||
|
int oldSummaryLabelY = m_summaryLabel->y();
|
||||||
|
|
||||||
|
int kitAreaHeight = m_kitAreaWidget->isVisible() ? m_kitAreaWidget->sizeHint().height() : 0;
|
||||||
|
|
||||||
// 1. Calculate the summary label height
|
// 1. Calculate the summary label height
|
||||||
int summaryLabelY = 1;
|
int summaryLabelY = 1 + kitAreaHeight;
|
||||||
|
|
||||||
int summaryLabelHeight = 0;
|
int summaryLabelHeight = 0;
|
||||||
int oldSummaryLabelHeight = m_summaryLabel->height();
|
int oldSummaryLabelHeight = m_summaryLabel->height();
|
||||||
bool onlySummary = false;
|
bool onlySummary = false;
|
||||||
@@ -785,7 +872,7 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
if (actionBar->isVisible())
|
if (actionBar->isVisible())
|
||||||
alignedWithActionHeight = actionBar->height() - statusBar->height();
|
alignedWithActionHeight = actionBar->height() - statusBar->height();
|
||||||
int bottomMargin = 9;
|
int bottomMargin = 9;
|
||||||
int totalHeight = 0;
|
int heightWithoutKitArea = 0;
|
||||||
|
|
||||||
if (!onlySummary) {
|
if (!onlySummary) {
|
||||||
// list widget heigth
|
// list widget heigth
|
||||||
@@ -795,22 +882,24 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
|
|
||||||
int titleWidgetsHeight = m_titleWidgets.first()->height();
|
int titleWidgetsHeight = m_titleWidgets.first()->height();
|
||||||
if (keepSize) {
|
if (keepSize) {
|
||||||
totalHeight = height();
|
heightWithoutKitArea = height() - oldSummaryLabelY + 1;
|
||||||
} else {
|
} else {
|
||||||
// Clamp the size of the listwidgets to be
|
// Clamp the size of the listwidgets to be
|
||||||
// at least as high as the the sidebar button
|
// at least as high as the the sidebar button
|
||||||
// and at most twice as high
|
// and at most twice as high
|
||||||
totalHeight = summaryLabelHeight + qBound(alignedWithActionHeight,
|
heightWithoutKitArea = summaryLabelHeight
|
||||||
|
+ qBound(alignedWithActionHeight,
|
||||||
maxItemCount * 30 + bottomMargin + titleWidgetsHeight,
|
maxItemCount * 30 + bottomMargin + titleWidgetsHeight,
|
||||||
alignedWithActionHeight * 2);
|
alignedWithActionHeight * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
int titleY = summaryLabelY + summaryLabelHeight;
|
int titleY = summaryLabelY + summaryLabelHeight;
|
||||||
int listY = titleY + titleWidgetsHeight;
|
int listY = titleY + titleWidgetsHeight;
|
||||||
int listHeight = totalHeight - bottomMargin - listY + 1;
|
int listHeight = heightWithoutKitArea + kitAreaHeight - bottomMargin - listY + 1;
|
||||||
|
|
||||||
// list widget widths
|
// list widget widths
|
||||||
int minWidth = qMax(m_summaryLabel->sizeHint().width(), 250);
|
int minWidth = qMax(m_summaryLabel->sizeHint().width(), 250);
|
||||||
|
minWidth = qMax(minWidth, m_kitAreaWidget->sizeHint().width());
|
||||||
if (keepSize) {
|
if (keepSize) {
|
||||||
// Do not make the widget smaller then it was before
|
// Do not make the widget smaller then it was before
|
||||||
int oldTotalListWidgetWidth = m_projectListWidget->isVisibleTo(this) ?
|
int oldTotalListWidgetWidth = m_projectListWidget->isVisibleTo(this) ?
|
||||||
@@ -837,19 +926,21 @@ void MiniProjectTargetSelector::doLayout(bool keepSize)
|
|||||||
}
|
}
|
||||||
|
|
||||||
m_summaryLabel->resize(x - 1, summaryLabelHeight);
|
m_summaryLabel->resize(x - 1, summaryLabelHeight);
|
||||||
setFixedSize(x, totalHeight);
|
m_kitAreaWidget->resize(x - 1, kitAreaHeight);
|
||||||
|
setFixedSize(x, heightWithoutKitArea + kitAreaHeight);
|
||||||
} else {
|
} else {
|
||||||
if (keepSize)
|
if (keepSize)
|
||||||
totalHeight = height();
|
heightWithoutKitArea = height() - oldSummaryLabelY + 1;
|
||||||
else
|
else
|
||||||
totalHeight = qMax(summaryLabelHeight + bottomMargin, alignedWithActionHeight);
|
heightWithoutKitArea = qMax(summaryLabelHeight + bottomMargin, alignedWithActionHeight);
|
||||||
m_summaryLabel->resize(m_summaryLabel->sizeHint().width(), totalHeight - bottomMargin);
|
m_summaryLabel->resize(m_summaryLabel->sizeHint().width(), heightWithoutKitArea - bottomMargin);
|
||||||
setFixedSize(m_summaryLabel->width() + 1, totalHeight); //1 extra pixel for the border
|
m_kitAreaWidget->resize(m_kitAreaWidget->sizeHint());
|
||||||
|
setFixedSize(m_summaryLabel->width() + 1, heightWithoutKitArea + kitAreaHeight); //1 extra pixel for the border
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isVisibleTo(parentWidget())) {
|
if (isVisibleTo(parentWidget())) {
|
||||||
QPoint moveTo = statusBar->mapToGlobal(QPoint(0,0));
|
QPoint moveTo = statusBar->mapToGlobal(QPoint(0,0));
|
||||||
moveTo -= QPoint(0, totalHeight);
|
moveTo -= QPoint(0, height());
|
||||||
move(moveTo);
|
move(moveTo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1177,6 +1268,8 @@ void MiniProjectTargetSelector::activeTargetChanged(ProjectExplorer::Target *tar
|
|||||||
|
|
||||||
m_target = target;
|
m_target = target;
|
||||||
|
|
||||||
|
m_kitAreaWidget->setKit(m_target ? m_target->kit() : 0);
|
||||||
|
|
||||||
m_listWidgets[TARGET]->setActiveProjectConfiguration(m_target);
|
m_listWidgets[TARGET]->setActiveProjectConfiguration(m_target);
|
||||||
|
|
||||||
if (m_buildConfiguration)
|
if (m_buildConfiguration)
|
||||||
|
|||||||
@@ -35,12 +35,14 @@
|
|||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QComboBox;
|
class QComboBox;
|
||||||
|
class QGridLayout;
|
||||||
class QLabel;
|
class QLabel;
|
||||||
class QStackedWidget;
|
class QStackedWidget;
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
class Kit;
|
class Kit;
|
||||||
|
class KitConfigWidget;
|
||||||
class Project;
|
class Project;
|
||||||
class Target;
|
class Target;
|
||||||
class BuildConfiguration;
|
class BuildConfiguration;
|
||||||
@@ -87,6 +89,25 @@ private:
|
|||||||
bool m_ignoreIndexChange;
|
bool m_ignoreIndexChange;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class KitAreaWidget : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
explicit KitAreaWidget(QWidget *parent = 0);
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void setKit(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void updateKit(ProjectExplorer::Kit *k);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QGridLayout *m_layout;
|
||||||
|
Kit *m_kit;
|
||||||
|
QList<KitConfigWidget *> m_widgets;
|
||||||
|
QList<QLabel *> m_labels;
|
||||||
|
};
|
||||||
|
|
||||||
class GenericListWidget : public ListWidget
|
class GenericListWidget : public ListWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -176,6 +197,7 @@ private:
|
|||||||
|
|
||||||
enum TYPES { PROJECT = 0, TARGET = 1, BUILD = 2, DEPLOY = 3, RUN = 4, LAST = 5 };
|
enum TYPES { PROJECT = 0, TARGET = 1, BUILD = 2, DEPLOY = 3, RUN = 4, LAST = 5 };
|
||||||
ProjectListWidget *m_projectListWidget;
|
ProjectListWidget *m_projectListWidget;
|
||||||
|
KitAreaWidget *m_kitAreaWidget;
|
||||||
QVector<GenericListWidget *> m_listWidgets;
|
QVector<GenericListWidget *> m_listWidgets;
|
||||||
QVector<QWidget *> m_titleWidgets;
|
QVector<QWidget *> m_titleWidgets;
|
||||||
QLabel *m_summaryLabel;
|
QLabel *m_summaryLabel;
|
||||||
|
|||||||
Reference in New Issue
Block a user