Commit dbe5a6f3 authored by dt's avatar dt
Browse files

Rework the project settings.

This has still a few missing things, but this enough to start getting
some feedback. Missing are non qt projects, a solution for the
runconfiguration, a missing black line between the treeview on top and
the project settings at the bottom. Some flickering with removing/adding
widgets to the QScrollArea and not showing the expanded widget if the
Details button is right at the bottom.
parent 4e788157
...@@ -40,7 +40,7 @@ using namespace CMakeProjectManager; ...@@ -40,7 +40,7 @@ using namespace CMakeProjectManager;
using namespace CMakeProjectManager::Internal; using namespace CMakeProjectManager::Internal;
CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project) CMakeBuildEnvironmentWidget::CMakeBuildEnvironmentWidget(CMakeProject *project)
: BuildStepConfigWidget(), m_pro(project) : BuildConfigWidget(), m_pro(project)
{ {
QVBoxLayout *vbox = new QVBoxLayout(this); QVBoxLayout *vbox = new QVBoxLayout(this);
vbox->setMargin(0); vbox->setMargin(0);
......
...@@ -43,7 +43,7 @@ namespace CMakeProjectManager { ...@@ -43,7 +43,7 @@ namespace CMakeProjectManager {
namespace Internal { namespace Internal {
class CMakeProject; class CMakeProject;
class CMakeBuildEnvironmentWidget : public ProjectExplorer::BuildStepConfigWidget class CMakeBuildEnvironmentWidget : public ProjectExplorer::BuildConfigWidget
{ {
Q_OBJECT Q_OBJECT
......
...@@ -512,14 +512,14 @@ QString CMakeProject::buildDirectory(const QString &buildConfiguration) const ...@@ -512,14 +512,14 @@ QString CMakeProject::buildDirectory(const QString &buildConfiguration) const
return buildDirectory; return buildDirectory;
} }
ProjectExplorer::BuildStepConfigWidget *CMakeProject::createConfigWidget() ProjectExplorer::BuildConfigWidget *CMakeProject::createConfigWidget()
{ {
return new CMakeBuildSettingsWidget(this); return new CMakeBuildSettingsWidget(this);
} }
QList<ProjectExplorer::BuildStepConfigWidget*> CMakeProject::subConfigWidgets() QList<ProjectExplorer::BuildConfigWidget*> CMakeProject::subConfigWidgets()
{ {
QList<ProjectExplorer::BuildStepConfigWidget*> list; QList<ProjectExplorer::BuildConfigWidget*> list;
list << new CMakeBuildEnvironmentWidget(this); list << new CMakeBuildEnvironmentWidget(this);
return list; return list;
} }
......
...@@ -89,8 +89,8 @@ public: ...@@ -89,8 +89,8 @@ public:
virtual QString buildDirectory(const QString &buildConfiguration) const; virtual QString buildDirectory(const QString &buildConfiguration) const;
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual ProjectExplorer::BuildConfigWidget *createConfigWidget();
virtual QList<ProjectExplorer::BuildStepConfigWidget*> subConfigWidgets(); virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
// This method is called for new build configurations // This method is called for new build configurations
// You should probably set some default values in this method // You should probably set some default values in this method
...@@ -204,7 +204,7 @@ private: ...@@ -204,7 +204,7 @@ private:
QString m_fileName; QString m_fileName;
}; };
class CMakeBuildSettingsWidget : public ProjectExplorer::BuildStepConfigWidget class CMakeBuildSettingsWidget : public ProjectExplorer::BuildConfigWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
......
...@@ -145,6 +145,18 @@ void MakeStep::setAdditionalArguments(const QString &buildConfiguration, const Q ...@@ -145,6 +145,18 @@ void MakeStep::setAdditionalArguments(const QString &buildConfiguration, const Q
setValue(buildConfiguration, "additionalArguments", list); setValue(buildConfiguration, "additionalArguments", list);
} }
// TODO
//QString MakeStep::oneLineSummary(const QString &buildConfiguration)
//{
// QStringList arguments = value(buildConfiguration, "buildTargets").toStringList();
// arguments << additionalArguments(buildConfiguration);
// return tr("<b>%1 %2</b> in %3").arg(
// m_pro->toolChain(buildConfiguration)->makeCommand(),
// arguments.join(" "),
// m_pro->buildDirectory(buildConfiguration));
//
//}
// //
// MakeStepConfigWidget // MakeStepConfigWidget
// //
...@@ -214,6 +226,12 @@ void MakeStepConfigWidget::init(const QString &buildConfiguration) ...@@ -214,6 +226,12 @@ void MakeStepConfigWidget::init(const QString &buildConfiguration)
m_additionalArguments->setText(ProjectExplorer::Environment::joinArgumentList(m_makeStep->additionalArguments(m_buildConfiguration))); m_additionalArguments->setText(ProjectExplorer::Environment::joinArgumentList(m_makeStep->additionalArguments(m_buildConfiguration)));
} }
QString MakeStepConfigWidget::summaryText() const
{
// TODO
return tr("<b>Make:</b>");
}
// //
// MakeStepFactory // MakeStepFactory
// //
......
...@@ -78,6 +78,7 @@ public: ...@@ -78,6 +78,7 @@ public:
MakeStepConfigWidget(MakeStep *makeStep); MakeStepConfigWidget(MakeStep *makeStep);
virtual QString displayName() const; virtual QString displayName() const;
virtual void init(const QString &buildConfiguration); virtual void init(const QString &buildConfiguration);
virtual QString summaryText() const;
private slots: private slots:
void itemChanged(QListWidgetItem*); void itemChanged(QListWidgetItem*);
void additionalArgumentsEdited(); void additionalArgumentsEdited();
......
...@@ -193,6 +193,12 @@ void GenericMakeStepConfigWidget::init(const QString &buildConfiguration) ...@@ -193,6 +193,12 @@ void GenericMakeStepConfigWidget::init(const QString &buildConfiguration)
connect(m_ui->targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*))); connect(m_ui->targetsList, SIGNAL(itemChanged(QListWidgetItem*)), this, SLOT(itemChanged(QListWidgetItem*)));
} }
QString GenericMakeStepConfigWidget::summaryText() const
{
// TODO
return tr("<b>Make:</b>");
}
void GenericMakeStepConfigWidget::itemChanged(QListWidgetItem *item) void GenericMakeStepConfigWidget::itemChanged(QListWidgetItem *item)
{ {
QTC_ASSERT(!m_buildConfiguration.isNull(), return); QTC_ASSERT(!m_buildConfiguration.isNull(), return);
......
...@@ -73,6 +73,7 @@ public: ...@@ -73,6 +73,7 @@ public:
GenericMakeStepConfigWidget(GenericMakeStep *makeStep); GenericMakeStepConfigWidget(GenericMakeStep *makeStep);
virtual QString displayName() const; virtual QString displayName() const;
virtual void init(const QString &buildConfiguration); virtual void init(const QString &buildConfiguration);
virtual QString summaryText() const;
private slots: private slots:
void itemChanged(QListWidgetItem*); void itemChanged(QListWidgetItem*);
void makeLineEditTextEdited(); void makeLineEditTextEdited();
......
...@@ -427,14 +427,14 @@ QString GenericProject::buildDirectory(const QString &buildConfiguration) const ...@@ -427,14 +427,14 @@ QString GenericProject::buildDirectory(const QString &buildConfiguration) const
return buildDirectory; return buildDirectory;
} }
ProjectExplorer::BuildStepConfigWidget *GenericProject::createConfigWidget() ProjectExplorer::BuildConfigWidget *GenericProject::createConfigWidget()
{ {
return new GenericBuildSettingsWidget(this); return new GenericBuildSettingsWidget(this);
} }
QList<ProjectExplorer::BuildStepConfigWidget*> GenericProject::subConfigWidgets() QList<ProjectExplorer::BuildConfigWidget*> GenericProject::subConfigWidgets()
{ {
return QList<ProjectExplorer::BuildStepConfigWidget*>(); return QList<ProjectExplorer::BuildConfigWidget*>();
} }
void GenericProject::newBuildConfiguration(const QString &buildConfiguration) void GenericProject::newBuildConfiguration(const QString &buildConfiguration)
......
...@@ -82,8 +82,8 @@ public: ...@@ -82,8 +82,8 @@ public:
virtual ProjectExplorer::Environment environment(const QString &buildConfiguration) const; virtual ProjectExplorer::Environment environment(const QString &buildConfiguration) const;
virtual QString buildDirectory(const QString &buildConfiguration) const; virtual QString buildDirectory(const QString &buildConfiguration) const;
virtual ProjectExplorer::BuildStepConfigWidget *createConfigWidget(); virtual ProjectExplorer::BuildConfigWidget *createConfigWidget();
virtual QList<ProjectExplorer::BuildStepConfigWidget*> subConfigWidgets(); virtual QList<ProjectExplorer::BuildConfigWidget*> subConfigWidgets();
virtual void newBuildConfiguration(const QString &buildConfiguration); virtual void newBuildConfiguration(const QString &buildConfiguration);
virtual GenericProjectNode *rootProjectNode() const; virtual GenericProjectNode *rootProjectNode() const;
...@@ -172,7 +172,7 @@ private: ...@@ -172,7 +172,7 @@ private:
QString m_fileName; QString m_fileName;
}; };
class GenericBuildSettingsWidget : public ProjectExplorer::BuildStepConfigWidget class GenericBuildSettingsWidget : public ProjectExplorer::BuildConfigWidget
{ {
Q_OBJECT Q_OBJECT
......
...@@ -212,14 +212,14 @@ void BuildSettingsWidget::updateBuildSettings() ...@@ -212,14 +212,14 @@ void BuildSettingsWidget::updateBuildSettings()
m_removeButton->setEnabled(m_project->buildConfigurations().size() > 1); m_removeButton->setEnabled(m_project->buildConfigurations().size() > 1);
// Add pages // Add pages
BuildStepConfigWidget *generalConfigWidget = m_project->createConfigWidget(); BuildConfigWidget *generalConfigWidget = m_project->createConfigWidget();
m_subWidgets->addWidget(generalConfigWidget->displayName(), generalConfigWidget); m_subWidgets->addWidget(generalConfigWidget->displayName(), generalConfigWidget);
m_subWidgets->addWidget(tr("Build Steps"), new BuildStepsPage(m_project)); m_subWidgets->addWidget(tr("Build Steps"), new BuildStepsPage(m_project));
m_subWidgets->addWidget(tr("Clean Steps"), new BuildStepsPage(m_project, true)); m_subWidgets->addWidget(tr("Clean Steps"), new BuildStepsPage(m_project, true));
QList<BuildStepConfigWidget *> subConfigWidgets = m_project->subConfigWidgets(); QList<BuildConfigWidget *> subConfigWidgets = m_project->subConfigWidgets();
foreach (BuildStepConfigWidget *subConfigWidget, subConfigWidgets) foreach (BuildConfigWidget *subConfigWidget, subConfigWidgets)
m_subWidgets->addWidget(subConfigWidget->displayName(), subConfigWidget); m_subWidgets->addWidget(subConfigWidget->displayName(), subConfigWidget);
// Add tree items // Add tree items
...@@ -254,7 +254,7 @@ void BuildSettingsWidget::activeBuildConfigurationChanged() ...@@ -254,7 +254,7 @@ void BuildSettingsWidget::activeBuildConfigurationChanged()
} }
} }
foreach (QWidget *widget, m_subWidgets->widgets()) { foreach (QWidget *widget, m_subWidgets->widgets()) {
if (BuildStepConfigWidget *buildStepWidget = qobject_cast<BuildStepConfigWidget*>(widget)) { if (BuildConfigWidget *buildStepWidget = qobject_cast<BuildConfigWidget*>(widget)) {
buildStepWidget->init(activeBuildConfiguration); buildStepWidget->init(activeBuildConfiguration);
} }
} }
......
...@@ -131,8 +131,6 @@ Q_SIGNALS: ...@@ -131,8 +131,6 @@ Q_SIGNALS:
void addToTaskWindow(const QString &filename, int type, int linenumber, const QString &description); void addToTaskWindow(const QString &filename, int type, int linenumber, const QString &description);
void addToOutputWindow(const QString &string); void addToOutputWindow(const QString &string);
void displayNameChanged(BuildStep *, const QString &displayName);
private: private:
QList<Internal::BuildConfiguration *> buildConfigurations(); QList<Internal::BuildConfiguration *> buildConfigurations();
void addBuildConfiguration(const QString & name); void addBuildConfiguration(const QString & name);
...@@ -164,22 +162,34 @@ public: ...@@ -164,22 +162,34 @@ public:
virtual QString displayNameForName(const QString &name) const = 0; virtual QString displayNameForName(const QString &name) const = 0;
}; };
class PROJECTEXPLORER_EXPORT BuildStepConfigWidget class PROJECTEXPLORER_EXPORT BuildConfigWidget
: public QWidget : public QWidget
{ {
Q_OBJECT Q_OBJECT
public: public:
BuildStepConfigWidget() BuildConfigWidget()
:QWidget(0) :QWidget(0)
{} {}
virtual QString displayName() const = 0; virtual QString displayName() const = 0;
// This is called to set up the config widget before showing it // This is called to set up the config widget before showing it
// buildConfiguration is QString::null for the non buildConfiguration specific page
virtual void init(const QString &buildConfiguration) = 0; virtual void init(const QString &buildConfiguration) = 0;
}; };
class PROJECTEXPLORER_EXPORT BuildStepConfigWidget
: public BuildConfigWidget
{
Q_OBJECT
public:
BuildStepConfigWidget()
: BuildConfigWidget()
{}
virtual QString summaryText() const = 0;
signals:
void updateSummary();
};
} // namespace ProjectExplorer } // namespace ProjectExplorer
#endif // BUILDSTEP_H #endif // BUILDSTEP_H
...@@ -36,67 +36,80 @@ ...@@ -36,67 +36,80 @@
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <QtGui/QLabel>
#include <QtGui/QPushButton>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace ProjectExplorer::Internal; using namespace ProjectExplorer::Internal;
BuildStepsPage::BuildStepsPage(Project *project, bool clean) : BuildStepsPage::BuildStepsPage(Project *project, bool clean) :
BuildStepConfigWidget(), BuildConfigWidget(),
m_ui(new Ui::BuildStepsPage),
m_pro(project), m_pro(project),
m_clean(clean) m_clean(clean)
{ {
m_ui->setupUi(this); m_vbox = new QVBoxLayout(this);
m_vbox->setContentsMargins(20, 0, 0, 0);
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps();
foreach (BuildStep *bs, steps) {
addBuildStepWidget(-1, bs);
}
m_ui->buildStepAddButton->setMenu(new QMenu(this)); m_noStepsLabel = new QLabel(tr("No Build Steps"), this);
m_ui->buildStepAddButton->setIcon(QIcon(Core::Constants::ICON_PLUS)); m_noStepsLabel->setVisible(steps.isEmpty());
m_ui->buildStepRemoveToolButton->setIcon(QIcon(Core::Constants::ICON_MINUS)); m_vbox->addWidget(m_noStepsLabel);
m_ui->buildStepUpToolButton->setArrowType(Qt::UpArrow);
m_ui->buildStepDownToolButton->setArrowType(Qt::DownArrow);
connect(m_ui->buildSettingsList, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), QHBoxLayout *hboxLayout = new QHBoxLayout();
this, SLOT(updateBuildStepWidget(QTreeWidgetItem *, QTreeWidgetItem *))); m_addButton = new QPushButton(this);
m_addButton->setText(tr("Add build step"));
m_addButton->setMenu(new QMenu(this));
hboxLayout->addWidget(m_addButton);
connect(m_ui->buildStepAddButton->menu(), SIGNAL(aboutToShow()), m_removeButton = new QPushButton(this);
this, SLOT(updateAddBuildStepMenu())); m_removeButton->setText(tr("Remove build step"));
m_removeButton->setMenu(new QMenu(this));
hboxLayout->addWidget(m_removeButton);
hboxLayout->addStretch(10);
connect(m_ui->buildStepAddButton, SIGNAL(clicked()), m_vbox->addLayout(hboxLayout);
this, SLOT(addBuildStep()));
connect(m_ui->buildStepRemoveToolButton, SIGNAL(clicked()),
this, SLOT(removeBuildStep()));
connect(m_ui->buildStepUpToolButton, SIGNAL(clicked()),
this, SLOT(upBuildStep()));
connect(m_ui->buildStepDownToolButton, SIGNAL(clicked()),
this, SLOT(downBuildStep()));
// Remove dummy pages updateBuildStepButtonsState();
while (QWidget *widget = m_ui->buildSettingsWidget->currentWidget()) {
m_ui->buildSettingsWidget->removeWidget(widget);
delete widget;
}
// Add buildsteps connect(m_addButton->menu(), SIGNAL(aboutToShow()),
const QList<BuildStep *> &steps = m_clean ? m_pro->cleanSteps() : m_pro->buildSteps(); this, SLOT(updateAddBuildStepMenu()));
foreach (BuildStep *bs, steps) {
connect(bs, SIGNAL(displayNameChanged(BuildStep *, QString)),
this, SLOT(displayNameChanged(BuildStep *,QString)));
QTreeWidgetItem *buildStepItem = new QTreeWidgetItem(); connect(m_removeButton->menu(), SIGNAL(aboutToShow()),
buildStepItem->setText(0, bs->displayName()); this, SLOT(updateRemoveBuildStepMenu()));
m_ui->buildSettingsWidget->addWidget(bs->createConfigWidget());
m_ui->buildSettingsList->invisibleRootItem()->addChild(buildStepItem);
}
} }
BuildStepsPage::~BuildStepsPage() BuildStepsPage::~BuildStepsPage()
{ {
// Also deletes all added widgets foreach(BuildStepsWidgetStruct s, m_buildSteps) {
delete m_ui; delete s.detailsLabel;
delete s.upButton;
delete s.downButton;
delete s.detailsButton;
delete s.hbox;
delete s.widget;
}
m_buildSteps.clear();
} }
void BuildStepsPage::displayNameChanged(BuildStep *bs, const QString & /* displayName */) void BuildStepsPage::toggleDetails()
{ {
int index = m_clean ? m_pro->cleanSteps().indexOf(bs) : m_pro->buildSteps().indexOf(bs); QToolButton *tb = qobject_cast<QToolButton *>(sender());
m_ui->buildSettingsList->invisibleRootItem()->child(index)->setText(0, bs->displayName()); if (tb)
foreach(const BuildStepsWidgetStruct &s, m_buildSteps)
if (s.detailsButton == tb)
s.widget->setVisible(!s.widget->isVisible());
}
void BuildStepsPage::updateSummary()
{
BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(sender());
if (widget)
foreach(const BuildStepsWidgetStruct &s, m_buildSteps)
if (s.widget == widget)
s.detailsLabel->setText(widget->summaryText());
} }
QString BuildStepsPage::displayName() const QString BuildStepsPage::displayName() const
...@@ -108,33 +121,13 @@ void BuildStepsPage::init(const QString &buildConfiguration) ...@@ -108,33 +121,13 @@ void BuildStepsPage::init(const QString &buildConfiguration)
{ {
m_configuration = buildConfiguration; m_configuration = buildConfiguration;
m_ui->buildSettingsList->setCurrentItem(m_ui->buildSettingsList->invisibleRootItem()->child(0));
// make sure widget is updated // make sure widget is updated
if (m_ui->buildSettingsWidget->currentWidget()) { foreach(BuildStepsWidgetStruct s, m_buildSteps) {
BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(m_ui->buildSettingsWidget->currentWidget()); s.widget->init(m_configuration);
widget->init(m_configuration); s.detailsLabel->setText(s.widget->summaryText());
} }
} }
/* switch from one tree item / build step to another */
void BuildStepsPage::updateBuildStepWidget(QTreeWidgetItem *newItem, QTreeWidgetItem *oldItem)
{
if (oldItem == newItem)
return;
Q_ASSERT(m_pro);
if (newItem) {
int row = m_ui->buildSettingsList->indexOfTopLevelItem(newItem);
m_ui->buildSettingsWidget->setCurrentIndex(row);
m_ui->groupBox->setTitle(newItem->text(0));
BuildStepConfigWidget *widget = qobject_cast<BuildStepConfigWidget *>(m_ui->buildSettingsWidget->currentWidget());
Q_ASSERT(widget);
widget->init(m_configuration);
}
updateBuildStepButtonsState();
}
void BuildStepsPage::updateAddBuildStepMenu() void BuildStepsPage::updateAddBuildStepMenu()
{ {
QMap<QString, QPair<QString, IBuildStepFactory *> > map; QMap<QString, QPair<QString, IBuildStepFactory *> > map;
...@@ -148,7 +141,7 @@ void BuildStepsPage::updateAddBuildStepMenu() ...@@ -148,7 +141,7 @@ void BuildStepsPage::updateAddBuildStepMenu()
} }
// Ask the user which one to add // Ask the user which one to add
QMenu *menu = m_ui->buildStepAddButton->menu(); QMenu *menu = m_addButton->menu();
m_addBuildStepHash.clear(); m_addBuildStepHash.clear();
menu->clear(); menu->clear();
if (!map.isEmpty()) { if (!map.isEmpty()) {
...@@ -164,119 +157,165 @@ void BuildStepsPage::updateAddBuildStepMenu() ...@@ -164,119 +157,165 @@ void BuildStepsPage::updateAddBuildStepMenu()
} }
} }
void BuildStepsPage::addBuildStepWidget(int pos, BuildStep *step)
{
// create everything
BuildStepsWidgetStruct s;
s.widget = step->createConfigWidget();
s.detailsLabel = new QLabel(this);
s.detailsLabel->setText(s.widget->summaryText());
s.upButton = new QToolButton(this);
s.upButton->setArrowType(Qt::UpArrow);
s.downButton = new QToolButton(this);
s.downButton->setArrowType(Qt::DownArrow);
s.detailsButton = new QToolButton(this);
s.detailsButton->setText(tr("Details"));
// layout
s.hbox = new QHBoxLayout();
s.hbox->addWidget(s.detailsLabel);
s.hbox->addWidget(s.upButton);
s.hbox->addWidget(s.downButton);
s.hbox->addWidget(s.detailsButton);
if (pos == -1)
m_buildSteps.append(s);
else
m_buildSteps.insert(pos, s);
if (pos == -1) {
m_vbox->addLayout(s.hbox);
m_vbox->addWidget(s.widget);
} else {
m_vbox->insertLayout(pos *2, s.hbox);
m_vbox->insertWidget(pos *2 + 1, s.widget);
}
s.widget->hide();