forked from qt-creator/qt-creator
New project mode layout, first part.
This commit is contained in:
@@ -54,6 +54,11 @@ using namespace ProjectExplorer::Internal;
|
|||||||
// BuildSettingsPanelFactory
|
// BuildSettingsPanelFactory
|
||||||
///
|
///
|
||||||
|
|
||||||
|
QString BuildSettingsPanelFactory::displayName() const
|
||||||
|
{
|
||||||
|
return QApplication::tr("Build Settings");
|
||||||
|
}
|
||||||
|
|
||||||
bool BuildSettingsPanelFactory::supports(Project *project)
|
bool BuildSettingsPanelFactory::supports(Project *project)
|
||||||
{
|
{
|
||||||
return project->hasBuildSettings();
|
return project->hasBuildSettings();
|
||||||
@@ -94,6 +99,11 @@ QIcon BuildSettingsPanel::icon() const
|
|||||||
return m_icon;
|
return m_icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BuildSettingsPanel::widgetWasAddedToLayout()
|
||||||
|
{
|
||||||
|
m_widget->setupUi();
|
||||||
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
// BuildSettingsWidget
|
// BuildSettingsWidget
|
||||||
///
|
///
|
||||||
@@ -108,12 +118,14 @@ BuildSettingsWidget::BuildSettingsWidget(Project *project) :
|
|||||||
m_buildConfiguration(0),
|
m_buildConfiguration(0),
|
||||||
m_leftMargin(0)
|
m_leftMargin(0)
|
||||||
{
|
{
|
||||||
// Provide some time for our contentsmargins to get updated:
|
// setup is done after panel has been added to layout.
|
||||||
QTimer::singleShot(0, this, SLOT(setupUi()));
|
// setupUi will be called by the IPropertiesPanel implementation then.
|
||||||
|
// this is necessary to handle the margin by hand for the up/down/delete hover
|
||||||
}
|
}
|
||||||
|
|
||||||
void BuildSettingsWidget::setupUi()
|
void BuildSettingsWidget::setupUi()
|
||||||
{
|
{
|
||||||
|
// called by IPropertiesPanel implementation once the panel has been added
|
||||||
QMargins margins(contentsMargins());
|
QMargins margins(contentsMargins());
|
||||||
m_leftMargin = margins.left();
|
m_leftMargin = margins.left();
|
||||||
margins.setLeft(0);
|
margins.setLeft(0);
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace Internal {
|
|||||||
class BuildSettingsPanelFactory : public IPanelFactory
|
class BuildSettingsPanelFactory : public IPanelFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
QString displayName() const;
|
||||||
bool supports(Project *project);
|
bool supports(Project *project);
|
||||||
IPropertiesPanel *createPanel(Project *project);
|
IPropertiesPanel *createPanel(Project *project);
|
||||||
};
|
};
|
||||||
@@ -65,6 +66,7 @@ public:
|
|||||||
QString displayName() const;
|
QString displayName() const;
|
||||||
QWidget *widget() const;
|
QWidget *widget() const;
|
||||||
QIcon icon() const;
|
QIcon icon() const;
|
||||||
|
void widgetWasAddedToLayout();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BuildSettingsWidget *m_widget;
|
BuildSettingsWidget *m_widget;
|
||||||
@@ -84,6 +86,8 @@ public:
|
|||||||
void addSubWidget(const QString &name, QWidget *widget);
|
void addSubWidget(const QString &name, QWidget *widget);
|
||||||
QList<QWidget *> subWidgets() const;
|
QList<QWidget *> subWidgets() const;
|
||||||
|
|
||||||
|
void setupUi();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void updateBuildSettings();
|
void updateBuildSettings();
|
||||||
void currentIndexChanged(int index);
|
void currentIndexChanged(int index);
|
||||||
@@ -96,8 +100,6 @@ private slots:
|
|||||||
void checkMakeActiveLabel();
|
void checkMakeActiveLabel();
|
||||||
void makeActive();
|
void makeActive();
|
||||||
|
|
||||||
void setupUi();
|
|
||||||
|
|
||||||
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
||||||
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
||||||
void buildConfigurationDisplayNameChanged();
|
void buildConfigurationDisplayNameChanged();
|
||||||
|
|||||||
@@ -319,6 +319,11 @@ DependenciesPanelFactory::DependenciesPanelFactory(SessionManager *session)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString DependenciesPanelFactory::displayName() const
|
||||||
|
{
|
||||||
|
return QApplication::tr("Dependencies");
|
||||||
|
}
|
||||||
|
|
||||||
bool DependenciesPanelFactory::supports(Project * /* project */)
|
bool DependenciesPanelFactory::supports(Project * /* project */)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ class DependenciesPanelFactory : public IPanelFactory
|
|||||||
public:
|
public:
|
||||||
DependenciesPanelFactory(SessionManager *session);
|
DependenciesPanelFactory(SessionManager *session);
|
||||||
|
|
||||||
|
QString displayName() const;
|
||||||
bool supports(Project *project);
|
bool supports(Project *project);
|
||||||
IPropertiesPanel *createPanel(Project *project);
|
IPropertiesPanel *createPanel(Project *project);
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,9 @@
|
|||||||
#include <QtGui/QPainter>
|
#include <QtGui/QPainter>
|
||||||
#include <QtGui/QFont>
|
#include <QtGui/QFont>
|
||||||
#include <QtGui/QMouseEvent>
|
#include <QtGui/QMouseEvent>
|
||||||
|
#include <QtGui/QMenu>
|
||||||
|
|
||||||
|
#include <QtDebug>
|
||||||
|
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
@@ -15,6 +18,7 @@ static const int MARGIN = 12;
|
|||||||
static const int OTHER_HEIGHT = 38;
|
static const int OTHER_HEIGHT = 38;
|
||||||
static const int SELECTION_IMAGE_WIDTH = 10;
|
static const int SELECTION_IMAGE_WIDTH = 10;
|
||||||
static const int SELECTION_IMAGE_HEIGHT = 20;
|
static const int SELECTION_IMAGE_HEIGHT = 20;
|
||||||
|
static const int OVERFLOW_DROPDOWN_WIDTH = Utils::StyleHelper::navigationWidgetHeight();
|
||||||
|
|
||||||
static void drawFirstLevelSeparator(QPainter *painter, QPoint top, QPoint bottom)
|
static void drawFirstLevelSeparator(QPainter *painter, QPoint top, QPoint bottom)
|
||||||
{
|
{
|
||||||
@@ -53,7 +57,8 @@ static void drawSecondLevelSeparator(QPainter *painter, QPoint top, QPoint botto
|
|||||||
DoubleTabWidget::DoubleTabWidget(QWidget *parent) :
|
DoubleTabWidget::DoubleTabWidget(QWidget *parent) :
|
||||||
QWidget(parent),
|
QWidget(parent),
|
||||||
ui(new Ui::DoubleTabWidget),
|
ui(new Ui::DoubleTabWidget),
|
||||||
m_currentIndex(-1)
|
m_currentIndex(-1),
|
||||||
|
m_lastVisibleIndex(-1)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
}
|
}
|
||||||
@@ -88,6 +93,44 @@ void DoubleTabWidget::addTab(const QString &name, const QStringList &subTabs)
|
|||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DoubleTabWidget::insertTab(int index, const QString &name, const QStringList &subTabs)
|
||||||
|
{
|
||||||
|
Tab tab;
|
||||||
|
tab.name = name;
|
||||||
|
tab.subTabs = subTabs;
|
||||||
|
tab.currentSubTab = tab.subTabs.isEmpty() ? -1 : 0;
|
||||||
|
m_tabs.insert(index, tab);
|
||||||
|
if (m_currentIndex == -1) {
|
||||||
|
m_currentIndex = m_tabs.size()-1;
|
||||||
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
|
} else if (m_currentIndex >= index) {
|
||||||
|
++m_currentIndex;
|
||||||
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
void DoubleTabWidget::removeTab(int index)
|
||||||
|
{
|
||||||
|
m_tabs.removeAt(index);
|
||||||
|
if (index <= m_currentIndex) {
|
||||||
|
--m_currentIndex;
|
||||||
|
if (m_currentIndex < 0 && m_tabs.size() > 0)
|
||||||
|
m_currentIndex = 0;
|
||||||
|
if (m_currentIndex < 0) {
|
||||||
|
emit currentIndexChanged(-1, -1);
|
||||||
|
} else {
|
||||||
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
|
||||||
|
int DoubleTabWidget::tabCount() const
|
||||||
|
{
|
||||||
|
return m_tabs.size();
|
||||||
|
}
|
||||||
|
|
||||||
void DoubleTabWidget::mousePressEvent(QMouseEvent *event)
|
void DoubleTabWidget::mousePressEvent(QMouseEvent *event)
|
||||||
{
|
{
|
||||||
if (event->y() < Utils::StyleHelper::navigationWidgetHeight()) {
|
if (event->y() < Utils::StyleHelper::navigationWidgetHeight()) {
|
||||||
@@ -98,21 +141,39 @@ void DoubleTabWidget::mousePressEvent(QMouseEvent *event)
|
|||||||
if (eventX <= x)
|
if (eventX <= x)
|
||||||
return;
|
return;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < m_tabs.size(); ++i) {
|
for (i = 0; i <= m_lastVisibleIndex; ++i) {
|
||||||
int otherX = x + 2 * MARGIN + fm.width(m_tabs.at(i).name);
|
int otherX = x + 2 * MARGIN + fm.width(m_tabs.at(
|
||||||
|
m_currentTabIndices.at(i)).name);
|
||||||
if (eventX > x && eventX < otherX) {
|
if (eventX > x && eventX < otherX) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
x = otherX;
|
x = otherX;
|
||||||
}
|
}
|
||||||
if (i < m_tabs.size()) {
|
if (i <= m_lastVisibleIndex) {
|
||||||
if (m_currentIndex != i) {
|
if (m_currentIndex != m_currentTabIndices.at(i)) {
|
||||||
m_currentIndex = i;
|
m_currentIndex = m_currentTabIndices.at(i);
|
||||||
update();
|
update();
|
||||||
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
}
|
}
|
||||||
event->accept();
|
event->accept();
|
||||||
return;
|
return;
|
||||||
|
} else if (m_lastVisibleIndex < m_tabs.size() - 1) {
|
||||||
|
// handle overflow menu
|
||||||
|
if (eventX > x && eventX < x + OVERFLOW_DROPDOWN_WIDTH) {
|
||||||
|
QMenu overflowMenu;
|
||||||
|
QList<QAction *> actions;
|
||||||
|
for (int i = m_lastVisibleIndex + 1; i < m_tabs.size(); ++i) {
|
||||||
|
actions << overflowMenu.addAction(m_tabs.at(m_currentTabIndices.at(i)).name);
|
||||||
|
}
|
||||||
|
if (QAction *action = overflowMenu.exec(mapToGlobal(QPoint(x+1, 1)))) {
|
||||||
|
int index = m_currentTabIndices.at(actions.indexOf(action) + m_lastVisibleIndex + 1);
|
||||||
|
if (m_currentIndex != index) {
|
||||||
|
m_currentIndex = index;
|
||||||
|
update();
|
||||||
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if (event->y() < Utils::StyleHelper::navigationWidgetHeight() + OTHER_HEIGHT) {
|
} else if (event->y() < Utils::StyleHelper::navigationWidgetHeight() + OTHER_HEIGHT) {
|
||||||
int diff = (OTHER_HEIGHT - SELECTION_IMAGE_HEIGHT) / 2;
|
int diff = (OTHER_HEIGHT - SELECTION_IMAGE_HEIGHT) / 2;
|
||||||
@@ -146,7 +207,6 @@ void DoubleTabWidget::mousePressEvent(QMouseEvent *event)
|
|||||||
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
emit currentIndexChanged(m_currentIndex, m_tabs.at(m_currentIndex).currentSubTab);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
event->ignore();
|
event->ignore();
|
||||||
}
|
}
|
||||||
@@ -193,18 +253,85 @@ void DoubleTabWidget::paintEvent(QPaintEvent *event)
|
|||||||
|
|
||||||
// top level tabs
|
// top level tabs
|
||||||
int x = 2 * MARGIN + qMax(fm.width(m_title), MIN_LEFT_MARGIN);
|
int x = 2 * MARGIN + qMax(fm.width(m_title), MIN_LEFT_MARGIN);
|
||||||
|
|
||||||
|
// calculate sizes
|
||||||
|
QList<int> nameWidth;
|
||||||
|
int width = x;
|
||||||
|
int indexSmallerThanOverflow = -1;
|
||||||
|
int indexSmallerThanWidth = -1;
|
||||||
for (int i = 0; i < m_tabs.size(); ++i) {
|
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||||
if (i == m_currentIndex) {
|
const Tab &tab = m_tabs.at(i);
|
||||||
|
int w = fm.width(tab.name);
|
||||||
|
nameWidth << w;
|
||||||
|
width += 2 * MARGIN + w;
|
||||||
|
if (width < r.width())
|
||||||
|
indexSmallerThanWidth = i;
|
||||||
|
if (width < r.width() - OVERFLOW_DROPDOWN_WIDTH)
|
||||||
|
indexSmallerThanOverflow = i;
|
||||||
|
}
|
||||||
|
m_lastVisibleIndex = -1;
|
||||||
|
m_currentTabIndices.resize(m_tabs.size());
|
||||||
|
if (indexSmallerThanWidth == m_tabs.size() - 1) {
|
||||||
|
// => everything fits
|
||||||
|
for (int i = 0; i < m_tabs.size(); ++i)
|
||||||
|
m_currentTabIndices[i] = i;
|
||||||
|
m_lastVisibleIndex = m_tabs.size()-1;
|
||||||
|
} else {
|
||||||
|
// => we need the overflow thingy
|
||||||
|
if (m_currentIndex <= indexSmallerThanOverflow) {
|
||||||
|
// easy going, simply draw everything that fits
|
||||||
|
for (int i = 0; i < m_tabs.size(); ++i)
|
||||||
|
m_currentTabIndices[i] = i;
|
||||||
|
m_lastVisibleIndex = indexSmallerThanOverflow;
|
||||||
|
} else {
|
||||||
|
// now we need to put the current tab into
|
||||||
|
// visible range. for that we need to find the place
|
||||||
|
// to put it, so it fits
|
||||||
|
width = x;
|
||||||
|
int index = 0;
|
||||||
|
bool handledCurrentIndex = false;
|
||||||
|
for (int i = 0; i < m_tabs.size(); ++i) {
|
||||||
|
if (index != m_currentIndex) {
|
||||||
|
if (!handledCurrentIndex) {
|
||||||
|
// check if enough room for current tab after this one
|
||||||
|
if (width + 2 * MARGIN + nameWidth.at(index)
|
||||||
|
+ 2 * MARGIN + nameWidth.at(m_currentIndex)
|
||||||
|
< r.width() - OVERFLOW_DROPDOWN_WIDTH) {
|
||||||
|
m_currentTabIndices[i] = index;
|
||||||
|
++index;
|
||||||
|
width += 2 * MARGIN + nameWidth.at(index);
|
||||||
|
} else {
|
||||||
|
m_currentTabIndices[i] = m_currentIndex;
|
||||||
|
handledCurrentIndex = true;
|
||||||
|
m_lastVisibleIndex = i;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
m_currentTabIndices[i] = index;
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
++index;
|
||||||
|
--i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// actually draw top level tabs
|
||||||
|
for (int i = 0; i <= m_lastVisibleIndex; ++i) {
|
||||||
|
int actualIndex = m_currentTabIndices.at(i);
|
||||||
|
Tab tab = m_tabs.at(actualIndex);
|
||||||
|
if (actualIndex == m_currentIndex) {
|
||||||
painter.setPen(Utils::StyleHelper::borderColor());
|
painter.setPen(Utils::StyleHelper::borderColor());
|
||||||
painter.drawLine(x - 1, 0, x - 1, r.height() - 1);
|
painter.drawLine(x - 1, 0, x - 1, r.height() - 1);
|
||||||
painter.fillRect(QRect(x, 0,
|
painter.fillRect(QRect(x, 0,
|
||||||
2 * MARGIN + fm.width(m_tabs.at(i).name),
|
2 * MARGIN + fm.width(tab.name),
|
||||||
r.height() + 1),
|
r.height() + 1),
|
||||||
grad);
|
grad);
|
||||||
x += MARGIN;
|
x += MARGIN;
|
||||||
painter.setPen(Qt::black);
|
painter.setPen(Qt::black);
|
||||||
painter.drawText(x, baseline, m_tabs.at(i).name);
|
painter.drawText(x, baseline, tab.name);
|
||||||
x += fm.width(m_tabs.at(i).name);
|
x += nameWidth.at(actualIndex);
|
||||||
x += MARGIN;
|
x += MARGIN;
|
||||||
painter.setPen(Utils::StyleHelper::borderColor());
|
painter.setPen(Utils::StyleHelper::borderColor());
|
||||||
painter.drawLine(x, 0, x, r.height() - 1);
|
painter.drawLine(x, 0, x, r.height() - 1);
|
||||||
@@ -213,19 +340,27 @@ void DoubleTabWidget::paintEvent(QPaintEvent *event)
|
|||||||
drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1));
|
drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1));
|
||||||
x += MARGIN;
|
x += MARGIN;
|
||||||
painter.setPen(Utils::StyleHelper::panelTextColor());
|
painter.setPen(Utils::StyleHelper::panelTextColor());
|
||||||
painter.drawText(x + 1, baseline, m_tabs.at(i).name);
|
painter.drawText(x + 1, baseline, tab.name);
|
||||||
x += fm.width(m_tabs.at(i).name);
|
x += nameWidth.at(actualIndex);
|
||||||
x += MARGIN;
|
x += MARGIN;
|
||||||
drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1));
|
drawFirstLevelSeparator(&painter, QPoint(x, 0), QPoint(x, r.height()-1));
|
||||||
}
|
}
|
||||||
if (x >= r.width()) // TODO: do something useful...
|
}
|
||||||
break;
|
|
||||||
|
// draw overflow button
|
||||||
|
if (m_lastVisibleIndex < m_tabs.size() - 1) {
|
||||||
|
QStyleOption opt;
|
||||||
|
opt.rect = QRect(x, 0, OVERFLOW_DROPDOWN_WIDTH - 1, r.height() - 1);
|
||||||
|
style()->drawPrimitive(QStyle::PE_IndicatorArrowDown,
|
||||||
|
&opt, &painter, this);
|
||||||
|
drawFirstLevelSeparator(&painter, QPoint(x + OVERFLOW_DROPDOWN_WIDTH, 0),
|
||||||
|
QPoint(x + OVERFLOW_DROPDOWN_WIDTH, r.height()-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
// second level tabs
|
// second level tabs
|
||||||
static QPixmap left(":/projectexplorer/leftselection.png");
|
static QPixmap left(":/projectexplorer/images/leftselection.png");
|
||||||
static QPixmap mid(":/projectexplorer/midselection.png");
|
static QPixmap mid(":/projectexplorer/images/midselection.png");
|
||||||
static QPixmap right(":/projectexplorer/rightselection.png");
|
static QPixmap right(":/projectexplorer/images/rightselection.png");
|
||||||
if (m_currentIndex != -1) {
|
if (m_currentIndex != -1) {
|
||||||
int y = r.height() + (OTHER_HEIGHT - left.height()) / 2.;
|
int y = r.height() + (OTHER_HEIGHT - left.height()) / 2.;
|
||||||
int imageHeight = left.height();
|
int imageHeight = left.height();
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef DOUBLETABWIDGET_H
|
#ifndef DOUBLETABWIDGET_H
|
||||||
#define DOUBLETABWIDGET_H
|
#define DOUBLETABWIDGET_H
|
||||||
|
|
||||||
|
#include <QtCore/QVector>
|
||||||
#include <QtGui/QWidget>
|
#include <QtGui/QWidget>
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
namespace ProjectExplorer {
|
||||||
@@ -20,6 +21,9 @@ public:
|
|||||||
QString title() const { return m_title; }
|
QString title() const { return m_title; }
|
||||||
|
|
||||||
void addTab(const QString &name, const QStringList &subTabs);
|
void addTab(const QString &name, const QStringList &subTabs);
|
||||||
|
void insertTab(int index, const QString &name, const QStringList &subTabs);
|
||||||
|
void removeTab(int index);
|
||||||
|
int tabCount() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void currentIndexChanged(int index, int subIndex);
|
void currentIndexChanged(int index, int subIndex);
|
||||||
@@ -42,6 +46,8 @@ private:
|
|||||||
QString m_title;
|
QString m_title;
|
||||||
QList<Tab> m_tabs;
|
QList<Tab> m_tabs;
|
||||||
int m_currentIndex;
|
int m_currentIndex;
|
||||||
|
QVector<int> m_currentTabIndices;
|
||||||
|
int m_lastVisibleIndex;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Internal
|
} // namespace Internal
|
||||||
|
|||||||
@@ -38,6 +38,11 @@
|
|||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace ProjectExplorer::Internal;
|
using namespace ProjectExplorer::Internal;
|
||||||
|
|
||||||
|
QString EditorSettingsPanelFactory::displayName() const
|
||||||
|
{
|
||||||
|
return QApplication::tr("Editor Settings");
|
||||||
|
}
|
||||||
|
|
||||||
bool EditorSettingsPanelFactory::supports(Project * /*project*/)
|
bool EditorSettingsPanelFactory::supports(Project * /*project*/)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ namespace Internal {
|
|||||||
class EditorSettingsPanelFactory : public IPanelFactory
|
class EditorSettingsPanelFactory : public IPanelFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
QString displayName() const;
|
||||||
bool supports(Project *project);
|
bool supports(Project *project);
|
||||||
IPropertiesPanel *createPanel(Project *project);
|
IPropertiesPanel *createPanel(Project *project);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,12 +48,14 @@ public:
|
|||||||
virtual QString displayName() const = 0;
|
virtual QString displayName() const = 0;
|
||||||
virtual QIcon icon() const = 0;
|
virtual QIcon icon() const = 0;
|
||||||
virtual QWidget *widget() const = 0;
|
virtual QWidget *widget() const = 0;
|
||||||
|
virtual void widgetWasAddedToLayout() { }
|
||||||
};
|
};
|
||||||
|
|
||||||
class PROJECTEXPLORER_EXPORT IPanelFactory : public QObject
|
class PROJECTEXPLORER_EXPORT IPanelFactory : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
virtual QString displayName() const = 0;
|
||||||
virtual bool supports(Project *project) = 0;
|
virtual bool supports(Project *project) = 0;
|
||||||
virtual IPropertiesPanel *createPanel(Project *project) = 0;
|
virtual IPropertiesPanel *createPanel(Project *project) = 0;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -903,6 +903,7 @@ void ProjectExplorerPlugin::extensionsInitialized()
|
|||||||
|
|
||||||
void ProjectExplorerPlugin::shutdown()
|
void ProjectExplorerPlugin::shutdown()
|
||||||
{
|
{
|
||||||
|
d->m_proWindow->shutdown(); // disconnect from session
|
||||||
d->m_session->clear();
|
d->m_session->clear();
|
||||||
// d->m_proWindow->saveConfigChanges();
|
// d->m_proWindow->saveConfigChanges();
|
||||||
}
|
}
|
||||||
@@ -2240,7 +2241,7 @@ BuildConfigDialog::BuildConfigDialog(Project *project, QWidget *parent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QFormLayout *formlayout = new QFormLayout;
|
QFormLayout *formlayout = new QFormLayout;
|
||||||
formlayout->addRow(ActiveConfigurationWidget::tr("Active run configuration"),
|
formlayout->addRow(tr("Active run configuration"),
|
||||||
// ^ avoiding a new translatable string for active run configuration
|
// ^ avoiding a new translatable string for active run configuration
|
||||||
new QLabel(activeRun->displayName()));
|
new QLabel(activeRun->displayName()));
|
||||||
formlayout->addRow(tr("Choose build configuration:"), m_configCombo);
|
formlayout->addRow(tr("Choose build configuration:"), m_configCombo);
|
||||||
|
|||||||
@@ -29,6 +29,8 @@
|
|||||||
|
|
||||||
#include "projectwindow.h"
|
#include "projectwindow.h"
|
||||||
|
|
||||||
|
#include "doubletabwidget.h"
|
||||||
|
|
||||||
#include "project.h"
|
#include "project.h"
|
||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "projectexplorer.h"
|
#include "projectexplorer.h"
|
||||||
@@ -90,22 +92,6 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
///
|
|
||||||
// PanelsWidget::Panel
|
|
||||||
///
|
|
||||||
|
|
||||||
PanelsWidget::Panel::Panel(QWidget * w) :
|
|
||||||
iconLabel(0), lineWidget(0), nameLabel(0), panelWidget(w)
|
|
||||||
{ }
|
|
||||||
|
|
||||||
PanelsWidget::Panel::~Panel()
|
|
||||||
{
|
|
||||||
delete iconLabel;
|
|
||||||
delete lineWidget;
|
|
||||||
delete nameLabel;
|
|
||||||
// do not delete panelWidget, we do not own it!
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// PanelsWidget
|
// PanelsWidget
|
||||||
///
|
///
|
||||||
@@ -129,24 +115,7 @@ PanelsWidget::PanelsWidget(QWidget *parent) :
|
|||||||
|
|
||||||
PanelsWidget::~PanelsWidget()
|
PanelsWidget::~PanelsWidget()
|
||||||
{
|
{
|
||||||
clear();
|
qDeleteAll(m_panels);
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Add a widget into the grid layout of the PanelsWidget.
|
|
||||||
*
|
|
||||||
* ...
|
|
||||||
* +--------+-------------------------------------------+ ABOVE_CONTENTS_MARGIN
|
|
||||||
* | widget (with contentsmargins adjusted!) |
|
|
||||||
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
|
||||||
*/
|
|
||||||
void PanelsWidget::addWidget(QWidget *widget)
|
|
||||||
{
|
|
||||||
QTC_ASSERT(widget, return);
|
|
||||||
|
|
||||||
const int row(m_layout->rowCount() - 1);
|
|
||||||
m_layout->setRowStretch(row, 0);
|
|
||||||
addPanelWidget(new Panel(widget), row);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -162,70 +131,48 @@ void PanelsWidget::addWidget(QWidget *widget)
|
|||||||
* | widget (with contentsmargins adjusted!) |
|
* | widget (with contentsmargins adjusted!) |
|
||||||
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
* +--------+-------------------------------------------+ BELOW_CONTENTS_MARGIN
|
||||||
*/
|
*/
|
||||||
void PanelsWidget::addWidget(const QString &name, QWidget *widget, const QIcon & icon)
|
void PanelsWidget::addPropertiesPanel(IPropertiesPanel *panel)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(widget, return);
|
QTC_ASSERT(panel, return);
|
||||||
|
|
||||||
Panel *p = new Panel(widget);
|
|
||||||
|
|
||||||
// icon:
|
// icon:
|
||||||
const int headerRow(m_layout->rowCount() - 1);
|
const int headerRow(m_layout->rowCount() - 1);
|
||||||
m_layout->setRowStretch(headerRow, 0);
|
m_layout->setRowStretch(headerRow, 0);
|
||||||
|
|
||||||
if (!icon.isNull()) {
|
if (!panel->icon().isNull()) {
|
||||||
p->iconLabel = new QLabel(m_root);
|
QLabel *iconLabel = new QLabel(m_root);
|
||||||
p->iconLabel->setPixmap(icon.pixmap(ICON_SIZE, ICON_SIZE));
|
iconLabel->setPixmap(panel->icon().pixmap(ICON_SIZE, ICON_SIZE));
|
||||||
p->iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
iconLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
||||||
m_layout->addWidget(p->iconLabel, headerRow, 0, 2, 1, Qt::AlignTop | Qt::AlignHCenter);
|
m_layout->addWidget(iconLabel, headerRow, 0, 2, 1, Qt::AlignTop | Qt::AlignHCenter);
|
||||||
}
|
}
|
||||||
|
|
||||||
// name:
|
// name:
|
||||||
p->nameLabel = new QLabel(m_root);
|
QLabel *nameLabel = new QLabel(m_root);
|
||||||
p->nameLabel->setText(name);
|
nameLabel->setText(panel->displayName());
|
||||||
p->nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
nameLabel->setContentsMargins(0, ABOVE_HEADING_MARGIN, 0, 0);
|
||||||
QFont f = p->nameLabel->font();
|
QFont f = nameLabel->font();
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
f.setPointSizeF(f.pointSizeF() * 1.4);
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
||||||
p->nameLabel->setFont(f);
|
nameLabel->setFont(f);
|
||||||
m_layout->addWidget(p->nameLabel, headerRow, 1, 1, 1, Qt::AlignBottom | Qt::AlignLeft);
|
m_layout->addWidget(nameLabel, headerRow, 1, 1, 1, Qt::AlignBottom | Qt::AlignLeft);
|
||||||
|
|
||||||
// line:
|
// line:
|
||||||
const int lineRow(headerRow + 1);
|
const int lineRow(headerRow + 1);
|
||||||
p->lineWidget = new OnePixelBlackLine(m_root);
|
m_layout->addWidget(new OnePixelBlackLine(m_root), lineRow, 1);
|
||||||
m_layout->addWidget(p->lineWidget, lineRow, 1);
|
|
||||||
|
|
||||||
// add the widget:
|
// add the widget:
|
||||||
const int widgetRow(lineRow + 1);
|
const int widgetRow(lineRow + 1);
|
||||||
addPanelWidget(p, widgetRow);
|
addPanelWidget(panel, widgetRow);
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *PanelsWidget::rootWidget() const
|
void PanelsWidget::addPanelWidget(IPropertiesPanel *panel, int row)
|
||||||
{
|
{
|
||||||
return m_root;
|
QWidget *widget = panel->widget();
|
||||||
}
|
widget->setContentsMargins(m_layout->columnMinimumWidth(0),
|
||||||
|
|
||||||
void PanelsWidget::clear()
|
|
||||||
{
|
|
||||||
foreach (Panel *p, m_panels) {
|
|
||||||
if (p->iconLabel)
|
|
||||||
m_layout->removeWidget(p->iconLabel);
|
|
||||||
if (p->lineWidget)
|
|
||||||
m_layout->removeWidget(p->lineWidget);
|
|
||||||
if (p->nameLabel)
|
|
||||||
m_layout->removeWidget(p->nameLabel);
|
|
||||||
if (p->panelWidget)
|
|
||||||
m_layout->removeWidget(p->panelWidget);
|
|
||||||
delete p;
|
|
||||||
}
|
|
||||||
m_panels.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
void PanelsWidget::addPanelWidget(Panel *panel, int row)
|
|
||||||
{
|
|
||||||
panel->panelWidget->setContentsMargins(m_layout->columnMinimumWidth(0),
|
|
||||||
ABOVE_CONTENTS_MARGIN, 0,
|
ABOVE_CONTENTS_MARGIN, 0,
|
||||||
BELOW_CONTENTS_MARGIN);
|
BELOW_CONTENTS_MARGIN);
|
||||||
m_layout->addWidget(panel->panelWidget, row, 0, 1, 2);
|
widget->setParent(m_root);
|
||||||
|
m_layout->addWidget(widget, row, 0, 1, 2);
|
||||||
|
|
||||||
const int stretchRow(row + 1);
|
const int stretchRow(row + 1);
|
||||||
m_layout->setRowStretch(stretchRow, 10);
|
m_layout->setRowStretch(stretchRow, 10);
|
||||||
@@ -233,470 +180,13 @@ void PanelsWidget::addPanelWidget(Panel *panel, int row)
|
|||||||
m_panels.append(panel);
|
m_panels.append(panel);
|
||||||
}
|
}
|
||||||
|
|
||||||
////
|
|
||||||
// ActiveConfigurationWidget
|
|
||||||
////
|
|
||||||
|
|
||||||
ActiveConfigurationWidget::ActiveConfigurationWidget(QWidget *parent)
|
|
||||||
: QWidget(parent)
|
|
||||||
{
|
|
||||||
QGridLayout *grid = new QGridLayout(this);
|
|
||||||
grid->setMargin(0);
|
|
||||||
RunConfigurationComboBox *runConfigurationComboBox = new RunConfigurationComboBox(this);
|
|
||||||
grid->addWidget(new QLabel(tr("Active run configuration")), 0, 0);
|
|
||||||
grid->addWidget(runConfigurationComboBox, 0, 1);
|
|
||||||
|
|
||||||
SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach(Project *p, session->projects()) {
|
|
||||||
++i;
|
|
||||||
BuildConfigurationComboBox *buildConfigurationComboBox = new BuildConfigurationComboBox(p, this);
|
|
||||||
QLabel *label = new QLabel("Build configuration for <b>" + p->displayName() + "</b>", this);
|
|
||||||
grid->addWidget(label, i, 0);
|
|
||||||
grid->addWidget(buildConfigurationComboBox, i, 1);
|
|
||||||
m_buildComboBoxMap.insert(p, qMakePair(buildConfigurationComboBox, label));
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
||||||
|
|
||||||
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
void ActiveConfigurationWidget::projectAdded(Project *p)
|
|
||||||
{
|
|
||||||
QGridLayout *grid = static_cast<QGridLayout *>(layout());
|
|
||||||
BuildConfigurationComboBox *buildConfigurationComboBox = new BuildConfigurationComboBox(p, this);
|
|
||||||
QLabel *label = new QLabel("Build configuration for <b>" + p->displayName() + "</b>");
|
|
||||||
grid->addWidget(label);
|
|
||||||
grid->addWidget(buildConfigurationComboBox);
|
|
||||||
m_buildComboBoxMap.insert(p, qMakePair(buildConfigurationComboBox, label));
|
|
||||||
}
|
|
||||||
|
|
||||||
void ActiveConfigurationWidget::projectRemoved(Project *p)
|
|
||||||
{
|
|
||||||
// Find row
|
|
||||||
|
|
||||||
// TODO also remove the label...
|
|
||||||
QPair<BuildConfigurationComboBox *, QLabel *> pair = m_buildComboBoxMap.value(p);;
|
|
||||||
delete pair.first;
|
|
||||||
delete pair.second;
|
|
||||||
m_buildComboBoxMap.remove(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
ActiveConfigurationWidget::~ActiveConfigurationWidget()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
////
|
|
||||||
// RunConfigurationComboBox
|
|
||||||
////
|
|
||||||
|
|
||||||
RunConfigurationComboBox::RunConfigurationComboBox(QWidget *parent)
|
|
||||||
: QComboBox(parent), m_ignoreChange(false)
|
|
||||||
{
|
|
||||||
setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
||||||
|
|
||||||
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
||||||
|
|
||||||
// Setup the treewidget
|
|
||||||
rebuildTree();
|
|
||||||
|
|
||||||
// Connect
|
|
||||||
foreach(Project *p, session->projects()) {
|
|
||||||
foreach(RunConfiguration *rc, p->runConfigurations()) {
|
|
||||||
connect(rc, SIGNAL(displayNameChanged()), this, SLOT(rebuildTree()));
|
|
||||||
}
|
|
||||||
connectToProject(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
connect(session, SIGNAL(startupProjectChanged(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(activeRunConfigurationChanged()));
|
|
||||||
|
|
||||||
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
||||||
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
||||||
connect(this, SIGNAL(activated(int)),
|
|
||||||
this, SLOT(activeItemChanged(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
RunConfigurationComboBox::~RunConfigurationComboBox()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
int RunConfigurationComboBox::convertTreeIndexToInt(int project, int runconfigurationIndex)
|
|
||||||
{
|
|
||||||
++runconfigurationIndex;
|
|
||||||
++project;
|
|
||||||
for(int i=0; i<count(); ++i) {
|
|
||||||
if (itemData(i, Qt::UserRole).toInt() == 0) {
|
|
||||||
--project;
|
|
||||||
} else if (itemData(i, Qt::UserRole).toInt() == 1 && project == 0) {
|
|
||||||
--runconfigurationIndex;
|
|
||||||
}
|
|
||||||
if (runconfigurationIndex == 0) {
|
|
||||||
return i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
QPair<int, int> RunConfigurationComboBox::convertIntToTreeIndex(int index)
|
|
||||||
{
|
|
||||||
int projectIndex = -1;
|
|
||||||
int runConfigIndex = -1;
|
|
||||||
for(int i = 0; i <= index; ++i) {
|
|
||||||
if (itemData(i, Qt::UserRole).toInt() == 0) {
|
|
||||||
++projectIndex;
|
|
||||||
runConfigIndex = -1;
|
|
||||||
} else if (itemData(i, Qt::UserRole).toInt() == 1) {
|
|
||||||
++runConfigIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return qMakePair(projectIndex, runConfigIndex);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::activeItemChanged(int index)
|
|
||||||
{
|
|
||||||
if (m_ignoreChange)
|
|
||||||
return;
|
|
||||||
m_ignoreChange = true;
|
|
||||||
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
||||||
QPair<int, int> pair = convertIntToTreeIndex(index);
|
|
||||||
if (pair.first == -1) {
|
|
||||||
setCurrentIndex(-1);
|
|
||||||
} else {
|
|
||||||
if (pair.second == -1)
|
|
||||||
pair.second = 0;
|
|
||||||
QList<Project *> projects = session->projects();
|
|
||||||
if (pair.first < projects.count()) {
|
|
||||||
Project *p = projects.at(pair.first);
|
|
||||||
QList<RunConfiguration *> runconfigurations = p->runConfigurations();
|
|
||||||
if (pair.second < runconfigurations.count()) {
|
|
||||||
session->setStartupProject(p);
|
|
||||||
p->setActiveRunConfiguration(runconfigurations.at(pair.second));
|
|
||||||
if (currentIndex() != convertTreeIndexToInt(pair.first, pair.second))
|
|
||||||
setCurrentIndex(convertTreeIndexToInt(pair.first, pair.second));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
m_ignoreChange = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::activeRunConfigurationChanged()
|
|
||||||
{
|
|
||||||
if (m_ignoreChange)
|
|
||||||
return;
|
|
||||||
m_ignoreChange = true;
|
|
||||||
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
||||||
Project *startupProject = session->startupProject();
|
|
||||||
if (startupProject) {
|
|
||||||
int projectIndex = session->projects().indexOf(startupProject);
|
|
||||||
int runConfigurationIndex = startupProject->runConfigurations().indexOf(startupProject->activeRunConfiguration());
|
|
||||||
setCurrentIndex(convertTreeIndexToInt(projectIndex, runConfigurationIndex));
|
|
||||||
} else {
|
|
||||||
setCurrentIndex(-1);
|
|
||||||
}
|
|
||||||
m_ignoreChange = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::addedRunConfiguration(RunConfiguration *runConfiguration)
|
|
||||||
{
|
|
||||||
if (runConfiguration) {
|
|
||||||
connect(runConfiguration, SIGNAL(displayNameChanged()),
|
|
||||||
this, SLOT(rebuildTree()));
|
|
||||||
}
|
|
||||||
rebuildTree();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::removedRunConfiguration(RunConfiguration *rc)
|
|
||||||
{
|
|
||||||
Q_UNUSED(rc)
|
|
||||||
rebuildTree();
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::projectAdded(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
rebuildTree();
|
|
||||||
foreach(RunConfiguration *rc, p->runConfigurations())
|
|
||||||
connect(rc, SIGNAL(displayNameChanged()), this, SLOT(rebuildTree()));
|
|
||||||
connectToProject(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::projectRemoved(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
rebuildTree();
|
|
||||||
disconnectFromProject(p);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::connectToProject(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
connect(p, SIGNAL(activeRunConfigurationChanged()),
|
|
||||||
this, SLOT(activeRunConfigurationChanged()));
|
|
||||||
connect(p, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration *)),
|
|
||||||
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration *)));
|
|
||||||
connect(p, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration *)),
|
|
||||||
this, SLOT(removedRunConfiguration(ProjectExplorer::RunConfiguration *)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::disconnectFromProject(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
disconnect(p, SIGNAL(activeRunConfigurationChanged()),
|
|
||||||
this, SLOT(activeRunConfigurationChanged()));
|
|
||||||
disconnect(p, SIGNAL(addedRunConfiguration(ProjectExplorer::RunConfiguration *)),
|
|
||||||
this, SLOT(addedRunConfiguration(ProjectExplorer::RunConfiguration *)));
|
|
||||||
disconnect(p, SIGNAL(removedRunConfiguration(ProjectExplorer::RunConfiguration *)),
|
|
||||||
this, SLOT(removedRunConfiguration(ProjectExplorer::RunConfiguration *)));
|
|
||||||
}
|
|
||||||
|
|
||||||
void RunConfigurationComboBox::rebuildTree()
|
|
||||||
{
|
|
||||||
m_ignoreChange = true;
|
|
||||||
clear();
|
|
||||||
|
|
||||||
SessionManager *session = ProjectExplorer::ProjectExplorerPlugin::instance()->session();
|
|
||||||
Project *startupProject = session->startupProject();
|
|
||||||
foreach(Project *p, session->projects()) {
|
|
||||||
addItem(p->displayName(), QVariant(0));
|
|
||||||
foreach(RunConfiguration *rc, p->runConfigurations()) {
|
|
||||||
addItem(" " + rc->displayName(), QVariant(1));
|
|
||||||
if ((startupProject == p) && (p->activeRunConfiguration() == rc)){
|
|
||||||
setCurrentIndex(count() - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Select the right index
|
|
||||||
m_ignoreChange = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
////
|
|
||||||
// BuildConfigurationComboBox
|
|
||||||
////
|
|
||||||
|
|
||||||
|
|
||||||
BuildConfigurationComboBox::BuildConfigurationComboBox(Project *p, QWidget *parent)
|
|
||||||
: QStackedWidget(parent), ignoreIndexChange(false), m_project(p)
|
|
||||||
{
|
|
||||||
setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
||||||
m_comboBox = new QComboBox(this);
|
|
||||||
m_comboBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
||||||
addWidget(m_comboBox);
|
|
||||||
|
|
||||||
m_label = new QLabel(this);
|
|
||||||
m_label->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
|
||||||
addWidget(m_label);
|
|
||||||
|
|
||||||
//m_comboBox->setSizeAdjustPolicy(QComboBox::AdjustToContents);
|
|
||||||
foreach(BuildConfiguration *buildConfiguration, p->buildConfigurations()) {
|
|
||||||
m_comboBox->addItem(buildConfiguration->displayName(), QVariant::fromValue(buildConfiguration));
|
|
||||||
connect(buildConfiguration, SIGNAL(displayNameChanged()),
|
|
||||||
this, SLOT(displayNameChanged()));
|
|
||||||
}
|
|
||||||
if (p->buildConfigurations().count() == 1) {
|
|
||||||
m_label->setText(m_comboBox->itemText(0));
|
|
||||||
setCurrentWidget(m_label);
|
|
||||||
}
|
|
||||||
|
|
||||||
int index = p->buildConfigurations().indexOf(p->activeBuildConfiguration());
|
|
||||||
if (index != -1)
|
|
||||||
m_comboBox->setCurrentIndex(index);
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// connect(p, SIGNAL(buildConfigurationDisplayNameChanged(QString)),
|
|
||||||
// this, SLOT(nameChanged(ProjectExplorer::BuildConfiguration *)));
|
|
||||||
connect(p, SIGNAL(activeBuildConfigurationChanged()),
|
|
||||||
this, SLOT(activeConfigurationChanged()));
|
|
||||||
connect(p, SIGNAL(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
||||||
this, SLOT(addedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
|
||||||
connect(p, SIGNAL(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)),
|
|
||||||
this, SLOT(removedBuildConfiguration(ProjectExplorer::BuildConfiguration*)));
|
|
||||||
connect(m_comboBox, SIGNAL(activated(int)),
|
|
||||||
this, SLOT(changedIndex(int)));
|
|
||||||
}
|
|
||||||
|
|
||||||
BuildConfigurationComboBox::~BuildConfigurationComboBox()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildConfigurationComboBox::displayNameChanged()
|
|
||||||
{
|
|
||||||
for (int i=0; i < m_comboBox->count(); ++i) {
|
|
||||||
BuildConfiguration *bc = m_comboBox->itemData(i).value<BuildConfiguration *>();
|
|
||||||
const QString &displayName = bc->displayName();
|
|
||||||
m_comboBox->setItemText(i, displayName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_comboBox->count() == 1)
|
|
||||||
m_label->setText(m_comboBox->itemText(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
int BuildConfigurationComboBox::buildConfigurationToIndex(BuildConfiguration *bc)
|
|
||||||
{
|
|
||||||
for (int i=0; i < m_comboBox->count(); ++i)
|
|
||||||
if (m_comboBox->itemData(i).value<BuildConfiguration *>() == bc)
|
|
||||||
return i;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildConfigurationComboBox::activeConfigurationChanged()
|
|
||||||
{
|
|
||||||
const int index(buildConfigurationToIndex(m_project->activeBuildConfiguration()));
|
|
||||||
if (index == -1)
|
|
||||||
return;
|
|
||||||
ignoreIndexChange = true;
|
|
||||||
m_comboBox->setCurrentIndex(index);
|
|
||||||
ignoreIndexChange = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildConfigurationComboBox::addedBuildConfiguration(BuildConfiguration *bc)
|
|
||||||
{
|
|
||||||
ignoreIndexChange = true;
|
|
||||||
m_comboBox->addItem(bc->displayName(), QVariant::fromValue(bc));
|
|
||||||
|
|
||||||
if (m_comboBox->count() == 2)
|
|
||||||
setCurrentWidget(m_comboBox);
|
|
||||||
ignoreIndexChange = false;
|
|
||||||
connect(bc, SIGNAL(displayNameChanged()),
|
|
||||||
this, SLOT(displayNameChanged()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildConfigurationComboBox::removedBuildConfiguration(BuildConfiguration * bc)
|
|
||||||
{
|
|
||||||
ignoreIndexChange = true;
|
|
||||||
const int index(buildConfigurationToIndex(bc));
|
|
||||||
if (index == -1)
|
|
||||||
return;
|
|
||||||
m_comboBox->removeItem(index);
|
|
||||||
if (m_comboBox->count() == 1) {
|
|
||||||
m_label->setText(m_comboBox->itemText(0));
|
|
||||||
setCurrentWidget(m_label);
|
|
||||||
}
|
|
||||||
ignoreIndexChange = false;
|
|
||||||
connect(bc, SIGNAL(displayNameChanged()),
|
|
||||||
this, SLOT(displayNameChanged()));
|
|
||||||
}
|
|
||||||
|
|
||||||
void BuildConfigurationComboBox::changedIndex(int newIndex)
|
|
||||||
{
|
|
||||||
if (newIndex == -1)
|
|
||||||
return;
|
|
||||||
m_project->setActiveBuildConfiguration(m_comboBox->itemData(newIndex).value<BuildConfiguration *>());
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
// ProjectLabel
|
|
||||||
///
|
|
||||||
|
|
||||||
ProjectLabel::ProjectLabel(QWidget *parent)
|
|
||||||
: QLabel(parent)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectLabel::~ProjectLabel()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectLabel::setProject(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
if (p)
|
|
||||||
setText(tr("Edit Project Settings for Project <b>%1</b>").arg(p->displayName()));
|
|
||||||
else
|
|
||||||
setText(tr("No Project loaded"));
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
|
||||||
// ProjectPushButton
|
|
||||||
///
|
|
||||||
|
|
||||||
ProjectPushButton::ProjectPushButton(QWidget *parent)
|
|
||||||
: QPushButton(parent)
|
|
||||||
{
|
|
||||||
setText(tr("Select Project"));
|
|
||||||
m_menu = new QMenu(this);
|
|
||||||
setMenu(m_menu);
|
|
||||||
|
|
||||||
setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
||||||
|
|
||||||
SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
|
||||||
|
|
||||||
foreach(Project *p, session->projects()) {
|
|
||||||
QAction *act = m_menu->addAction(p->displayName());
|
|
||||||
act->setData(QVariant::fromValue((void *) p));
|
|
||||||
connect(act, SIGNAL(triggered()),
|
|
||||||
this, SLOT(actionTriggered()));
|
|
||||||
}
|
|
||||||
|
|
||||||
setEnabled(session->projects().count() > 1);
|
|
||||||
|
|
||||||
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectRemoved(ProjectExplorer::Project*)));
|
|
||||||
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
|
||||||
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectPushButton::~ProjectPushButton()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectPushButton::projectAdded(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
QAction *act = m_menu->addAction(p->displayName());
|
|
||||||
act->setData(QVariant::fromValue((void *) p));
|
|
||||||
connect(act, SIGNAL(triggered()),
|
|
||||||
this, SLOT(actionTriggered()));
|
|
||||||
|
|
||||||
// Activate it
|
|
||||||
if (m_menu->actions().count() == 1)
|
|
||||||
emit projectChanged(p);
|
|
||||||
else if (m_menu->actions().count() > 1)
|
|
||||||
setEnabled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectPushButton::projectRemoved(ProjectExplorer::Project *p)
|
|
||||||
{
|
|
||||||
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects();
|
|
||||||
|
|
||||||
bool needToChange = false;
|
|
||||||
foreach(QAction *act, m_menu->actions()) {
|
|
||||||
if (act->data().value<void *>() == (void *) p) {
|
|
||||||
delete act;
|
|
||||||
needToChange = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Comboboxes don't emit a signal if the index did't actually change
|
|
||||||
if (m_menu->actions().isEmpty()) {
|
|
||||||
emit projectChanged(0);
|
|
||||||
setEnabled(false);
|
|
||||||
} else if (needToChange) {
|
|
||||||
emit projectChanged((ProjectExplorer::Project *) m_menu->actions().first()->data().value<void *>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectPushButton::actionTriggered()
|
|
||||||
{
|
|
||||||
QAction *action = qobject_cast<QAction *>(sender());
|
|
||||||
emit projectChanged((ProjectExplorer::Project *) action->data().value<void *>());
|
|
||||||
}
|
|
||||||
|
|
||||||
///
|
///
|
||||||
// ProjectWindow
|
// ProjectWindow
|
||||||
///
|
///
|
||||||
|
|
||||||
ProjectWindow::ProjectWindow(QWidget *parent)
|
ProjectWindow::ProjectWindow(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent),
|
||||||
|
m_panelsWidget(0)
|
||||||
{
|
{
|
||||||
ProjectExplorer::SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
ProjectExplorer::SessionManager *session = ProjectExplorerPlugin::instance()->session();
|
||||||
|
|
||||||
@@ -705,88 +195,77 @@ ProjectWindow::ProjectWindow(QWidget *parent)
|
|||||||
viewLayout->setMargin(0);
|
viewLayout->setMargin(0);
|
||||||
viewLayout->setSpacing(0);
|
viewLayout->setSpacing(0);
|
||||||
|
|
||||||
// Add toolbar used everywhere
|
m_tabWidget = new DoubleTabWidget(this);
|
||||||
viewLayout->addWidget(new Utils::StyledBar(this));
|
m_tabWidget->setTitle(tr("Select a Project:"));
|
||||||
|
viewLayout->addWidget(m_tabWidget);
|
||||||
|
|
||||||
// Setup our container for the contents:
|
// Setup our container for the contents:
|
||||||
m_panelsWidget = new PanelsWidget(this);
|
m_centralWidget = new QStackedWidget(this);
|
||||||
viewLayout->addWidget(m_panelsWidget);
|
viewLayout->addWidget(m_centralWidget);
|
||||||
|
|
||||||
// Run and build configuration selection panel:
|
// no projects label:
|
||||||
m_activeConfigurationWidget = new ActiveConfigurationWidget(m_panelsWidget->rootWidget());
|
m_noprojectLabel = new QWidget;
|
||||||
|
QVBoxLayout *noprojectLayout = new QVBoxLayout;
|
||||||
// Spacer and line panel:
|
noprojectLayout->setMargin(0);
|
||||||
m_spacerBetween = new OnePixelBlackLine(m_panelsWidget->rootWidget());
|
QLabel *label = new QLabel(m_noprojectLabel);
|
||||||
|
label->setText(tr("No project loaded."));
|
||||||
// Project chooser panel:
|
|
||||||
m_projectChooser = new QWidget(m_panelsWidget->rootWidget());
|
|
||||||
QHBoxLayout *hbox = new QHBoxLayout(m_projectChooser);
|
|
||||||
hbox->setMargin(0);
|
|
||||||
ProjectLabel *label = new ProjectLabel(m_projectChooser);
|
|
||||||
{
|
{
|
||||||
QFont f = label->font();
|
QFont f = label->font();
|
||||||
f.setPointSizeF(f.pointSizeF() * 1.4);
|
f.setPointSizeF(f.pointSizeF() * 1.4);
|
||||||
f.setBold(true);
|
f.setBold(true);
|
||||||
label->setFont(f);
|
label->setFont(f);
|
||||||
}
|
}
|
||||||
hbox->addWidget(label);
|
label->setMargin(10);
|
||||||
ProjectPushButton *changeProject = new ProjectPushButton(m_projectChooser);
|
label->setAlignment(Qt::AlignTop);
|
||||||
connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
|
noprojectLayout->addWidget(label);
|
||||||
label, SLOT(setProject(ProjectExplorer::Project*)));
|
noprojectLayout->addStretch(10);
|
||||||
hbox->addWidget(changeProject);
|
m_centralWidget->addWidget(m_noprojectLabel);
|
||||||
|
|
||||||
// no projects label:
|
|
||||||
m_noprojectLabel = new QLabel(this);
|
|
||||||
m_noprojectLabel->setText(tr("No project loaded."));
|
|
||||||
{
|
|
||||||
QFont f = m_noprojectLabel->font();
|
|
||||||
f.setPointSizeF(f.pointSizeF() * 1.4);
|
|
||||||
f.setBold(true);
|
|
||||||
m_noprojectLabel->setFont(f);
|
|
||||||
}
|
|
||||||
m_noprojectLabel->setMargin(10);
|
|
||||||
m_noprojectLabel->setAlignment(Qt::AlignTop);
|
|
||||||
viewLayout->addWidget(m_noprojectLabel);
|
|
||||||
|
|
||||||
// show either panels or no projects label:
|
|
||||||
bool noProjects = session->projects().isEmpty();
|
|
||||||
m_panelsWidget->setVisible(!noProjects);
|
|
||||||
m_noprojectLabel->setVisible(noProjects);
|
|
||||||
|
|
||||||
// connects:
|
// connects:
|
||||||
connect(changeProject, SIGNAL(projectChanged(ProjectExplorer::Project*)),
|
connect(m_tabWidget, SIGNAL(currentIndexChanged(int,int)),
|
||||||
this, SLOT(showProperties(ProjectExplorer::Project*)));
|
this, SLOT(showProperties(int,int)));
|
||||||
|
|
||||||
connect(session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
|
connect(session, SIGNAL(sessionLoaded()), this, SLOT(restoreStatus()));
|
||||||
connect(session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
|
connect(session, SIGNAL(aboutToSaveSession()), this, SLOT(saveStatus()));
|
||||||
|
|
||||||
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
connect(session, SIGNAL(projectAdded(ProjectExplorer::Project*)),
|
||||||
this, SLOT(projectAdded()));
|
this, SLOT(projectAdded(ProjectExplorer::Project*)));
|
||||||
connect(session, SIGNAL(projectRemoved(ProjectExplorer::Project*)),
|
connect(session, SIGNAL(aboutToRemoveProject(ProjectExplorer::Project*)),
|
||||||
this, SLOT(projectRemoved()));
|
this, SLOT(aboutToRemoveProject(ProjectExplorer::Project*)));
|
||||||
|
|
||||||
// Update properties to empty project for now:
|
// Update properties to empty project for now:
|
||||||
showProperties(0);
|
showProperties(-1, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectWindow::~ProjectWindow()
|
ProjectWindow::~ProjectWindow()
|
||||||
{
|
{
|
||||||
qDeleteAll(m_panels);
|
|
||||||
m_panels.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectWindow::projectAdded()
|
void ProjectWindow::shutdown()
|
||||||
{
|
{
|
||||||
m_panelsWidget->setVisible(true);
|
showProperties(-1, -1); // TODO that's a bit stupid, but otherwise stuff is still
|
||||||
m_noprojectLabel->setVisible(false);
|
// connected to the session
|
||||||
|
disconnect(ProjectExplorerPlugin::instance()->session(), 0, this, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectWindow::projectRemoved()
|
void ProjectWindow::projectAdded(ProjectExplorer::Project *project)
|
||||||
{
|
{
|
||||||
if (ProjectExplorerPlugin::instance()->session()->projects().isEmpty()) {
|
QList<Project *> projects = ProjectExplorerPlugin::instance()->session()->projects();
|
||||||
m_panelsWidget->setVisible(false);
|
int index = projects.indexOf(project);
|
||||||
m_noprojectLabel->setVisible(true);
|
QStringList subtabs;
|
||||||
|
foreach (IPanelFactory *panelFactory, ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>()) {
|
||||||
|
if (panelFactory->supports(project))
|
||||||
|
subtabs << panelFactory->displayName();
|
||||||
}
|
}
|
||||||
|
m_tabIndexToProject.insert(index, project);
|
||||||
|
m_tabWidget->insertTab(index, project->displayName(), subtabs);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectWindow::aboutToRemoveProject(ProjectExplorer::Project *project)
|
||||||
|
{
|
||||||
|
int index = m_tabIndexToProject.indexOf(project);
|
||||||
|
m_tabIndexToProject.removeAt(index);
|
||||||
|
m_tabWidget->removeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectWindow::restoreStatus()
|
void ProjectWindow::restoreStatus()
|
||||||
@@ -799,30 +278,45 @@ void ProjectWindow::saveStatus()
|
|||||||
// TODO
|
// TODO
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectWindow::showProperties(Project *project)
|
void ProjectWindow::showProperties(int index, int subIndex)
|
||||||
{
|
{
|
||||||
// Remove all existing panels:
|
if (index < 0) {
|
||||||
m_panelsWidget->clear();
|
m_centralWidget->setCurrentWidget(m_noprojectLabel);
|
||||||
|
if (m_panelsWidget) {
|
||||||
|
m_centralWidget->removeWidget(m_panelsWidget);
|
||||||
|
delete m_panelsWidget;
|
||||||
|
m_panelsWidget = 0;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Project *project = m_tabIndexToProject.at(index);
|
||||||
|
|
||||||
// delete custom panels:
|
|
||||||
qDeleteAll(m_panels);
|
|
||||||
m_panels.clear();
|
|
||||||
|
|
||||||
// Set up our default panels:
|
|
||||||
m_panelsWidget->addWidget(tr("Active Build and Run Configurations"), m_activeConfigurationWidget, QIcon());
|
|
||||||
m_panelsWidget->addWidget(m_spacerBetween);
|
|
||||||
m_panelsWidget->addWidget(m_projectChooser);
|
|
||||||
|
|
||||||
|
PanelsWidget *panelsWidget = 0;
|
||||||
// Set up custom panels again:
|
// Set up custom panels again:
|
||||||
if (project) {
|
|
||||||
QList<IPanelFactory *> pages =
|
QList<IPanelFactory *> pages =
|
||||||
ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>();
|
ExtensionSystem::PluginManager::instance()->getObjects<IPanelFactory>();
|
||||||
|
int indexOfPanel = 0;
|
||||||
foreach (IPanelFactory *panelFactory, pages) {
|
foreach (IPanelFactory *panelFactory, pages) {
|
||||||
if (panelFactory->supports(project)) {
|
if (panelFactory->supports(project)) {
|
||||||
|
if (indexOfPanel == subIndex) {
|
||||||
|
panelsWidget = new PanelsWidget(m_centralWidget);
|
||||||
IPropertiesPanel *panel = panelFactory->createPanel(project);
|
IPropertiesPanel *panel = panelFactory->createPanel(project);
|
||||||
m_panelsWidget->addWidget(panel->displayName(), panel->widget(), panel->icon());
|
panelsWidget->addPropertiesPanel(panel);
|
||||||
m_panels.push_back(panel);
|
panel->widgetWasAddedToLayout();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
++indexOfPanel;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (panelsWidget) {
|
||||||
|
// add the new stuff to the stack widget
|
||||||
|
m_centralWidget->addWidget(panelsWidget);
|
||||||
|
m_centralWidget->setCurrentWidget(panelsWidget);
|
||||||
|
if (m_panelsWidget) {
|
||||||
|
m_centralWidget->removeWidget(m_panelsWidget);
|
||||||
|
delete m_panelsWidget;
|
||||||
|
}
|
||||||
|
m_panelsWidget = panelsWidget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,8 +30,11 @@
|
|||||||
#ifndef PROJECTWINDOW_H
|
#ifndef PROJECTWINDOW_H
|
||||||
#define PROJECTWINDOW_H
|
#define PROJECTWINDOW_H
|
||||||
|
|
||||||
|
#include "iprojectproperties.h"
|
||||||
|
|
||||||
#include <QtCore/QPair>
|
#include <QtCore/QPair>
|
||||||
#include <QtCore/QMap>
|
#include <QtCore/QMap>
|
||||||
|
#include <QtGui/QApplication>
|
||||||
#include <QtGui/QComboBox>
|
#include <QtGui/QComboBox>
|
||||||
#include <QtGui/QLabel>
|
#include <QtGui/QLabel>
|
||||||
#include <QtGui/QPushButton>
|
#include <QtGui/QPushButton>
|
||||||
@@ -54,6 +57,8 @@ class RunConfiguration;
|
|||||||
|
|
||||||
namespace Internal {
|
namespace Internal {
|
||||||
|
|
||||||
|
class DoubleTabWidget;
|
||||||
|
|
||||||
class PanelsWidget : public QScrollArea
|
class PanelsWidget : public QScrollArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -61,117 +66,16 @@ public:
|
|||||||
PanelsWidget(QWidget *parent);
|
PanelsWidget(QWidget *parent);
|
||||||
~PanelsWidget();
|
~PanelsWidget();
|
||||||
// Adds a widget
|
// Adds a widget
|
||||||
void addWidget(QWidget *widget);
|
void addPropertiesPanel(IPropertiesPanel *panel);
|
||||||
void addWidget(const QString &name, QWidget *widget, const QIcon &icon);
|
|
||||||
|
|
||||||
QWidget *rootWidget() const;
|
|
||||||
|
|
||||||
// Removes all widgets and deletes them
|
|
||||||
void clear();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct Panel
|
void addPanelWidget(IPropertiesPanel *panel, int row);
|
||||||
{
|
|
||||||
// This does not take ownership of widget!
|
|
||||||
explicit Panel(QWidget *widget);
|
|
||||||
~Panel();
|
|
||||||
|
|
||||||
QLabel *iconLabel;
|
|
||||||
QWidget *lineWidget;
|
|
||||||
QLabel *nameLabel;
|
|
||||||
QWidget *panelWidget;
|
|
||||||
};
|
|
||||||
QList<Panel *> m_panels;
|
|
||||||
|
|
||||||
void addPanelWidget(Panel *panel, int row);
|
|
||||||
|
|
||||||
|
QList<IPropertiesPanel *> m_panels;
|
||||||
QGridLayout *m_layout;
|
QGridLayout *m_layout;
|
||||||
QWidget *m_root;
|
QWidget *m_root;
|
||||||
};
|
};
|
||||||
|
|
||||||
class BuildConfigurationComboBox : public QStackedWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
BuildConfigurationComboBox(ProjectExplorer::Project *p, QWidget *parent = 0);
|
|
||||||
~BuildConfigurationComboBox();
|
|
||||||
private slots:
|
|
||||||
void displayNameChanged();
|
|
||||||
void activeConfigurationChanged();
|
|
||||||
void addedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
|
||||||
void removedBuildConfiguration(ProjectExplorer::BuildConfiguration *bc);
|
|
||||||
void changedIndex(int newIndex);
|
|
||||||
private:
|
|
||||||
int buildConfigurationToIndex(BuildConfiguration *bc);
|
|
||||||
bool ignoreIndexChange;
|
|
||||||
ProjectExplorer::Project *m_project;
|
|
||||||
QComboBox *m_comboBox;
|
|
||||||
QLabel *m_label;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ActiveConfigurationWidget : public QWidget
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ActiveConfigurationWidget(QWidget *parent = 0);
|
|
||||||
~ActiveConfigurationWidget();
|
|
||||||
private slots:
|
|
||||||
void projectAdded(ProjectExplorer::Project*);
|
|
||||||
void projectRemoved(ProjectExplorer::Project*);
|
|
||||||
private:
|
|
||||||
QMap<ProjectExplorer::Project *, QPair<BuildConfigurationComboBox *, QLabel *> > m_buildComboBoxMap;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RunConfigurationComboBox : public QComboBox
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
RunConfigurationComboBox(QWidget *parent = 0);
|
|
||||||
~RunConfigurationComboBox();
|
|
||||||
private slots:
|
|
||||||
void activeRunConfigurationChanged();
|
|
||||||
void activeItemChanged(int);
|
|
||||||
void addedRunConfiguration(ProjectExplorer::RunConfiguration *);
|
|
||||||
void removedRunConfiguration(ProjectExplorer::RunConfiguration *);
|
|
||||||
void projectAdded(ProjectExplorer::Project*);
|
|
||||||
void projectRemoved(ProjectExplorer::Project*);
|
|
||||||
void rebuildTree();
|
|
||||||
private:
|
|
||||||
int convertTreeIndexToInt(int project, int runconfigurationIndex);
|
|
||||||
QPair<int, int> convertIntToTreeIndex(int index);
|
|
||||||
void connectToProject(ProjectExplorer::Project *p);
|
|
||||||
void disconnectFromProject(ProjectExplorer::Project *p);
|
|
||||||
|
|
||||||
bool m_ignoreChange;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ProjectLabel : public QLabel
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ProjectLabel(QWidget *parent);
|
|
||||||
~ProjectLabel();
|
|
||||||
public slots:
|
|
||||||
void setProject(ProjectExplorer::Project *);
|
|
||||||
};
|
|
||||||
|
|
||||||
class ProjectPushButton : public QPushButton
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
public:
|
|
||||||
ProjectPushButton(QWidget *parent);
|
|
||||||
~ProjectPushButton();
|
|
||||||
signals:
|
|
||||||
void projectChanged(ProjectExplorer::Project *);
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void projectAdded(ProjectExplorer::Project*);
|
|
||||||
void projectRemoved(ProjectExplorer::Project*);
|
|
||||||
void actionTriggered();
|
|
||||||
private:
|
|
||||||
QMenu *m_menu;
|
|
||||||
};
|
|
||||||
|
|
||||||
class ProjectWindow : public QWidget
|
class ProjectWindow : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
@@ -180,22 +84,20 @@ public:
|
|||||||
explicit ProjectWindow(QWidget *parent = 0);
|
explicit ProjectWindow(QWidget *parent = 0);
|
||||||
~ProjectWindow();
|
~ProjectWindow();
|
||||||
|
|
||||||
|
void shutdown();
|
||||||
private slots:
|
private slots:
|
||||||
void showProperties(ProjectExplorer::Project *project);
|
void showProperties(int index, int subIndex);
|
||||||
void restoreStatus();
|
void restoreStatus();
|
||||||
void saveStatus();
|
void saveStatus();
|
||||||
void projectAdded();
|
void projectAdded(ProjectExplorer::Project*);
|
||||||
void projectRemoved();
|
void aboutToRemoveProject(ProjectExplorer::Project*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void updateRunConfigurationsComboBox();
|
DoubleTabWidget *m_tabWidget;
|
||||||
|
QWidget *m_noprojectLabel;
|
||||||
ActiveConfigurationWidget *m_activeConfigurationWidget;
|
QStackedWidget *m_centralWidget;
|
||||||
QWidget *m_spacerBetween;
|
|
||||||
QWidget *m_projectChooser;
|
|
||||||
QLabel *m_noprojectLabel;
|
|
||||||
PanelsWidget *m_panelsWidget;
|
PanelsWidget *m_panelsWidget;
|
||||||
QList<IPropertiesPanel *> m_panels;
|
QList<ProjectExplorer::Project *> m_tabIndexToProject;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -89,6 +89,11 @@ using ExtensionSystem::PluginManager;
|
|||||||
/// RunSettingsPanelFactory
|
/// RunSettingsPanelFactory
|
||||||
///
|
///
|
||||||
|
|
||||||
|
QString RunSettingsPanelFactory::displayName() const
|
||||||
|
{
|
||||||
|
return QApplication::tr("Run Settings");
|
||||||
|
}
|
||||||
|
|
||||||
bool RunSettingsPanelFactory::supports(Project * /* project */)
|
bool RunSettingsPanelFactory::supports(Project * /* project */)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ class RunSettingsWidget;
|
|||||||
class RunSettingsPanelFactory : public IPanelFactory
|
class RunSettingsPanelFactory : public IPanelFactory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual bool supports(Project *project);
|
QString displayName() const;
|
||||||
|
bool supports(Project *project);
|
||||||
IPropertiesPanel *createPanel(Project *project);
|
IPropertiesPanel *createPanel(Project *project);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user